diff --git a/.gitignore b/.gitignore index a1164f2..6101275 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,7 @@ lib-cov *.pid *.gz *.swp - +.nyc_output pids logs results @@ -26,3 +26,5 @@ bower_components # OS metadata .DS_Store Thumbs.db + +coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index 734cf89..658a156 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +### 24/01/17 - Version 1.0.3 + - Add user inputed gates to applyGate() and generateGate() + - Switch to Sparse matrices for quicker operation + - General Bug Fixes + ### 23/01/17 - Version 1.0.2 - Change to standard Math.js module - Add Docco Documentation diff --git a/README.md b/README.md index 3dc743b..d7ad92b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Qics - _Quantum Idealistic Computer Simulator_ -[![Greenkeeper badge](https://badges.greenkeeper.io/adamisntdead/qics.svg)](https://greenkeeper.io/) - [![GitHub issues](https://img.shields.io/github/issues/adamisntdead/qics.svg)](https://github.com/adamisntdead/qics/issues) [![GitHub license](https://img.shields.io/badge/license-Apache%202-blue.svg)](https://raw.githubusercontent.com/adamisntdead/qics/master/LICENSE) [![Travis](https://img.shields.io/travis/adamisntdead/qics.svg)](https://travis-ci.org/adamisntdead/qics) [![npm](https://img.shields.io/npm/v/qics.svg)](https://www.npmjs.com/package/qics) +[![Greenkeeper badge](https://badges.greenkeeper.io/adamisntdead/qics.svg)](https://greenkeeper.io/) + Qics is an Idealistic, Quantum Computer Simulation Library. It works by holding a Quantum Register as a Matrix, @@ -57,7 +57,7 @@ __Example simulation:__ const qics = require('qics'); // Create a new Quantum Register with 3 Qubits -const reg = new qicks.Register(3); +const reg = new qics.Register(3); // Apply some gates. // Hadamard Gate @@ -70,6 +70,23 @@ reg.applyGate('CNOT', 1, 3) ; console.log(reg.measure()); ``` +You can also use your own gates, by inputing them as an Array or Math.Matrix object +to the applyGate function. + +```javascript +// Manually Add A NOT Gate + +const reg = new qics.Register(2); + +reg.applyGate([ + [0, 1], + [1, 0] +], 1); + + +// Now measure the register. Should return either "10" +console.log(reg.measure()); +``` *** ### Documentation @@ -84,6 +101,8 @@ To deploy the docs to the github pages, run ```shell git subtree push --prefix docs origin gh-pages ``` +To build the docs, run `npm run docs`. + *** ### Build diff --git a/ROADMAP.md b/ROADMAP.md new file mode 100644 index 0000000..a4453dd --- /dev/null +++ b/ROADMAP.md @@ -0,0 +1,11 @@ +# Roadmap / Planned Changes +*** +### Features +- Output to latex +- Draw Gate Diagrams +- Qudits +- Benchmarks +- Custom Programming Language / Parser +- Extra Gates (i.e. Swap, Toffoli) +- Quantum Functions (i.e. Grover Search) +- State Dump for debugging programs diff --git a/dist/qics.js b/dist/qics.js index e53676f..266429d 100644 --- a/dist/qics.js +++ b/dist/qics.js @@ -47,7 +47,7 @@ var qics = 'use strict'; - var gates = __webpack_require__(79); + var gates = __webpack_require__(80); var Register = __webpack_require__(138); // Exports the Gates class and the Register Class @@ -187,7 +187,7 @@ var qics = 'use strict'; - var NumberFormatter = __webpack_require__(504); + var NumberFormatter = __webpack_require__(505); /** * Test whether value is a number @@ -2462,7 +2462,7 @@ var qics = 'use strict'; - var keywords = __webpack_require__(62); + var keywords = __webpack_require__(63); var extend = __webpack_require__(5).extend; var deepEqual= __webpack_require__(5).deepEqual; @@ -3221,7 +3221,7 @@ var qics = var latex = __webpack_require__(4); var algorithm01 = load(__webpack_require__(28)); - var algorithm04 = load(__webpack_require__(74)); + var algorithm04 = load(__webpack_require__(75)); var algorithm10 = load(__webpack_require__(31)); var algorithm13 = load(__webpack_require__(7)); var algorithm14 = load(__webpack_require__(6)); @@ -3710,7 +3710,7 @@ var qics = 'use strict'; var formatNumber = __webpack_require__(3).format; - var formatBigNumber = __webpack_require__(508).format; + var formatBigNumber = __webpack_require__(509).format; /** * Test whether value is a string @@ -4177,7 +4177,7 @@ var qics = 'use strict'; exports.array = __webpack_require__(8); - exports['boolean'] = __webpack_require__(511); + exports['boolean'] = __webpack_require__(512); exports['function'] = __webpack_require__(34); exports.number = __webpack_require__(3); exports.object = __webpack_require__(5); @@ -4714,7 +4714,7 @@ var qics = function factory (type, config, load, typed) { var AccessorNode = load(__webpack_require__(86)); - var ArrayNode = load(__webpack_require__(63)); + var ArrayNode = load(__webpack_require__(64)); var AssignmentNode = load(__webpack_require__(87)); var BlockNode = load(__webpack_require__(88)); var ConditionalNode = load(__webpack_require__(89)); @@ -4725,7 +4725,7 @@ var qics = var OperatorNode = load(__webpack_require__(49)); var ParenthesisNode = load(__webpack_require__(50)); var FunctionNode = load(__webpack_require__(45)); - var RangeNode = load(__webpack_require__(64)); + var RangeNode = load(__webpack_require__(65)); var SymbolNode = load(__webpack_require__(25)); @@ -6638,11 +6638,11 @@ var qics = function factory (type, config, load, typed) { var latex = __webpack_require__(4); - var eye = load(__webpack_require__(67)); + var eye = load(__webpack_require__(68)); var multiply = load(__webpack_require__(11)); var matrix = load(__webpack_require__(2)); var fraction = load(__webpack_require__(128)); - var number = load(__webpack_require__(76)); + var number = load(__webpack_require__(77)); /** * Calculates the power of x to y, `x ^ y`. @@ -10079,7 +10079,7 @@ var qics = 'use strict'; - var scatter = __webpack_require__(512); + var scatter = __webpack_require__(513); var DimensionError = __webpack_require__(10); function factory (type, config, load, typed) { @@ -10417,6 +10417,50 @@ var qics = /***/ }, /* 62 */ +/***/ function(module, exports, __webpack_require__) { + + var core = __webpack_require__(143); + + /** + * math.js factory function. Creates a new instance of math.js + * + * @param {Object} [config] Available configuration options: + * {number} epsilon + * Minimum relative difference between two + * compared values, used by all comparison functions. + * {string} matrix + * A string 'matrix' (default) or 'array'. + * {string} number + * A string 'number' (default), 'bignumber', or + * 'fraction' + * {number} precision + * The number of significant digits for BigNumbers. + * Not applicable for Numbers. + * {boolean} predictable + * Predictable output type of functions. When true, + * output type depends only on the input types. When + * false (default), output type can vary depending + * on input values. For example `math.sqrt(-2)` + * returns `NaN` when predictable is false, and + * returns `complex('2i')` when true. + */ + function create (config) { + // create a new math.js instance + var math = core.create(config); + math.create = create; + + // import data types, functions, constants, expression parser, etc. + math['import'](__webpack_require__(475)); + + return math; + } + + // return a new instance of math.js + module.exports = create(); + + +/***/ }, +/* 63 */ /***/ function(module, exports) { 'use strict'; @@ -10428,7 +10472,7 @@ var qics = /***/ }, -/* 63 */ +/* 64 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -10571,7 +10615,7 @@ var qics = /***/ }, -/* 64 */ +/* 65 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -10789,7 +10833,7 @@ var qics = /***/ }, -/* 65 */ +/* 66 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -10956,7 +11000,7 @@ var qics = exports.factory = factory; /***/ }, -/* 66 */ +/* 67 */ /***/ function(module, exports) { 'use strict'; @@ -10984,7 +11028,7 @@ var qics = /***/ }, -/* 67 */ +/* 68 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11136,7 +11180,7 @@ var qics = /***/ }, -/* 68 */ +/* 69 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11221,7 +11265,7 @@ var qics = /***/ }, -/* 69 */ +/* 70 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11363,7 +11407,7 @@ var qics = /***/ }, -/* 70 */ +/* 71 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11665,7 +11709,7 @@ var qics = /***/ }, -/* 71 */ +/* 72 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11840,7 +11884,7 @@ var qics = /***/ }, -/* 72 */ +/* 73 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -11899,7 +11943,7 @@ var qics = /***/ }, -/* 73 */ +/* 74 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12157,7 +12201,7 @@ var qics = /***/ }, -/* 74 */ +/* 75 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12350,7 +12394,7 @@ var qics = /***/ }, -/* 75 */ +/* 76 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12516,7 +12560,7 @@ var qics = /***/ }, -/* 76 */ +/* 77 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12601,7 +12645,7 @@ var qics = /***/ }, -/* 77 */ +/* 78 */ /***/ function(module, exports) { /** @@ -12628,10 +12672,10 @@ var qics = /***/ }, -/* 78 */ +/* 79 */ /***/ function(module, exports, __webpack_require__) { - var bitNot = __webpack_require__(77); + var bitNot = __webpack_require__(78); /** * Applies bitwise function to numbers @@ -12758,7 +12802,7 @@ var qics = /***/ }, -/* 79 */ +/* 80 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -12767,7 +12811,8 @@ var qics = function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var math = __webpack_require__(80); + var math = __webpack_require__(62); + var helper = __webpack_require__(139); // Complex number i and -i for easy access var i = math.complex(0, 1); @@ -12792,81 +12837,110 @@ var qics = value: function generateGate(gate, numQubits, qubit1) { var qubit2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; - if (gate === 'CNOT') { - // Set the control and target qubits - var control = qubit1; - var target = qubit2; - - // Grab the gates now for easy access in the function - var identity = math.eye(2); - var X = this.X; - - // This matrix is the 'Control Matrix'. At the end of the gate generation, - // the NaN's positions will be evaluated to figure out if it should be a - // a 0 or a 1 - var C = [[NaN, 0], [0, 1]]; - - // Turn the gate order into an array, so that it can be reduced later. - var gateOrder = []; - for (var _i = 1; _i <= numQubits; _i++) { - if (_i === control) { - gateOrder.push(C); - } else if (_i === target) { - gateOrder.push(X); - } else { - gateOrder.push(identity); + if (math.typeof(gate) === 'string') { + if (gate === 'CNOT') { + // Set the control and target qubits + var control = qubit1; + var target = qubit2; + + // Grab the gates now for easy access in the function + var identity = math.eye(2, 'sparse'); + var X = math.matrix(this.X, 'sparse'); + + // This matrix is the 'Control Matrix'. At the end of the gate + // generation, the NaN's positions will be evaluated to figure + // out if it should be a 0 or a 1 + var C = math.matrix([[NaN, 0], [0, 1]], 'sparse'); + + // Turn the gate order into an array, so that it can be reduced later. + var gateOrder = []; + for (var _i = 1; _i <= numQubits; _i++) { + if (_i === control) { + gateOrder.push(C); + } else if (_i === target) { + gateOrder.push(X); + } else { + gateOrder.push(identity); + } } - } - - // Now the gateOrder array is taken and reduced using the - // 'Kronecker Product' - var newGate = gateOrder.reduce(function (a, b) { - return math.kron(a, b); - }); - - // This needs to now be converted into an array if it is - // returned from math.js as a matrix - if (math.typeof(newGate) === 'Matrix') { - newGate = newGate.toArray(); - } - // Loop through the new matrix and if the NaN's are in the - // center, then replace with a 0, otherwise, replace with a 1 - for (var _i2 = 0; _i2 < newGate.length; _i2++) { - for (var j = 0; j < newGate[_i2].length; j++) { - if (math.isNaN(newGate[_i2][j])) { - if (_i2 === j) { - newGate[_i2][j] = 1; + // Now the gateOrder array is taken and reduced using the + // 'Kronecker Product' + var newGate = math.matrix(gateOrder.reduce(function (a, b) { + return math.kron(a, b); + }), 'sparse'); + + // Loop through the new matrix and if the NaN's are in the + // center, then replace with a 0, otherwise, replace with a 1 + newGate = math.map(newGate, function (val, index) { + if (math.isNaN(val)) { + if (index[0] === index[1]) { + return 1; } else { - newGate[_i2][j] = 0; + return 0; } + } else { + return val; + } + }); + + // Return the expanded gate. + return newGate; + } else { + // Put the gates here for easy access + var _identity = math.eye(2, 'sparse'); + var mainGate = math.matrix(this[gate], 'sparse'); + + // Again, Turn the gate order into an array, so that it can be + // reduced later. + var _gateOrder = []; + + for (var _i2 = 1; _i2 <= numQubits; _i2++) { + if (_i2 === qubit1) { + _gateOrder.push(mainGate); + } else { + _gateOrder.push(_identity); } } + + // Reduce and return the expanded gate. + return _gateOrder.reduce(function (a, b) { + return math.kron(a, b); + }); } - // Return the expanded gate. - return newGate; - } else { + } else if (math.typeof(gate) === 'Matrix' || math.typeof(gate) === 'Array') { + // This expand / generates a gate from a user inputed matrix + // Put the gates here for easy access - var _identity = math.eye(2); - var mainGate = this[gate]; + var _identity2 = math.eye(2, 'sparse'); + var _mainGate = math.matrix(gate, 'sparse'); + + // Gate must be unitary so check here + if (!helper.isUnitary(_mainGate)) { + // It's not unitary, throw an Error + throw new Error('The gate supplied to generateGate is not unitary'); + } // Again, Turn the gate order into an array, so that it can be // reduced later. - var _gateOrder = []; + var _gateOrder2 = []; for (var _i3 = 1; _i3 <= numQubits; _i3++) { if (_i3 === qubit1) { - _gateOrder.push(mainGate); + _gateOrder2.push(_mainGate); } else { - _gateOrder.push(_identity); + _gateOrder2.push(_identity2); } } // Reduce and return the expanded gate. - return _gateOrder.reduce(function (a, b) { + return _gateOrder2.reduce(function (a, b) { return math.kron(a, b); }); } + + // Doesn't match a default case, return an Id gate + return math.eye(math.pow(2, numQubits), 'sparse'); } }, { key: 'X', @@ -12940,50 +13014,6 @@ var qics = module.exports = gates; -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { - - var core = __webpack_require__(142); - - /** - * math.js factory function. Creates a new instance of math.js - * - * @param {Object} [config] Available configuration options: - * {number} epsilon - * Minimum relative difference between two - * compared values, used by all comparison functions. - * {string} matrix - * A string 'matrix' (default) or 'array'. - * {string} number - * A string 'number' (default), 'bignumber', or - * 'fraction' - * {number} precision - * The number of significant digits for BigNumbers. - * Not applicable for Numbers. - * {boolean} predictable - * Predictable output type of functions. When true, - * output type depends only on the input types. When - * false (default), output type can vary depending - * on input values. For example `math.sqrt(-2)` - * returns `NaN` when predictable is false, and - * returns `complex('2i')` when true. - */ - function create (config) { - // create a new math.js instance - var math = core.create(config); - math.create = create; - - // import data types, functions, constants, expression parser, etc. - math['import'](__webpack_require__(474)); - - return math; - } - - // return a new instance of math.js - module.exports = create(); - - /***/ }, /* 81 */ /***/ function(module, exports, __webpack_require__) { @@ -13200,39 +13230,39 @@ var qics = // construction functions - docs.bignumber = __webpack_require__(165); - docs['boolean'] = __webpack_require__(166); - docs.complex = __webpack_require__(167); - docs.createUnit = __webpack_require__(168); - docs.fraction = __webpack_require__(169); - docs.index = __webpack_require__(170); - docs.matrix = __webpack_require__(171); - docs.number = __webpack_require__(172); - docs.sparse = __webpack_require__(173); - docs.splitUnit = __webpack_require__(174); - docs.string = __webpack_require__(175); - docs.unit = __webpack_require__(176); + docs.bignumber = __webpack_require__(166); + docs['boolean'] = __webpack_require__(167); + docs.complex = __webpack_require__(168); + docs.createUnit = __webpack_require__(169); + docs.fraction = __webpack_require__(170); + docs.index = __webpack_require__(171); + docs.matrix = __webpack_require__(172); + docs.number = __webpack_require__(173); + docs.sparse = __webpack_require__(174); + docs.splitUnit = __webpack_require__(175); + docs.string = __webpack_require__(176); + docs.unit = __webpack_require__(177); // constants docs.e = __webpack_require__(82); docs.E = __webpack_require__(82); - docs['false'] = __webpack_require__(158); - docs.i = __webpack_require__(159); - docs['Infinity'] = __webpack_require__(150); - docs.LN2 = __webpack_require__(152); - docs.LN10 = __webpack_require__(151); - docs.LOG2E = __webpack_require__(154); - docs.LOG10E = __webpack_require__(153); - docs.NaN = __webpack_require__(155); - docs['null'] = __webpack_require__(160); + docs['false'] = __webpack_require__(159); + docs.i = __webpack_require__(160); + docs['Infinity'] = __webpack_require__(151); + docs.LN2 = __webpack_require__(153); + docs.LN10 = __webpack_require__(152); + docs.LOG2E = __webpack_require__(155); + docs.LOG10E = __webpack_require__(154); + docs.NaN = __webpack_require__(156); + docs['null'] = __webpack_require__(161); docs.pi = __webpack_require__(83); docs.PI = __webpack_require__(83); - docs.phi = __webpack_require__(161); - docs.SQRT1_2 = __webpack_require__(156); - docs.SQRT2 = __webpack_require__(157); - docs.tau = __webpack_require__(162); - docs['true'] = __webpack_require__(163); - docs.version = __webpack_require__(164); + docs.phi = __webpack_require__(162); + docs.SQRT1_2 = __webpack_require__(157); + docs.SQRT2 = __webpack_require__(158); + docs.tau = __webpack_require__(163); + docs['true'] = __webpack_require__(164); + docs.version = __webpack_require__(165); // physical constants // TODO: more detailed docs for physical constants @@ -13295,191 +13325,191 @@ var qics = docs.planckTemperature = {description: 'Planck temperature', examples: ['planckTemperature']}; // functions - algebra - docs.derivative = __webpack_require__(180); - docs.lsolve = __webpack_require__(181); - docs.lup = __webpack_require__(182); - docs.lusolve = __webpack_require__(183); - docs.simplify = __webpack_require__(184); - docs.slu = __webpack_require__(185); - docs.usolve = __webpack_require__(186); + docs.derivative = __webpack_require__(181); + docs.lsolve = __webpack_require__(182); + docs.lup = __webpack_require__(183); + docs.lusolve = __webpack_require__(184); + docs.simplify = __webpack_require__(185); + docs.slu = __webpack_require__(186); + docs.usolve = __webpack_require__(187); // functions - arithmetic - docs.abs = __webpack_require__(187); - docs.add = __webpack_require__(188); - docs.cbrt = __webpack_require__(189); - docs.ceil = __webpack_require__(190); - docs.cube = __webpack_require__(191); - docs.divide = __webpack_require__(192); - docs.dotDivide = __webpack_require__(193); - docs.dotMultiply = __webpack_require__(194); - docs.dotPow = __webpack_require__(195); - docs.exp = __webpack_require__(196); - docs.fix = __webpack_require__(197); - docs.floor = __webpack_require__(198); - docs.gcd = __webpack_require__(199); - docs.hypot = __webpack_require__(200); - docs.lcm = __webpack_require__(201); - docs.log = __webpack_require__(202); - docs.log10 = __webpack_require__(203); - docs.mod = __webpack_require__(204); - docs.multiply = __webpack_require__(205); - docs.norm = __webpack_require__(206); - docs.nthRoot = __webpack_require__(207); - docs.pow = __webpack_require__(208); - docs.round = __webpack_require__(209); - docs.sign = __webpack_require__(210); - docs.sqrt = __webpack_require__(211); - docs.square = __webpack_require__(212); - docs.subtract = __webpack_require__(213); - docs.unaryMinus = __webpack_require__(214); - docs.unaryPlus = __webpack_require__(215); - docs.xgcd = __webpack_require__(216); + docs.abs = __webpack_require__(188); + docs.add = __webpack_require__(189); + docs.cbrt = __webpack_require__(190); + docs.ceil = __webpack_require__(191); + docs.cube = __webpack_require__(192); + docs.divide = __webpack_require__(193); + docs.dotDivide = __webpack_require__(194); + docs.dotMultiply = __webpack_require__(195); + docs.dotPow = __webpack_require__(196); + docs.exp = __webpack_require__(197); + docs.fix = __webpack_require__(198); + docs.floor = __webpack_require__(199); + docs.gcd = __webpack_require__(200); + docs.hypot = __webpack_require__(201); + docs.lcm = __webpack_require__(202); + docs.log = __webpack_require__(203); + docs.log10 = __webpack_require__(204); + docs.mod = __webpack_require__(205); + docs.multiply = __webpack_require__(206); + docs.norm = __webpack_require__(207); + docs.nthRoot = __webpack_require__(208); + docs.pow = __webpack_require__(209); + docs.round = __webpack_require__(210); + docs.sign = __webpack_require__(211); + docs.sqrt = __webpack_require__(212); + docs.square = __webpack_require__(213); + docs.subtract = __webpack_require__(214); + docs.unaryMinus = __webpack_require__(215); + docs.unaryPlus = __webpack_require__(216); + docs.xgcd = __webpack_require__(217); // functions - bitwise - docs.bitAnd = __webpack_require__(217); - docs.bitNot = __webpack_require__(218); - docs.bitOr = __webpack_require__(219); - docs.bitXor = __webpack_require__(220); - docs.leftShift = __webpack_require__(221); - docs.rightArithShift = __webpack_require__(222); - docs.rightLogShift = __webpack_require__(223); + docs.bitAnd = __webpack_require__(218); + docs.bitNot = __webpack_require__(219); + docs.bitOr = __webpack_require__(220); + docs.bitXor = __webpack_require__(221); + docs.leftShift = __webpack_require__(222); + docs.rightArithShift = __webpack_require__(223); + docs.rightLogShift = __webpack_require__(224); // functions - combinatorics - docs.bellNumbers = __webpack_require__(224); - docs.catalan = __webpack_require__(225); - docs.composition = __webpack_require__(226); - docs.stirlingS2 = __webpack_require__(227); + docs.bellNumbers = __webpack_require__(225); + docs.catalan = __webpack_require__(226); + docs.composition = __webpack_require__(227); + docs.stirlingS2 = __webpack_require__(228); // functions - core - docs['config'] = __webpack_require__(177); - docs['import'] = __webpack_require__(178); - docs['typed'] = __webpack_require__(179); + docs['config'] = __webpack_require__(178); + docs['import'] = __webpack_require__(179); + docs['typed'] = __webpack_require__(180); // functions - complex - docs.arg = __webpack_require__(228); - docs.conj = __webpack_require__(229); - docs.re = __webpack_require__(231); - docs.im = __webpack_require__(230); + docs.arg = __webpack_require__(229); + docs.conj = __webpack_require__(230); + docs.re = __webpack_require__(232); + docs.im = __webpack_require__(231); // functions - expression - docs['eval'] = __webpack_require__(232); - docs.help = __webpack_require__(233); + docs['eval'] = __webpack_require__(233); + docs.help = __webpack_require__(234); // functions - geometry - docs.distance = __webpack_require__(234); - docs.intersect = __webpack_require__(235); + docs.distance = __webpack_require__(235); + docs.intersect = __webpack_require__(236); // functions - logical - docs['and'] = __webpack_require__(236); - docs['not'] = __webpack_require__(237); - docs['or'] = __webpack_require__(238); - docs['xor'] = __webpack_require__(239); + docs['and'] = __webpack_require__(237); + docs['not'] = __webpack_require__(238); + docs['or'] = __webpack_require__(239); + docs['xor'] = __webpack_require__(240); // functions - matrix - docs['concat'] = __webpack_require__(240); - docs.cross = __webpack_require__(241); - docs.det = __webpack_require__(242); - docs.diag = __webpack_require__(243); - docs.dot = __webpack_require__(244); - docs.eye = __webpack_require__(245); - docs.filter = __webpack_require__(246); - docs.flatten = __webpack_require__(247); - docs.forEach = __webpack_require__(248); - docs.inv = __webpack_require__(249); - docs.kron = __webpack_require__(250); - docs.map = __webpack_require__(251); - docs.ones = __webpack_require__(252); - docs.partitionSelect = __webpack_require__(253); - docs.range = __webpack_require__(254); - docs.resize = __webpack_require__(255); - docs.size = __webpack_require__(256); - docs.sort = __webpack_require__(257); - docs.squeeze = __webpack_require__(258); - docs.subset = __webpack_require__(259); - docs.trace = __webpack_require__(260); - docs.transpose = __webpack_require__(261); - docs.zeros = __webpack_require__(262); + docs['concat'] = __webpack_require__(241); + docs.cross = __webpack_require__(242); + docs.det = __webpack_require__(243); + docs.diag = __webpack_require__(244); + docs.dot = __webpack_require__(245); + docs.eye = __webpack_require__(246); + docs.filter = __webpack_require__(247); + docs.flatten = __webpack_require__(248); + docs.forEach = __webpack_require__(249); + docs.inv = __webpack_require__(250); + docs.kron = __webpack_require__(251); + docs.map = __webpack_require__(252); + docs.ones = __webpack_require__(253); + docs.partitionSelect = __webpack_require__(254); + docs.range = __webpack_require__(255); + docs.resize = __webpack_require__(256); + docs.size = __webpack_require__(257); + docs.sort = __webpack_require__(258); + docs.squeeze = __webpack_require__(259); + docs.subset = __webpack_require__(260); + docs.trace = __webpack_require__(261); + docs.transpose = __webpack_require__(262); + docs.zeros = __webpack_require__(263); // functions - probability - docs.combinations = __webpack_require__(263); + docs.combinations = __webpack_require__(264); //docs.distribution = require('./function/probability/distribution'); - docs.factorial = __webpack_require__(264); - docs.gamma = __webpack_require__(265); - docs.kldivergence = __webpack_require__(266); - docs.multinomial = __webpack_require__(267); - docs.permutations = __webpack_require__(268); - docs.pickRandom = __webpack_require__(269); - docs.random = __webpack_require__(270); - docs.randomInt = __webpack_require__(271); + docs.factorial = __webpack_require__(265); + docs.gamma = __webpack_require__(266); + docs.kldivergence = __webpack_require__(267); + docs.multinomial = __webpack_require__(268); + docs.permutations = __webpack_require__(269); + docs.pickRandom = __webpack_require__(270); + docs.random = __webpack_require__(271); + docs.randomInt = __webpack_require__(272); // functions - relational - docs.compare = __webpack_require__(272); - docs.deepEqual = __webpack_require__(273); - docs['equal'] = __webpack_require__(274); - docs.larger = __webpack_require__(275); - docs.largerEq = __webpack_require__(276); - docs.smaller = __webpack_require__(277); - docs.smallerEq = __webpack_require__(278); - docs.unequal = __webpack_require__(279); + docs.compare = __webpack_require__(273); + docs.deepEqual = __webpack_require__(274); + docs['equal'] = __webpack_require__(275); + docs.larger = __webpack_require__(276); + docs.largerEq = __webpack_require__(277); + docs.smaller = __webpack_require__(278); + docs.smallerEq = __webpack_require__(279); + docs.unequal = __webpack_require__(280); // functions - special - docs.erf = __webpack_require__(280); + docs.erf = __webpack_require__(281); // functions - statistics - docs.mad = __webpack_require__(281); - docs.max = __webpack_require__(282); - docs.mean = __webpack_require__(283); - docs.median = __webpack_require__(284); - docs.min = __webpack_require__(285); - docs.mode = __webpack_require__(286); - docs.prod = __webpack_require__(287); - docs.quantileSeq = __webpack_require__(288); - docs.std = __webpack_require__(289); - docs.sum = __webpack_require__(290); - docs['var'] = __webpack_require__(291); + docs.mad = __webpack_require__(282); + docs.max = __webpack_require__(283); + docs.mean = __webpack_require__(284); + docs.median = __webpack_require__(285); + docs.min = __webpack_require__(286); + docs.mode = __webpack_require__(287); + docs.prod = __webpack_require__(288); + docs.quantileSeq = __webpack_require__(289); + docs.std = __webpack_require__(290); + docs.sum = __webpack_require__(291); + docs['var'] = __webpack_require__(292); // functions - trigonometry - docs.acos = __webpack_require__(292); - docs.acosh = __webpack_require__(293); - docs.acot = __webpack_require__(294); - docs.acoth = __webpack_require__(295); - docs.acsc = __webpack_require__(296); - docs.acsch = __webpack_require__(297); - docs.asec = __webpack_require__(298); - docs.asech = __webpack_require__(299); - docs.asin = __webpack_require__(300); - docs.asinh = __webpack_require__(301); - docs.atan = __webpack_require__(302); - docs.atanh = __webpack_require__(304); - docs.atan2 = __webpack_require__(303); - docs.cos = __webpack_require__(305); - docs.cosh = __webpack_require__(306); - docs.cot = __webpack_require__(307); - docs.coth = __webpack_require__(308); - docs.csc = __webpack_require__(309); - docs.csch = __webpack_require__(310); - docs.sec = __webpack_require__(311); - docs.sech = __webpack_require__(312); - docs.sin = __webpack_require__(313); - docs.sinh = __webpack_require__(314); - docs.tan = __webpack_require__(315); - docs.tanh = __webpack_require__(316); + docs.acos = __webpack_require__(293); + docs.acosh = __webpack_require__(294); + docs.acot = __webpack_require__(295); + docs.acoth = __webpack_require__(296); + docs.acsc = __webpack_require__(297); + docs.acsch = __webpack_require__(298); + docs.asec = __webpack_require__(299); + docs.asech = __webpack_require__(300); + docs.asin = __webpack_require__(301); + docs.asinh = __webpack_require__(302); + docs.atan = __webpack_require__(303); + docs.atanh = __webpack_require__(305); + docs.atan2 = __webpack_require__(304); + docs.cos = __webpack_require__(306); + docs.cosh = __webpack_require__(307); + docs.cot = __webpack_require__(308); + docs.coth = __webpack_require__(309); + docs.csc = __webpack_require__(310); + docs.csch = __webpack_require__(311); + docs.sec = __webpack_require__(312); + docs.sech = __webpack_require__(313); + docs.sin = __webpack_require__(314); + docs.sinh = __webpack_require__(315); + docs.tan = __webpack_require__(316); + docs.tanh = __webpack_require__(317); // functions - units - docs.to = __webpack_require__(317); + docs.to = __webpack_require__(318); // functions - utils - docs.clone = __webpack_require__(318); - docs.format = __webpack_require__(319); - docs.isNaN = __webpack_require__(321); - docs.isInteger = __webpack_require__(320); - docs.isNegative = __webpack_require__(322); - docs.isNumeric = __webpack_require__(323); - docs.isPositive = __webpack_require__(324); - docs.isPrime = __webpack_require__(325); - docs.isZero = __webpack_require__(326); + docs.clone = __webpack_require__(319); + docs.format = __webpack_require__(320); + docs.isNaN = __webpack_require__(322); + docs.isInteger = __webpack_require__(321); + docs.isNegative = __webpack_require__(323); + docs.isNumeric = __webpack_require__(324); + docs.isPositive = __webpack_require__(325); + docs.isPrime = __webpack_require__(326); + docs.isZero = __webpack_require__(327); // docs.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects. - docs['typeof'] = __webpack_require__(327); + docs['typeof'] = __webpack_require__(328); return docs; } @@ -13732,12 +13762,12 @@ var qics = function factory (type, config, load, typed) { var Node = load(__webpack_require__(12)); - var ArrayNode = load(__webpack_require__(63)); + var ArrayNode = load(__webpack_require__(64)); var matrix = load(__webpack_require__(2)); - var assign = load(__webpack_require__(336)); + var assign = load(__webpack_require__(337)); var access = load(__webpack_require__(93)); - var keywords = __webpack_require__(62); + var keywords = __webpack_require__(63); var operators = __webpack_require__(46); /** @@ -14335,7 +14365,7 @@ var qics = 'use strict'; - var keywords = __webpack_require__(62); + var keywords = __webpack_require__(63); var latex = __webpack_require__(4); var operators = __webpack_require__(46); @@ -14508,7 +14538,7 @@ var qics = function factory (type, config, load, typed) { var Node = load(__webpack_require__(12)); - var RangeNode = load(__webpack_require__(64)); + var RangeNode = load(__webpack_require__(65)); var SymbolNode = load(__webpack_require__(25)); var Range = load(__webpack_require__(130)); @@ -15340,8 +15370,8 @@ var qics = function factory (type, config, load, typed) { - var cs_sqr = load(__webpack_require__(364)); - var cs_lu = load(__webpack_require__(359)); + var cs_sqr = load(__webpack_require__(365)); + var cs_lu = load(__webpack_require__(360)); /** * Calculate the Sparse Matrix LU decomposition with full pivoting. Sparse Matrix `A` is decomposed in two matrices (`L`, `U`) and two permutation vectors (`pinv`, `q`) where @@ -15419,7 +15449,7 @@ var qics = var ParenthesisNode = load(__webpack_require__(50)); var SymbolNode = load(__webpack_require__(25)); var Node = load(__webpack_require__(12)); - var simplifyConstant = load(__webpack_require__(350)); + var simplifyConstant = load(__webpack_require__(351)); var util = load(__webpack_require__(97)); var isCommutative = util.isCommutative; @@ -16197,7 +16227,7 @@ var qics = var subtract = load(__webpack_require__(19)); var equalScalar = load(__webpack_require__(9)); - var solveValidation = load(__webpack_require__(65)); + var solveValidation = load(__webpack_require__(66)); var DenseMatrix = type.DenseMatrix; @@ -16390,7 +16420,7 @@ var qics = var subtract = load(__webpack_require__(19)); var equalScalar = load(__webpack_require__(9)); - var solveValidation = load(__webpack_require__(65)); + var solveValidation = load(__webpack_require__(66)); var DenseMatrix = type.DenseMatrix; @@ -16578,7 +16608,7 @@ var qics = function factory (type, config, load) { - var cs_flip = load(__webpack_require__(66)); + var cs_flip = load(__webpack_require__(67)); /** * Marks the node at w[j] @@ -17677,7 +17707,7 @@ var qics = var multiply = load(__webpack_require__(11)); var unaryMinus = load(__webpack_require__(37)); var det = load(__webpack_require__(109)); - var eye = load(__webpack_require__(67)); + var eye = load(__webpack_require__(68)); /** * Calculate the inverse of a square matrix. @@ -18925,7 +18955,7 @@ var qics = var add = load(__webpack_require__(18)); var divide = load(__webpack_require__(17)); var compare = load(__webpack_require__(47)); - var partitionSelect = load(__webpack_require__(69)); + var partitionSelect = load(__webpack_require__(70)); /** * Compute the median of a matrix or a list with values. The values are @@ -19721,7 +19751,7 @@ var qics = /* 127 */ /***/ function(module, exports, __webpack_require__) { - var Complex = __webpack_require__(139); + var Complex = __webpack_require__(140); var format = __webpack_require__(3).format; var isNumber = __webpack_require__(3).isNumber; @@ -19992,7 +20022,7 @@ var qics = var validateIndex = array.validateIndex; function factory (type, config, load, typed) { - var Matrix = load(__webpack_require__(73)); // force loading Matrix (do not use via type.Matrix) + var Matrix = load(__webpack_require__(74)); // force loading Matrix (do not use via type.Matrix) /** * Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type. @@ -21405,11 +21435,11 @@ var qics = var pow = load(__webpack_require__(36)); var abs = load(__webpack_require__(26)); var fix = load(__webpack_require__(104)); - var equal = load(__webpack_require__(71)); - var isNumeric = load(__webpack_require__(72)); + var equal = load(__webpack_require__(72)); + var isNumeric = load(__webpack_require__(73)); var format = load(__webpack_require__(123)); var getTypeOf = load(__webpack_require__(126)); - var toNumber = load(__webpack_require__(76)); + var toNumber = load(__webpack_require__(77)); var Complex = load(__webpack_require__(127)); /** @@ -22370,7 +22400,7 @@ var qics = } } } - var util = __webpack_require__(519); + var util = __webpack_require__(520); // Is the proposed unit list "simpler" than the existing one? if(proposedUnitList.length < this.units.length && !missingBaseDim) { @@ -24667,7 +24697,7 @@ var qics = /* 135 */ /***/ function(module, exports, __webpack_require__) { - var Emitter = __webpack_require__(515); + var Emitter = __webpack_require__(516); /** * Extend given object with emitter functions `on`, `off`, `once`, `emit` @@ -24721,9 +24751,9 @@ var qics = function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var math = __webpack_require__(80); - var weighted = __webpack_require__(520); - var gates = __webpack_require__(79); + var math = __webpack_require__(62); + var weighted = __webpack_require__(521); + var gates = __webpack_require__(80); var Register = function () { // This is the constructor for the Register, it takes a parameter @@ -24735,9 +24765,10 @@ var qics = // The number of amplitudes needed is 2^n, Where N is the number of qubits. // The math.zeros function Creates a matrix of 0s, ie. math.zeros(5) = [0, // 0, 0, 0, 0] - this.amplitudes = math.zeros(math.pow(2, numQubits)).toArray(); + this.amplitudes = math.matrix([math.zeros(math.pow(2, numQubits)).toArray()], 'sparse'); + // Set the chance of getting all Zeros to 1 - this.amplitudes[0] = 1; + this.amplitudes = math.subset(this.amplitudes, math.index(0, 0), 1); // Set the fact it has not been measured this.measured = false; } @@ -24762,6 +24793,7 @@ var qics = // Get the gate from the generateGates function, and then multiply the // amplitude vector against it var gateMatrix = gates.generateGate(gate, this.numQubits, qubit1, qubit2); + this.amplitudes = math.multiply(this.amplitudes, gateMatrix); } } @@ -24809,6 +24841,49 @@ var qics = /***/ }, /* 139 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var math = __webpack_require__(62); + + // Finds the sum of all the elements in an array + var sum = function sum(array) { + var total = 0; + math.forEach(array, function (val) { + // Itterate through the array, adding to the total variable + total += val; + }); + + // Return the sum + return total; + }; + + // Checks to if a matrix is unitary. Accepts a mathjs matrix or + // array, and returns true or false accordingly + var isUnitary = function isUnitary(matrix) { + // A Square matrix is unitary if its conjugate transpose is + // equal to its inverse + var givenMatrix = math.matrix(matrix, 'sparse'); + + // Check if its Square + if (math.size(givenMatrix)[0] !== math.size(givenMatrix)[1]) { + return false; + } + + var conjugateTranspose = math.transpose(math.conj(givenMatrix)); + var inverse = math.inv(givenMatrix); + + return math.deepEqual(inverse, conjugateTranspose); + }; + + module.exports = { + sum: sum, + isUnitary: isUnitary + }; + +/***/ }, +/* 140 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** @@ -25998,7 +26073,7 @@ var qics = /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(137)(module))) /***/ }, -/* 140 */ +/* 141 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v5.0.8 https://github.com/MikeMcl/decimal.js/LICENCE */ @@ -31025,7 +31100,7 @@ var qics = /***/ }, -/* 141 */ +/* 142 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {/** @@ -31811,13 +31886,13 @@ var qics = /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(137)(module))) /***/ }, -/* 142 */ +/* 143 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(144); + module.exports = __webpack_require__(145); /***/ }, -/* 143 */ +/* 144 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -31882,7 +31957,7 @@ var qics = math.i = type.Complex.I; // meta information - math.version = __webpack_require__(513); + math.version = __webpack_require__(514); } exports.factory = factory; @@ -31890,16 +31965,16 @@ var qics = exports.math = true; // request access to the math namespace /***/ }, -/* 144 */ +/* 145 */ /***/ function(module, exports, __webpack_require__) { var isFactory = __webpack_require__(5).isFactory; var deepExtend = __webpack_require__(5).deepExtend; - var typedFactory = __webpack_require__(147); + var typedFactory = __webpack_require__(148); var emitter = __webpack_require__(135); - var importFactory = __webpack_require__(146); - var configFactory = __webpack_require__(145); + var importFactory = __webpack_require__(147); + var configFactory = __webpack_require__(146); /** * Math.js core. Creates a new, empty math.js instance @@ -32021,7 +32096,7 @@ var qics = /***/ }, -/* 145 */ +/* 146 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -32146,7 +32221,7 @@ var qics = /***/ }, -/* 146 */ +/* 147 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -32418,10 +32493,10 @@ var qics = /***/ }, -/* 147 */ +/* 148 */ /***/ function(module, exports, __webpack_require__) { - var typedFunction = __webpack_require__(516); + var typedFunction = __webpack_require__(517); var digits = __webpack_require__(3).digits; // returns a new instance of typed-function @@ -32627,7 +32702,7 @@ var qics = /***/ }, -/* 148 */ +/* 149 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -32663,7 +32738,7 @@ var qics = /***/ }, -/* 149 */ +/* 150 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -32786,7 +32861,7 @@ var qics = /***/ }, -/* 150 */ +/* 151 */ /***/ function(module, exports) { module.exports = { @@ -32805,7 +32880,7 @@ var qics = /***/ }, -/* 151 */ +/* 152 */ /***/ function(module, exports) { module.exports = { @@ -32824,7 +32899,7 @@ var qics = /***/ }, -/* 152 */ +/* 153 */ /***/ function(module, exports) { module.exports = { @@ -32843,7 +32918,7 @@ var qics = /***/ }, -/* 153 */ +/* 154 */ /***/ function(module, exports) { module.exports = { @@ -32862,7 +32937,7 @@ var qics = /***/ }, -/* 154 */ +/* 155 */ /***/ function(module, exports) { module.exports = { @@ -32881,7 +32956,7 @@ var qics = /***/ }, -/* 155 */ +/* 156 */ /***/ function(module, exports) { module.exports = { @@ -32900,7 +32975,7 @@ var qics = /***/ }, -/* 156 */ +/* 157 */ /***/ function(module, exports) { module.exports = { @@ -32919,7 +32994,7 @@ var qics = /***/ }, -/* 157 */ +/* 158 */ /***/ function(module, exports) { module.exports = { @@ -32938,7 +33013,7 @@ var qics = /***/ }, -/* 158 */ +/* 159 */ /***/ function(module, exports) { module.exports = { @@ -32956,7 +33031,7 @@ var qics = /***/ }, -/* 159 */ +/* 160 */ /***/ function(module, exports) { module.exports = { @@ -32976,7 +33051,7 @@ var qics = /***/ }, -/* 160 */ +/* 161 */ /***/ function(module, exports) { module.exports = { @@ -32994,7 +33069,7 @@ var qics = /***/ }, -/* 161 */ +/* 162 */ /***/ function(module, exports) { module.exports = { @@ -33012,7 +33087,7 @@ var qics = /***/ }, -/* 162 */ +/* 163 */ /***/ function(module, exports) { module.exports = { @@ -33031,7 +33106,7 @@ var qics = /***/ }, -/* 163 */ +/* 164 */ /***/ function(module, exports) { module.exports = { @@ -33049,7 +33124,7 @@ var qics = /***/ }, -/* 164 */ +/* 165 */ /***/ function(module, exports) { module.exports = { @@ -33067,7 +33142,7 @@ var qics = /***/ }, -/* 165 */ +/* 166 */ /***/ function(module, exports) { module.exports = { @@ -33092,7 +33167,7 @@ var qics = /***/ }, -/* 166 */ +/* 167 */ /***/ function(module, exports) { module.exports = { @@ -33119,7 +33194,7 @@ var qics = /***/ }, -/* 167 */ +/* 168 */ /***/ function(module, exports) { module.exports = { @@ -33144,7 +33219,7 @@ var qics = /***/ }, -/* 168 */ +/* 169 */ /***/ function(module, exports) { module.exports = { @@ -33168,7 +33243,7 @@ var qics = /***/ }, -/* 169 */ +/* 170 */ /***/ function(module, exports) { module.exports = { @@ -33191,7 +33266,7 @@ var qics = /***/ }, -/* 170 */ +/* 171 */ /***/ function(module, exports) { module.exports = { @@ -33222,7 +33297,7 @@ var qics = /***/ }, -/* 171 */ +/* 172 */ /***/ function(module, exports) { module.exports = { @@ -33253,7 +33328,7 @@ var qics = /***/ }, -/* 172 */ +/* 173 */ /***/ function(module, exports) { module.exports = { @@ -33282,7 +33357,7 @@ var qics = /***/ }, -/* 173 */ +/* 174 */ /***/ function(module, exports) { module.exports = { @@ -33307,7 +33382,7 @@ var qics = /***/ }, -/* 174 */ +/* 175 */ /***/ function(module, exports) { module.exports = { @@ -33328,7 +33403,7 @@ var qics = /***/ }, -/* 175 */ +/* 176 */ /***/ function(module, exports) { module.exports = { @@ -33352,7 +33427,7 @@ var qics = /***/ }, -/* 176 */ +/* 177 */ /***/ function(module, exports) { module.exports = { @@ -33378,7 +33453,7 @@ var qics = /***/ }, -/* 177 */ +/* 178 */ /***/ function(module, exports) { module.exports = { @@ -33400,7 +33475,7 @@ var qics = /***/ }, -/* 178 */ +/* 179 */ /***/ function(module, exports) { module.exports = { @@ -33421,7 +33496,7 @@ var qics = /***/ }, -/* 179 */ +/* 180 */ /***/ function(module, exports) { module.exports = { @@ -33442,7 +33517,7 @@ var qics = /***/ }, -/* 180 */ +/* 181 */ /***/ function(module, exports) { module.exports = { @@ -33470,7 +33545,7 @@ var qics = /***/ }, -/* 181 */ +/* 182 */ /***/ function(module, exports) { module.exports = { @@ -33493,7 +33568,7 @@ var qics = /***/ }, -/* 182 */ +/* 183 */ /***/ function(module, exports) { module.exports = { @@ -33516,7 +33591,7 @@ var qics = /***/ }, -/* 183 */ +/* 184 */ /***/ function(module, exports) { module.exports = { @@ -33539,7 +33614,7 @@ var qics = /***/ }, -/* 184 */ +/* 185 */ /***/ function(module, exports) { module.exports = { @@ -33564,7 +33639,7 @@ var qics = /***/ }, -/* 185 */ +/* 186 */ /***/ function(module, exports) { module.exports = { @@ -33584,7 +33659,7 @@ var qics = /***/ }, -/* 186 */ +/* 187 */ /***/ function(module, exports) { module.exports = { @@ -33605,7 +33680,7 @@ var qics = /***/ }, -/* 187 */ +/* 188 */ /***/ function(module, exports) { module.exports = { @@ -33624,7 +33699,7 @@ var qics = /***/ }, -/* 188 */ +/* 189 */ /***/ function(module, exports) { module.exports = { @@ -33649,7 +33724,7 @@ var qics = /***/ }, -/* 189 */ +/* 190 */ /***/ function(module, exports) { module.exports = { @@ -33680,7 +33755,7 @@ var qics = /***/ }, -/* 190 */ +/* 191 */ /***/ function(module, exports) { module.exports = { @@ -33701,7 +33776,7 @@ var qics = /***/ }, -/* 191 */ +/* 192 */ /***/ function(module, exports) { module.exports = { @@ -33725,7 +33800,7 @@ var qics = /***/ }, -/* 192 */ +/* 193 */ /***/ function(module, exports) { module.exports = { @@ -33751,7 +33826,7 @@ var qics = /***/ }, -/* 193 */ +/* 194 */ /***/ function(module, exports) { module.exports = { @@ -33776,7 +33851,7 @@ var qics = /***/ }, -/* 194 */ +/* 195 */ /***/ function(module, exports) { module.exports = { @@ -33801,7 +33876,7 @@ var qics = /***/ }, -/* 195 */ +/* 196 */ /***/ function(module, exports) { module.exports = { @@ -33824,7 +33899,7 @@ var qics = /***/ }, -/* 196 */ +/* 197 */ /***/ function(module, exports) { module.exports = { @@ -33849,7 +33924,7 @@ var qics = /***/ }, -/* 197 */ +/* 198 */ /***/ function(module, exports) { module.exports = { @@ -33871,7 +33946,7 @@ var qics = /***/ }, -/* 198 */ +/* 199 */ /***/ function(module, exports) { module.exports = { @@ -33892,7 +33967,7 @@ var qics = /***/ }, -/* 199 */ +/* 200 */ /***/ function(module, exports) { module.exports = { @@ -33913,7 +33988,7 @@ var qics = /***/ }, -/* 200 */ +/* 201 */ /***/ function(module, exports) { module.exports = { @@ -33935,7 +34010,7 @@ var qics = /***/ }, -/* 201 */ +/* 202 */ /***/ function(module, exports) { module.exports = { @@ -33955,7 +34030,7 @@ var qics = /***/ }, -/* 202 */ +/* 203 */ /***/ function(module, exports) { module.exports = { @@ -33983,7 +34058,7 @@ var qics = }; /***/ }, -/* 203 */ +/* 204 */ /***/ function(module, exports) { module.exports = { @@ -34008,7 +34083,7 @@ var qics = /***/ }, -/* 204 */ +/* 205 */ /***/ function(module, exports) { module.exports = { @@ -34034,7 +34109,7 @@ var qics = /***/ }, -/* 205 */ +/* 206 */ /***/ function(module, exports) { module.exports = { @@ -34059,7 +34134,7 @@ var qics = /***/ }, -/* 206 */ +/* 207 */ /***/ function(module, exports) { module.exports = { @@ -34085,7 +34160,7 @@ var qics = /***/ }, -/* 207 */ +/* 208 */ /***/ function(module, exports) { module.exports = { @@ -34111,7 +34186,7 @@ var qics = }; /***/ }, -/* 208 */ +/* 209 */ /***/ function(module, exports) { module.exports = { @@ -34133,7 +34208,7 @@ var qics = /***/ }, -/* 209 */ +/* 210 */ /***/ function(module, exports) { module.exports = { @@ -34158,7 +34233,7 @@ var qics = /***/ }, -/* 210 */ +/* 211 */ /***/ function(module, exports) { module.exports = { @@ -34181,7 +34256,7 @@ var qics = /***/ }, -/* 211 */ +/* 212 */ /***/ function(module, exports) { module.exports = { @@ -34205,7 +34280,7 @@ var qics = /***/ }, -/* 212 */ +/* 213 */ /***/ function(module, exports) { module.exports = { @@ -34232,7 +34307,7 @@ var qics = /***/ }, -/* 213 */ +/* 214 */ /***/ function(module, exports) { module.exports = { @@ -34257,7 +34332,7 @@ var qics = /***/ }, -/* 214 */ +/* 215 */ /***/ function(module, exports) { module.exports = { @@ -34281,7 +34356,7 @@ var qics = /***/ }, -/* 215 */ +/* 216 */ /***/ function(module, exports) { module.exports = { @@ -34304,7 +34379,7 @@ var qics = /***/ }, -/* 216 */ +/* 217 */ /***/ function(module, exports) { module.exports = { @@ -34324,7 +34399,7 @@ var qics = /***/ }, -/* 217 */ +/* 218 */ /***/ function(module, exports) { module.exports = { @@ -34347,7 +34422,7 @@ var qics = /***/ }, -/* 218 */ +/* 219 */ /***/ function(module, exports) { module.exports = { @@ -34370,7 +34445,7 @@ var qics = /***/ }, -/* 219 */ +/* 220 */ /***/ function(module, exports) { module.exports = { @@ -34392,7 +34467,7 @@ var qics = /***/ }, -/* 220 */ +/* 221 */ /***/ function(module, exports) { module.exports = { @@ -34413,7 +34488,7 @@ var qics = /***/ }, -/* 221 */ +/* 222 */ /***/ function(module, exports) { module.exports = { @@ -34435,7 +34510,7 @@ var qics = /***/ }, -/* 222 */ +/* 223 */ /***/ function(module, exports) { module.exports = { @@ -34458,7 +34533,7 @@ var qics = /***/ }, -/* 223 */ +/* 224 */ /***/ function(module, exports) { module.exports = { @@ -34481,7 +34556,7 @@ var qics = /***/ }, -/* 224 */ +/* 225 */ /***/ function(module, exports) { module.exports = { @@ -34499,7 +34574,7 @@ var qics = }; /***/ }, -/* 225 */ +/* 226 */ /***/ function(module, exports) { module.exports = { @@ -34517,7 +34592,7 @@ var qics = }; /***/ }, -/* 226 */ +/* 227 */ /***/ function(module, exports) { module.exports = { @@ -34534,7 +34609,7 @@ var qics = }; /***/ }, -/* 227 */ +/* 228 */ /***/ function(module, exports) { module.exports = { @@ -34552,7 +34627,7 @@ var qics = /***/ }, -/* 228 */ +/* 229 */ /***/ function(module, exports) { module.exports = { @@ -34578,7 +34653,7 @@ var qics = /***/ }, -/* 229 */ +/* 230 */ /***/ function(module, exports) { module.exports = { @@ -34604,7 +34679,7 @@ var qics = /***/ }, -/* 230 */ +/* 231 */ /***/ function(module, exports) { module.exports = { @@ -34630,7 +34705,7 @@ var qics = /***/ }, -/* 231 */ +/* 232 */ /***/ function(module, exports) { module.exports = { @@ -34656,7 +34731,7 @@ var qics = /***/ }, -/* 232 */ +/* 233 */ /***/ function(module, exports) { module.exports = { @@ -34676,7 +34751,7 @@ var qics = /***/ }, -/* 233 */ +/* 234 */ /***/ function(module, exports) { module.exports = { @@ -34696,7 +34771,7 @@ var qics = /***/ }, -/* 234 */ +/* 235 */ /***/ function(module, exports) { module.exports = { @@ -34716,7 +34791,7 @@ var qics = /***/ }, -/* 235 */ +/* 236 */ /***/ function(module, exports) { module.exports = { @@ -34736,7 +34811,7 @@ var qics = /***/ }, -/* 236 */ +/* 237 */ /***/ function(module, exports) { module.exports = { @@ -34759,7 +34834,7 @@ var qics = /***/ }, -/* 237 */ +/* 238 */ /***/ function(module, exports) { module.exports = { @@ -34783,7 +34858,7 @@ var qics = /***/ }, -/* 238 */ +/* 239 */ /***/ function(module, exports) { module.exports = { @@ -34806,7 +34881,7 @@ var qics = /***/ }, -/* 239 */ +/* 240 */ /***/ function(module, exports) { module.exports = { @@ -34830,7 +34905,7 @@ var qics = /***/ }, -/* 240 */ +/* 241 */ /***/ function(module, exports) { module.exports = { @@ -34855,7 +34930,7 @@ var qics = /***/ }, -/* 241 */ +/* 242 */ /***/ function(module, exports) { module.exports = { @@ -34878,7 +34953,7 @@ var qics = /***/ }, -/* 242 */ +/* 243 */ /***/ function(module, exports) { module.exports = { @@ -34899,7 +34974,7 @@ var qics = /***/ }, -/* 243 */ +/* 244 */ /***/ function(module, exports) { module.exports = { @@ -34923,7 +34998,7 @@ var qics = /***/ }, -/* 244 */ +/* 245 */ /***/ function(module, exports) { module.exports = { @@ -34947,7 +35022,7 @@ var qics = /***/ }, -/* 245 */ +/* 246 */ /***/ function(module, exports) { module.exports = { @@ -34973,7 +35048,7 @@ var qics = /***/ }, -/* 246 */ +/* 247 */ /***/ function(module, exports) { module.exports = { @@ -34993,7 +35068,7 @@ var qics = /***/ }, -/* 247 */ +/* 248 */ /***/ function(module, exports) { module.exports = { @@ -35016,7 +35091,7 @@ var qics = /***/ }, -/* 248 */ +/* 249 */ /***/ function(module, exports) { module.exports = { @@ -35034,7 +35109,7 @@ var qics = /***/ }, -/* 249 */ +/* 250 */ /***/ function(module, exports) { module.exports = { @@ -35056,7 +35131,7 @@ var qics = /***/ }, -/* 250 */ +/* 251 */ /***/ function(module, exports) { module.exports = { @@ -35077,7 +35152,7 @@ var qics = /***/ }, -/* 251 */ +/* 252 */ /***/ function(module, exports) { module.exports = { @@ -35095,7 +35170,7 @@ var qics = /***/ }, -/* 252 */ +/* 253 */ /***/ function(module, exports) { module.exports = { @@ -35125,7 +35200,7 @@ var qics = /***/ }, -/* 253 */ +/* 254 */ /***/ function(module, exports) { module.exports = { @@ -35145,7 +35220,7 @@ var qics = /***/ }, -/* 254 */ +/* 255 */ /***/ function(module, exports) { module.exports = { @@ -35176,7 +35251,7 @@ var qics = /***/ }, -/* 255 */ +/* 256 */ /***/ function(module, exports) { module.exports = { @@ -35201,7 +35276,7 @@ var qics = /***/ }, -/* 256 */ +/* 257 */ /***/ function(module, exports) { module.exports = { @@ -35225,7 +35300,7 @@ var qics = /***/ }, -/* 257 */ +/* 258 */ /***/ function(module, exports) { module.exports = { @@ -35247,7 +35322,7 @@ var qics = /***/ }, -/* 258 */ +/* 259 */ /***/ function(module, exports) { module.exports = { @@ -35270,7 +35345,7 @@ var qics = /***/ }, -/* 259 */ +/* 260 */ /***/ function(module, exports) { module.exports = { @@ -35301,7 +35376,7 @@ var qics = /***/ }, -/* 260 */ +/* 261 */ /***/ function(module, exports) { module.exports = { @@ -35322,7 +35397,7 @@ var qics = /***/ }, -/* 261 */ +/* 262 */ /***/ function(module, exports) { module.exports = { @@ -35345,7 +35420,7 @@ var qics = /***/ }, -/* 262 */ +/* 263 */ /***/ function(module, exports) { module.exports = { @@ -35374,7 +35449,7 @@ var qics = /***/ }, -/* 263 */ +/* 264 */ /***/ function(module, exports) { module.exports = { @@ -35392,7 +35467,7 @@ var qics = /***/ }, -/* 264 */ +/* 265 */ /***/ function(module, exports) { module.exports = { @@ -35412,7 +35487,7 @@ var qics = /***/ }, -/* 265 */ +/* 266 */ /***/ function(module, exports) { module.exports = { @@ -35433,7 +35508,7 @@ var qics = /***/ }, -/* 266 */ +/* 267 */ /***/ function(module, exports) { module.exports = { @@ -35452,7 +35527,7 @@ var qics = /***/ }, -/* 267 */ +/* 268 */ /***/ function(module, exports) { module.exports = { @@ -35469,7 +35544,7 @@ var qics = }; /***/ }, -/* 268 */ +/* 269 */ /***/ function(module, exports) { module.exports = { @@ -35489,7 +35564,7 @@ var qics = /***/ }, -/* 269 */ +/* 270 */ /***/ function(module, exports) { module.exports = { @@ -35517,7 +35592,7 @@ var qics = /***/ }, -/* 270 */ +/* 271 */ /***/ function(module, exports) { module.exports = { @@ -35543,7 +35618,7 @@ var qics = /***/ }, -/* 271 */ +/* 272 */ /***/ function(module, exports) { module.exports = { @@ -35566,7 +35641,7 @@ var qics = }; /***/ }, -/* 272 */ +/* 273 */ /***/ function(module, exports) { module.exports = { @@ -35591,7 +35666,7 @@ var qics = /***/ }, -/* 273 */ +/* 274 */ /***/ function(module, exports) { module.exports = { @@ -35613,7 +35688,7 @@ var qics = /***/ }, -/* 274 */ +/* 275 */ /***/ function(module, exports) { module.exports = { @@ -35640,7 +35715,7 @@ var qics = /***/ }, -/* 275 */ +/* 276 */ /***/ function(module, exports) { module.exports = { @@ -35668,7 +35743,7 @@ var qics = /***/ }, -/* 276 */ +/* 277 */ /***/ function(module, exports) { module.exports = { @@ -35694,7 +35769,7 @@ var qics = /***/ }, -/* 277 */ +/* 278 */ /***/ function(module, exports) { module.exports = { @@ -35721,7 +35796,7 @@ var qics = /***/ }, -/* 278 */ +/* 279 */ /***/ function(module, exports) { module.exports = { @@ -35747,7 +35822,7 @@ var qics = /***/ }, -/* 279 */ +/* 280 */ /***/ function(module, exports) { module.exports = { @@ -35775,7 +35850,7 @@ var qics = /***/ }, -/* 280 */ +/* 281 */ /***/ function(module, exports) { module.exports = { @@ -35795,7 +35870,7 @@ var qics = /***/ }, -/* 281 */ +/* 282 */ /***/ function(module, exports) { module.exports = { @@ -35821,7 +35896,7 @@ var qics = /***/ }, -/* 282 */ +/* 283 */ /***/ function(module, exports) { module.exports = { @@ -35855,7 +35930,7 @@ var qics = /***/ }, -/* 283 */ +/* 284 */ /***/ function(module, exports) { module.exports = { @@ -35888,7 +35963,7 @@ var qics = /***/ }, -/* 284 */ +/* 285 */ /***/ function(module, exports) { module.exports = { @@ -35916,7 +35991,7 @@ var qics = /***/ }, -/* 285 */ +/* 286 */ /***/ function(module, exports) { module.exports = { @@ -35950,7 +36025,7 @@ var qics = /***/ }, -/* 286 */ +/* 287 */ /***/ function(module, exports) { module.exports = { @@ -35980,7 +36055,7 @@ var qics = /***/ }, -/* 287 */ +/* 288 */ /***/ function(module, exports) { module.exports = { @@ -36010,7 +36085,7 @@ var qics = /***/ }, -/* 288 */ +/* 289 */ /***/ function(module, exports) { module.exports = { @@ -36041,7 +36116,7 @@ var qics = }; /***/ }, -/* 289 */ +/* 290 */ /***/ function(module, exports) { module.exports = { @@ -36074,7 +36149,7 @@ var qics = /***/ }, -/* 290 */ +/* 291 */ /***/ function(module, exports) { module.exports = { @@ -36104,7 +36179,7 @@ var qics = /***/ }, -/* 291 */ +/* 292 */ /***/ function(module, exports) { module.exports = { @@ -36137,7 +36212,7 @@ var qics = /***/ }, -/* 292 */ +/* 293 */ /***/ function(module, exports) { module.exports = { @@ -36160,7 +36235,7 @@ var qics = /***/ }, -/* 293 */ +/* 294 */ /***/ function(module, exports) { module.exports = { @@ -36181,7 +36256,7 @@ var qics = }; /***/ }, -/* 294 */ +/* 295 */ /***/ function(module, exports) { module.exports = { @@ -36204,7 +36279,7 @@ var qics = /***/ }, -/* 295 */ +/* 296 */ /***/ function(module, exports) { module.exports = { @@ -36224,7 +36299,7 @@ var qics = }; /***/ }, -/* 296 */ +/* 297 */ /***/ function(module, exports) { module.exports = { @@ -36248,7 +36323,7 @@ var qics = /***/ }, -/* 297 */ +/* 298 */ /***/ function(module, exports) { module.exports = { @@ -36269,7 +36344,7 @@ var qics = /***/ }, -/* 298 */ +/* 299 */ /***/ function(module, exports) { module.exports = { @@ -36293,7 +36368,7 @@ var qics = /***/ }, -/* 299 */ +/* 300 */ /***/ function(module, exports) { module.exports = { @@ -36314,7 +36389,7 @@ var qics = /***/ }, -/* 300 */ +/* 301 */ /***/ function(module, exports) { module.exports = { @@ -36337,7 +36412,7 @@ var qics = /***/ }, -/* 301 */ +/* 302 */ /***/ function(module, exports) { module.exports = { @@ -36358,7 +36433,7 @@ var qics = /***/ }, -/* 302 */ +/* 303 */ /***/ function(module, exports) { module.exports = { @@ -36381,7 +36456,7 @@ var qics = /***/ }, -/* 303 */ +/* 304 */ /***/ function(module, exports) { module.exports = { @@ -36408,7 +36483,7 @@ var qics = /***/ }, -/* 304 */ +/* 305 */ /***/ function(module, exports) { module.exports = { @@ -36429,7 +36504,7 @@ var qics = /***/ }, -/* 305 */ +/* 306 */ /***/ function(module, exports) { module.exports = { @@ -36455,7 +36530,7 @@ var qics = /***/ }, -/* 306 */ +/* 307 */ /***/ function(module, exports) { module.exports = { @@ -36477,7 +36552,7 @@ var qics = /***/ }, -/* 307 */ +/* 308 */ /***/ function(module, exports) { module.exports = { @@ -36500,7 +36575,7 @@ var qics = /***/ }, -/* 308 */ +/* 309 */ /***/ function(module, exports) { module.exports = { @@ -36523,7 +36598,7 @@ var qics = /***/ }, -/* 309 */ +/* 310 */ /***/ function(module, exports) { module.exports = { @@ -36546,7 +36621,7 @@ var qics = /***/ }, -/* 310 */ +/* 311 */ /***/ function(module, exports) { module.exports = { @@ -36569,7 +36644,7 @@ var qics = /***/ }, -/* 311 */ +/* 312 */ /***/ function(module, exports) { module.exports = { @@ -36592,7 +36667,7 @@ var qics = /***/ }, -/* 312 */ +/* 313 */ /***/ function(module, exports) { module.exports = { @@ -36615,7 +36690,7 @@ var qics = /***/ }, -/* 313 */ +/* 314 */ /***/ function(module, exports) { module.exports = { @@ -36641,7 +36716,7 @@ var qics = /***/ }, -/* 314 */ +/* 315 */ /***/ function(module, exports) { module.exports = { @@ -36662,7 +36737,7 @@ var qics = /***/ }, -/* 315 */ +/* 316 */ /***/ function(module, exports) { module.exports = { @@ -36687,7 +36762,7 @@ var qics = /***/ }, -/* 316 */ +/* 317 */ /***/ function(module, exports) { module.exports = { @@ -36709,7 +36784,7 @@ var qics = /***/ }, -/* 317 */ +/* 318 */ /***/ function(module, exports) { module.exports = { @@ -36730,7 +36805,7 @@ var qics = /***/ }, -/* 318 */ +/* 319 */ /***/ function(module, exports) { module.exports = { @@ -36752,7 +36827,7 @@ var qics = /***/ }, -/* 319 */ +/* 320 */ /***/ function(module, exports) { module.exports = { @@ -36774,7 +36849,7 @@ var qics = /***/ }, -/* 320 */ +/* 321 */ /***/ function(module, exports) { module.exports = { @@ -36794,7 +36869,7 @@ var qics = /***/ }, -/* 321 */ +/* 322 */ /***/ function(module, exports) { module.exports = { @@ -36815,7 +36890,7 @@ var qics = /***/ }, -/* 322 */ +/* 323 */ /***/ function(module, exports) { module.exports = { @@ -36836,7 +36911,7 @@ var qics = /***/ }, -/* 323 */ +/* 324 */ /***/ function(module, exports) { module.exports = { @@ -36861,7 +36936,7 @@ var qics = /***/ }, -/* 324 */ +/* 325 */ /***/ function(module, exports) { module.exports = { @@ -36882,7 +36957,7 @@ var qics = /***/ }, -/* 325 */ +/* 326 */ /***/ function(module, exports) { module.exports = { @@ -36901,7 +36976,7 @@ var qics = }; /***/ }, -/* 326 */ +/* 327 */ /***/ function(module, exports) { module.exports = { @@ -36922,7 +36997,7 @@ var qics = /***/ }, -/* 327 */ +/* 328 */ /***/ function(module, exports) { module.exports = { @@ -36943,7 +37018,7 @@ var qics = /***/ }, -/* 328 */ +/* 329 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37005,7 +37080,7 @@ var qics = /***/ }, -/* 329 */ +/* 330 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37073,7 +37148,7 @@ var qics = exports.factory = factory; /***/ }, -/* 330 */ +/* 331 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37143,20 +37218,20 @@ var qics = /***/ }, -/* 331 */ +/* 332 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(328), __webpack_require__(329), __webpack_require__(330), - __webpack_require__(332), + __webpack_require__(331), + __webpack_require__(333), __webpack_require__(85) ]; /***/ }, -/* 332 */ +/* 333 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37211,23 +37286,23 @@ var qics = /***/ }, -/* 333 */ +/* 334 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(84), - __webpack_require__(331), - __webpack_require__(335), - __webpack_require__(340), + __webpack_require__(332), + __webpack_require__(336), + __webpack_require__(341), - __webpack_require__(149), + __webpack_require__(150), __webpack_require__(29), __webpack_require__(81) ]; /***/ }, -/* 334 */ +/* 335 */ /***/ function(module, exports) { 'use strict'; @@ -37250,12 +37325,12 @@ var qics = /***/ }, -/* 335 */ +/* 336 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(86), - __webpack_require__(63), + __webpack_require__(64), __webpack_require__(87), __webpack_require__(88), __webpack_require__(89), @@ -37267,14 +37342,14 @@ var qics = __webpack_require__(92), __webpack_require__(49), __webpack_require__(50), - __webpack_require__(64), + __webpack_require__(65), __webpack_require__(25), - __webpack_require__(334) + __webpack_require__(335) ]; /***/ }, -/* 336 */ +/* 337 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37331,7 +37406,7 @@ var qics = /***/ }, -/* 337 */ +/* 338 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37377,7 +37452,7 @@ var qics = /***/ }, -/* 338 */ +/* 339 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37447,7 +37522,7 @@ var qics = /***/ }, -/* 339 */ +/* 340 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37499,25 +37574,25 @@ var qics = /***/ }, -/* 340 */ +/* 341 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(337), __webpack_require__(338), __webpack_require__(339), - __webpack_require__(341), + __webpack_require__(340), __webpack_require__(342), __webpack_require__(343), __webpack_require__(344), __webpack_require__(345), __webpack_require__(346), - __webpack_require__(347) + __webpack_require__(347), + __webpack_require__(348) ]; /***/ }, -/* 341 */ +/* 342 */ /***/ function(module, exports) { 'use strict'; @@ -37574,7 +37649,7 @@ var qics = /***/ }, -/* 342 */ +/* 343 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37588,7 +37663,7 @@ var qics = * This transform creates a one-based index instead of a zero-based index */ function factory (type, config, load, typed) { - var map = load(__webpack_require__(68)); + var map = load(__webpack_require__(69)); var matrix = load(__webpack_require__(2)); return typed('max', { @@ -37644,7 +37719,7 @@ var qics = /***/ }, -/* 343 */ +/* 344 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37691,7 +37766,7 @@ var qics = /***/ }, -/* 344 */ +/* 345 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37738,7 +37813,7 @@ var qics = /***/ }, -/* 345 */ +/* 346 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37785,7 +37860,7 @@ var qics = /***/ }, -/* 346 */ +/* 347 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37819,7 +37894,7 @@ var qics = /***/ }, -/* 347 */ +/* 348 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -37853,7 +37928,7 @@ var qics = /***/ }, -/* 348 */ +/* 349 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -38572,11 +38647,11 @@ var qics = /***/ }, -/* 349 */ +/* 350 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(348), + __webpack_require__(349), // simplify __webpack_require__(96), @@ -38587,13 +38662,13 @@ var qics = // solver __webpack_require__(98), - __webpack_require__(351), + __webpack_require__(352), __webpack_require__(99) ]; /***/ }, -/* 350 */ +/* 351 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -38816,7 +38891,7 @@ var qics = /***/ }, -/* 351 */ +/* 352 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -38828,9 +38903,9 @@ var qics = var matrix = load(__webpack_require__(2)); var lup = load(__webpack_require__(94)); var slu = load(__webpack_require__(95)); - var cs_ipvec = load(__webpack_require__(357)); + var cs_ipvec = load(__webpack_require__(358)); - var solveValidation = load(__webpack_require__(65)); + var solveValidation = load(__webpack_require__(66)); var usolve = load(__webpack_require__(99)); var lsolve = load(__webpack_require__(98)); @@ -38947,15 +39022,15 @@ var qics = /***/ }, -/* 352 */ +/* 353 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load) { - var cs_flip = load(__webpack_require__(66)); - var cs_fkeep = load(__webpack_require__(356)); + var cs_flip = load(__webpack_require__(67)); + var cs_fkeep = load(__webpack_require__(357)); var cs_tdfs = load(__webpack_require__(102)); var add = load(__webpack_require__(16)); @@ -39526,7 +39601,7 @@ var qics = /***/ }, -/* 353 */ +/* 354 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -39535,7 +39610,7 @@ var qics = var transpose = load(__webpack_require__(53)); - var cs_leaf = load(__webpack_require__(358)); + var cs_leaf = load(__webpack_require__(359)); /** * Computes the column counts using the upper triangular part of A. @@ -39653,7 +39728,7 @@ var qics = /***/ }, -/* 354 */ +/* 355 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -39662,7 +39737,7 @@ var qics = var cs_marked = load(__webpack_require__(101)); var cs_mark = load(__webpack_require__(100)); - var cs_unflip = load(__webpack_require__(365)); + var cs_unflip = load(__webpack_require__(366)); /** * Depth-first search computes the nonzero pattern xi of the directed graph G (Matrix) starting @@ -39744,7 +39819,7 @@ var qics = /***/ }, -/* 355 */ +/* 356 */ /***/ function(module, exports) { 'use strict'; @@ -39826,7 +39901,7 @@ var qics = /***/ }, -/* 356 */ +/* 357 */ /***/ function(module, exports) { 'use strict'; @@ -39897,7 +39972,7 @@ var qics = /***/ }, -/* 357 */ +/* 358 */ /***/ function(module, exports) { 'use strict'; @@ -39944,7 +40019,7 @@ var qics = /***/ }, -/* 358 */ +/* 359 */ /***/ function(module, exports) { 'use strict'; @@ -40016,7 +40091,7 @@ var qics = /***/ }, -/* 359 */ +/* 360 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40030,7 +40105,7 @@ var qics = var larger = load(__webpack_require__(27)); var largerEq = load(__webpack_require__(116)); - var cs_spsolve = load(__webpack_require__(363)); + var cs_spsolve = load(__webpack_require__(364)); var SparseMatrix = type.SparseMatrix; @@ -40200,7 +40275,7 @@ var qics = /***/ }, -/* 360 */ +/* 361 */ /***/ function(module, exports) { 'use strict'; @@ -40277,7 +40352,7 @@ var qics = /***/ }, -/* 361 */ +/* 362 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40342,14 +40417,14 @@ var qics = /***/ }, -/* 362 */ +/* 363 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load) { - var cs_dfs = load(__webpack_require__(354)); + var cs_dfs = load(__webpack_require__(355)); var cs_marked = load(__webpack_require__(101)); var cs_mark = load(__webpack_require__(100)); @@ -40409,7 +40484,7 @@ var qics = /***/ }, -/* 363 */ +/* 364 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40420,7 +40495,7 @@ var qics = var multiply = load(__webpack_require__(11)); var subtract = load(__webpack_require__(19)); - var cs_reach = load(__webpack_require__(362)); + var cs_reach = load(__webpack_require__(363)); /** * The function cs_spsolve() computes the solution to G * x = bk, where bk is the @@ -40501,18 +40576,18 @@ var qics = /***/ }, -/* 364 */ +/* 365 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load) { - var cs_amd = load(__webpack_require__(352)); - var cs_permute = load(__webpack_require__(360)); - var cs_etree = load(__webpack_require__(355)); - var cs_post = load(__webpack_require__(361)); - var cs_counts = load(__webpack_require__(353)); + var cs_amd = load(__webpack_require__(353)); + var cs_permute = load(__webpack_require__(361)); + var cs_etree = load(__webpack_require__(356)); + var cs_post = load(__webpack_require__(362)); + var cs_counts = load(__webpack_require__(354)); /** * Symbolic ordering and analysis for QR and LU decompositions. @@ -40670,14 +40745,14 @@ var qics = /***/ }, -/* 365 */ +/* 366 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load) { - var cs_flip = load(__webpack_require__(66)); + var cs_flip = load(__webpack_require__(67)); /** * Flips the value if it is negative of returns the same value otherwise. @@ -40700,7 +40775,7 @@ var qics = /***/ }, -/* 366 */ +/* 367 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40891,7 +40966,7 @@ var qics = /***/ }, -/* 367 */ +/* 368 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -40958,7 +41033,7 @@ var qics = /***/ }, -/* 368 */ +/* 369 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41028,7 +41103,7 @@ var qics = /***/ }, -/* 369 */ +/* 370 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41177,7 +41252,7 @@ var qics = /***/ }, -/* 370 */ +/* 371 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41324,7 +41399,7 @@ var qics = /***/ }, -/* 371 */ +/* 372 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41387,7 +41462,7 @@ var qics = /***/ }, -/* 372 */ +/* 373 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41453,7 +41528,7 @@ var qics = /***/ }, -/* 373 */ +/* 374 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41465,7 +41540,7 @@ var qics = var matrix = load(__webpack_require__(2)); var algorithm01 = load(__webpack_require__(28)); - var algorithm04 = load(__webpack_require__(74)); + var algorithm04 = load(__webpack_require__(75)); var algorithm10 = load(__webpack_require__(31)); var algorithm13 = load(__webpack_require__(7)); var algorithm14 = load(__webpack_require__(6)); @@ -41658,7 +41733,7 @@ var qics = /***/ }, -/* 374 */ +/* 375 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -41748,46 +41823,46 @@ var qics = /***/ }, -/* 375 */ +/* 376 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(26), __webpack_require__(16), __webpack_require__(18), - __webpack_require__(366), __webpack_require__(367), __webpack_require__(368), + __webpack_require__(369), __webpack_require__(35), __webpack_require__(103), - __webpack_require__(369), __webpack_require__(370), __webpack_require__(371), - __webpack_require__(104), __webpack_require__(372), + __webpack_require__(104), __webpack_require__(373), __webpack_require__(374), - __webpack_require__(376), - __webpack_require__(105), + __webpack_require__(375), __webpack_require__(377), + __webpack_require__(105), __webpack_require__(378), - __webpack_require__(11), __webpack_require__(379), + __webpack_require__(11), __webpack_require__(380), - __webpack_require__(36), __webpack_require__(381), + __webpack_require__(36), __webpack_require__(382), - __webpack_require__(51), __webpack_require__(383), + __webpack_require__(51), + __webpack_require__(384), __webpack_require__(19), __webpack_require__(37), - __webpack_require__(384), - __webpack_require__(385) + __webpack_require__(385), + __webpack_require__(386) ]; /***/ }, -/* 376 */ +/* 377 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42007,7 +42082,7 @@ var qics = /***/ }, -/* 377 */ +/* 378 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42091,7 +42166,7 @@ var qics = /***/ }, -/* 378 */ +/* 379 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42281,7 +42356,7 @@ var qics = /***/ }, -/* 379 */ +/* 380 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42502,7 +42577,7 @@ var qics = /***/ }, -/* 380 */ +/* 381 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42807,7 +42882,7 @@ var qics = /***/ }, -/* 381 */ +/* 382 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -42987,7 +43062,7 @@ var qics = /***/ }, -/* 382 */ +/* 383 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -43062,7 +43137,7 @@ var qics = /***/ }, -/* 383 */ +/* 384 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -43133,7 +43208,7 @@ var qics = /***/ }, -/* 384 */ +/* 385 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -43211,7 +43286,7 @@ var qics = /***/ }, -/* 385 */ +/* 386 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -43354,13 +43429,13 @@ var qics = /***/ }, -/* 386 */ +/* 387 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var isInteger = __webpack_require__(3).isInteger; - var bigBitAnd = __webpack_require__(505); + var bigBitAnd = __webpack_require__(506); function factory (type, config, load, typed) { var latex = __webpack_require__(4); @@ -43509,13 +43584,13 @@ var qics = /***/ }, -/* 387 */ +/* 388 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var deepMap = __webpack_require__(1); - var bigBitNot = __webpack_require__(77); + var bigBitNot = __webpack_require__(78); var isInteger = __webpack_require__(3).isInteger; function factory (type, config, load, typed) { @@ -43571,13 +43646,13 @@ var qics = /***/ }, -/* 388 */ +/* 389 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var isInteger = __webpack_require__(3).isInteger; - var bigBitOr = __webpack_require__(506); + var bigBitOr = __webpack_require__(507); function factory (type, config, load, typed) { var latex = __webpack_require__(4); @@ -43585,7 +43660,7 @@ var qics = var matrix = load(__webpack_require__(2)); var algorithm01 = load(__webpack_require__(28)); - var algorithm04 = load(__webpack_require__(74)); + var algorithm04 = load(__webpack_require__(75)); var algorithm10 = load(__webpack_require__(31)); var algorithm13 = load(__webpack_require__(7)); var algorithm14 = load(__webpack_require__(6)); @@ -43726,13 +43801,13 @@ var qics = /***/ }, -/* 389 */ +/* 390 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var isInteger = __webpack_require__(3).isInteger; - var bigBitXor = __webpack_require__(507); + var bigBitXor = __webpack_require__(508); function factory (type, config, load, typed) { var latex = __webpack_require__(4); @@ -43881,28 +43956,28 @@ var qics = /***/ }, -/* 390 */ +/* 391 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(386), __webpack_require__(387), __webpack_require__(388), __webpack_require__(389), - __webpack_require__(391), + __webpack_require__(390), __webpack_require__(392), - __webpack_require__(393) + __webpack_require__(393), + __webpack_require__(394) ]; /***/ }, -/* 391 */ +/* 392 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var isInteger = __webpack_require__(3).isInteger; - var bigLeftShift = __webpack_require__(509); + var bigLeftShift = __webpack_require__(510); function factory (type, config, load, typed) { var latex = __webpack_require__(4); @@ -43913,7 +43988,7 @@ var qics = var algorithm01 = load(__webpack_require__(28)); var algorithm02 = load(__webpack_require__(22)); - var algorithm08 = load(__webpack_require__(75)); + var algorithm08 = load(__webpack_require__(76)); var algorithm10 = load(__webpack_require__(31)); var algorithm11 = load(__webpack_require__(14)); var algorithm13 = load(__webpack_require__(7)); @@ -44064,13 +44139,13 @@ var qics = /***/ }, -/* 392 */ +/* 393 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; var isInteger = __webpack_require__(3).isInteger; - var bigRightArithShift = __webpack_require__(510); + var bigRightArithShift = __webpack_require__(511); function factory (type, config, load, typed) { var latex = __webpack_require__(4); @@ -44081,7 +44156,7 @@ var qics = var algorithm01 = load(__webpack_require__(28)); var algorithm02 = load(__webpack_require__(22)); - var algorithm08 = load(__webpack_require__(75)); + var algorithm08 = load(__webpack_require__(76)); var algorithm10 = load(__webpack_require__(31)); var algorithm11 = load(__webpack_require__(14)); var algorithm13 = load(__webpack_require__(7)); @@ -44232,7 +44307,7 @@ var qics = /***/ }, -/* 393 */ +/* 394 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44248,7 +44323,7 @@ var qics = var algorithm01 = load(__webpack_require__(28)); var algorithm02 = load(__webpack_require__(22)); - var algorithm08 = load(__webpack_require__(75)); + var algorithm08 = load(__webpack_require__(76)); var algorithm10 = load(__webpack_require__(31)); var algorithm11 = load(__webpack_require__(14)); var algorithm13 = load(__webpack_require__(7)); @@ -44400,7 +44475,7 @@ var qics = /***/ }, -/* 394 */ +/* 395 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44459,7 +44534,7 @@ var qics = /***/ }, -/* 395 */ +/* 396 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44516,7 +44591,7 @@ var qics = /***/ }, -/* 396 */ +/* 397 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44573,19 +44648,19 @@ var qics = /***/ }, -/* 397 */ +/* 398 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(394), - __webpack_require__(396), + __webpack_require__(395), + __webpack_require__(397), __webpack_require__(106), - __webpack_require__(395) + __webpack_require__(396) ]; /***/ }, -/* 398 */ +/* 399 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44650,7 +44725,7 @@ var qics = /***/ }, -/* 399 */ +/* 400 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44711,7 +44786,7 @@ var qics = /***/ }, -/* 400 */ +/* 401 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44774,19 +44849,19 @@ var qics = /***/ }, -/* 401 */ +/* 402 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(398), __webpack_require__(399), __webpack_require__(400), - __webpack_require__(402) + __webpack_require__(401), + __webpack_require__(403) ]; /***/ }, -/* 402 */ +/* 403 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -44849,7 +44924,7 @@ var qics = /***/ }, -/* 403 */ +/* 404 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45156,17 +45231,17 @@ var qics = /***/ }, -/* 404 */ +/* 405 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(405), - __webpack_require__(403) + __webpack_require__(406), + __webpack_require__(404) ]; /***/ }, -/* 405 */ +/* 406 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45314,31 +45389,31 @@ var qics = /***/ }, -/* 406 */ +/* 407 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(349), - __webpack_require__(375), - __webpack_require__(390), - __webpack_require__(397), - __webpack_require__(401), - __webpack_require__(404), - __webpack_require__(408), - __webpack_require__(415), - __webpack_require__(422), - __webpack_require__(430), - __webpack_require__(434), + __webpack_require__(350), + __webpack_require__(376), + __webpack_require__(391), + __webpack_require__(398), + __webpack_require__(402), + __webpack_require__(405), + __webpack_require__(409), + __webpack_require__(416), + __webpack_require__(423), + __webpack_require__(431), __webpack_require__(435), - __webpack_require__(441), - __webpack_require__(461), - __webpack_require__(468), - __webpack_require__(471) + __webpack_require__(436), + __webpack_require__(442), + __webpack_require__(462), + __webpack_require__(469), + __webpack_require__(472) ]; /***/ }, -/* 407 */ +/* 408 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45515,19 +45590,19 @@ var qics = /***/ }, -/* 408 */ +/* 409 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(407), + __webpack_require__(408), __webpack_require__(107), - __webpack_require__(409), - __webpack_require__(410) + __webpack_require__(410), + __webpack_require__(411) ]; /***/ }, -/* 409 */ +/* 410 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45691,7 +45766,7 @@ var qics = /***/ }, -/* 410 */ +/* 411 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45855,7 +45930,7 @@ var qics = /***/ }, -/* 411 */ +/* 412 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -45962,7 +46037,7 @@ var qics = /***/ }, -/* 412 */ +/* 413 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46138,7 +46213,7 @@ var qics = /***/ }, -/* 413 */ +/* 414 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46223,7 +46298,7 @@ var qics = /***/ }, -/* 414 */ +/* 415 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46274,29 +46349,29 @@ var qics = /***/ }, -/* 415 */ +/* 416 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(108), - __webpack_require__(411), - __webpack_require__(109), __webpack_require__(412), + __webpack_require__(109), __webpack_require__(413), - __webpack_require__(67), - __webpack_require__(110), __webpack_require__(414), + __webpack_require__(68), + __webpack_require__(110), + __webpack_require__(415), __webpack_require__(111), __webpack_require__(112), - __webpack_require__(416), - __webpack_require__(68), __webpack_require__(417), __webpack_require__(69), - __webpack_require__(113), __webpack_require__(418), + __webpack_require__(70), + __webpack_require__(113), __webpack_require__(419), __webpack_require__(420), __webpack_require__(421), + __webpack_require__(422), __webpack_require__(52), __webpack_require__(114), __webpack_require__(53), @@ -46305,7 +46380,7 @@ var qics = /***/ }, -/* 416 */ +/* 417 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46401,7 +46476,7 @@ var qics = /***/ }, -/* 417 */ +/* 418 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46541,7 +46616,7 @@ var qics = /***/ }, -/* 418 */ +/* 419 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46685,7 +46760,7 @@ var qics = /***/ }, -/* 419 */ +/* 420 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46746,7 +46821,7 @@ var qics = /***/ }, -/* 420 */ +/* 421 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46872,7 +46947,7 @@ var qics = /***/ }, -/* 421 */ +/* 422 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46939,7 +47014,7 @@ var qics = /***/ }, -/* 422 */ +/* 423 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ @@ -46947,17 +47022,17 @@ var qics = __webpack_require__(54), __webpack_require__(55), __webpack_require__(115), - __webpack_require__(423), __webpack_require__(424), __webpack_require__(425), __webpack_require__(426), __webpack_require__(427), - __webpack_require__(428) + __webpack_require__(428), + __webpack_require__(429) ]; /***/ }, -/* 423 */ +/* 424 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -46970,7 +47045,7 @@ var qics = var multiply = load(__webpack_require__(11)); var dotDivide = load(__webpack_require__(103)); var log = load(__webpack_require__(105)); - var isNumeric = load(__webpack_require__(72)); + var isNumeric = load(__webpack_require__(73)); /** * Calculate the Kullback-Leibler (KL) divergence between two distributions @@ -47054,7 +47129,7 @@ var qics = /***/ }, -/* 424 */ +/* 425 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -47113,7 +47188,7 @@ var qics = /***/ }, -/* 425 */ +/* 426 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -47213,13 +47288,13 @@ var qics = /***/ }, -/* 426 */ +/* 427 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(70)); + var distribution = load(__webpack_require__(71)); /** * Random pick one or more values from a one dimensional array. @@ -47264,13 +47339,13 @@ var qics = /***/ }, -/* 427 */ +/* 428 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(70)); + var distribution = load(__webpack_require__(71)); /** * Return a random number larger or equal to `min` and smaller than `max` @@ -47315,13 +47390,13 @@ var qics = /***/ }, -/* 428 */ +/* 429 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(70)); + var distribution = load(__webpack_require__(71)); /** * Return a random integer number larger or equal to `min` and smaller than `max` @@ -47364,13 +47439,13 @@ var qics = /***/ }, -/* 429 */ +/* 430 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load, typed) { - var equal = load(__webpack_require__(71)); + var equal = load(__webpack_require__(72)); /** * Test element wise whether two matrices are equal. @@ -47451,23 +47526,23 @@ var qics = /***/ }, -/* 430 */ +/* 431 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(47), - __webpack_require__(429), - __webpack_require__(71), + __webpack_require__(430), + __webpack_require__(72), __webpack_require__(27), __webpack_require__(116), __webpack_require__(39), - __webpack_require__(431), - __webpack_require__(432) + __webpack_require__(432), + __webpack_require__(433) ]; /***/ }, -/* 431 */ +/* 432 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -47647,7 +47722,7 @@ var qics = /***/ }, -/* 432 */ +/* 433 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -47857,7 +47932,7 @@ var qics = /***/ }, -/* 433 */ +/* 434 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48060,35 +48135,35 @@ var qics = /***/ }, -/* 434 */ +/* 435 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(433) + __webpack_require__(434) ]; /***/ }, -/* 435 */ +/* 436 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(436), + __webpack_require__(437), __webpack_require__(117), __webpack_require__(118), __webpack_require__(119), __webpack_require__(120), - __webpack_require__(437), __webpack_require__(438), __webpack_require__(439), __webpack_require__(440), + __webpack_require__(441), __webpack_require__(121), __webpack_require__(122) ]; /***/ }, -/* 436 */ +/* 437 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48097,7 +48172,7 @@ var qics = function factory (type, config, load, typed) { var abs = load(__webpack_require__(26)); - var map = load(__webpack_require__(68)); + var map = load(__webpack_require__(69)); var median = load(__webpack_require__(119)); var subtract = load(__webpack_require__(19)); @@ -48158,7 +48233,7 @@ var qics = /***/ }, -/* 437 */ +/* 438 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48240,7 +48315,7 @@ var qics = exports.factory = factory; /***/ }, -/* 438 */ +/* 439 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48322,7 +48397,7 @@ var qics = /***/ }, -/* 439 */ +/* 440 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48335,7 +48410,7 @@ var qics = function factory (type, config, load, typed) { var add = load(__webpack_require__(16)); var multiply = load(__webpack_require__(11)); - var partitionSelect = load(__webpack_require__(69)); + var partitionSelect = load(__webpack_require__(70)); var compare = load(__webpack_require__(47)); /** @@ -48585,7 +48660,7 @@ var qics = /***/ }, -/* 440 */ +/* 441 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48665,17 +48740,17 @@ var qics = /***/ }, -/* 441 */ +/* 442 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ __webpack_require__(123), - __webpack_require__(442) + __webpack_require__(443) ]; /***/ }, -/* 442 */ +/* 443 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48768,7 +48843,7 @@ var qics = /***/ }, -/* 443 */ +/* 444 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48833,7 +48908,7 @@ var qics = /***/ }, -/* 444 */ +/* 445 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48893,7 +48968,7 @@ var qics = /***/ }, -/* 445 */ +/* 446 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -48954,7 +49029,7 @@ var qics = /***/ }, -/* 446 */ +/* 447 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49018,7 +49093,7 @@ var qics = /***/ }, -/* 447 */ +/* 448 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49077,7 +49152,7 @@ var qics = /***/ }, -/* 448 */ +/* 449 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49140,7 +49215,7 @@ var qics = /***/ }, -/* 449 */ +/* 450 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49210,7 +49285,7 @@ var qics = /***/ }, -/* 450 */ +/* 451 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49276,7 +49351,7 @@ var qics = /***/ }, -/* 451 */ +/* 452 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49335,7 +49410,7 @@ var qics = /***/ }, -/* 452 */ +/* 453 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49396,7 +49471,7 @@ var qics = /***/ }, -/* 453 */ +/* 454 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49554,7 +49629,7 @@ var qics = /***/ }, -/* 454 */ +/* 455 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49625,7 +49700,7 @@ var qics = /***/ }, -/* 455 */ +/* 456 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49693,7 +49768,7 @@ var qics = /***/ }, -/* 456 */ +/* 457 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49765,7 +49840,7 @@ var qics = /***/ }, -/* 457 */ +/* 458 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49829,7 +49904,7 @@ var qics = /***/ }, -/* 458 */ +/* 459 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49904,7 +49979,7 @@ var qics = /***/ }, -/* 459 */ +/* 460 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -49968,7 +50043,7 @@ var qics = /***/ }, -/* 460 */ +/* 461 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50049,13 +50124,12 @@ var qics = /***/ }, -/* 461 */ +/* 462 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(443), - __webpack_require__(124), __webpack_require__(444), + __webpack_require__(124), __webpack_require__(445), __webpack_require__(446), __webpack_require__(447), @@ -50072,17 +50146,18 @@ var qics = __webpack_require__(458), __webpack_require__(459), __webpack_require__(460), - __webpack_require__(462), + __webpack_require__(461), __webpack_require__(463), __webpack_require__(464), __webpack_require__(465), __webpack_require__(466), - __webpack_require__(467) + __webpack_require__(467), + __webpack_require__(468) ]; /***/ }, -/* 462 */ +/* 463 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50146,7 +50221,7 @@ var qics = /***/ }, -/* 463 */ +/* 464 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50220,7 +50295,7 @@ var qics = /***/ }, -/* 464 */ +/* 465 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50289,7 +50364,7 @@ var qics = /***/ }, -/* 465 */ +/* 466 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50362,7 +50437,7 @@ var qics = /***/ }, -/* 466 */ +/* 467 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50427,7 +50502,7 @@ var qics = /***/ }, -/* 467 */ +/* 468 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50504,15 +50579,15 @@ var qics = /***/ }, -/* 468 */ +/* 469 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(469) + __webpack_require__(470) ]; /***/ }, -/* 469 */ +/* 470 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50608,7 +50683,7 @@ var qics = /***/ }, -/* 470 */ +/* 471 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50648,24 +50723,24 @@ var qics = /***/ }, -/* 471 */ +/* 472 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(470), + __webpack_require__(471), __webpack_require__(40), __webpack_require__(48), - __webpack_require__(72), + __webpack_require__(73), __webpack_require__(56), - __webpack_require__(473), + __webpack_require__(474), __webpack_require__(125), - __webpack_require__(472), + __webpack_require__(473), __webpack_require__(126) ]; /***/ }, -/* 472 */ +/* 473 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50737,7 +50812,7 @@ var qics = /***/ }, -/* 473 */ +/* 474 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -50824,30 +50899,30 @@ var qics = /***/ }, -/* 474 */ +/* 475 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(488), // data types (Matrix, Complex, Unit, ...) - __webpack_require__(143), // constants - __webpack_require__(333), // expression parsing - __webpack_require__(406), // functions - __webpack_require__(475), // serialization utility (math.json.reviver) - __webpack_require__(148) // errors + __webpack_require__(489), // data types (Matrix, Complex, Unit, ...) + __webpack_require__(144), // constants + __webpack_require__(334), // expression parsing + __webpack_require__(407), // functions + __webpack_require__(476), // serialization utility (math.json.reviver) + __webpack_require__(149) // errors ]; /***/ }, -/* 475 */ +/* 476 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(476) + __webpack_require__(477) ]; /***/ }, -/* 476 */ +/* 477 */ /***/ function(module, exports) { 'use strict'; @@ -50875,10 +50950,10 @@ var qics = /***/ }, -/* 477 */ +/* 478 */ /***/ function(module, exports, __webpack_require__) { - var Decimal = __webpack_require__(140); + var Decimal = __webpack_require__(141); function factory (type, config, load, typed, math) { var BigNumber = Decimal.clone({precision: config.precision}); @@ -50928,7 +51003,7 @@ var qics = exports.math = true; // request access to the math namespace /***/ }, -/* 478 */ +/* 479 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -51002,20 +51077,20 @@ var qics = /***/ }, -/* 479 */ +/* 480 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ // type - __webpack_require__(477), + __webpack_require__(478), // construction function - __webpack_require__(478) + __webpack_require__(479) ]; /***/ }, -/* 480 */ +/* 481 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -51099,7 +51174,7 @@ var qics = /***/ }, -/* 481 */ +/* 482 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -51270,7 +51345,7 @@ var qics = /***/ }, -/* 482 */ +/* 483 */ /***/ function(module, exports) { 'use strict'; @@ -51327,20 +51402,20 @@ var qics = /***/ }, -/* 483 */ +/* 484 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ // type - __webpack_require__(481), + __webpack_require__(482), // construction function - __webpack_require__(482) + __webpack_require__(483) ]; /***/ }, -/* 484 */ +/* 485 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -51446,7 +51521,7 @@ var qics = /***/ }, -/* 485 */ +/* 486 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ @@ -51454,15 +51529,15 @@ var qics = __webpack_require__(127), // construction function - __webpack_require__(484) + __webpack_require__(485) ]; /***/ }, -/* 486 */ +/* 487 */ /***/ function(module, exports, __webpack_require__) { - var Fraction = __webpack_require__(141); + var Fraction = __webpack_require__(142); /** * Attach type information @@ -51504,12 +51579,12 @@ var qics = /***/ }, -/* 487 */ +/* 488 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ // type - __webpack_require__(486), + __webpack_require__(487), // construction function __webpack_require__(128) @@ -51517,25 +51592,25 @@ var qics = /***/ }, -/* 488 */ +/* 489 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ - __webpack_require__(479), __webpack_require__(480), - __webpack_require__(483), - __webpack_require__(485), - __webpack_require__(487), - __webpack_require__(496), - __webpack_require__(76), + __webpack_require__(481), + __webpack_require__(484), + __webpack_require__(486), + __webpack_require__(488), __webpack_require__(497), + __webpack_require__(77), __webpack_require__(498), - __webpack_require__(502) + __webpack_require__(499), + __webpack_require__(503) ]; /***/ }, -/* 489 */ +/* 490 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -51890,7 +51965,7 @@ var qics = /***/ }, -/* 490 */ +/* 491 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -52120,7 +52195,7 @@ var qics = /***/ }, -/* 491 */ +/* 492 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -52409,7 +52484,7 @@ var qics = /***/ }, -/* 492 */ +/* 493 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -52556,7 +52631,7 @@ var qics = /***/ }, -/* 493 */ +/* 494 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -52577,7 +52652,7 @@ var qics = var validateIndex = array.validateIndex; function factory (type, config, load, typed) { - var Matrix = load(__webpack_require__(73)); // force loading Matrix (do not use via type.Matrix) + var Matrix = load(__webpack_require__(74)); // force loading Matrix (do not use via type.Matrix) var equalScalar = load(__webpack_require__(9)); /** @@ -53900,7 +53975,7 @@ var qics = /***/ }, -/* 494 */ +/* 495 */ /***/ function(module, exports) { 'use strict'; @@ -53970,7 +54045,7 @@ var qics = /***/ }, -/* 495 */ +/* 496 */ /***/ function(module, exports) { 'use strict'; @@ -54037,29 +54112,29 @@ var qics = /***/ }, -/* 496 */ +/* 497 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ // types - __webpack_require__(73), + __webpack_require__(74), __webpack_require__(129), + __webpack_require__(494), __webpack_require__(493), - __webpack_require__(492), - __webpack_require__(489), __webpack_require__(490), __webpack_require__(491), + __webpack_require__(492), __webpack_require__(130), // construction functions - __webpack_require__(494), + __webpack_require__(495), __webpack_require__(2), - __webpack_require__(495) + __webpack_require__(496) ]; /***/ }, -/* 497 */ +/* 498 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ @@ -54069,7 +54144,7 @@ var qics = /***/ }, -/* 498 */ +/* 499 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -54144,7 +54219,7 @@ var qics = /***/ }, -/* 499 */ +/* 500 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -54235,7 +54310,7 @@ var qics = /***/ }, -/* 500 */ +/* 501 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -54278,7 +54353,7 @@ var qics = /***/ }, -/* 501 */ +/* 502 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -54345,7 +54420,7 @@ var qics = /***/ }, -/* 502 */ +/* 503 */ /***/ function(module, exports, __webpack_require__) { module.exports = [ @@ -54353,21 +54428,21 @@ var qics = __webpack_require__(133), // construction function - __webpack_require__(501), + __webpack_require__(502), // create new units - __webpack_require__(499), + __webpack_require__(500), // split units - __webpack_require__(500), + __webpack_require__(501), // physical constants - __webpack_require__(503) + __webpack_require__(504) ]; /***/ }, -/* 503 */ +/* 504 */ /***/ function(module, exports, __webpack_require__) { var lazy = __webpack_require__(5).lazy; @@ -54457,7 +54532,7 @@ var qics = /***/ }, -/* 504 */ +/* 505 */ /***/ function(module, exports) { 'use strict'; @@ -54711,10 +54786,10 @@ var qics = /***/ }, -/* 505 */ +/* 506 */ /***/ function(module, exports, __webpack_require__) { - var bitwise = __webpack_require__(78); + var bitwise = __webpack_require__(79); /** * Bitwise and for Bignumbers @@ -54785,10 +54860,10 @@ var qics = /***/ }, -/* 506 */ +/* 507 */ /***/ function(module, exports, __webpack_require__) { - var bitwise = __webpack_require__(78); + var bitwise = __webpack_require__(79); /** * Bitwise OR for BigNumbers @@ -54844,11 +54919,11 @@ var qics = /***/ }, -/* 507 */ +/* 508 */ /***/ function(module, exports, __webpack_require__) { - var bitwise = __webpack_require__(78); - var bitNot = __webpack_require__(77); + var bitwise = __webpack_require__(79); + var bitNot = __webpack_require__(78); /** * Bitwise XOR for BigNumbers @@ -54910,7 +54985,7 @@ var qics = /***/ }, -/* 508 */ +/* 509 */ /***/ function(module, exports) { /** @@ -55099,7 +55174,7 @@ var qics = /***/ }, -/* 509 */ +/* 510 */ /***/ function(module, exports) { @@ -55146,7 +55221,7 @@ var qics = /***/ }, -/* 510 */ +/* 511 */ /***/ function(module, exports) { /* @@ -55199,7 +55274,7 @@ var qics = /***/ }, -/* 511 */ +/* 512 */ /***/ function(module, exports) { 'use strict'; @@ -55215,7 +55290,7 @@ var qics = /***/ }, -/* 512 */ +/* 513 */ /***/ function(module, exports) { 'use strict'; @@ -55285,7 +55360,7 @@ var qics = /***/ }, -/* 513 */ +/* 514 */ /***/ function(module, exports) { module.exports = '3.9.0'; @@ -55294,7 +55369,7 @@ var qics = /***/ }, -/* 514 */ +/* 515 */ /***/ function(module, exports) { // shim for using process in browser @@ -55480,7 +55555,7 @@ var qics = /***/ }, -/* 515 */ +/* 516 */ /***/ function(module, exports) { function E () { @@ -55552,7 +55627,7 @@ var qics = /***/ }, -/* 516 */ +/* 517 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** @@ -56945,7 +57020,7 @@ var qics = /***/ }, -/* 517 */ +/* 518 */ /***/ function(module, exports) { if (typeof Object.create === 'function') { @@ -56974,7 +57049,7 @@ var qics = /***/ }, -/* 518 */ +/* 519 */ /***/ function(module, exports) { module.exports = function isBuffer(arg) { @@ -56985,7 +57060,7 @@ var qics = } /***/ }, -/* 519 */ +/* 520 */ /***/ function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors. @@ -57513,7 +57588,7 @@ var qics = } exports.isPrimitive = isPrimitive; - exports.isBuffer = __webpack_require__(518); + exports.isBuffer = __webpack_require__(519); function objectToString(o) { return Object.prototype.toString.call(o); @@ -57557,7 +57632,7 @@ var qics = * prototype. * @param {function} superCtor Constructor function to inherit prototype from. */ - exports.inherits = __webpack_require__(517); + exports.inherits = __webpack_require__(518); exports._extend = function(origin, add) { // Don't do anything if add isn't an object @@ -57575,17 +57650,17 @@ var qics = return Object.prototype.hasOwnProperty.call(obj, prop); } - /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(514))) + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(515))) /***/ }, -/* 520 */ +/* 521 */ /***/ function(module, exports, __webpack_require__) { - module.exports = __webpack_require__(521) + module.exports = __webpack_require__(522) /***/ }, -/* 521 */ +/* 522 */ /***/ function(module, exports) { function getTotal(weights) { diff --git a/dist/qics.min.js b/dist/qics.min.js index d57c263..e93503a 100644 --- a/dist/qics.min.js +++ b/dist/qics.min.js @@ -1,10 +1,10 @@ -var qics=function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(79),i=r(138);e.exports={gates:n,Register:i}},function(e,t){"use strict";e.exports=function e(t,r,n){return t&&"function"==typeof t.map?t.map(function(t){return e(t,r,n)}):r(t)}},function(e,t){"use strict";function r(e,t,r,n){function i(t,r,n){var i=e.Matrix.storage(r||"default");return new i(t,n)}var a=n("matrix",{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i});return a.toTex={0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},a}t.name="matrix",t.factory=r},function(e,t,r){"use strict";var n=r(504);t.isNumber=function(e){return"number"==typeof e},t.isInteger=function(e){return!!isFinite(e)&&e==Math.round(e)},t.sign=Math.sign||function(e){return e>0?1:e<0?-1:0},t.format=function(e,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-(1/0))return"-Infinity";if(isNaN(e))return"NaN";var n="auto",i=void 0;switch(r&&(r.notation&&(n=r.notation),t.isNumber(r)?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"engineering":return t.toEngineering(e,i);case"auto":return t.toPrecision(e,i,r&&r.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return new n(e).toExponential(t)},t.toEngineering=function(e,t){return new n(e).toEngineering(t)},t.toFixed=function(e,t){return new n(e).toFixed(t)},t.toPrecision=function(e,t,r){return new n(e).toPrecision(t,r)},t.digits=function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},t.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,t.nearlyEqual=function(e,r,n){if(null==n)return e==r;if(e==r)return!0;if(isNaN(e)||isNaN(r))return!1;if(isFinite(e)&&isFinite(r)){var i=Math.abs(e-r);return i>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},t.defaultTemplate="\\mathrm{${name}}\\left(${args}\\right)";var r={deg:"^\\circ"};t.toSymbol=function(e,n){if(n="undefined"!=typeof n&&n)return r.hasOwnProperty(e)?r[e]:"\\mathrm{"+e+"}";if(t.symbols.hasOwnProperty(e))return t.symbols[e];if(e.indexOf("_")!==-1){var i=e.indexOf("_");return t.toSymbol(e.substring(0,i))+"_{"+t.toSymbol(e.substring(i+1))+"}"}return e}},function(e,t){"use strict";t.clone=function e(t){var r=typeof t;if("number"===r||"string"===r||"boolean"===r||null===t||void 0===t)return t;if("function"==typeof t.clone)return t.clone();if(Array.isArray(t))return t.map(function(t){return e(t)});if(t instanceof Number)return new Number(t.valueOf());if(t instanceof String)return new String(t.valueOf());if(t instanceof Boolean)return new Boolean(t.valueOf());if(t instanceof Date)return new Date(t.valueOf());if(t&&t.isBigNumber===!0)return t;if(t instanceof RegExp)throw new TypeError("Cannot clone "+t);var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=e(t[i]));return n},t.extend=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},t.deepExtend=function e(t,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(var n in r)if(r.hasOwnProperty(n))if(r[n]&&r[n].constructor===Object)void 0===t[n]&&(t[n]={}),t[n].constructor===Object?e(t[n],r[n]):t[n]=r[n];else{if(Array.isArray(r[n]))throw new TypeError("Arrays are not supported by deepExtend");t[n]=r[n]}return t},t.deepEqual=function(e,r){var n,i,a;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!=r.length)return!1;for(i=0,a=e.length;i0?s(p,0,f,f[0],c,t,o):[];return new a({data:h,size:i(f),datatype:u})},s=function(e,t,r,n,i,a,o){var u=[];if(t===r.length-1)for(var c=0;c0?s(g,0,h,h[0],o,f):[];return new i({data:v,size:h,datatype:d})},s=function(e,t,r,n,i,a){var o=[];if(t===r.length-1)for(var u=0;u")}function i(e,r,n,a){var o,s,u=e.length,c=r[n],f=Math.min(u,c);if(e.length=c,n=t)throw new f(e,t)},t.UNINITIALIZED={},t.resize=function(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");t.forEach(function(e){if(!s.isNumber(e)||!s.isInteger(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(t)+")")});var n=void 0!==r?r:0;return i(e,t,0,n),e},t.squeeze=function(e,r){for(var n=r||t.size(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var i=n.length;1===n[i-1];)i--;return i_)for(var C=0,S=0;S0)throw new Error("Calling compile(math) is deprecated. Call the function as compile() instead.");var e={math:o.expression.transform,args:{},_validateScope:u},t={},r=this._compile(e,t),n=Object.keys(e).map(function(e){return" var "+e+' = defs["'+e+'"];'}),i=n.join(" ")+'return { "eval": function (scope) { if (scope) _validateScope(scope); scope = scope || {}; return '+r+"; }};",a=new Function("defs",i);return a(e)},s.prototype._compile=function(e,t){throw new Error("Cannot compile a Node interface")},s.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},s.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},s.prototype._ifNode=function(e){if(!e||!e.isNode)throw new TypeError("Callback function must return a Node");return e},s.prototype.traverse=function(e){function t(e,r){e.forEach(function(e,n,i){r(e,n,i),t(e,r)})}e(this,null,null),t(this,e)},s.prototype.transform=function(e){function t(e,r){return e.map(function(e,n,i){var a=r(e,n,i);return t(a,r)})}var r=e(this,null,null);return t(r,e)},s.prototype.filter=function(e){var t=[];return this.traverse(function(r,n,i){e(r,n,i)&&t.push(r)}),t},s.prototype.find=function(){throw new Error("Function Node.find is deprecated. Use Node.filter instead.")},s.prototype.match=function(){throw new Error("Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.")},s.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},s.prototype.cloneDeep=function(){return this.map(function(e){return e.cloneDeep()})},s.prototype.equals=function(e){return!!e&&a(this,e)},s.prototype.toString=function(e){var t;if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":break;case"function":t=e.handler(this,e);break;default:throw new TypeError("Object or function expected as callback")}return"undefined"!=typeof t?t:this._toString(e)},s.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},s.prototype.toTex=function(e){var t;if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":break;case"function":t=e.handler(this,e);break;default:throw new TypeError("Object or function expected as callback")}return"undefined"!=typeof t?t:this._toTex(e)},s.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},s.prototype.getIdentifier=function(){return this.type},s.prototype.getContent=function(){return this},s}var i=r(62),a=(r(5).extend,r(5).deepEqual);t.name="Node",t.path="expression.node",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=e.DenseMatrix,o=function(e,t,r,o){var s=e._data,u=e._size,c=e._datatype,f=t._values,l=t._index,p=t._ptr,h=t._size,m=t._datatype;if(u.length!==h.length)throw new i(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,g=u[0],v=u[1],y=0,x=r;"string"==typeof c&&c===m&&(d=c,y=n.convert(0,d),x=n.find(r,[d,d]));for(var w=[],b=0;bt},"number, number":function(e,r){return e>r&&!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gt(r)&&!a(e,r,t.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 m(e.value,t.value)},"string, string":function(e,t){return e>t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,m);break;default:r=u(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,m,!1);break;default:r=l(e,t,m)}}return r},"Array, Array":function(e,t){return m(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return m(s(e),t)},"Matrix, Array":function(e,t){return m(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=p(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,m,!0);break;default:r=p(t,e,m,!0)}return r},"Array, any":function(e,t){return p(s(e),t,m,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+h.operators.larger+"${args[1]}\\right)"},m}var i=r(3).nearlyEqual,a=r(32);t.name="larger",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=e.DenseMatrix,o=function(e,t,r,o){var s=e._data,u=e._size,c=e._datatype,f=t._values,l=t._index,p=t._ptr,h=t._size,m=t._datatype;if(u.length!==h.length)throw new i(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,g,v=u[0],y=u[1],x="string"==typeof c&&c===m?c:void 0,w=x?n.find(r,[x,x]):r,b=[];for(d=0;d0?new K(r):e}function x(){var e,t,r,n,i=w();if("="==ye){if(i&&i.isSymbolNode)return e=i.name,m(),r=x(),new Q(new ce(e),r);if(i&&i.isAccessorNode)return m(),r=x(),new Q(i.object,i.index,r);if(i&&i.isFunctionNode&&(n=!0,t=[],e=i.name,i.args.forEach(function(e,r){e&&e.isSymbolNode?t[r]=e.name:n=!1}),n))return m(),r=x(),new re(e,t,r);throw W("Invalid left hand side of assignment operator =")}return i}function w(){for(var e=b();"?"==ye;){var t=be;be=we,m();var r=e,n=x();if(":"!=ye)throw W("False part of conditional expression expected");be=null,m();var i=x();e=new ee(r,n,i),be=t}return e}function b(){for(var e=N();"or"==ye;)m(),e=new ae("or","or",[e,N()]);return e}function N(){for(var e=E();"xor"==ye;)m(),e=new ae("xor","xor",[e,E()]);return e}function E(){for(var e=M();"and"==ye;)m(),e=new ae("and","and",[e,M()]);return e}function M(){for(var e=A();"|"==ye;)m(),e=new ae("|","bitOr",[e,A()]);return e}function A(){for(var e=O();"^|"==ye;)m(),e=new ae("^|","bitXor",[e,O()]);return e}function O(){for(var e=_();"&"==ye;)m(),e=new ae("&","bitAnd",[e,_()]);return e}function _(){var e,t,r,n,i;for(e=T(),t={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};ye in t;)r=ye,n=t[r],m(),i=[e,T()],e=new ae(r,n,i);return e}function T(){var e,t,r,n,i;for(e=C(),t={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};ye in t;)r=ye,n=t[r],m(),i=[e,C()],e=new ae(r,n,i);return e}function C(){var e,t,r,n,i;for(e=S(),t={to:"to",in:"to"};ye in t;)r=ye,n=t[r],m(),"in"===r&&""===ye?e=new ae("*","multiply",[e,new ce("in")],!0):(i=[e,S()],e=new ae(r,n,i));return e}function S(){var e,t=[];if(e=":"==ye?new te("1","number"):z(),":"==ye&&be!==we){for(t.push(e);":"==ye&&t.length<3;)m(),")"==ye||"]"==ye||","==ye||""==ye?t.push(new ce("end")):t.push(z());e=3==t.length?new ue(t[0],t[2],t[1]):new ue(t[0],t[1])}return e}function z(){var e,t,r,n,i;for(e=k(),t={"+":"add","-":"subtract"};ye in t;)r=ye,n=t[r],m(),i=[e,k()],e=new ae(r,n,i);return e}function k(){var e,t,r,n,i;for(e=B(),t=e,r={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};;)if(ye in r)n=ye,i=r[n],m(),t=B(),e=new ae(n,i,[e,t]);else{if(!(xe==fe.SYMBOL||"in"==ye&&e&&e.isConstantNode)&&(xe!=fe.NUMBER||t.isConstantNode||t.isOperatorNode&&"!"!==t.op)&&"("!=ye)break;t=B(),e=new ae("*","multiply",[e,t],!0)}return e}function B(){var e,t,r={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"}[ye];return r?(e=ye,m(),t=[B()],new ae(e,r,t)):I()}function I(){var e,t,r,n;return e=P(),"^"!=ye&&".^"!=ye||(t=ye,r="^"==t?"pow":"dotPow",m(),n=[e,B()],e=new ae(t,r,n)),e}function P(){var e,t,r,n,i;for(e=R(),t={"!":"factorial","'":"transpose"};ye in t;)r=ye,n=t[r],h(),i=[e],e=new ae(r,n,i),e=q(e);return e}function R(){var e,t=[];if(xe==fe.SYMBOL&&he[ye]){if(e=he[ye],h(),"("==ye){if(t=[],d(),h(),")"!=ye)for(t.push(x());","==ye;)h(),t.push(x());if(")"!=ye)throw W("Parenthesis ) expected");g(),h()}return new e(t)}return U()}function U(){var e,t;return xe==fe.SYMBOL||xe==fe.DELIMITER&&ye in pe?(t=ye,h(),e=new ce(t),e=q(e)):j()}function q(e,t){for(var r;!("("!=ye&&"["!=ye&&"."!=ye||t&&t.indexOf(ye)===-1);)if(r=[],"("==ye){if(!(e.isSymbolNode||e.isAccessorNode||e.isFunctionNode))return e;if(d(),h(),")"!=ye)for(r.push(x());","==ye;)h(),r.push(x());if(")"!=ye)throw W("Parenthesis ) expected");g(),h(),e=new se(e,r)}else if("["==ye){if(d(),h(),"]"!=ye)for(r.push(x());","==ye;)h(),r.push(x());if("]"!=ye)throw W("Parenthesis ] expected");g(),h(),e=new X(e,new ne(r))}else{if(h(),xe!=fe.SYMBOL)throw W("Property name expected after dot");r.push(new te(ye)),h();var n=!0;e=new X(e,new ne(r,n))}return e}function j(){var e,t;return'"'==ye?(t=L(),e=new te(t,"string"),e=q(e)):F()}function L(){for(var e="";""!=ve&&'"'!=ve;)"\\"==ve&&(e+=ve,c()),e+=ve,c();if(h(),'"'!=ye)throw W('End of string " expected');return h(),e}function F(){var e,t,r,n;if("["==ye){if(d(),h(),"]"!=ye){var i=D();if(";"==ye){for(r=1,t=[i];";"==ye;)h(),t[r]=D(),r++;if("]"!=ye)throw W("End of matrix ] expected");g(),h(),n=t[0].items.length;for(var a=1;a":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},pe={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},he={},me="",de="",ge=0,ve="",ye="",xe=fe.NULL,we=0,be=null;return s.isAlpha=function(e,t,r){return s.isValidLatinOrGreek(e)||s.isValidMathSymbol(e,r)||s.isValidMathSymbol(t,e)},s.isValidLatinOrGreek=function(e){return/^[a-zA-Z_\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},s.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\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(t)},s.isWhitespace=function(e,t){return" "==e||"\t"==e||"\n"==e&&t>0},s.isDecimalMark=function(e,t){return"."==e&&"/"!==t&&"*"!==t&&"^"!==t},s.isDigitDot=function(e){return e>="0"&&e<="9"||"."==e},s.isDigit=function(e){return e>="0"&&e<="9"},s}var i=r(42),a=r(1);t.name="parse",t.path="expression",t.factory=n},function(e,t,r){var n=r(43);t.transform=function(e){return e&&e.isIndexError?new n(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}},function(e,t){"use strict";function r(e,t,r,n){var i=e.DenseMatrix,a=function(e,t,r,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,f=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var l,p=c[0],h=c[1],m=r;"string"==typeof f&&(l=f,t=n.convert(t,l),m=n.find(r,[l,l]));for(var d=[],g=new i({data:d,size:[p,h],datatype:l}),v=[],y=[],x=0;x=0||t.predictable?Math.pow(r,n):new e.Complex(r,0).pow(n,0)}function u(e,t){if(!i(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=a(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 n=l(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(n=p(o,n)),t>>=1,o=p(o,o);return n}function c(e,t){return h(u(e.valueOf(),t))}var f=r(4),l=n(r(67)),p=n(r(11)),h=n(r(2)),m=n(r(128)),d=n(r(76)),g=o("pow",{"number, number":s,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(r,n){return n.isInteger()||r>=0||t.predictable?r.pow(n):new e.Complex(r.toNumber(),0).pow(n.toNumber(),0)},"Fraction, Fraction":function(e,r){if(1!==r.d){if(t.predictable)throw new Error("Function pow does not support non-integer exponents for fractions.");return s(e.valueOf(),r.valueOf())}return e.pow(r)},"Array, number":u,"Array, BigNumber":function(e,t){return u(e,t.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(e,t){return c(e,t.toNumber())},"Unit, number":function(e,t){return e.pow(t)}});return g.toTex={2:"\\left(${args[0]}\\right)"+f.operators.pow+"{${args[1]}}"},g}var i=r(3).isInteger,a=r(8).size;t.name="pow",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("unaryMinus",{number:function(e){return-e},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=s(e.value),t},"Array | Matrix":function(e){return i(e,s,!0)}});return s.toTex={1:o.operators.unaryMinus+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="unaryMinus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=u(t),i=n?new e.BigNumber(0):0;if(c(t),r){var o=f(r);return t.length>0?o.resize(t,i):o}var s=[];return t.length>0?a(s,t,i):s}function u(e){var t=!1;return e.forEach(function(e,r,n){e&&e.isBigNumber===!0&&(t=!0,n[r]=e.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")})}var f=n(r(2)),l=o("zeros",{"":function(){return"Array"===t.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var r=e[e.length-1];if("string"==typeof r){var n=e.pop();return s(e,n)}return"Array"===t.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var t=e.storage();return s(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return s(e.valueOf(),t)}});return l.toTex=void 0,l}var i=r(3).isInteger,a=r(8).resize;t.name="zeros",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(2)),u=n(r(13)),c=n(r(23)),f=n(r(15)),l=n(r(7)),p=n(r(6)),h=r(4),m=o("smaller",{"boolean, boolean":function(e,t){return e=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}r.prototype=new RangeError,r.prototype.constructor=RangeError,r.prototype.name="IndexError",r.prototype.isIndexError=!0,e.exports=r},function(e,t,r){"use strict";function n(e,t,n,a){function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t){if("string"!=typeof t)throw new TypeError('String expected for parameter "valueType"');if("string"!=typeof e)throw new TypeError('String expected for parameter "value"');this.value=e,this.valueType=t}else this.value=e+"",this.valueType=i(e);if(!u[this.valueType])throw new TypeError('Unsupported type of value "'+this.valueType+'"')}var s=n(r(12)),u={number:!0,string:!0,boolean:!0,undefined:!0,null:!0};return o.prototype=new s,o.prototype.type="ConstantNode",o.prototype.isConstantNode=!0,o.prototype._compile=function(e,t){switch(this.valueType){case"number":var r=e.math.config().number;return"BigNumber"===r?'math.bignumber("'+this.value+'")':"Fraction"===r?'math.fraction("'+this.value+'")':this.value.replace(/^(0*)[0-9]/,function(e,t){return e.substring(t.length)});case"string":return'"'+this.value+'"';case"boolean":return this.value;case"undefined":return this.value;case"null":return this.value;default:throw new TypeError('Unsupported type of constant "'+this.valueType+'"')}},o.prototype.forEach=function(e){},o.prototype.map=function(e){return this.clone()},o.prototype.clone=function(){return new o(this.value,this.valueType)},o.prototype._toString=function(e){switch(this.valueType){case"string":return'"'+this.value+'"';default:return this.value}},o.prototype._toTex=function(e){var t,r=this.value;switch(this.valueType){case"string":return'\\mathtt{"'+r+'"}';case"number":return t=r.toLowerCase().indexOf("e"),t!==-1?r.substring(0,t)+"\\cdot10^{"+r.substring(t+1)+"}":r;default:return r}},o}var i=r(61).type;t.name="ConstantNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a,o){function s(e,t){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new f(e)),!e||!e.isNode)throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(function(e){return e&&e.isNode}))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")}});var r=function(){throw new Error("Property `FunctionNode.object` is deprecated, use `FunctionNode.fn` instead")};Object.defineProperty(this,"object",{get:r,set:r})}function u(e,t,r){for(var n,i="",a=new RegExp("\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)","ig"),o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var s=t[n[1]];if(!s)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof s){case"string":i+=s;break;case"object":if(s.isNode)i+=s.toTex(r);else{if(!Array.isArray(s))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=s.map(function(e,t){if(e&&e.isNode)return e.toTex(r);throw new TypeError("Template: "+n[1]+"["+t+"] is not a Node.")}).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!s[n[2]]||!s[n[2]].isNode)throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=s[n[2]].toTex(r)}}return i+=e.slice(o)}var c=n(r(12)),f=n(r(25));s.prototype=new c,s.prototype.type="FunctionNode",s.prototype.isFunctionNode=!0,s.prototype._compile=function(e,t){var r,n=this.fn._compile(e,t),i=this.args.map(function(r){return r._compile(e,t)});if(this.fn.isSymbolNode){var a=this.fn.name,o=e.math[a],s="function"==typeof o&&1==o.rawArgs;return s?(r=this._getUniqueArgumentsName(e),e[r]=this.args,n+"("+r+", math, scope)"):n+"("+i.join(", ")+")"}if(this.fn.isAccessorNode&&this.fn.index.isObjectProperty()){r=this._getUniqueArgumentsName(e),e[r]=this.args;var u=this.fn.object._compile(e,t),c=this.fn.index.getObjectProperty();return"(function () {var object = "+u+';return (object["'+c+'"] && object["'+c+'"].rawArgs) ? object["'+c+'"]('+r+', math, scope) : object["'+c+'"]('+i.join(", ")+")})()"}return r=this._getUniqueArgumentsName(e),e[r]=this.args,"(function () {var fn = "+n+";return (fn && fn.rawArgs) ? fn("+r+", math, scope) : fn("+i.join(", ")+")})()"},s.prototype._getUniqueArgumentsName=function(e){var t,r=0;do t="args"+r,r++;while(t in e);return t},s.prototype.forEach=function(e){for(var t=0;tt?1:-1},"number, number":function(e,r){return e===r||i(e,r,t.epsilon)?0:e>r?1:-1},"BigNumber, BigNumber":function(r,n){return r.eq(n)||a(r,n,t.epsilon)?new e.BigNumber(0):new e.BigNumber(r.cmp(n))},"Fraction, Fraction":function(t,r){return new e.Fraction(t.compare(r))},"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 h(e.value,t.value)},"string, string":function(e,t){return e===t?0:e>t?1:-1},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,h);break;default:r=u(t,e,h,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,h,!1);break;default:r=l(e,t,h)}}return r},"Array, Array":function(e,t){return h(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return h(s(e),t)},"Matrix, Array":function(e,t){return h(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,h,!1);break;default:r=p(e,t,h,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,h,!0);break;default:r=p(t,e,h,!0)}return r},"Array, any":function(e,t){return p(s(e),t,h,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,h,!0).valueOf()}});return h.toTex=void 0,h}var i=r(3).nearlyEqual,a=r(32);t.name="compare",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNegative",{number:function(e){return e<0},BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isNegative",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o,s){function u(e,t,r,n){if(!(this instanceof u))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(r)||!r.every(function(e){return e&&e.isNode}))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=n===!0,this.op=e,this.fn=t,this.args=r||[]}function c(e,t,r,n){var i=a.getPrecedence(e,t),o=a.getAssociativity(e,t);if("all"===t||r.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier()){var s=r.map(function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});return s}if(0===r.length)return[];if(1===r.length){var u=a.getPrecedence(r[0],t);if(n&&null!==u){var c,f;if("keep"===t?(c=r[0].getIdentifier(),f=e.getIdentifier()):(c=r[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),a.properties[i][f].latexLeftParens===!1)return[!1];if(a.properties[u][c].latexParens===!1)return[!1]}return null===u?[!1]:u<=i?[!0]:[!1]}if(2===r.length){var l,p=a.getPrecedence(r[0],t),h=a.isAssociativeWith(e,r[0],t);l=null!==p&&(p===i&&"right"===o&&!h||p2&&("OperatorNode:add"===e.getIdentifier()||"OperatorNode:multiply"===e.getIdentifier())){var x=r.map(function(r){var n=a.getPrecedence(r,t),s=a.isAssociativeWith(e,r,t),u=a.getAssociativity(r,t);return null!==n&&(i===n&&o===u&&!s||n2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var l=n.map(function(t,r){return t=t.toString(e),i[r]&&(t="("+t+")"),t});return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(" "):l.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},u.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",n=this.args,o=c(this,t,n,!0),s=i.operators[this.fn];if(s="undefined"==typeof s?this.op:s,1===n.length){var u=a.getAssociativity(this,t),f=n[0].toTex(e);return o[0]&&(f="\\left("+f+"\\right)"),"right"===u?s+f:"left"===u?f+s:f+s}if(2===n.length){var l=n[0],p=l.toTex(e);o[0]&&(p="\\left("+p+"\\right)");var h=n[1],m=h.toTex(e);o[1]&&(m="\\left("+m+"\\right)");var d;switch(d="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+p+"}{"+m+"}";case"OperatorNode:pow":switch(p="{"+p+"}",m="{"+m+"}",d){case"ConditionalNode":case"OperatorNode:divide":p="\\left("+p+"\\right)"}case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return p+"~"+m}return p+s+m}if(n.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var g=n.map(function(t,r){return t=t.toTex(e),o[r]&&(t="\\left("+t+"\\right)"),t});return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?g.join("~"):g.join(s)}return"\\mathrm{"+this.fn+"}\\left("+n.map(function(t){return t.toTex(e)}).join(",")+"\\right)"},u.prototype.getIdentifier=function(){return this.type+":"+this.fn},u}var i=r(4),a=r(46);t.name="OperatorNode",t.path="expression.node",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e||!e.isNode)throw new TypeError('Node expected for parameter "content"');this.content=e}var o=n(r(12));return a.prototype=new o,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(e,t){return this.content._compile(e,t)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(e){e(this.content,"content",this)},a.prototype.map=function(e){var t=e(this.content,"content",this);return new a(t)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},a.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left("+this.content.toTex(e)+"\\right)":this.content.toTex(e)},a}t.name="ParenthesisNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function a(r){return r>=0||t.predictable?Math.sqrt(r):new e.Complex(r,0).sqrt()}var o=n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},"Array | Matrix":function(e){return i(e,o,!0)},Unit:function(e){return e.pow(.5)}});return o.toTex={1:"\\sqrt{${args[0]}}"},o}var i=r(1);t.name="sqrt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,c){function f(e,t){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(1!=t.size().length)throw new u(t.size().length,1);var r=e.length;s(t.min()[0],r),s(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach(function(t){i+=e.charAt(t)}),i}function l(e,t,r,n){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(1!=t.size().length)throw new u(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),a=i.size()[0];if(a!=r.length)throw new u(i.size()[0],r.length);var o=e.length;s(t.min()[0]),s(t.max()[0]);for(var c=[],f=0;fo)for(f=o-1,a=c.length;fe)throw new TypeError("k must be less than or equal to n");for(r=Math.max(t,e-t),n=1,i=1;i<=e-r;i++)n=n*(r+i)/i;return n},"BigNumber, BigNumber":function(t,r){var n,a,o,s,u=new e.BigNumber(1);if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");for(n=t.minus(r),r.lt(n)&&(n=r),a=u,o=u,s=t.minus(n);o.lte(s);o=o.plus(1))a=a.times(n.plus(o)).dividedBy(o);return a}});return o.toTex={2:"\\binom{${args[0]}}{${args[1]}}"},o}function i(e){return e.isInteger()&&e.gte(0)}var a=r(3).isInteger;t.name="combinations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(115)),s=r(4),u=a("factorial",{number:function(e){if(e<0)throw new Error("Value must be non-negative");return o(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return o(e.plus(1))},"Array | Matrix":function(e){return i(e,u)}});return u.toTex={1:"\\left(${args[0]}\\right)"+s.operators.factorial},u}var i=r(1);t.name="factorial",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isPositive",{number:function(e){return e>0},BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isPositive",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_=n&&p?[]:void 0,T=[],C=[],S=new s({values:_,index:T,ptr:C,size:[y,x],datatype:v}),z=_?[]:void 0,k=_?[]:void 0,B=[],I=[];for(M=0;M=i.length)throw new o(t,i.length);return e&&e.isMatrix===!0?e.create(n(e.valueOf(),t,r)):n(e,t,r)}},function(e,t){"use strict";t.type=function(e){var t=typeof e;return"object"===t?null===e?"null":e instanceof Boolean?"boolean":e instanceof Number?"number":e instanceof String?"string":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":"Object":"function"===t?"Function":t},t.isScalar=function(e){return!(e&&e.isMatrix||Array.isArray(e))}},function(e,t){"use strict";e.exports={end:!0}},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(function(e){return e&&e.isNode}))throw new TypeError("Array containing Nodes expected");var t=function(){throw new Error("Property `ArrayNode.nodes` is deprecated, use `ArrayNode.items` instead")};Object.defineProperty(this,"nodes",{get:t,set:t})}var o=n(r(12));return a.prototype=new o,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(e,t){var r="Array"!==e.math.config().matrix,n=this.items.map(function(r){return r._compile(e,t)});return(r?"math.matrix([":"[")+n.join(",")+(r?"])":"]")},a.prototype.forEach=function(e){for(var t=0;t3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}function s(e,t){var r=i.getPrecedence(e,t),n={},a=i.getPrecedence(e.start,t);if(n.start=null!==a&&a<=r||"all"===t,e.step){var o=i.getPrecedence(e.step,t);n.step=null!==o&&o<=r||"all"===t}var s=i.getPrecedence(e.end,t);return n.end=null!==s&&s<=r||"all"===t,n}var u=n(r(12));return o.prototype=new u,o.prototype.type="RangeNode",o.prototype.isRangeNode=!0,o.prototype.needsEnd=function(){var e=this.filter(function(e){return e&&e.isSymbolNode&&"end"==e.name});return e.length>0},o.prototype._compile=function(e,t){return"math.range("+this.start._compile(e,t)+", "+this.end._compile(e,t)+(this.step?", "+this.step._compile(e,t):"")+")"},o.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},o.prototype.clone=function(){return new o(this.start,this.end,this.step&&this.step)},o.prototype._toString=function(e){var t,r=e&&e.parenthesis?e.parenthesis:"keep",n=s(this,r),i=this.start.toString(e);if(n.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),t+=":"+o},o.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=s(this,t),n=this.start.toTex(e);if(r.start&&(n="\\left("+n+"\\right)"),this.step){var i=this.step.toTex(e);r.step&&(i="\\left("+i+"\\right)"),n+=":"+i}var a=this.end.toTex(e);return r.end&&(a="\\left("+a+"\\right)"),n+=":"+a},o}var i=r(46);t.name="RangeNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e){var t=e.DenseMatrix,r=function(e,r,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+a.format(i)+")");var u=i[0],c=i[1];if(u!==c)throw new RangeError("Matrix must be square (size: "+a.format(i)+")");var f,l,p;if(r&&r.isMatrix===!0){var h=r.size();if(1===h.length){if(h[0]!==u)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(f=[],p=r._data,l=0;l1)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,r){if(t>=e.length)throw new Error("k out of bounds");for(var n=0,i=e.length-1;n=0){var u=e[o];e[o]=e[a],e[a]=u,--o}else++a;r(e[a],s)>0&&--a,t<=a?i=a:n=a+1}return e[t]}var c=n(r(47));return a("partitionSelect",{"Array | Matrix, number":function(e,t){return s(e,t,c)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,c);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s})}var i=r(3).isInteger;t.name="partitionSelect",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e){if(!l.hasOwnProperty(e))throw new Error("Unknown distribution "+e);var t=Array.prototype.slice.call(arguments,1),r=l[e].apply(this,t);return function(e){var t={random:function(e,t,r){var s,u,f;if(arguments.length>3)throw new i("random",arguments.length,0,3);if(1===arguments.length?a(e)?s=e:f=e:2===arguments.length?a(e)?(s=e,f=t):(u=e,f=t):(s=e,u=t,f=r),void 0!==u&&!o(u)||void 0!==f&&!o(f))throw new TypeError("Invalid argument in function random");if(void 0===f&&(f=1),void 0===u&&(u=0),void 0!==s){var p=l(s.valueOf(),u,f,n);return s&&s.isMatrix===!0?c(p):p}return n(u,f)},randomInt:s({"number | Array":function(e){var t=0;if(a(e)){var r=e,n=1,i=l(r.valueOf(),t,n,u);return r&&r.isMatrix===!0?c(i):i}var n=e;return u(t,n)},"number | Array, number":function(e,t){if(a(e)){var r=e,n=t,i=0,o=l(r.valueOf(),i,n,u);return r&&r.isMatrix===!0?c(o):o}var i=e,n=t;return u(i,n)},"Array, number, number":function(e,t,r){var n=l(e.valueOf(),t,r,u);return e&&e.isMatrix===!0?c(n):n}}),pickRandom:s({Array:function(e){return r(e)},"Array, number | Array":function(e,t){var n,i;if(Array.isArray(t))i=t;else{if(!o(t))throw new TypeError("Invalid argument in function pickRandom");n=t}return r(e,n,i)},"Array, number | Array, Array | number":function(e,t,n){var i,a;if(Array.isArray(t)?(a=t,i=n):(a=n,i=t),!Array.isArray(a)||!o(i))throw new TypeError("Invalid argument in function pickRandom");return r(e,i,a)}})},r=function(e,t,r){var n="undefined"==typeof t;if(n&&(t=1),e&&e.isMatrix===!0)e=e.valueOf();else if(!Array.isArray(e))throw new TypeError("Unsupported type of value in function pickRandom");if(f.size(e).length>1)throw new Error("Only one dimensional vectors supported");if("undefined"!=typeof r){if(r.length!=e.length)throw new Error("Weights must have the same length as possibles");for(var i=0,a=0,s=r.length;a=u)return e;for(var c,l=[];l.length1)for(var a=0,i=e.shift();a1;)e=Math.random(),t=Math.random(),r=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*t)+.5;return r}}};return u.toTex=void 0,u}var i=r(42),a=r(41),o=r(3).isNumber;t.name="distribution",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(9)),s=n(r(13)),u=n(r(23)),c=n(r(15)),f=n(r(7)),l=n(r(6)),p=r(4),h=i("equal",{"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:o(e,t)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=u(e,t,o);break;default:r=s(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=s(e,t,o,!1);break;default:r=f(e,t,o)}}return r},"Array, Array":function(e,t){return h(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return h(a(e),t)},"Matrix, Array":function(e,t){return h(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=l(e,t,o,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=c(t,e,o,!0);break;default:r=l(t,e,o,!0)}return r},"Array, any":function(e,t){return l(a(e),t,o,!1).valueOf()},"any, Array":function(e,t){return l(a(t),e,o,!0).valueOf()}});return h.toTex={2:"\\left(${args[0]}"+p.operators.equal+"${args[1]}\\right)"},h}t.name="equal",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string":function(){return!1},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isNumeric",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.storage=function(e){if(!o(e))throw new TypeError("format must be a string value");var t=i._storage[e];if(!t)throw new SyntaxError("Unsupported matrix storage format: "+e);return t},i._storage={},i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i}var i=r(24),a=i.string,o=a.isString;t.name="Matrix",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_,T=n&&p?[]:void 0,C=[],S=[],z=new s({values:T,index:C,ptr:S,size:[y,x],datatype:v}),k=n&&p?[]:void 0,B=n&&p?[]:void 0,I=[],P=[];for(M=0;M0)if(++s>c)for(s-=c;s--;u+="0");else s1&&(null==f[o+1]&&(f[o+1]=0),f[o+1]+=f[o]>>1,f[o]&=1)}return f.reverse()}var i=r(77);e.exports=function(e,t,r){var a,o,s=e.constructor,u=+(e.s<0),c=+(t.s<0);if(u){a=n(i(e));for(var f=0;f0;)r(l[--m],p[--d])==g&&(v=v.plus(y)),y=y.times(x);for(;d>0;)r(h,p[--d])==g&&(v=v.plus(y)),y=y.times(x);return s.config({precision:w}),0==g&&(v.s=-v.s),v}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:1;if("CNOT"===e){for(var i=r,o=n,s=a.eye(2),u=this.X,c=[[NaN,0],[0,1]],f=[],l=1;l<=t;l++)l===i?f.push(c):l===o?f.push(u):f.push(s);var p=f.reduce(function(e,t){return a.kron(e,t)});"Matrix"===a.typeof(p)&&(p=p.toArray());for(var h=0;h0)for(t=0;t0&&C.forEach(0,r-1,function(e,t){d._forEachRow(e,y,x,w,function(r,n){r>e&&C.accumulate(r,m(f(n,t)))})});var k=r,B=C.get(r),I=s(B);C.forEach(r+1,i-1,function(e,t){var r=s(t);p(r,I)&&(k=e,I=r,B=t)}),r!==k&&(d._swapRows(r,k,b[1],y,x,w),d._swapRows(r,k,A[1],N,E,M),C.swap(r,k),T(r,k)),C.forEach(0,i-1,function(e,t){e<=r?(N.push(t),E.push(e)):(t=c(t,B),h(t,0)||(y.push(t),x.push(e)))})}return M.push(N.length),w.push(y.length),{L:new d({values:y,index:x,ptr:w,size:b}),U:new d({values:N,index:E,ptr:M,size:A}),p:O,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}};return y}var i=r(24),a=i.object;t.name="lup",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(364)),s=n(r(359)),u=i("slu",{"SparseMatrix, number, number":function(e,t,r){if(!o(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=a(t,e,!1),i=s(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"}}}});return u}var i=r(24),a=i.number,o=a.isInteger;t.name="slu",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){return e.transform(function(e,t,r){return e.isParenthesisNode?e.content:e})}function o(e){for(var t=[],r=0;r");if(2!==u.length)throw SyntaxError("Could not parse rule: "+i);i={l:u[0],r:u[1]};case"object":if(n={l:a(m(i.l)),r:a(m(i.r))},i.context&&(n.evaluate=i.context),i.evaluate&&(n.evaluate=m(i.evaluate)),n.l.isOperatorNode&&E(n.l)){var c=_(n.l),f=s();n.expanded={},n.expanded.l=c([n.l.clone(),f]),M(n.expanded.l),A(n.expanded.l),n.expanded.r=c([n.r,f])}break;case"function":n=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(n)}return t}function s(){return new x("_p"+C++)}function u(e,t){var r,n,i=[],a=_(e);if(N(e,t))for(var o=0;o=2&&2===e.args.length){for(var i=u(t,e.context),a=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var c=[],o=0;o2&&o(e)){for(var i=e.args.pop();e.args.length>0;)i=t([e.args.pop(),i]);e.args=i.args}}}function f(e){if(e.args&&0!==e.args.length){for(var t=l(e),r=e.args.length,n=0;n2&&o(e)){for(var i=e.args.shift();e.args.length>0;)i=t([i,e.args.shift()]);e.args=i.args}}}function l(e){return e.isOperatorNode?function(t){try{return new h(e.op,e.fn,t)}catch(e){return console.error(e),[]}}:function(t){return new p(new m(e.name),t)}}var p=i.expression.node.FunctionNode,h=i.expression.node.OperatorNode,m=i.expression.node.SymbolNode,d={add:!0,multiply:!0},g={add:!0,multiply:!0};return{createMakeNodeFunction:l,isCommutative:a,isAssociative:o,flatten:s,allChildren:u,unflattenr:c,unflattenl:f}}t.factory=r,t.math=!0},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(17)),s=n(r(21)),u=n(r(19)),c=n(r(9)),f=n(r(65)),l=e.DenseMatrix,p=i("lsolve",{"SparseMatrix, Array | Matrix":function(e,t){return m(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return h(e,t)},"Array, Array | Matrix":function(e,t){var r=a(e),n=h(r,t);return n.valueOf()}}),h=function(e,t){t=f(e,t,!0);for(var r=t._data,n=e._size[0],i=e._size[1],a=[],p=e._data,h=0;hv&&(w.push(h[n]),b.push(r));if(c(x,0))throw new Error("Linear system cannot be solved since matrix is singular");var E=o(y,x);for(n=0,N=b.length;n=0;h--){var m,d=r[h][0]||0;if(c(d,0))m=0;else{var g=p[h][h];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=o(d,g);for(var v=h-1;v>=0;v--)r[v]=[u(r[v][0]||0,s(m,p[v][h]))]}a[h]=[m]}return new l({data:a,size:[n,1]})},m=function(e,t){t=f(e,t,!0);for(var r,n,i=t._data,a=e._size[0],p=e._size[1],h=e._values,m=e._index,d=e._ptr,g=[],v=p-1;v>=0;v--){var y=i[v][0]||0;if(c(y,0))g[v]=[0];else{var x=0,w=[],b=[],N=d[v],E=d[v+1];for(n=E-1;n>=N;n--)r=m[n],r===v?x=h[n]:r=0;){var u=r[o+s],c=r[n+u];c==-1?(s--,a[t++]=u):(r[n+u]=r[i+c],++s,r[o+s]=c)}return t};return e}t.name="cs_tdfs",t.path="sparse",t.factory=r},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(17)),s=r(4),u=n(r(22)),c=n(r(13)),f=n(r(23)),l=n(r(14)),p=n(r(15)),h=n(r(7)),m=n(r(6)),d=i("dotDivide",{"any, any":o,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,o,!1);break;default:r=u(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=h(e,t,o)}}return r},"Array, Array":function(e,t){return d(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return d(a(e),t)},"Matrix, Array":function(e,t){return d(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,o,!1);break;default:r=m(e,t,o,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=p(t,e,o,!0);break;default:r=m(t,e,o,!0)}return r},"Array, any":function(e,t){return m(a(e),t,o,!1).valueOf()},"any, Array":function(e,t){return m(a(t),e,o,!0).valueOf()}});return d.toTex={2:"\\left(${args[0]}"+s.operators.dotDivide+"${args[1]}\\right)"},d}t.name="dotDivide",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("fix",{number:function(e){return e>0?Math.floor(e):Math.ceil(e)},Complex:function(t){return new e.Complex(t.re>0?Math.floor(t.re):Math.ceil(t.re),t.im>0?Math.floor(t.im):Math.ceil(t.im))},BigNumber:function(e){return e.isNegative()?e.ceil():e.floor()},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="fix",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(17)),s=a("log",{number:function(r){return r>=0||t.predictable?Math.log(r):new e.Complex(r,0).log()},Complex:function(e){return e.log()},BigNumber:function(r){return!r.isNegative()||t.predictable?r.ln():new e.Complex(r.toNumber(),0).log()},"Array | Matrix":function(e){return i(e,s)},"any, any":function(e,t){return o(s(e),s(t))}});return s.toTex={1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},s}var i=r(1);t.name="log",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(19)),s=n(r(11)),u=n(r(35)),c=n(r(36)),f=n(r(55)),l=n(r(54)),p=n(r(48)),h=n(r(40)),m=n(r(27)),d=i("stirlingS2",{"number | BigNumber, number | BigNumber":function(e,t){if(!h(e)||p(e)||!h(t)||p(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(m(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var r=f(t),n=0,i=0;i<=t;i++){var d=c(-1,o(t,i)),g=l(t,i),v=c(i,e);n=a(n,s(s(g,v),d))}return u(n,r)}});return d.toTex={2:"\\mathrm{S}\\left(${args}\\right)"},d}t.name="stirlingS2",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("not",{number:function(e){return!e},Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return s(e.value)},"Array | Matrix":function(e){return i(e,s)}});return s.toTex={1:o.operators.not+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="not",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){var l=n(r(2)),p=f("concat",{"...Array | Matrix | number | BigNumber":function(e){var t,r,n=e.length,f=-1,p=!1,h=[];for(t=0;t0&&f>r)throw new u(f,r+1)}else{var d=a(m).valueOf(),g=s.size(d);if(h[t]=d,r=f,f=g.length-1,t>0&&f!=r)throw new c(r+1,f+1)}}if(0==h.length)throw new SyntaxError("At least one matrix expected");for(var v=h.shift();h.length;)v=i(v,h.shift(),f,0);return p?l(v):v},"...string":function(e){return e.join("")}});return p.toTex=void 0,p}function i(e,t,r,n){if(n0)for(;it;)n.push(i),i+=r;return n}function u(e,t,r){var n=[],i=e;if(r>0)for(;i<=t;)n.push(i),i+=r;else if(r<0)for(;i>=t;)n.push(i),i+=r;return n}function c(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lt(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gt(t);)n.push(i),i=i.plus(r);return n}function f(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lte(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gte(t);)n.push(i),i=i.plus(r);return n}function l(e){var t=e.split(":"),r=t.map(function(e){return Number(e)}),n=r.some(function(e){return isNaN(e)});if(n)return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}var p=n(r(2)),h=new e.BigNumber(0),m=new e.BigNumber(1),d=i("range",{string:o,"string, boolean":o,"number, number":function(e,t){return a(s(e,t,1))},"number, number, number":function(e,t,r){return a(s(e,t,r))},"number, number, boolean":function(e,t,r){return a(r?u(e,t,1):s(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return a(n?u(e,t,r):s(e,t,r))},"BigNumber, BigNumber":function(e,t){return a(c(e,t,m))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return a(c(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){return a(r?f(e,t,m):c(e,t,m))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return a(n?f(e,t,r):c(e,t,r))}});return d.toTex=void 0,d}t.name="range",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(2)),u=n(r(16)),c=o("trace",{Array:function(e){return c(s(e))},Matrix:function(e){var t;switch(e.storage()){case"dense":t=f(e);break;case"sparse":t=l(e)}return t},any:i}),f=function(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1==t[0])return i(r[0]);throw new RangeError("Matrix must be square (size: "+a(t)+")");case 2:var n=t[0],o=t[1];if(n===o){for(var s=0,c=0;c0)for(var f=0;ff)break}return c}throw new RangeError("Matrix must be square (size: "+a(i)+")")};return c.toTex={1:"\\mathrm{tr}\\left(${args[0]}\\right)"},c}var i=r(5).clone,a=r(20).format;t.name="trace",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(r){if(r.isZero())return new e.BigNumber(1);for(var n=t.precision+(0|Math.log(r.toNumber())),i=e.BigNumber.clone({precision:n}),a=new i(r),o=r.toNumber()-1;o>1;)a=a.times(o),o--;return new e.BigNumber(a.toPrecision(e.BigNumber.precision))}var f=n(r(11)),l=n(r(36)),p=u("gamma",{number:function(e){var t,r;if(a(e)){if(e<=0)return isFinite(e)?1/0:NaN;if(e>171)return 1/0;for(var n=e-2,i=e-1;n>1;)i*=n,n--;return 0==i&&(i=1),i}if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*p(1-e));if(e>=171.35)return 1/0;if(e>85){var u=e*e,c=u*e,f=c*e,l=f*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*u)-139/(51840*c)-571/(2488320*f)+163879/(209018880*l)+5246819/(75246796800*l*e))}--e,r=s[0];for(var h=1;h=t},"number, number":function(e,r){return e>=r||i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gte(r)||a(e,r,t.epsilon)},"Fraction, Fraction":function(e,t){return e.compare(t)!==-1},"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 m(e.value,t.value)},"string, string":function(e,t){return e>=t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,m);break;default:r=u(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,m,!1);break;default:r=l(e,t,m)}}return r},"Array, Array":function(e,t){return m(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return m(s(e),t)},"Matrix, Array":function(e,t){return m(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=p(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,m,!0);break;default:r=p(t,e,m,!0)}return r},"Array, any":function(e,t){return p(s(e),t,m,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+h.operators.largerEq+"${args[1]}\\right)"},m}var i=r(3).nearlyEqual,a=r(32);t.name="largerEq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t){return f(e,t)?e:t}function c(e){var t=void 0;if(i(e,function(e){(void 0===t||f(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate max of an empty array");return t}var f=n(r(27)),l=s("max",{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(e,t){return a(e,t.valueOf(),u)},"...":function(e){if(o(e))throw new TypeError("Scalar values expected in function max");return c(e)}});return l.toTex="\\max\\left(${args}\\right)",l}var i=r(33),a=r(60),o=r(59);t.name="max",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(e,t){var r=o(e,t,l),n=Array.isArray(e)?i(e):e.size();return p(r,n[t])}function f(e){var t=0,r=0;if(a(e,function(e){t=l(t,e),r++}),0===r)throw new Error("Cannot calculate mean of an empty array");return p(t,r)}var l=n(r(16)),p=n(r(35)),h=u("mean",{"Array | Matrix":f,"Array | Matrix, number | BigNumber":c,"...":function(e){if(s(e))throw new TypeError("Scalar values expected in function mean");return f(e)}});return h.toTex=void 0,h}var i=r(8).size,a=r(33),o=r(60),s=r(59);t.name="mean",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(e){e=i(e.valueOf());var t=e.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=l(e,r+1),a=e[r],o=0;o0&&(a=e[o]);return m(a,n)}var s=l(e,(t-1)/2);return h(s)}var u=n(r(18)),c=n(r(17)),f=n(r(47)),l=n(r(69)),p=o("median",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(a(e))throw new TypeError("Scalar values expected in function median");return s(e)}}),h=o({"number | BigNumber | Unit":function(e){return e}}),m=o({"number | BigNumber | Unit, number | BigNumber | Unit":function(e,t){return c(u(e,t),2)}});return p.toTex=void 0,p}var i=r(8).flatten,a=(r(60),r(59));t.name="median",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t){return f(e,t)?e:t}function c(e){var t=void 0;if(i(e,function(e){(void 0===t||f(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate min of an empty array");return t}var f=n(r(39)),l=s("min",{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(e,t){return a(e,t.valueOf(),u)},"...":function(e){if(o(e))throw new TypeError("Scalar values expected in function min");return c(e)}});return l.toTex="\\min\\left(${args}\\right)",l}var i=r(33),a=r(60),o=r(59);t.name="min",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(r){var n=void 0;if(i(r,function(e){n=void 0===n?e:s(n,e)}),void 0===n)switch(t.number){case"number":return 0;case"BigNumber":return new e.BigNumber(0);case"Fraction":return new e.Fraction(0);default:return 0}return n}var s=n(r(18)),u=a("sum",{"Array | Matrix":function(e){return o(e)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(e){return o(e)}});return u.toTex=void 0,u}var i=r(33);t.name="sum",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=0,i=0;if(0==t.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(a(t,function(e){n=u(n,e),i++}),0===i)throw new Error("Cannot calculate var of an empty array");var o=l(n,i);switch(n=0,a(t,function(e){var t=c(e,o);n=u(n,f(t,t))}),r){case"uncorrected":return l(n,i);case"biased":return l(n,i+1);case"unbiased":var s=n&&n.isBigNumber===!0?new e.BigNumber(0):0;return 1==i?s:l(n,i-1);default:throw new Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}var u=n(r(18)),c=n(r(19)),f=n(r(21)),l=n(r(17)),p=o("variance",{"Array | Matrix":function(e){return s(e,i)},"Array | Matrix, string":s,"...":function(e){return s(e,i)}});return p.toTex="\\mathrm{Var}\\left(${args}\\right)",p}var i="unbiased",a=r(33);t.name="var",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("format",{any:i.format,"any, Object | function | number":i.format});return a.toTex=void 0,a}var i=r(20);t.name="format",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("acosh",{number:function(r){return r>=1||t.predictable?a(r):r<=-1?new e.Complex(Math.log(Math.sqrt(r*r-1)-r),Math.PI):new e.Complex(r,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\cosh^{-1}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)};t.name="acosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isZero",{number:function(e){return 0===e},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 a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isZero",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("_typeof",{any:function(e){var t=i.type(e);if("Object"===t){if(e.isBigNumber===!0)return"BigNumber";if(e.isComplex===!0)return"Complex";if(e.isFraction===!0)return"Fraction";if(e.isMatrix===!0)return"Matrix";if(e.isUnit===!0)return"Unit";if(e.isIndex===!0)return"Index";if(e.isRange===!0)return"Range";if(e.isChain===!0)return"Chain";if(e.isHelp===!0)return"Help"}return t}});return a.toTex=void 0,a}var i=r(61);t.name="typeof",t.factory=n},function(e,t,r){function n(e,t,r,n,s){return i.prototype.type="Complex",i.prototype.isComplex=!0,i.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},i.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},i.prototype.format=function(e){var t="",r=this.im,n=this.re,i=a(this.re,e),s=a(this.im,e),u=o(e)?e:e?e.precision:null;if(null!==u){var c=Math.pow(10,-u);Math.abs(n/r)0?1==r?i+" + i":i+" + "+s+"i":r==-1?i+" - i":i+" - "+s.substring(1)+"i"},i.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"==typeof t)return i(t);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var r=arguments[0],n=arguments[1];if(o(r)){if(n&&n.isUnit&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),o(n))return new i({r:r,phi:n});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")}},i.prototype.valueOf=i.prototype.toString,i.fromJSON=function(e){return new i(e)},i.EPSILON=t.epsilon,s.on("config",function(e,t){e.epsilon!==t.epsilon&&(i.EPSILON=e.epsilon)}),i}var i=r(139),a=r(3).format,o=r(3).isNumber;t.name="Complex",t.path="type",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("fraction",{number:function(t){if(!isFinite(t)||isNaN(t))throw new Error(t+" cannot be represented as a fraction");return new e.Fraction(t)},string:function(t){return new e.Fraction(t)},"number, number":function(t,r){return new e.Fraction(t,r)},BigNumber:function(t){return new e.Fraction(t.toString())},Fraction:function(e){return e},Object:function(t){return new e.Fraction(t)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);t.name="fraction",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,c){function d(e,t){if(!(this instanceof d))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!h(t))throw new Error("Invalid datatype: "+t);if(e&&e.isMatrix===!0)"DenseMatrix"===e.type?(this._data=u.clone(e._data),this._size=u.clone(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&f(e.data)&&f(e.size))this._data=e.data,this._size=e.size,this._datatype=t||e.datatype;else if(f(e))this._data=b(e),this._size=s.size(this._data),s.validate(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._data=[],this._size=[0],this._datatype=t}}function g(e,t){if(!t||t.isIndex!==!0)throw new TypeError("Invalid index");var r=t.isScalar();if(r)return e.get(t.min());var n=t.size();if(n.length!=e._size.length)throw new a(n.length,e._size.length);for(var i=t.min(),o=t.max(),s=0,u=e._size.length;s");var p=t.max().map(function(e){return e+1});w(e,p,n);var h=o.length,m=0;x(e._data,t,r,h,m)}return e}function x(e,t,r,n,i){var a=i==n-1,o=t.dimension(i);a?o.forEach(function(t,n){m(t),e[t]=r[n[0]]}):o.forEach(function(a,o){m(a),x(e[a],t,r[o[0]],n,i+1)})}function w(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&E(e,n,r)}function b(e){for(var t=0,r=e.length;t0?e:0,r=e<0?-e:0,n=this._size[0],i=this._size[1],a=Math.min(n-r,i-t),o=[],s=0;s0?n:0,m=n<0?-n:0,g=t[0],v=t[1],y=Math.min(g-m,v-u);if(f(r)){if(r.length!==y)throw new Error("Invalid value array length");o=function(e){return r[e]}}else if(r&&r.isMatrix===!0){var x=r.size();if(1!==x.length||x[0]!==y)throw new Error("Invalid matrix length");o=function(e){return r.get([e])}}else o=function(){return r};i||(i=o(0)&&o(0).isBigNumber===!0?new e.BigNumber(0):0);var w=[];if(t.length>0){w=s.resize(w,t,i);for(var b=0;b0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},a.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},a.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++},a.prototype.map=function(e){var t=[];return this.forEach(function(r,n,i){t[n[0]]=e(r,n,i)}),t},a.prototype.toArray=function(){var e=[];return this.forEach(function(t,r){e[r[0]]=t}),e},a.prototype.valueOf=function(){return this.toArray()},a.prototype.format=function(e){var t=i.format(this.start,e);return 1!=this.step&&(t+=":"+i.format(this.step,e)),t+=":"+i.format(this.end,e)},a.prototype.toString=function(){return this.format()},a.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(e){return new a(e.start,e.end,e.step)},a}var i=r(3);t.name="Range",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_,T=n&&p?[]:void 0,C=[],S=[],z=new s({values:T,index:C,ptr:S,size:[y,x],datatype:v}),k=T?[]:void 0,B=[];for(M=0;M="0"&&e<="9"||"."==e}function p(e){return e>="0"&&e<="9"}function h(){P++,R=I.charAt(P)}function m(e){P=e,R=I.charAt(P)}function d(){var e,t="";if(e=P,"+"==R?h():"-"==R&&(t+=R,h()),!l(R))return m(e),null;if("."==R){if(t+=R,h(),!p(R))return m(e),null}else{for(;p(R);)t+=R,h();"."==R&&(t+=R,h())}for(;p(R);)t+=R,h();if("E"==R||"e"==R){var r="",n=P;if(r+=R,h(),"+"!=R&&"-"!=R||(r+=R,h()),!p(R))return m(n),t;for(t+=r;p(R);)t+=R,h()}return t}function g(){for(var e="",t=I.charCodeAt(P);t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122;)e+=R,h(),t=I.charCodeAt(P);return t=e.charCodeAt(0),t>=65&&t<=90||t>=97&&t<=122?e||null:null}function v(e){return R===e?(h(),e):null}function y(e){if(G.hasOwnProperty(e)){var t=G[e],r=t.prefixes[""];return{unit:t,prefix:r}}for(var n in G)if(G.hasOwnProperty(n)&&i(e,n)){var t=G[n],a=e.length-n.length,o=e.substring(0,a),r=t.prefixes[o];if(void 0!==r)return{unit:t,prefix:r}}return null}function x(t){if("BigNumber"===t.number){var r=o.pi(e.BigNumber);G.rad.value=new e.BigNumber(1),G.deg.value=r.div(180),G.grad.value=r.div(200),G.cycle.value=r.times(2),G.arcsec.value=r.div(648e3),G.arcmin.value=r.div(10800)}else G.rad.value=1,G.deg.value=Math.PI/180,G.grad.value=Math.PI/200,G.cycle.value=2*Math.PI,G.arcsec.value=Math.PI/648e3,G.arcmin.value=Math.PI/10800}function w(e){for(var t=0;t="0"&&e<="9"};if(0===t&&!n(r))throw new Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(t>0&&!n(r)&&!i(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}var b=n(r(18)),N=n(r(19)),E=n(r(21)),M=n(r(17)),A=n(r(36)),O=n(r(26)),_=n(r(104)),T=n(r(71)),C=n(r(72)),S=n(r(123)),z=n(r(126)),k=n(r(76)),B=n(r(127));c.prototype.type="Unit",c.prototype.isUnit=!0;var I,P,R;c.parse=function(r,n){if(n=n||{},I=r,P=-1,R="","string"!=typeof I)throw new TypeError("Invalid argument in Unit.parse, string expected");var i=new c;i.units=[],h(),f();var a=d(),o=null;a&&(o="BigNumber"===t.number?new e.BigNumber(a):"Fraction"===t.number?new e.Fraction(a):parseFloat(a)),f();for(var s=1,u=!1,l=[],p=1;;){for(f();"("===R;)l.push(s),p*=s,s=1,h(),f();if(!R)break;var m=R,x=g();if(null==x)throw new SyntaxError('Unexpected "'+m+'" in "'+I+'" at index '+P.toString());var w=y(x);if(null==w)throw new SyntaxError('Unit "'+x+'" not found.');var b=s*p;if(f(),v("^")){f();var N=d();if(null==N)throw new SyntaxError('In "'+r+'", "^" must be followed by a floating-point number');b*=N}i.units.push({unit:w.unit,prefix:w.prefix,power:b});for(var E=0;E1||Math.abs(this.units[0].power-1)>1e-15)},c.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=c._getNumberConverter(z(e));for(var s=0;s1e-12)return!1;return!0},c.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},c.prototype.equals=function(e){return this.equalBase(e)&&T(this.value,e.value)},c.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(V.hasOwnProperty(s)?t.push({unit:V[s].unit,prefix:V[s].prefix,power:this.dimensions[o]||0}):a=!0)}r(519);t.length0?(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 i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var a=e;return r>0&&n>0&&(a+=" / "),a+=t},c.prototype.format=function(e){this.simplifyUnitListLazy();var t=!1,r=!0;"undefined"!=typeof this.value&&null!==this.value&&this.value.isComplex&&(t=Math.abs(this.value.re)<1e-14,r=Math.abs(this.value.im)<1e-14);for(var n in this.units)this.units[n].unit&&("VA"===this.units[n].unit.name&&t?this.units[n].unit=G.VAR:"VAR"!==this.units[n].unit.name||t||(this.units[n].unit=G.VA));1!==this.units.length||this.fixPrefix||Math.abs(this.units[0].power-Math.round(this.units[0].power))<1e-14&&(this.units[0].prefix=this._bestPrefix());var i=this._denormalize(this.value),a=null!==this.value?S(i,e||{}):"",o=this.formatUnits();return this.value&&this.value.isComplex&&(a="("+a+")"),o.length>0&&a.length>0&&(a+=" "),a+=o},c.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=O(this.value),t=O(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(a.hasOwnProperty(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);(u1e-12){p=!1;break}if(p){l=!0;break}}if(!l){var m=e+"_STUFF",d={dimensions:a.dimensions.slice(0)};d.key=m,F[m]=d,V[m]={unit:f,prefix:q.NONE[""]},f.base=m}}else{var m=e+"_STUFF";if(L.indexOf(m)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');L.push(m);for(var g in F)F.hasOwnProperty(g)&&(F[g].dimensions[L.length-1]=0);for(var d={dimensions:[]},u=0;u2&&void 0!==arguments[2]?arguments[2]:-1;if(this.measured)throw new Error("Cannot Apply Gate to a Measured Quantum Register");var n=s.generateGate(e,this.numQubits,t,r);this.amplitudes=a.multiply(this.amplitudes,n)}},{key:"measure",value:function(){if(this.measured)return this.value;var e=[];a.forEach(this.amplitudes,function(t){var r=a.pow(a.abs(t),2);e.push(r)});var t=a.zeros(e.length).toArray().map(function(e,t){return t});return this.value=Number(o.select(t,e)).toString(2),this.value.length0?1:e<0?-1:0},t.format=function(e,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-(1/0))return"-Infinity";if(isNaN(e))return"NaN";var n="auto",i=void 0;switch(r&&(r.notation&&(n=r.notation),t.isNumber(r)?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"engineering":return t.toEngineering(e,i);case"auto":return t.toPrecision(e,i,r&&r.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return new n(e).toExponential(t)},t.toEngineering=function(e,t){return new n(e).toEngineering(t)},t.toFixed=function(e,t){return new n(e).toFixed(t)},t.toPrecision=function(e,t,r){return new n(e).toPrecision(t,r)},t.digits=function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},t.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,t.nearlyEqual=function(e,r,n){if(null==n)return e==r;if(e==r)return!0;if(isNaN(e)||isNaN(r))return!1;if(isFinite(e)&&isFinite(r)){var i=Math.abs(e-r);return i>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},t.defaultTemplate="\\mathrm{${name}}\\left(${args}\\right)";var r={deg:"^\\circ"};t.toSymbol=function(e,n){if(n="undefined"!=typeof n&&n)return r.hasOwnProperty(e)?r[e]:"\\mathrm{"+e+"}";if(t.symbols.hasOwnProperty(e))return t.symbols[e];if(e.indexOf("_")!==-1){var i=e.indexOf("_");return t.toSymbol(e.substring(0,i))+"_{"+t.toSymbol(e.substring(i+1))+"}"}return e}},function(e,t){"use strict";t.clone=function e(t){var r=typeof t;if("number"===r||"string"===r||"boolean"===r||null===t||void 0===t)return t;if("function"==typeof t.clone)return t.clone();if(Array.isArray(t))return t.map(function(t){return e(t)});if(t instanceof Number)return new Number(t.valueOf());if(t instanceof String)return new String(t.valueOf());if(t instanceof Boolean)return new Boolean(t.valueOf());if(t instanceof Date)return new Date(t.valueOf());if(t&&t.isBigNumber===!0)return t;if(t instanceof RegExp)throw new TypeError("Cannot clone "+t);var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=e(t[i]));return n},t.extend=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},t.deepExtend=function e(t,r){if(Array.isArray(r))throw new TypeError("Arrays are not supported by deepExtend");for(var n in r)if(r.hasOwnProperty(n))if(r[n]&&r[n].constructor===Object)void 0===t[n]&&(t[n]={}),t[n].constructor===Object?e(t[n],r[n]):t[n]=r[n];else{if(Array.isArray(r[n]))throw new TypeError("Arrays are not supported by deepExtend");t[n]=r[n]}return t},t.deepEqual=function(e,r){var n,i,a;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!=r.length)return!1;for(i=0,a=e.length;i0?s(p,0,f,f[0],c,t,o):[];return new a({data:h,size:i(f),datatype:u})},s=function(e,t,r,n,i,a,o){var u=[];if(t===r.length-1)for(var c=0;c0?s(g,0,h,h[0],o,f):[];return new i({data:v,size:h,datatype:d})},s=function(e,t,r,n,i,a){var o=[];if(t===r.length-1)for(var u=0;u")}function i(e,r,n,a){var o,s,u=e.length,c=r[n],f=Math.min(u,c);if(e.length=c,n=t)throw new f(e,t)},t.UNINITIALIZED={},t.resize=function(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");t.forEach(function(e){if(!s.isNumber(e)||!s.isInteger(e)||e<0)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(t)+")")});var n=void 0!==r?r:0;return i(e,t,0,n),e},t.squeeze=function(e,r){for(var n=r||t.size(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var i=n.length;1===n[i-1];)i--;return i_)for(var C=0,S=0;S0)throw new Error("Calling compile(math) is deprecated. Call the function as compile() instead.");var e={math:o.expression.transform,args:{},_validateScope:u},t={},r=this._compile(e,t),n=Object.keys(e).map(function(e){return" var "+e+' = defs["'+e+'"];'}),i=n.join(" ")+'return { "eval": function (scope) { if (scope) _validateScope(scope); scope = scope || {}; return '+r+"; }};",a=new Function("defs",i);return a(e)},s.prototype._compile=function(e,t){throw new Error("Cannot compile a Node interface")},s.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},s.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},s.prototype._ifNode=function(e){if(!e||!e.isNode)throw new TypeError("Callback function must return a Node");return e},s.prototype.traverse=function(e){function t(e,r){e.forEach(function(e,n,i){r(e,n,i),t(e,r)})}e(this,null,null),t(this,e)},s.prototype.transform=function(e){function t(e,r){return e.map(function(e,n,i){var a=r(e,n,i);return t(a,r)})}var r=e(this,null,null);return t(r,e)},s.prototype.filter=function(e){var t=[];return this.traverse(function(r,n,i){e(r,n,i)&&t.push(r)}),t},s.prototype.find=function(){throw new Error("Function Node.find is deprecated. Use Node.filter instead.")},s.prototype.match=function(){throw new Error("Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.")},s.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},s.prototype.cloneDeep=function(){return this.map(function(e){return e.cloneDeep()})},s.prototype.equals=function(e){return!!e&&a(this,e)},s.prototype.toString=function(e){var t;if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":break;case"function":t=e.handler(this,e);break;default:throw new TypeError("Object or function expected as callback")}return"undefined"!=typeof t?t:this._toString(e)},s.prototype._toString=function(){throw new Error("_toString not implemented for "+this.type)},s.prototype.toTex=function(e){var t;if(e&&"object"==typeof e)switch(typeof e.handler){case"object":case"undefined":break;case"function":t=e.handler(this,e);break;default:throw new TypeError("Object or function expected as callback")}return"undefined"!=typeof t?t:this._toTex(e)},s.prototype._toTex=function(e){throw new Error("_toTex not implemented for "+this.type)},s.prototype.getIdentifier=function(){return this.type},s.prototype.getContent=function(){return this},s}var i=r(63),a=(r(5).extend,r(5).deepEqual);t.name="Node",t.path="expression.node",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=e.DenseMatrix,o=function(e,t,r,o){var s=e._data,u=e._size,c=e._datatype,f=t._values,l=t._index,p=t._ptr,h=t._size,m=t._datatype;if(u.length!==h.length)throw new i(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,g=u[0],v=u[1],y=0,x=r;"string"==typeof c&&c===m&&(d=c,y=n.convert(0,d),x=n.find(r,[d,d]));for(var w=[],b=0;bt},"number, number":function(e,r){return e>r&&!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gt(r)&&!a(e,r,t.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 m(e.value,t.value)},"string, string":function(e,t){return e>t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,m);break;default:r=u(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,m,!1);break;default:r=l(e,t,m)}}return r},"Array, Array":function(e,t){return m(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return m(s(e),t)},"Matrix, Array":function(e,t){return m(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=p(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,m,!0);break;default:r=p(t,e,m,!0)}return r},"Array, any":function(e,t){return p(s(e),t,m,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+h.operators.larger+"${args[1]}\\right)"},m}var i=r(3).nearlyEqual,a=r(32);t.name="larger",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=e.DenseMatrix,o=function(e,t,r,o){var s=e._data,u=e._size,c=e._datatype,f=t._values,l=t._index,p=t._ptr,h=t._size,m=t._datatype;if(u.length!==h.length)throw new i(u.length,h.length);if(u[0]!==h[0]||u[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+h+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var d,g,v=u[0],y=u[1],x="string"==typeof c&&c===m?c:void 0,w=x?n.find(r,[x,x]):r,b=[];for(d=0;d0?new K(r):e}function x(){var e,t,r,n,i=w();if("="==ye){if(i&&i.isSymbolNode)return e=i.name,m(),r=x(),new Q(new ce(e),r);if(i&&i.isAccessorNode)return m(),r=x(),new Q(i.object,i.index,r);if(i&&i.isFunctionNode&&(n=!0,t=[],e=i.name,i.args.forEach(function(e,r){e&&e.isSymbolNode?t[r]=e.name:n=!1}),n))return m(),r=x(),new re(e,t,r);throw W("Invalid left hand side of assignment operator =")}return i}function w(){for(var e=b();"?"==ye;){var t=be;be=we,m();var r=e,n=x();if(":"!=ye)throw W("False part of conditional expression expected");be=null,m();var i=x();e=new ee(r,n,i),be=t}return e}function b(){for(var e=N();"or"==ye;)m(),e=new ae("or","or",[e,N()]);return e}function N(){for(var e=E();"xor"==ye;)m(),e=new ae("xor","xor",[e,E()]);return e}function E(){for(var e=M();"and"==ye;)m(),e=new ae("and","and",[e,M()]);return e}function M(){for(var e=A();"|"==ye;)m(),e=new ae("|","bitOr",[e,A()]);return e}function A(){for(var e=O();"^|"==ye;)m(),e=new ae("^|","bitXor",[e,O()]);return e}function O(){for(var e=_();"&"==ye;)m(),e=new ae("&","bitAnd",[e,_()]);return e}function _(){var e,t,r,n,i;for(e=T(),t={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};ye in t;)r=ye,n=t[r],m(),i=[e,T()],e=new ae(r,n,i);return e}function T(){var e,t,r,n,i;for(e=C(),t={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};ye in t;)r=ye,n=t[r],m(),i=[e,C()],e=new ae(r,n,i);return e}function C(){var e,t,r,n,i;for(e=S(),t={to:"to",in:"to"};ye in t;)r=ye,n=t[r],m(),"in"===r&&""===ye?e=new ae("*","multiply",[e,new ce("in")],!0):(i=[e,S()],e=new ae(r,n,i));return e}function S(){var e,t=[];if(e=":"==ye?new te("1","number"):z(),":"==ye&&be!==we){for(t.push(e);":"==ye&&t.length<3;)m(),")"==ye||"]"==ye||","==ye||""==ye?t.push(new ce("end")):t.push(z());e=3==t.length?new ue(t[0],t[2],t[1]):new ue(t[0],t[1])}return e}function z(){var e,t,r,n,i;for(e=k(),t={"+":"add","-":"subtract"};ye in t;)r=ye,n=t[r],m(),i=[e,k()],e=new ae(r,n,i);return e}function k(){var e,t,r,n,i;for(e=B(),t=e,r={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"};;)if(ye in r)n=ye,i=r[n],m(),t=B(),e=new ae(n,i,[e,t]);else{if(!(xe==fe.SYMBOL||"in"==ye&&e&&e.isConstantNode)&&(xe!=fe.NUMBER||t.isConstantNode||t.isOperatorNode&&"!"!==t.op)&&"("!=ye)break;t=B(),e=new ae("*","multiply",[e,t],!0)}return e}function B(){var e,t,r={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"}[ye];return r?(e=ye,m(),t=[B()],new ae(e,r,t)):I()}function I(){var e,t,r,n;return e=P(),"^"!=ye&&".^"!=ye||(t=ye,r="^"==t?"pow":"dotPow",m(),n=[e,B()],e=new ae(t,r,n)),e}function P(){var e,t,r,n,i;for(e=R(),t={"!":"factorial","'":"transpose"};ye in t;)r=ye,n=t[r],h(),i=[e],e=new ae(r,n,i),e=q(e);return e}function R(){var e,t=[];if(xe==fe.SYMBOL&&he[ye]){if(e=he[ye],h(),"("==ye){if(t=[],d(),h(),")"!=ye)for(t.push(x());","==ye;)h(),t.push(x());if(")"!=ye)throw W("Parenthesis ) expected");g(),h()}return new e(t)}return U()}function U(){var e,t;return xe==fe.SYMBOL||xe==fe.DELIMITER&&ye in pe?(t=ye,h(),e=new ce(t),e=q(e)):j()}function q(e,t){for(var r;!("("!=ye&&"["!=ye&&"."!=ye||t&&t.indexOf(ye)===-1);)if(r=[],"("==ye){if(!(e.isSymbolNode||e.isAccessorNode||e.isFunctionNode))return e;if(d(),h(),")"!=ye)for(r.push(x());","==ye;)h(),r.push(x());if(")"!=ye)throw W("Parenthesis ) expected");g(),h(),e=new se(e,r)}else if("["==ye){if(d(),h(),"]"!=ye)for(r.push(x());","==ye;)h(),r.push(x());if("]"!=ye)throw W("Parenthesis ] expected");g(),h(),e=new X(e,new ne(r))}else{if(h(),xe!=fe.SYMBOL)throw W("Property name expected after dot");r.push(new te(ye)),h();var n=!0;e=new X(e,new ne(r,n))}return e}function j(){var e,t;return'"'==ye?(t=L(),e=new te(t,"string"),e=q(e)):F()}function L(){for(var e="";""!=ve&&'"'!=ve;)"\\"==ve&&(e+=ve,c()),e+=ve,c();if(h(),'"'!=ye)throw W('End of string " expected');return h(),e}function F(){var e,t,r,n;if("["==ye){if(d(),h(),"]"!=ye){var i=D();if(";"==ye){for(r=1,t=[i];";"==ye;)h(),t[r]=D(),r++;if("]"!=ye)throw W("End of matrix ] expected");g(),h(),n=t[0].items.length;for(var a=1;a":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},pe={mod:!0,to:!0,in:!0,and:!0,xor:!0,or:!0,not:!0},he={},me="",de="",ge=0,ve="",ye="",xe=fe.NULL,we=0,be=null;return s.isAlpha=function(e,t,r){return s.isValidLatinOrGreek(e)||s.isValidMathSymbol(e,r)||s.isValidMathSymbol(t,e)},s.isValidLatinOrGreek=function(e){return/^[a-zA-Z_\u00C0-\u02AF\u0370-\u03FF\u2100-\u214F]$/.test(e)},s.isValidMathSymbol=function(e,t){return/^[\uD835]$/.test(e)&&/^[\uDC00-\uDFFF]$/.test(t)&&/^[^\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(t)},s.isWhitespace=function(e,t){return" "==e||"\t"==e||"\n"==e&&t>0},s.isDecimalMark=function(e,t){return"."==e&&"/"!==t&&"*"!==t&&"^"!==t},s.isDigitDot=function(e){return e>="0"&&e<="9"||"."==e},s.isDigit=function(e){return e>="0"&&e<="9"},s}var i=r(42),a=r(1);t.name="parse",t.path="expression",t.factory=n},function(e,t,r){var n=r(43);t.transform=function(e){return e&&e.isIndexError?new n(e.index+1,e.min+1,void 0!==e.max?e.max+1:void 0):e}},function(e,t){"use strict";function r(e,t,r,n){var i=e.DenseMatrix,a=function(e,t,r,a){var o=e._values,s=e._index,u=e._ptr,c=e._size,f=e._datatype;if(!o)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var l,p=c[0],h=c[1],m=r;"string"==typeof f&&(l=f,t=n.convert(t,l),m=n.find(r,[l,l]));for(var d=[],g=new i({data:d,size:[p,h],datatype:l}),v=[],y=[],x=0;x=0||t.predictable?Math.pow(r,n):new e.Complex(r,0).pow(n,0)}function u(e,t){if(!i(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=a(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 n=l(r[0]).valueOf(),o=e;t>=1;)1==(1&t)&&(n=p(o,n)),t>>=1,o=p(o,o);return n}function c(e,t){return h(u(e.valueOf(),t))}var f=r(4),l=n(r(68)),p=n(r(11)),h=n(r(2)),m=n(r(128)),d=n(r(77)),g=o("pow",{"number, number":s,"Complex, Complex":function(e,t){return e.pow(t)},"BigNumber, BigNumber":function(r,n){return n.isInteger()||r>=0||t.predictable?r.pow(n):new e.Complex(r.toNumber(),0).pow(n.toNumber(),0)},"Fraction, Fraction":function(e,r){if(1!==r.d){if(t.predictable)throw new Error("Function pow does not support non-integer exponents for fractions.");return s(e.valueOf(),r.valueOf())}return e.pow(r)},"Array, number":u,"Array, BigNumber":function(e,t){return u(e,t.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(e,t){return c(e,t.toNumber())},"Unit, number":function(e,t){return e.pow(t)}});return g.toTex={2:"\\left(${args[0]}\\right)"+f.operators.pow+"{${args[1]}}"},g}var i=r(3).isInteger,a=r(8).size;t.name="pow",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("unaryMinus",{number:function(e){return-e},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=s(e.value),t},"Array | Matrix":function(e){return i(e,s,!0)}});return s.toTex={1:o.operators.unaryMinus+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="unaryMinus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=u(t),i=n?new e.BigNumber(0):0;if(c(t),r){var o=f(r);return t.length>0?o.resize(t,i):o}var s=[];return t.length>0?a(s,t,i):s}function u(e){var t=!1;return e.forEach(function(e,r,n){e&&e.isBigNumber===!0&&(t=!0,n[r]=e.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||e<0)throw new Error("Parameters in function zeros must be positive integers")})}var f=n(r(2)),l=o("zeros",{"":function(){return"Array"===t.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var r=e[e.length-1];if("string"==typeof r){var n=e.pop();return s(e,n)}return"Array"===t.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var t=e.storage();return s(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return s(e.valueOf(),t)}});return l.toTex=void 0,l}var i=r(3).isInteger,a=r(8).resize;t.name="zeros",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(2)),u=n(r(13)),c=n(r(23)),f=n(r(15)),l=n(r(7)),p=n(r(6)),h=r(4),m=o("smaller",{"boolean, boolean":function(e,t){return e=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}r.prototype=new RangeError,r.prototype.constructor=RangeError,r.prototype.name="IndexError",r.prototype.isIndexError=!0,e.exports=r},function(e,t,r){"use strict";function n(e,t,n,a){function o(e,t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(t){if("string"!=typeof t)throw new TypeError('String expected for parameter "valueType"');if("string"!=typeof e)throw new TypeError('String expected for parameter "value"');this.value=e,this.valueType=t}else this.value=e+"",this.valueType=i(e);if(!u[this.valueType])throw new TypeError('Unsupported type of value "'+this.valueType+'"')}var s=n(r(12)),u={number:!0,string:!0,boolean:!0,undefined:!0,null:!0};return o.prototype=new s,o.prototype.type="ConstantNode",o.prototype.isConstantNode=!0,o.prototype._compile=function(e,t){switch(this.valueType){case"number":var r=e.math.config().number;return"BigNumber"===r?'math.bignumber("'+this.value+'")':"Fraction"===r?'math.fraction("'+this.value+'")':this.value.replace(/^(0*)[0-9]/,function(e,t){return e.substring(t.length)});case"string":return'"'+this.value+'"';case"boolean":return this.value;case"undefined":return this.value;case"null":return this.value;default:throw new TypeError('Unsupported type of constant "'+this.valueType+'"')}},o.prototype.forEach=function(e){},o.prototype.map=function(e){return this.clone()},o.prototype.clone=function(){return new o(this.value,this.valueType)},o.prototype._toString=function(e){switch(this.valueType){case"string":return'"'+this.value+'"';default:return this.value}},o.prototype._toTex=function(e){var t,r=this.value;switch(this.valueType){case"string":return'\\mathtt{"'+r+'"}';case"number":return t=r.toLowerCase().indexOf("e"),t!==-1?r.substring(0,t)+"\\cdot10^{"+r.substring(t+1)+"}":r;default:return r}},o}var i=r(61).type;t.name="ConstantNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a,o){function s(e,t){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if("string"==typeof e&&(e=new f(e)),!e||!e.isNode)throw new TypeError('Node expected as parameter "fn"');if(!Array.isArray(t)||!t.every(function(e){return e&&e.isNode}))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")}});var r=function(){throw new Error("Property `FunctionNode.object` is deprecated, use `FunctionNode.fn` instead")};Object.defineProperty(this,"object",{get:r,set:r})}function u(e,t,r){for(var n,i="",a=new RegExp("\\$(?:\\{([a-z_][a-z_0-9]*)(?:\\[([0-9]+)\\])?\\}|\\$)","ig"),o=0;null!==(n=a.exec(e));)if(i+=e.substring(o,n.index),o=n.index,"$$"===n[0])i+="$",o++;else{o+=n[0].length;var s=t[n[1]];if(!s)throw new ReferenceError("Template: Property "+n[1]+" does not exist.");if(void 0===n[2])switch(typeof s){case"string":i+=s;break;case"object":if(s.isNode)i+=s.toTex(r);else{if(!Array.isArray(s))throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes");i+=s.map(function(e,t){if(e&&e.isNode)return e.toTex(r);throw new TypeError("Template: "+n[1]+"["+t+"] is not a Node.")}).join(",")}break;default:throw new TypeError("Template: "+n[1]+" has to be a Node, String or array of Nodes")}else{if(!s[n[2]]||!s[n[2]].isNode)throw new TypeError("Template: "+n[1]+"["+n[2]+"] is not a Node.");i+=s[n[2]].toTex(r)}}return i+=e.slice(o)}var c=n(r(12)),f=n(r(25));s.prototype=new c,s.prototype.type="FunctionNode",s.prototype.isFunctionNode=!0,s.prototype._compile=function(e,t){var r,n=this.fn._compile(e,t),i=this.args.map(function(r){return r._compile(e,t)});if(this.fn.isSymbolNode){var a=this.fn.name,o=e.math[a],s="function"==typeof o&&1==o.rawArgs;return s?(r=this._getUniqueArgumentsName(e),e[r]=this.args,n+"("+r+", math, scope)"):n+"("+i.join(", ")+")"}if(this.fn.isAccessorNode&&this.fn.index.isObjectProperty()){r=this._getUniqueArgumentsName(e),e[r]=this.args;var u=this.fn.object._compile(e,t),c=this.fn.index.getObjectProperty();return"(function () {var object = "+u+';return (object["'+c+'"] && object["'+c+'"].rawArgs) ? object["'+c+'"]('+r+', math, scope) : object["'+c+'"]('+i.join(", ")+")})()"}return r=this._getUniqueArgumentsName(e),e[r]=this.args,"(function () {var fn = "+n+";return (fn && fn.rawArgs) ? fn("+r+", math, scope) : fn("+i.join(", ")+")})()"},s.prototype._getUniqueArgumentsName=function(e){var t,r=0;do t="args"+r,r++;while(t in e);return t},s.prototype.forEach=function(e){for(var t=0;tt?1:-1},"number, number":function(e,r){return e===r||i(e,r,t.epsilon)?0:e>r?1:-1},"BigNumber, BigNumber":function(r,n){return r.eq(n)||a(r,n,t.epsilon)?new e.BigNumber(0):new e.BigNumber(r.cmp(n))},"Fraction, Fraction":function(t,r){return new e.Fraction(t.compare(r))},"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 h(e.value,t.value)},"string, string":function(e,t){return e===t?0:e>t?1:-1},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,h);break;default:r=u(t,e,h,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,h,!1);break;default:r=l(e,t,h)}}return r},"Array, Array":function(e,t){return h(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return h(s(e),t)},"Matrix, Array":function(e,t){return h(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,h,!1);break;default:r=p(e,t,h,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,h,!0);break;default:r=p(t,e,h,!0)}return r},"Array, any":function(e,t){return p(s(e),t,h,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,h,!0).valueOf()}});return h.toTex=void 0,h}var i=r(3).nearlyEqual,a=r(32);t.name="compare",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNegative",{number:function(e){return e<0},BigNumber:function(e){return e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s<0},Unit:function(e){return a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isNegative",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o,s){function u(e,t,r,n){if(!(this instanceof u))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(r)||!r.every(function(e){return e&&e.isNode}))throw new TypeError('Array containing Nodes expected for parameter "args"');this.implicit=n===!0,this.op=e,this.fn=t,this.args=r||[]}function c(e,t,r,n){var i=a.getPrecedence(e,t),o=a.getAssociativity(e,t);if("all"===t||r.length>2&&"OperatorNode:add"!==e.getIdentifier()&&"OperatorNode:multiply"!==e.getIdentifier()){var s=r.map(function(e){switch(e.getContent().type){case"ArrayNode":case"ConstantNode":case"SymbolNode":case"ParenthesisNode":return!1;default:return!0}});return s}if(0===r.length)return[];if(1===r.length){var u=a.getPrecedence(r[0],t);if(n&&null!==u){var c,f;if("keep"===t?(c=r[0].getIdentifier(),f=e.getIdentifier()):(c=r[0].getContent().getIdentifier(),f=e.getContent().getIdentifier()),a.properties[i][f].latexLeftParens===!1)return[!1];if(a.properties[u][c].latexParens===!1)return[!1]}return null===u?[!1]:u<=i?[!0]:[!1]}if(2===r.length){var l,p=a.getPrecedence(r[0],t),h=a.isAssociativeWith(e,r[0],t);l=null!==p&&(p===i&&"right"===o&&!h||p2&&("OperatorNode:add"===e.getIdentifier()||"OperatorNode:multiply"===e.getIdentifier())){var x=r.map(function(r){var n=a.getPrecedence(r,t),s=a.isAssociativeWith(e,r,t),u=a.getAssociativity(r,t);return null!==n&&(i===n&&o===u&&!s||n2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var l=n.map(function(t,r){return t=t.toString(e),i[r]&&(t="("+t+")"),t});return this.implicit&&"OperatorNode:multiply"===this.getIdentifier()&&"hide"===r?l.join(" "):l.join(" "+this.op+" ")}return this.fn+"("+this.args.join(", ")+")"},u.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=e&&e.implicit?e.implicit:"hide",n=this.args,o=c(this,t,n,!0),s=i.operators[this.fn];if(s="undefined"==typeof s?this.op:s,1===n.length){var u=a.getAssociativity(this,t),f=n[0].toTex(e);return o[0]&&(f="\\left("+f+"\\right)"),"right"===u?s+f:"left"===u?f+s:f+s}if(2===n.length){var l=n[0],p=l.toTex(e);o[0]&&(p="\\left("+p+"\\right)");var h=n[1],m=h.toTex(e);o[1]&&(m="\\left("+m+"\\right)");var d;switch(d="keep"===t?l.getIdentifier():l.getContent().getIdentifier(),this.getIdentifier()){case"OperatorNode:divide":return s+"{"+p+"}{"+m+"}";case"OperatorNode:pow":switch(p="{"+p+"}",m="{"+m+"}",d){case"ConditionalNode":case"OperatorNode:divide":p="\\left("+p+"\\right)"}case"OperatorNode:multiply":if(this.implicit&&"hide"===r)return p+"~"+m}return p+s+m}if(n.length>2&&("OperatorNode:add"===this.getIdentifier()||"OperatorNode:multiply"===this.getIdentifier())){var g=n.map(function(t,r){return t=t.toTex(e),o[r]&&(t="\\left("+t+"\\right)"),t});return"OperatorNode:multiply"===this.getIdentifier()&&this.implicit?g.join("~"):g.join(s)}return"\\mathrm{"+this.fn+"}\\left("+n.map(function(t){return t.toTex(e)}).join(",")+"\\right)"},u.prototype.getIdentifier=function(){return this.type+":"+this.fn},u}var i=r(4),a=r(46);t.name="OperatorNode",t.path="expression.node",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e||!e.isNode)throw new TypeError('Node expected for parameter "content"');this.content=e}var o=n(r(12));return a.prototype=new o,a.prototype.type="ParenthesisNode",a.prototype.isParenthesisNode=!0,a.prototype._compile=function(e,t){return this.content._compile(e,t)},a.prototype.getContent=function(){return this.content.getContent()},a.prototype.forEach=function(e){e(this.content,"content",this)},a.prototype.map=function(e){var t=e(this.content,"content",this);return new a(t)},a.prototype.clone=function(){return new a(this.content)},a.prototype._toString=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"("+this.content.toString(e)+")":this.content.toString(e)},a.prototype._toTex=function(e){return!e||e&&!e.parenthesis||e&&"keep"===e.parenthesis?"\\left("+this.content.toTex(e)+"\\right)":this.content.toTex(e)},a}t.name="ParenthesisNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function a(r){return r>=0||t.predictable?Math.sqrt(r):new e.Complex(r,0).sqrt()}var o=n("sqrt",{number:a,Complex:function(e){return e.sqrt()},BigNumber:function(e){return!e.isNegative()||t.predictable?e.sqrt():a(e.toNumber())},"Array | Matrix":function(e){return i(e,o,!0)},Unit:function(e){return e.pow(.5)}});return o.toTex={1:"\\sqrt{${args[0]}}"},o}var i=r(1);t.name="sqrt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,c){function f(e,t){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(1!=t.size().length)throw new u(t.size().length,1);var r=e.length;s(t.min()[0],r),s(t.max()[0],r);var n=t.dimension(0),i="";return n.forEach(function(t){i+=e.charAt(t)}),i}function l(e,t,r,n){if(!t||t.isIndex!==!0)throw new TypeError("Index expected");if(1!=t.size().length)throw new u(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),a=i.size()[0];if(a!=r.length)throw new u(i.size()[0],r.length);var o=e.length;s(t.min()[0]),s(t.max()[0]);for(var c=[],f=0;fo)for(f=o-1,a=c.length;fe)throw new TypeError("k must be less than or equal to n");for(r=Math.max(t,e-t),n=1,i=1;i<=e-r;i++)n=n*(r+i)/i;return n},"BigNumber, BigNumber":function(t,r){var n,a,o,s,u=new e.BigNumber(1);if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");for(n=t.minus(r),r.lt(n)&&(n=r),a=u,o=u,s=t.minus(n);o.lte(s);o=o.plus(1))a=a.times(n.plus(o)).dividedBy(o);return a}});return o.toTex={2:"\\binom{${args[0]}}{${args[1]}}"},o}function i(e){return e.isInteger()&&e.gte(0)}var a=r(3).isInteger;t.name="combinations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(115)),s=r(4),u=a("factorial",{number:function(e){if(e<0)throw new Error("Value must be non-negative");return o(e+1)},BigNumber:function(e){if(e.isNegative())throw new Error("Value must be non-negative");return o(e.plus(1))},"Array | Matrix":function(e){return i(e,u)}});return u.toTex={1:"\\left(${args[0]}\\right)"+s.operators.factorial},u}var i=r(1);t.name="factorial",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isPositive",{number:function(e){return e>0},BigNumber:function(e){return!e.isNeg()&&!e.isZero()&&!e.isNaN()},Fraction:function(e){return e.s>0&&e.n>0},Unit:function(e){return a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isPositive",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_=n&&p?[]:void 0,T=[],C=[],S=new s({values:_,index:T,ptr:C,size:[y,x],datatype:v}),z=_?[]:void 0,k=_?[]:void 0,B=[],I=[];for(M=0;M=i.length)throw new o(t,i.length);return e&&e.isMatrix===!0?e.create(n(e.valueOf(),t,r)):n(e,t,r)}},function(e,t){"use strict";t.type=function(e){var t=typeof e;return"object"===t?null===e?"null":e instanceof Boolean?"boolean":e instanceof Number?"number":e instanceof String?"string":Array.isArray(e)?"Array":e instanceof Date?"Date":e instanceof RegExp?"RegExp":"Object":"function"===t?"Function":t},t.isScalar=function(e){return!(e&&e.isMatrix||Array.isArray(e))}},function(e,t,r){function n(e){var t=i.create(e);return t.create=n,t.import(r(475)),t}var i=r(143);e.exports=n()},function(e,t){"use strict";e.exports={end:!0}},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.items=e||[],!Array.isArray(this.items)||!this.items.every(function(e){return e&&e.isNode}))throw new TypeError("Array containing Nodes expected");var t=function(){throw new Error("Property `ArrayNode.nodes` is deprecated, use `ArrayNode.items` instead")};Object.defineProperty(this,"nodes",{get:t,set:t})}var o=n(r(12));return a.prototype=new o,a.prototype.type="ArrayNode",a.prototype.isArrayNode=!0,a.prototype._compile=function(e,t){var r="Array"!==e.math.config().matrix,n=this.items.map(function(r){return r._compile(e,t)});return(r?"math.matrix([":"[")+n.join(",")+(r?"])":"]")},a.prototype.forEach=function(e){for(var t=0;t3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}function s(e,t){var r=i.getPrecedence(e,t),n={},a=i.getPrecedence(e.start,t);if(n.start=null!==a&&a<=r||"all"===t,e.step){var o=i.getPrecedence(e.step,t);n.step=null!==o&&o<=r||"all"===t}var s=i.getPrecedence(e.end,t);return n.end=null!==s&&s<=r||"all"===t,n}var u=n(r(12));return o.prototype=new u,o.prototype.type="RangeNode",o.prototype.isRangeNode=!0,o.prototype.needsEnd=function(){var e=this.filter(function(e){return e&&e.isSymbolNode&&"end"==e.name});return e.length>0},o.prototype._compile=function(e,t){return"math.range("+this.start._compile(e,t)+", "+this.end._compile(e,t)+(this.step?", "+this.step._compile(e,t):"")+")"},o.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},o.prototype.clone=function(){return new o(this.start,this.end,this.step&&this.step)},o.prototype._toString=function(e){var t,r=e&&e.parenthesis?e.parenthesis:"keep",n=s(this,r),i=this.start.toString(e);if(n.start&&(i="("+i+")"),t=i,this.step){var a=this.step.toString(e);n.step&&(a="("+a+")"),t+=":"+a}var o=this.end.toString(e);return n.end&&(o="("+o+")"),t+=":"+o},o.prototype._toTex=function(e){var t=e&&e.parenthesis?e.parenthesis:"keep",r=s(this,t),n=this.start.toTex(e);if(r.start&&(n="\\left("+n+"\\right)"),this.step){var i=this.step.toTex(e);r.step&&(i="\\left("+i+"\\right)"),n+=":"+i}var a=this.end.toTex(e);return r.end&&(a="\\left("+a+"\\right)"),n+=":"+a},o}var i=r(46);t.name="RangeNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e){var t=e.DenseMatrix,r=function(e,r,n){var i=e.size();if(2!==i.length)throw new RangeError("Matrix must be two dimensional (size: "+a.format(i)+")");var u=i[0],c=i[1];if(u!==c)throw new RangeError("Matrix must be square (size: "+a.format(i)+")");var f,l,p;if(r&&r.isMatrix===!0){var h=r.size();if(1===h.length){if(h[0]!==u)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");for(f=[],p=r._data,l=0;l1)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,r){if(t>=e.length)throw new Error("k out of bounds");for(var n=0,i=e.length-1;n=0){var u=e[o];e[o]=e[a],e[a]=u,--o}else++a;r(e[a],s)>0&&--a,t<=a?i=a:n=a+1}return e[t]}var c=n(r(47));return a("partitionSelect",{"Array | Matrix, number":function(e,t){return s(e,t,c)},"Array | Matrix, number, string":function(e,t,r){if("asc"===r)return s(e,t,c);if("desc"===r)return s(e,t,o);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s})}var i=r(3).isInteger;t.name="partitionSelect",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e){if(!l.hasOwnProperty(e))throw new Error("Unknown distribution "+e);var t=Array.prototype.slice.call(arguments,1),r=l[e].apply(this,t);return function(e){var t={random:function(e,t,r){var s,u,f;if(arguments.length>3)throw new i("random",arguments.length,0,3);if(1===arguments.length?a(e)?s=e:f=e:2===arguments.length?a(e)?(s=e,f=t):(u=e,f=t):(s=e,u=t,f=r),void 0!==u&&!o(u)||void 0!==f&&!o(f))throw new TypeError("Invalid argument in function random");if(void 0===f&&(f=1),void 0===u&&(u=0),void 0!==s){var p=l(s.valueOf(),u,f,n);return s&&s.isMatrix===!0?c(p):p}return n(u,f)},randomInt:s({"number | Array":function(e){var t=0;if(a(e)){var r=e,n=1,i=l(r.valueOf(),t,n,u);return r&&r.isMatrix===!0?c(i):i}var n=e;return u(t,n)},"number | Array, number":function(e,t){if(a(e)){var r=e,n=t,i=0,o=l(r.valueOf(),i,n,u);return r&&r.isMatrix===!0?c(o):o}var i=e,n=t;return u(i,n)},"Array, number, number":function(e,t,r){var n=l(e.valueOf(),t,r,u);return e&&e.isMatrix===!0?c(n):n}}),pickRandom:s({Array:function(e){return r(e)},"Array, number | Array":function(e,t){var n,i;if(Array.isArray(t))i=t;else{if(!o(t))throw new TypeError("Invalid argument in function pickRandom");n=t}return r(e,n,i)},"Array, number | Array, Array | number":function(e,t,n){var i,a;if(Array.isArray(t)?(a=t,i=n):(a=n,i=t),!Array.isArray(a)||!o(i))throw new TypeError("Invalid argument in function pickRandom");return r(e,i,a)}})},r=function(e,t,r){var n="undefined"==typeof t;if(n&&(t=1),e&&e.isMatrix===!0)e=e.valueOf();else if(!Array.isArray(e))throw new TypeError("Unsupported type of value in function pickRandom");if(f.size(e).length>1)throw new Error("Only one dimensional vectors supported");if("undefined"!=typeof r){if(r.length!=e.length)throw new Error("Weights must have the same length as possibles");for(var i=0,a=0,s=r.length;a=u)return e;for(var c,l=[];l.length1)for(var a=0,i=e.shift();a1;)e=Math.random(),t=Math.random(),r=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*t)+.5;return r}}};return u.toTex=void 0,u}var i=r(42),a=r(41),o=r(3).isNumber;t.name="distribution",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(9)),s=n(r(13)),u=n(r(23)),c=n(r(15)),f=n(r(7)),l=n(r(6)),p=r(4),h=i("equal",{"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:o(e,t)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=u(e,t,o);break;default:r=s(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=s(e,t,o,!1);break;default:r=f(e,t,o)}}return r},"Array, Array":function(e,t){return h(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return h(a(e),t)},"Matrix, Array":function(e,t){return h(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=l(e,t,o,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=c(t,e,o,!0);break;default:r=l(t,e,o,!0)}return r},"Array, any":function(e,t){return l(a(e),t,o,!1).valueOf()},"any, Array":function(e,t){return l(a(t),e,o,!0).valueOf()}});return h.toTex={2:"\\left(${args[0]}"+p.operators.equal+"${args[1]}\\right)"},h}t.name="equal",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string":function(){return!1},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isNumeric",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.prototype.type="Matrix",i.prototype.isMatrix=!0,i.storage=function(e){if(!o(e))throw new TypeError("format must be a string value");var t=i._storage[e];if(!t)throw new SyntaxError("Unsupported matrix storage format: "+e);return t},i._storage={},i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.create=function(e,t){throw new Error("Cannot invoke create on a Matrix interface")},i.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i}var i=r(24),a=i.string,o=a.isString;t.name="Matrix",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_,T=n&&p?[]:void 0,C=[],S=[],z=new s({values:T,index:C,ptr:S,size:[y,x],datatype:v}),k=n&&p?[]:void 0,B=n&&p?[]:void 0,I=[],P=[];for(M=0;M0)if(++s>c)for(s-=c;s--;u+="0");else s1&&(null==f[o+1]&&(f[o+1]=0),f[o+1]+=f[o]>>1,f[o]&=1)}return f.reverse()}var i=r(78);e.exports=function(e,t,r){var a,o,s=e.constructor,u=+(e.s<0),c=+(t.s<0);if(u){a=n(i(e));for(var f=0;f0;)r(l[--m],p[--d])==g&&(v=v.plus(y)),y=y.times(x);for(;d>0;)r(h,p[--d])==g&&(v=v.plus(y)),y=y.times(x);return s.config({precision:w}),0==g&&(v.s=-v.s),v}},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,t){for(var r=0;r3&&void 0!==arguments[3]?arguments[3]:1;if("string"===a.typeof(e)){if("CNOT"===e){for(var i=r,s=n,u=a.eye(2,"sparse"),c=a.matrix(this.X,"sparse"),f=a.matrix([[NaN,0],[0,1]],"sparse"),l=[],p=1;p<=t;p++)p===i?l.push(f):p===s?l.push(c):l.push(u);var h=a.matrix(l.reduce(function(e,t){return a.kron(e,t)}),"sparse");return h=a.map(h,function(e,t){ +return a.isNaN(e)?t[0]===t[1]?1:0:e})}for(var m=a.eye(2,"sparse"),d=a.matrix(this[e],"sparse"),g=[],v=1;v<=t;v++)v===r?g.push(d):g.push(m);return g.reduce(function(e,t){return a.kron(e,t)})}if("Matrix"===a.typeof(e)||"Array"===a.typeof(e)){var y=a.eye(2,"sparse"),x=a.matrix(e,"sparse");if(!o.isUnitary(x))throw new Error("The gate supplied to generateGate is not unitary");for(var w=[],b=1;b<=t;b++)b===r?w.push(x):w.push(y);return w.reduce(function(e,t){return a.kron(e,t)})}return a.eye(a.pow(2,t),"sparse")}},{key:"X",get:function(){return[[0,1],[1,0]]}},{key:"Y",get:function(){return[[0,u],[s,0]]}},{key:"Z",get:function(){return[[1,0],[0,-1]]}},{key:"H",get:function(){return a.multiply(1/a.sqrt(2),[[1,1],[1,-1]])}},{key:"Id",get:function(){return a.eye(2)}},{key:"S",get:function(){return[[1,0],[0,s]]}},{key:"SDagger",get:function(){return a.conj(a.transpose([[1,0],[0,s]]))}},{key:"T",get:function(){return[[1,0],[0,a.pow(a.e,a.multiply(s,a.pi/4))]]}},{key:"TDagger",get:function(){return a.conj(a.transpose([[1,0],[0,a.pow(a.e,a.multiply(s,a.pi/4))]]))}}]),e}();e.exports=c},function(e,t,r){"use strict";function n(e,t,n,a,o){function s(){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");this.scope={}}var u=n(r(29));return s.prototype.type="Parser",s.prototype.isParser=!0,s.prototype.parse=function(e){throw new Error("Parser.parse is deprecated. Use math.parse instead.")},s.prototype.compile=function(e){throw new Error("Parser.compile is deprecated. Use math.compile instead.")},s.prototype.eval=function(e){return u(e).compile().eval(this.scope)},s.prototype.get=function(e){return this.scope[e]},s.prototype.getAll=function(){return i({},this.scope)},s.prototype.set=function(e,t){return this.scope[e]=t},s.prototype.remove=function(e){delete this.scope[e]},s.prototype.clear=function(){for(var e in this.scope)this.scope.hasOwnProperty(e)&&delete this.scope[e]},s}var i=r(5).extend;t.name="Parser",t.path="expression",t.factory=n,t.math=!0},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t,r){function n(e,t,n,i){var a={};return a.bignumber=r(166),a.boolean=r(167),a.complex=r(168),a.createUnit=r(169),a.fraction=r(170),a.index=r(171),a.matrix=r(172),a.number=r(173),a.sparse=r(174),a.splitUnit=r(175),a.string=r(176),a.unit=r(177),a.e=r(82),a.E=r(82),a.false=r(159),a.i=r(160),a.Infinity=r(151),a.LN2=r(153),a.LN10=r(152),a.LOG2E=r(155),a.LOG10E=r(154),a.NaN=r(156),a.null=r(161),a.pi=r(83),a.PI=r(83),a.phi=r(162),a.SQRT1_2=r(157),a.SQRT2=r(158),a.tau=r(163),a.true=r(164),a.version=r(165),a.speedOfLight={description:"Speed of light in vacuum",examples:["speedOfLight"]},a.gravitationConstant={description:"Newtonian constant of gravitation",examples:["gravitationConstant"]},a.planckConstant={description:"Planck constant",examples:["planckConstant"]},a.reducedPlanckConstant={description:"Reduced Planck constant",examples:["reducedPlanckConstant"]},a.magneticConstant={description:"Magnetic constant (vacuum permeability)",examples:["magneticConstant"]},a.electricConstant={description:"Electric constant (vacuum permeability)",examples:["electricConstant"]},a.vacuumImpedance={description:"Characteristic impedance of vacuum",examples:["vacuumImpedance"]},a.coulomb={description:"Coulomb's constant",examples:["coulomb"]},a.elementaryCharge={description:"Elementary charge",examples:["elementaryCharge"]},a.bohrMagneton={description:"Borh magneton",examples:["bohrMagneton"]},a.conductanceQuantum={description:"Conductance quantum",examples:["conductanceQuantum"]},a.inverseConductanceQuantum={description:"Inverse conductance quantum",examples:["inverseConductanceQuantum"]},a.magneticFluxQuantum={description:"Magnetic flux quantum",examples:["magneticFluxQuantum"]},a.nuclearMagneton={description:"Nuclear magneton",examples:["nuclearMagneton"]},a.klitzing={description:"Von Klitzing constant",examples:["klitzing"]},a.bohrRadius={description:"Borh radius",examples:["bohrRadius"]},a.classicalElectronRadius={description:"Classical electron radius",examples:["classicalElectronRadius"]},a.electronMass={description:"Electron mass",examples:["electronMass"]},a.fermiCoupling={description:"Fermi coupling constant",examples:["fermiCoupling"]},a.fineStructure={description:"Fine-structure constant",examples:["fineStructure"]},a.hartreeEnergy={description:"Hartree energy",examples:["hartreeEnergy"]},a.protonMass={description:"Proton mass",examples:["protonMass"]},a.deuteronMass={description:"Deuteron Mass",examples:["deuteronMass"]},a.neutronMass={description:"Neutron mass",examples:["neutronMass"]},a.quantumOfCirculation={description:"Quantum of circulation",examples:["quantumOfCirculation"]},a.rydberg={description:"Rydberg constant",examples:["rydberg"]},a.thomsonCrossSection={description:"Thomson cross section",examples:["thomsonCrossSection"]},a.weakMixingAngle={description:"Weak mixing angle",examples:["weakMixingAngle"]},a.efimovFactor={description:"Efimov factor",examples:["efimovFactor"]},a.atomicMass={description:"Atomic mass constant",examples:["atomicMass"]},a.avogadro={description:"Avogadro's number",examples:["avogadro"]},a.boltzmann={description:"Boltzmann constant",examples:["boltzmann"]},a.faraday={description:"Faraday constant",examples:["faraday"]},a.firstRadiation={description:"First radiation constant",examples:["firstRadiation"]},a.loschmidt={description:"Loschmidt constant at T=273.15 K and p=101.325 kPa",examples:["loschmidt"]},a.gasConstant={description:"Gas constant",examples:["gasConstant"]},a.molarPlanckConstant={description:"Molar Planck constant",examples:["molarPlanckConstant"]},a.molarVolume={description:"Molar volume of an ideal gas at T=273.15 K and p=101.325 kPa",examples:["molarVolume"]},a.sackurTetrode={description:"Sackur-Tetrode constant at T=1 K and p=101.325 kPa",examples:["sackurTetrode"]},a.secondRadiation={description:"Second radiation constant",examples:["secondRadiation"]},a.stefanBoltzmann={description:"Stefan-Boltzmann constant",examples:["stefanBoltzmann"]},a.wienDisplacement={description:"Wien displacement law constant",examples:["wienDisplacement"]},a.molarMass={description:"Molar mass constant",examples:["molarMass"]},a.molarMassC12={description:"Molar mass constant of carbon-12",examples:["molarMassC12"]},a.gravity={description:"Standard acceleration of gravity (standard acceleration of free-fall on Earth)",examples:["gravity"]},a.planckLength={description:"Planck length",examples:["planckLength"]},a.planckMass={description:"Planck mass",examples:["planckMass"]},a.planckTime={description:"Planck time",examples:["planckTime"]},a.planckCharge={description:"Planck charge",examples:["planckCharge"]},a.planckTemperature={description:"Planck temperature",examples:["planckTemperature"]},a.derivative=r(181),a.lsolve=r(182),a.lup=r(183),a.lusolve=r(184),a.simplify=r(185),a.slu=r(186),a.usolve=r(187),a.abs=r(188),a.add=r(189),a.cbrt=r(190),a.ceil=r(191),a.cube=r(192),a.divide=r(193),a.dotDivide=r(194),a.dotMultiply=r(195),a.dotPow=r(196),a.exp=r(197),a.fix=r(198),a.floor=r(199),a.gcd=r(200),a.hypot=r(201),a.lcm=r(202),a.log=r(203),a.log10=r(204),a.mod=r(205),a.multiply=r(206),a.norm=r(207),a.nthRoot=r(208),a.pow=r(209),a.round=r(210),a.sign=r(211),a.sqrt=r(212),a.square=r(213),a.subtract=r(214),a.unaryMinus=r(215),a.unaryPlus=r(216),a.xgcd=r(217),a.bitAnd=r(218),a.bitNot=r(219),a.bitOr=r(220),a.bitXor=r(221),a.leftShift=r(222),a.rightArithShift=r(223),a.rightLogShift=r(224),a.bellNumbers=r(225),a.catalan=r(226),a.composition=r(227),a.stirlingS2=r(228),a.config=r(178),a.import=r(179),a.typed=r(180),a.arg=r(229),a.conj=r(230),a.re=r(232),a.im=r(231),a.eval=r(233),a.help=r(234),a.distance=r(235),a.intersect=r(236),a.and=r(237),a.not=r(238),a.or=r(239),a.xor=r(240),a.concat=r(241),a.cross=r(242),a.det=r(243),a.diag=r(244),a.dot=r(245),a.eye=r(246),a.filter=r(247),a.flatten=r(248),a.forEach=r(249),a.inv=r(250),a.kron=r(251),a.map=r(252),a.ones=r(253),a.partitionSelect=r(254),a.range=r(255),a.resize=r(256),a.size=r(257),a.sort=r(258),a.squeeze=r(259),a.subset=r(260),a.trace=r(261),a.transpose=r(262),a.zeros=r(263),a.combinations=r(264),a.factorial=r(265),a.gamma=r(266),a.kldivergence=r(267),a.multinomial=r(268),a.permutations=r(269),a.pickRandom=r(270),a.random=r(271),a.randomInt=r(272),a.compare=r(273),a.deepEqual=r(274),a.equal=r(275),a.larger=r(276),a.largerEq=r(277),a.smaller=r(278),a.smallerEq=r(279),a.unequal=r(280),a.erf=r(281),a.mad=r(282),a.max=r(283),a.mean=r(284),a.median=r(285),a.min=r(286),a.mode=r(287),a.prod=r(288),a.quantileSeq=r(289),a.std=r(290),a.sum=r(291),a.var=r(292),a.acos=r(293),a.acosh=r(294),a.acot=r(295),a.acoth=r(296),a.acsc=r(297),a.acsch=r(298),a.asec=r(299),a.asech=r(300),a.asin=r(301),a.asinh=r(302),a.atan=r(303),a.atanh=r(305),a.atan2=r(304),a.cos=r(306),a.cosh=r(307),a.cot=r(308),a.coth=r(309),a.csc=r(310),a.csch=r(311),a.sec=r(312),a.sech=r(313),a.sin=r(314),a.sinh=r(315),a.tan=r(316),a.tanh=r(317),a.to=r(318),a.clone=r(319),a.format=r(320),a.isNaN=r(322),a.isInteger=r(321),a.isNegative=r(323),a.isNumeric=r(324),a.isPositive=r(325),a.isPrime=r(326),a.isZero=r(327),a.typeof=r(328),a}t.name="docs",t.path="expression",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,a){var o=n(r(81));return i("parser",{"":function(){return new o(a)}})}t.name="parser",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e||!e.isNode)throw new TypeError('Node expected for parameter "object"');if(!t||!t.isIndexNode)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 o(e){return!(e.isAccessorNode||e.isArrayNode||e.isConstantNode||e.isFunctionNode||e.isObjectNode||e.isParenthesisNode||e.isSymbolNode)}var s=n(r(12)),u=n(r(93));return a.prototype=new s,a.prototype.type="AccessorNode",a.prototype.isAccessorNode=!0,a.prototype._compile=function(e,t){e.access=u;var r=this.object._compile(e,t),n=this.index._compile(e,t);return this.index.isObjectProperty()?r+'["'+this.index.getObjectProperty()+'"]':this.index.needsSize()?"(function () { var object = "+r+"; var size = math.size(object).valueOf(); return access(object, "+n+");})()":"access("+r+", "+n+")"},a.prototype.forEach=function(e){e(this.object,"object",this),e(this.index,"index",this)},a.prototype.map=function(e){return new a(this._ifNode(e(this.object,"object",this)),this._ifNode(e(this.index,"index",this)))},a.prototype.clone=function(){return new a(this.object,this.index)},a.prototype._toString=function(e){var t=this.object.toString(e);return o(this.object)&&(t="("+t+")"),t+this.index.toString(e)},a.prototype._toTex=function(e){var t=this.object.toTex(e);return o(this.object)&&(t="\\left("+t+"\\right)"),t+this.index.toTex(e)},a}t.name="AccessorNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(this.object=e,this.index=r?t:null,this.value=r?r:t,!e||!e.isSymbolNode&&!e.isAccessorNode)throw new TypeError('SymbolNode or AccessorNode expected as "object"');if(e&&e.isSymbolNode&&"end"===e.name)throw new Error('Cannot assign to symbol "end"');if(this.index&&!this.index.isIndexNode)throw new TypeError('IndexNode expected as "index"');if(!this.value||!this.value.isNode)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 o(e,t){t||(t="keep");var r=f.getPrecedence(e,t),n=f.getPrecedence(e.value,t);return"all"===t||null!==n&&n<=r}var s=n(r(12)),u=(n(r(64)),n(r(2)),n(r(337))),c=n(r(93)),f=(r(63),r(46));return a.prototype=new s,a.prototype.type="AssignmentNode",a.prototype.isAssignmentNode=!0,a.prototype._compile=function(e,t){e.assign=u,e.access=c;var r,n=this.object._compile(e,t),i=this.index?this.index._compile(e,t):null,a=this.value._compile(e,t);if(this.index){if(this.index.isObjectProperty())return n+'["'+this.index.getObjectProperty()+'"] = '+a;if(this.object.isSymbolNode)return r=this.index.needsSize()?"var size = math.size(object).valueOf();":"","(function () { var object = "+n+"; var value = "+a+"; "+r+' scope["'+this.object.name+'"] = assign(object, '+i+", value); return value;})()";r=this.index.needsSize()?"var size = math.size(object).valueOf();":"";var o=this.object.object._compile(e,t);if(this.object.index.isObjectProperty()){var s='["'+this.object.index.getObjectProperty()+'"]';return"(function () { var parent = "+o+"; var object = parent"+s+"; var value = "+a+";"+r+" parent"+s+" = assign(object, "+i+", value); return value;})()"}var f=this.object.index.needsSize()?"var size = math.size(parent).valueOf();":"",l=this.object.index._compile(e,t);return"(function () { var parent = "+o+"; "+f+" var parentIndex = "+l+"; var object = access(parent, parentIndex); var value = "+a+"; "+r+" assign(parent, parentIndex, assign(object, "+i+", value)); return value;})()"}if(!this.object.isSymbolNode)throw new TypeError("SymbolNode expected as object");return'scope["'+this.object.name+'"] = '+a},a.prototype.forEach=function(e){e(this.object,"object",this),this.index&&e(this.index,"index",this),e(this.value,"value",this)},a.prototype.map=function(e){var t=this._ifNode(e(this.object,"object",this)),r=this.index?this._ifNode(e(this.index,"index",this)):null,n=this._ifNode(e(this.value,"value",this));return new a(t,r,n)},a.prototype.clone=function(){return new a(this.object,this.index,this.value)},a.prototype._toString=function(e){var t=this.object.toString(e),r=this.index?this.index.toString(e):"",n=this.value.toString(e);return o(this,e&&e.parenthesis)&&(n="("+n+")"),t+r+" = "+n},a.prototype._toTex=function(e){var t=this.object.toTex(e),r=this.index?this.index.toTex(e):"",n=this.value.toTex(e);return o(this,e&&e.parenthesis)&&(n="\\left("+n+"\\right)"),t+r+":="+n},a}r(4);t.name="AssignmentNode",t.path="expression.node",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if(!(this instanceof a))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(!t||!t.isNode)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}})}var o=n(r(12)),s=n(r(132));return a.prototype=new o,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(e,t){e.ResultSet=s;var r=this.blocks.map(function(r){var n=r.node._compile(e,t);return r.visible?"results.push("+n+");":n+";"});return"(function () {var results = [];"+r.join("")+"return new ResultSet(results);})()"},a.prototype.forEach=function(e){for(var t=0;t0)for(t=0;t0&&C.forEach(0,r-1,function(e,t){d._forEachRow(e,y,x,w,function(r,n){r>e&&C.accumulate(r,m(f(n,t)))})});var k=r,B=C.get(r),I=s(B);C.forEach(r+1,i-1,function(e,t){var r=s(t);p(r,I)&&(k=e,I=r,B=t)}),r!==k&&(d._swapRows(r,k,b[1],y,x,w),d._swapRows(r,k,A[1],N,E,M),C.swap(r,k),T(r,k)),C.forEach(0,i-1,function(e,t){e<=r?(N.push(t),E.push(e)):(t=c(t,B),h(t,0)||(y.push(t),x.push(e)))})}return M.push(N.length),w.push(y.length),{L:new d({values:y,index:x,ptr:w,size:b}),U:new d({values:N,index:E,ptr:M,size:A}),p:O,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.p}}};return y}var i=r(24),a=i.object;t.name="lup",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(365)),s=n(r(360)),u=i("slu",{"SparseMatrix, number, number":function(e,t,r){if(!o(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=a(t,e,!1),i=s(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"}}}});return u}var i=r(24),a=i.number,o=a.isInteger;t.name="slu",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){return e.transform(function(e,t,r){return e.isParenthesisNode?e.content:e})}function o(e){for(var t=[],r=0;r");if(2!==u.length)throw SyntaxError("Could not parse rule: "+i);i={l:u[0],r:u[1]};case"object":if(n={l:a(m(i.l)),r:a(m(i.r))},i.context&&(n.evaluate=i.context),i.evaluate&&(n.evaluate=m(i.evaluate)),n.l.isOperatorNode&&E(n.l)){var c=_(n.l),f=s();n.expanded={},n.expanded.l=c([n.l.clone(),f]),M(n.expanded.l),A(n.expanded.l),n.expanded.r=c([n.r,f])}break;case"function":n=i;break;default:throw TypeError("Unsupported type of rule: "+o)}t.push(n)}return t}function s(){return new x("_p"+C++)}function u(e,t){var r,n,i=[],a=_(e);if(N(e,t))for(var o=0;o=2&&2===e.args.length){for(var i=u(t,e.context),a=[],o=0;o2)throw Error("Unexpected non-binary associative function: "+e.toString());return[]}for(var c=[],o=0;o2&&o(e)){for(var i=e.args.pop();e.args.length>0;)i=t([e.args.pop(),i]);e.args=i.args}}}function f(e){if(e.args&&0!==e.args.length){for(var t=l(e),r=e.args.length,n=0;n2&&o(e)){for(var i=e.args.shift();e.args.length>0;)i=t([i,e.args.shift()]);e.args=i.args}}}function l(e){return e.isOperatorNode?function(t){try{return new h(e.op,e.fn,t)}catch(e){return console.error(e),[]}}:function(t){return new p(new m(e.name),t)}}var p=i.expression.node.FunctionNode,h=i.expression.node.OperatorNode,m=i.expression.node.SymbolNode,d={add:!0,multiply:!0},g={add:!0,multiply:!0};return{createMakeNodeFunction:l,isCommutative:a,isAssociative:o,flatten:s,allChildren:u,unflattenr:c,unflattenl:f}}t.factory=r,t.math=!0},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(17)),s=n(r(21)),u=n(r(19)),c=n(r(9)),f=n(r(66)),l=e.DenseMatrix,p=i("lsolve",{"SparseMatrix, Array | Matrix":function(e,t){return m(e,t)},"DenseMatrix, Array | Matrix":function(e,t){return h(e,t)},"Array, Array | Matrix":function(e,t){var r=a(e),n=h(r,t);return n.valueOf()}}),h=function(e,t){t=f(e,t,!0);for(var r=t._data,n=e._size[0],i=e._size[1],a=[],p=e._data,h=0;hv&&(w.push(h[n]),b.push(r));if(c(x,0))throw new Error("Linear system cannot be solved since matrix is singular");var E=o(y,x);for(n=0,N=b.length;n=0;h--){var m,d=r[h][0]||0;if(c(d,0))m=0;else{var g=p[h][h];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=o(d,g);for(var v=h-1;v>=0;v--)r[v]=[u(r[v][0]||0,s(m,p[v][h]))]}a[h]=[m]}return new l({data:a,size:[n,1]})},m=function(e,t){t=f(e,t,!0);for(var r,n,i=t._data,a=e._size[0],p=e._size[1],h=e._values,m=e._index,d=e._ptr,g=[],v=p-1;v>=0;v--){var y=i[v][0]||0;if(c(y,0))g[v]=[0];else{var x=0,w=[],b=[],N=d[v],E=d[v+1];for(n=E-1;n>=N;n--)r=m[n],r===v?x=h[n]:r=0;){var u=r[o+s],c=r[n+u];c==-1?(s--,a[t++]=u):(r[n+u]=r[i+c],++s,r[o+s]=c)}return t};return e}t.name="cs_tdfs",t.path="sparse",t.factory=r},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(17)),s=r(4),u=n(r(22)),c=n(r(13)),f=n(r(23)),l=n(r(14)),p=n(r(15)),h=n(r(7)),m=n(r(6)),d=i("dotDivide",{"any, any":o,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,o,!1);break;default:r=u(t,e,o,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,o,!1);break;default:r=h(e,t,o)}}return r},"Array, Array":function(e,t){return d(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return d(a(e),t)},"Matrix, Array":function(e,t){return d(e,a(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,o,!1);break;default:r=m(e,t,o,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=p(t,e,o,!0);break;default:r=m(t,e,o,!0)}return r},"Array, any":function(e,t){return m(a(e),t,o,!1).valueOf()},"any, Array":function(e,t){return m(a(t),e,o,!0).valueOf()}});return d.toTex={2:"\\left(${args[0]}"+s.operators.dotDivide+"${args[1]}\\right)"},d}t.name="dotDivide",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("fix",{number:function(e){return e>0?Math.floor(e):Math.ceil(e)},Complex:function(t){return new e.Complex(t.re>0?Math.floor(t.re):Math.ceil(t.re),t.im>0?Math.floor(t.im):Math.ceil(t.im))},BigNumber:function(e){return e.isNegative()?e.ceil():e.floor()},Fraction:function(e){return e.s<0?e.ceil():e.floor()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="fix",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(17)),s=a("log",{number:function(r){return r>=0||t.predictable?Math.log(r):new e.Complex(r,0).log()},Complex:function(e){return e.log()},BigNumber:function(r){return!r.isNegative()||t.predictable?r.ln():new e.Complex(r.toNumber(),0).log()},"Array | Matrix":function(e){return i(e,s)},"any, any":function(e,t){return o(s(e),s(t))}});return s.toTex={1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},s}var i=r(1);t.name="log",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(19)),s=n(r(11)),u=n(r(35)),c=n(r(36)),f=n(r(55)),l=n(r(54)),p=n(r(48)),h=n(r(40)),m=n(r(27)),d=i("stirlingS2",{"number | BigNumber, number | BigNumber":function(e,t){if(!h(e)||p(e)||!h(t)||p(t))throw new TypeError("Non-negative integer value expected in function stirlingS2");if(m(t,e))throw new TypeError("k must be less than or equal to n in function stirlingS2");for(var r=f(t),n=0,i=0;i<=t;i++){var d=c(-1,o(t,i)),g=l(t,i),v=c(i,e);n=a(n,s(s(g,v),d))}return u(n,r)}});return d.toTex={2:"\\mathrm{S}\\left(${args}\\right)"},d}t.name="stirlingS2",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("not",{number:function(e){return!e},Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return s(e.value)},"Array | Matrix":function(e){return i(e,s)}});return s.toTex={1:o.operators.not+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="not",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){var l=n(r(2)),p=f("concat",{"...Array | Matrix | number | BigNumber":function(e){var t,r,n=e.length,f=-1,p=!1,h=[];for(t=0;t0&&f>r)throw new u(f,r+1)}else{var d=a(m).valueOf(),g=s.size(d);if(h[t]=d,r=f,f=g.length-1,t>0&&f!=r)throw new c(r+1,f+1)}}if(0==h.length)throw new SyntaxError("At least one matrix expected");for(var v=h.shift();h.length;)v=i(v,h.shift(),f,0);return p?l(v):v},"...string":function(e){return e.join("")}});return p.toTex=void 0,p}function i(e,t,r,n){if(n0)for(;it;)n.push(i),i+=r;return n}function u(e,t,r){var n=[],i=e;if(r>0)for(;i<=t;)n.push(i),i+=r;else if(r<0)for(;i>=t;)n.push(i),i+=r;return n}function c(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lt(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gt(t);)n.push(i),i=i.plus(r);return n}function f(e,t,r){var n=[],i=e;if(r.gt(h))for(;i.lte(t);)n.push(i),i=i.plus(r);else if(r.lt(h))for(;i.gte(t);)n.push(i),i=i.plus(r);return n}function l(e){var t=e.split(":"),r=t.map(function(e){return Number(e)}),n=r.some(function(e){return isNaN(e)});if(n)return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}var p=n(r(2)),h=new e.BigNumber(0),m=new e.BigNumber(1),d=i("range",{string:o,"string, boolean":o,"number, number":function(e,t){return a(s(e,t,1))},"number, number, number":function(e,t,r){return a(s(e,t,r))},"number, number, boolean":function(e,t,r){return a(r?u(e,t,1):s(e,t,1))},"number, number, number, boolean":function(e,t,r,n){return a(n?u(e,t,r):s(e,t,r))},"BigNumber, BigNumber":function(e,t){return a(c(e,t,m))},"BigNumber, BigNumber, BigNumber":function(e,t,r){return a(c(e,t,r))},"BigNumber, BigNumber, boolean":function(e,t,r){return a(r?f(e,t,m):c(e,t,m))},"BigNumber, BigNumber, BigNumber, boolean":function(e,t,r,n){return a(n?f(e,t,r):c(e,t,r))}});return d.toTex=void 0,d}t.name="range",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(2)),u=n(r(16)),c=o("trace",{Array:function(e){return c(s(e))},Matrix:function(e){var t;switch(e.storage()){case"dense":t=f(e);break;case"sparse":t=l(e)}return t},any:i}),f=function(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1==t[0])return i(r[0]);throw new RangeError("Matrix must be square (size: "+a(t)+")");case 2:var n=t[0],o=t[1];if(n===o){for(var s=0,c=0;c0)for(var f=0;ff)break}return c}throw new RangeError("Matrix must be square (size: "+a(i)+")")};return c.toTex={1:"\\mathrm{tr}\\left(${args[0]}\\right)"},c}var i=r(5).clone,a=r(20).format;t.name="trace",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(r){if(r.isZero())return new e.BigNumber(1);for(var n=t.precision+(0|Math.log(r.toNumber())),i=e.BigNumber.clone({precision:n}),a=new i(r),o=r.toNumber()-1;o>1;)a=a.times(o),o--;return new e.BigNumber(a.toPrecision(e.BigNumber.precision))}var f=n(r(11)),l=n(r(36)),p=u("gamma",{number:function(e){var t,r;if(a(e)){if(e<=0)return isFinite(e)?1/0:NaN;if(e>171)return 1/0;for(var n=e-2,i=e-1;n>1;)i*=n,n--;return 0==i&&(i=1),i}if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*p(1-e));if(e>=171.35)return 1/0;if(e>85){var u=e*e,c=u*e,f=c*e,l=f*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*u)-139/(51840*c)-571/(2488320*f)+163879/(209018880*l)+5246819/(75246796800*l*e))}--e,r=s[0];for(var h=1;h=t},"number, number":function(e,r){return e>=r||i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gte(r)||a(e,r,t.epsilon)},"Fraction, Fraction":function(e,t){return e.compare(t)!==-1},"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 m(e.value,t.value)},"string, string":function(e,t){return e>=t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=c(e,t,m);break;default:r=u(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=u(e,t,m,!1);break;default:r=l(e,t,m)}}return r},"Array, Array":function(e,t){return m(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return m(s(e),t)},"Matrix, Array":function(e,t){return m(e,s(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=p(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,m,!0);break;default:r=p(t,e,m,!0)}return r},"Array, any":function(e,t){return p(s(e),t,m,!1).valueOf()},"any, Array":function(e,t){return p(s(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+h.operators.largerEq+"${args[1]}\\right)"},m}var i=r(3).nearlyEqual,a=r(32);t.name="largerEq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t){return f(e,t)?e:t}function c(e){var t=void 0;if(i(e,function(e){(void 0===t||f(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate max of an empty array");return t}var f=n(r(27)),l=s("max",{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(e,t){return a(e,t.valueOf(),u)},"...":function(e){if(o(e))throw new TypeError("Scalar values expected in function max");return c(e)}});return l.toTex="\\max\\left(${args}\\right)",l}var i=r(33),a=r(60),o=r(59);t.name="max",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(e,t){var r=o(e,t,l),n=Array.isArray(e)?i(e):e.size();return p(r,n[t])}function f(e){var t=0,r=0;if(a(e,function(e){t=l(t,e),r++}),0===r)throw new Error("Cannot calculate mean of an empty array");return p(t,r)}var l=n(r(16)),p=n(r(35)),h=u("mean",{"Array | Matrix":f,"Array | Matrix, number | BigNumber":c,"...":function(e){if(s(e))throw new TypeError("Scalar values expected in function mean");return f(e)}});return h.toTex=void 0,h}var i=r(8).size,a=r(33),o=r(60),s=r(59);t.name="mean",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(e){e=i(e.valueOf());var t=e.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=l(e,r+1),a=e[r],o=0;o0&&(a=e[o]);return m(a,n)}var s=l(e,(t-1)/2);return h(s)}var u=n(r(18)),c=n(r(17)),f=n(r(47)),l=n(r(70)),p=o("median",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(e){if(a(e))throw new TypeError("Scalar values expected in function median");return s(e)}}),h=o({"number | BigNumber | Unit":function(e){return e}}),m=o({"number | BigNumber | Unit, number | BigNumber | Unit":function(e,t){return c(u(e,t),2)}});return p.toTex=void 0,p}var i=r(8).flatten,a=(r(60),r(59));t.name="median",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t){return f(e,t)?e:t}function c(e){var t=void 0;if(i(e,function(e){(void 0===t||f(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate min of an empty array");return t}var f=n(r(39)),l=s("min",{"Array | Matrix":c,"Array | Matrix, number | BigNumber":function(e,t){return a(e,t.valueOf(),u)},"...":function(e){if(o(e))throw new TypeError("Scalar values expected in function min");return c(e)}});return l.toTex="\\min\\left(${args}\\right)",l}var i=r(33),a=r(60),o=r(59);t.name="min",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(r){var n=void 0;if(i(r,function(e){n=void 0===n?e:s(n,e)}),void 0===n)switch(t.number){case"number":return 0;case"BigNumber":return new e.BigNumber(0);case"Fraction":return new e.Fraction(0);default:return 0}return n}var s=n(r(18)),u=a("sum",{"Array | Matrix":function(e){return o(e)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(e){return o(e)}});return u.toTex=void 0,u}var i=r(33);t.name="sum",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=0,i=0;if(0==t.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(a(t,function(e){n=u(n,e),i++}),0===i)throw new Error("Cannot calculate var of an empty array");var o=l(n,i);switch(n=0,a(t,function(e){var t=c(e,o);n=u(n,f(t,t))}),r){case"uncorrected":return l(n,i);case"biased":return l(n,i+1);case"unbiased":var s=n&&n.isBigNumber===!0?new e.BigNumber(0):0;return 1==i?s:l(n,i-1);default:throw new Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}var u=n(r(18)),c=n(r(19)),f=n(r(21)),l=n(r(17)),p=o("variance",{"Array | Matrix":function(e){return s(e,i)},"Array | Matrix, string":s,"...":function(e){return s(e,i)}});return p.toTex="\\mathrm{Var}\\left(${args}\\right)",p}var i="unbiased",a=r(33);t.name="var",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("format",{any:i.format,"any, Object | function | number":i.format});return a.toTex=void 0,a}var i=r(20);t.name="format",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("acosh",{number:function(r){return r>=1||t.predictable?a(r):r<=-1?new e.Complex(Math.log(Math.sqrt(r*r-1)-r),Math.PI):new e.Complex(r,0).acosh()},Complex:function(e){return e.acosh()},BigNumber:function(e){return e.acosh()},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\cosh^{-1}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.acosh||function(e){return Math.log(Math.sqrt(e*e-1)+e)};t.name="acosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isZero",{number:function(e){return 0===e},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 a(e.value)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);r(3);t.name="isZero",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("_typeof",{any:function(e){var t=i.type(e);if("Object"===t){if(e.isBigNumber===!0)return"BigNumber";if(e.isComplex===!0)return"Complex";if(e.isFraction===!0)return"Fraction";if(e.isMatrix===!0)return"Matrix";if(e.isUnit===!0)return"Unit";if(e.isIndex===!0)return"Index";if(e.isRange===!0)return"Range";if(e.isChain===!0)return"Chain";if(e.isHelp===!0)return"Help"}return t}});return a.toTex=void 0,a}var i=r(61);t.name="typeof",t.factory=n},function(e,t,r){function n(e,t,r,n,s){return i.prototype.type="Complex",i.prototype.isComplex=!0,i.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},i.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},i.prototype.format=function(e){var t="",r=this.im,n=this.re,i=a(this.re,e),s=a(this.im,e),u=o(e)?e:e?e.precision:null;if(null!==u){var c=Math.pow(10,-u);Math.abs(n/r)0?1==r?i+" + i":i+" + "+s+"i":r==-1?i+" - i":i+" - "+s.substring(1)+"i"},i.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"==typeof t)return i(t);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var r=arguments[0],n=arguments[1];if(o(r)){if(n&&n.isUnit&&n.hasBase("ANGLE")&&(n=n.toNumber("rad")),o(n))return new i({r:r,phi:n});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")}},i.prototype.valueOf=i.prototype.toString,i.fromJSON=function(e){return new i(e)},i.EPSILON=t.epsilon,s.on("config",function(e,t){e.epsilon!==t.epsilon&&(i.EPSILON=e.epsilon)}),i}var i=r(140),a=r(3).format,o=r(3).isNumber;t.name="Complex",t.path="type",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("fraction",{number:function(t){if(!isFinite(t)||isNaN(t))throw new Error(t+" cannot be represented as a fraction");return new e.Fraction(t)},string:function(t){return new e.Fraction(t)},"number, number":function(t,r){return new e.Fraction(t,r)},BigNumber:function(t){return new e.Fraction(t.toString())},Fraction:function(e){return e},Object:function(t){return new e.Fraction(t)},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);t.name="fraction",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,c){function d(e,t){if(!(this instanceof d))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!h(t))throw new Error("Invalid datatype: "+t);if(e&&e.isMatrix===!0)"DenseMatrix"===e.type?(this._data=u.clone(e._data),this._size=u.clone(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&f(e.data)&&f(e.size))this._data=e.data,this._size=e.size,this._datatype=t||e.datatype;else if(f(e))this._data=b(e),this._size=s.size(this._data),s.validate(this._data,this._size),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._data=[],this._size=[0],this._datatype=t}}function g(e,t){if(!t||t.isIndex!==!0)throw new TypeError("Invalid index");var r=t.isScalar();if(r)return e.get(t.min());var n=t.size();if(n.length!=e._size.length)throw new a(n.length,e._size.length);for(var i=t.min(),o=t.max(),s=0,u=e._size.length;s");var p=t.max().map(function(e){return e+1});w(e,p,n);var h=o.length,m=0;x(e._data,t,r,h,m)}return e}function x(e,t,r,n,i){var a=i==n-1,o=t.dimension(i);a?o.forEach(function(t,n){m(t),e[t]=r[n[0]]}):o.forEach(function(a,o){m(a),x(e[a],t,r[o[0]],n,i+1)})}function w(e,t,r){for(var n=e._size.slice(0),i=!1;n.lengthn[a]&&(n[a]=t[a],i=!0);i&&E(e,n,r)}function b(e){for(var t=0,r=e.length;t0?e:0,r=e<0?-e:0,n=this._size[0],i=this._size[1],a=Math.min(n-r,i-t),o=[],s=0;s0?n:0,m=n<0?-n:0,g=t[0],v=t[1],y=Math.min(g-m,v-u);if(f(r)){if(r.length!==y)throw new Error("Invalid value array length");o=function(e){return r[e]}}else if(r&&r.isMatrix===!0){var x=r.size();if(1!==x.length||x[0]!==y)throw new Error("Invalid matrix length");o=function(e){return r.get([e])}}else o=function(){return r};i||(i=o(0)&&o(0).isBigNumber===!0?new e.BigNumber(0):0);var w=[];if(t.length>0){w=s.resize(w,t,i);for(var b=0;b0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},a.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},a.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++},a.prototype.map=function(e){var t=[];return this.forEach(function(r,n,i){t[n[0]]=e(r,n,i)}),t},a.prototype.toArray=function(){var e=[];return this.forEach(function(t,r){e[r[0]]=t}),e},a.prototype.valueOf=function(){return this.toArray()},a.prototype.format=function(e){var t=i.format(this.start,e);return 1!=this.step&&(t+=":"+i.format(this.step,e)),t+=":"+i.format(this.end,e)},a.prototype.toString=function(){return this.format()},a.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(e){return new a(e.start,e.end,e.step)},a}var i=r(3);t.name="Range",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(9)),s=e.SparseMatrix,u=function(e,t,r){var n=e._values,u=e._index,c=e._ptr,f=e._size,l=e._datatype,p=t._values,h=t._index,m=t._ptr,d=t._size,g=t._datatype;if(f.length!==d.length)throw new i(f.length,d.length);if(f[0]!==d[0]||f[1]!==d[1])throw new RangeError("Dimension mismatch. Matrix A ("+f+") must match Matrix B ("+d+")");var v,y=f[0],x=f[1],w=o,b=0,N=r;"string"==typeof l&&l===g&&(v=l,w=a.find(o,[v,v]),b=a.convert(0,v),N=a.find(r,[v,v]));var E,M,A,O,_,T=n&&p?[]:void 0,C=[],S=[],z=new s({values:T,index:C,ptr:S,size:[y,x],datatype:v}),k=T?[]:void 0,B=[];for(M=0;M="0"&&e<="9"||"."==e}function p(e){return e>="0"&&e<="9"}function h(){P++,R=I.charAt(P)}function m(e){P=e,R=I.charAt(P)}function d(){var e,t="";if(e=P,"+"==R?h():"-"==R&&(t+=R,h()),!l(R))return m(e),null;if("."==R){if(t+=R,h(),!p(R))return m(e),null}else{for(;p(R);)t+=R,h();"."==R&&(t+=R,h())}for(;p(R);)t+=R,h();if("E"==R||"e"==R){var r="",n=P;if(r+=R,h(),"+"!=R&&"-"!=R||(r+=R,h()),!p(R))return m(n),t;for(t+=r;p(R);)t+=R,h()}return t}function g(){for(var e="",t=I.charCodeAt(P);t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122;)e+=R,h(),t=I.charCodeAt(P);return t=e.charCodeAt(0),t>=65&&t<=90||t>=97&&t<=122?e||null:null}function v(e){return R===e?(h(),e):null}function y(e){if(G.hasOwnProperty(e)){var t=G[e],r=t.prefixes[""];return{unit:t,prefix:r}}for(var n in G)if(G.hasOwnProperty(n)&&i(e,n)){var t=G[n],a=e.length-n.length,o=e.substring(0,a),r=t.prefixes[o];if(void 0!==r)return{unit:t,prefix:r}}return null}function x(t){if("BigNumber"===t.number){var r=o.pi(e.BigNumber);G.rad.value=new e.BigNumber(1),G.deg.value=r.div(180),G.grad.value=r.div(200),G.cycle.value=r.times(2),G.arcsec.value=r.div(648e3),G.arcmin.value=r.div(10800)}else G.rad.value=1,G.deg.value=Math.PI/180,G.grad.value=Math.PI/200,G.cycle.value=2*Math.PI,G.arcsec.value=Math.PI/648e3,G.arcmin.value=Math.PI/10800}function w(e){for(var t=0;t="0"&&e<="9"};if(0===t&&!n(r))throw new Error('Invalid unit name (must begin with alpha character): "'+e+'"');if(t>0&&!n(r)&&!i(r))throw new Error('Invalid unit name (only alphanumeric characters are allowed): "'+e+'"')}}var b=n(r(18)),N=n(r(19)),E=n(r(21)),M=n(r(17)),A=n(r(36)),O=n(r(26)),_=n(r(104)),T=n(r(72)),C=n(r(73)),S=n(r(123)),z=n(r(126)),k=n(r(77)),B=n(r(127));c.prototype.type="Unit",c.prototype.isUnit=!0;var I,P,R;c.parse=function(r,n){if(n=n||{},I=r,P=-1,R="","string"!=typeof I)throw new TypeError("Invalid argument in Unit.parse, string expected");var i=new c;i.units=[],h(),f();var a=d(),o=null;a&&(o="BigNumber"===t.number?new e.BigNumber(a):"Fraction"===t.number?new e.Fraction(a):parseFloat(a)),f();for(var s=1,u=!1,l=[],p=1;;){for(f();"("===R;)l.push(s),p*=s,s=1,h(),f();if(!R)break;var m=R,x=g();if(null==x)throw new SyntaxError('Unexpected "'+m+'" in "'+I+'" at index '+P.toString());var w=y(x);if(null==w)throw new SyntaxError('Unit "'+x+'" not found.');var b=s*p;if(f(),v("^")){f();var N=d();if(null==N)throw new SyntaxError('In "'+r+'", "^" must be followed by a floating-point number');b*=N}i.units.push({unit:w.unit,prefix:w.prefix,power:b});for(var E=0;E1||Math.abs(this.units[0].power-1)>1e-15)},c.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=c._getNumberConverter(z(e));for(var s=0;s1e-12)return!1;return!0},c.prototype.equalBase=function(e){for(var t=0;t1e-12)return!1;return!0},c.prototype.equals=function(e){return this.equalBase(e)&&T(this.value,e.value)},c.prototype.multiply=function(e){for(var t=this.clone(),r=0;r1e-12&&(V.hasOwnProperty(s)?t.push({unit:V[s].unit,prefix:V[s].prefix,power:this.dimensions[o]||0}):a=!0)}r(520);t.length0?(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 i=0;i0?(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,Math.abs(this.units[i].power+1)>1e-15&&(t+="^"+-this.units[i].power)):(t+=" "+this.units[i].prefix.name+this.units[i].unit.name,t+="^"+this.units[i].power));e=e.substr(1),t=t.substr(1),r>1&&n>0&&(e="("+e+")"),n>1&&r>0&&(t="("+t+")");var a=e;return r>0&&n>0&&(a+=" / "),a+=t},c.prototype.format=function(e){this.simplifyUnitListLazy();var t=!1,r=!0;"undefined"!=typeof this.value&&null!==this.value&&this.value.isComplex&&(t=Math.abs(this.value.re)<1e-14,r=Math.abs(this.value.im)<1e-14);for(var n in this.units)this.units[n].unit&&("VA"===this.units[n].unit.name&&t?this.units[n].unit=G.VAR:"VAR"!==this.units[n].unit.name||t||(this.units[n].unit=G.VA));1!==this.units.length||this.fixPrefix||Math.abs(this.units[0].power-Math.round(this.units[0].power))<1e-14&&(this.units[0].prefix=this._bestPrefix());var i=this._denormalize(this.value),a=null!==this.value?S(i,e||{}):"",o=this.formatUnits();return this.value&&this.value.isComplex&&(a="("+a+")"),o.length>0&&a.length>0&&(a+=" "),a+=o},c.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=O(this.value),t=O(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(a.hasOwnProperty(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);(u1e-12){p=!1;break}if(p){l=!0;break}}if(!l){var m=e+"_STUFF",d={dimensions:a.dimensions.slice(0)};d.key=m,F[m]=d,V[m]={unit:f,prefix:q.NONE[""]},f.base=m}}else{var m=e+"_STUFF";if(L.indexOf(m)>=0)throw new Error('Cannot create new base unit "'+e+'": a base unit with that name already exists (and cannot be overridden)');L.push(m);for(var g in F)F.hasOwnProperty(g)&&(F[g].dimensions[L.length-1]=0);for(var d={dimensions:[]},u=0;u2&&void 0!==arguments[2]?arguments[2]:-1;if(this.measured)throw new Error("Cannot Apply Gate to a Measured Quantum Register");var n=s.generateGate(e,this.numQubits,t,r);this.amplitudes=a.multiply(this.amplitudes,n)}},{key:"measure",value:function(){if(this.measured)return this.value;var e=[];a.forEach(this.amplitudes,function(t){var r=a.pow(a.abs(t),2);e.push(r)});var t=a.zeros(e.length).toArray().map(function(e,t){return t});return this.value=Number(o.select(t,e)).toString(2),this.value.length0){for(e>=1&&(h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=h);d<=y&&v<=y;){if(r=(m+g)/(d+v),e===r){d+v<=y?(n=m+g,i=d+v):v>d?(n=g,i=v):(n=m,i=d);break}e>r?(m+=g,d+=v):(g+=m,v+=d),d>y?(n=g,i=v):(n=m,i=d)}n*=h}else(isNaN(e)||isNaN(t))&&(i=n=NaN);break;case"string":if(d=e.match(/\d+|./g),"-"===d[m]?(a=-1,m++):"+"===d[m]&&m++,d.length===m+1?c=o(d[m++],a):"."===d[m+1]||"."===d[m]?("."!==d[m]&&(u=o(d[m++],a)),m++,(m+1===d.length||"("===d[m+1]&&")"===d[m+3]||"'"===d[m+1]&&"'"===d[m+3])&&(c=o(d[m],a),p=Math.pow(10,d[m].length),m++),("("===d[m]&&")"===d[m+2]||"'"===d[m]&&"'"===d[m+2])&&(l=o(d[m+1],a),h=Math.pow(10,d[m+1].length)-1,m+=3)):"/"===d[m+1]||":"===d[m+1]?(c=o(d[m],a),p=o(d[m+2],1),m+=3):"/"===d[m+3]&&" "===d[m+1]&&(u=o(d[m],a),c=o(d[m+2],a),p=o(d[m+4],1),m+=5),d.length<=m){i=p*h,a=n=l+i*u+h*c;break}default:s()}if(0===i)throw"DIV/0";f.s=a<0?-1:1,f.n=Math.abs(n),f.d=Math.abs(i)},p=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n},h=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>c)return 0;return n},m=function(e,t,r){for(var n=1,i=p(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0},d=function(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}};u.REDUCE=1,u.prototype={s:1,n:0,d:1,abs:function(){return new u(this.n,this.d)},neg:function(){return new u(-this.s*this.n,this.d)},add:function(e,t){return l(e,t),new u(this.s*this.n*f.d+f.s*this.d*f.n,this.d*f.d)},sub:function(e,t){return l(e,t),new u(this.s*this.n*f.d-f.s*this.d*f.n,this.d*f.d)},mul:function(e,t){return l(e,t),new u(this.s*f.s*this.n*f.n,this.d*f.d)},div:function(e,t){return l(e,t),new u(this.s*f.s*this.n*f.d,this.d*f.n)},clone:function(){return new u(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new u(NaN):void 0===e?new u(this.s*this.n%this.d,1):(l(e,t),0===f.n&&0===this.d&&u(0,0),new u(this.s*f.d*this.n%(f.n*this.d),f.d*this.d))},gcd:function(e,t){return l(e,t),new u(d(f.n,this.n),f.d*this.d/d(f.d,this.d))},lcm:function(e,t){return l(e,t),0===f.n&&0===this.n?new u:new u(f.n*this.n/d(f.n,this.n),d(f.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new u(NaN):new u(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 u(NaN):new u(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 u(NaN):new u(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new u(this.s*this.d,this.n)},pow:function(e){return e<0?new u(Math.pow(this.s*this.d,-e),Math.pow(this.n,-e)):new u(Math.pow(this.s*this.n,e),Math.pow(this.d,e))},equals:function(e,t){return l(e,t),this.s*this.n*f.d===f.s*f.n*this.d},compare:function(e,t){l(e,t);var r=this.s*this.n*f.d-f.s*f.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=[];do n.push(Math.floor(t/r)),e=t%r,t=r,r=e;while(1!==t);return n},toString:function(){var e,t=this.n,r=this.d;if(isNaN(t)||isNaN(r))return"NaN";u.REDUCE||(e=d(t,r),t/=e,r/=e);for(var n=String(t).split(""),i=0,a=[~this.s?"":"-","",""],o="",s=h(t,r),c=m(t,r,s),f=-1,l=1,p=15+s+c+n.length,g=0;g0)if(f===c)a[l]+=o+"(",o="";else if(f===s+c){a[l]+=o+")";break}i>=r?(a[l]+=o+(i/r|0),o="",i%=r):l>1?o+="0":a[l]&&(a[l]+="0")}return a[0]+=a[1]||"0",a[2]?a[0]+"."+a[2]:a[0]}},r(136).amd?(n=[],i=function(){return u}.apply(t,n),!(void 0!==i&&(e.exports=i))):e.exports=u}(this)}).call(t,r(137)(e))},function(e,t,r){e.exports=r(144)},function(e,t,r){"use strict";function n(e,t,o,s,u){u.on("config",function(r,i){r.number!==i.number&&n(e,t,o,s,u)}),u.true=!0,u.false=!1,u.null=null,u.uninitialized=r(8).UNINITIALIZED,"BigNumber"===t.number?(u.Infinity=new e.BigNumber(1/0),u.NaN=new e.BigNumber(NaN),i.lazy(u,"pi",function(){return a.pi(e.BigNumber)}),i.lazy(u,"tau",function(){return a.tau(e.BigNumber)}),i.lazy(u,"e",function(){return a.e(e.BigNumber)}),i.lazy(u,"phi",function(){return a.phi(e.BigNumber)}),i.lazy(u,"E",function(){return u.e}),i.lazy(u,"LN2",function(){return new e.BigNumber(2).ln()}),i.lazy(u,"LN10",function(){return new e.BigNumber(10).ln()}),i.lazy(u,"LOG2E",function(){return new e.BigNumber(1).div(new e.BigNumber(2).ln())}),i.lazy(u,"LOG10E",function(){return new e.BigNumber(1).div(new e.BigNumber(10).ln())}),i.lazy(u,"PI",function(){return u.pi}),i.lazy(u,"SQRT1_2",function(){return new e.BigNumber("0.5").sqrt()}),i.lazy(u,"SQRT2",function(){return new e.BigNumber(2).sqrt()})):(u.Infinity=1/0,u.NaN=NaN,u.pi=Math.PI,u.tau=2*Math.PI,u.e=Math.E,u.phi=1.618033988749895,u.E=u.e,u.LN2=Math.LN2,u.LN10=Math.LN10,u.LOG2E=Math.LOG2E,u.LOG10E=Math.LOG10E,u.PI=u.pi,u.SQRT1_2=Math.SQRT1_2,u.SQRT2=Math.SQRT2),u.i=e.Complex.I,u.version=r(513)}var i=r(5),a=r(134);t.factory=n,t.lazy=!1,t.math=!0},function(e,t,r){var n=r(5).isFactory,i=(r(5).deepExtend,r(147)),a=r(135),o=r(146),s=r(145);t.create=function(e){function t(e){if(!n(e))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var i,a=r.indexOf(e);return a===-1?(i=e.math===!0?e.factory(c.type,f,t,c.typed,c):e.factory(c.type,f,t,c.typed),r.push(e),u.push(i)):i=u[a],i}if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r=[],u=[],c=a.mixin({});c.type={},c.expression={transform:Object.create(c)},c.algebra={},c.typed=i.create(c.type);var f={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1};return c.import=t(o),c.config=t(s),e&&c.config(e),c}},function(e,t,r){"use strict";function n(e,t,r,n,i){function a(e){if(e){var r=s.clone(t);o(e,"matrix",u),o(e,"number",c),s.deepExtend(t,e);var n=s.clone(t);return i.emit("config",n,r),n}return s.clone(t)}var u=["Matrix","Array"],c=["number","BigNumber","Fraction"];return a.MATRIX=u,a.NUMBER=c,a}function i(e,t){return e.indexOf(t)!==-1}function a(e,t){return e.map(function(e){return e.toLowerCase()}).indexOf(t.toLowerCase())}function o(e,t,r){if(void 0!==e[t]&&!i(r,e[t])){var n=a(r,e[t]);n!==-1?(console.warn('Warning: Wrong casing for configuration option "'+t+'", should be "'+r[n]+'" instead of "'+e[t]+'".'),e[t]=r[n]):console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+r.map(JSON.stringify).join(", ")+".")}}var s=r(5);t.name="config",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n,u){function c(e,t){var r=arguments.length;if(1!=r&&2!=r)throw new s("import",r,1,2);if(t||(t={}),a(e))h(e,t);else if(Array.isArray(e))e.forEach(function(e){c(e,t)});else if("object"==typeof e){for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];m(i)?f(n,i,t):a(e)?h(e,t):c(i,t)}}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}function f(e,t,r){if(r.wrap&&"function"==typeof t&&(t=p(t)),d(u[e])&&d(t))return t=r.override?n(e,t.signatures):n(u[e],t),u[e]=t,l(e,t),void u.emit("import",e,function(){return t});if(void 0===u[e]||r.override)return u[e]=t,l(e,t),void u.emit("import",e,function(){return t});if(!r.silent)throw new Error('Cannot import "'+e+'": already exists')}function l(e,t){t&&"function"==typeof t.transform&&(u.expression.transform[e]=t.transform)}function p(e){var t=function(){for(var t=[],r=0,n=arguments.length;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+t+"). Use function bignumber(x) to convert to BigNumber.");return new e.BigNumber(t)}},{from:"number",to:"Complex",convert:function(t){return new e.Complex(t,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(t){return new e.Complex(t.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(t){return new e.Complex(t.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(t){if(i(t)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to Fraction (value: "+t+"). Use function fraction(x) to convert to Fraction.");return new e.Fraction(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:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(t){return new e.BigNumber(+t)}},{from:"boolean",to:"Fraction",convert:function(t){return new e.Fraction(+t)}},{from:"boolean",to:"string",convert:function(e){return+e}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new e.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new e.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(t){return new e.DenseMatrix(t)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],t}},function(e,t,r){"use strict";var n=r(42),i=r(10),a=r(43);e.exports=[{name:"ArgumentsError",path:"error",factory:function(){return n}},{name:"DimensionError",path:"error",factory:function(){return i}},{name:"IndexError",path:"error",factory:function(){return a}}]},function(e,t,r){"use strict";function n(e,t,n,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}var u=n(r(85))();return s.prototype.type="Help",s.prototype.isHelp=!0,s.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var r=0;r0){for(e>=1&&(h=Math.pow(10,Math.floor(1+Math.log(e)/Math.LN10)),e/=h);d<=y&&v<=y;){if(r=(m+g)/(d+v),e===r){d+v<=y?(n=m+g,i=d+v):v>d?(n=g,i=v):(n=m,i=d);break}e>r?(m+=g,d+=v):(g+=m,v+=d),d>y?(n=g,i=v):(n=m,i=d)}n*=h}else(isNaN(e)||isNaN(t))&&(i=n=NaN);break;case"string":if(d=e.match(/\d+|./g),"-"===d[m]?(a=-1,m++):"+"===d[m]&&m++,d.length===m+1?c=o(d[m++],a):"."===d[m+1]||"."===d[m]?("."!==d[m]&&(u=o(d[m++],a)),m++,(m+1===d.length||"("===d[m+1]&&")"===d[m+3]||"'"===d[m+1]&&"'"===d[m+3])&&(c=o(d[m],a),p=Math.pow(10,d[m].length),m++),("("===d[m]&&")"===d[m+2]||"'"===d[m]&&"'"===d[m+2])&&(l=o(d[m+1],a),h=Math.pow(10,d[m+1].length)-1,m+=3)):"/"===d[m+1]||":"===d[m+1]?(c=o(d[m],a),p=o(d[m+2],1),m+=3):"/"===d[m+3]&&" "===d[m+1]&&(u=o(d[m],a),c=o(d[m+2],a),p=o(d[m+4],1),m+=5),d.length<=m){i=p*h,a=n=l+i*u+h*c;break}default:s()}if(0===i)throw"DIV/0";f.s=a<0?-1:1,f.n=Math.abs(n),f.d=Math.abs(i)},p=function(e,t,r){for(var n=1;t>0;e=e*e%r,t>>=1)1&t&&(n=n*e%r);return n},h=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>c)return 0;return n},m=function(e,t,r){for(var n=1,i=p(10,r,t),a=0;a<300;a++){if(n===i)return a;n=10*n%t,i=10*i%t}return 0},d=function(e,t){if(!e)return t;if(!t)return e;for(;;){if(e%=t,!e)return t;if(t%=e,!t)return e}};u.REDUCE=1,u.prototype={s:1,n:0,d:1,abs:function(){return new u(this.n,this.d)},neg:function(){return new u(-this.s*this.n,this.d)},add:function(e,t){return l(e,t),new u(this.s*this.n*f.d+f.s*this.d*f.n,this.d*f.d)},sub:function(e,t){return l(e,t),new u(this.s*this.n*f.d-f.s*this.d*f.n,this.d*f.d)},mul:function(e,t){return l(e,t),new u(this.s*f.s*this.n*f.n,this.d*f.d)},div:function(e,t){return l(e,t),new u(this.s*f.s*this.n*f.d,this.d*f.n)},clone:function(){return new u(this)},mod:function(e,t){return isNaN(this.n)||isNaN(this.d)?new u(NaN):void 0===e?new u(this.s*this.n%this.d,1):(l(e,t),0===f.n&&0===this.d&&u(0,0),new u(this.s*f.d*this.n%(f.n*this.d),f.d*this.d))},gcd:function(e,t){return l(e,t),new u(d(f.n,this.n),f.d*this.d/d(f.d,this.d))},lcm:function(e,t){return l(e,t),0===f.n&&0===this.n?new u:new u(f.n*this.n/d(f.n,this.n),d(f.d,this.d))},ceil:function(e){return e=Math.pow(10,e||0),isNaN(this.n)||isNaN(this.d)?new u(NaN):new u(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 u(NaN):new u(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 u(NaN):new u(Math.round(e*this.s*this.n/this.d),e)},inverse:function(){return new u(this.s*this.d,this.n)},pow:function(e){return e<0?new u(Math.pow(this.s*this.d,-e),Math.pow(this.n,-e)):new u(Math.pow(this.s*this.n,e),Math.pow(this.d,e))},equals:function(e,t){return l(e,t),this.s*this.n*f.d===f.s*f.n*this.d},compare:function(e,t){l(e,t);var r=this.s*this.n*f.d-f.s*f.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=[];do n.push(Math.floor(t/r)),e=t%r,t=r,r=e;while(1!==t);return n},toString:function(){var e,t=this.n,r=this.d;if(isNaN(t)||isNaN(r))return"NaN";u.REDUCE||(e=d(t,r),t/=e,r/=e);for(var n=String(t).split(""),i=0,a=[~this.s?"":"-","",""],o="",s=h(t,r),c=m(t,r,s),f=-1,l=1,p=15+s+c+n.length,g=0;g0)if(f===c)a[l]+=o+"(",o="";else if(f===s+c){a[l]+=o+")";break}i>=r?(a[l]+=o+(i/r|0),o="",i%=r):l>1?o+="0":a[l]&&(a[l]+="0")}return a[0]+=a[1]||"0",a[2]?a[0]+"."+a[2]:a[0]}},r(136).amd?(n=[],i=function(){return u}.apply(t,n),!(void 0!==i&&(e.exports=i))):e.exports=u}(this)}).call(t,r(137)(e))},function(e,t,r){e.exports=r(145)},function(e,t,r){"use strict";function n(e,t,o,s,u){u.on("config",function(r,i){r.number!==i.number&&n(e,t,o,s,u)}),u.true=!0,u.false=!1,u.null=null,u.uninitialized=r(8).UNINITIALIZED,"BigNumber"===t.number?(u.Infinity=new e.BigNumber(1/0),u.NaN=new e.BigNumber(NaN),i.lazy(u,"pi",function(){return a.pi(e.BigNumber)}),i.lazy(u,"tau",function(){return a.tau(e.BigNumber)}),i.lazy(u,"e",function(){return a.e(e.BigNumber)}),i.lazy(u,"phi",function(){return a.phi(e.BigNumber)}),i.lazy(u,"E",function(){return u.e}),i.lazy(u,"LN2",function(){return new e.BigNumber(2).ln()}),i.lazy(u,"LN10",function(){return new e.BigNumber(10).ln()}),i.lazy(u,"LOG2E",function(){return new e.BigNumber(1).div(new e.BigNumber(2).ln())}),i.lazy(u,"LOG10E",function(){return new e.BigNumber(1).div(new e.BigNumber(10).ln())}),i.lazy(u,"PI",function(){return u.pi}),i.lazy(u,"SQRT1_2",function(){return new e.BigNumber("0.5").sqrt()}),i.lazy(u,"SQRT2",function(){return new e.BigNumber(2).sqrt()})):(u.Infinity=1/0,u.NaN=NaN,u.pi=Math.PI,u.tau=2*Math.PI,u.e=Math.E,u.phi=1.618033988749895,u.E=u.e,u.LN2=Math.LN2,u.LN10=Math.LN10,u.LOG2E=Math.LOG2E,u.LOG10E=Math.LOG10E,u.PI=u.pi,u.SQRT1_2=Math.SQRT1_2,u.SQRT2=Math.SQRT2),u.i=e.Complex.I,u.version=r(514)}var i=r(5),a=r(134);t.factory=n,t.lazy=!1,t.math=!0},function(e,t,r){var n=r(5).isFactory,i=(r(5).deepExtend,r(148)),a=r(135),o=r(147),s=r(146);t.create=function(e){function t(e){if(!n(e))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var i,a=r.indexOf(e);return a===-1?(i=e.math===!0?e.factory(c.type,f,t,c.typed,c):e.factory(c.type,f,t,c.typed),r.push(e),u.push(i)):i=u[a],i}if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r=[],u=[],c=a.mixin({});c.type={},c.expression={transform:Object.create(c)},c.algebra={},c.typed=i.create(c.type);var f={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1};return c.import=t(o),c.config=t(s),e&&c.config(e),c}},function(e,t,r){"use strict";function n(e,t,r,n,i){function a(e){if(e){var r=s.clone(t);o(e,"matrix",u),o(e,"number",c),s.deepExtend(t,e);var n=s.clone(t);return i.emit("config",n,r),n}return s.clone(t)}var u=["Matrix","Array"],c=["number","BigNumber","Fraction"];return a.MATRIX=u,a.NUMBER=c,a}function i(e,t){return e.indexOf(t)!==-1}function a(e,t){return e.map(function(e){return e.toLowerCase()}).indexOf(t.toLowerCase())}function o(e,t,r){if(void 0!==e[t]&&!i(r,e[t])){var n=a(r,e[t]);n!==-1?(console.warn('Warning: Wrong casing for configuration option "'+t+'", should be "'+r[n]+'" instead of "'+e[t]+'".'),e[t]=r[n]):console.warn('Warning: Unknown value "'+e[t]+'" for configuration option "'+t+'". Available options: '+r.map(JSON.stringify).join(", ")+".")}}var s=r(5);t.name="config",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n,u){function c(e,t){var r=arguments.length;if(1!=r&&2!=r)throw new s("import",r,1,2);if(t||(t={}),a(e))h(e,t);else if(Array.isArray(e))e.forEach(function(e){c(e,t)});else if("object"==typeof e){for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];m(i)?f(n,i,t):a(e)?h(e,t):c(i,t)}}else if(!t.silent)throw new TypeError("Factory, Object, or Array expected")}function f(e,t,r){if(r.wrap&&"function"==typeof t&&(t=p(t)),d(u[e])&&d(t))return t=r.override?n(e,t.signatures):n(u[e],t),u[e]=t,l(e,t),void u.emit("import",e,function(){return t});if(void 0===u[e]||r.override)return u[e]=t,l(e,t),void u.emit("import",e,function(){return t});if(!r.silent)throw new Error('Cannot import "'+e+'": already exists')}function l(e,t){t&&"function"==typeof t.transform&&(u.expression.transform[e]=t.transform)}function p(e){var t=function(){for(var t=[],r=0,n=arguments.length;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+t+"). Use function bignumber(x) to convert to BigNumber.");return new e.BigNumber(t)}},{from:"number",to:"Complex",convert:function(t){return new e.Complex(t,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(t){return new e.Complex(t.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(t){return new e.Complex(t.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(t){if(i(t)>15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to Fraction (value: "+t+"). Use function fraction(x) to convert to Fraction.");return new e.Fraction(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:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(t){return new e.BigNumber(+t)}},{from:"boolean",to:"Fraction",convert:function(t){return new e.Fraction(+t)}},{from:"boolean",to:"string",convert:function(e){return+e}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new e.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new e.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(t){return new e.DenseMatrix(t)}},{from:"Matrix",to:"Array",convert:function(e){return e.valueOf()}}],t}},function(e,t,r){"use strict";var n=r(42),i=r(10),a=r(43);e.exports=[{name:"ArgumentsError",path:"error",factory:function(){return n}},{name:"DimensionError",path:"error",factory:function(){return i}},{name:"IndexError",path:"error",factory:function(){return a}}]},function(e,t,r){"use strict";function n(e,t,n,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}var u=n(r(85))();return s.prototype.type="Help",s.prototype.isHelp=!0,s.prototype.toString=function(){var e=this.doc||{},t="\n";if(e.name&&(t+="Name: "+e.name+"\n\n"),e.category&&(t+="Category: "+e.category+"\n\n"),e.description&&(t+="Description:\n "+e.description+"\n\n"),e.syntax&&(t+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){t+="Examples:\n";for(var r=0;r1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]}},function(e,t){e.exports={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","multiply"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]}},function(e,t){e.exports={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","leftShift(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"]}},function(e,t){e.exports={name:"rightLogShift",category:"Bitwise",syntax:["x >> y","leftShift(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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"eval",category:"Expression",syntax:["eval(expression)","eval([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['eval("2 + 3")','eval("sqrt(" + 4 + ")")'],seealso:[]}},function(e,t){e.exports={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"xor",category:"Logical",syntax:["x or y","or(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 or 4"],seealso:["not","and","or"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"dot",category:"Matrix",syntax:["dot(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"]}},function(e,t){e.exports={name:"eye",category:"Matrix",syntax:["eye(n)","eye(m, n)","eye([m, n])","eye"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["eye(3)","eye(3, 5)","a = [1, 2, 3; 4, 5, 6]","eye(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","eye","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"kron",category:"Matrix",syntax:["math.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"]}},function(e,t){e.exports={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], function(val) { return value * value })"],seealso:["filter","forEach"]}},function(e,t){e.exports={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])","ones"],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","eye","inv","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","eye","inv","ones","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","det","diag","eye","inv","ones","range","squeeze","subset","trace","transpose","zeros"]}},function(e,t){e.exports={name:"sort",category:"Matrix",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc" or "desc", 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)'],seealso:["map","filter","forEach"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","subset","trace","transpose","zeros"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","trace","transpose","zeros"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","subset","transpose","zeros"]}},function(e,t){e.exports={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","eye","inv","ones","range","size","squeeze","subset","trace","zeros"]}},function(e,t){e.exports={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])","zeros"],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","eye","inv","ones","range","size","squeeze","subset","trace","transpose"]}},function(e,t){e.exports={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:["permutations","factorial"]}},function(e,t){e.exports={name:"factorial",category:"Probability",syntax:["kldivergence(x, y)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","permutations","gamma"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"kldivergence",category:"Probability",syntax:["n!","factorial(n)"],description:"Calculate the Kullback-Leibler (KL) divergence between two distributions.",examples:["math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5])"],seealso:[]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","factorial"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"randInt",category:"Probability",syntax:["randInt(max)","randInt(min, max)","randInt(size)","randInt(size, max)","randInt(size, min, max)"],description:"Return a random integer number",examples:["randInt(10, 20)","randInt([2, 3], 10)"],seealso:["pickRandom","random"]}},function(e,t){e.exports={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq"]}},function(e,t){e.exports={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:["[1,3,4] == [1,3,4]","[1,3,4] == [1,3]"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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","largerEq","compare"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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])","mad(10, 20, 30)"],seealso:["mean","median","std","abs"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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(5, 2, 7)","mode([3, -1, 5, 7])"],seealso:["max","mean","min","median","prod","std","sum","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={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(var(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","min","prod","sum","var"]}},function(e,t){e.exports={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","var"]}},function(e,t){e.exports={name:"var",category:"Statistics",syntax:["var(a, b, c, ...)","var(A)","var(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["var(2, 4, 6)","var([2, 4, 6, 8])",'var([2, 4, 6, 8], "uncorrected")','var([2, 4, 6, 8], "biased")',"var([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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(0.5)"],seealso:["acsch","asech"]}},function(e,t){e.exports={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(0.5)","acsc(csc(0.5))","acsc(2)"],seealso:["csc","asin","asec"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]}},function(e,t){e.exports={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(2.3))"],seealso:["sin","acos","atan"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(2.3))"],seealso:["tan","acos","asin"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.", -examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))",'isNumeric("3")',"isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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:[]}},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(29));return a("compile",{string:function(e){return o(e).compile()},"Array | Matrix":function(e){return i(e,function(e){return o(e).compile()})}})}var i=r(1);t.name="compile",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(29));return a("compile",{string:function(e){var t={};return o(e).compile().eval(t)},"string, Object":function(e,t){return o(e).compile().eval(t)},"Array | Matrix":function(e){var t={};return i(e,function(e){return o(e).compile().eval(t)})},"Array | Matrix, Object":function(e,t){return i(e,function(e){return o(e).compile().eval(t)})}})}var i=r(1);t.name="eval",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,a){var o=n(r(84));return i("help",{any:function(t){var r,n=t;if("string"!=typeof t)for(r in a)if(a.hasOwnProperty(r)&&t===a[r]){n=r;break}var i=o[n];if(!i)throw new Error('No documentation found on "'+n+'"');return new e.Help(i)}})}t.math=!0,t.name="help",t.factory=n},function(e,t,r){e.exports=[r(328),r(329),r(330),r(332),r(85)]},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(29));return i("parse",{"string | Array | Matrix":a,"string | Array | Matrix, Object":a})}t.name="parse",t.factory=n},function(e,t,r){e.exports=[r(84),r(331),r(335),r(340),r(149),r(29),r(81)]},function(e,t){"use strict";function r(e,t,r,n){function i(){throw new Error("UpdateNode is deprecated. Use AssignmentNode instead.")}return i}t.name="UpdateNode",t.path="expression.node",t.factory=r},function(e,t,r){e.exports=[r(86),r(63),r(87),r(88),r(89),r(44),r(91),r(90),r(45),r(12),r(92),r(49),r(50),r(64),r(25),r(334)]},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(52)),s=n(r(2));return function(e,t,r){try{if(Array.isArray(e))return s(e).subset(t,r).valueOf();if(e&&"function"==typeof e.subset)return e.subset(t,r);if("string"==typeof e)return o(e,t,r);if("object"==typeof e){if(!t.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return e[t.getObjectProperty()]=r,e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw i(e)}}}var i=r(30).transform;t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(108));return a("concat",{"...any":function(e){var t=e.length-1,r=e[t];"number"==typeof r?e[t]=r-1:r&&r.isBigNumber===!0&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform;t.name="concat",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t,r){var n,i;if(e[0]&&(n=e[0].compile().eval(r)),e[1])if(e[1]&&e[1].isSymbolNode)i=e[1].compile().eval(r);else{var a=r||{},s=e[1].filter(function(e){return e&&e.isSymbolNode&&!(e.name in t)&&!(e.name in a)})[0],u=Object.create(a),c=e[1].compile();if(!s)throw new Error("No undefined variable found in filter equation");var f=s.name;i=function(e){return u[f]=e,c.eval(u)}}return o(n,i)}var o=n(r(110));n(r(25));return a.rawArgs=!0,a}t.name="filter",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){n(r(111));return a("forEach",{"Array | Matrix, function":function(e,t){var r=i(t),n=function(i,a){Array.isArray(i)?i.forEach(function(e,t){n(e,a.concat(t+1))}):1===r?t(i):2===r?t(i,a):t(i,a,e)};n(e.valueOf(),[])}})}var i=r(34).maxArgumentCount;t.name="forEach",t.path="expression.transform",t.factory=n},function(e,t,r){e.exports=[r(337),r(338),r(339),r(341),r(342),r(343),r(344),r(345),r(346),r(347)]},function(e,t){"use strict";function r(e,t,r){return function(){for(var t=[],r=0,n=arguments.length;r0?0:2;else if(i&&i.isSet===!0)i=i.map(function(e){return e-1});else if(i&&(i.isArray===!0||i.isMatrix))i=i.map(function(e){return e-1});else if("number"==typeof i)i--;else if(i&&i.isBigNumber===!0)i=i.toNumber()-1;else if("string"!=typeof i)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=i}var a=new e.Index;return e.Index.apply(a,t),a}}t.name="index",t.path="expression.transform",t.factory=r},function(e,t,r){"use strict";function n(e,t,n,a){var o=(n(r(68)),n(r(2)));return a("max",{"Array, function":function(e,t){return i(e,t,e)},"Matrix, function":function(e,t){return o(i(e.valueOf(),t,e))}})}function i(e,t,r){function n(e,a){return Array.isArray(e)?e.map(function(e,t){return n(e,a.concat(t+1))}):1===i?t(e):2===i?t(e,a):t(e,a,r)}var i=a(t);return n(e,[])}var a=r(34).maxArgumentCount;t.name="map",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(117));return o("max",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="max",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(118));return o("mean",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="mean",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(120));return o("min",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="min",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(113));return i("range",{"...any":function(e){var t=e.length-1,r=e[t];return"boolean"!=typeof r&&e.push(!0),a.apply(null,e)}})}t.name="range",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(52));return a("subset",{"...any":function(e){try{return o.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform;t.name="subset",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if("log"!=e.name&&"nthRoot"!=e.name||2!=e.args.length){for(var t=0;t1?(r=l(n,a,i),s.unshift(r),r=l(n,s,i)):r=l(n,t,i)}else r=l(n,t,i);else t=e.args.map(p),r=l(n,t,i);return r;case"ParenthesisNode":return p(e.content);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"UpdateNode":case"ConditionalNode":default:throw"Unimplemented node type in simplifyConstant: "+e.type}}var h=n(r(97)),m=h.isCommutative,d=h.isAssociative,g=h.allChildren,v=h.createMakeNodeFunction,y=o.expression.node.ConstantNode,x=o.expression.node.OperatorNode,w=a({Fraction:f,number:c,BigNumber:function(e){return c(e._toNumber())},Complex:function(e){throw"Cannot convert Complex number to Node"}}),b=a({Fraction:function(e){return e},BigNumber:function(e){return e.decimalPlaces()<=15?o.fraction(e.toNumber()):e.toNumber()},number:function(e){return i(e)<=15?o.fraction(e):e},Complex:function(e){return 0!==e.im?e:i(e.re)<=15?o.fraction(e.re):e.re}});return s}var i=r(3).digits;t.math=!0,t.name="simplifyConstant",t.path="algebra.simplify",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(2)),s=n(r(94)),u=n(r(95)),c=n(r(357)),f=n(r(65)),l=n(r(99)),p=n(r(98)),h=a("lusolve",{"Array, Array | Matrix":function(e,t){e=o(e);var r=s(e),n=d(r.L,r.U,r.p,null,t);return n.valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=s(e);return d(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=s(e);return d(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var i=u(e,r,n);return d(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return d(e.L,e.U,e.p,e.q,t)}}),m=function(e){if(e&&e.isMatrix===!0)return e;if(i(e))return o(e);throw new TypeError("Invalid Matrix LU decomposition")},d=function(e,t,r,n,i){e=m(e),t=m(t),i=f(e,i,!1),r&&(i._data=c(r,i._data));var a=p(e,i),o=l(t,a);return n&&(o._data=c(n,o._data)),o};return h}var i=Array.isArray;t.name="lusolve",t.factory=n},function(e,t,r){"use strict";function n(e,t,n){var i=n(r(66)),a=n(r(356)),o=n(r(102)),s=n(r(16)),u=n(r(11)),c=n(r(53)),f=function(e,t){if(!t||e<=0||e>3)return null;var r=t._size,n=r[0],s=r[1],u=0,c=Math.max(16,10*Math.sqrt(s));c=Math.min(s-2,c);var f=l(e,t,n,s,c);a(f,d,null);for(var g,v,y,x,w,b,N,E,M,A,O,_,T,C,S,z,k=f._index,B=f._ptr,I=B[s],P=[],R=[],U=0,q=s+1,j=2*(s+1),L=3*(s+1),F=4*(s+1),D=5*(s+1),$=6*(s+1),G=7*(s+1),H=P,Z=p(s,B,R,U,L,H,j,G,q,$,F,D),V=h(s,B,R,D,F,$,c,q,L,H,j),W=0;VY?(b=y,N=Q,E=R[U+y]-Y):(b=k[Q++],N=B[b],E=R[U+b]),w=1;w<=E;w++)g=k[N++],(M=R[q+g])<=0||(J+=M,R[q+g]=-M,k[ee++]=g,R[j+g]!=-1&&(H[R[j+g]]=H[g]),H[g]!=-1?R[j+H[g]]=R[j+g]:R[L+R[D+g]]=R[j+g]);b!=y&&(B[b]=i(y),R[$+b]=0)}for(0!==Y&&(I=ee),R[D+y]=J,B[y]=K,R[U+y]=ee-K,R[F+y]=-2,Z=m(Z,u,R,$,s),A=K;A=Z?R[$+b]-=M:0!==R[$+b]&&(R[$+b]=R[D+b]+te)}for(A=K;A0?(z+=re,k[C++]=b,S+=b):(B[b]=i(y),R[$+b]=0)}R[F+g]=C-_+1;var ne=C,ie=_+R[U+g];for(Q=T+1;Q=0))for(S=H[g],g=R[G+S],R[G+S]=-1;g!=-1&&R[j+g]!=-1;g=R[j+g],Z++){for(E=R[U+g],O=R[F+g],Q=B[g]+1;Q<=B[g]+E-1;Q++)R[$+k[Q]]=Z;var oe=g;for(v=R[j+g];v!=-1;){var se=R[U+v]===E&&R[F+v]===O;for(Q=B[v]+1;se&&Q<=B[v]+E-1;Q++)R[$+k[Q]]!=Z&&(se=0);se?(B[v]=i(g),R[q+g]+=R[q+v],R[q+v]=0,R[F+v]=-1,v=R[j+v],R[j+oe]=v):(oe=v,v=R[j+v])}}for(Q=K,A=K;A=0;v--)R[q+v]>0||(R[j+v]=R[L+B[v]],R[L+B[v]]=v);for(b=s;b>=0;b--)R[q+b]<=0||B[b]!=-1&&(R[j+b]=R[L+B[b]],R[L+B[b]]=b);for(y=0,g=0;g<=s;g++)B[g]==-1&&(y=o(g,y,R,L,j,P,$));return P.splice(P.length-1,1),P},l=function(e,t,r,n,i){var a=c(t);if(1===e&&n===r)return s(t,a);if(2==e){for(var o=a._index,f=a._ptr,l=0,p=0;pi))for(var m=f[p+1];hs)r[u+h]=0,r[a+h]=-1,p++,t[h]=i(e),r[u+e]++;else{var d=r[c+m];d!=-1&&(f[d]=h),r[l+h]=r[c+m],r[c+m]=h}}return p},m=function(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a=1&&M[s]++,2==T.jleaf&&M[T.q]--}t[s]!=-1&&(v[y+s]=t[s])}for(s=0;s=0;){e=n[d];var g=s?s[e]:e;i(p,e)||(a(p,e),n[m+d]=g<0?0:o(p[g]));var v=1;for(c=n[m+d],f=g<0?0:o(p[g+1]);c=0;r--)e[r]!=-1&&(o[u+r]=o[s+e[r]],o[s+e[r]]=r);for(r=0;r=0;u--)for(f=r[u],l=r[u+1],c=f;c=0;s--)h[s]=-1,u=m[s],u!=-1&&(0===d[x+u]++&&(d[y+u]=s),d[g+s]=d[v+u],d[v+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0||t.predictable?a(r):new e.Complex(r,0).log().div(Math.LN10)},Complex:function(t){return new e.Complex(t).log().div(Math.LN10)},BigNumber:function(r){return!r.isNegative()||t.predictable?r.log():new e.Complex(r.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\log_{10}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.log10||function(e){return Math.log(e)/Math.LN10};t.name="log10",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(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")}var o=n(r(2)),s=r(4),u=n(r(22)),c=n(r(13)),f=n(r(57)),l=n(r(14)),p=n(r(15)),h=n(r(7)),m=n(r(6)),d=i("mod",{"number, number":a,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){return e.mod(t)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,d,!1);break;default:r=u(t,e,d,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,d,!1);break;default:r=h(e,t,d)}}return r},"Array, Array":function(e,t){return d(o(e),o(t)).valueOf()},"Array, Matrix":function(e,t){return d(o(e),t)},"Matrix, Array":function(e,t){return d(e,o(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=p(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r},"Array, any":function(e,t){return m(o(e),t,d,!1).valueOf()},"any, Array":function(e,t){return m(o(t),e,d,!0).valueOf()}});return d.toTex={2:"\\left(${args[0]}"+s.operators.mod+"${args[1]}\\right)"},d}t.name="mod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){var r=e.size();if(1==r.length){if(t===Number.POSITIVE_INFINITY||"inf"===t){var n=0;return e.forEach(function(e){var t=o(e);p(t,n)&&(n=t)},!0),n}if(t===Number.NEGATIVE_INFINITY||"-inf"===t){var i;return e.forEach(function(e){var t=o(e);i&&!h(t,i)||(i=t)},!0),i||0}if("fro"===t)return a(e,2);if("number"==typeof t&&!isNaN(t)){if(!l(t,0)){var m=0;return e.forEach(function(e){m=s(u(o(e),t),m)},!0),u(m,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}if(2==r.length){if(1===t){var v=[],y=0;return e.forEach(function(e,t){var r=t[1],n=s(v[r]||0,o(e));p(n,y)&&(y=n),v[r]=n},!0),y}if(t===Number.POSITIVE_INFINITY||"inf"===t){var x=[],w=0;return e.forEach(function(e,t){var r=t[0],n=s(x[r]||0,o(e));p(n,w)&&(w=n),x[r]=n},!0),w}if("fro"===t)return c(d(f(g(e),e)));if(2===t)throw new Error("Unsupported parameter value, missing implementation of matrix singular value decomposition");throw new Error("Unsupported parameter value")}}var o=n(r(26)),s=n(r(16)),u=n(r(36)),c=n(r(51)),f=n(r(11)),l=n(r(9)),p=n(r(27)),h=n(r(39)),m=n(r(2)),d=n(r(114)),g=n(r(53)),v=i("norm",{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},"boolean | null":function(e){return Math.abs(e)},Array:function(e){return a(m(e),2)},Matrix:function(e){return a(e,2)},"number | Complex | BigNumber | boolean | null, number | BigNumber | string":function(e){return v(e)},"Array, number | BigNumber | string":function(e,t){return a(m(e),t)},"Matrix, number | BigNumber | string":function(e,t){return a(e,t)}});return v.toTex={1:"\\left\\|${args[0]}\\right\\|",2:void 0},v}t.name="norm",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=e.BigNumber.precision,i=e.BigNumber.clone({precision:n+2}),a=new e.BigNumber(0),o=new i(1),s=r.isNegative();if(s&&(r=r.neg()),r.isZero())throw new Error("Root must be non-zero");if(t.isNegative()&&!r.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(t.isZero())return s?new i(1/0):0;if(!t.isFinite())return s?a:t;var u=t.abs().pow(o.div(r));return u=t.isNeg()?u.neg():u,new e.BigNumber((s?o.div(u):u).toPrecision(n))}var u=n(r(2)),c=n(r(28)),f=n(r(22)),l=n(r(58)),p=n(r(14)),h=n(r(7)),m=n(r(6)),d=o("nthRoot",{number:function(e){return i(e,2)},"number, number":i,BigNumber:function(t){return s(t,new e.BigNumber(2))},Complex:function(e){return a(e,2)},"Complex, number":a,"BigNumber, BigNumber":s,"Array | Matrix":function(e){return d(e,2)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=l(e,t,d);break;default:r=f(t,e,d,!0)}break;default:switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=c(e,t,d,!1);break;default:r=h(e,t,d)}}return r},"Array, Array":function(e,t){return d(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return d(u(e),t)},"Matrix, Array":function(e,t){return d(e,u(t))},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=p(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"number | BigNumber, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=p(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r},"Array, number | BigNumber":function(e,t){return d(u(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return d(e,u(t)).valueOf()}});return d.toTex={2:"\\sqrt[${args[1]}]{${args[0]}}"},d}function i(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 a(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");for(var r=e.arg(),n=e.abs(),i=[],a=Math.pow(n,1/t),o=0;o15)throw new Error("Number of decimals in function round must be in te range of 0-15");return i(e,t)},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(t,r){if(!r.isInteger())throw new TypeError(u);return new e.BigNumber(t).toDecimalPlaces(r.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Array | Matrix":function(e){return s(e,d,!0)},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=p(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"number | Complex | BigNumber, Matrix":function(e,t){if(!f(e,0)){var r;switch(t.storage()){case"sparse":r=h(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r}return l(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return m(c(e),t,d,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return m(c(t),e,d,!0).valueOf()}});return d.toTex={1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},d}function i(e,t){return parseFloat(o(e,t))}var a=r(3).isInteger,o=r(3).toFixed,s=r(1),u="Number of decimals in function round must be an integer";t.name="round",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sign",{number:i.sign,Complex:function(e){return e.sign()},BigNumber:function(t){return new e.BigNumber(t.cmp(0))},Fraction:function(t){return new e.Fraction(t.s,1)},"Array | Matrix":function(e){return a(e,o,!0)},Unit:function(e){return o(e.value)}});return o.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},o}var i=r(3),a=r(1);t.name="sign",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("square",{number:function(e){return e*e},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 i(e,a,!0)},Unit:function(e){return e.pow(2)}});return a.toTex={1:"\\left(${args[0]}\\right)^2"},a}var i=r(1);t.name="square",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("unaryPlus",{number:function(e){return e},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 i(e,s,!0)},"boolean | string | null":function(r){return"BigNumber"==t.number?new e.BigNumber(+r):+r}});return s.toTex={1:o.operators.unaryPlus+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="unaryPlus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(e,r){var n,a,o,s=0,c=1,f=1,l=0;if(!i(e)||!i(r))throw new Error("Parameters in function xgcd must be integer numbers");for(;r;)a=Math.floor(e/r),o=e%r,n=s,s=c-a*s,c=n,n=f,f=l-a*f,l=n,e=r,r=o;var p;return p=e<0?[-e,-c,-l]:[e,e?c:0,l],"Array"===t.matrix?p:u(p)}function s(r,n){var i,a,o,s=new e.BigNumber(0),c=new e.BigNumber(1),f=s,l=c,p=c,h=s;if(!r.isInt()||!n.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!n.isZero();)a=r.div(n).floor(),o=r.mod(n),i=f,f=l.minus(a.times(f)),l=i,i=p,p=h.minus(a.times(p)),h=i,r=n,n=o;var m;return m=r.lt(s)?[r.neg(),l.neg(),h.neg()]:[r,r.isZero()?0:l,h],"Array"===t.matrix?m:u(m)}var u=n(r(2)),c=a("xgcd",{"number, number":o,"BigNumber, BigNumber":s});return c.toTex=void 0,c}var i=r(3).isInteger;t.name="xgcd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(22)),f=n(r(58)),l=n(r(14)),p=n(r(7)),h=n(r(6)),m=o("bitAnd",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitAnd");return e&t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitAnd+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(505);t.name="bitAnd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){var u=r(4),c=s("bitNot",{number:function(e){if(!o(e))throw new Error("Integer expected in function bitNot");return~e},BigNumber:a,"Array | Matrix":function(e){return i(e,c)}});return c.toTex={1:u.operators.bitNot+"\\left(${args[0]}\\right)"},c}var i=r(1),a=r(77),o=r(3).isInteger;t.name="bitNot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(28)),f=n(r(74)),l=n(r(31)),p=n(r(7)),h=n(r(6)),m=o("bitOr",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitOr");return e|t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitOr+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(506);t.name="bitOr",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(13)),f=n(r(23)),l=n(r(15)),p=n(r(7)),h=n(r(6)),m=o("bitXor",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitXor");return e^t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitXor+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(507);t.name="bitXor",t.factory=n},function(e,t,r){e.exports=[r(386),r(387),r(388),r(389),r(391),r(392),r(393)]},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(9)),f=n(r(38)),l=n(r(28)),p=n(r(22)),h=n(r(75)),m=n(r(31)),d=n(r(14)),g=n(r(7)),v=n(r(6)),y=o("leftShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function leftShift");return e<>t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=h(e,t,y,!1);break;default:r=p(t,e,y,!0)}break;default:switch(t.storage()){case"sparse":r=l(e,t,y,!1);break;default:r=g(e,t,y)}}return r},"Array, Array":function(e,t){return y(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return y(u(e),t)},"Matrix, Array":function(e,t){return y(e,u(t))},"Matrix, number | BigNumber":function(e,t){if(!c(t,0)){var r;switch(e.storage()){case"sparse":r=d(e,t,y,!1);break;default:r=v(e,t,y,!1)}return r}return e.clone()},"number | BigNumber, Matrix":function(e,t){if(!c(e,0)){var r;switch(t.storage()){case"sparse":r=m(t,e,y,!0);break;default:r=v(t,e,y,!0)}return r}return f(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return y(u(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return y(e,u(t)).valueOf()}});return y.toTex={2:"\\left(${args[0]}"+s.operators.rightArithShift+"${args[1]}\\right)"},y}var i=r(3).isInteger,a=r(510);t.name="rightArithShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=n(r(2)),u=n(r(9)),c=n(r(38)),f=n(r(28)),l=n(r(22)),p=n(r(75)),h=n(r(31)),m=n(r(14)),d=n(r(7)),g=n(r(6)),v=a("rightLogShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function rightLogShift");return e>>>t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=p(e,t,v,!1);break;default:r=l(t,e,v,!0)}break;default:switch(t.storage()){case"sparse":r=f(e,t,v,!1);break;default:r=d(e,t,v)}}return r},"Array, Array":function(e,t){return v(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return v(s(e),t)},"Matrix, Array":function(e,t){return v(e,s(t))},"Matrix, number | BigNumber":function(e,t){if(!u(t,0)){var r;switch(e.storage()){case"sparse":r=m(e,t,v,!1);break;default:r=g(e,t,v,!1)}return r}return e.clone()},"number | BigNumber, Matrix":function(e,t){if(!u(e,0)){var r;switch(t.storage()){case"sparse":r=h(t,e,v,!0);break;default:r=g(t,e,v,!0)}return r}return c(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return v(s(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return v(e,s(t)).valueOf()}});return v.toTex={2:"\\left(${args[0]}"+o.operators.rightLogShift+"${args[1]}\\right)"},v}var i=r(3).isInteger;t.name="rightLogShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(106)),s=n(r(48)),u=n(r(40)),c=i("bellNumbers",{"number | BigNumber":function(e){if(!u(e)||s(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,r=0;r<=e;r++)t=a(t,o(e,r));return t}});return c.toTex={1:"\\mathrm{B}_{${args[0]}}"},c}t.name="bellNumbers",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(35)),s=n(r(11)),u=n(r(54)),c=n(r(48)),f=n(r(40)),l=i("catalan",{"number | BigNumber":function(e){if(!f(e)||c(e))throw new TypeError("Non-negative integer value expected in function catalan");return o(u(s(e,2),e),a(e,1))}});return l.toTex={1:"\\mathrm{C}_{${args[0]}}"},l}t.name="catalan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(54)),o=n(r(18)),s=n(r(56)),u=n(r(40)),c=n(r(27)),f=i("composition",{"number | BigNumber, number | BigNumber":function(e,t){if(!(u(e)&&s(e)&&u(t)&&s(t)))throw new TypeError("Positive integer value expected in function composition");if(c(t,e))throw new TypeError("k must be less than or equal to n in function composition");return a(o(e,-1),o(t,-1))}});return f.toTex=void 0,f}t.name="composition",t.factory=n},function(e,t,r){e.exports=[r(394),r(396),r(106),r(395)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(t){return e.BigNumber.atan2(0,t)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\arg\\left(${args[0]}\\right)"},a}var i=r(1);t.name="arg",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("conj",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\left(${args[0]}\\right)^*"},a}var i=r(1);t.name="conj",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("im",{number:function(e){return 0},BigNumber:function(t){return new e.BigNumber(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},a}var i=r(1);t.name="im",t.factory=n},function(e,t,r){e.exports=[r(398),r(399),r(400),r(402)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("re",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},a}var i=r(1);t.name="re",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){var m=(n(r(2)),s("distance",{"Array, Array, Array":function(e,t,r){if(2==e.length&&2==t.length&&2==r.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers expected for second argument");if(!i(r))throw new TypeError("Array with 2 numbers expected for third argument");var n=(r[1]-r[0])/(t[1]-t[0]),a=n*n*t[0],o=-1*(n*t[0]),s=e[1];return c(e[0],e[1],a,o,s)}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(!i(e))throw new TypeError("Values of pointX and pointY should be numbers");if(!i(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers");if(!i(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("lineOnePtX")&&t.hasOwnProperty("lineOnePtY")&&r.hasOwnProperty("lineTwoPtX")&&r.hasOwnProperty("lineTwoPtY")){var n=(r.lineTwoPtY-r.lineTwoPtX)/(t.lineOnePtY-t.lineOnePtX),a=n*n*t.lineOnePtX,o=-1*(n*t.lineOnePtX),s=e.pointX;return c(e.pointX,e.pointY,a,o,s)}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(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return c(e[0],e[1],t[0],t[1],t[2])}if(3==e.length&&6==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!o(t))throw new TypeError("Array with 6 numbers expected for second argument");return f(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(2==e.length&&2==t.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers expected for second argument");return l(e[0],e[1],t[0],t[1])}if(3==e.length&&3==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return p(e[0],e[1],e[2],t[0],t[1],t[2])}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2==Object.keys(e).length&&3==Object.keys(t).length){if(!i(e))throw new TypeError("Values of pointX and pointY should be numbers");if(!a(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("xCoeffLine")&&t.hasOwnProperty("yCoeffLine")&&t.hasOwnProperty("yCoeffLine"))return c(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(!a(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers");if(!o(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("x0")&&t.hasOwnProperty("y0")&&t.hasOwnProperty("z0")&&t.hasOwnProperty("a")&&t.hasOwnProperty("b")&&t.hasOwnProperty("c"))return f(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(!i(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers");if(!i(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY"))return l(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(!a(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers");if(!a(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&e.hasOwnProperty("pointOneZ")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY")&&t.hasOwnProperty("pointTwoZ"))return p(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(!u(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return h(e)}}));return m}function i(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]}function a(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]}function o(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]&&"number"==typeof e[3]&&"number"==typeof e[4]&&"number"==typeof e[5]}function s(e){for(var t=Object.keys(e),r=[],n=0;n1?[o]:o}var s=n(r(2)),u=n(r(19)),c=n(r(11)),f=a("cross",{"Matrix, Matrix":function(e,t){return s(o(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return s(o(e.toArray(),t))},"Array, Matrix":function(e,t){return s(o(e,t.toArray()))},"Array, Array":o});return f.toTex={2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},f}var i=r(8);t.name="cross",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(e,t,r,n){if(!a(t))throw new TypeError("Second parameter in function diag must be an integer");var i=t>0?t:0,o=t<0?-t:0;switch(r.length){case 1:return u(e,t,n,r[0],o,i);case 2:return c(e,t,n,r,o,i)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function u(t,r,n,i,a,o){var s=[i+a,i+o],u=e.Matrix.storage(n||"dense"),c=u.diagonal(s,t,r);return null!==n?c:c.valueOf()}function c(e,t,r,n,i,a){if(e&&e.isMatrix===!0){var o=e.diagonal(t);return null!==r?r!==o.storage()?f(o,r):o:o.valueOf()}for(var s=Math.min(n[0]-i,n[1]-a),u=[],c=0;c2||i(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=[],n=[];return e.map(function(e){return t.map(function(t){return e.map(function(e){return t.map(function(t){return n.push(u(e,t))})},r.push(n=[]))})},r=[])&&r}var s=n(r(2)),u=n(r(21)),c=a("kron",{"Matrix, Matrix":function(e,t){return s(o(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return s(o(e.toArray(),t))},"Array, Matrix":function(e,t){return s(o(e,t.toArray()))},"Array, Array":o});return c}var i=r(8).size;t.name="kron",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=u(t),i=n?new e.BigNumber(1):1;if(c(t),r){var o=f(r);return t.length>0?o.resize(t,i):o}var s=[];return t.length>0?a(s,t,i):s}function u(e){var t=!1;return e.forEach(function(e,r,n){e&&e.isBigNumber===!0&&(t=!0,n[r]=e.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||e<0)throw new Error("Parameters in function ones must be positive integers")})}var f=n(r(2)),l=o("ones",{"":function(){return"Array"===t.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var r=e[e.length-1];if("string"==typeof r){var n=e.pop();return s(e,n)}return"Array"===t.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var t=e.storage();return s(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return s(e.valueOf(),t)}});return l.toTex=void 0,l}var i=r(3).isInteger,a=r(8).resize;t.name="ones",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){function l(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 i(t.length,1);var n=t[0];if("number"!=typeof n||!o(n))throw new TypeError("Invalid size, must contain positive integers (size: "+s(t)+")");if(e.length>n)return e.substring(0,n);if(e.length1)throw new Error("first object must be one dimensional");if(n>1)throw new Error("second object must be one dimensional");if(r!==n)throw new Error("Length of two vectors must be equal");var i=u(e);if(0===i)throw new Error("Sum of elements in first object must be non zero");var a=u(t);if(0===a)throw new Error("Sum of elements in second object must be non zero");var o=s(e,u(e)),h=s(t,u(t)),m=u(c(o,l(f(o,h))));return p(m)?m:Number.NaN}var o=n(r(2)),s=n(r(35)),u=n(r(121)),c=n(r(11)),f=n(r(103)),l=n(r(105)),p=n(r(72)),h=i("kldivergence",{"Array, Array":function(e,t){return a(o(e),o(t))},"Matrix, Array":function(e,t){return a(e,o(t))},"Array, Matrix":function(e,t){return a(o(e),t)},"Matrix, Matrix":function(e,t){return a(e,t)}});return h}t.name="kldivergence",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(16)),s=n(r(11)),u=n(r(35)),c=n(r(55)),f=n(r(40)),l=n(r(56));return a("multinomial",{"Array | Matrix":function(e){var t=0,r=1;return i(e,function(e){if(!f(e)||!l(e))throw new TypeError("Positive integer value expected in function multinomial");t=o(t,e),r=s(r,c(e))}),u(c(t),r)}})}var i=r(33);t.name="multinomial",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(55)),u=o("permutations",{"number | BigNumber":s,"number, number":function(e,t){var r,n;if(!a(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!a(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");for(r=1,n=e-t+1;n<=e;n++)r*=n;return r},"BigNumber, BigNumber":function(t,r){var n,a;if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(t))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=new e.BigNumber(1),a=t.minus(r).plus(1);a.lte(t);a=a.plus(1))n=n.times(a);return n}});return u.toTex=void 0,u}function i(e){return e.isInteger()&&e.gte(0)}var a=r(3).isInteger;t.name="permutations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(70)),o=a("uniform").pickRandom;return o.toTex=void 0,o}t.name="pickRandom",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(70)),o=a("uniform").random;return o.toTex=void 0,o}t.name="random",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(70)),o=a("uniform").randomInt;return o.toTex=void 0,o}t.name="randomInt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var r=e.length;if(r!==t.length)return!1;for(var n=0;n=f?a(e):t<=o?a(e)*l(t):t<=4?a(e)*(1-p(t)):a(e)*(1-h(t))},BigNumber:function(t){return new e.BigNumber(m(t.toNumber()))},"Array | Matrix":function(e){return i(e,m)}});return m.toTex={1:"erf\\left(${args[0]}\\right)"},m}var i=r(1),a=r(3).sign,o=.46875,s=.5641895835477563,u=[[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]],c=[[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]],f=Math.pow(2,53);t.name="erf",t.factory=n},function(e,t,r){e.exports=[r(433)]},function(e,t,r){e.exports=[r(436),r(117),r(118),r(119),r(120),r(437),r(438),r(439),r(440),r(121),r(122)]},function(e,t,r){"use strict";function n(e,t,n,a){function o(e){if(e=i(e.valueOf()),0===e.length)throw new Error("Cannot calculate median absolute deviation of an empty array");var t=c(e);return c(u(e,function(e){return s(f(e,t))}))}var s=n(r(26)),u=n(r(68)),c=n(r(119)),f=n(r(19)),l=a("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});return l.toTex=void 0,l}var i=r(8).flatten;t.name="mad",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function a(e){e=i(e.valueOf());var t=e.length;if(0==t)throw new Error("Cannot calculate mode of an empty array");var r={},n=[],a=0;for(var o in e)e[o]in r||(r[e[o]]=0),r[e[o]]++,r[e[o]]==a?n.push(e[o]):r[e[o]]>a&&(a=r[e[o]],n=[e[o]]);return n}var o=n("mode",{"Array | Matrix":a,"...":function(e){return a(e)}});return o}var i=r(8).flatten;t.name="mode",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(e){var t=void 0;if(i(e,function(e){t=void 0===t?e:s(t,e)}),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}var s=n(r(21)),u=a("prod",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return o(e)}});return u.toTex=void 0,u}var i=r(33);t.name="prod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(t,r,n){var o,u,c;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(s(t)){if(n=n||!1,"boolean"==typeof n){if(u=t.valueOf(),a(r)){if(r<0)throw new Error("N/prob must be non-negative");if(r<=1)return f(u,r,n);if(r>1){if(!i(r))throw new Error("N must be a positive integer");var l=r+1;o=new Array(r);for(var p=0;p4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var l=new e.BigNumber(h+1);o=new Array(h);for(var p=0;p1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!m||!m.isBigNumber)throw new TypeError("Unexpected type of argument in function quantileSeq");if(c=new m.constructor(1),m.isNegative()||m.gt(c))throw new Error("Probability must be between 0 and 1, inclusive")}o[p]=f(u,m,n)}return o}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 f(e,t,r){var n=o(e),i=n.length;if(0===i)throw new Error("Cannot calculate quantile of an empty sequence");if(a(t)){var s=t*(i-1),u=s%1;if(0===u){var c=r?n[s]:h(n,s);return d(c),c}var f,g,v=Math.floor(s);if(r)f=n[v],g=n[v+1];else{g=h(n,v+1),f=n[v];for(var y=0;y0&&(f=n[y])}return d(f),d(g),l(p(f,1-u),p(g,u))}var s=t.times(i-1);if(s.isInteger()){s=s.toNumber();var c=r?n[s]:h(n,s);return d(c),c}var f,g,v=s.floor(),u=s.minus(v),x=v.toNumber();if(r)f=n[x],g=n[x+1];else{g=h(n,x+1),f=n[x];for(var y=0;y0&&(f=n[y])}d(f),d(g);var w=new u.constructor(1);return l(p(f,w.minus(u)),p(g,u))}var l=n(r(16)),p=n(r(11)),h=n(r(69)),m=n(r(47)),d=u({"number | BigNumber | Unit":function(e){return e}});return c}var i=r(3).isInteger,a=r(3).isNumber,o=r(8).flatten,s=r(41);t.name="quantileSeq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(0==e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(s.apply(null,arguments))}var o=n(r(51)),s=n(r(122)),u=i("std",{"Array | Matrix":a,"Array | Matrix, string":a,"...":function(e){return a(e)}});return u.toTex=void 0,u}t.name="std",t.factory=n},function(e,t,r){e.exports=[r(123),r(442)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("print",{"string, Object":i,"string, Object, number | Object":i});return a.toTex=void 0,a}function i(e,t,r){return e.replace(/\$([\w\.]+)/g,function(e,n){for(var i=n.split("."),s=t[i.shift()];i.length&&void 0!==s;){var u=i.shift();s=u?s[u]:s+"."}return void 0!==s?a(s)?s:o(s,r):e})}var a=r(20).isString,o=r(20).format;t.name="print",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acos",{number:function(r){return r>=-1&&r<=1||t.predictable?Math.acos(r):new e.Complex(r,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cos^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acos",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acot",{number:function(e){return Math.atan(1/e)},Complex:function(e){return e.acot()},BigNumber:function(t){return new e.BigNumber(1).div(t).atan()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cot^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acot",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acoth",{number:function(r){return r>=1||r<=-1||t.predictable?isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0:new e.Complex(r,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(t){return new e.BigNumber(1).div(t).atanh()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\coth^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acoth",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acsc",{number:function(r){return r<=-1||r>=1||t.predictable?Math.asin(1/r):new e.Complex(r,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(t){return new e.BigNumber(1).div(t).asin()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\csc^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acsc",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acsch",{number:function(e){return e=1/e,Math.log(e+Math.sqrt(e*e+1))},Complex:function(e){return e.acsch()},BigNumber:function(t){return new e.BigNumber(1).div(t).asinh()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={ -1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acsch",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asec",{number:function(r){return r<=-1||r>=1||t.predictable?Math.acos(1/r):new e.Complex(r,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(t){return new e.BigNumber(1).div(t).acos()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\sec^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asec",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=(a.find(n(r(124)),["Complex"]),a("asech",{number:function(r){if(r<=1&&r>=-1||t.predictable){r=1/r;var n=Math.sqrt(r*r-1);return r>0||t.predictable?Math.log(n+r):new e.Complex(Math.log(n-r),Math.PI)}return new e.Complex(r,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(t){return new e.BigNumber(1).div(t).acosh()},"Array | Matrix":function(e){return i(e,o)}}));return o.toTex={1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},o}var i=r(1);t.name="asech",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asin",{number:function(r){return r>=-1&&r<=1||t.predictable?Math.asin(r):new e.Complex(r,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sin^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asin",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asinh",{number:Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sinh^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("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 i(e,a,!0)}});return a.toTex={1:"\\tan^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="atan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(22)),s=n(r(13)),u=n(r(131)),c=n(r(14)),f=n(r(15)),l=n(r(7)),p=n(r(6)),h=i("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(t,r){return e.BigNumber.atan2(t,r)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=u(e,t,h,!1);break;default:r=o(t,e,h,!0)}break;default:switch(t.storage()){case"sparse":r=s(e,t,h,!1);break;default:r=l(e,t,h)}}return r},"Array, Array":function(e,t){return h(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return h(a(e),t)},"Matrix, Array":function(e,t){return h(e,a(t))},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=c(e,t,h,!1);break;default:r=p(e,t,h,!1)}return r},"number | BigNumber, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,h,!0);break;default:r=p(t,e,h,!0)}return r},"Array, number | BigNumber":function(e,t){return p(a(e),t,h,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(a(t),e,h,!0).valueOf()}});return h.toTex={2:"\\mathrm{atan2}\\left(${args}\\right)"},h}t.name="atan2",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("atanh",{number:function(r){return r<=1&&r>=-1||t.predictable?a(r):new e.Complex(r,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\tanh^{-1}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2};t.name="atanh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cos\\left(${args[0]}\\right)"},a}var i=r(1);t.name="cos",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("cosh",{number:a,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\cosh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2};t.name="cosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("cot",{number:function(e){return 1/Math.tan(e)},Complex:function(e){return e.cot()},BigNumber:function(t){return new e.BigNumber(1).div(t.tan())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cot\\left(${args[0]}\\right)"},a}var i=r(1);t.name="cot",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("coth",{number:i,Complex:function(e){return e.coth()},BigNumber:function(t){return new e.BigNumber(1).div(t.tanh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\coth\\left(${args[0]}\\right)"},o}function i(e){var t=Math.exp(2*e);return(t+1)/(t-1)}var a=r(1);t.name="coth",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("csc",{number:function(e){return 1/Math.sin(e)},Complex:function(e){return e.csc()},BigNumber:function(t){return new e.BigNumber(1).div(t.sin())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\csc\\left(${args[0]}\\right)"},a}var i=r(1);t.name="csc",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("csch",{number:i,Complex:function(e){return e.csch()},BigNumber:function(t){return new e.BigNumber(1).div(t.sinh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\mathrm{csch}\\left(${args[0]}\\right)"},o}function i(e){return 0==e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*o(e)}var a=r(1),o=r(3).sign;t.name="csch",t.factory=n},function(e,t,r){e.exports=[r(443),r(124),r(444),r(445),r(446),r(447),r(448),r(449),r(450),r(451),r(452),r(453),r(454),r(455),r(456),r(457),r(458),r(459),r(460),r(462),r(463),r(464),r(465),r(466),r(467)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("sec",{number:function(e){return 1/Math.cos(e)},Complex:function(e){return e.sec()},BigNumber:function(t){return new e.BigNumber(1).div(t.cos())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\sec\\left(${args[0]}\\right)"},a}var i=r(1);t.name="sec",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sech",{number:i,Complex:function(e){return e.sech()},BigNumber:function(t){return new e.BigNumber(1).div(t.cosh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\mathrm{sech}\\left(${args[0]}\\right)"},o}function i(e){return 2/(Math.exp(e)+Math.exp(-e))}var a=r(1);t.name="sech",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sin\\left(${args[0]}\\right)"},a}var i=r(1);t.name="sin",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sinh",{number:a,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\sinh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2};t.name="sinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\tan\\left(${args[0]}\\right)"},a}var i=r(1);t.name="tan",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("tanh",{number:a,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\tanh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};t.name="tanh",t.factory=n},function(e,t,r){e.exports=[r(469)]},function(e,t,r){"use strict";function n(e,t,n,i){var a=r(4),o=n(r(2)),s=n(r(7)),u=n(r(6)),c=i("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return s(e,t,c)},"Array, Array":function(e,t){return c(o(e),o(t)).valueOf()},"Array, Matrix":function(e,t){return c(o(e),t)},"Matrix, Array":function(e,t){return c(e,o(t))},"Matrix, any":function(e,t){return u(e,t,c,!1)},"any, Matrix":function(e,t){return u(t,e,c,!0)},"Array, any":function(e,t){return u(o(e),t,c,!1).valueOf()},"any, Array":function(e,t){return u(o(t),e,c,!0).valueOf()}});return c.toTex={2:"\\left(${args[0]}"+a.operators.to+"${args[1]}\\right)"},c}t.name="to",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("clone",{any:i.clone});return a.toTex=void 0,a}var i=r(5);t.name="clone",t.factory=n},function(e,t,r){e.exports=[r(470),r(40),r(48),r(72),r(56),r(473),r(125),r(472),r(126)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNaN",{number:function(e){return Number.isNaN(e)},BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return Number.isNaN(e.re)&&Number.isNaN(e.im)},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return i(e,Number.isNaN)}});return a}var i=r(1);r(3);t.name="isNaN",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isPrime",{number:function(e){if(e<2)return!1;if(2==e)return!0;if(e%2==0)return!1;for(var t=3;t*t<=e;t+=2)if(e%t==0)return!1;return!0},BigNumber:function(t){if(t.lt(2))return!1;if(t.equals(2))return!0;if(t.mod(2).isZero())return!1;for(var r=e.BigNumber(3);r.times(r).lte(t);r=r.plus(1))if(t.mod(r).isZero())return!1;return!0},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);t.name="isPrime",t.factory=n},function(e,t,r){e.exports=[r(488),r(143),r(333),r(406),r(475),r(148)]},function(e,t,r){e.exports=[r(476)]},function(e,t){"use strict";function r(e,t,r,n){return function(t,r){var n=e[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}}t.name="reviver",t.path="json",t.factory=r},function(e,t,r){function n(e,t,r,n,a){var o=i.clone({precision:t.precision});return o.prototype.type="BigNumber",o.prototype.isBigNumber=!0,o.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},o.fromJSON=function(e){return new o(e.value)},a.on("config",function(e,t){e.precision!==t.precision&&o.config({precision:e.precision})}),o}var i=r(140);t.name="BigNumber",t.path="type",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("bignumber",{"":function(){return new e.BigNumber(0)},number:function(t){return new e.BigNumber(t+"")},string:function(t){return new e.BigNumber(t)},BigNumber:function(e){return e},Fraction:function(t){return new e.BigNumber(t.n).div(t.d)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={0:"0",1:"\\left(${args[0]}\\right)"},a}var i=r(1);t.name="bignumber",t.factory=n},function(e,t,r){e.exports=[r(477),r(478)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("bool",{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},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 i(e,a)}});return a}var i=r(1);t.name="boolean",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");e&&e.isChain?this.value=e.value:this.value=e}function u(e,t){"function"==typeof t&&(s.prototype[e]=f(t))}function c(e,t){a(s.prototype,e,function(){var e=t();if("function"==typeof e)return f(e)})}function f(e){return function(){for(var t=[this.value],r=0;r0;){var i=n.right;n.left.right=n.right,n.right.left=n.left,n.left=t,n.right=t.right,t.right=n,n.right.left=n,n.parent=null,n=i,r--}return e.left.right=e.right,e.right.left=e.left,e==e.right?t=null:(t=e.right,t=h(t,this._size)),this._size--,this._minimum=t,e},a.prototype.remove=function(e){this._minimum=c(this._minimum,e,-1),this.extractMinimum()};var c=function(e,t,r){t.key=r;var n=t.parent;return n&&o(t.key,n.key)&&(f(e,t,n),l(e,n)),o(t.key,e.key)&&(e=t),e},f=function(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},l=function(e,t){var r=t.parent;r&&(t.mark?(f(e,t,r),l(r)):t.mark=!0)},p=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1},h=function(e,t){var r=Math.floor(Math.log(t)*u)+1,n=new Array(r),i=0,a=e;if(a)for(i++,a=a.right;a!==e;)i++,a=a.right;for(var c;i>0;){for(var f=a.degree,l=a.right;;){if(c=n[f],!c)break;if(s(a.key,c.key)){var h=c;c=a,a=h}p(c,a),n[f]=null,f++}n[f]=a,a=l,i--}e=null;for(var m=0;m=e&&(o(s.value,0)||r(s.key,s.value,this)),s=n.extractMinimum(),s&&a.push(s);for(var u=0;u0){var s=0;do{e._ptr.push(e._index.length);for(var u=0;u");for(var p=t.min()[0],h=t.min()[1],m=i[0],d=i[1],g=0;go-1||i>s-1)&&(O(this,Math.max(n+1,o),Math.max(i+1,s),r),o=this._size[0],s=this._size[1]),m(n,o),m(i,s);var l=E(n,this._ptr[i],this._ptr[i+1],this._index);return lp){for(u=p;ul){if(f){var m=0;for(u=0;ut-1&&(e._values.splice(c,1),e._index.splice(c,1),v++)}e._ptr[u]=e._values.length}return e._size[0]=t,e._size[1]=r,e};g.prototype.clone=function(){var e=new g({values:this._values?s.clone(this._values):void 0,index:s.clone(this._index),ptr:s.clone(this._ptr),size:s.clone(this._size),datatype:this._datatype});return e},g.prototype.size=function(){return this._size.slice(0)},g.prototype.map=function(e,t){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var r=this,n=this._size[0],i=this._size[1],a=function(t,n,i){return e(t,[n,i],r)};return _(this,0,n-1,0,i-1,a,t)};var _=function(e,t,r,n,i,a,o){var s=[],u=[],c=[],f=y,l=0;h(e._datatype)&&(f=d.find(y,[e._datatype,e._datatype])||y,l=d.convert(0,e._datatype));for(var p=function(e,t,r){e=a(e,t,r),f(e,l)||(s.push(e),u.push(t))},m=n;m<=i;m++){c.push(s.length);for(var v=e._ptr[m],x=e._ptr[m+1],w=t,b=v;b=t&&N<=r){if(!o)for(var E=w;E "+(this._values?u.format(this._values[c],e):"X")}return i},g.prototype.toString=function(){return u.format(this.toArray())},g.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index, -ptr:this._ptr,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(e){if(e){if(e.isBigNumber===!0&&(e=e.toNumber()),!l(e)||!p(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],i=this._size[1],a=Math.min(n-r,i-t),o=[],s=[],u=[];u[0]=0;for(var c=t;c0?r:0,c=r<0?-r:0,m=e[0],v=e[1],x=Math.min(m-c,v-u);if(f(t)){if(t.length!==x)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(t&&t.isMatrix===!0){var w=t.size();if(1!==w.length||w[0]!==x)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};for(var b=[],N=[],E=[],M=0;M=0&&A=u||i[f]!==t)){var p=n?n[c]:void 0;i.splice(f,0,t),n&&n.splice(f,0,p),i.splice(f<=c?c+1:c,1),n&&n.splice(f<=c?c+1:c,1)}else if(f=u||i[c]!==e)){var h=n?n[f]:void 0;i.splice(c,0,e),n&&n.splice(c,0,h),i.splice(c<=f?f+1:f,1),n&&n.splice(c<=f?f+1:f,1)}}},e.Matrix._storage.sparse=g,g}var i=r(24),a=r(10),o=i.array,s=i.object,u=i.string,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,h=u.isString,m=o.validateIndex;t.name="SparseMatrix",t.path="type",t.factory=n,t.lazy=!1},function(e,t){"use strict";function r(e,t,r,n){return n("index",{"...number | string | BigNumber | Range | Array | Matrix":function(t){var r=t.map(function(e){return e&&e.isBigNumber===!0?e.toNumber():e&&(Array.isArray(e)||e.isMatrix===!0)?e.map(function(e){return e&&e.isBigNumber===!0?e.toNumber():e}):e}),n=new e.Index;return e.Index.apply(n,r),n}})}t.name="index",t.factory=r},function(e,t){"use strict";function r(e,t,r,n){var i=e.SparseMatrix,a=n("sparse",{"":function(){return new i([])},string:function(e){return new i([],e)},"Array | Matrix":function(e){return new i(e)},"Array | Matrix, string":function(e,t){return new i(e,t)}});return a.toTex={0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},a}t.name="sparse",t.factory=r},function(e,t,r){e.exports=[r(73),r(129),r(493),r(492),r(489),r(490),r(491),r(130),r(494),r(2),r(495)]},function(e,t,r){e.exports=[r(132)]},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("string",{"":function(){return""},number:a.format,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return i(e,o)},any:function(e){return String(e)}});return o.toTex={0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},o}var i=r(1),a=r(3);t.name="string",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("createUnit",{"Object, Object":function(t,r){return e.Unit.createUnit(t,r)},Object:function(t){return e.Unit.createUnit(t,{})},"string, Unit | string | Object, Object":function(t,r,n){var i={};return i[t]=r,e.Unit.createUnit(i,n)},"string, Unit | string | Object":function(t,r){var n={};return n[t]=r,e.Unit.createUnit(n,{})},string:function(t){var r={};return r[t]={},e.Unit.createUnit(r,{})}});return i}r(1);t.name="createUnit",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("splitUnit",{"Unit, Array":function(e,t){return e.splitUnit(t)}});return i}r(1);t.name="splitUnit",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("unit",{Unit:function(e){return e.clone()},string:function(t){return e.Unit.isValuelessUnit(t)?new e.Unit(null,t):e.Unit.parse(t)},"number | BigNumber | Fraction | Complex, string":function(t,r){return new e.Unit(t,r)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},a}var i=r(1);t.name="unit",t.factory=n},function(e,t,r){e.exports=[r(133),r(501),r(499),r(500),r(503)]},function(e,t,r){function n(e,t,r,n,a){function o(t){var r=e.Unit.parse(t);return r.fixPrefix=!0,r}i(a,"speedOfLight",function(){return o("299792458 m s^-1")}),i(a,"gravitationConstant",function(){return o("6.6738480e-11 m^3 kg^-1 s^-2")}),i(a,"planckConstant",function(){return o("6.626069311e-34 J s")}),i(a,"reducedPlanckConstant",function(){return o("1.05457172647e-34 J s")}),i(a,"magneticConstant",function(){return o("1.2566370614e-6 N A^-2")}),i(a,"electricConstant",function(){return o("8.854187817e-12 F m^-1")}),i(a,"vacuumImpedance",function(){return o("376.730313461 ohm")}),i(a,"coulomb",function(){return o("8.9875517873681764e9 N m^2 C^-2")}),i(a,"elementaryCharge",function(){return o("1.60217656535e-19 C")}),i(a,"bohrMagneton",function(){return o("9.2740096820e-24 J T^-1")}),i(a,"conductanceQuantum",function(){return o("7.748091734625e-5 S")}),i(a,"inverseConductanceQuantum",function(){return o("12906.403721742 ohm")}),i(a,"magneticFluxQuantum",function(){return o("2.06783375846e-15 Wb")}),i(a,"nuclearMagneton",function(){return o("5.0507835311e-27 J T^-1")}),i(a,"klitzing",function(){return o("25812.807443484 ohm")}),i(a,"bohrRadius",function(){return o("5.291772109217e-11 m")}),i(a,"classicalElectronRadius",function(){return o("2.817940326727e-15 m")}),i(a,"electronMass",function(){return o("9.1093829140e-31 kg")}),i(a,"fermiCoupling",function(){return o("1.1663645e-5 GeV^-2")}),i(a,"fineStructure",function(){return.007297352569824}),i(a,"hartreeEnergy",function(){return o("4.3597443419e-18 J")}),i(a,"protonMass",function(){return o("1.67262177774e-27 kg")}),i(a,"deuteronMass",function(){return o("3.3435830926e-27 kg")}),i(a,"neutronMass",function(){return o("1.6749271613e-27 kg")}),i(a,"quantumOfCirculation",function(){return o("3.636947552024e-4 m^2 s^-1")}),i(a,"rydberg",function(){return o("10973731.56853955 m^-1")}),i(a,"thomsonCrossSection",function(){return o("6.65245873413e-29 m^2")}),i(a,"weakMixingAngle",function(){return.222321}),i(a,"efimovFactor",function(){return 22.7}),i(a,"atomicMass",function(){return o("1.66053892173e-27 kg")}),i(a,"avogadro",function(){return o("6.0221412927e23 mol^-1")}),i(a,"boltzmann",function(){return o("1.380648813e-23 J K^-1")}),i(a,"faraday",function(){return o("96485.336521 C mol^-1")}),i(a,"firstRadiation",function(){return o("3.7417715317e-16 W m^2")}),i(a,"loschmidt",function(){return o("2.686780524e25 m^-3")}),i(a,"gasConstant",function(){return o("8.314462175 J K^-1 mol^-1")}),i(a,"molarPlanckConstant",function(){return o("3.990312717628e-10 J s mol^-1")}),i(a,"molarVolume",function(){return o("2.241396820e-10 m^3 mol^-1")}),i(a,"sackurTetrode",function(){return-1.164870823}),i(a,"secondRadiation",function(){return o("1.438777013e-2 m K")}),i(a,"stefanBoltzmann",function(){return o("5.67037321e-8 W m^-2 K^-4")}),i(a,"wienDisplacement",function(){return o("2.897772126e-3 m K")}),i(a,"molarMass",function(){return o("1e-3 kg mol^-1")}),i(a,"molarMassC12",function(){return o("1.2e-2 kg mol^-1")}),i(a,"gravity",function(){return o("9.80665 m s^-2")}),i(a,"planckLength",function(){return o("1.61619997e-35 m")}),i(a,"planckMass",function(){return o("2.1765113e-8 kg")}),i(a,"planckTime",function(){return o("5.3910632e-44 s")}),i(a,"planckCharge",function(){return o("1.87554595641e-18 C")}),i(a,"planckTemperature",function(){return o("1.41683385e+32 K")})}var i=r(5).lazy;t.factory=n,t.lazy=!1,t.math=!0},function(e,t){"use strict";function r(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number");var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=a!==-1?a-1:n.length-1,this.sign=r,this.coefficients=n.replace(".","").replace(/^0*/,function(e){return i-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)}),0===this.coefficients.length&&(this.coefficients.push(0),i++),this.exponent=i}function n(e){for(var t=[],r=0;r=0?r:Math.abs(a);i.length-1=0;)u++;var f=i.slice(u).join(""),l=f.match(/[1-9]/)?"."+f:"";return c=i.slice(0,u).join("")+l,c+="e"+(r>=0?"+":"")+a.toString(),t.sign+c},r.prototype.toFixed=function(e){var t=this.roundDigits(this.exponent+1+(e||0)),r=t.coefficients,i=t.exponent+1,a=i+(e||0);return r.length0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i},r.prototype.toPrecision=function(e,t){var r=t&&void 0!==t.lower?t.lower:.001,i=t&&void 0!==t.upper?t.upper:1e5,a=Math.abs(Math.pow(10,this.exponent));if(a=i)return this.toExponential(e);var o=e?this.roundDigits(e):this.clone(),s=o.coefficients,u=o.exponent;s.length0?u:0;return ce){var n=r.splice(e,r.length-e);if(n[0]>=5){var i=e-1;for(r[i]++;10===r[i];)r.pop(),0===i&&(r.unshift(0),t.exponent++,i++),i--,r[i]++}}return t},e.exports=r},function(e,t,r){var n=r(78);e.exports=function(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 n(e,t,function(e,t){return e&t})}},function(e,t,r){var n=r(78);e.exports=function(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 i=new r(-1);return e.isZero()||t.eq(i)||e.eq(t)?t:t.isZero()||e.eq(i)?e:e.isFinite()&&t.isFinite()?n(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?i:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}},function(e,t,r){var n=r(78),i=r(77);e.exports=function(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 a=new r(-1);return e.eq(a)?i(t):t.eq(a)?i(e):e.isFinite()&&t.isFinite()?n(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()==t.isNegative()?1/0:-(1/0)):a}},function(e,t){t.format=function(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n="auto",i=void 0;switch(void 0!==r&&(r.notation&&(n=r.notation),"number"==typeof r?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"auto":var a=.001,o=1e5;r&&r.exponential&&(void 0!==r.exponential.lower&&(a=r.exponential.lower),void 0!==r.exponential.upper&&(o=r.exponential.upper));({toExpNeg:e.constructor.toExpNeg,toExpPos:e.constructor.toExpPos});if(e.constructor.config({toExpNeg:Math.round(Math.log(a)/Math.LN10),toExpPos:Math.round(Math.log(o)/Math.LN10)}),e.isZero())return"0";var s,u=e.abs();return s=u.gte(a)&&u.lt(o)?e.toSignificantDigits(i).toFixed():t.toExponential(e,i),s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()},t.toFixed=function(e,t){return e.toFixed(t||0)}},function(e,t){e.exports=function(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(e,t){e.exports=function(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():new r(e.isNegative()?-1:e.isFinite()?0:NaN)}},function(e,t){"use strict";t.isBoolean=function(e){return"boolean"==typeof e}},function(e,t){"use strict";e.exports=function(e,t,r,n,i,a,o,s,u,c,f){var l,p,h,m,d=e._values,g=e._index,v=e._ptr,y=o._index;if(n)for(p=v[t],h=v[t+1],l=p;l1)for(var r=1;rr&&!c?"Unexpected type of argument in function "+u+" (expected: "+s.join(" or ")+", actual: "+o+", index: "+r+")":"Too few arguments in function "+u+" (expected: "+s.join(" or ")+", index: "+r+")":"Too many arguments in function "+u+" (expected: "+r+", actual: "+t+")";var l=new TypeError(a);return l.data=f,l}function i(e){this.name=e||"refs",this.categories={}}function a(e,t){if("string"==typeof e){var r=e.trim(),n="..."===r.substr(0,3);if(n&&(r=r.substr(3)),""===r)this.types=["any"];else{this.types=r.split("|");for(var i=0;it&&(t=n)}return t}function d(e){for(var t,r=0;r0},a.prototype.contains=function(e){for(var t=0;tt.params.length)return 1;if(e.params.lengtho)return 1;if(i "+i+") {"),n.push(r+" var varArgs = [];"),n.push(r+" for (var i = "+i+"; i < arguments.length; i++) {"),n.push(r+" varArgs.push(arguments[i]);"),n.push(r+" }"),n.push(this.signature.toCode(e,r+" ")),n.push(r+"}");else{for(var s=function(r,n){for(var i=[],a=0;a "+r+") {",t+" throw createError(name, arguments.length, "+r+", arguments["+r+"]);",t+"}"].join("\n");for(var n={},i=[],a=0;a=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(r)?n.showHidden=r:r&&t._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),u(n,e,n.depth)}function a(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function o(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,r,n){if(e.customInspect&&r&&O(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return x(i)||(i=u(e,i,n)),i}var a=c(e,r);if(a)return a;var o=Object.keys(r),d=s(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),A(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(r);if(0===o.length){if(O(r)){var g=r.name?": "+r.name:"";return e.stylize("[Function"+g+"]","special")}if(N(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(M(r))return e.stylize(Date.prototype.toString.call(r),"date"); -if(A(r))return f(r)}var v="",y=!1,w=["{","}"];if(m(r)&&(y=!0,w=["[","]"]),O(r)){var b=r.name?": "+r.name:"";v=" [Function"+b+"]"}if(N(r)&&(v=" "+RegExp.prototype.toString.call(r)),M(r)&&(v=" "+Date.prototype.toUTCString.call(r)),A(r)&&(v=" "+f(r)),0===o.length&&(!y||0==r.length))return w[0]+v+w[1];if(n<0)return N(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var E;return E=y?l(e,r,n,d,o):o.map(function(t){return p(e,r,n,d,t,y)}),e.seen.pop(),h(E,v,w)}function c(e,t){if(b(t))return e.stylize("undefined","undefined");if(x(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return y(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i){for(var a=[],o=0,s=t.length;o-1&&(s=a?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),b(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function h(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function m(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function g(e){return null===e}function v(e){return null==e}function y(e){return"number"==typeof e}function x(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function b(e){return void 0===e}function N(e){return E(e)&&"[object RegExp]"===T(e)}function E(e){return"object"==typeof e&&null!==e}function M(e){return E(e)&&"[object Date]"===T(e)}function A(e){return E(e)&&("[object Error]"===T(e)||e instanceof Error)}function O(e){return"function"==typeof e}function _(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}function S(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function z(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var k=/%[sdj%]/g;t.format=function(e){if(!x(e)){for(var t=[],r=0;r=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r= 1 as expected.")}function i(e,t){var r=Object.keys(e),i=r.map(function(t){return e[t]});return n(r,i,t)}function a(e,t,r){if("function"==typeof r&&(r={rand:r}),null==r&&(r={}),Array.isArray(e)){if(null==t&&(t=e.map(function(){return 1})),Array.isArray(t)){if(e.length===t.length)return n(e,t,r);throw new TypeError("Set and Weights are different sizes.")}throw new TypeError("Set is an Array, and Weights is not.")}if("object"==typeof e)return i(e,t||r);throw new TypeError("Set is not an Object, nor is it an Array.")}e.exports=a,e.exports.select=a}]); \ No newline at end of file +examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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:[]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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(0)","isNumeric(bignumber(500))","isNumeric(fraction(0.125))",'isNumeric("3")',"isNumeric(2 + 3i)",'isNumeric([2.3, "foo", false])'],seealso:["isInteger","isZero","isNegative","isPositive","isNaN"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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"]}},function(e,t){e.exports={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:[]}},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(29));return a("compile",{string:function(e){return o(e).compile()},"Array | Matrix":function(e){return i(e,function(e){return o(e).compile()})}})}var i=r(1);t.name="compile",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(29));return a("compile",{string:function(e){var t={};return o(e).compile().eval(t)},"string, Object":function(e,t){return o(e).compile().eval(t)},"Array | Matrix":function(e){var t={};return i(e,function(e){return o(e).compile().eval(t)})},"Array | Matrix, Object":function(e,t){return i(e,function(e){return o(e).compile().eval(t)})}})}var i=r(1);t.name="eval",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,a){var o=n(r(84));return i("help",{any:function(t){var r,n=t;if("string"!=typeof t)for(r in a)if(a.hasOwnProperty(r)&&t===a[r]){n=r;break}var i=o[n];if(!i)throw new Error('No documentation found on "'+n+'"');return new e.Help(i)}})}t.math=!0,t.name="help",t.factory=n},function(e,t,r){e.exports=[r(329),r(330),r(331),r(333),r(85)]},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(29));return i("parse",{"string | Array | Matrix":a,"string | Array | Matrix, Object":a})}t.name="parse",t.factory=n},function(e,t,r){e.exports=[r(84),r(332),r(336),r(341),r(150),r(29),r(81)]},function(e,t){"use strict";function r(e,t,r,n){function i(){throw new Error("UpdateNode is deprecated. Use AssignmentNode instead.")}return i}t.name="UpdateNode",t.path="expression.node",t.factory=r},function(e,t,r){e.exports=[r(86),r(64),r(87),r(88),r(89),r(44),r(91),r(90),r(45),r(12),r(92),r(49),r(50),r(65),r(25),r(335)]},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(52)),s=n(r(2));return function(e,t,r){try{if(Array.isArray(e))return s(e).subset(t,r).valueOf();if(e&&"function"==typeof e.subset)return e.subset(t,r);if("string"==typeof e)return o(e,t,r);if("object"==typeof e){if(!t.isObjectProperty())throw TypeError("Cannot apply a numeric index as object property");return e[t.getObjectProperty()]=r,e}throw new TypeError("Cannot apply index: unsupported type of object")}catch(e){throw i(e)}}}var i=r(30).transform;t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(108));return a("concat",{"...any":function(e){var t=e.length-1,r=e[t];"number"==typeof r?e[t]=r-1:r&&r.isBigNumber===!0&&(e[t]=r.minus(1));try{return o.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform;t.name="concat",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t,r){var n,i;if(e[0]&&(n=e[0].compile().eval(r)),e[1])if(e[1]&&e[1].isSymbolNode)i=e[1].compile().eval(r);else{var a=r||{},s=e[1].filter(function(e){return e&&e.isSymbolNode&&!(e.name in t)&&!(e.name in a)})[0],u=Object.create(a),c=e[1].compile();if(!s)throw new Error("No undefined variable found in filter equation");var f=s.name;i=function(e){return u[f]=e,c.eval(u)}}return o(n,i)}var o=n(r(110));n(r(25));return a.rawArgs=!0,a}t.name="filter",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){n(r(111));return a("forEach",{"Array | Matrix, function":function(e,t){var r=i(t),n=function(i,a){Array.isArray(i)?i.forEach(function(e,t){n(e,a.concat(t+1))}):1===r?t(i):2===r?t(i,a):t(i,a,e)};n(e.valueOf(),[])}})}var i=r(34).maxArgumentCount;t.name="forEach",t.path="expression.transform",t.factory=n},function(e,t,r){e.exports=[r(338),r(339),r(340),r(342),r(343),r(344),r(345),r(346),r(347),r(348)]},function(e,t){"use strict";function r(e,t,r){return function(){for(var t=[],r=0,n=arguments.length;r0?0:2;else if(i&&i.isSet===!0)i=i.map(function(e){return e-1});else if(i&&(i.isArray===!0||i.isMatrix))i=i.map(function(e){return e-1});else if("number"==typeof i)i--;else if(i&&i.isBigNumber===!0)i=i.toNumber()-1;else if("string"!=typeof i)throw new TypeError("Dimension must be an Array, Matrix, number, string, or Range");t[r]=i}var a=new e.Index;return e.Index.apply(a,t),a}}t.name="index",t.path="expression.transform",t.factory=r},function(e,t,r){"use strict";function n(e,t,n,a){var o=(n(r(69)),n(r(2)));return a("max",{"Array, function":function(e,t){return i(e,t,e)},"Matrix, function":function(e,t){return o(i(e.valueOf(),t,e))}})}function i(e,t,r){function n(e,a){return Array.isArray(e)?e.map(function(e,t){return n(e,a.concat(t+1))}):1===i?t(e):2===i?t(e,a):t(e,a,r)}var i=a(t);return n(e,[])}var a=r(34).maxArgumentCount;t.name="map",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(117));return o("max",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="max",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(118));return o("mean",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="mean",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(120));return o("min",{"...any":function(e){if(2==e.length&&a(e[0])){var t=e[1];"number"==typeof t?e[1]=t-1:t&&t.isBigNumber===!0&&(e[1]=t.minus(1))}try{return s.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform,a=r(41);t.name="min",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(113));return i("range",{"...any":function(e){var t=e.length-1,r=e[t];return"boolean"!=typeof r&&e.push(!0),a.apply(null,e)}})}t.name="range",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(52));return a("subset",{"...any":function(e){try{return o.apply(null,e)}catch(e){throw i(e)}}})}var i=r(30).transform;t.name="subset",t.path="expression.transform",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e){if("log"!=e.name&&"nthRoot"!=e.name||2!=e.args.length){for(var t=0;t1?(r=l(n,a,i),s.unshift(r),r=l(n,s,i)):r=l(n,t,i)}else r=l(n,t,i);else t=e.args.map(p),r=l(n,t,i);return r;case"ParenthesisNode":return p(e.content);case"AccessorNode":case"ArrayNode":case"AssignmentNode":case"BlockNode":case"FunctionAssignmentNode":case"IndexNode":case"ObjectNode":case"RangeNode":case"UpdateNode":case"ConditionalNode":default:throw"Unimplemented node type in simplifyConstant: "+e.type}}var h=n(r(97)),m=h.isCommutative,d=h.isAssociative,g=h.allChildren,v=h.createMakeNodeFunction,y=o.expression.node.ConstantNode,x=o.expression.node.OperatorNode,w=a({Fraction:f,number:c,BigNumber:function(e){return c(e._toNumber())},Complex:function(e){throw"Cannot convert Complex number to Node"}}),b=a({Fraction:function(e){return e},BigNumber:function(e){return e.decimalPlaces()<=15?o.fraction(e.toNumber()):e.toNumber()},number:function(e){return i(e)<=15?o.fraction(e):e},Complex:function(e){return 0!==e.im?e:i(e.re)<=15?o.fraction(e.re):e.re}});return s}var i=r(3).digits;t.math=!0,t.name="simplifyConstant",t.path="algebra.simplify",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(2)),s=n(r(94)),u=n(r(95)),c=n(r(358)),f=n(r(66)),l=n(r(99)),p=n(r(98)),h=a("lusolve",{"Array, Array | Matrix":function(e,t){e=o(e);var r=s(e),n=d(r.L,r.U,r.p,null,t);return n.valueOf()},"DenseMatrix, Array | Matrix":function(e,t){var r=s(e);return d(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix":function(e,t){var r=s(e);return d(r.L,r.U,r.p,null,t)},"SparseMatrix, Array | Matrix, number, number":function(e,t,r,n){var i=u(e,r,n);return d(i.L,i.U,i.p,i.q,t)},"Object, Array | Matrix":function(e,t){return d(e.L,e.U,e.p,e.q,t)}}),m=function(e){if(e&&e.isMatrix===!0)return e;if(i(e))return o(e);throw new TypeError("Invalid Matrix LU decomposition")},d=function(e,t,r,n,i){e=m(e),t=m(t),i=f(e,i,!1),r&&(i._data=c(r,i._data));var a=p(e,i),o=l(t,a);return n&&(o._data=c(n,o._data)),o};return h}var i=Array.isArray;t.name="lusolve",t.factory=n},function(e,t,r){"use strict";function n(e,t,n){var i=n(r(67)),a=n(r(357)),o=n(r(102)),s=n(r(16)),u=n(r(11)),c=n(r(53)),f=function(e,t){if(!t||e<=0||e>3)return null;var r=t._size,n=r[0],s=r[1],u=0,c=Math.max(16,10*Math.sqrt(s));c=Math.min(s-2,c);var f=l(e,t,n,s,c);a(f,d,null);for(var g,v,y,x,w,b,N,E,M,A,O,_,T,C,S,z,k=f._index,B=f._ptr,I=B[s],P=[],R=[],U=0,q=s+1,j=2*(s+1),L=3*(s+1),F=4*(s+1),D=5*(s+1),$=6*(s+1),G=7*(s+1),H=P,Z=p(s,B,R,U,L,H,j,G,q,$,F,D),V=h(s,B,R,D,F,$,c,q,L,H,j),W=0;VY?(b=y,N=Q,E=R[U+y]-Y):(b=k[Q++],N=B[b],E=R[U+b]),w=1;w<=E;w++)g=k[N++],(M=R[q+g])<=0||(J+=M,R[q+g]=-M,k[ee++]=g,R[j+g]!=-1&&(H[R[j+g]]=H[g]),H[g]!=-1?R[j+H[g]]=R[j+g]:R[L+R[D+g]]=R[j+g]);b!=y&&(B[b]=i(y),R[$+b]=0)}for(0!==Y&&(I=ee),R[D+y]=J,B[y]=K,R[U+y]=ee-K,R[F+y]=-2,Z=m(Z,u,R,$,s),A=K;A=Z?R[$+b]-=M:0!==R[$+b]&&(R[$+b]=R[D+b]+te)}for(A=K;A0?(z+=re,k[C++]=b,S+=b):(B[b]=i(y),R[$+b]=0)}R[F+g]=C-_+1;var ne=C,ie=_+R[U+g];for(Q=T+1;Q=0))for(S=H[g],g=R[G+S],R[G+S]=-1;g!=-1&&R[j+g]!=-1;g=R[j+g],Z++){for(E=R[U+g],O=R[F+g],Q=B[g]+1;Q<=B[g]+E-1;Q++)R[$+k[Q]]=Z;var oe=g;for(v=R[j+g];v!=-1;){var se=R[U+v]===E&&R[F+v]===O;for(Q=B[v]+1;se&&Q<=B[v]+E-1;Q++)R[$+k[Q]]!=Z&&(se=0);se?(B[v]=i(g),R[q+g]+=R[q+v],R[q+v]=0,R[F+v]=-1,v=R[j+v],R[j+oe]=v):(oe=v,v=R[j+v])}}for(Q=K,A=K;A=0;v--)R[q+v]>0||(R[j+v]=R[L+B[v]],R[L+B[v]]=v);for(b=s;b>=0;b--)R[q+b]<=0||B[b]!=-1&&(R[j+b]=R[L+B[b]],R[L+B[b]]=b);for(y=0,g=0;g<=s;g++)B[g]==-1&&(y=o(g,y,R,L,j,P,$));return P.splice(P.length-1,1),P},l=function(e,t,r,n,i){var a=c(t);if(1===e&&n===r)return s(t,a);if(2==e){for(var o=a._index,f=a._ptr,l=0,p=0;pi))for(var m=f[p+1];hs)r[u+h]=0,r[a+h]=-1,p++,t[h]=i(e),r[u+e]++;else{var d=r[c+m];d!=-1&&(f[d]=h),r[l+h]=r[c+m],r[c+m]=h}}return p},m=function(e,t,r,n,i){if(e<2||e+t<0){for(var a=0;a=1&&M[s]++,2==T.jleaf&&M[T.q]--}t[s]!=-1&&(v[y+s]=t[s])}for(s=0;s=0;){e=n[d];var g=s?s[e]:e;i(p,e)||(a(p,e),n[m+d]=g<0?0:o(p[g]));var v=1;for(c=n[m+d],f=g<0?0:o(p[g+1]);c=0;r--)e[r]!=-1&&(o[u+r]=o[s+e[r]],o[s+e[r]]=r);for(r=0;r=0;u--)for(f=r[u],l=r[u+1],c=f;c=0;s--)h[s]=-1,u=m[s],u!=-1&&(0===d[x+u]++&&(d[y+u]=s),d[g+s]=d[v+u],d[v+u]=s);for(t.lnz=0,t.m2=a,u=0;u=0||t.predictable?a(r):new e.Complex(r,0).log().div(Math.LN10)},Complex:function(t){return new e.Complex(t).log().div(Math.LN10)},BigNumber:function(r){return!r.isNegative()||t.predictable?r.log():new e.Complex(r.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\log_{10}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.log10||function(e){return Math.log(e)/Math.LN10};t.name="log10",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(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")}var o=n(r(2)),s=r(4),u=n(r(22)),c=n(r(13)),f=n(r(57)),l=n(r(14)),p=n(r(15)),h=n(r(7)),m=n(r(6)),d=i("mod",{"number, number":a,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.mod(t)},"Fraction, Fraction":function(e,t){return e.mod(t)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,d,!1);break;default:r=u(t,e,d,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,d,!1);break;default:r=h(e,t,d)}}return r},"Array, Array":function(e,t){return d(o(e),o(t)).valueOf()},"Array, Matrix":function(e,t){return d(o(e),t)},"Matrix, Array":function(e,t){return d(e,o(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=p(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r},"Array, any":function(e,t){return m(o(e),t,d,!1).valueOf()},"any, Array":function(e,t){return m(o(t),e,d,!0).valueOf()}});return d.toTex={2:"\\left(${args[0]}"+s.operators.mod+"${args[1]}\\right)"},d}t.name="mod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){var r=e.size();if(1==r.length){if(t===Number.POSITIVE_INFINITY||"inf"===t){var n=0;return e.forEach(function(e){var t=o(e);p(t,n)&&(n=t)},!0),n}if(t===Number.NEGATIVE_INFINITY||"-inf"===t){var i;return e.forEach(function(e){var t=o(e);i&&!h(t,i)||(i=t)},!0),i||0}if("fro"===t)return a(e,2);if("number"==typeof t&&!isNaN(t)){if(!l(t,0)){var m=0;return e.forEach(function(e){m=s(u(o(e),t),m)},!0),u(m,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}if(2==r.length){if(1===t){var v=[],y=0;return e.forEach(function(e,t){var r=t[1],n=s(v[r]||0,o(e));p(n,y)&&(y=n),v[r]=n},!0),y}if(t===Number.POSITIVE_INFINITY||"inf"===t){var x=[],w=0;return e.forEach(function(e,t){var r=t[0],n=s(x[r]||0,o(e));p(n,w)&&(w=n),x[r]=n},!0),w}if("fro"===t)return c(d(f(g(e),e)));if(2===t)throw new Error("Unsupported parameter value, missing implementation of matrix singular value decomposition");throw new Error("Unsupported parameter value")}}var o=n(r(26)),s=n(r(16)),u=n(r(36)),c=n(r(51)),f=n(r(11)),l=n(r(9)),p=n(r(27)),h=n(r(39)),m=n(r(2)),d=n(r(114)),g=n(r(53)),v=i("norm",{number:Math.abs,Complex:function(e){return e.abs()},BigNumber:function(e){return e.abs()},"boolean | null":function(e){return Math.abs(e)},Array:function(e){return a(m(e),2)},Matrix:function(e){return a(e,2)},"number | Complex | BigNumber | boolean | null, number | BigNumber | string":function(e){return v(e)},"Array, number | BigNumber | string":function(e,t){return a(m(e),t)},"Matrix, number | BigNumber | string":function(e,t){return a(e,t)}});return v.toTex={1:"\\left\\|${args[0]}\\right\\|",2:void 0},v}t.name="norm",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=e.BigNumber.precision,i=e.BigNumber.clone({precision:n+2}),a=new e.BigNumber(0),o=new i(1),s=r.isNegative();if(s&&(r=r.neg()),r.isZero())throw new Error("Root must be non-zero");if(t.isNegative()&&!r.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(t.isZero())return s?new i(1/0):0;if(!t.isFinite())return s?a:t;var u=t.abs().pow(o.div(r));return u=t.isNeg()?u.neg():u,new e.BigNumber((s?o.div(u):u).toPrecision(n))}var u=n(r(2)),c=n(r(28)),f=n(r(22)),l=n(r(58)),p=n(r(14)),h=n(r(7)),m=n(r(6)),d=o("nthRoot",{number:function(e){return i(e,2)},"number, number":i,BigNumber:function(t){return s(t,new e.BigNumber(2))},Complex:function(e){return a(e,2)},"Complex, number":a,"BigNumber, BigNumber":s,"Array | Matrix":function(e){return d(e,2)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=l(e,t,d);break;default:r=f(t,e,d,!0)}break;default:switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=c(e,t,d,!1);break;default:r=h(e,t,d)}}return r},"Array, Array":function(e,t){return d(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return d(u(e),t)},"Matrix, Array":function(e,t){return d(e,u(t))},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=p(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"number | BigNumber, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":if(1!==t.density())throw new Error("Root must be non-zero");r=p(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r},"Array, number | BigNumber":function(e,t){return d(u(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return d(e,u(t)).valueOf()}});return d.toTex={2:"\\sqrt[${args[1]}]{${args[0]}}"},d}function i(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 a(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");for(var r=e.arg(),n=e.abs(),i=[],a=Math.pow(n,1/t),o=0;o15)throw new Error("Number of decimals in function round must be in te range of 0-15");return i(e,t)},Complex:function(e){return e.round()},"Complex, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Complex, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);var r=t.toNumber();return e.round(r)},"number, BigNumber":function(t,r){if(!r.isInteger())throw new TypeError(u);return new e.BigNumber(t).toDecimalPlaces(r.toNumber())},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError(u);return e.toDecimalPlaces(t.toNumber())},Fraction:function(e){return e.round()},"Fraction, number":function(e,t){if(t%1)throw new TypeError(u);return e.round(t)},"Array | Matrix":function(e){return s(e,d,!0)},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=p(e,t,d,!1);break;default:r=m(e,t,d,!1)}return r},"number | Complex | BigNumber, Matrix":function(e,t){if(!f(e,0)){var r;switch(t.storage()){case"sparse":r=h(t,e,d,!0);break;default:r=m(t,e,d,!0)}return r}return l(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return m(c(e),t,d,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,t){return m(c(t),e,d,!0).valueOf()}});return d.toTex={1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},d}function i(e,t){return parseFloat(o(e,t))}var a=r(3).isInteger,o=r(3).toFixed,s=r(1),u="Number of decimals in function round must be an integer";t.name="round",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sign",{number:i.sign,Complex:function(e){return e.sign()},BigNumber:function(t){return new e.BigNumber(t.cmp(0))},Fraction:function(t){return new e.Fraction(t.s,1)},"Array | Matrix":function(e){return a(e,o,!0)},Unit:function(e){return o(e.value)}});return o.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},o}var i=r(3),a=r(1);t.name="sign",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("square",{number:function(e){return e*e},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 i(e,a,!0)},Unit:function(e){return e.pow(2)}});return a.toTex={1:"\\left(${args[0]}\\right)^2"},a}var i=r(1);t.name="square",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=a("unaryPlus",{number:function(e){return e},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 i(e,s,!0)},"boolean | string | null":function(r){return"BigNumber"==t.number?new e.BigNumber(+r):+r}});return s.toTex={1:o.operators.unaryPlus+"\\left(${args[0]}\\right)"},s}var i=r(1);t.name="unaryPlus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(e,r){var n,a,o,s=0,c=1,f=1,l=0;if(!i(e)||!i(r))throw new Error("Parameters in function xgcd must be integer numbers");for(;r;)a=Math.floor(e/r),o=e%r,n=s,s=c-a*s,c=n,n=f,f=l-a*f,l=n,e=r,r=o;var p;return p=e<0?[-e,-c,-l]:[e,e?c:0,l],"Array"===t.matrix?p:u(p)}function s(r,n){var i,a,o,s=new e.BigNumber(0),c=new e.BigNumber(1),f=s,l=c,p=c,h=s;if(!r.isInt()||!n.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!n.isZero();)a=r.div(n).floor(),o=r.mod(n),i=f,f=l.minus(a.times(f)),l=i,i=p,p=h.minus(a.times(p)),h=i,r=n,n=o;var m;return m=r.lt(s)?[r.neg(),l.neg(),h.neg()]:[r,r.isZero()?0:l,h],"Array"===t.matrix?m:u(m)}var u=n(r(2)),c=a("xgcd",{"number, number":o,"BigNumber, BigNumber":s});return c.toTex=void 0,c}var i=r(3).isInteger;t.name="xgcd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(22)),f=n(r(58)),l=n(r(14)),p=n(r(7)),h=n(r(6)),m=o("bitAnd",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitAnd");return e&t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m,!1);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitAnd+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(506);t.name="bitAnd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){var u=r(4),c=s("bitNot",{number:function(e){if(!o(e))throw new Error("Integer expected in function bitNot");return~e},BigNumber:a,"Array | Matrix":function(e){return i(e,c)}});return c.toTex={1:u.operators.bitNot+"\\left(${args[0]}\\right)"},c}var i=r(1),a=r(78),o=r(3).isInteger;t.name="bitNot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(28)),f=n(r(75)),l=n(r(31)),p=n(r(7)),h=n(r(6)),m=o("bitOr",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitOr");return e|t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitOr+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(507);t.name="bitOr",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(13)),f=n(r(23)),l=n(r(15)),p=n(r(7)),h=n(r(6)),m=o("bitXor",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitXor");return e^t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=f(e,t,m);break;default:r=c(t,e,m,!0)}break;default:switch(t.storage()){case"sparse":r=c(e,t,m,!1);break;default:r=p(e,t,m)}}return r},"Array, Array":function(e,t){return m(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return m(u(e),t)},"Matrix, Array":function(e,t){return m(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=l(e,t,m,!1);break;default:r=h(e,t,m,!1)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=l(t,e,m,!0);break;default:r=h(t,e,m,!0)}return r},"Array, any":function(e,t){return h(u(e),t,m,!1).valueOf()},"any, Array":function(e,t){return h(u(t),e,m,!0).valueOf()}});return m.toTex={2:"\\left(${args[0]}"+s.operators.bitXor+"${args[1]}\\right)"},m}var i=r(3).isInteger,a=r(508);t.name="bitXor",t.factory=n},function(e,t,r){e.exports=[r(387),r(388),r(389),r(390),r(392),r(393),r(394)]},function(e,t,r){"use strict";function n(e,t,n,o){var s=r(4),u=n(r(2)),c=n(r(9)),f=n(r(38)),l=n(r(28)),p=n(r(22)),h=n(r(76)),m=n(r(31)),d=n(r(14)),g=n(r(7)),v=n(r(6)),y=o("leftShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function leftShift");return e<>t},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=h(e,t,y,!1);break;default:r=p(t,e,y,!0)}break;default:switch(t.storage()){case"sparse":r=l(e,t,y,!1);break;default:r=g(e,t,y)}}return r},"Array, Array":function(e,t){return y(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return y(u(e),t)},"Matrix, Array":function(e,t){return y(e,u(t))},"Matrix, number | BigNumber":function(e,t){if(!c(t,0)){var r;switch(e.storage()){case"sparse":r=d(e,t,y,!1);break;default:r=v(e,t,y,!1)}return r}return e.clone()},"number | BigNumber, Matrix":function(e,t){if(!c(e,0)){var r;switch(t.storage()){case"sparse":r=m(t,e,y,!0);break;default:r=v(t,e,y,!0)}return r}return f(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return y(u(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return y(e,u(t)).valueOf()}});return y.toTex={2:"\\left(${args[0]}"+s.operators.rightArithShift+"${args[1]}\\right)"},y}var i=r(3).isInteger,a=r(511);t.name="rightArithShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=r(4),s=n(r(2)),u=n(r(9)),c=n(r(38)),f=n(r(28)),l=n(r(22)),p=n(r(76)),h=n(r(31)),m=n(r(14)),d=n(r(7)),g=n(r(6)),v=a("rightLogShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function rightLogShift");return e>>>t},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=p(e,t,v,!1);break;default:r=l(t,e,v,!0)}break;default:switch(t.storage()){case"sparse":r=f(e,t,v,!1);break;default:r=d(e,t,v)}}return r},"Array, Array":function(e,t){return v(s(e),s(t)).valueOf()},"Array, Matrix":function(e,t){return v(s(e),t)},"Matrix, Array":function(e,t){return v(e,s(t))},"Matrix, number | BigNumber":function(e,t){if(!u(t,0)){var r;switch(e.storage()){case"sparse":r=m(e,t,v,!1);break;default:r=g(e,t,v,!1)}return r}return e.clone()},"number | BigNumber, Matrix":function(e,t){if(!u(e,0)){var r;switch(t.storage()){case"sparse":r=h(t,e,v,!0);break;default:r=g(t,e,v,!0)}return r}return c(t.size(),t.storage())},"Array, number | BigNumber":function(e,t){return v(s(e),t).valueOf()},"number | BigNumber, Array":function(e,t){return v(e,s(t)).valueOf()}});return v.toTex={2:"\\left(${args[0]}"+o.operators.rightLogShift+"${args[1]}\\right)"},v}var i=r(3).isInteger;t.name="rightLogShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(106)),s=n(r(48)),u=n(r(40)),c=i("bellNumbers",{"number | BigNumber":function(e){if(!u(e)||s(e))throw new TypeError("Non-negative integer value expected in function bellNumbers");for(var t=0,r=0;r<=e;r++)t=a(t,o(e,r));return t}});return c.toTex={1:"\\mathrm{B}_{${args[0]}}"},c}t.name="bellNumbers",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(16)),o=n(r(35)),s=n(r(11)),u=n(r(54)),c=n(r(48)),f=n(r(40)),l=i("catalan",{"number | BigNumber":function(e){if(!f(e)||c(e))throw new TypeError("Non-negative integer value expected in function catalan");return o(u(s(e,2),e),a(e,1))}});return l.toTex={1:"\\mathrm{C}_{${args[0]}}"},l}t.name="catalan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(54)),o=n(r(18)),s=n(r(56)),u=n(r(40)),c=n(r(27)),f=i("composition",{"number | BigNumber, number | BigNumber":function(e,t){if(!(u(e)&&s(e)&&u(t)&&s(t)))throw new TypeError("Positive integer value expected in function composition");if(c(t,e))throw new TypeError("k must be less than or equal to n in function composition");return a(o(e,-1),o(t,-1))}});return f.toTex=void 0,f}t.name="composition",t.factory=n},function(e,t,r){e.exports=[r(395),r(397),r(106),r(396)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("arg",{number:function(e){return Math.atan2(0,e)},BigNumber:function(t){return e.BigNumber.atan2(0,t)},Complex:function(e){return e.arg()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\arg\\left(${args[0]}\\right)"},a}var i=r(1);t.name="arg",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("conj",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.conjugate()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\left(${args[0]}\\right)^*"},a}var i=r(1);t.name="conj",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("im",{number:function(e){return 0},BigNumber:function(t){return new e.BigNumber(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\Im\\left\\lbrace${args[0]}\\right\\rbrace"},a}var i=r(1);t.name="im",t.factory=n},function(e,t,r){e.exports=[r(399),r(400),r(401),r(403)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("re",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\Re\\left\\lbrace${args[0]}\\right\\rbrace"},a}var i=r(1);t.name="re",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){var m=(n(r(2)),s("distance",{"Array, Array, Array":function(e,t,r){if(2==e.length&&2==t.length&&2==r.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers expected for second argument");if(!i(r))throw new TypeError("Array with 2 numbers expected for third argument");var n=(r[1]-r[0])/(t[1]-t[0]),a=n*n*t[0],o=-1*(n*t[0]),s=e[1];return c(e[0],e[1],a,o,s)}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(!i(e))throw new TypeError("Values of pointX and pointY should be numbers");if(!i(t))throw new TypeError("Values of lineOnePtX and lineOnePtY should be numbers");if(!i(r))throw new TypeError("Values of lineTwoPtX and lineTwoPtY should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("lineOnePtX")&&t.hasOwnProperty("lineOnePtY")&&r.hasOwnProperty("lineTwoPtX")&&r.hasOwnProperty("lineTwoPtY")){var n=(r.lineTwoPtY-r.lineTwoPtX)/(t.lineOnePtY-t.lineOnePtX),a=n*n*t.lineOnePtX,o=-1*(n*t.lineOnePtX),s=e.pointX;return c(e.pointX,e.pointY,a,o,s)}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(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return c(e[0],e[1],t[0],t[1],t[2])}if(3==e.length&&6==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!o(t))throw new TypeError("Array with 6 numbers expected for second argument");return f(e[0],e[1],e[2],t[0],t[1],t[2],t[3],t[4],t[5])}if(2==e.length&&2==t.length){if(!i(e))throw new TypeError("Array with 2 numbers expected for first argument");if(!i(t))throw new TypeError("Array with 2 numbers expected for second argument");return l(e[0],e[1],t[0],t[1])}if(3==e.length&&3==t.length){if(!a(e))throw new TypeError("Array with 3 numbers expected for first argument");if(!a(t))throw new TypeError("Array with 3 numbers expected for second argument");return p(e[0],e[1],e[2],t[0],t[1],t[2])}throw new TypeError("Invalid Arguments: Try again")},"Object, Object":function(e,t){if(2==Object.keys(e).length&&3==Object.keys(t).length){if(!i(e))throw new TypeError("Values of pointX and pointY should be numbers");if(!a(t))throw new TypeError("Values of xCoeffLine, yCoeffLine and constant should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("xCoeffLine")&&t.hasOwnProperty("yCoeffLine")&&t.hasOwnProperty("yCoeffLine"))return c(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(!a(e))throw new TypeError("Values of pointX, pointY and pointZ should be numbers");if(!o(t))throw new TypeError("Values of x0, y0, z0, a, b and c should be numbers");if(e.hasOwnProperty("pointX")&&e.hasOwnProperty("pointY")&&t.hasOwnProperty("x0")&&t.hasOwnProperty("y0")&&t.hasOwnProperty("z0")&&t.hasOwnProperty("a")&&t.hasOwnProperty("b")&&t.hasOwnProperty("c"))return f(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(!i(e))throw new TypeError("Values of pointOneX and pointOneY should be numbers");if(!i(t))throw new TypeError("Values of pointTwoX and pointTwoY should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY"))return l(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(!a(e))throw new TypeError("Values of pointOneX, pointOneY and pointOneZ should be numbers");if(!a(t))throw new TypeError("Values of pointTwoX, pointTwoY and pointTwoZ should be numbers");if(e.hasOwnProperty("pointOneX")&&e.hasOwnProperty("pointOneY")&&e.hasOwnProperty("pointOneZ")&&t.hasOwnProperty("pointTwoX")&&t.hasOwnProperty("pointTwoY")&&t.hasOwnProperty("pointTwoZ"))return p(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(!u(e))throw new TypeError("Incorrect array format entered for pairwise distance calculation");return h(e)}}));return m}function i(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]}function a(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]}function o(e){return e.constructor!==Array&&(e=s(e)),"number"==typeof e[0]&&"number"==typeof e[1]&&"number"==typeof e[2]&&"number"==typeof e[3]&&"number"==typeof e[4]&&"number"==typeof e[5]}function s(e){for(var t=Object.keys(e),r=[],n=0;n1?[o]:o}var s=n(r(2)),u=n(r(19)),c=n(r(11)),f=a("cross",{"Matrix, Matrix":function(e,t){return s(o(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return s(o(e.toArray(),t))},"Array, Matrix":function(e,t){return s(o(e,t.toArray()))},"Array, Array":o});return f.toTex={2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},f}var i=r(8);t.name="cross",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(e,t,r,n){if(!a(t))throw new TypeError("Second parameter in function diag must be an integer");var i=t>0?t:0,o=t<0?-t:0;switch(r.length){case 1:return u(e,t,n,r[0],o,i);case 2:return c(e,t,n,r,o,i)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function u(t,r,n,i,a,o){var s=[i+a,i+o],u=e.Matrix.storage(n||"dense"),c=u.diagonal(s,t,r);return null!==n?c:c.valueOf()}function c(e,t,r,n,i,a){if(e&&e.isMatrix===!0){var o=e.diagonal(t);return null!==r?r!==o.storage()?f(o,r):o:o.valueOf()}for(var s=Math.min(n[0]-i,n[1]-a),u=[],c=0;c2||i(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=[],n=[];return e.map(function(e){return t.map(function(t){return e.map(function(e){return t.map(function(t){return n.push(u(e,t))})},r.push(n=[]))})},r=[])&&r}var s=n(r(2)),u=n(r(21)),c=a("kron",{"Matrix, Matrix":function(e,t){return s(o(e.toArray(),t.toArray()))},"Matrix, Array":function(e,t){return s(o(e.toArray(),t))},"Array, Matrix":function(e,t){return s(o(e,t.toArray()))},"Array, Array":o});return c}var i=r(8).size;t.name="kron",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function s(t,r){var n=u(t),i=n?new e.BigNumber(1):1;if(c(t),r){var o=f(r);return t.length>0?o.resize(t,i):o}var s=[];return t.length>0?a(s,t,i):s}function u(e){var t=!1;return e.forEach(function(e,r,n){e&&e.isBigNumber===!0&&(t=!0,n[r]=e.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||e<0)throw new Error("Parameters in function ones must be positive integers")})}var f=n(r(2)),l=o("ones",{"":function(){return"Array"===t.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var r=e[e.length-1];if("string"==typeof r){var n=e.pop();return s(e,n)}return"Array"===t.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var t=e.storage();return s(e.valueOf(),t)},"Array | Matrix, string":function(e,t){return s(e.valueOf(),t)}});return l.toTex=void 0,l}var i=r(3).isInteger,a=r(8).resize;t.name="ones",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){function l(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 i(t.length,1);var n=t[0];if("number"!=typeof n||!o(n))throw new TypeError("Invalid size, must contain positive integers (size: "+s(t)+")");if(e.length>n)return e.substring(0,n);if(e.length1)throw new Error("first object must be one dimensional");if(n>1)throw new Error("second object must be one dimensional");if(r!==n)throw new Error("Length of two vectors must be equal");var i=u(e);if(0===i)throw new Error("Sum of elements in first object must be non zero");var a=u(t);if(0===a)throw new Error("Sum of elements in second object must be non zero");var o=s(e,u(e)),h=s(t,u(t)),m=u(c(o,l(f(o,h))));return p(m)?m:Number.NaN}var o=n(r(2)),s=n(r(35)),u=n(r(121)),c=n(r(11)),f=n(r(103)),l=n(r(105)),p=n(r(73)),h=i("kldivergence",{"Array, Array":function(e,t){return a(o(e),o(t))},"Matrix, Array":function(e,t){return a(e,o(t))},"Array, Matrix":function(e,t){return a(o(e),t)},"Matrix, Matrix":function(e,t){return a(e,t)}});return h}t.name="kldivergence",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=n(r(16)),s=n(r(11)),u=n(r(35)),c=n(r(55)),f=n(r(40)),l=n(r(56));return a("multinomial",{"Array | Matrix":function(e){var t=0,r=1;return i(e,function(e){if(!f(e)||!l(e))throw new TypeError("Positive integer value expected in function multinomial");t=o(t,e),r=s(r,c(e))}),u(c(t),r)}})}var i=r(33);t.name="multinomial",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var s=n(r(55)),u=o("permutations",{"number | BigNumber":s,"number, number":function(e,t){var r,n;if(!a(e)||e<0)throw new TypeError("Positive integer value expected in function permutations");if(!a(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");for(r=1,n=e-t+1;n<=e;n++)r*=n;return r},"BigNumber, BigNumber":function(t,r){var n,a;if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(t))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=new e.BigNumber(1),a=t.minus(r).plus(1);a.lte(t);a=a.plus(1))n=n.times(a);return n}});return u.toTex=void 0,u}function i(e){return e.isInteger()&&e.gte(0)}var a=r(3).isInteger;t.name="permutations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(71)),o=a("uniform").pickRandom;return o.toTex=void 0,o}t.name="pickRandom",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(71)),o=a("uniform").random;return o.toTex=void 0,o}t.name="random",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(71)),o=a("uniform").randomInt;return o.toTex=void 0,o}t.name="randomInt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var r=e.length;if(r!==t.length)return!1;for(var n=0;n=f?a(e):t<=o?a(e)*l(t):t<=4?a(e)*(1-p(t)):a(e)*(1-h(t))},BigNumber:function(t){return new e.BigNumber(m(t.toNumber()))},"Array | Matrix":function(e){return i(e,m)}});return m.toTex={1:"erf\\left(${args[0]}\\right)"},m}var i=r(1),a=r(3).sign,o=.46875,s=.5641895835477563,u=[[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]],c=[[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]],f=Math.pow(2,53);t.name="erf",t.factory=n},function(e,t,r){e.exports=[r(434)]},function(e,t,r){e.exports=[r(437),r(117),r(118),r(119),r(120),r(438),r(439),r(440),r(441),r(121),r(122)]},function(e,t,r){"use strict";function n(e,t,n,a){function o(e){if(e=i(e.valueOf()),0===e.length)throw new Error("Cannot calculate median absolute deviation of an empty array");var t=c(e);return c(u(e,function(e){return s(f(e,t))}))}var s=n(r(26)),u=n(r(69)),c=n(r(119)),f=n(r(19)),l=a("mad",{"Array | Matrix":o,"...":function(e){return o(e)}});return l.toTex=void 0,l}var i=r(8).flatten;t.name="mad",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function a(e){e=i(e.valueOf());var t=e.length;if(0==t)throw new Error("Cannot calculate mode of an empty array");var r={},n=[],a=0;for(var o in e)e[o]in r||(r[e[o]]=0),r[e[o]]++,r[e[o]]==a?n.push(e[o]):r[e[o]]>a&&(a=r[e[o]],n=[e[o]]);return n}var o=n("mode",{"Array | Matrix":a,"...":function(e){return a(e)}});return o}var i=r(8).flatten;t.name="mode",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function o(e){var t=void 0;if(i(e,function(e){t=void 0===t?e:s(t,e)}),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}var s=n(r(21)),u=a("prod",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(e){return o(e)}});return u.toTex=void 0,u}var i=r(33);t.name="prod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,u){function c(t,r,n){var o,u,c;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(s(t)){if(n=n||!1,"boolean"==typeof n){if(u=t.valueOf(),a(r)){if(r<0)throw new Error("N/prob must be non-negative");if(r<=1)return f(u,r,n);if(r>1){if(!i(r))throw new Error("N must be a positive integer");var l=r+1;o=new Array(r);for(var p=0;p4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");var l=new e.BigNumber(h+1);o=new Array(h);for(var p=0;p1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!m||!m.isBigNumber)throw new TypeError("Unexpected type of argument in function quantileSeq");if(c=new m.constructor(1),m.isNegative()||m.gt(c))throw new Error("Probability must be between 0 and 1, inclusive")}o[p]=f(u,m,n)}return o}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 f(e,t,r){var n=o(e),i=n.length;if(0===i)throw new Error("Cannot calculate quantile of an empty sequence");if(a(t)){var s=t*(i-1),u=s%1;if(0===u){var c=r?n[s]:h(n,s);return d(c),c}var f,g,v=Math.floor(s);if(r)f=n[v],g=n[v+1];else{g=h(n,v+1),f=n[v];for(var y=0;y0&&(f=n[y])}return d(f),d(g),l(p(f,1-u),p(g,u))}var s=t.times(i-1);if(s.isInteger()){s=s.toNumber();var c=r?n[s]:h(n,s);return d(c),c}var f,g,v=s.floor(),u=s.minus(v),x=v.toNumber();if(r)f=n[x],g=n[x+1];else{g=h(n,x+1),f=n[x];for(var y=0;y0&&(f=n[y])}d(f),d(g);var w=new u.constructor(1);return l(p(f,w.minus(u)),p(g,u))}var l=n(r(16)),p=n(r(11)),h=n(r(70)),m=n(r(47)),d=u({"number | BigNumber | Unit":function(e){return e}});return c}var i=r(3).isInteger,a=r(3).isNumber,o=r(8).flatten,s=r(41);t.name="quantileSeq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function a(e,t){if(0==e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(s.apply(null,arguments))}var o=n(r(51)),s=n(r(122)),u=i("std",{"Array | Matrix":a,"Array | Matrix, string":a,"...":function(e){return a(e)}});return u.toTex=void 0,u}t.name="std",t.factory=n},function(e,t,r){e.exports=[r(123),r(443)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("print",{"string, Object":i,"string, Object, number | Object":i});return a.toTex=void 0,a}function i(e,t,r){return e.replace(/\$([\w\.]+)/g,function(e,n){for(var i=n.split("."),s=t[i.shift()];i.length&&void 0!==s;){var u=i.shift();s=u?s[u]:s+"."}return void 0!==s?a(s)?s:o(s,r):e})}var a=r(20).isString,o=r(20).format;t.name="print",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acos",{number:function(r){return r>=-1&&r<=1||t.predictable?Math.acos(r):new e.Complex(r,0).acos()},Complex:function(e){return e.acos()},BigNumber:function(e){return e.acos()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cos^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acos",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acot",{number:function(e){return Math.atan(1/e)},Complex:function(e){return e.acot()},BigNumber:function(t){return new e.BigNumber(1).div(t).atan()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cot^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acot",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acoth",{number:function(r){return r>=1||r<=-1||t.predictable?isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0:new e.Complex(r,0).acoth()},Complex:function(e){return e.acoth()},BigNumber:function(t){return new e.BigNumber(1).div(t).atanh()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\coth^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acoth",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acsc",{number:function(r){return r<=-1||r>=1||t.predictable?Math.asin(1/r):new e.Complex(r,0).acsc()},Complex:function(e){return e.acsc()},BigNumber:function(t){return new e.BigNumber(1).div(t).asin()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\csc^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acsc",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("acsch",{number:function(e){return e=1/e,Math.log(e+Math.sqrt(e*e+1))},Complex:function(e){return e.acsch()},BigNumber:function(t){return new e.BigNumber(1).div(t).asinh()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={ +1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="acsch",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asec",{number:function(r){return r<=-1||r>=1||t.predictable?Math.acos(1/r):new e.Complex(r,0).asec()},Complex:function(e){return e.asec()},BigNumber:function(t){return new e.BigNumber(1).div(t).acos()},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\sec^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asec",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var o=(a.find(n(r(124)),["Complex"]),a("asech",{number:function(r){if(r<=1&&r>=-1||t.predictable){r=1/r;var n=Math.sqrt(r*r-1);return r>0||t.predictable?Math.log(n+r):new e.Complex(Math.log(n-r),Math.PI)}return new e.Complex(r,0).asech()},Complex:function(e){return e.asech()},BigNumber:function(t){return new e.BigNumber(1).div(t).acosh()},"Array | Matrix":function(e){return i(e,o)}}));return o.toTex={1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},o}var i=r(1);t.name="asech",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asin",{number:function(r){return r>=-1&&r<=1||t.predictable?Math.asin(r):new e.Complex(r,0).asin()},Complex:function(e){return e.asin()},BigNumber:function(e){return e.asin()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sin^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asin",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("asinh",{number:Math.asinh||function(e){return Math.log(Math.sqrt(e*e+1)+e)},Complex:function(e){return e.asinh()},BigNumber:function(e){return e.asinh()},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sinh^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="asinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("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 i(e,a,!0)}});return a.toTex={1:"\\tan^{-1}\\left(${args[0]}\\right)"},a}var i=r(1);t.name="atan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(2)),o=n(r(22)),s=n(r(13)),u=n(r(131)),c=n(r(14)),f=n(r(15)),l=n(r(7)),p=n(r(6)),h=i("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(t,r){return e.BigNumber.atan2(t,r)},"Matrix, Matrix":function(e,t){var r;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":r=u(e,t,h,!1);break;default:r=o(t,e,h,!0)}break;default:switch(t.storage()){case"sparse":r=s(e,t,h,!1);break;default:r=l(e,t,h)}}return r},"Array, Array":function(e,t){return h(a(e),a(t)).valueOf()},"Array, Matrix":function(e,t){return h(a(e),t)},"Matrix, Array":function(e,t){return h(e,a(t))},"Matrix, number | BigNumber":function(e,t){var r;switch(e.storage()){case"sparse":r=c(e,t,h,!1);break;default:r=p(e,t,h,!1)}return r},"number | BigNumber, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=f(t,e,h,!0);break;default:r=p(t,e,h,!0)}return r},"Array, number | BigNumber":function(e,t){return p(a(e),t,h,!1).valueOf()},"number | BigNumber, Array":function(e,t){return p(a(t),e,h,!0).valueOf()}});return h.toTex={2:"\\mathrm{atan2}\\left(${args}\\right)"},h}t.name="atan2",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("atanh",{number:function(r){return r<=1&&r>=-1||t.predictable?a(r):new e.Complex(r,0).atanh()},Complex:function(e){return e.atanh()},BigNumber:function(e){return e.atanh()},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\tanh^{-1}\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.atanh||function(e){return Math.log((1+e)/(1-e))/2};t.name="atanh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("cos",{number:Math.cos,Complex:function(e){return e.cos()},BigNumber:function(e){return e.cos()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cos\\left(${args[0]}\\right)"},a}var i=r(1);t.name="cos",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("cosh",{number:a,Complex:function(e){return e.cosh()},BigNumber:function(e){return e.cosh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o)}});return o.toTex={1:"\\cosh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.cosh||function(e){return(Math.exp(e)+Math.exp(-e))/2};t.name="cosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("cot",{number:function(e){return 1/Math.tan(e)},Complex:function(e){return e.cot()},BigNumber:function(t){return new e.BigNumber(1).div(t.tan())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\cot\\left(${args[0]}\\right)"},a}var i=r(1);t.name="cot",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("coth",{number:i,Complex:function(e){return e.coth()},BigNumber:function(t){return new e.BigNumber(1).div(t.tanh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\coth\\left(${args[0]}\\right)"},o}function i(e){var t=Math.exp(2*e);return(t+1)/(t-1)}var a=r(1);t.name="coth",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("csc",{number:function(e){return 1/Math.sin(e)},Complex:function(e){return e.csc()},BigNumber:function(t){return new e.BigNumber(1).div(t.sin())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\csc\\left(${args[0]}\\right)"},a}var i=r(1);t.name="csc",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("csch",{number:i,Complex:function(e){return e.csch()},BigNumber:function(t){return new e.BigNumber(1).div(t.sinh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\mathrm{csch}\\left(${args[0]}\\right)"},o}function i(e){return 0==e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*o(e)}var a=r(1),o=r(3).sign;t.name="csch",t.factory=n},function(e,t,r){e.exports=[r(444),r(124),r(445),r(446),r(447),r(448),r(449),r(450),r(451),r(452),r(453),r(454),r(455),r(456),r(457),r(458),r(459),r(460),r(461),r(463),r(464),r(465),r(466),r(467),r(468)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("sec",{number:function(e){return 1/Math.cos(e)},Complex:function(e){return e.sec()},BigNumber:function(t){return new e.BigNumber(1).div(t.cos())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\sec\\left(${args[0]}\\right)"},a}var i=r(1);t.name="sec",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sech",{number:i,Complex:function(e){return e.sech()},BigNumber:function(t){return new e.BigNumber(1).div(t.cosh())},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return o(t.value)},"Array | Matrix":function(e){return a(e,o)}});return o.toTex={1:"\\mathrm{sech}\\left(${args[0]}\\right)"},o}function i(e){return 2/(Math.exp(e)+Math.exp(-e))}var a=r(1);t.name="sech",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("sin",{number:Math.sin,Complex:function(e){return e.sin()},BigNumber:function(e){return e.sin()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\sin\\left(${args[0]}\\right)"},a}var i=r(1);t.name="sin",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("sinh",{number:a,Complex:function(e){return e.sinh()},BigNumber:function(e){return e.sinh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\sinh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.sinh||function(e){return(Math.exp(e)-Math.exp(-e))/2};t.name="sinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("tan",{number:Math.tan,Complex:function(e){return e.tan()},BigNumber:function(e){return e.tan()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return a(t.value)},"Array | Matrix":function(e){return i(e,a,!0)}});return a.toTex={1:"\\tan\\left(${args[0]}\\right)"},a}var i=r(1);t.name="tan",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("tanh",{number:a,Complex:function(e){return e.tanh()},BigNumber:function(e){return e.tanh()},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return o(t.value)},"Array | Matrix":function(e){return i(e,o,!0)}});return o.toTex={1:"\\tanh\\left(${args[0]}\\right)"},o}var i=r(1),a=Math.tanh||function(e){var t=Math.exp(2*e);return(t-1)/(t+1)};t.name="tanh",t.factory=n},function(e,t,r){e.exports=[r(470)]},function(e,t,r){"use strict";function n(e,t,n,i){var a=r(4),o=n(r(2)),s=n(r(7)),u=n(r(6)),c=i("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Matrix, Matrix":function(e,t){return s(e,t,c)},"Array, Array":function(e,t){return c(o(e),o(t)).valueOf()},"Array, Matrix":function(e,t){return c(o(e),t)},"Matrix, Array":function(e,t){return c(e,o(t))},"Matrix, any":function(e,t){return u(e,t,c,!1)},"any, Matrix":function(e,t){return u(t,e,c,!0)},"Array, any":function(e,t){return u(o(e),t,c,!1).valueOf()},"any, Array":function(e,t){return u(o(t),e,c,!0).valueOf()}});return c.toTex={2:"\\left(${args[0]}"+a.operators.to+"${args[1]}\\right)"},c}t.name="to",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("clone",{any:i.clone});return a.toTex=void 0,a}var i=r(5);t.name="clone",t.factory=n},function(e,t,r){e.exports=[r(471),r(40),r(48),r(73),r(56),r(474),r(125),r(473),r(126)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isNaN",{number:function(e){return Number.isNaN(e)},BigNumber:function(e){return e.isNaN()},Fraction:function(e){return!1},Complex:function(e){return Number.isNaN(e.re)&&Number.isNaN(e.im)},Unit:function(e){return Number.isNaN(e.value)},"Array | Matrix":function(e){return i(e,Number.isNaN)}});return a}var i=r(1);r(3);t.name="isNaN",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("isPrime",{number:function(e){if(e<2)return!1;if(2==e)return!0;if(e%2==0)return!1;for(var t=3;t*t<=e;t+=2)if(e%t==0)return!1;return!0},BigNumber:function(t){if(t.lt(2))return!1;if(t.equals(2))return!0;if(t.mod(2).isZero())return!1;for(var r=e.BigNumber(3);r.times(r).lte(t);r=r.plus(1))if(t.mod(r).isZero())return!1;return!0},"Array | Matrix":function(e){return i(e,a)}});return a}var i=r(1);t.name="isPrime",t.factory=n},function(e,t,r){e.exports=[r(489),r(144),r(334),r(407),r(476),r(149)]},function(e,t,r){e.exports=[r(477)]},function(e,t){"use strict";function r(e,t,r,n){return function(t,r){var n=e[r&&r.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(r):r}}t.name="reviver",t.path="json",t.factory=r},function(e,t,r){function n(e,t,r,n,a){var o=i.clone({precision:t.precision});return o.prototype.type="BigNumber",o.prototype.isBigNumber=!0,o.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},o.fromJSON=function(e){return new o(e.value)},a.on("config",function(e,t){e.precision!==t.precision&&o.config({precision:e.precision})}),o}var i=r(141);t.name="BigNumber",t.path="type",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("bignumber",{"":function(){return new e.BigNumber(0)},number:function(t){return new e.BigNumber(t+"")},string:function(t){return new e.BigNumber(t)},BigNumber:function(e){return e},Fraction:function(t){return new e.BigNumber(t.n).div(t.d)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={0:"0",1:"\\left(${args[0]}\\right)"},a}var i=r(1);t.name="bignumber",t.factory=n},function(e,t,r){e.exports=[r(478),r(479)]},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("bool",{"":function(){return!1},boolean:function(e){return e},number:function(e){return!!e},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 i(e,a)}});return a}var i=r(1);t.name="boolean",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");e&&e.isChain?this.value=e.value:this.value=e}function u(e,t){"function"==typeof t&&(s.prototype[e]=f(t))}function c(e,t){a(s.prototype,e,function(){var e=t();if("function"==typeof e)return f(e)})}function f(e){return function(){for(var t=[this.value],r=0;r0;){var i=n.right;n.left.right=n.right,n.right.left=n.left,n.left=t,n.right=t.right,t.right=n,n.right.left=n,n.parent=null,n=i,r--}return e.left.right=e.right,e.right.left=e.left,e==e.right?t=null:(t=e.right,t=h(t,this._size)),this._size--,this._minimum=t,e},a.prototype.remove=function(e){this._minimum=c(this._minimum,e,-1),this.extractMinimum()};var c=function(e,t,r){t.key=r;var n=t.parent;return n&&o(t.key,n.key)&&(f(e,t,n),l(e,n)),o(t.key,e.key)&&(e=t),e},f=function(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},l=function(e,t){var r=t.parent;r&&(t.mark?(f(e,t,r),l(r)):t.mark=!0)},p=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1},h=function(e,t){var r=Math.floor(Math.log(t)*u)+1,n=new Array(r),i=0,a=e;if(a)for(i++,a=a.right;a!==e;)i++,a=a.right;for(var c;i>0;){for(var f=a.degree,l=a.right;;){if(c=n[f],!c)break;if(s(a.key,c.key)){var h=c;c=a,a=h}p(c,a),n[f]=null,f++}n[f]=a,a=l,i--}e=null;for(var m=0;m=e&&(o(s.value,0)||r(s.key,s.value,this)),s=n.extractMinimum(),s&&a.push(s);for(var u=0;u0){var s=0;do{e._ptr.push(e._index.length);for(var u=0;u");for(var p=t.min()[0],h=t.min()[1],m=i[0],d=i[1],g=0;go-1||i>s-1)&&(O(this,Math.max(n+1,o),Math.max(i+1,s),r),o=this._size[0],s=this._size[1]),m(n,o),m(i,s);var l=E(n,this._ptr[i],this._ptr[i+1],this._index);return lp){for(u=p;ul){if(f){var m=0;for(u=0;ut-1&&(e._values.splice(c,1),e._index.splice(c,1),v++)}e._ptr[u]=e._values.length}return e._size[0]=t,e._size[1]=r,e};g.prototype.clone=function(){var e=new g({values:this._values?s.clone(this._values):void 0,index:s.clone(this._index),ptr:s.clone(this._ptr),size:s.clone(this._size),datatype:this._datatype});return e},g.prototype.size=function(){return this._size.slice(0)},g.prototype.map=function(e,t){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var r=this,n=this._size[0],i=this._size[1],a=function(t,n,i){return e(t,[n,i],r)};return _(this,0,n-1,0,i-1,a,t)};var _=function(e,t,r,n,i,a,o){var s=[],u=[],c=[],f=y,l=0;h(e._datatype)&&(f=d.find(y,[e._datatype,e._datatype])||y,l=d.convert(0,e._datatype));for(var p=function(e,t,r){e=a(e,t,r),f(e,l)||(s.push(e),u.push(t))},m=n;m<=i;m++){c.push(s.length);for(var v=e._ptr[m],x=e._ptr[m+1],w=t,b=v;b=t&&N<=r){if(!o)for(var E=w;E "+(this._values?u.format(this._values[c],e):"X")}return i},g.prototype.toString=function(){return u.format(this.toArray())},g.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index, +ptr:this._ptr,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(e){if(e){if(e.isBigNumber===!0&&(e=e.toNumber()),!l(e)||!p(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],i=this._size[1],a=Math.min(n-r,i-t),o=[],s=[],u=[];u[0]=0;for(var c=t;c0?r:0,c=r<0?-r:0,m=e[0],v=e[1],x=Math.min(m-c,v-u);if(f(t)){if(t.length!==x)throw new Error("Invalid value array length");s=function(e){return t[e]}}else if(t&&t.isMatrix===!0){var w=t.size();if(1!==w.length||w[0]!==x)throw new Error("Invalid matrix length");s=function(e){return t.get([e])}}else s=function(){return t};for(var b=[],N=[],E=[],M=0;M=0&&A=u||i[f]!==t)){var p=n?n[c]:void 0;i.splice(f,0,t),n&&n.splice(f,0,p),i.splice(f<=c?c+1:c,1),n&&n.splice(f<=c?c+1:c,1)}else if(f=u||i[c]!==e)){var h=n?n[f]:void 0;i.splice(c,0,e),n&&n.splice(c,0,h),i.splice(c<=f?f+1:f,1),n&&n.splice(c<=f?f+1:f,1)}}},e.Matrix._storage.sparse=g,g}var i=r(24),a=r(10),o=i.array,s=i.object,u=i.string,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,h=u.isString,m=o.validateIndex;t.name="SparseMatrix",t.path="type",t.factory=n,t.lazy=!1},function(e,t){"use strict";function r(e,t,r,n){return n("index",{"...number | string | BigNumber | Range | Array | Matrix":function(t){var r=t.map(function(e){return e&&e.isBigNumber===!0?e.toNumber():e&&(Array.isArray(e)||e.isMatrix===!0)?e.map(function(e){return e&&e.isBigNumber===!0?e.toNumber():e}):e}),n=new e.Index;return e.Index.apply(n,r),n}})}t.name="index",t.factory=r},function(e,t){"use strict";function r(e,t,r,n){var i=e.SparseMatrix,a=n("sparse",{"":function(){return new i([])},string:function(e){return new i([],e)},"Array | Matrix":function(e){return new i(e)},"Array | Matrix, string":function(e,t){return new i(e,t)}});return a.toTex={0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},a}t.name="sparse",t.factory=r},function(e,t,r){e.exports=[r(74),r(129),r(494),r(493),r(490),r(491),r(492),r(130),r(495),r(2),r(496)]},function(e,t,r){e.exports=[r(132)]},function(e,t,r){"use strict";function n(e,t,r,n){var o=n("string",{"":function(){return""},number:a.format,null:function(e){return"null"},boolean:function(e){return e+""},string:function(e){return e},"Array | Matrix":function(e){return i(e,o)},any:function(e){return String(e)}});return o.toTex={0:'\\mathtt{""}',1:"\\mathrm{string}\\left(${args[0]}\\right)"},o}var i=r(1),a=r(3);t.name="string",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("createUnit",{"Object, Object":function(t,r){return e.Unit.createUnit(t,r)},Object:function(t){return e.Unit.createUnit(t,{})},"string, Unit | string | Object, Object":function(t,r,n){var i={};return i[t]=r,e.Unit.createUnit(i,n)},"string, Unit | string | Object":function(t,r){var n={};return n[t]=r,e.Unit.createUnit(n,{})},string:function(t){var r={};return r[t]={},e.Unit.createUnit(r,{})}});return i}r(1);t.name="createUnit",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("splitUnit",{"Unit, Array":function(e,t){return e.splitUnit(t)}});return i}r(1);t.name="splitUnit",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var a=n("unit",{Unit:function(e){return e.clone()},string:function(t){return e.Unit.isValuelessUnit(t)?new e.Unit(null,t):e.Unit.parse(t)},"number | BigNumber | Fraction | Complex, string":function(t,r){return new e.Unit(t,r)},"Array | Matrix":function(e){return i(e,a)}});return a.toTex={1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},a}var i=r(1);t.name="unit",t.factory=n},function(e,t,r){e.exports=[r(133),r(502),r(500),r(501),r(504)]},function(e,t,r){function n(e,t,r,n,a){function o(t){var r=e.Unit.parse(t);return r.fixPrefix=!0,r}i(a,"speedOfLight",function(){return o("299792458 m s^-1")}),i(a,"gravitationConstant",function(){return o("6.6738480e-11 m^3 kg^-1 s^-2")}),i(a,"planckConstant",function(){return o("6.626069311e-34 J s")}),i(a,"reducedPlanckConstant",function(){return o("1.05457172647e-34 J s")}),i(a,"magneticConstant",function(){return o("1.2566370614e-6 N A^-2")}),i(a,"electricConstant",function(){return o("8.854187817e-12 F m^-1")}),i(a,"vacuumImpedance",function(){return o("376.730313461 ohm")}),i(a,"coulomb",function(){return o("8.9875517873681764e9 N m^2 C^-2")}),i(a,"elementaryCharge",function(){return o("1.60217656535e-19 C")}),i(a,"bohrMagneton",function(){return o("9.2740096820e-24 J T^-1")}),i(a,"conductanceQuantum",function(){return o("7.748091734625e-5 S")}),i(a,"inverseConductanceQuantum",function(){return o("12906.403721742 ohm")}),i(a,"magneticFluxQuantum",function(){return o("2.06783375846e-15 Wb")}),i(a,"nuclearMagneton",function(){return o("5.0507835311e-27 J T^-1")}),i(a,"klitzing",function(){return o("25812.807443484 ohm")}),i(a,"bohrRadius",function(){return o("5.291772109217e-11 m")}),i(a,"classicalElectronRadius",function(){return o("2.817940326727e-15 m")}),i(a,"electronMass",function(){return o("9.1093829140e-31 kg")}),i(a,"fermiCoupling",function(){return o("1.1663645e-5 GeV^-2")}),i(a,"fineStructure",function(){return.007297352569824}),i(a,"hartreeEnergy",function(){return o("4.3597443419e-18 J")}),i(a,"protonMass",function(){return o("1.67262177774e-27 kg")}),i(a,"deuteronMass",function(){return o("3.3435830926e-27 kg")}),i(a,"neutronMass",function(){return o("1.6749271613e-27 kg")}),i(a,"quantumOfCirculation",function(){return o("3.636947552024e-4 m^2 s^-1")}),i(a,"rydberg",function(){return o("10973731.56853955 m^-1")}),i(a,"thomsonCrossSection",function(){return o("6.65245873413e-29 m^2")}),i(a,"weakMixingAngle",function(){return.222321}),i(a,"efimovFactor",function(){return 22.7}),i(a,"atomicMass",function(){return o("1.66053892173e-27 kg")}),i(a,"avogadro",function(){return o("6.0221412927e23 mol^-1")}),i(a,"boltzmann",function(){return o("1.380648813e-23 J K^-1")}),i(a,"faraday",function(){return o("96485.336521 C mol^-1")}),i(a,"firstRadiation",function(){return o("3.7417715317e-16 W m^2")}),i(a,"loschmidt",function(){return o("2.686780524e25 m^-3")}),i(a,"gasConstant",function(){return o("8.314462175 J K^-1 mol^-1")}),i(a,"molarPlanckConstant",function(){return o("3.990312717628e-10 J s mol^-1")}),i(a,"molarVolume",function(){return o("2.241396820e-10 m^3 mol^-1")}),i(a,"sackurTetrode",function(){return-1.164870823}),i(a,"secondRadiation",function(){return o("1.438777013e-2 m K")}),i(a,"stefanBoltzmann",function(){return o("5.67037321e-8 W m^-2 K^-4")}),i(a,"wienDisplacement",function(){return o("2.897772126e-3 m K")}),i(a,"molarMass",function(){return o("1e-3 kg mol^-1")}),i(a,"molarMassC12",function(){return o("1.2e-2 kg mol^-1")}),i(a,"gravity",function(){return o("9.80665 m s^-2")}),i(a,"planckLength",function(){return o("1.61619997e-35 m")}),i(a,"planckMass",function(){return o("2.1765113e-8 kg")}),i(a,"planckTime",function(){return o("5.3910632e-44 s")}),i(a,"planckCharge",function(){return o("1.87554595641e-18 C")}),i(a,"planckTemperature",function(){return o("1.41683385e+32 K")})}var i=r(5).lazy;t.factory=n,t.lazy=!1,t.math=!0},function(e,t){"use strict";function r(e){var t=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number");var r=t[1],n=t[2],i=parseFloat(t[4]||"0"),a=n.indexOf(".");i+=a!==-1?a-1:n.length-1,this.sign=r,this.coefficients=n.replace(".","").replace(/^0*/,function(e){return i-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)}),0===this.coefficients.length&&(this.coefficients.push(0),i++),this.exponent=i}function n(e){for(var t=[],r=0;r=0?r:Math.abs(a);i.length-1=0;)u++;var f=i.slice(u).join(""),l=f.match(/[1-9]/)?"."+f:"";return c=i.slice(0,u).join("")+l,c+="e"+(r>=0?"+":"")+a.toString(),t.sign+c},r.prototype.toFixed=function(e){var t=this.roundDigits(this.exponent+1+(e||0)),r=t.coefficients,i=t.exponent+1,a=i+(e||0);return r.length0?"."+r.join(""):"")+"e"+(i>=0?"+":"")+i},r.prototype.toPrecision=function(e,t){var r=t&&void 0!==t.lower?t.lower:.001,i=t&&void 0!==t.upper?t.upper:1e5,a=Math.abs(Math.pow(10,this.exponent));if(a=i)return this.toExponential(e);var o=e?this.roundDigits(e):this.clone(),s=o.coefficients,u=o.exponent;s.length0?u:0;return ce){var n=r.splice(e,r.length-e);if(n[0]>=5){var i=e-1;for(r[i]++;10===r[i];)r.pop(),0===i&&(r.unshift(0),t.exponent++,i++),i--,r[i]++}}return t},e.exports=r},function(e,t,r){var n=r(79);e.exports=function(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 n(e,t,function(e,t){return e&t})}},function(e,t,r){var n=r(79);e.exports=function(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 i=new r(-1);return e.isZero()||t.eq(i)||e.eq(t)?t:t.isZero()||e.eq(i)?e:e.isFinite()&&t.isFinite()?n(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?i:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e}},function(e,t,r){var n=r(79),i=r(78);e.exports=function(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 a=new r(-1);return e.eq(a)?i(t):t.eq(a)?i(e):e.isFinite()&&t.isFinite()?n(e,t,function(e,t){return e^t}):e.isFinite()||t.isFinite()?new r(e.isNegative()==t.isNegative()?1/0:-(1/0)):a}},function(e,t){t.format=function(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n="auto",i=void 0;switch(void 0!==r&&(r.notation&&(n=r.notation),"number"==typeof r?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"auto":var a=.001,o=1e5;r&&r.exponential&&(void 0!==r.exponential.lower&&(a=r.exponential.lower),void 0!==r.exponential.upper&&(o=r.exponential.upper));({toExpNeg:e.constructor.toExpNeg,toExpPos:e.constructor.toExpPos});if(e.constructor.config({toExpNeg:Math.round(Math.log(a)/Math.LN10),toExpPos:Math.round(Math.log(o)/Math.LN10)}),e.isZero())return"0";var s,u=e.abs();return s=u.gte(a)&&u.lt(o)?e.toSignificantDigits(i).toFixed():t.toExponential(e,i),s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()},t.toFixed=function(e,t){return e.toFixed(t||0)}},function(e,t){e.exports=function(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(e,t){e.exports=function(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():new r(e.isNegative()?-1:e.isFinite()?0:NaN)}},function(e,t){"use strict";t.isBoolean=function(e){return"boolean"==typeof e}},function(e,t){"use strict";e.exports=function(e,t,r,n,i,a,o,s,u,c,f){var l,p,h,m,d=e._values,g=e._index,v=e._ptr,y=o._index;if(n)for(p=v[t],h=v[t+1],l=p;l1)for(var r=1;rr&&!c?"Unexpected type of argument in function "+u+" (expected: "+s.join(" or ")+", actual: "+o+", index: "+r+")":"Too few arguments in function "+u+" (expected: "+s.join(" or ")+", index: "+r+")":"Too many arguments in function "+u+" (expected: "+r+", actual: "+t+")";var l=new TypeError(a);return l.data=f,l}function i(e){this.name=e||"refs",this.categories={}}function a(e,t){if("string"==typeof e){var r=e.trim(),n="..."===r.substr(0,3);if(n&&(r=r.substr(3)),""===r)this.types=["any"];else{this.types=r.split("|");for(var i=0;it&&(t=n)}return t}function d(e){for(var t,r=0;r0},a.prototype.contains=function(e){for(var t=0;tt.params.length)return 1;if(e.params.lengtho)return 1;if(i "+i+") {"),n.push(r+" var varArgs = [];"),n.push(r+" for (var i = "+i+"; i < arguments.length; i++) {"),n.push(r+" varArgs.push(arguments[i]);"),n.push(r+" }"),n.push(this.signature.toCode(e,r+" ")),n.push(r+"}");else{for(var s=function(r,n){for(var i=[],a=0;a "+r+") {",t+" throw createError(name, arguments.length, "+r+", arguments["+r+"]);",t+"}"].join("\n");for(var n={},i=[],a=0;a=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(r)?n.showHidden=r:r&&t._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=a),u(n,e,n.depth)}function a(e,t){var r=i.styles[t];return r?"["+i.colors[r][0]+"m"+e+"["+i.colors[r][1]+"m":e}function o(e,t){return e}function s(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function u(e,r,n){if(e.customInspect&&r&&O(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return x(i)||(i=u(e,i,n)),i}var a=c(e,r);if(a)return a;var o=Object.keys(r),d=s(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(r)),A(r)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return f(r);if(0===o.length){if(O(r)){var g=r.name?": "+r.name:"";return e.stylize("[Function"+g+"]","special")}if(N(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(M(r))return e.stylize(Date.prototype.toString.call(r),"date"); +if(A(r))return f(r)}var v="",y=!1,w=["{","}"];if(m(r)&&(y=!0,w=["[","]"]),O(r)){var b=r.name?": "+r.name:"";v=" [Function"+b+"]"}if(N(r)&&(v=" "+RegExp.prototype.toString.call(r)),M(r)&&(v=" "+Date.prototype.toUTCString.call(r)),A(r)&&(v=" "+f(r)),0===o.length&&(!y||0==r.length))return w[0]+v+w[1];if(n<0)return N(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special");e.seen.push(r);var E;return E=y?l(e,r,n,d,o):o.map(function(t){return p(e,r,n,d,t,y)}),e.seen.pop(),h(E,v,w)}function c(e,t){if(b(t))return e.stylize("undefined","undefined");if(x(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return y(t)?e.stylize(""+t,"number"):d(t)?e.stylize(""+t,"boolean"):g(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,r,n,i){for(var a=[],o=0,s=t.length;o-1&&(s=a?s.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+s.split("\n").map(function(e){return" "+e}).join("\n"))):s=e.stylize("[Circular]","special")),b(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(""+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=e.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=e.stylize(o,"string"))}return o+": "+s}function h(e,t,r){var n=0,i=e.reduce(function(e,t){return n++,t.indexOf("\n")>=0&&n++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function m(e){return Array.isArray(e)}function d(e){return"boolean"==typeof e}function g(e){return null===e}function v(e){return null==e}function y(e){return"number"==typeof e}function x(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function b(e){return void 0===e}function N(e){return E(e)&&"[object RegExp]"===T(e)}function E(e){return"object"==typeof e&&null!==e}function M(e){return E(e)&&"[object Date]"===T(e)}function A(e){return E(e)&&("[object Error]"===T(e)||e instanceof Error)}function O(e){return"function"==typeof e}function _(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function T(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}function S(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function z(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var k=/%[sdj%]/g;t.format=function(e){if(!x(e)){for(var t=[],r=0;r=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),s=n[r];r= 1 as expected.")}function i(e,t){var r=Object.keys(e),i=r.map(function(t){return e[t]});return n(r,i,t)}function a(e,t,r){if("function"==typeof r&&(r={rand:r}),null==r&&(r={}),Array.isArray(e)){if(null==t&&(t=e.map(function(){return 1})),Array.isArray(t)){if(e.length===t.length)return n(e,t,r);throw new TypeError("Set and Weights are different sizes.")}throw new TypeError("Set is an Array, and Weights is not.")}if("object"==typeof e)return i(e,t||r);throw new TypeError("Set is not an Object, nor is it an Array.")}e.exports=a,e.exports.select=a}]); \ No newline at end of file diff --git a/docs/QuantumRegister.html b/docs/QuantumRegister.html index 53f1902..42b6c62 100644 --- a/docs/QuantumRegister.html +++ b/docs/QuantumRegister.html @@ -101,9 +101,9 @@

QuantumRegister.js

-
		this.amplitudes = math
+            
		this.amplitudes = math.matrix([math
 			.zeros(math.pow(2, numQubits))
-			.toArray();
+ .toArray()], 'sparse');
@@ -118,7 +118,7 @@

QuantumRegister.js

-
		this.amplitudes[0] = 1;
+
		this.amplitudes = math.subset(this.amplitudes, math.index(0, 0), 1);
@@ -191,6 +191,7 @@

QuantumRegister.js

this.numQubits, qubit1, qubit2); + this.amplitudes = math.multiply(this.amplitudes, gateMatrix); } } diff --git a/docs/gates.html b/docs/gates.html index fe69b9d..201465d 100644 --- a/docs/gates.html +++ b/docs/gates.html @@ -63,7 +63,8 @@

gates.js

-
const math = require('mathjs');
+
const math = require('mathjs');
+const helper = require('./helper');
@@ -203,6 +204,7 @@

gates.js

[0, i] ]; } + static get SDagger() { return math.conj( math.transpose( @@ -233,6 +235,7 @@

gates.js

[0, math.pow(math.e, (math.multiply(i, math.pi / 4)))] ]; } + static get TDagger() { return math.conj( math.transpose( @@ -248,7 +251,8 @@

gates.js

# Helper Functions # ################################################# */ static generateGate(gate, numQubits, qubit1, qubit2 = 1) { - if (gate === 'CNOT') { + if (math.typeof(gate) === 'string') { + if (gate === 'CNOT') { @@ -263,8 +267,8 @@

gates.js

-
      const control = qubit1;
-      const target = qubit2;
+
        const control = qubit1;
+        const target = qubit2;
@@ -279,8 +283,8 @@

gates.js

-
      const identity = math.eye(2);
-      const X = this.X;
+
        const identity = math.eye(2, 'sparse');
+        const X = math.matrix(this.X, 'sparse');
@@ -291,16 +295,16 @@

gates.js

-

This matrix is the ‘Control Matrix’. At the end of the gate generation, -the NaN’s positions will be evaluated to figure out if it should be a -a 0 or a 1

+

This matrix is the ‘Control Matrix’. At the end of the gate +generation, the NaN’s positions will be evaluated to figure +out if it should be a 0 or a 1

-
      const C = [
-        [NaN, 0],
-        [0, 1]
-      ];
+
        const C = math.matrix([
+          [NaN, 0],
+          [0, 1]
+        ], 'sparse');
@@ -315,16 +319,16 @@

gates.js

-
      let gateOrder = [];
-      for (let i = 1; i <= numQubits; i++) {
-        if (i === control) {
-          gateOrder.push(C);
-        } else if (i === target) {
-          gateOrder.push(X);
-        } else {
-          gateOrder.push(identity);
-        }
-      }
+
        let gateOrder = [];
+        for (let i = 1; i <= numQubits; i++) {
+          if (i === control) {
+            gateOrder.push(C);
+          } else if (i === target) {
+            gateOrder.push(X);
+          } else {
+            gateOrder.push(identity);
+          }
+        }
@@ -340,7 +344,10 @@

gates.js

-
      let newGate = gateOrder.reduce((a, b) => math.kron(a, b));
+
        let newGate = math.matrix(
+          gateOrder.reduce((a, b) => math.kron(a, b)),
+          'sparse'
+        );
@@ -351,14 +358,22 @@

gates.js

-

This needs to now be converted into an array if it is -returned from math.js as a matrix

+

Loop through the new matrix and if the NaN’s are in the +center, then replace with a 0, otherwise, replace with a 1

-
      if (math.typeof(newGate) === 'Matrix') {
-        newGate = newGate.toArray();
-      }
+
        newGate = math.map(newGate, (val, index) => {
+          if (math.isNaN(val)) {
+            if (index[0] === index[1]) {
+              return 1;
+            } else {
+              return 0;
+            }
+          } else {
+            return val;
+          }
+        });
@@ -369,22 +384,12 @@

gates.js

-

Loop through the new matrix and if the NaN’s are in the -center, then replace with a 0, otherwise, replace with a 1

+

Return the expanded gate.

-
      for (let i = 0; i < newGate.length; i++) {
-        for (let j = 0; j < newGate[i].length; j++) {
-          if (math.isNaN(newGate[i][j])) {
-            if (i === j) {
-              newGate[i][j] = 1;
-            } else {
-              newGate[i][j] = 0;
-            }
-          }
-        }
-      }
+
        return newGate;
+      } else {
@@ -395,12 +400,12 @@

gates.js

-

Return the expanded gate.

+

Put the gates here for easy access

-
      return newGate;
-    } else {
+
          const identity = math.eye(2, 'sparse');
+          const mainGate = math.matrix(this[gate], 'sparse');
@@ -411,12 +416,20 @@

gates.js

-

Put the gates here for easy access

+

Again, Turn the gate order into an array, so that it can be +reduced later.

-
      const identity = math.eye(2);
-      const mainGate = this[gate];
+
          let gateOrder = [];
+
+          for (let i = 1; i <= numQubits; i++) {
+            if (i === qubit1) {
+              gateOrder.push(mainGate);
+            } else {
+              gateOrder.push(identity);
+            }
+          }
@@ -427,20 +440,14 @@

gates.js

-

Again, Turn the gate order into an array, so that it can be -reduced later.

+

Reduce and return the expanded gate.

-
      let gateOrder = [];
-
-      for (let i = 1; i <= numQubits; i++) {
-        if (i === qubit1) {
-          gateOrder.push(mainGate);
-        } else {
-          gateOrder.push(identity);
+            
          return gateOrder.reduce((a, b) => math.kron(a, b));
         }
-      }
+ } else if (math.typeof(gate) === 'Matrix' + || math.typeof(gate) === 'Array') {
@@ -451,14 +458,112 @@

gates.js

+

This expand / generates a gate from a user inputed matrix

+ + + + + + +
  • +
    + +
    + +
    +

    Put the gates here for easy access

    + +
    + +
            const identity = math.eye(2, 'sparse');
    +        const mainGate = math.matrix(gate, 'sparse');
    + +
  • + + +
  • +
    + +
    + +
    +

    Gate must be unitary so check here

    + +
    + +
            if (!helper.isUnitary(mainGate)) {
    + +
  • + + +
  • +
    + +
    + +
    +

    It’s not unitary, throw an Error

    + +
    + +
              throw new Error('The gate supplied to generateGate is not unitary');
    +        }
    + +
  • + + +
  • +
    + +
    + +
    +

    Again, Turn the gate order into an array, so that it can be +reduced later.

    + +
    + +
            let gateOrder = [];
    +
    +        for (let i = 1; i <= numQubits; i++) {
    +          if (i === qubit1) {
    +            gateOrder.push(mainGate);
    +          } else {
    +            gateOrder.push(identity);
    +          }
    +        }
    + +
  • + + +
  • +
    + +
    + +

    Reduce and return the expanded gate.

    -
          return gateOrder.reduce((a, b) => math.kron(a, b));
    -    }
    -  }
    +            
            return gateOrder.reduce((a, b) => math.kron(a, b));
    +    }
    + +
  • + + +
  • +
    + +
    + +
    +

    Doesn’t match a default case, return an Id gate

    +
    + +
        return math.eye(math.pow(2, numQubits), 'sparse');
    +  }
     }
     
     module.exports = gates;
    diff --git a/docs/helper.html b/docs/helper.html index d8e2773..9e8e14e 100644 --- a/docs/helper.html +++ b/docs/helper.html @@ -112,10 +112,66 @@

    helper.js

      return total;
    +};
    + +
  • + + +
  • +
    + +
    + +
    +

    Checks to if a matrix is unitary. Accepts a mathjs matrix or +array, and returns true or false accordingly

    + +
    + +
    const isUnitary = (matrix) => {
    + +
  • + + +
  • +
    + +
    + +
    +

    A Square matrix is unitary if its conjugate transpose is +equal to its inverse

    + +
    + +
      const givenMatrix = math.matrix(matrix, 'sparse');
    + +
  • + + +
  • +
    + +
    + +
    +

    Check if its Square

    + +
    + +
      if ((math.size(givenMatrix))[0] !== (math.size(givenMatrix))[1]) {
    +    return false;
    +  }
    +
    +  const conjugateTranspose = math.transpose(math.conj(givenMatrix));
    +  const inverse = math.inv(givenMatrix);
    +
    +  return math.deepEqual(inverse, conjugateTranspose);
     };
     
     module.exports = {
    -  sum: sum
    +  sum: sum,
    +  isUnitary: isUnitary
     };
  • diff --git a/lib/QuantumRegister.js b/lib/QuantumRegister.js index 3f662de..7e6a04a 100644 --- a/lib/QuantumRegister.js +++ b/lib/QuantumRegister.js @@ -18,9 +18,10 @@ var Register = function () { // The number of amplitudes needed is 2^n, Where N is the number of qubits. // The math.zeros function Creates a matrix of 0s, ie. math.zeros(5) = [0, // 0, 0, 0, 0] - this.amplitudes = math.zeros(math.pow(2, numQubits)).toArray(); + this.amplitudes = math.matrix([math.zeros(math.pow(2, numQubits)).toArray()], 'sparse'); + // Set the chance of getting all Zeros to 1 - this.amplitudes[0] = 1; + this.amplitudes = math.subset(this.amplitudes, math.index(0, 0), 1); // Set the fact it has not been measured this.measured = false; } @@ -45,6 +46,7 @@ var Register = function () { // Get the gate from the generateGates function, and then multiply the // amplitude vector against it var gateMatrix = gates.generateGate(gate, this.numQubits, qubit1, qubit2); + this.amplitudes = math.multiply(this.amplitudes, gateMatrix); } } diff --git a/lib/gates.js b/lib/gates.js index a8fb8e4..d0cf8ba 100644 --- a/lib/gates.js +++ b/lib/gates.js @@ -5,6 +5,7 @@ var _createClass = function () { function defineProperties(target, props) { for function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var math = require('mathjs'); +var helper = require('./helper'); // Complex number i and -i for easy access var i = math.complex(0, 1); @@ -29,81 +30,110 @@ var gates = function () { value: function generateGate(gate, numQubits, qubit1) { var qubit2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1; - if (gate === 'CNOT') { - // Set the control and target qubits - var control = qubit1; - var target = qubit2; - - // Grab the gates now for easy access in the function - var identity = math.eye(2); - var X = this.X; - - // This matrix is the 'Control Matrix'. At the end of the gate generation, - // the NaN's positions will be evaluated to figure out if it should be a - // a 0 or a 1 - var C = [[NaN, 0], [0, 1]]; - - // Turn the gate order into an array, so that it can be reduced later. - var gateOrder = []; - for (var _i = 1; _i <= numQubits; _i++) { - if (_i === control) { - gateOrder.push(C); - } else if (_i === target) { - gateOrder.push(X); - } else { - gateOrder.push(identity); + if (math.typeof(gate) === 'string') { + if (gate === 'CNOT') { + // Set the control and target qubits + var control = qubit1; + var target = qubit2; + + // Grab the gates now for easy access in the function + var identity = math.eye(2, 'sparse'); + var X = math.matrix(this.X, 'sparse'); + + // This matrix is the 'Control Matrix'. At the end of the gate + // generation, the NaN's positions will be evaluated to figure + // out if it should be a 0 or a 1 + var C = math.matrix([[NaN, 0], [0, 1]], 'sparse'); + + // Turn the gate order into an array, so that it can be reduced later. + var gateOrder = []; + for (var _i = 1; _i <= numQubits; _i++) { + if (_i === control) { + gateOrder.push(C); + } else if (_i === target) { + gateOrder.push(X); + } else { + gateOrder.push(identity); + } } - } - - // Now the gateOrder array is taken and reduced using the - // 'Kronecker Product' - var newGate = gateOrder.reduce(function (a, b) { - return math.kron(a, b); - }); - - // This needs to now be converted into an array if it is - // returned from math.js as a matrix - if (math.typeof(newGate) === 'Matrix') { - newGate = newGate.toArray(); - } - // Loop through the new matrix and if the NaN's are in the - // center, then replace with a 0, otherwise, replace with a 1 - for (var _i2 = 0; _i2 < newGate.length; _i2++) { - for (var j = 0; j < newGate[_i2].length; j++) { - if (math.isNaN(newGate[_i2][j])) { - if (_i2 === j) { - newGate[_i2][j] = 1; + // Now the gateOrder array is taken and reduced using the + // 'Kronecker Product' + var newGate = math.matrix(gateOrder.reduce(function (a, b) { + return math.kron(a, b); + }), 'sparse'); + + // Loop through the new matrix and if the NaN's are in the + // center, then replace with a 0, otherwise, replace with a 1 + newGate = math.map(newGate, function (val, index) { + if (math.isNaN(val)) { + if (index[0] === index[1]) { + return 1; } else { - newGate[_i2][j] = 0; + return 0; } + } else { + return val; + } + }); + + // Return the expanded gate. + return newGate; + } else { + // Put the gates here for easy access + var _identity = math.eye(2, 'sparse'); + var mainGate = math.matrix(this[gate], 'sparse'); + + // Again, Turn the gate order into an array, so that it can be + // reduced later. + var _gateOrder = []; + + for (var _i2 = 1; _i2 <= numQubits; _i2++) { + if (_i2 === qubit1) { + _gateOrder.push(mainGate); + } else { + _gateOrder.push(_identity); } } + + // Reduce and return the expanded gate. + return _gateOrder.reduce(function (a, b) { + return math.kron(a, b); + }); } - // Return the expanded gate. - return newGate; - } else { + } else if (math.typeof(gate) === 'Matrix' || math.typeof(gate) === 'Array') { + // This expand / generates a gate from a user inputed matrix + // Put the gates here for easy access - var _identity = math.eye(2); - var mainGate = this[gate]; + var _identity2 = math.eye(2, 'sparse'); + var _mainGate = math.matrix(gate, 'sparse'); + + // Gate must be unitary so check here + if (!helper.isUnitary(_mainGate)) { + // It's not unitary, throw an Error + throw new Error('The gate supplied to generateGate is not unitary'); + } // Again, Turn the gate order into an array, so that it can be // reduced later. - var _gateOrder = []; + var _gateOrder2 = []; for (var _i3 = 1; _i3 <= numQubits; _i3++) { if (_i3 === qubit1) { - _gateOrder.push(mainGate); + _gateOrder2.push(_mainGate); } else { - _gateOrder.push(_identity); + _gateOrder2.push(_identity2); } } // Reduce and return the expanded gate. - return _gateOrder.reduce(function (a, b) { + return _gateOrder2.reduce(function (a, b) { return math.kron(a, b); }); } + + // Doesn't match a default case, return an Id gate + return math.eye(math.pow(2, numQubits), 'sparse'); } }, { key: 'X', diff --git a/lib/helper.js b/lib/helper.js index f8a258b..3562e6f 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -14,6 +14,25 @@ var sum = function sum(array) { return total; }; +// Checks to if a matrix is unitary. Accepts a mathjs matrix or +// array, and returns true or false accordingly +var isUnitary = function isUnitary(matrix) { + // A Square matrix is unitary if its conjugate transpose is + // equal to its inverse + var givenMatrix = math.matrix(matrix, 'sparse'); + + // Check if its Square + if (math.size(givenMatrix)[0] !== math.size(givenMatrix)[1]) { + return false; + } + + var conjugateTranspose = math.transpose(math.conj(givenMatrix)); + var inverse = math.inv(givenMatrix); + + return math.deepEqual(inverse, conjugateTranspose); +}; + module.exports = { - sum: sum + sum: sum, + isUnitary: isUnitary }; \ No newline at end of file diff --git a/package.json b/package.json index e84d502..8e48134 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "qics", - "version": "1.0.2", + "version": "1.0.3", "description": "A Javascript Idealistic Quantum Computer Simulation Library", "main": "lib/index.js", "scripts": { @@ -10,9 +10,9 @@ "build:all": "npm run build && npm run build:var && npm run build:var:min && npm run docs", "clean": "rimraf lib dist coverage docs", "lint": "eslint src test examples", - "test": "mocha --compilers js:babel-core/register --recursive", + "test": "nyc mocha --compilers js:babel-core/register --recursive", "test:watch": "npm test -- --watch", - "docs": "rimraf docs && docco src/*.js -o ./docs" + "docs": "rimraf docs && docco src/*.js" }, "repository": { "type": "git", @@ -34,6 +34,7 @@ }, "homepage": "https://github.com/adamisntdead/qics", "dependencies": { + "docco": "^0.7.0", "mathjs": "^3.9.0", "weighted": "^0.3.0" }, @@ -45,11 +46,13 @@ "babel-preset-es2015": "^6.6.0", "chai": "^3.5.0", "cross-env": "^3.1.4", + "docco": "^0.7.0", "eslint": "^3.1.0", "eslint-plugin-import": "^2.0.1", "eslint-plugin-prefer-object-spread": "^1.1.0", "eslint-plugin-react": "^6.2.0", "mocha": "^3.2.0", + "nyc": "^10.1.2", "rimraf": "^2.5.2", "webpack": "^1.12.14" }, diff --git a/src/QuantumRegister.js b/src/QuantumRegister.js index 3b0af82..f83b244 100644 --- a/src/QuantumRegister.js +++ b/src/QuantumRegister.js @@ -10,11 +10,12 @@ class Register { // The number of amplitudes needed is 2^n, Where N is the number of qubits. // The math.zeros function Creates a matrix of 0s, ie. math.zeros(5) = [0, // 0, 0, 0, 0] - this.amplitudes = math + this.amplitudes = math.matrix([math .zeros(math.pow(2, numQubits)) - .toArray(); + .toArray()], 'sparse'); + // Set the chance of getting all Zeros to 1 - this.amplitudes[0] = 1; + this.amplitudes = math.subset(this.amplitudes, math.index(0, 0), 1); // Set the fact it has not been measured this.measured = false; } @@ -36,6 +37,7 @@ class Register { this.numQubits, qubit1, qubit2); + this.amplitudes = math.multiply(this.amplitudes, gateMatrix); } } diff --git a/src/gates.js b/src/gates.js index cb65902..6871b24 100644 --- a/src/gates.js +++ b/src/gates.js @@ -1,4 +1,5 @@ const math = require('mathjs'); +const helper = require('./helper'); // Complex number i and -i for easy access const i = math.complex(0, 1); @@ -53,6 +54,7 @@ class gates { [0, i] ]; } + static get SDagger() { return math.conj( math.transpose( @@ -71,6 +73,7 @@ class gates { [0, math.pow(math.e, (math.multiply(i, math.pi / 4)))] ]; } + static get TDagger() { return math.conj( math.transpose( @@ -86,83 +89,113 @@ class gates { # Helper Functions # ################################################# */ static generateGate(gate, numQubits, qubit1, qubit2 = 1) { - if (gate === 'CNOT') { - // Set the control and target qubits - const control = qubit1; - const target = qubit2; - - // Grab the gates now for easy access in the function - const identity = math.eye(2); - const X = this.X; - - // This matrix is the 'Control Matrix'. At the end of the gate generation, - // the NaN's positions will be evaluated to figure out if it should be a - // a 0 or a 1 - const C = [ - [NaN, 0], - [0, 1] - ]; - - // Turn the gate order into an array, so that it can be reduced later. - let gateOrder = []; - for (let i = 1; i <= numQubits; i++) { - if (i === control) { - gateOrder.push(C); - } else if (i === target) { - gateOrder.push(X); - } else { - gateOrder.push(identity); + if (math.typeof(gate) === 'string') { + if (gate === 'CNOT') { + // Set the control and target qubits + const control = qubit1; + const target = qubit2; + + // Grab the gates now for easy access in the function + const identity = math.eye(2, 'sparse'); + const X = math.matrix(this.X, 'sparse'); + + // This matrix is the 'Control Matrix'. At the end of the gate + // generation, the NaN's positions will be evaluated to figure + // out if it should be a 0 or a 1 + const C = math.matrix([ + [NaN, 0], + [0, 1] + ], 'sparse'); + + // Turn the gate order into an array, so that it can be reduced later. + let gateOrder = []; + for (let i = 1; i <= numQubits; i++) { + if (i === control) { + gateOrder.push(C); + } else if (i === target) { + gateOrder.push(X); + } else { + gateOrder.push(identity); + } } - } - - - // Now the gateOrder array is taken and reduced using the - // 'Kronecker Product' - let newGate = gateOrder.reduce((a, b) => math.kron(a, b)); - - // This needs to now be converted into an array if it is - // returned from math.js as a matrix - if (math.typeof(newGate) === 'Matrix') { - newGate = newGate.toArray(); - } - - // Loop through the new matrix and if the NaN's are in the - // center, then replace with a 0, otherwise, replace with a 1 - for (let i = 0; i < newGate.length; i++) { - for (let j = 0; j < newGate[i].length; j++) { - if (math.isNaN(newGate[i][j])) { - if (i === j) { - newGate[i][j] = 1; + + + // Now the gateOrder array is taken and reduced using the + // 'Kronecker Product' + let newGate = math.matrix( + gateOrder.reduce((a, b) => math.kron(a, b)), + 'sparse' + ); + + // Loop through the new matrix and if the NaN's are in the + // center, then replace with a 0, otherwise, replace with a 1 + newGate = math.map(newGate, (val, index) => { + if (math.isNaN(val)) { + if (index[0] === index[1]) { + return 1; + } else { + return 0; + } + } else { + return val; + } + }); + + // Return the expanded gate. + return newGate; + } else { + // Put the gates here for easy access + const identity = math.eye(2, 'sparse'); + const mainGate = math.matrix(this[gate], 'sparse'); + + // Again, Turn the gate order into an array, so that it can be + // reduced later. + let gateOrder = []; + + for (let i = 1; i <= numQubits; i++) { + if (i === qubit1) { + gateOrder.push(mainGate); } else { - newGate[i][j] = 0; + gateOrder.push(identity); } } + + // Reduce and return the expanded gate. + return gateOrder.reduce((a, b) => math.kron(a, b)); } - } - // Return the expanded gate. - return newGate; - } else { - // Put the gates here for easy access - const identity = math.eye(2); - const mainGate = this[gate]; - - // Again, Turn the gate order into an array, so that it can be - // reduced later. - let gateOrder = []; - - for (let i = 1; i <= numQubits; i++) { - if (i === qubit1) { - gateOrder.push(mainGate); - } else { - gateOrder.push(identity); + } else if (math.typeof(gate) === 'Matrix' + || math.typeof(gate) === 'Array') { + // This expand / generates a gate from a user inputed matrix + + // Put the gates here for easy access + const identity = math.eye(2, 'sparse'); + const mainGate = math.matrix(gate, 'sparse'); + + // Gate must be unitary so check here + if (!helper.isUnitary(mainGate)) { + // It's not unitary, throw an Error + throw new Error('The gate supplied to generateGate is not unitary'); + } + + // Again, Turn the gate order into an array, so that it can be + // reduced later. + let gateOrder = []; + + for (let i = 1; i <= numQubits; i++) { + if (i === qubit1) { + gateOrder.push(mainGate); + } else { + gateOrder.push(identity); + } } - } - // Reduce and return the expanded gate. - return gateOrder.reduce((a, b) => math.kron(a, b)); + // Reduce and return the expanded gate. + return gateOrder.reduce((a, b) => math.kron(a, b)); } - } + // Doesn't match a default case, return an Id gate + return math.eye(math.pow(2, numQubits), 'sparse'); + } } module.exports = gates; diff --git a/src/helper.js b/src/helper.js index c6eac7a..9fcbc84 100644 --- a/src/helper.js +++ b/src/helper.js @@ -12,6 +12,25 @@ const sum = (array) => { return total; }; +// Checks to if a matrix is unitary. Accepts a mathjs matrix or +// array, and returns true or false accordingly +const isUnitary = (matrix) => { + // A Square matrix is unitary if its conjugate transpose is + // equal to its inverse + const givenMatrix = math.matrix(matrix, 'sparse'); + + // Check if its Square + if ((math.size(givenMatrix))[0] !== (math.size(givenMatrix))[1]) { + return false; + } + + const conjugateTranspose = math.transpose(math.conj(givenMatrix)); + const inverse = math.inv(givenMatrix); + + return math.deepEqual(inverse, conjugateTranspose); +}; + module.exports = { - sum: sum + sum: sum, + isUnitary: isUnitary }; diff --git a/test/gates.test.js b/test/gates.test.js index b61172c..9bdfe34 100644 --- a/test/gates.test.js +++ b/test/gates.test.js @@ -3,6 +3,10 @@ import { expect } from 'chai'; const gates = require('../src/index').gates; const math = require('mathjs'); +// Complex number i and -i for easy access +const i = math.complex(0, 1); +const negI = math.complex(0, -1); + /* ######################################### # Cases # ######################################## */ @@ -29,4 +33,70 @@ describe('GenerateGate', () => { [0, 0, 0, 0, 0, 0, 1, 0] ])).to.equal(true); }); + + it('should generate from an inputed gate', () => { + // Gonna use my own X gate + expect(math.deepEqual(gates.generateGate('X', 2, 1), gates.generateGate([ + [0, 1], + [1, 0] + ], 2, 1))).to.equal(true); + }); + + it('should return an identity gate if the input isn\'t corrent', () => { + // Test with the input of a number, doesn't make sense so + // should be an id gate + expect(math.deepEqual( + math.eye(2), + gates.generateGate(7, 1, 1) + )).to.equal(true); + }); +}); + +describe('Gate Arrays', () => { + it('should return correct gates', () => { + expect(math.deepEqual(gates.X, [ + [0, 1], + [1, 0] + ])).to.equal(true); + expect(math.deepEqual(gates.Y, [ + [0, negI], + [i, 0] + ])).to.equal(true); + expect(math.deepEqual(gates.Z, [ + [1, 0], + [0, -1] + ])).to.equal(true); + expect(math.deepEqual(gates.H, math.multiply(1 / math.sqrt(2), [ + [1, 1], + [1, -1] + ]))).to.equal(true); + expect(math.deepEqual(gates.Id, [ + [1, 0], + [0, 1] + ])).to.equal(true); + expect(math.deepEqual(gates.S, [ + [1, 0], + [0, i] + ])).to.equal(true); + expect(math.deepEqual(gates.SDagger, math.conj( + math.transpose( + [ + [1, 0], + [0, i] + ] + ) + ))).to.equal(true); + expect(math.deepEqual(gates.T, [ + [1, 0], + [0, math.pow(math.e, (math.multiply(i, math.pi / 4)))] + ])).to.equal(true); + expect(math.deepEqual(gates.TDagger, math.conj( + math.transpose( + [ + [1, 0], + [0, math.pow(math.e, (math.multiply(i, math.pi / 4)))] + ] + ) + ))).to.equal(true); + }); });