From 729f2247f5738794735936e060408f43fe3487b6 Mon Sep 17 00:00:00 2001 From: josdejong Date: Thu, 28 Nov 2013 17:46:24 +0100 Subject: [PATCH] Released version 0.16.0 --- HISTORY.md | 2 +- bower.json | 2 +- dist/math.js | 1383 +++++++++++++++++++++++++++++----------------- dist/math.min.js | 16 +- package.json | 2 +- 5 files changed, 874 insertions(+), 531 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 668fda543..5ede10357 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -2,7 +2,7 @@ https://github.com/josdejong/mathjs -## not yet released, version 0.16.0 +## 2013-11-28, version 0.16.0 - Implemented BigNumber support for arbitrary precision calculations. Added settings `number.defaultType` and `number.precision` to configure diff --git a/bower.json b/bower.json index 681ea1b04..f4065aa93 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "mathjs", - "version": "0.16.0-SNAPSHOT", + "version": "0.16.0", "main": "./dist/math.js", "ignore": [ "coverage", diff --git a/dist/math.js b/dist/math.js index 0d44dd1bb..b02d6aaf2 100644 --- a/dist/math.js +++ b/dist/math.js @@ -6,8 +6,8 @@ * It features real and complex numbers, units, matrices, a large set of * mathematical functions, and a flexible expression parser. * - * @version 0.16.0-SNAPSHOT - * @date 2013-11-23 + * @version 0.16.0 + * @date 2013-11-28 * * @license * Copyright (C) 2013 Jos de Jong @@ -2794,8 +2794,7 @@ ConstantNode.prototype.toString = function() { module.exports = ConstantNode; },{"../../util/string":215,"./Node":109}],108:[function(require,module,exports){ -var Node = require('./Node'), - error = require('../../util/error'); +var Node = require('./Node'); /** * @constructor FunctionNode @@ -2819,7 +2818,8 @@ function FunctionNode(name, variables, expr, functionScope, scope) { // validate correct number of arguments if (arguments.length != num) { - throw new error.ArgumentsError(name, arguments.length, num); + throw new SyntaxError('Wrong number of arguments in function ' + name + + ' (' + arguments.length + ' provided, ' + num + ' expected)'); } // fill in the provided arguments in the functionScope variables @@ -2883,7 +2883,7 @@ FunctionNode.prototype.toString = function() { module.exports = FunctionNode; -},{"../../util/error":211,"./Node":109}],109:[function(require,module,exports){ +},{"./Node":109}],109:[function(require,module,exports){ /** * Node */ @@ -3051,10 +3051,12 @@ var number= require('../../util/number'), RangeNode = require('./RangeNode'), SymbolNode = require('./SymbolNode'), + BigNumber = require('bignumber.js'), Index = require('../../type/Index'), Range = require('../../type/Range'), - isNumber = number.isNumber; + isNumber = number.isNumber, + toNumber = number.toNumber; /** * @constructor ParamsNode @@ -3148,6 +3150,11 @@ ParamsNode.prototype.eval = function() { result = param.eval(); } + // convert big number to number + if (result instanceof BigNumber) result = toNumber(result); + + // TODO: implement support for BigNumber + // change from one-based to zero-based range if (result instanceof Range) { result.start --; @@ -3214,19 +3221,26 @@ ParamsNode.prototype.toString = function() { module.exports = ParamsNode; -},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113}],112:[function(require,module,exports){ +},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113,"bignumber.js":217}],112:[function(require,module,exports){ var number = require('../../util/number'), Node = require('./Node'), - Range = require('../../type/Range'); + + BigNumber = require('bignumber.js'), + Range = require('../../type/Range'), + Matrix = require('../../type/Matrix'), + + toNumber = number.toNumber; /** * @constructor RangeNode * create a range * @param {Object} math The math namespace containing all functions + * @param {Object} settings Settings of the math * @param {Node[]} params */ -function RangeNode (math, params) { +function RangeNode (math, settings, params) { this.math = math; + this.settings = settings; this.start = null; // included lower-bound this.end = null; // included upper-bound @@ -3255,20 +3269,10 @@ RangeNode.prototype = new Node(); */ RangeNode.prototype.eval = function() { // evaluate the parameters - var start = this.start.eval(); - var step = this.step ? this.step.eval() : 1; - var end = this.end.eval(); - - // validate parameters - if (!number.isNumber(start)) { - throw new TypeError('Parameter start must be a number'); - } - if (!number.isNumber(end)) { - throw new TypeError('Parameter end must be a number'); - } - if (!number.isNumber(step)) { - throw new TypeError('Parameter step must be a number'); - } + var range = this._evalParams(), + start = range.start, + step = range.step, + end = range.end; // generate the range (upper-bound included!) var array = [], @@ -3286,7 +3290,7 @@ RangeNode.prototype.eval = function() { } } - return array; + return (this.settings.matrix.defaultType === 'array') ? array : new Matrix(array); }; /** @@ -3295,9 +3299,10 @@ RangeNode.prototype.eval = function() { */ RangeNode.prototype.toRange = function() { // evaluate the parameters - var start = this.start.eval(); - var step = this.step ? this.step.eval() : 1; - var end = this.end.eval(); + var range = this._evalParams(), + start = range.start, + step = range.step, + end = range.end; // upper-bound be included, so compensate for that // NOTE: this only works for integer values! @@ -3307,6 +3312,35 @@ RangeNode.prototype.toRange = function() { return new Range(start, end, step); }; +/** + * Evaluate the range parameters start, step, end + * @returns {{start: Number, end: Number, step: Number}} range + * @private + */ +RangeNode.prototype._evalParams = function _evalParams() { + var start = this.start.eval(); + var end = this.end.eval(); + var step = this.step ? this.step.eval() : 1; + + // TODO: implement support for big numbers + + // convert big numbers to numbers + if (start instanceof BigNumber) start = toNumber(start); + if (end instanceof BigNumber) end = toNumber(end); + if (step instanceof BigNumber) step = toNumber(step); + + // validate parameters + if (!number.isNumber(start)) throw new TypeError('Parameter start must be a number'); + if (!number.isNumber(end)) throw new TypeError('Parameter end must be a number'); + if (!number.isNumber(step)) throw new TypeError('Parameter step must be a number'); + + return { + start: start, + end: end, + step: step + }; +}; + /** * Find all nodes matching given filter * @param {Object} filter See Node.find for a description of the filter settings @@ -3351,7 +3385,7 @@ RangeNode.prototype.toString = function() { module.exports = RangeNode; -},{"../../type/Range":206,"../../util/number":213,"./Node":109}],113:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/Range":206,"../../util/number":213,"./Node":109,"bignumber.js":217}],113:[function(require,module,exports){ var Node = require('./Node'); /** @@ -3402,10 +3436,12 @@ var number= require('../../util/number'), RangeNode = require('./RangeNode'), SymbolNode = require('./SymbolNode'), + BigNumber = require('bignumber.js'), Index = require('../../type/Index'), Range = require('../../type/Range'), - isNumber = number.isNumber; + isNumber = number.isNumber, + toNumber = number.toNumber; /** * @constructor UpdateNode @@ -3491,6 +3527,11 @@ UpdateNode.prototype.eval = function() { result = param.eval(); } + // convert big number to number + if (result instanceof BigNumber) result = toNumber(result); + + // TODO: implement support for BigNumber + // change from one-based to zero-based range if (result instanceof Range) { result.start --; @@ -3567,7 +3608,7 @@ UpdateNode.prototype.toString = function() { module.exports = UpdateNode; -},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113}],115:[function(require,module,exports){ +},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113,"bignumber.js":217}],115:[function(require,module,exports){ /** * Custom node handlers, * (can be added to the exports object) @@ -3614,7 +3655,7 @@ module.exports = function (math) { */ math.abs = function abs(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('abs', arguments.length, 1); + throw new math.error.ArgumentsError('abs', arguments.length, 1); } if (isNumber(x)) { @@ -3637,7 +3678,7 @@ module.exports = function (math) { return Math.abs(x); } - throw new util.error.UnsupportedTypeError('abs', x); + throw new math.error.UnsupportedTypeError('abs', x); }; }; @@ -3674,7 +3715,7 @@ module.exports = function (math) { */ math.add = function add(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('add', arguments.length, 2); + throw new math.error.ArgumentsError('add', arguments.length, 2); } if (isNumber(x)) { @@ -3730,30 +3771,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) + y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.plus(y); } + + // downgrade to Number + return add(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x + toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.plus(y) } + + // downgrade to Number + return add(x, toNumber(y)); } if (isString(x) || isString(y)) { @@ -3771,7 +3818,7 @@ module.exports = function (math) { return add(x, +y); } - throw new util.error.UnsupportedTypeError('add', x, y); + throw new math.error.UnsupportedTypeError('add', x, y); }; }; @@ -3800,7 +3847,7 @@ module.exports = function (math) { */ math.ceil = function ceil(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('ceil', arguments.length, 1); + throw new math.error.ArgumentsError('ceil', arguments.length, 1); } if (isNumber(x)) { @@ -3826,7 +3873,7 @@ module.exports = function (math) { return Math.ceil(x); } - throw new util.error.UnsupportedTypeError('ceil', x); + throw new math.error.UnsupportedTypeError('ceil', x); }; }; @@ -3856,7 +3903,7 @@ module.exports = function (math) { */ math.cube = function cube(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('cube', arguments.length, 1); + throw new math.error.ArgumentsError('cube', arguments.length, 1); } if (isNumber(x)) { @@ -3879,7 +3926,7 @@ module.exports = function (math) { return cube(+x); } - throw new util.error.UnsupportedTypeError('cube', x); + throw new math.error.UnsupportedTypeError('cube', x); }; }; @@ -3913,7 +3960,7 @@ module.exports = function(math) { */ math.divide = function divide(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('divide', arguments.length, 2); + throw new math.error.ArgumentsError('divide', arguments.length, 2); } if (isNumber(x)) { @@ -3939,30 +3986,36 @@ module.exports = function(math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) / y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.div(y); } + + // downgrade to Number + return divide(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x / toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.div(y) } + + // downgrade to Number + return divide(x, toNumber(y)); } if (isUnit(x)) { @@ -3999,7 +4052,7 @@ module.exports = function(math) { return divide(x, +y); } - throw new util.error.UnsupportedTypeError('divide', x, y); + throw new math.error.UnsupportedTypeError('divide', x, y); }; /** @@ -4029,8 +4082,7 @@ module.exports = function(math) { },{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],122:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - collection = require('../../type/collection'); + var collection = require('../../type/collection'); /** * Divide two values element wise. @@ -4044,17 +4096,16 @@ module.exports = function (math) { */ math.edivide = function edivide(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('edivide', arguments.length, 2); + throw new math.error.ArgumentsError('edivide', arguments.length, 2); } return collection.deepMap2(x, y, math.divide); }; }; -},{"../../type/collection":208,"../../util/index":212}],123:[function(require,module,exports){ +},{"../../type/collection":208}],123:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - collection = require('../../type/collection'); + var collection = require('../../type/collection'); /** * Multiply two values element wise. @@ -4068,17 +4119,16 @@ module.exports = function (math) { */ math.emultiply = function emultiply(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('emultiply', arguments.length, 2); + throw new math.error.ArgumentsError('emultiply', arguments.length, 2); } return collection.deepMap2(x, y, math.multiply); }; }; -},{"../../type/collection":208,"../../util/index":212}],124:[function(require,module,exports){ +},{"../../type/collection":208}],124:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - collection = require('../../type/collection'); + var collection = require('../../type/collection'); /** * Calculates the power of x to y element wise @@ -4092,14 +4142,14 @@ module.exports = function (math) { */ math.epow = function epow(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('epow', arguments.length, 2); + throw new math.error.ArgumentsError('epow', arguments.length, 2); } return collection.deepMap2(x, y, math.pow); }; }; -},{"../../type/collection":208,"../../util/index":212}],125:[function(require,module,exports){ +},{"../../type/collection":208}],125:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -4132,7 +4182,7 @@ module.exports = function (math) { */ math.equal = function equal(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('equal', arguments.length, 2); + throw new math.error.ArgumentsError('equal', arguments.length, 2); } if (isNumber(x)) { @@ -4154,30 +4204,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) == y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.eq(y); } + + // downgrade to Number + return equal(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x == toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.eq(y) } + + // downgrade to Number + return equal(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -4202,7 +4258,7 @@ module.exports = function (math) { return equal(x, +y); } - throw new util.error.UnsupportedTypeError('equal', x, y); + throw new math.error.UnsupportedTypeError('equal', x, y); }; }; @@ -4210,6 +4266,7 @@ module.exports = function (math) { module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), @@ -4231,7 +4288,7 @@ module.exports = function (math) { */ math.exp = function exp (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('exp', arguments.length, 1); + throw new math.error.ArgumentsError('exp', arguments.length, 1); } if (isNumber(x)) { @@ -4246,7 +4303,11 @@ module.exports = function (math) { ); } - // TODO: implement BigNumber support for exp + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return exp(util.number.toNumber(x)); + } if (isCollection(x)) { return collection.deepMap(x, exp); @@ -4256,11 +4317,11 @@ module.exports = function (math) { return Math.exp(x); } - throw new util.error.UnsupportedTypeError('exp', x); + throw new math.error.UnsupportedTypeError('exp', x); }; }; -},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],127:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],127:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -4285,7 +4346,7 @@ module.exports = function (math) { */ math.fix = function fix(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('fix', arguments.length, 1); + throw new math.error.ArgumentsError('fix', arguments.length, 1); } if (isNumber(x)) { @@ -4311,7 +4372,7 @@ module.exports = function (math) { return fix(+x); } - throw new util.error.UnsupportedTypeError('fix', x); + throw new math.error.UnsupportedTypeError('fix', x); }; }; @@ -4340,7 +4401,7 @@ module.exports = function (math) { */ math.floor = function floor(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('floor', arguments.length, 1); + throw new math.error.ArgumentsError('floor', arguments.length, 1); } if (isNumber(x)) { @@ -4366,7 +4427,7 @@ module.exports = function (math) { return floor(+x); } - throw new util.error.UnsupportedTypeError('floor', x); + throw new math.error.UnsupportedTypeError('floor', x); }; }; @@ -4424,22 +4485,10 @@ module.exports = function (math) { // downgrade bignumbers to numbers if (a instanceof BigNumber) { - a = toNumber(a); - if (isNumber(a)) { - return gcd(a, b); - } - else { - throw Error('Parameters in function gcd must be integer numbers.'); - } + return gcd(toNumber(a), b); } if (b instanceof BigNumber) { - b = toNumber(b); - if (isNumber(b)) { - return gcd(a, b); - } - else { - throw Error('Parameters in function gcd must be integer numbers.'); - } + return gcd(a, toNumber(b)); } if (isBoolean(a)) { @@ -4449,7 +4498,7 @@ module.exports = function (math) { return gcd(a, +b); } - throw new util.error.UnsupportedTypeError('gcd', a, b); + throw new math.error.UnsupportedTypeError('gcd', a, b); } if (arguments.length > 2) { @@ -4498,7 +4547,7 @@ module.exports = function (math) { */ math.larger = function larger(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('larger', arguments.length, 2); + throw new math.error.ArgumentsError('larger', arguments.length, 2); } if (isNumber(x) && isNumber(y)) { @@ -4506,30 +4555,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) > y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.gt(y); } + + // downgrade to Number + return larger(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x > toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.gt(y) } + + // downgrade to Number + return larger(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -4558,7 +4613,7 @@ module.exports = function (math) { throw new TypeError('No ordering relation is defined for complex numbers'); } - throw new util.error.UnsupportedTypeError('larger', x, y); + throw new math.error.UnsupportedTypeError('larger', x, y); }; }; @@ -4595,7 +4650,7 @@ module.exports = function (math) { */ math.largereq = function largereq(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('largereq', arguments.length, 2); + throw new math.error.ArgumentsError('largereq', arguments.length, 2); } if (isNumber(x) && isNumber(y)) { @@ -4603,30 +4658,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) >= y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.gte(y); } + + // downgrade to Number + return largereq(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x >= toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.gte(y) } + + // downgrade to Number + return largereq(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -4655,7 +4716,7 @@ module.exports = function (math) { throw new TypeError('No ordering relation is defined for complex numbers'); } - throw new util.error.UnsupportedTypeError('largereq', x, y); + throw new math.error.UnsupportedTypeError('largereq', x, y); }; }; @@ -4729,25 +4790,13 @@ module.exports = function (math) { // downgrade bignumbers to numbers if (a instanceof BigNumber) { - a = toNumber(a); - if (isNumber(a)) { - return lcm(a, b); - } - else { - throw Error('Parameters in function lcm must be integer numbers.'); - } + return lcm(toNumber(a), b); } if (b instanceof BigNumber) { - b = toNumber(b); - if (isNumber(b)) { - return lcm(a, b); - } - else { - throw Error('Parameters in function lcm must be integer numbers.'); - } + return lcm(a, toNumber(b)); } - throw new util.error.UnsupportedTypeError('lcm', a, b); + throw new math.error.UnsupportedTypeError('lcm', a, b); } if (arguments.length > 2) { @@ -4772,7 +4821,6 @@ module.exports = function (math) { collection = require('../../type/collection'), isNumber = util.number.isNumber, - toNumber = util.number.toNumber, isBoolean = util.boolean.isBoolean, isComplex = Complex.isComplex, isCollection = collection.isCollection; @@ -4811,9 +4859,9 @@ module.exports = function (math) { } if (x instanceof BigNumber) { - // TODO: implement BigNumber support for log + // TODO: implement BigNumber support // downgrade to Number - return log(toNumber(x)); + return log(util.number.toNumber(x)); } if (isCollection(x)) { @@ -4824,14 +4872,14 @@ module.exports = function (math) { return log(+x); } - throw new util.error.UnsupportedTypeError('log', x); + throw new math.error.UnsupportedTypeError('log', x); } else if (arguments.length == 2) { // calculate logarithm for a specified base, log(x, base) return math.divide(log(x), log(base)); } else { - throw new util.error.ArgumentsError('log', arguments.length, 1, 2); + throw new math.error.ArgumentsError('log', arguments.length, 1, 2); } }; }; @@ -4844,7 +4892,6 @@ module.exports = function (math) { Complex = require('../../type/Complex'), collection = require('../../type/collection'), - toNumber = util.number.toNumber, isNumber = util.number.isNumber, isBoolean = util.boolean.isBoolean, isComplex = Complex.isComplex, @@ -4862,7 +4909,7 @@ module.exports = function (math) { */ math.log10 = function log10(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('log10', arguments.length, 1); + throw new math.error.ArgumentsError('log10', arguments.length, 1); } if (isNumber(x)) { @@ -4876,9 +4923,9 @@ module.exports = function (math) { } if (x instanceof BigNumber) { - // TODO: implement BigNumber support for log10 + // TODO: implement BigNumber support // downgrade to Number - return log10(toNumber(x)); + return log10(util.number.toNumber(x)); } if (isComplex(x)) { @@ -4896,7 +4943,7 @@ module.exports = function (math) { return log10(+x); } - throw new util.error.UnsupportedTypeError('log10', x); + throw new math.error.UnsupportedTypeError('log10', x); }; }; @@ -4927,7 +4974,7 @@ module.exports = function (math) { */ math.mod = function mod(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('mod', arguments.length, 2); + throw new math.error.ArgumentsError('mod', arguments.length, 2); } // see http://functions.wolfram.com/IntegerFunctions/Mod/ @@ -4940,30 +4987,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return _mod(toNumber(x), y); - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.mod(y); } + + // downgrade to Number + return mod(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return _mod(x, toNumber(y)); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.mod(y) } + + // downgrade to Number + return mod(x, toNumber(y)); } // TODO: implement mod for complex values @@ -4979,7 +5032,7 @@ module.exports = function (math) { return mod(x, +y); } - throw new util.error.UnsupportedTypeError('mod', x, y); + throw new math.error.UnsupportedTypeError('mod', x, y); }; /** @@ -5042,7 +5095,7 @@ module.exports = function(math) { */ math.multiply = function multiply(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('multiply', arguments.length, 2); + throw new math.error.ArgumentsError('multiply', arguments.length, 2); } if (isNumber(x)) { @@ -5073,30 +5126,36 @@ module.exports = function(math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) * y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.times(y); } + + // downgrade to Number + return multiply(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x * toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.times(y) } + + // downgrade to Number + return multiply(x, toNumber(y)); } if (isUnit(x)) { @@ -5216,7 +5275,7 @@ module.exports = function(math) { return multiply(x, +y); } - throw new util.error.UnsupportedTypeError('multiply', x, y); + throw new math.error.UnsupportedTypeError('multiply', x, y); }; /** @@ -5436,7 +5495,7 @@ module.exports = function (math) { */ math.pow = function pow(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('pow', arguments.length, 2); + throw new math.error.ArgumentsError('pow', arguments.length, 2); } if (isNumber(x)) { @@ -5464,33 +5523,41 @@ module.exports = function (math) { } // TODO: pow for complex numbers and bignumbers + if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return Math.pow(toNumber(x), y); - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.pow(y); } + + // downgrade to Number + return pow(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return Math.pow(x, toNumber(y)); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.pow(y) } + + // downgrade to Number + return pow(x, toNumber(y)); } + if (isArray(x)) { if (!isNumber(y) || !isInteger(y) || y < 0) { throw new TypeError('For A^b, b must be a positive integer ' + @@ -5531,7 +5598,7 @@ module.exports = function (math) { return pow(x, +y); } - throw new util.error.UnsupportedTypeError('pow', x, y); + throw new math.error.UnsupportedTypeError('pow', x, y); }; /** @@ -5559,8 +5626,6 @@ module.exports = function (math) { collection = require('../../type/collection'), isNumber = util.number.isNumber, - toNumber = util.number.toNumber, - toBigNumber = util.number.toBigNumber, isInteger = util.number.isInteger, isBoolean = util.boolean.isBoolean, isComplex = Complex.isComplex, @@ -5580,7 +5645,7 @@ module.exports = function (math) { */ math.round = function round(x, n) { if (arguments.length != 1 && arguments.length != 2) { - throw new util.error.ArgumentsError('round', arguments.length, 1, 2); + throw new math.error.ArgumentsError('round', arguments.length, 1, 2); } if (n == undefined) { @@ -5608,7 +5673,7 @@ module.exports = function (math) { return Math.round(x); } - throw new util.error.UnsupportedTypeError('round', x); + throw new math.error.UnsupportedTypeError('round', x); } else { // round (x, n) @@ -5651,7 +5716,7 @@ module.exports = function (math) { return round(x, +n); } - throw new util.error.UnsupportedTypeError('round', x, n); + throw new math.error.UnsupportedTypeError('round', x, n); } }; @@ -5700,7 +5765,7 @@ module.exports = function (math) { */ math.sign = function sign(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('sign', arguments.length, 1); + throw new math.error.ArgumentsError('sign', arguments.length, 1); } if (isNumber(x)) { @@ -5724,7 +5789,7 @@ module.exports = function (math) { return number.sign(x); } - throw new util.error.UnsupportedTypeError('sign', x); + throw new math.error.UnsupportedTypeError('sign', x); }; }; @@ -5761,7 +5826,7 @@ module.exports = function (math) { */ math.smaller = function smaller(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('smaller', arguments.length, 2); + throw new math.error.ArgumentsError('smaller', arguments.length, 2); } if (isNumber(x) && isNumber(y)) { @@ -5769,30 +5834,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) < y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.lt(y); } + + // downgrade to Number + return smaller(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x < toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.lt(y) } + + // downgrade to Number + return smaller(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -5821,7 +5892,7 @@ module.exports = function (math) { throw new TypeError('No ordering relation is defined for complex numbers'); } - throw new util.error.UnsupportedTypeError('smaller', x, y); + throw new math.error.UnsupportedTypeError('smaller', x, y); }; }; @@ -5858,7 +5929,7 @@ module.exports = function (math) { */ math.smallereq = function smallereq(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('smallereq', arguments.length, 2); + throw new math.error.ArgumentsError('smallereq', arguments.length, 2); } if (isNumber(x) && isNumber(y)) { @@ -5866,30 +5937,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) <= y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.lte(y); } + + // downgrade to Number + return smallereq(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x <= toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.lte(y) } + + // downgrade to Number + return smallereq(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -5918,7 +5995,7 @@ module.exports = function (math) { throw new TypeError('No ordering relation is defined for complex numbers'); } - throw new util.error.UnsupportedTypeError('smallereq', x, y); + throw new math.error.UnsupportedTypeError('smallereq', x, y); }; }; @@ -5947,7 +6024,7 @@ module.exports = function (math) { */ math.sqrt = function sqrt (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('sqrt', arguments.length, 1); + throw new math.error.ArgumentsError('sqrt', arguments.length, 1); } if (isNumber(x)) { @@ -5987,7 +6064,7 @@ module.exports = function (math) { return sqrt(+x); } - throw new util.error.UnsupportedTypeError('sqrt', x); + throw new math.error.UnsupportedTypeError('sqrt', x); }; }; @@ -6017,7 +6094,7 @@ module.exports = function (math) { */ math.square = function square(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('square', arguments.length, 1); + throw new math.error.ArgumentsError('square', arguments.length, 1); } if (isNumber(x)) { @@ -6040,7 +6117,7 @@ module.exports = function (math) { return x * x; } - throw new util.error.UnsupportedTypeError('square', x); + throw new math.error.UnsupportedTypeError('square', x); }; }; @@ -6076,7 +6153,7 @@ module.exports = function (math) { */ math.subtract = function subtract(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('subtract', arguments.length, 2); + throw new math.error.ArgumentsError('subtract', arguments.length, 2); } if (isNumber(x)) { @@ -6110,30 +6187,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) - y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return x.minus(y); } + + // downgrade to Number + return subtract(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x - toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return x.minus(y) } + + // downgrade to Number + return subtract(x, toNumber(y)); } if (isUnit(x)) { @@ -6169,7 +6252,7 @@ module.exports = function (math) { return subtract(x, +y); } - throw new util.error.UnsupportedTypeError('subtract', x, y); + throw new math.error.UnsupportedTypeError('subtract', x, y); }; }; @@ -6201,7 +6284,7 @@ module.exports = function (math) { */ math.unary = function unary(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('unary', arguments.length, 1); + throw new math.error.ArgumentsError('unary', arguments.length, 1); } if (isNumber(x)) { @@ -6233,7 +6316,7 @@ module.exports = function (math) { return -x; } - throw new util.error.UnsupportedTypeError('unary', x); + throw new math.error.UnsupportedTypeError('unary', x); }; }; @@ -6264,7 +6347,7 @@ module.exports = function (math) { */ math.unequal = function unequal(x, y) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('unequal', arguments.length, 2); + throw new math.error.ArgumentsError('unequal', arguments.length, 2); } if (isNumber(x)) { @@ -6286,30 +6369,36 @@ module.exports = function (math) { } if (x instanceof BigNumber) { + // try to convert to big number if (isNumber(y)) { - // try to convert to big number, if not possible, downgrade to Numbers y = toBigNumber(y); - if (isNumber(y)) { - return toNumber(x) != y; - } + } + else if (isBoolean(y)) { + y = new BigNumber(y ? 1 : 0); } if (y instanceof BigNumber) { return !x.eq(y); } + + // downgrade to Number + return unequal(toNumber(x), y); } if (y instanceof BigNumber) { + // try to convert to big number if (isNumber(x)) { - // try to convert to big number, if not possible, downgrade to Numbers x = toBigNumber(x); - if (isNumber(x)) { - return x != toNumber(y); - } + } + else if (isBoolean(x)) { + x = new BigNumber(x ? 1 : 0); } if (x instanceof BigNumber) { return !x.eq(y) } + + // downgrade to Number + return unequal(x, toNumber(y)); } if ((isUnit(x)) && (isUnit(y))) { @@ -6334,7 +6423,7 @@ module.exports = function (math) { return unequal(x, +y); } - throw new util.error.UnsupportedTypeError('unequal', x, y); + throw new math.error.UnsupportedTypeError('unequal', x, y); }; }; @@ -6376,22 +6465,10 @@ module.exports = function (math) { // downgrade bignumbers to numbers if (a instanceof BigNumber) { - a = toNumber(a); - if (isNumber(a)) { - return xgcd(a, b); - } - else { - throw Error('Parameters in function xgcd must be integer numbers.'); - } + return xgcd(toNumber(a), b); } if (b instanceof BigNumber) { - b = toNumber(b); - if (isNumber(b)) { - return xgcd(a, b); - } - else { - throw Error('Parameters in function xgcd must be integer numbers.'); - } + return xgcd(a, toNumber(b)); } if (isBoolean(a)) { @@ -6401,7 +6478,7 @@ module.exports = function (math) { return xgcd(a, +b); } - throw new util.error.UnsupportedTypeError('xgcd', a, b); + throw new math.error.UnsupportedTypeError('xgcd', a, b); } // zero or one argument @@ -6474,7 +6551,7 @@ module.exports = function (math) { */ math.arg = function arg(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('arg', arguments.length, 1); + throw new math.error.ArgumentsError('arg', arguments.length, 1); } if (isNumber(x)) { @@ -6499,7 +6576,7 @@ module.exports = function (math) { return arg(util.number.toNumber(x)); } - throw new util.error.UnsupportedTypeError('arg', x); + throw new math.error.UnsupportedTypeError('arg', x); }; }; @@ -6530,7 +6607,7 @@ module.exports = function (math) { */ math.conj = function conj(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('conj', arguments.length, 1); + throw new math.error.ArgumentsError('conj', arguments.length, 1); } if (isNumber(x)) { @@ -6583,7 +6660,7 @@ module.exports = function (math) { */ math.im = function im(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('im', arguments.length, 1); + throw new math.error.ArgumentsError('im', arguments.length, 1); } if (isNumber(x)) { @@ -6637,7 +6714,7 @@ module.exports = function (math) { */ math.re = function re(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('re', arguments.length, 1); + throw new math.error.ArgumentsError('re', arguments.length, 1); } if (isNumber(x)) { @@ -6698,7 +6775,7 @@ module.exports = function (math) { */ math.bignumber = function bignumber(value) { if (arguments.length > 1) { - throw new util.error.ArgumentsError('bignumber', arguments.length, 0, 1); + throw new math.error.ArgumentsError('bignumber', arguments.length, 0, 1); } if ((value instanceof BigNumber) || isNumber(value) || isString(value)) { @@ -6717,7 +6794,7 @@ module.exports = function (math) { return new BigNumber(0); } - throw new util.error.UnsupportedTypeError('bignumber', value); + throw new math.error.UnsupportedTypeError('bignumber', value); }; }; @@ -6743,7 +6820,7 @@ module.exports = function (math) { */ math['boolean'] = function bool (value) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('boolean', arguments.length, 0, 1); + throw new math.error.ArgumentsError('boolean', arguments.length, 0, 1); } if (value === 'true' || value === true) { @@ -6883,17 +6960,11 @@ module.exports = function (math) { // convert re to number if (re instanceof BigNumber) { re = toNumber(re); - if (!isNumber(re)) { - throw new TypeError('Cannot convert BigNumber ' + re + ' to Number'); - } } // convert im to number if (im instanceof BigNumber) { im = toNumber(im); - if (!isNumber(im)) { - throw new TypeError('Cannot convert BigNumber ' + im + ' to Number'); - } } if (isNumber(re) && isNumber(im)) { @@ -6907,7 +6978,7 @@ module.exports = function (math) { break; default: - throw new util.error.ArgumentsError('complex', arguments.length, 0, 2); + throw new math.error.ArgumentsError('complex', arguments.length, 0, 2); } }; }; @@ -6916,7 +6987,10 @@ module.exports = function (math) { module.exports = function (math) { var util = require('../../util/index'), - Index = require('../../type/Index'); + BigNumber = require('bignumber.js'), + Index = require('../../type/Index'), + + toNumber = util.number.toNumber; /** * Create an index. An Index can store ranges having start, step, and end @@ -6938,16 +7012,30 @@ module.exports = function (math) { */ math.index = function matrix(ranges) { var i = new Index(); - Index.apply(i, arguments); + + // downgrade BigNumber to Number + var args = Array.prototype.slice.apply(arguments).map(function (arg) { + if (arg instanceof BigNumber) { + return toNumber(arg); + } + else if (Array.isArray(arg)) { + return arg.map(function (elem) { + return (elem instanceof BigNumber) ? toNumber (elem) : elem; + }); + } + else { + return arg; + } + }); + + Index.apply(i, args); return i; }; }; -},{"../../type/Index":204,"../../util/index":212}],156:[function(require,module,exports){ +},{"../../type/Index":204,"../../util/index":212,"bignumber.js":217}],156:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - - Matrix = require('../../type/Matrix'); + var Matrix = require('../../type/Matrix'); /** * Create a matrix. The function creates a new math.type.Matrix object. @@ -6968,14 +7056,14 @@ module.exports = function (math) { */ math.matrix = function matrix(data) { if (arguments.length > 1) { - throw new util.error.ArgumentsError('matrix', arguments.length, 0, 1); + throw new math.error.ArgumentsError('matrix', arguments.length, 0, 1); } return new Matrix(data); }; }; -},{"../../type/Matrix":205,"../../util/index":212}],157:[function(require,module,exports){ +},{"../../type/Matrix":205}],157:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -7014,16 +7102,14 @@ module.exports = function (math) { } return num; default: - throw new util.error.ArgumentsError('number', arguments.length, 0, 1); + throw new math.error.ArgumentsError('number', arguments.length, 0, 1); } }; }; },{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],158:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - - Parser = require('../../expression/Parser'); + var Parser = require('../../expression/Parser'); /** * Create a parser. The function creates a new math.expression.Parser object. @@ -7066,7 +7152,7 @@ module.exports = function (math) { }; }; -},{"../../expression/Parser":4,"../../util/index":212}],159:[function(require,module,exports){ +},{"../../expression/Parser":4}],159:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -7103,7 +7189,7 @@ module.exports = function (math) { return value.toString(); default: - throw new util.error.ArgumentsError('string', arguments.length, 0, 1); + throw new math.error.ArgumentsError('string', arguments.length, 0, 1); } }; }; @@ -7118,8 +7204,6 @@ module.exports = function (math) { isCollection = collection.isCollection, toNumber = util.number.toNumber, - isNumber = util.number.isNumber, - isBoolean = util.boolean.isBoolean, isString = util.string.isString; /** @@ -7172,22 +7256,18 @@ module.exports = function (math) { case 2: // a number and a unit - var _value = arguments[0], - _unit = arguments[1]; - // convert value to number - if (_value instanceof BigNumber) { - _value = toNumber(_value); - if (!isNumber(_value)) { - throw new TypeError('Cannot convert BigNumber ' + _value + ' to Number'); - } + if (arguments[0] instanceof BigNumber) { + // convert value to number + return new Unit(toNumber(arguments[0]), arguments[1]); + } + else { + return new Unit(arguments[0], arguments[1]); } - - return new Unit(_value, _unit); break; default: - throw new util.error.ArgumentsError('unit', arguments.length, 1, 2); + throw new math.error.ArgumentsError('unit', arguments.length, 1, 2); } }; }; @@ -7230,7 +7310,7 @@ module.exports = function (math) { */ math.eval = function _eval (expr, scope) { if (arguments.length != 1 && arguments.length != 2) { - throw new util.error.ArgumentsError('eval', arguments.length, 1, 2); + throw new math.error.ArgumentsError('eval', arguments.length, 1, 2); } // instantiate a scope @@ -7268,9 +7348,7 @@ module.exports = function (math) { },{"../../expression/Scope":5,"../../type/collection":208,"../../util/index":212}],162:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - - Help = require('../../type/Help'); + var Help = require('../../type/Help'); /** * Retrieve help on a function or data type. @@ -7326,10 +7404,11 @@ module.exports = function (math) { }; }; -},{"../../type/Help":203,"../../util/index":212}],163:[function(require,module,exports){ +},{"../../type/Help":203}],163:[function(require,module,exports){ module.exports = function (math, settings) { var util = require('../../util/index'), + toNumber = util.number.toNumber, isString = util.string.isString, isArray = Array.isArray, @@ -7386,7 +7465,7 @@ module.exports = function (math, settings) { */ math.parse = function parse (expr, scope) { if (arguments.length != 1 && arguments.length != 2) { - throw new util.error.ArgumentsError('parse', arguments.length, 1, 2); + throw new math.error.ArgumentsError('parse', arguments.length, 1, 2); } // instantiate a scope @@ -7581,7 +7660,7 @@ module.exports = function (math, settings) { next(); } - // check for scientific notation like "2.3e-4" or "1.23e50" + // check for exponential notation like "2.3e-4" or "1.23e50" if (c == 'E' || c == 'e') { token += c; next(); @@ -7898,7 +7977,8 @@ module.exports = function (math, settings) { if (token == ':') { // implicit start=1 (one-based) - node = new ConstantNode(1); + var one = (settings.number.defaultType === 'bignumber') ? new BigNumber(1) : 1; + node = new ConstantNode(one); } else { // explicit start @@ -7922,7 +8002,7 @@ module.exports = function (math, settings) { } if (params.length) { - node = new RangeNode(math, params); + node = new RangeNode(math, settings, params); } } @@ -8514,12 +8594,17 @@ module.exports = function (math, settings) { //*/ if (token_type == TOKENTYPE.SYMBOL) { + // convert bignumber to number as both Complex and Unit don't support BigNumber + number = (number instanceof BigNumber) ? toNumber(number) : number; + + // create a complex number if (token == 'i' || token == 'I') { value = new Complex(0, number); getToken(); return new ConstantNode(value); } + // create a unit if (Unit.isPlainUnit(token)) { value = new Unit(number, token); getToken(); @@ -8734,7 +8819,7 @@ module.exports = function (math) { } } else { - throw new util.error.UnsupportedTypeError('concat', arg); + throw new math.error.UnsupportedTypeError('concat', arg); } } @@ -8801,7 +8886,7 @@ module.exports = function (math) { */ math.det = function det (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('det', arguments.length, 1); + throw new math.error.ArgumentsError('det', arguments.length, 1); } var size = array.size(x.valueOf()); @@ -8955,7 +9040,7 @@ module.exports = function (math, settings) { var data, vector, i, iMax; if (arguments.length != 1 && arguments.length != 2) { - throw new util.error.ArgumentsError('diag', arguments.length, 1, 2); + throw new math.error.ArgumentsError('diag', arguments.length, 1, 2); } if (k) { @@ -9018,9 +9103,11 @@ module.exports = function (math, settings) { module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), + toNumber = util.number.toNumber, isNumber = util.number.isNumber, isInteger = util.number.isInteger, isArray = Array.isArray; @@ -9053,12 +9140,20 @@ module.exports = function (math, settings) { } else if (args.length > 2) { // error in case of an n-dimensional size - throw new util.error.ArgumentsError('eye', args.length, 0, 2); + throw new math.error.ArgumentsError('eye', args.length, 0, 2); } - var rows = args[0], + var asBigNumber = args[0] instanceof BigNumber, + rows = args[0], cols = args[1]; + if (rows instanceof BigNumber) { + rows = toNumber(rows); + } + if (cols instanceof BigNumber) { + cols = toNumber(cols); + } + if (!isNumber(rows) || !isInteger(rows) || rows < 1) { throw new Error('Parameters in function eye must be positive integers'); } @@ -9070,28 +9165,27 @@ module.exports = function (math, settings) { // create and args the matrix var matrix = new Matrix(); - var defaultValue = 0; - matrix.resize(args, defaultValue); + var one = asBigNumber ? new BigNumber(1) : 1; + var defaultValue = asBigNumber ? new BigNumber(0) : 0; + matrix.resize(args.map(toNumber), defaultValue); // fill in ones on the diagonal var minimum = math.min(args); var data = matrix.valueOf(); for (var d = 0; d < minimum; d++) { - data[d][d] = 1; + data[d][d] = one; } return asMatrix ? matrix : matrix.valueOf(); }; }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],168:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],168:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), + var string = require('../../util/string'), Matrix = require('../../type/Matrix'), - collection = require('../../type/collection'), - - string = util.string; + collection = require('../../type/collection'); /** * Calculate the inverse of a matrix @@ -9105,7 +9199,7 @@ module.exports = function (math) { */ math.inv = function inv (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('inv', arguments.length, 1); + throw new math.error.ArgumentsError('inv', arguments.length, 1); } var size = math.size(x).valueOf(); switch (size.length) { @@ -9272,15 +9366,17 @@ module.exports = function (math) { } }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],169:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208,"../../util/string":215}],169:[function(require,module,exports){ module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), array = util.array, + toNumber = util.number.toNumber, isArray = Array.isArray; /** @@ -9306,22 +9402,26 @@ module.exports = function (math, settings) { else { // output an array or matrix var res = []; - var defaultValue = 1; - res = array.resize(res, args, defaultValue); + var defaultValue = (args[0] instanceof BigNumber) ? new BigNumber(1) : 1; + res = array.resize(res, args.map(toNumber), defaultValue); + return asMatrix ? new Matrix(res) : res; } }; }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],170:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],170:[function(require,module,exports){ module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), isString = util.string.isString, - isNumber = util.number.isNumber; + isNumber = util.number.isNumber, + toNumber = util.number.toNumber, + toBigNumber = util.number.toBigNumber; /** * Create an array from a range. @@ -9379,19 +9479,62 @@ module.exports = function (math, settings) { break; default: - throw new util.error.ArgumentsError('range', arguments.length, 2, 3); + throw new math.error.ArgumentsError('range', arguments.length, 2, 3); } - if (!isNumber(start)) { + // verify type of parameters + if (!isNumber(start) && !(start instanceof BigNumber)) { throw new TypeError('Parameter start must be a number'); } - if (!isNumber(end)) { + if (!isNumber(end) && !(end instanceof BigNumber)) { throw new TypeError('Parameter end must be a number'); } - if (!isNumber(step)) { + if (!isNumber(step) && !(step instanceof BigNumber)) { throw new TypeError('Parameter step must be a number'); } + // go big + if (start instanceof BigNumber || end instanceof BigNumber || step instanceof BigNumber) { + // create a range with big numbers + var asBigNumber = true; + + // convert start, end, step to BigNumber + if (!(start instanceof BigNumber)) { + start = toBigNumber(start); + } + if (!(end instanceof BigNumber)) { + end = toBigNumber(end); + } + if (!(step instanceof BigNumber)) { + step = toBigNumber(step); + } + + if (!(start instanceof BigNumber) || !(end instanceof BigNumber) || !(step instanceof BigNumber)) { + // not all values can be converted to big number :( + // fall back to numbers + asBigNumber = false; + start = toNumber(start); + end = toNumber(end); + step = toNumber(step); + } + } + + // generate the range + var array = asBigNumber ? _bigRange(start, end, step) : _range(start, end, step); + + // return as array or matrix + return (settings.matrix.defaultType === 'array') ? array : new Matrix(array); + }; + + /** + * Create a range with numbers + * @param {Number} start + * @param {Number} end + * @param {Number} step + * @returns {Array} range + * @private + */ + function _range (start, end, step) { var array = [], x = start; if (step > 0) { @@ -9407,8 +9550,36 @@ module.exports = function (math, settings) { } } - return (settings.matrix.defaultType === 'array') ? array : new Matrix(array); - }; + return array; + } + + /** + * Create a range with big numbers + * @param {BigNumber} start + * @param {BigNumber} end + * @param {BigNumber} step + * @returns {Array} range + * @private + */ + function _bigRange (start, end, step) { + var array = [], + x = start.clone(), + zero = new BigNumber(0); + if (step.gt(zero)) { + while (x.lt(end)) { + array.push(x); + x = x.plus(step); + } + } + else if (step.lt(zero)) { + while (x.gt(end)) { + array.push(x); + x = x.plus(step); + } + } + + return array; + } /** * Parse a string into a range, @@ -9420,16 +9591,32 @@ module.exports = function (math, settings) { * @private */ function _parse (str) { - var args = str.split(':'); - var nums = args.map(function (arg) { - return Number(arg); - }); + var args = str.split(':'), + nums = null; - var invalid = nums.some(function (num) { - return isNaN(num); - }); - if(invalid) { - return null; + if (settings.number.defaultType === 'bignumber') { + // bignumber + try { + nums = args.map(function (arg) { + return new BigNumber(arg); + }); + } + catch (err) { + return null; + } + } + else { + // number + nums = args.map(function (arg) { + return parseFloat(arg); + }); + + var invalid = nums.some(function (num) { + return isNaN(num); + }); + if(invalid) { + return null; + } } switch (nums.length) { @@ -9454,15 +9641,17 @@ module.exports = function (math, settings) { }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],171:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],171:[function(require,module,exports){ module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Matrix = require('../../type/Matrix'), array = util.array, clone = util.object.clone, isString = util.string.isString, + toNumber = util.number.toNumber, isNumber = util.number.isNumber, isInteger = util.number.isInteger, isArray = array.isArray; @@ -9482,7 +9671,7 @@ module.exports = function (math, settings) { */ math.resize = function resize (x, size, defaultValue) { if (arguments.length != 2 && arguments.length != 3) { - throw new util.error.ArgumentsError('resize', arguments.length, 2, 3); + throw new math.error.ArgumentsError('resize', arguments.length, 2, 3); } var asMatrix = (x instanceof Matrix) ? true : isArray(x) ? false : @@ -9495,6 +9684,11 @@ module.exports = function (math, settings) { size = size.valueOf(); // get Array } + if (size.length && size[0] instanceof BigNumber) { + // convert bignumbers to numbers + size = size.map(toNumber); + } + if (isString(x)) { return _resizeString(x, size, defaultValue); } @@ -9561,10 +9755,11 @@ module.exports = function (math, settings) { } }; -},{"../../type/Matrix":205,"../../util/index":212}],172:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../util/index":212,"bignumber.js":217}],172:[function(require,module,exports){ module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), Matrix = require('../../type/Matrix'), @@ -9586,12 +9781,13 @@ module.exports = function (math, settings) { */ math.size = function size (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('size', arguments.length, 1); + throw new math.error.ArgumentsError('size', arguments.length, 1); } var asArray = (settings.matrix.defaultType === 'array'); - if (isNumber(x) || isComplex(x) || isUnit(x) || isBoolean(x) || x == null) { + if (isNumber(x) || isComplex(x) || isUnit(x) || isBoolean(x) || + x == null || x instanceof BigNumber) { return asArray ? [] : new Matrix([]); } @@ -9607,11 +9803,11 @@ module.exports = function (math, settings) { return new Matrix(x.size()); } - throw new util.error.UnsupportedTypeError('size', x); + throw new math.error.UnsupportedTypeError('size', x); }; }; -},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../util/index":212}],173:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../util/index":212,"bignumber.js":217}],173:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -9631,7 +9827,7 @@ module.exports = function (math) { */ math.squeeze = function squeeze (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('squeeze', arguments.length, 1); + throw new math.error.ArgumentsError('squeeze', arguments.length, 1); } if (isArray(x)) { @@ -9691,7 +9887,7 @@ module.exports = function (math) { return _setSubset(arguments[0], arguments[1], arguments[2], arguments[3]); default: // wrong number of arguments - throw new util.error.ArgumentsError('subset', arguments.length, 2, 4); + throw new math.error.ArgumentsError('subset', arguments.length, 2, 4); } }; @@ -9718,7 +9914,7 @@ module.exports = function (math) { return _getSubstring(value, index); } else { - throw new util.error.UnsupportedTypeError('subset', value); + throw new math.error.UnsupportedTypeError('subset', value); } } @@ -9777,7 +9973,7 @@ module.exports = function (math) { return _setSubstring(value, index, replacement, defaultValue); } else { - throw new util.error.UnsupportedTypeError('subset', value); + throw new math.error.UnsupportedTypeError('subset', value); } } @@ -9861,7 +10057,7 @@ module.exports = function (math) { */ math.transpose = function transpose (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('transpose', arguments.length, 1); + throw new math.error.ArgumentsError('transpose', arguments.length, 1); } var size = math.size(x).valueOf(); @@ -9917,10 +10113,12 @@ module.exports = function (math) { module.exports = function (math, settings) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), array = util.array, + toNumber = util.number.toNumber, isArray = Array.isArray; /** @@ -9946,18 +10144,19 @@ module.exports = function (math, settings) { else { // output an array or matrix var res = []; - var defaultValue = 0; - res = array.resize(res, args, defaultValue); + var defaultValue = (args[0] instanceof BigNumber) ? new BigNumber(0) : 0; + res = array.resize(res, args.map(toNumber), defaultValue); return asMatrix ? new Matrix(res) : res; } }; }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],177:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],177:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), collection = require('../../type/collection'), isNumber = util.number.isNumber, @@ -9974,12 +10173,14 @@ module.exports = function (math) { * Factorial only supports an integer value as argument. * For matrices, the function is evaluated element wise. * - * @Param {Number | Array | Matrix} x - * @return {Number | Array | Matrix} res + * @Param {Number | BigNumber | Array | Matrix} x + * @return {Number | BigNumber | Array | Matrix} res */ math.factorial = function factorial (x) { + var value, res; + if (arguments.length != 1) { - throw new util.error.ArgumentsError('factorial', arguments.length, 1); + throw new math.error.ArgumentsError('factorial', arguments.length, 1); } if (isNumber(x)) { @@ -9987,9 +10188,8 @@ module.exports = function (math) { throw new TypeError('Positive integer value expected in function factorial'); } - var value = x, - res = value; - value--; + value = x - 1; + res = x; while (value > 1) { res *= value; value--; @@ -10002,25 +10202,42 @@ module.exports = function (math) { return res; } + if (x instanceof BigNumber) { + if (!x.round().equals(x) || x.lt(0)) { + throw new TypeError('Positive integer value expected in function factorial'); + } + + var one = new BigNumber(1); + + value = x.minus(one); + res = x; + while (value.gt(one)) { + res = res.times(value); + value = value.minus(one); + } + + if (res.equals(0)) { + res = one; // 0! is per definition 1 + } + + return res; + } + if (isBoolean(x)) { return 1; // factorial(1) = 1, factorial(0) = 1 } - // TODO: implement BigNumber support for factorial - if (isCollection(x)) { return collection.deepMap(x, factorial); } - throw new util.error.UnsupportedTypeError('factorial', x); + throw new math.error.UnsupportedTypeError('factorial', x); }; }; -},{"../../type/collection":208,"../../util/index":212}],178:[function(require,module,exports){ +},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],178:[function(require,module,exports){ module.exports = function (math, settings) { - var util = require('../../util/index'), - - Matrix = require('../../type/Matrix'), + var Matrix = require('../../type/Matrix'), collection = require('../../type/collection'); // TODO: implement BigNumber support for random @@ -10085,7 +10302,7 @@ module.exports = function (math, settings) { random: function(arg1, arg2, arg3) { var size, min, max; if (arguments.length > 3) { - throw new util.error.ArgumentsError('random', arguments.length, 0, 3); + throw new math.error.ArgumentsError('random', arguments.length, 0, 3); // `random(max)` or `random(size)` } else if (arguments.length === 1) { @@ -10120,7 +10337,7 @@ module.exports = function (math, settings) { randomInt: function(arg1, arg2, arg3) { var size, min, max; if (arguments.length > 3 || arguments.length < 1) - throw new util.error.ArgumentsError('randomInt', arguments.length, 1, 3); + throw new math.error.ArgumentsError('randomInt', arguments.length, 1, 3); // `randomInt(max)` else if (arguments.length === 1) max = arg1; @@ -10149,10 +10366,10 @@ module.exports = function (math, settings) { pickRandom: function(possibles) { if (arguments.length !== 1) { - throw new util.error.ArgumentsError('pickRandom', arguments.length, 1); + throw new math.error.ArgumentsError('pickRandom', arguments.length, 1); } if (!Array.isArray(possibles)) { - throw new util.error.UnsupportedTypeError('pickRandom', possibles); + throw new math.error.UnsupportedTypeError('pickRandom', possibles); } // TODO: add support for matrices @@ -10199,7 +10416,7 @@ module.exports = function (math, settings) { math.pickRandom = uniformRandFunctions.pickRandom; }; -},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],179:[function(require,module,exports){ +},{"../../type/Matrix":205,"../../type/collection":208}],179:[function(require,module,exports){ module.exports = function (math) { var Matrix = require('../../type/Matrix'), collection = require('../../type/collection'), @@ -10432,6 +10649,7 @@ module.exports = function (math) { module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), collection = require('../../type/collection'), @@ -10454,7 +10672,7 @@ module.exports = function (math) { */ math.acos = function acos(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('acos', arguments.length, 1); + throw new math.error.ArgumentsError('acos', arguments.length, 1); } if (isNumber(x)) { @@ -10511,14 +10729,21 @@ module.exports = function (math) { return Math.acos(x); } - throw new util.error.UnsupportedTypeError('acos', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return acos(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('acos', x); }; }; -},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],183:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],183:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), collection = require('../../type/collection'), @@ -10541,7 +10766,7 @@ module.exports = function (math) { */ math.asin = function asin(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('asin', arguments.length, 1); + throw new math.error.ArgumentsError('asin', arguments.length, 1); } if (isNumber(x)) { @@ -10595,14 +10820,21 @@ module.exports = function (math) { return Math.asin(x); } - throw new util.error.UnsupportedTypeError('asin', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return asin(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('asin', x); }; }; -},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],184:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],184:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), collection = require('../../type/collection'), @@ -10625,7 +10857,7 @@ module.exports = function (math) { */ math.atan = function atan(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('atan', arguments.length, 1); + throw new math.error.ArgumentsError('atan', arguments.length, 1); } if (isNumber(x)) { @@ -10666,17 +10898,25 @@ module.exports = function (math) { return Math.atan(x); } - throw new util.error.UnsupportedTypeError('atan', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return atan(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('atan', x); }; }; -},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],185:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],185:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), collection = require('../../type/collection'), + toNumber = util.number.toNumber, isNumber = util.number.isNumber, isBoolean = util.boolean.isBoolean, isComplex = Complex.isComplex, @@ -10697,7 +10937,7 @@ module.exports = function (math) { */ math.atan2 = function atan2(y, x) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('atan2', arguments.length, 2); + throw new math.error.ArgumentsError('atan2', arguments.length, 2); } if (isNumber(y)) { @@ -10732,14 +10972,23 @@ module.exports = function (math) { return atan2(y, +x); } - throw new util.error.UnsupportedTypeError('atan2', y, x); + // TODO: implement bignumber support + if (y instanceof BigNumber) { + return atan2(toNumber(y), x); + } + if (x instanceof BigNumber) { + return atan2(y, toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('atan2', y, x); }; }; -},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],186:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],186:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -10764,7 +11013,7 @@ module.exports = function (math) { */ math.cos = function cos(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('cos', arguments.length, 1); + throw new math.error.ArgumentsError('cos', arguments.length, 1); } if (isNumber(x)) { @@ -10794,14 +11043,21 @@ module.exports = function (math) { return Math.cos(x); } - throw new util.error.UnsupportedTypeError('cos', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return cos(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('cos', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],187:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],187:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -10824,7 +11080,7 @@ module.exports = function (math) { */ math.cot = function cot(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('cot', arguments.length, 1); + throw new math.error.ArgumentsError('cot', arguments.length, 1); } if (isNumber(x)) { @@ -10856,14 +11112,21 @@ module.exports = function (math) { return cot(+x); } - throw new util.error.UnsupportedTypeError('cot', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return cot(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('cot', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],188:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],188:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -10886,7 +11149,7 @@ module.exports = function (math) { */ math.csc = function csc(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('csc', arguments.length, 1); + throw new math.error.ArgumentsError('csc', arguments.length, 1); } if (isNumber(x)) { @@ -10919,14 +11182,21 @@ module.exports = function (math) { return csc(+x); } - throw new util.error.UnsupportedTypeError('csc', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return csc(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('csc', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],189:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],189:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -10949,7 +11219,7 @@ module.exports = function (math) { */ math.sec = function sec(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('sec', arguments.length, 1); + throw new math.error.ArgumentsError('sec', arguments.length, 1); } if (isNumber(x)) { @@ -10981,14 +11251,21 @@ module.exports = function (math) { return sec(+x); } - throw new util.error.UnsupportedTypeError('sec', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return sec(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('sec', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],190:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],190:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -11013,7 +11290,7 @@ module.exports = function (math) { */ math.sin = function sin(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('sin', arguments.length, 1); + throw new math.error.ArgumentsError('sin', arguments.length, 1); } if (isNumber(x)) { @@ -11042,14 +11319,21 @@ module.exports = function (math) { return Math.sin(x); } - throw new util.error.UnsupportedTypeError('sin', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return sin(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('sin', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],191:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],191:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), + BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), Unit = require('../../type/Unit'), collection = require('../../type/collection'), @@ -11074,7 +11358,7 @@ module.exports = function (math) { */ math.tan = function tan(x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('tan', arguments.length, 1); + throw new math.error.ArgumentsError('tan', arguments.length, 1); } if (isNumber(x)) { @@ -11107,11 +11391,17 @@ module.exports = function (math) { return Math.tan(x); } - throw new util.error.UnsupportedTypeError('tan', x); + if (x instanceof BigNumber) { + // TODO: implement BigNumber support + // downgrade to Number + return tan(util.number.toNumber(x)); + } + + throw new math.error.UnsupportedTypeError('tan', x); }; }; -},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],192:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],192:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -11136,7 +11426,7 @@ module.exports = function (math) { */ math['in'] = function unit_in(x, unit) { if (arguments.length != 2) { - throw new util.error.ArgumentsError('in', arguments.length, 2); + throw new math.error.ArgumentsError('in', arguments.length, 2); } if (isUnit(x)) { @@ -11151,14 +11441,13 @@ module.exports = function (math) { return collection.deepMap2(x, unit, unit_in); } - throw new util.error.UnsupportedTypeError('in', x, unit); + throw new math.error.UnsupportedTypeError('in', x, unit); }; }; },{"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],193:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - object = util.object; + var object = require('../../util/object'); /** * Clone an object @@ -11170,17 +11459,16 @@ module.exports = function (math) { */ math.clone = function clone (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('clone', arguments.length, 1); + throw new math.error.ArgumentsError('clone', arguments.length, 1); } return object.clone(x); }; }; -},{"../../util/index":212}],194:[function(require,module,exports){ +},{"../../util/object":214}],194:[function(require,module,exports){ module.exports = function (math) { - var error = require('../../util/error'), - isMatrix = require('../../type/Matrix').isMatrix; + var isMatrix = require('../../type/Matrix').isMatrix; /** * Execute a callback method on each entry of the matrix or the array. @@ -11191,7 +11479,7 @@ module.exports = function (math) { */ math.forEach = function (x, callback) { if (arguments.length != 2) { - throw new error.ArgumentsError('forEach', arguments.length, 2); + throw new math.error.ArgumentsError('forEach', arguments.length, 2); } if (Array.isArray(x)) { @@ -11199,7 +11487,7 @@ module.exports = function (math) { } else if (isMatrix(x)) { return x.forEach(callback); } else { - throw new error.UnsupportedTypeError('forEach', x); + throw new math.error.UnsupportedTypeError('forEach', x); } }; @@ -11220,10 +11508,9 @@ module.exports = function (math) { }; }; -},{"../../type/Matrix":205,"../../util/error":211}],195:[function(require,module,exports){ +},{"../../type/Matrix":205}],195:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - string = util.string; + var string = require('../../util/string'); /** * Format a value of any type into a string. @@ -11243,18 +11530,18 @@ module.exports = function (math) { * Number notation. Choose from: * 'fixed' Always use regular number notation. * For example '123.40' and '14000000' - * 'scientific' Always use scientific notation. + * 'exponential' Always use exponential notation. * For example '1.234e+2' and '1.4e+7' * 'auto' (default) Regular number notation for numbers * having an absolute value between * `lower` and `upper` bounds, and uses - * scientific notation elsewhere. + * exponential notation elsewhere. * Lower bound is included, upper bound * is excluded. * For example '123.4' and '1.4e7'. * {Number} precision A number between 0 and 16 to round * the digits of the number. - * In case of notations 'scientific' and + * In case of notations 'exponential' and * 'auto', `precision` defines the total * number of significant digits returned * and is undefined by default. @@ -11262,10 +11549,10 @@ module.exports = function (math) { * `precision` defines the number of * significant digits after the decimal * point, and is 0 by default. - * {Object} scientific An object containing two parameters, + * {Object} exponential An object containing two parameters, * {Number} lower and {Number} upper, * used by notation 'auto' to determine - * when to return scientific notation. + * when to return exponential notation. * Default values are `lower=1e-3` and * `upper=1e5`. * Only applicable for notation `auto`. @@ -11283,7 +11570,7 @@ module.exports = function (math) { * format(21385, 2); // '21000' * format(12.071, {notation: 'fixed'}); // '12' * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' - * format(52.8, {notation: 'scientific'}); // '5.28e+1' + * format(52.8, {notation: 'exponential'}); // '5.28e+1' * * @param {*} value Value to be stringified * @param {Object | Function | Number} [options] @@ -11292,14 +11579,14 @@ module.exports = function (math) { math.format = function format (value, options) { var num = arguments.length; if (num !== 1 && num !== 2) { - throw new util.error.ArgumentsError('format', num, 1, 2); + throw new math.error.ArgumentsError('format', num, 1, 2); } return string.format(value, options); }; }; -},{"../../util/index":212}],196:[function(require,module,exports){ +},{"../../util/string":215}],196:[function(require,module,exports){ module.exports = function (math) { var util = require('../../util/index'), @@ -11423,8 +11710,7 @@ module.exports = function (math) { },{"../../type/Complex":202,"../../type/Unit":207,"../../util/index":212}],197:[function(require,module,exports){ module.exports = function (math) { - var error = require('../../util/error'), - isMatrix = require('../../type/Matrix').isMatrix; + var isMatrix = require('../../type/Matrix').isMatrix; /** * Create a new matrix or array with the results of the callback function executed on @@ -11437,7 +11723,7 @@ module.exports = function (math) { */ math.map = function (x, callback) { if (arguments.length != 2) { - throw new error.ArgumentsError('map', arguments.length, 2); + throw new math.error.ArgumentsError('map', arguments.length, 2); } if (Array.isArray(x)) { @@ -11445,7 +11731,7 @@ module.exports = function (math) { } else if (isMatrix(x)) { return x.map(callback); } else { - throw new error.UnsupportedTypeError('map', x); + throw new math.error.UnsupportedTypeError('map', x); } }; @@ -11467,10 +11753,9 @@ module.exports = function (math) { }; }; -},{"../../type/Matrix":205,"../../util/error":211}],198:[function(require,module,exports){ +},{"../../type/Matrix":205}],198:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), - string = util.string, + var string = require('../../util/string'), isString = string.isString; @@ -11501,7 +11786,7 @@ module.exports = function (math) { math.print = function print (template, values, precision) { var num = arguments.length; if (num != 2 && num != 3) { - throw new util.error.ArgumentsError('print', num, 2, 3); + throw new math.error.ArgumentsError('print', num, 2, 3); } if (!isString(template)) { @@ -11535,7 +11820,7 @@ module.exports = function (math) { }; }; -},{"../../util/index":212}],199:[function(require,module,exports){ +},{"../../util/string":215}],199:[function(require,module,exports){ module.exports = function (math) { /** * Wrap any value in a Selector, allowing to perform chained operations on @@ -11579,7 +11864,7 @@ module.exports = function (math) { },{}],200:[function(require,module,exports){ module.exports = function (math) { - var util = require('../../util/index'), + var types = require('../../util/types'), BigNumber = require('bignumber.js'), Complex = require('../../type/Complex'), @@ -11600,11 +11885,11 @@ module.exports = function (math) { */ math['typeof'] = function _typeof (x) { if (arguments.length != 1) { - throw new util.error.ArgumentsError('typeof', arguments.length, 1); + throw new math.error.ArgumentsError('typeof', arguments.length, 1); } // JavaScript types - var type = util.types.type(x); + var type = types.type(x); // math.js types if (type === 'object') { @@ -11623,7 +11908,7 @@ module.exports = function (math) { }; }; -},{"../../type/Complex":202,"../../type/Help":203,"../../type/Index":204,"../../type/Matrix":205,"../../type/Range":206,"../../type/Unit":207,"../../util/index":212,"bignumber.js":217}],201:[function(require,module,exports){ +},{"../../type/Complex":202,"../../type/Help":203,"../../type/Index":204,"../../type/Matrix":205,"../../type/Range":206,"../../type/Unit":207,"../../util/types":216,"bignumber.js":217}],201:[function(require,module,exports){ var object = require('./util/object'); /** @@ -11713,19 +11998,20 @@ function mathjs (settings) { throw new Error('Moved to math.expression.Parser'); }; - // types (Matrix, Complex, Unit, ...) math.type = {}; math.type.BigNumber = require('bignumber.js'); - math.type.Complex = require('./type/Complex.js'); - math.type.Range = require('./type/Range.js'); - math.type.Index = require('./type/Index.js'); - math.type.Matrix = require('./type/Matrix.js'); - math.type.Unit = require('./type/Unit.js'); - math.type.Help = require('./type/Help.js'); + math.type.Complex = require('./type/Complex'); + math.type.Range = require('./type/Range'); + math.type.Index = require('./type/Index'); + math.type.Matrix = require('./type/Matrix'); + math.type.Unit = require('./type/Unit'); + math.type.Help = require('./type/Help'); - math.collection = require('./type/collection.js'); + math.collection = require('./type/collection'); + // error utility functions + require('./type/error')(math); // expression parser require('./function/expression/eval.js')(math, _settings); @@ -11879,7 +12165,7 @@ for (var prop in instance) { if (typeof window !== 'undefined') { window.math = mathjs; } -},{"./chaining/Selector.js":2,"./constants.js":3,"./expression/Parser.js":4,"./expression/Scope.js":5,"./expression/docs/index.js":103,"./expression/node/index.js":116,"./function/arithmetic/abs.js":117,"./function/arithmetic/add.js":118,"./function/arithmetic/ceil.js":119,"./function/arithmetic/cube.js":120,"./function/arithmetic/divide.js":121,"./function/arithmetic/edivide.js":122,"./function/arithmetic/emultiply.js":123,"./function/arithmetic/epow.js":124,"./function/arithmetic/equal.js":125,"./function/arithmetic/exp.js":126,"./function/arithmetic/fix.js":127,"./function/arithmetic/floor.js":128,"./function/arithmetic/gcd.js":129,"./function/arithmetic/larger.js":130,"./function/arithmetic/largereq.js":131,"./function/arithmetic/lcm.js":132,"./function/arithmetic/log.js":133,"./function/arithmetic/log10.js":134,"./function/arithmetic/mod.js":135,"./function/arithmetic/multiply.js":136,"./function/arithmetic/pow.js":137,"./function/arithmetic/round.js":138,"./function/arithmetic/sign.js":139,"./function/arithmetic/smaller.js":140,"./function/arithmetic/smallereq.js":141,"./function/arithmetic/sqrt.js":142,"./function/arithmetic/square.js":143,"./function/arithmetic/subtract.js":144,"./function/arithmetic/unary.js":145,"./function/arithmetic/unequal.js":146,"./function/arithmetic/xgcd.js":147,"./function/complex/arg.js":148,"./function/complex/conj.js":149,"./function/complex/im.js":150,"./function/complex/re.js":151,"./function/construction/bignumber":152,"./function/construction/boolean.js":153,"./function/construction/complex.js":154,"./function/construction/index.js":155,"./function/construction/matrix.js":156,"./function/construction/number.js":157,"./function/construction/parser.js":158,"./function/construction/string.js":159,"./function/construction/unit.js":160,"./function/expression/eval.js":161,"./function/expression/help.js":162,"./function/expression/parse.js":163,"./function/matrix/concat.js":164,"./function/matrix/det.js":165,"./function/matrix/diag.js":166,"./function/matrix/eye.js":167,"./function/matrix/inv.js":168,"./function/matrix/ones.js":169,"./function/matrix/range.js":170,"./function/matrix/resize.js":171,"./function/matrix/size.js":172,"./function/matrix/squeeze.js":173,"./function/matrix/subset.js":174,"./function/matrix/transpose.js":175,"./function/matrix/zeros.js":176,"./function/probability/factorial.js":177,"./function/probability/random.js":178,"./function/statistics/max.js":179,"./function/statistics/mean.js":180,"./function/statistics/min.js":181,"./function/trigonometry/acos.js":182,"./function/trigonometry/asin.js":183,"./function/trigonometry/atan.js":184,"./function/trigonometry/atan2.js":185,"./function/trigonometry/cos.js":186,"./function/trigonometry/cot.js":187,"./function/trigonometry/csc.js":188,"./function/trigonometry/sec.js":189,"./function/trigonometry/sin.js":190,"./function/trigonometry/tan.js":191,"./function/units/in.js":192,"./function/utils/clone.js":193,"./function/utils/forEach.js":194,"./function/utils/format.js":195,"./function/utils/import.js":196,"./function/utils/map.js":197,"./function/utils/print.js":198,"./function/utils/select.js":199,"./function/utils/typeof.js":200,"./type/Complex.js":202,"./type/Help.js":203,"./type/Index.js":204,"./type/Matrix.js":205,"./type/Range.js":206,"./type/Unit.js":207,"./type/collection.js":208,"./util/object":214,"bignumber.js":217}],202:[function(require,module,exports){ +},{"./chaining/Selector.js":2,"./constants.js":3,"./expression/Parser.js":4,"./expression/Scope.js":5,"./expression/docs/index.js":103,"./expression/node/index.js":116,"./function/arithmetic/abs.js":117,"./function/arithmetic/add.js":118,"./function/arithmetic/ceil.js":119,"./function/arithmetic/cube.js":120,"./function/arithmetic/divide.js":121,"./function/arithmetic/edivide.js":122,"./function/arithmetic/emultiply.js":123,"./function/arithmetic/epow.js":124,"./function/arithmetic/equal.js":125,"./function/arithmetic/exp.js":126,"./function/arithmetic/fix.js":127,"./function/arithmetic/floor.js":128,"./function/arithmetic/gcd.js":129,"./function/arithmetic/larger.js":130,"./function/arithmetic/largereq.js":131,"./function/arithmetic/lcm.js":132,"./function/arithmetic/log.js":133,"./function/arithmetic/log10.js":134,"./function/arithmetic/mod.js":135,"./function/arithmetic/multiply.js":136,"./function/arithmetic/pow.js":137,"./function/arithmetic/round.js":138,"./function/arithmetic/sign.js":139,"./function/arithmetic/smaller.js":140,"./function/arithmetic/smallereq.js":141,"./function/arithmetic/sqrt.js":142,"./function/arithmetic/square.js":143,"./function/arithmetic/subtract.js":144,"./function/arithmetic/unary.js":145,"./function/arithmetic/unequal.js":146,"./function/arithmetic/xgcd.js":147,"./function/complex/arg.js":148,"./function/complex/conj.js":149,"./function/complex/im.js":150,"./function/complex/re.js":151,"./function/construction/bignumber":152,"./function/construction/boolean.js":153,"./function/construction/complex.js":154,"./function/construction/index.js":155,"./function/construction/matrix.js":156,"./function/construction/number.js":157,"./function/construction/parser.js":158,"./function/construction/string.js":159,"./function/construction/unit.js":160,"./function/expression/eval.js":161,"./function/expression/help.js":162,"./function/expression/parse.js":163,"./function/matrix/concat.js":164,"./function/matrix/det.js":165,"./function/matrix/diag.js":166,"./function/matrix/eye.js":167,"./function/matrix/inv.js":168,"./function/matrix/ones.js":169,"./function/matrix/range.js":170,"./function/matrix/resize.js":171,"./function/matrix/size.js":172,"./function/matrix/squeeze.js":173,"./function/matrix/subset.js":174,"./function/matrix/transpose.js":175,"./function/matrix/zeros.js":176,"./function/probability/factorial.js":177,"./function/probability/random.js":178,"./function/statistics/max.js":179,"./function/statistics/mean.js":180,"./function/statistics/min.js":181,"./function/trigonometry/acos.js":182,"./function/trigonometry/asin.js":183,"./function/trigonometry/atan.js":184,"./function/trigonometry/atan2.js":185,"./function/trigonometry/cos.js":186,"./function/trigonometry/cot.js":187,"./function/trigonometry/csc.js":188,"./function/trigonometry/sec.js":189,"./function/trigonometry/sin.js":190,"./function/trigonometry/tan.js":191,"./function/units/in.js":192,"./function/utils/clone.js":193,"./function/utils/forEach.js":194,"./function/utils/format.js":195,"./function/utils/import.js":196,"./function/utils/map.js":197,"./function/utils/print.js":198,"./function/utils/select.js":199,"./function/utils/typeof.js":200,"./type/Complex":202,"./type/Help":203,"./type/Index":204,"./type/Matrix":205,"./type/Range":206,"./type/Unit":207,"./type/collection":208,"./type/error":209,"./util/object":214,"bignumber.js":217}],202:[function(require,module,exports){ var util = require('../util/index'), number = util.number, @@ -11919,8 +12205,7 @@ function Complex(re, im) { case 2: if (!isNumber(re) || !isNumber(im)) { - throw new TypeError( - 'Two numbers expected in Complex constructor'); + throw new TypeError('Two numbers expected in Complex constructor'); } this.re = re; this.im = im; @@ -12015,7 +12300,7 @@ function parseNumber () { next(); } - // check for scientific notation like "2.3e-4" or "1.23e50" + // check for exponential notation like "2.3e-4" or "1.23e50" if (c == 'E' || c == 'e') { number += c; next(); @@ -12707,7 +12992,7 @@ Matrix.prototype.subset = function subset(index, replacement, defaultValue) { return _set(this, index, replacement, defaultValue); default: - throw new util.error.ArgumentsError('subset', arguments.length, 1, 3); + throw new SyntaxError('Wrong number of arguments'); } }; @@ -13521,7 +13806,7 @@ function parseNumber () { next(); } - // check for scientific notation like "2.3e-4" or "1.23e50" + // check for exponential notation like "2.3e-4" or "1.23e50" if (c == 'E' || c == 'e') { number += c; next(); @@ -14269,6 +14554,11 @@ exports.deepMap2 = function deepMap2(array1, array2, callback) { res[i] = deepMap2(array1, array2[i], callback); } } + else if (array2 instanceof Matrix) { + // callback(object, matrix) + res = deepMap2(array1, array2.valueOf(), callback); + return new Matrix(res); + } else { // callback(object, object) res = callback(array1, array2); @@ -14376,6 +14666,60 @@ exports.deepForEach = function deepForEach (array, callback) { }; },{"../util/index":212,"./Matrix":205}],209:[function(require,module,exports){ +module.exports = function (math) { + var types = require('./../util/types'); + + // export the error constructors to namespace math.error.* + var error = {}; + math.error = error; + + /** + * Create a TypeError with message: + * 'Function does not support a parameter of type '; + * @param {String} name Function name + * @param {*} [value1] + * @param {*...} [value_n] + * @extends TypeError + */ + error.UnsupportedTypeError = function UnsupportedTypeError(name, value1, value_n) { + if (arguments.length == 2) { + var type1 = math['typeof'](value1); + this.message = 'Function ' + name + '(' + type1 + ') not supported'; + } + else if (arguments.length > 2) { + var values = Array.prototype.splice.call(arguments, 1); + var types = values.map(function (value) { + return math['typeof'](value); + }); + this.message = 'Function ' + name + '(' + types.join(', ') + ') not supported'; + } + else { + this.message = 'Unsupported type of argument in function ' + name; + } + }; + + error.UnsupportedTypeError.prototype = new TypeError(); + error.UnsupportedTypeError.prototype.name = 'UnsupportedTypeError'; + + /** + * Create a syntax error with the message: + * 'Wrong number of arguments in function ( provided, - expected)' + * @param {String} name Function name + * @param {Number} count Actual argument count + * @param {Number} min Minimum required argument count + * @param {Number} [max] Maximum required argument count + * @extends SyntaxError + */ + error.ArgumentsError = function ArgumentsError(name, count, min, max) { + this.message = 'Wrong number of arguments in function ' + name + + ' (' + count + ' provided, ' + + min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; + }; + + error.ArgumentsError.prototype = new SyntaxError(); + error.ArgumentsError.prototype.name = 'ArgumentError'; +}; +},{"./../util/types":216}],210:[function(require,module,exports){ var number = require('./number'), string = require('./string'), object = require('./object'), @@ -14638,7 +14982,7 @@ exports.unsqueeze = function unsqueeze(array, dims) { * @return {Boolean} isArray */ exports.isArray = isArray; -},{"./number":213,"./object":214,"./string":215,"./types":216}],210:[function(require,module,exports){ +},{"./number":213,"./object":214,"./string":215,"./types":216}],211:[function(require,module,exports){ /** * Test whether value is a Boolean * @param {*} value @@ -14648,65 +14992,15 @@ exports.isBoolean = function isBoolean(value) { return (value instanceof Boolean) || (typeof value == 'boolean'); }; -},{}],211:[function(require,module,exports){ -var types = require('./types'); - -/** - * Create a TypeError with message: - * 'Function does not support a parameter of type '; - * @param {String} name Function name - * @param {*} value1 - * @param {*} [value2] - * @extends TypeError - */ -exports.UnsupportedTypeError = function UnsupportedTypeError(name, value1, value2) { - if (arguments.length == 2) { - var t = types.type(value1); - this.message = 'Function ' + name + '(' + t + ') not supported'; - } - else if (arguments.length > 2) { - var args = []; - for (var i = 1; i < arguments.length; i++) { - args.push(types.type(arguments[i])); - } - this.message = 'Function ' + name + '(' + args.join(', ') + ') not supported'; - } - else { - this.message = 'Unsupported type of argument in function ' + name; - } -}; - -exports.UnsupportedTypeError.prototype = new TypeError(); -exports.UnsupportedTypeError.prototype.name = 'UnsupportedTypeError'; - -/** - * Create a syntax error with the message: - * 'Wrong number of arguments in function ( provided, - expected)' - * @param {String} name Function name - * @param {Number} count Actual argument count - * @param {Number} min Minimum required argument count - * @param {Number} [max] Maximum required argument count - * @extends SyntaxError - */ -exports.ArgumentsError = function ArgumentsError(name, count, min, max) { - this.message = 'Wrong number of arguments in function ' + name + - ' (' + count + ' provided, ' + - min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; -}; - -exports.ArgumentsError.prototype = new SyntaxError(); -exports.ArgumentsError.prototype.name = 'ArgumentError'; - -},{"./types":216}],212:[function(require,module,exports){ +},{}],212:[function(require,module,exports){ exports.array = require('./array'); exports.boolean = require('./boolean'); -exports.error = require('./error'); exports.number = require('./number'); exports.object = require('./object'); exports.string = require('./string'); exports.types = require('./types'); -},{"./array":209,"./boolean":210,"./error":211,"./number":213,"./object":214,"./string":215,"./types":216}],213:[function(require,module,exports){ +},{"./array":210,"./boolean":211,"./number":213,"./object":214,"./string":215,"./types":216}],213:[function(require,module,exports){ var BigNumber = require('bignumber.js'); /** @@ -14763,18 +15057,18 @@ exports.sign = function sign (x) { * Number notation. Choose from: * 'fixed' Always use regular number notation. * For example '123.40' and '14000000' - * 'scientific' Always use scientific notation. + * 'exponential' Always use exponential notation. * For example '1.234e+2' and '1.4e+7' * 'auto' (default) Regular number notation for numbers * having an absolute value between * `lower` and `upper` bounds, and uses - * scientific notation elsewhere. + * exponential notation elsewhere. * Lower bound is included, upper bound * is excluded. * For example '123.4' and '1.4e7'. * {Number} precision A number between 0 and 16 to round * the digits of the number. - * In case of notations 'scientific' and + * In case of notations 'exponential' and * 'auto', `precision` defines the total * number of significant digits returned * and is undefined by default. @@ -14782,10 +15076,10 @@ exports.sign = function sign (x) { * `precision` defines the number of * significant digits after the decimal * point, and is 0 by default. - * {Object} scientific An object containing two parameters, + * {Object} exponential An object containing two parameters, * {Number} lower and {Number} upper, * used by notation 'auto' to determine - * when to return scientific notation. + * when to return exponential notation. * Default values are `lower=1e-3` and * `upper=1e5`. * Only applicable for notation `auto`. @@ -14803,7 +15097,7 @@ exports.sign = function sign (x) { * format(21385, 2); // '21000' * format(12.071, {notation: 'fixed'}); // '12' * format(2.3, {notation: 'fixed', precision: 2}); // '2.30' - * format(52.8, {notation: 'scientific'}); // '5.28e+1' + * format(52.8, {notation: 'exponential'}); // '5.28e+1' * * @param {Number | BigNumber} value * @param {Object | Function | Number} [options] @@ -14850,43 +15144,69 @@ exports.format = function format(value, options) { // handle the various notations switch (notation) { case 'fixed': - return value.toFixed(precision || 0); // The (precision || 0) is to defeat a bug in BigNumber + return exports.toFixed(value, precision); + // TODO: notation 'scientific' is deprecated since version 0.16.0, remove this some day case 'scientific': - return exports.toScientific(value, precision); + throw new Error('Format notation "scientific" is deprecated. Use "exponential" instead.'); + + case 'exponential': + return exports.toExponential(value, precision); case 'auto': - // determine lower and upper bound for scientific notation. + // determine lower and upper bound for exponential notation. + // TODO: implement support for upper and lower to be BigNumbers themselves var lower = 1e-3; var upper = 1e5; - if (options && options.scientific) { - if (options.scientific.lower !== undefined) { - lower = options.scientific.lower; + if (options && options.exponential) { + if (options.exponential.lower !== undefined) { + lower = options.exponential.lower; } - if (options.scientific.upper !== undefined) { - upper = options.scientific.upper; + if (options.exponential.upper !== undefined) { + upper = options.exponential.upper; } } + else if (options && options.scientific) { + // TODO: 'options.scientific' is deprecated since version 0.16.0, remove this some day + throw new Error('options.scientific is deprecated, use options.exponential instead.'); + } + + // adjust BigNumber configuration + var isBigNumber = value instanceof BigNumber; + if (isBigNumber) { + var oldScientific = BigNumber.config().EXPONENTIAL_AT; + BigNumber.config({ + EXPONENTIAL_AT: [ + Math.round(Math.log(lower) / Math.LN10), + Math.round(Math.log(upper) / Math.LN10) + ] + }); + } // handle special case zero if (_isZero(value)) { return '0'; } - // determine whether or not to output scientific notation + // determine whether or not to output exponential notation var str; if (_isBetween(value, lower, upper)) { // normal number notation - if (value instanceof BigNumber) { + if (isBigNumber) { str = new BigNumber(value.toPrecision(precision)).toString(); } else { // Number - str = parseFloat(value.toPrecision(precision)) + ''; + str = parseFloat(value.toPrecision(precision ? Math.min(precision, 21) : precision)) + ''; } } else { - // scientific notation - str = exports.toScientific(value, precision); + // exponential notation + str = exports.toExponential(value, precision); + } + + // restore BigNumber configuration + if (isBigNumber) { + BigNumber.config({EXPONENTIAL_AT: oldScientific}); } // remove trailing zeros after the decimal point @@ -14898,7 +15218,7 @@ exports.format = function format(value, options) { default: throw new Error('Unknown notation "' + notation + '". ' + - 'Choose "auto", "scientific", or "fixed".'); + 'Choose "auto", "exponential", or "fixed".'); } }; @@ -14936,22 +15256,44 @@ function _isBetween(value, lower, upper) { } /** - * Format a number in scientific notation. Like '1.23e+5', '2.3e+0', '3.500e-3' - * @param {Number} value + * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' + * @param {Number | BigNumber} value * @param {Number} [precision] Number of digits in formatted output. * If not provided, the maximum available digits * is used. * @returns {string} str */ -exports.toScientific = function toScientific (value, precision) { +exports.toExponential = function toExponential (value, precision) { if (precision !== undefined) { - return value.toExponential(precision - 1); + if (value instanceof BigNumber) { + return value.toExponential(precision - 1); + } + else { // Number + return value.toExponential(Math.min(precision - 1, 20)); + } } else { return value.toExponential(); } }; +/** + * Format a number with fixed notation. + * @param {Number | BigNumber} value + * @param {Number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. + */ +exports.toFixed = function toFixed (value, precision) { + if (value instanceof BigNumber) { + return value.toFixed(precision || 0); + // Note: the (precision || 0) is needed as the toFixed of BigNumber has an + // undefined default precision instead of 0. + } + else { // Number + return value.toFixed(Math.min(precision, 20)); + } +}; + /** * Count the number of significant digits of a number. * @@ -14966,7 +15308,7 @@ exports.toScientific = function toScientific (value, precision) { exports.digits = function digits (value) { return value .toExponential() - .replace(/e[\+\-0-9]*$/, '') // remove scientific notation + .replace(/e[\+\-0-9]*$/, '') // remove exponential notation .replace( /^0\.0*|\./, '') // remove decimal point and leading zeros .length }; @@ -15135,7 +15477,7 @@ exports.deepEqual = function deepEqual (a, b) { } }; -},{"./boolean":210,"./number":213,"./string":215}],215:[function(require,module,exports){ +},{"./boolean":211,"./number":213,"./string":215}],215:[function(require,module,exports){ var number = require('./number'), BigNumber = require('bignumber.js'); @@ -15326,6 +15668,7 @@ exports.type = function type (x) { // The exponent value at and above which toString returns exponential notation. // Number type: 21 TO_EXP_POS = 21, // 0 to MAX + TO_EXP_POS = 21, // 0 to MAX // RANGE : [MIN_EXP, MAX_EXP] diff --git a/dist/math.min.js b/dist/math.min.js index c7d408aae..be7b8404e 100644 --- a/dist/math.min.js +++ b/dist/math.min.js @@ -6,8 +6,8 @@ * It features real and complex numbers, units, matrices, a large set of * mathematical functions, and a flexible expression parser. * - * @version 0.16.0-SNAPSHOT - * @date 2013-11-23 + * @version 0.16.0 + * @date 2013-11-28 * * @license * Copyright (C) 2013 Jos de Jong @@ -24,9 +24,9 @@ * License for the specific language governing permissions and limitations under * the License. */ -!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.mathjs=e():"undefined"!=typeof global?global.mathjs=e():"undefined"!=typeof self&&(self.mathjs=e())}(function(){var e;return function t(e,n,r){function i(a,s){if(!n[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=n[a]={exports:{}};e[a][0].call(c.exports,function(t){var n=e[a][1][t];return i(n?n:t)},c,c.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;ar;r++)n[r].clear();this.clearCache()},clearCache:function(){this.cache={}}},n.context=[],t.exports=n},{"../type/Unit":207}],6:[function(e,t){t.exports={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]}},{}],7:[function(e,t){t.exports={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]}},{}],8:[function(e,t){t.exports={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]}},{}],9:[function(e,t){t.exports={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]}},{}],10:[function(e,t){t.exports={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]}},{}],11:[function(e,t){t.exports={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]}},{}],12:[function(e,t){t.exports={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]}},{}],13:[function(e,t){t.exports={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]}},{}],14:[function(e,t){t.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"]}},{}],15:[function(e,t){t.exports={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]}},{}],16:[function(e,t){t.exports={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]}},{}],17:[function(e,t){t.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"]}},{}],18:[function(e,t){t.exports={name:"tau",category:"Constants",syntax:["pi"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]}},{}],19:[function(e,t){t.exports={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]}},{}],20:[function(e,t){t.exports={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]}},{}],21:[function(e,t){t.exports={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["2.1 + 3.6","ans - 3.6","3 + 2i",'"hello" + " world"',"3 cm + 2 inch"],seealso:["subtract"]}},{}],22:[function(e,t){t.exports={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity.If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]}},{}],23:[function(e,t){t.exports={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]}},{}],24:[function(e,t){t.exports={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["2 / 3","ans * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]}},{}],25:[function(e,t){t.exports={name:"edivide",category:"Operators",syntax:["x ./ y","edivide(x, y)"],description:"divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","emultiply","divide"]}},{}],26:[function(e,t){t.exports={name:"emultiply",category:"Operators",syntax:["x .* y","emultiply(x, y)"],description:"multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","edivide"]}},{}],27:[function(e,t){t.exports={name:"epow",category:"Operators",syntax:["x .^ y","epow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]}},{}],28:[function(e,t){t.exports={name:"equal",category:"Operators",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns 1 if the values are equal, and 0 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"]}},{}],29:[function(e,t){t.exports={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["square","multiply","log"]}},{}],30:[function(e,t){t.exports={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero.If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]}},{}],31:[function(e,t){t.exports={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]}},{}],32:[function(e,t){t.exports={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]}},{}],33:[function(e,t){t.exports={name:"larger",category:"Operators",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns 1 if x is larger than y, and 0 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"]}},{}],34:[function(e,t){t.exports={name:"largereq",category:"Operators",syntax:["x >= y","largereq(x, y)"],description:"Check if value x is larger or equal to y. Returns 1 if x is larger or equal to y, and 0 if not.",examples:["2 > 1+1","2 >= 1+1","a = 3.2","b = 6-2.8","(a > b)"],seealso:["equal","unequal","smallereq","smaller","largereq"]}},{}],35:[function(e,t){t.exports={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]}},{}],36:[function(e,t){t.exports={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 3","log(1000, 10)","log(1000) / log(10)","b = logb(1024, 2)","2 ^ b"],seealso:["exp","log10"]}},{}],37:[function(e,t){t.exports={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(1000)","10 ^ 3","log10(0.01)","log(1000) / log(10)","log(1000, 10)"],seealso:["exp","log"]}},{}],38:[function(e,t){t.exports={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","function isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:[]}},{}],39:[function(e,t){t.exports={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["2.1 * 3.6","ans / 3.6","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]}},{}],40:[function(e,t){t.exports={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3 = 8","2*2*2","1 + e ^ (pi * i)"],seealso:["unequal","smaller","larger","smallereq","largereq"]}},{}],41:[function(e,t){t.exports={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]}},{}],42:[function(e,t){t.exports={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]}},{}],43:[function(e,t){t.exports={name:"smaller",category:"Operators",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns 1 if x is smaller than y, and 0 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"]}},{}],44:[function(e,t){t.exports={name:"smallereq",category:"Operators",syntax:["x <= y","smallereq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns 1 if x is smaller than y, and 0 if not.",examples:["2 < 1+1","2 <= 1+1","a = 3.2","b = 6-2.8","(a < b)"],seealso:["equal","unequal","larger","smaller","largereq"]}},{}],45:[function(e,t){t.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"]}},{}],46:[function(e,t){t.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"]}},{}],47:[function(e,t){t.exports={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["5.3 - 2","ans + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]}},{}],48:[function(e,t){t.exports={name:"unary",category:"Operators",syntax:["-x","unary(x)"],description:"Inverse the sign of a value.",examples:["-4.5","-(-5.6)"],seealso:["add","subtract"]}},{}],49:[function(e,t){t.exports={name:"unequal",category:"Operators",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns 1 if the values are unequal, and 0 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"]}},{}],50:[function(e,t){t.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"]}},{}],51:[function(e,t){t.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"]}},{}],52:[function(e,t){t.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"]}},{}],53:[function(e,t){t.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"]}},{}],54:[function(e,t){t.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"]}},{}],55:[function(e,t){t.exports={name:"bignumber",category:"Type",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","index","matrix","string","unit"]}},{}],56:[function(e,t){t.exports={name:"boolean",category:"Type",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]}},{}],57:[function(e,t){t.exports={name:"complex",category:"Type",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]}},{}],58:[function(e,t){t.exports={name:"index",category:"Type",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]}},{}],59:[function(e,t){t.exports={name:"matrix",category:"Type",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()","matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])"],seealso:["bignumber","boolean","complex","index","number","string","unit"]}},{}],60:[function(e,t){t.exports={name:"number",category:"Type",syntax:["x","number(x)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]}},{}],61:[function(e,t){t.exports={name:"string",category:"Type",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]}},{}],62:[function(e,t){t.exports={name:"unit",category:"Type",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]}},{}],63:[function(e,t){t.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:[]}},{}],64:[function(e,t){t.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:[]}},{}],65:[function(e,t){t.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 first 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)","[a, b]","concat(a, b, 2)","[a; b]"],seealso:["det","diag","eye","inv","ones","range","size","squeeze","subset","transpose","zeros"]}},{}],66:[function(e,t){t.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","transpose","zeros"]}},{}],67:[function(e,t){t.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","transpose","zeros"]}},{}],68:[function(e,t){t.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","transpose","zeros"]}},{}],69:[function(e,t){t.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","transpose","zeros"]}},{}],70:[function(e,t){t.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","transpose","zeros"]}},{}],71:[function(e,t){t.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","transpose","zeros"]}},{}],72:[function(e,t){t.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], 0)","resize(2, [2, 3], 0)",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze"]}},{}],73:[function(e,t){t.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","transpose","zeros"]}},{}],74:[function(e,t){t.exports={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove singleton dimensions from a matrix.",examples:["a = zeros(1,3,2)","size(squeeze(a))","b = zeros(3,1,1)","size(squeeze(b))"],seealso:["concat","det","diag","eye","inv","ones","range","size","subset","transpose","zeros"]}},{}],75:[function(e,t){t.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","transpose","zeros"]}},{}],76:[function(e,t){t.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","zeros"]}},{}],77:[function(e,t){t.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","transpose"]}},{}],78:[function(e,t){t.exports={name:"distribution",category:"Probability",syntax:["distribution(name)","distribution(name, arg1, arg2, ...)"],description:'Create a distribution object of a specific type. A distribution object contains functions `random([size,] [min,] [max])`, `randomInt([size,] [min,] [max])`, and `pickRandom(array)`. Available types of distributions: "uniform", "normal". Note that the function distribution is currently not available via the expression parser.',examples:[],seealso:["random","randomInt"]}},{}],79:[function(e,t){t.exports={name:"factorial",category:"Probability",syntax:["x!","factorial(x)"],description:"Compute the factorial of a value",examples:["5!","5*4*3*2*1","3!"],seealso:[]}},{}],80:[function(e,t){t.exports={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])"],seealso:["distribution","random","randomInt"]}},{}],81:[function(e,t){t.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:["distribution","pickRandom","randomInt"]}},{}],82:[function(e,t){t.exports={name:"randInt",category:"Probability",syntax:["randInt()","randInt(max)","randInt(min, max)","randInt(size)","randInt(size, max)","randInt(size, min, max)"],description:"Return a random integer number",examples:["randInt()","randInt(10, 20)","randInt([2, 3], 10)"],seealso:["distribution","pickRandom","random"]}},{}],83:[function(e,t){t.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], 0)","max([2, 5; 4, 3], 1)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","min"]}},{}],84:[function(e,t){t.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], 0)","mean([2, 5; 4, 3], 1)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","min"]}},{}],85:[function(e,t){t.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], 0)","min([2, 5; 4, 3], 1)","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","min"]}},{}],86:[function(e,t){t.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","acos","asin"]}},{}],87:[function(e,t){t.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","asin"]}},{}],88:[function(e,t){t.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"]}},{}],89:[function(e,t){t.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"]}},{}],90:[function(e,t){t.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"]}},{}],91:[function(e,t){t.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"]}},{}],92:[function(e,t){t.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"]}},{}],93:[function(e,t){t.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"]}},{}],94:[function(e,t){t.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"]}},{}],95:[function(e,t){t.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"]}},{}],96:[function(e,t){t.exports={name:"in",category:"Units",syntax:["x in unit","in(x, unit)"],description:"Change the unit of a value.",examples:["5 inch in cm","3.2kg in g","16 bytes in bits"],seealso:[]}},{}],97:[function(e,t){t.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:[]}},{}],98:[function(e,t){t.exports={name:"forEach",category:"Utils",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:[]}},{}],99:[function(e,t){t.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"]}},{}],100:[function(e,t){t.exports={name:"import",category:"Utils",syntax:["import(string)"],description:"Import functions from a file.",examples:['import("numbers")','import("./mylib.js")'],seealso:[]}},{}],101:[function(e,t){t.exports={name:"map",category:"Utils",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 math.max(val, 1.5) })"],seealso:[]}},{}],102:[function(e,t){t.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:[]}},{}],103:[function(e,t,n){n.e=e("./constants/e"),n.E=e("./constants/e"),n["false"]=e("./constants/false"),n.i=e("./constants/i"),n.Infinity=e("./constants/Infinity"),n.LN2=e("./constants/LN2"),n.LN10=e("./constants/LN10"),n.LOG2E=e("./constants/LOG2E"),n.LOG10E=e("./constants/LOG10E"),n.NaN=e("./constants/NaN"),n.pi=e("./constants/pi"),n.PI=e("./constants/pi"),n.SQRT1_2=e("./constants/SQRT1_2"),n.SQRT2=e("./constants/SQRT2"),n.tau=e("./constants/tau"),n["true"]=e("./constants/true"),n.abs=e("./function/arithmetic/abs"),n.add=e("./function/arithmetic/add"),n.ceil=e("./function/arithmetic/ceil"),n.cube=e("./function/arithmetic/cube"),n.divide=e("./function/arithmetic/divide"),n.edivide=e("./function/arithmetic/edivide"),n.emultiply=e("./function/arithmetic/emultiply"),n.epow=e("./function/arithmetic/epow"),n.equal=e("./function/arithmetic/equal"),n.exp=e("./function/arithmetic/exp"),n.fix=e("./function/arithmetic/fix"),n.floor=e("./function/arithmetic/floor"),n.gcd=e("./function/arithmetic/gcd"),n.larger=e("./function/arithmetic/larger"),n.largereq=e("./function/arithmetic/largereq"),n.lcm=e("./function/arithmetic/lcm"),n.log=e("./function/arithmetic/log"),n.log10=e("./function/arithmetic/log10"),n.mod=e("./function/arithmetic/mod"),n.multiply=e("./function/arithmetic/multiply"),n.pow=e("./function/arithmetic/pow"),n.round=e("./function/arithmetic/round"),n.sign=e("./function/arithmetic/sign"),n.smaller=e("./function/arithmetic/smaller"),n.smallereq=e("./function/arithmetic/smallereq"),n.sqrt=e("./function/arithmetic/sqrt"),n.square=e("./function/arithmetic/square"),n.subtract=e("./function/arithmetic/subtract"),n.unary=e("./function/arithmetic/unary"),n.unequal=e("./function/arithmetic/unequal"),n.xgcd=e("./function/arithmetic/xgcd"),n.arg=e("./function/complex/arg"),n.conj=e("./function/complex/conj"),n.re=e("./function/complex/re"),n.im=e("./function/complex/im"),n.bignumber=e("./function/construction/bignumber"),n.boolean=e("./function/construction/boolean"),n.complex=e("./function/construction/complex"),n.index=e("./function/construction/index"),n.matrix=e("./function/construction/matrix"),n.number=e("./function/construction/number"),n.string=e("./function/construction/string"),n.unit=e("./function/construction/unit"),n.eval=e("./function/expression/eval"),n.help=e("./function/expression/help"),n.concat=e("./function/matrix/concat"),n.det=e("./function/matrix/det"),n.diag=e("./function/matrix/diag"),n.eye=e("./function/matrix/eye"),n.inv=e("./function/matrix/inv"),n.ones=e("./function/matrix/ones"),n.range=e("./function/matrix/range"),n.resize=e("./function/matrix/resize"),n.size=e("./function/matrix/size"),n.squeeze=e("./function/matrix/squeeze"),n.subset=e("./function/matrix/subset"),n.transpose=e("./function/matrix/transpose"),n.zeros=e("./function/matrix/zeros"),n.factorial=e("./function/probability/factorial"),n.distribution=e("./function/probability/distribution"),n.pickRandom=e("./function/probability/pickRandom"),n.random=e("./function/probability/random"),n.randomInt=e("./function/probability/randomInt"),n.min=e("./function/statistics/min"),n.mean=e("./function/statistics/mean"),n.max=e("./function/statistics/max"),n.acos=e("./function/trigonometry/acos"),n.asin=e("./function/trigonometry/asin"),n.atan=e("./function/trigonometry/atan"),n.atan2=e("./function/trigonometry/atan2"),n.cos=e("./function/trigonometry/cos"),n.cot=e("./function/trigonometry/cot"),n.csc=e("./function/trigonometry/csc"),n.sec=e("./function/trigonometry/sec"),n.sin=e("./function/trigonometry/sin"),n.tan=e("./function/trigonometry/tan"),n["in"]=e("./function/units/in"),n.clone=e("./function/utils/clone"),n.map=e("./function/utils/map"),n.forEach=e("./function/utils/forEach"),n.format=e("./function/utils/format"),n["import"]=e("./function/utils/import"),n["typeof"]=e("./function/utils/typeof") -},{"./constants/Infinity":6,"./constants/LN10":7,"./constants/LN2":8,"./constants/LOG10E":9,"./constants/LOG2E":10,"./constants/NaN":11,"./constants/SQRT1_2":12,"./constants/SQRT2":13,"./constants/e":14,"./constants/false":15,"./constants/i":16,"./constants/pi":17,"./constants/tau":18,"./constants/true":19,"./function/arithmetic/abs":20,"./function/arithmetic/add":21,"./function/arithmetic/ceil":22,"./function/arithmetic/cube":23,"./function/arithmetic/divide":24,"./function/arithmetic/edivide":25,"./function/arithmetic/emultiply":26,"./function/arithmetic/epow":27,"./function/arithmetic/equal":28,"./function/arithmetic/exp":29,"./function/arithmetic/fix":30,"./function/arithmetic/floor":31,"./function/arithmetic/gcd":32,"./function/arithmetic/larger":33,"./function/arithmetic/largereq":34,"./function/arithmetic/lcm":35,"./function/arithmetic/log":36,"./function/arithmetic/log10":37,"./function/arithmetic/mod":38,"./function/arithmetic/multiply":39,"./function/arithmetic/pow":40,"./function/arithmetic/round":41,"./function/arithmetic/sign":42,"./function/arithmetic/smaller":43,"./function/arithmetic/smallereq":44,"./function/arithmetic/sqrt":45,"./function/arithmetic/square":46,"./function/arithmetic/subtract":47,"./function/arithmetic/unary":48,"./function/arithmetic/unequal":49,"./function/arithmetic/xgcd":50,"./function/complex/arg":51,"./function/complex/conj":52,"./function/complex/im":53,"./function/complex/re":54,"./function/construction/bignumber":55,"./function/construction/boolean":56,"./function/construction/complex":57,"./function/construction/index":58,"./function/construction/matrix":59,"./function/construction/number":60,"./function/construction/string":61,"./function/construction/unit":62,"./function/expression/eval":63,"./function/expression/help":64,"./function/matrix/concat":65,"./function/matrix/det":66,"./function/matrix/diag":67,"./function/matrix/eye":68,"./function/matrix/inv":69,"./function/matrix/ones":70,"./function/matrix/range":71,"./function/matrix/resize":72,"./function/matrix/size":73,"./function/matrix/squeeze":74,"./function/matrix/subset":75,"./function/matrix/transpose":76,"./function/matrix/zeros":77,"./function/probability/distribution":78,"./function/probability/factorial":79,"./function/probability/pickRandom":80,"./function/probability/random":81,"./function/probability/randomInt":82,"./function/statistics/max":83,"./function/statistics/mean":84,"./function/statistics/min":85,"./function/trigonometry/acos":86,"./function/trigonometry/asin":87,"./function/trigonometry/atan":88,"./function/trigonometry/atan2":89,"./function/trigonometry/cos":90,"./function/trigonometry/cot":91,"./function/trigonometry/csc":92,"./function/trigonometry/sec":93,"./function/trigonometry/sin":94,"./function/trigonometry/tan":95,"./function/units/in":96,"./function/utils/clone":97,"./function/utils/forEach":98,"./function/utils/format":99,"./function/utils/import":100,"./function/utils/map":101,"./function/utils/typeof":102}],104:[function(e,t){function n(e,t){this.settings=e,this.nodes=t||[]}var r=e("./Node"),i=(e("../../util/object"),e("../../util/string")),o=(e("../../type/collection"),e("../../type/Matrix"));n.prototype=new r,n.prototype.eval=function(){for(var e=this.nodes,t=[],n=0,r=e.length;r>n;n++){var i=e[n],a=i.eval();t[n]=a instanceof o?a.valueOf():a}return"array"===this.settings.matrix.defaultType?t:new o(t)},n.prototype.find=function(e){var t=[];this.match(e)&&t.push(this);for(var n=this.nodes,r=0,i=n.length;i>r;r++)for(var o=n[r],a=0,s=o.length;s>a;a++)t=t.concat(o[a].find(e));return t},n.prototype.toString=function(){return i.format(this.nodes)},t.exports=n},{"../../type/Matrix":205,"../../type/collection":208,"../../util/object":214,"../../util/string":215,"./Node":109}],105:[function(e,t){function n(e,t,n){this.name=e,this.expr=t,this.scope=n}var r=e("./Node");n.prototype=new r,n.prototype.eval=function(){if(void 0===this.expr)throw new Error("Undefined symbol "+this.name);var e=this.expr.eval();return this.scope.set(this.name,e),e},n.prototype.find=function(e){var t=[];return this.match(e)&&t.push(this),this.expr&&(t=t.concat(this.expr.find(e))),t},n.prototype.toString=function(){return this.name+" = "+this.expr.toString()},t.exports=n},{"./Node":109}],106:[function(e,t){function n(){this.params=[],this.visible=[]}var r=e("./Node");n.prototype=new r,n.prototype.add=function(e,t){var n=this.params.length;this.params[n]=e,this.visible[n]=void 0!=t?t:!0},n.prototype.eval=function(){for(var e=[],t=0,n=this.params.length;n>t;t++){var r=this.params[t].eval();this.visible[t]&&e.push(r)}return e},n.prototype.find=function(e){var t=[];this.match(e)&&t.push(this);var n=this.params;if(n)for(var r=0,i=n.length;i>r;r++)t=t.concat(n[r].find(e));return t},n.prototype.toString=function(){for(var e=[],t=0,n=this.params.length;n>t;t++)this.visible[t]&&e.push("\n "+this.params[t].toString());return"["+e.join(",")+"\n]"},t.exports=n},{"./Node":109}],107:[function(e,t){function n(e){this.value=e}var r=e("./Node"),i=e("../../util/string");n.prototype=new r,n.prototype.eval=function(){return this.value},n.prototype.toString=function(){return i.format(this.value)},t.exports=n},{"../../util/string":215,"./Node":109}],108:[function(e,t){function n(e,t,n,r,o){this.name=e,this.variables=t,this.expr=n,this.scope=o,this.fn=function(){var o=t?t.length:0;if(arguments.length!=o)throw new i.ArgumentsError(e,arguments.length,o);for(var a=0;o>a;a++)r.set(t[a],arguments[a]);return n.eval()},this.fn.toString=function(){return e+"("+t.join(", ")+")"}}var r=e("./Node"),i=e("../../util/error");n.prototype=new r,n.prototype.eval=function(){return this.scope.set(this.name,this.fn),this.fn},n.prototype.find=function(e){var t=[];return this.match(e)&&t.push(this),this.expr&&(t=t.concat(this.expr.find(e))),t},n.prototype.toString=function(){return this.fn.toString()},t.exports=n},{"../../util/error":211,"./Node":109}],109:[function(e,t){function n(){}n.prototype.eval=function(){throw new Error("Cannot evaluate a Node interface")},n.prototype.find=function(e){return this.match(e)?[this]:[]},n.prototype.match=function(e){var t=!0;if(e&&(!e.type||this instanceof e.type||(t=!1),t&&e.properties))for(var n in e.properties)if(e.properties.hasOwnProperty(n)&&this[n]!=e.properties[n]){t=!1;break}return t},n.prototype.toString=function(){return""},t.exports=n},{}],110:[function(e,t){function n(e,t,n){this.name=e,this.fn=t,this.params=n}var r=e("./Node");n.prototype=new r,n.prototype.eval=function(){return this.fn.apply(this,this.params.map(function(e){return e.eval()}))},n.prototype.find=function(e){var t=[];this.match(e)&&t.push(this);var n=this.params;if(n)for(var r=0,i=n.length;i>r;r++)t=t.concat(n[r].find(e));return t},n.prototype.toString=function(){var e=this.params;switch(e.length){case 1:return"-"==this.name?"-"+e[0].toString():e[0].toString()+this.name;case 2:var t=e[0].toString();e[0]instanceof n&&(t="("+t+")");var r=e[1].toString();return e[1]instanceof n&&(r="("+r+")"),t+" "+this.name+" "+r;default:return this.name+"("+this.params.join(", ")+")"}},t.exports=n},{"./Node":109}],111:[function(e,t){function n(e,t,n,r){if(this.math=e,this.object=t,this.params=n,this.paramScopes=r,this.hasContextParams=!1,n)for(var i={type:a,properties:{name:"end"}},o=0,s=n.length;s>o;o++)if(n[o].find(i).length>0){this.hasContextParams=!0;break}}var r=e("../../util/number"),i=e("./Node"),o=e("./RangeNode"),a=e("./SymbolNode"),s=e("../../type/Index"),u=e("../../type/Range"),c=r.isNumber;n.prototype=new i,n.prototype.eval=function(){var e,t,n,r,i=this.object;if(void 0==i)throw new Error("Node undefined");var a=i.eval();if(this.hasContextParams&&"function"!=typeof a){var f=this.paramScopes,l=this.math.size(a).valueOf();if(f&&l)for(e=0,t=this.params.length;t>e;e++){var m=f[e];m&&m.set("end",l[e])}}if("function"==typeof a){for(n=this.params,r=[],e=0,t=this.params.length;t>e;e++)r[e]=n[e].eval();return a.apply(this,r)}for(n=this.params,r=[],e=0,t=this.params.length;t>e;e++){var p,h=n[e];if(p=h instanceof o?h.toRange():h.eval(),p instanceof u)p.start--,p.end--;else{if(!c(p))throw new TypeError("Number or Range expected");p--}r[e]=p}var g=s.create(r);return this.math.subset(a,g)},n.prototype.find=function(e){var t=[];this.match(e)&&t.push(this),this.object&&(t=t.concat(this.object.find(e)));var n=this.params;if(n)for(var r=0,i=n.length;i>r;r++)t=t.concat(n[r].find(e));return t},n.prototype.toString=function(){var e=this.object?this.object.toString():"";return this.params&&(e+="("+this.params.join(", ")+")"),e},t.exports=n},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113}],112:[function(e,t){function n(e,t){if(this.math=e,this.start=null,this.end=null,this.step=null,2==t.length)this.start=t[0],this.end=t[1];else{if(3!=t.length)throw new SyntaxError("Wrong number of arguments");this.start=t[0],this.step=t[1],this.end=t[2]}}var r=e("../../util/number"),i=e("./Node"),o=e("../../type/Range");n.prototype=new i,n.prototype.eval=function(){var e=this.start.eval(),t=this.step?this.step.eval():1,n=this.end.eval();if(!r.isNumber(e))throw new TypeError("Parameter start must be a number");if(!r.isNumber(n))throw new TypeError("Parameter end must be a number");if(!r.isNumber(t))throw new TypeError("Parameter step must be a number");var i=[],o=e;if(t>0)for(;n>=o;)i.push(o),o+=t;else if(0>t)for(;o>=n;)i.push(o),o+=t;return i},n.prototype.toRange=function(){var e=this.start.eval(),t=this.step?this.step.eval():1,n=this.end.eval();return n=this.math.add(n,t>0?1:-1),new o(e,n,t)},n.prototype.find=function(e){var t=[];return this.match(e)&&t.push(this),this.start&&(t=t.concat(this.start.find(e))),this.step&&(t=t.concat(this.step.find(e))),this.end&&(t=t.concat(this.end.find(e))),t},n.prototype.toString=function(){var e=this.start.toString();return this.step&&(e+=":"+this.step.toString()),e+=":"+this.end.toString()},t.exports=n},{"../../type/Range":206,"../../util/number":213,"./Node":109}],113:[function(e,t){function n(e,t){this.name=e,this.scope=t}var r=e("./Node");n.prototype=new r,n.prototype.eval=function(){var e=this.scope.get(this.name);if(void 0===e)throw new Error("Undefined symbol "+this.name);return e},n.prototype.toString=function(){return this.name},t.exports=n},{"./Node":109}],114:[function(e,t){function n(e,t,n,r,i,o){this.math=e,this.name=t,this.params=n,this.paramScopes=r,this.expr=i,this.scope=o,this.hasContextParams=!1;for(var s={type:a,properties:{name:"end"}},u=0,c=n.length;c>u;u++)if(n[u].find(s).length>0){this.hasContextParams=!0;break}}var r=e("../../util/number"),i=e("./Node"),o=e("./RangeNode"),a=e("./SymbolNode"),s=e("../../type/Index"),u=e("../../type/Range"),c=r.isNumber;n.prototype=new i,n.prototype.eval=function(){if(void 0===this.expr)throw new Error("Undefined symbol "+this.name);var e,t=this.scope.get(this.name);if(void 0==t)throw new Error("Undefined symbol "+this.name);if(this.hasContextParams&&"function"!=typeof t){var n=this.paramScopes,r=this.math.size(t).valueOf();if(n&&r)for(var i=0,a=this.params.length;a>i;i++){var f=n[i];f&&f.set("end",r[i])}}var l=[];this.params.forEach(function(e){var t;if(t=e instanceof o?e.toRange():e.eval(),t instanceof u)t.start--,t.end--;else{if(!c(t))throw new TypeError("Number or Range expected");t--}l.push(t)});var m=this.expr.eval(),p=s.create(l);return e=this.math.subset(t,p,m),this.scope.set(this.name,e),e},n.prototype.find=function(e){var t=[];this.match(e)&&t.push(this);var n=this.params;if(n)for(var r=0,i=n.length;i>r;r++)t=t.concat(n[r].find(e));return this.expr&&(t=t.concat(this.expr.find(e))),t},n.prototype.toString=function(){var e="";return e+=this.name,this.params&&this.params.length&&(e+="("+this.params.join(", ")+")"),e+=" = ",e+=this.expr.toString()},t.exports=n},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113}],115:[function(){},{}],116:[function(e,t,n){n.AssignmentNode=e("./AssignmentNode"),n.BlockNode=e("./BlockNode"),n.ConstantNode=e("./ConstantNode"),n.FunctionNode=e("./FunctionNode"),n.ArrayNode=e("./ArrayNode"),n.Node=e("./Node"),n.OperatorNode=e("./OperatorNode"),n.ParamsNode=e("./ParamsNode"),n.RangeNode=e("./RangeNode"),n.SymbolNode=e("./SymbolNode"),n.UpdateNode=e("./UpdateNode"),n.handlers=e("./handlers")},{"./ArrayNode":104,"./AssignmentNode":105,"./BlockNode":106,"./ConstantNode":107,"./FunctionNode":108,"./Node":109,"./OperatorNode":110,"./ParamsNode":111,"./RangeNode":112,"./SymbolNode":113,"./UpdateNode":114,"./handlers":115}],117:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/collection")),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.abs=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("abs",arguments.length,1);if(a(e))return Math.abs(e);if(u(e))return Math.sqrt(e.re*e.re+e.im*e.im);if(e instanceof r)return e.abs();if(c(e))return o.deepMap(e,f);if(s(e))return Math.abs(e);throw new n.error.UnsupportedTypeError("abs",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],118:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/Unit")),a=e("../../type/collection"),s=n.boolean.isBoolean,u=n.number.isNumber,c=n.number.toNumber,f=n.number.toBigNumber,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.add=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("add",arguments.length,2);if(u(e)){if(u(t))return e+t;if(m(t))return new i(e+t.re,t.im)}if(m(e)){if(m(t))return new i(e.re+t.re,e.im+t.im);if(u(t))return new i(e.re+t,e.im)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Units do not match");if(null==e.value)throw new Error("Unit on left hand side of operator + has an undefined value");if(null==t.value)throw new Error("Unit on right hand side of operator + has an undefined value");var o=e.clone();return o.value+=t.value,o.fixPrefix=!1,o}if(e instanceof r){if(u(t)&&(t=f(t),u(t)))return c(e)+t;if(t instanceof r)return e.plus(t)}if(t instanceof r){if(u(e)&&(e=f(e),u(e)))return e+c(t);if(e instanceof r)return e.plus(t)}if(l(e)||l(t))return e+t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(s(e))return g(+e,t);if(s(t))return g(e,+t);throw new n.error.UnsupportedTypeError("add",e,t)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],119:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=o.isCollection,c=i.isComplex;t.ceil=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("ceil",arguments.length,1);if(a(e))return Math.ceil(e);if(c(e))return new i(Math.ceil(e.re),Math.ceil(e.im));if(e instanceof r)return e.ceil();if(u(e))return o.deepMap(e,f);if(s(e))return Math.ceil(e);throw new n.error.UnsupportedTypeError("ceil",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],120:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.cube=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cube",arguments.length,1);if(a(e))return e*e*e;if(u(e))return t.multiply(t.multiply(e,e),e);if(e instanceof r)return e.times(e).times(e);if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("cube",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],121:[function(e,t){t.exports=function(t){function n(e,t){var n=t.re*t.re+t.im*t.im;return 0!=n?new o((e.re*t.re+e.im*t.im)/n,(e.im*t.re-e.re*t.im)/n):new o(0!=e.re?e.re/0:0,0!=e.im?e.im/0:0)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=(e("../../type/Matrix"),e("../../type/Unit")),s=e("../../type/collection"),u=r.number.isNumber,c=r.number.toNumber,f=r.number.toBigNumber,l=r.boolean.isBoolean,m=o.isComplex,p=a.isUnit,h=s.isCollection;t.divide=function g(e,a){if(2!=arguments.length)throw new r.error.ArgumentsError("divide",arguments.length,2);if(u(e)){if(u(a))return e/a;if(m(a))return n(new o(e,0),a)}if(m(e)){if(m(a))return n(e,a);if(u(a))return n(e,new o(a,0))}if(e instanceof i){if(u(a)&&(a=f(a),u(a)))return c(e)/a;if(a instanceof i)return e.div(a)}if(a instanceof i){if(u(e)&&(e=f(e),u(e)))return e/c(a);if(e instanceof i)return e.div(a)}if(p(e)&&u(a)){var x=e.clone();return x.value/=a,x}if(h(e))return h(a)?t.multiply(e,t.inv(a)):s.deepMap2(e,a,g);if(h(a))return t.multiply(e,t.inv(a));if(l(e))return g(+e,a);if(l(a))return g(e,+a);throw new r.error.UnsupportedTypeError("divide",e,a)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],122:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/collection");t.edivide=function(e,i){if(2!=arguments.length)throw new n.error.ArgumentsError("edivide",arguments.length,2);return r.deepMap2(e,i,t.divide)}}},{"../../type/collection":208,"../../util/index":212}],123:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/collection");t.emultiply=function(e,i){if(2!=arguments.length)throw new n.error.ArgumentsError("emultiply",arguments.length,2);return r.deepMap2(e,i,t.multiply)}}},{"../../type/collection":208,"../../util/index":212}],124:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/collection");t.epow=function(e,i){if(2!=arguments.length)throw new n.error.ArgumentsError("epow",arguments.length,2);return r.deepMap2(e,i,t.pow)}}},{"../../type/collection":208,"../../util/index":212}],125:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.number.toNumber,c=n.number.toBigNumber,f=n.boolean.isBoolean,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.equal=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("equal",arguments.length,2);if(s(e)){if(s(t))return e==t;if(m(t))return e==t.re&&0==t.im}if(m(e)){if(s(t))return e.re==t&&0==e.im;if(m(t))return e.re==t.re&&e.im==t.im}if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)==t;if(t instanceof r)return e.eq(t)}if(t instanceof r){if(s(e)&&(e=c(e),s(e)))return e==u(t);if(e instanceof r)return e.eq(t)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value==t.value}if(l(e)||l(t))return e==t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);throw new n.error.UnsupportedTypeError("equal",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],126:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=(e("../../type/Matrix"),e("../../type/collection")),o=n.number.isNumber,a=n.boolean.isBoolean,s=r.isComplex,u=i.isCollection;t.exp=function c(e){if(1!=arguments.length)throw new n.error.ArgumentsError("exp",arguments.length,1);if(o(e))return Math.exp(e);if(s(e)){var t=Math.exp(e.re);return new r(t*Math.cos(e.im),t*Math.sin(e.im))}if(u(e))return i.deepMap(e,c);if(a(e))return Math.exp(e);throw new n.error.UnsupportedTypeError("exp",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],127:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.fix=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("fix",arguments.length,1);if(a(e))return e>0?Math.floor(e):Math.ceil(e);if(u(e))return new i(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im));if(e instanceof r)return e.isNegative()?e.ceil():e.floor();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("fix",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],128:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.floor=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("floor",arguments.length,1);if(a(e))return Math.floor(e);if(u(e))return new i(Math.floor(e.re),Math.floor(e.im));if(e instanceof r)return e.floor();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("floor",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],129:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=n.number.isNumber,a=n.number.toNumber,s=n.boolean.isBoolean,u=n.number.isInteger,c=i.isCollection;t.gcd=function f(){var e,t=arguments[0],l=arguments[1];if(2==arguments.length){if(o(t)&&o(l)){if(!u(t)||!u(l))throw new Error("Parameters in function gcd must be integer numbers");for(;0!=l;)e=t%l,t=l,l=e;return 0>t?-t:t}if(c(t)||c(l))return i.deepMap2(t,l,f);if(t instanceof r){if(t=a(t),o(t))return f(t,l);throw Error("Parameters in function gcd must be integer numbers.")}if(l instanceof r){if(l=a(l),o(l))return f(t,l);throw Error("Parameters in function gcd must be integer numbers.")}if(s(t))return f(+t,l);if(s(l))return f(t,+l);throw new n.error.UnsupportedTypeError("gcd",t,l)}if(arguments.length>2){for(var m=1;mt;if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)>t;if(t instanceof r)return e.gt(t)}if(t instanceof r){if(s(e)&&(e=c(e),s(e)))return e>u(t);if(e instanceof r)return e.gt(t)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>t.value}if(l(e)||l(t))return e>t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("larger",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],131:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.number.toNumber,c=n.number.toBigNumber,f=n.boolean.isBoolean,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.largereq=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("largereq",arguments.length,2);if(s(e)&&s(t))return e>=t;if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)>=t;if(t instanceof r)return e.gte(t)}if(t instanceof r){if(s(e)&&(e=c(e),s(e)))return e>=u(t);if(e instanceof r)return e.gte(t)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>=t.value}if(l(e)||l(t))return e>=t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("largereq",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],132:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=n.number.isNumber,a=n.number.toNumber,s=n.boolean.isBoolean,u=n.number.isInteger,c=i.isCollection;t.lcm=function f(){var e,t=arguments[0],l=arguments[1];if(2==arguments.length){if(o(t)&&o(l)){if(!u(t)||!u(l))throw new Error("Parameters in function lcm must be integer numbers");if(0==t||0==l)return 0;for(var m=t*l;0!=l;)e=l,l=t%e,t=e;return Math.abs(m/t)}if(c(t)||c(l))return i.deepMap2(t,l,f);if(s(t))return f(+t,l);if(s(l))return f(t,+l);if(t instanceof r){if(t=a(t),o(t))return f(t,l);throw Error("Parameters in function lcm must be integer numbers.")}if(l instanceof r){if(l=a(l),o(l))return f(t,l);throw Error("Parameters in function lcm must be integer numbers.")}throw new n.error.UnsupportedTypeError("lcm",t,l)}if(arguments.length>2){for(var p=1;p=0?Math.log(e):l(new i(e,0));if(c(e))return new i(Math.log(Math.sqrt(e.re*e.re+e.im*e.im)),Math.atan2(e.im,e.re));if(e instanceof r)return l(s(e));if(f(e))return o.deepMap(e,l);if(u(e))return l(+e);throw new n.error.UnsupportedTypeError("log",e)}if(2==arguments.length)return t.divide(l(e),l(m));throw new n.error.ArgumentsError("log",arguments.length,1,2)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],134:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.toNumber,s=n.number.isNumber,u=n.boolean.isBoolean,c=i.isComplex,f=o.isCollection;t.log10=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("log10",arguments.length,1);if(s(e))return e>=0?Math.log(e)/Math.LN10:l(new i(e,0));if(e instanceof r)return l(a(e));if(c(e))return new i(Math.log(Math.sqrt(e.re*e.re+e.im*e.im))/Math.LN10,Math.atan2(e.im,e.re)/Math.LN10);if(f(e))return o.deepMap(e,l);if(u(e))return l(+e);throw new n.error.UnsupportedTypeError("log10",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],135:[function(e,t){t.exports=function(t){function n(e,t){if(t>0)return e>0?e%t:0==e?0:e-t*Math.floor(e/t);if(0==t)return e;throw new Error("Cannot calculate mod for a negative divisor")}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/collection"),a=r.number.isNumber,s=r.number.toNumber,u=r.number.toBigNumber,c=r.boolean.isBoolean,f=o.isCollection;t.mod=function l(e,t){if(2!=arguments.length)throw new r.error.ArgumentsError("mod",arguments.length,2);if(a(e)&&a(t))return n(e,t);if(e instanceof i){if(a(t)&&(t=u(t),a(t)))return n(s(e),t);if(t instanceof i)return e.mod(t)}if(t instanceof i){if(a(e)&&(e=u(e),a(e)))return n(e,s(t));if(e instanceof i)return e.mod(t)}if(f(e)||f(t))return o.deepMap2(e,t,l);if(c(e))return l(+e,t);if(c(t))return l(e,+t);throw new r.error.UnsupportedTypeError("mod",e,t)}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],136:[function(e,t){t.exports=function(t){function n(e,n){for(var r=[],i=e.length,o=n[0].length,a=e[0].length,s=0;i>s;s++){r[s]=[];for(var u=0;o>u;u++){for(var c=null,f=0;a>f;f++){var l=t.multiply(e[s][f],n[f][u]);c=null===c?l:t.add(c,l)}r[s][u]=c}}return r}function r(e,n){for(var r=[],i=n.length,o=n[0].length,a=0;o>a;a++){for(var s=null,u=0;i>u;u++){var c=t.multiply(e[u],n[u][a]);s=0===u?c:t.add(s,c)}r[a]=s}return r}function i(e,n){for(var r=[],i=e.length,o=e[0].length,a=0;i>a;a++){for(var s=null,u=0;o>u;u++){var c=t.multiply(e[a][u],n[u]);s=0===u?c:t.add(s,c)}r[a]=s}return r}function o(e,n){var r=e.length,i=null;if(r){i=0;for(var o=0,a=e.length;a>o;o++)i=t.add(i,t.multiply(e[o],n[o]))}return i}function a(e,t){return 0==e.im?0==t.im?e.re*t.re:0==t.re?new c(0,e.re*t.im):new c(e.re*t.re,e.re*t.im):0==e.re?0==t.im?new c(0,e.im*t.re):0==t.re?-e.im*t.im:new c(-e.im*t.im,e.im*t.re):0==t.im?new c(e.re*t.re,e.im*t.re):0==t.re?new c(-e.im*t.im,e.re*t.im):new c(e.re*t.re-e.im*t.im,e.re*t.im+e.im*t.re)}var s=e("../../util/index"),u=e("bignumber.js"),c=e("../../type/Complex"),f=e("../../type/Matrix"),l=e("../../type/Unit"),m=e("../../type/collection"),p=s.array,h=s.number.isNumber,g=s.number.toNumber,x=s.number.toBigNumber,d=s.boolean.isBoolean,y=c.isComplex,b=Array.isArray,v=l.isUnit;t.multiply=function w(e,t){if(2!=arguments.length)throw new s.error.ArgumentsError("multiply",arguments.length,2);if(h(e)){if(h(t))return e*t;if(y(t))return a(new c(e,0),t);if(v(t))return res=t.clone(),res.value*=e,res}if(y(e)){if(h(t))return a(e,new c(t,0));if(y(t))return a(e,t)}if(e instanceof u){if(h(t)&&(t=x(t),h(t)))return g(e)*t;if(t instanceof u)return e.times(t)}if(t instanceof u){if(h(e)&&(e=x(e),h(e)))return e*g(t);if(e instanceof u)return e.times(t)}if(v(e)&&h(t))return res=e.clone(),res.value*=t,res;if(b(e)){if(b(t)){var l=p.size(e),E=p.size(t);if(1==l.length){if(1==E.length){if(l[0]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Length of A must match length of B (A is "+l[0]+", B is "+E[0]+l[0]+" != "+E[0]+")");return o(e,t)}if(2==E.length){if(l[0]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Length of A must match rows of B (A is "+l[0]+", B is "+E[0]+"x"+E[1]+", "+l[0]+" != "+E[0]+")");return r(e,t)}throw new Error("Can only multiply a 1 or 2 dimensional matrix (B has "+E.length+" dimensions)")}if(2==l.length){if(1==E.length){if(l[1]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Columns of A must match length of B (A is "+l[0]+"x"+l[0]+", B is "+E[0]+", "+l[1]+" != "+E[0]+")");return i(e,t)}if(2==E.length){if(l[1]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Columns of A must match rows of B (A is "+l[0]+"x"+l[1]+", B is "+E[0]+"x"+E[1]+", "+l[1]+" != "+E[0]+")");return n(e,t)}throw new Error("Can only multiply a 1 or 2 dimensional matrix (B has "+E.length+" dimensions)")}throw new Error("Can only multiply a 1 or 2 dimensional matrix (A has "+l.length+" dimensions)")}return t instanceof f?new f(w(e,t.valueOf())):m.deepMap2(e,t,w)}if(e instanceof f)return t instanceof f?new f(w(e.valueOf(),t.valueOf())):new f(w(e.valueOf(),t));if(b(t))return m.deepMap2(e,t,w);if(t instanceof f)return new f(m.deepMap2(e,t.valueOf(),w));if(d(e))return w(+e,t);if(d(t))return w(e,+t);throw new s.error.UnsupportedTypeError("multiply",e,t)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],137:[function(e,t){t.exports=function(t){function n(e,n){var r=t.log(e),i=t.multiply(r,n);return t.exp(i)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=e("../../type/Matrix"),s=(e("../../type/collection"),r.array),u=r.number.isNumber,c=r.number.toNumber,f=r.number.toBigNumber,l=r.boolean.isBoolean,m=Array.isArray,p=r.number.isInteger,h=o.isComplex;t.pow=function g(e,x){if(2!=arguments.length)throw new r.error.ArgumentsError("pow",arguments.length,2);if(u(e)){if(u(x))return p(x)||e>=0?Math.pow(e,x):n(new o(e,0),new o(x,0)); -if(h(x))return n(new o(e,0),x)}if(h(e)){if(u(x))return n(e,new o(x,0));if(h(x))return n(e,x)}if(e instanceof i){if(u(x)&&(x=f(x),u(x)))return Math.pow(c(e),x);if(x instanceof i)return e.pow(x)}if(x instanceof i){if(u(e)&&(e=f(e),u(e)))return Math.pow(e,c(x));if(e instanceof i)return e.pow(x)}if(m(e)){if(!u(x)||!p(x)||0>x)throw new TypeError("For A^b, b must be a positive integer (value is "+x+")");var d=s.size(e);if(2!=d.length)throw new Error("For A^b, A must be 2 dimensional (A has "+d.length+" dimensions)");if(d[0]!=d[1])throw new Error("For A^b, A must be square (size is "+d[0]+"x"+d[1]+")");if(0==x)return t.eye(d[0]);for(var y=e,b=1;x>b;b++)y=t.multiply(e,y);return y}if(e instanceof a)return new a(g(e.valueOf(),x));if(l(e))return g(+e,x);if(l(x))return g(e,+x);throw new r.error.UnsupportedTypeError("pow",e,x)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],138:[function(e,t){t.exports=function(t){function n(e,t){if(t){var n=Math.pow(10,t);return Math.round(e*n)/n}return Math.round(e)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=e("../../type/collection"),s=r.number.isNumber,u=(r.number.toNumber,r.number.toBigNumber,r.number.isInteger),c=r.boolean.isBoolean,f=o.isComplex,l=a.isCollection;t.round=function m(e,t){if(1!=arguments.length&&2!=arguments.length)throw new r.error.ArgumentsError("round",arguments.length,1,2);if(void 0==t){if(s(e))return Math.round(e);if(f(e))return new o(Math.round(e.re),Math.round(e.im));if(e instanceof i)return e.round();if(l(e))return a.deepMap(e,m);if(c(e))return Math.round(e);throw new r.error.UnsupportedTypeError("round",e)}if(t instanceof i&&(t=parseFloat(t.valueOf())),!s(t)||!u(t))throw new TypeError("Number of decimals in function round must be an integer");if(0>t||t>9)throw new Error("Number of decimals in function round must be in te range of 0-9");if(s(e))return n(e,t);if(f(e))return new o(n(e.re,t),n(e.im,t));if(e instanceof i&&s(t))return e.round(t);if(l(e)||l(t))return a.deepMap2(e,t,m);if(c(e))return m(+e,t);if(c(t))return m(e,+t);throw new r.error.UnsupportedTypeError("round",e,t)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],139:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number,s=n.number.isNumber,u=n.boolean.isBoolean,c=i.isComplex,f=o.isCollection;t.sign=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sign",arguments.length,1);if(s(e))return a.sign(e);if(c(e)){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new i(e.re/t,e.im/t)}if(e instanceof r)return new r(e.cmp(0));if(f(e))return o.deepMap(e,l);if(u(e))return a.sign(e);throw new n.error.UnsupportedTypeError("sign",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],140:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.number.toNumber,c=n.number.toBigNumber,f=n.boolean.isBoolean,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.smaller=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("smaller",arguments.length,2);if(s(e)&&s(t))return t>e;if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)e;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("smaller",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],141:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.number.toNumber,c=n.number.toBigNumber,f=n.boolean.isBoolean,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.smallereq=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("smallereq",arguments.length,2);if(s(e)&&s(t))return t>=e;if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)<=t;if(t instanceof r)return e.lte(t)}if(t instanceof r){if(s(e)&&(e=c(e),s(e)))return e<=u(t);if(e instanceof r)return e.lte(t)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value<=t.value}if(l(e)||l(t))return t>=e;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("smallereq",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],142:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.sqrt=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sqrt",arguments.length,1);if(a(e))return e>=0?Math.sqrt(e):f(new i(e,0));if(u(e)){var t=Math.sqrt(e.re*e.re+e.im*e.im);return e.im>=0?new i(.5*Math.sqrt(2*(t+e.re)),.5*Math.sqrt(2*(t-e.re))):new i(.5*Math.sqrt(2*(t+e.re)),-.5*Math.sqrt(2*(t-e.re)))}if(e instanceof r)return e.sqrt();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("sqrt",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],143:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=i.isComplex,c=o.isCollection;t.square=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("square",arguments.length,1);if(a(e))return e*e;if(u(e))return t.multiply(e,e);if(e instanceof r)return e.times(e);if(c(e))return o.deepMap(e,f);if(s(e))return e*e;throw new n.error.UnsupportedTypeError("square",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],144:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/Unit")),a=e("../../type/collection"),s=n.number.toNumber,u=n.number.toBigNumber,c=n.boolean.isBoolean,f=n.number.isNumber,l=i.isComplex,m=o.isUnit,p=a.isCollection;t.subtract=function h(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("subtract",arguments.length,2);if(f(e)){if(f(t))return e-t;if(l(t))return new i(e-t.re,-t.im)}else if(l(e)){if(f(t))return new i(e.re-t,e.im);if(l(t))return new i(e.re-t.re,e.im-t.im)}if(e instanceof r){if(f(t)&&(t=u(t),f(t)))return s(e)-t;if(t instanceof r)return e.minus(t)}if(t instanceof r){if(f(e)&&(e=u(e),f(e)))return e-s(t);if(e instanceof r)return e.minus(t)}if(m(e)&&m(t)){if(!e.equalBase(t))throw new Error("Units do not match");if(null==e.value)throw new Error("Unit on left hand side of operator - has an undefined value");if(null==t.value)throw new Error("Unit on right hand side of operator - has an undefined value");var o=e.clone();return o.value-=t.value,o.fixPrefix=!1,o}if(p(e)||p(t))return a.deepMap2(e,t,h);if(c(e))return h(+e,t);if(c(t))return h(e,+t);throw new n.error.UnsupportedTypeError("subtract",e,t)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],145:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;t.unary=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("unary",arguments.length,1);if(s(e))return-e;if(c(e))return new i(-e.re,-e.im);if(e instanceof r)return e.neg();if(f(e)){var t=e.clone();return t.value=-e.value,t}if(l(e))return a.deepMap(e,m);if(u(e))return-e;throw new n.error.UnsupportedTypeError("unary",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],146:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=n.number.isNumber,u=n.number.toNumber,c=n.number.toBigNumber,f=n.boolean.isBoolean,l=n.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;t.unequal=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("unequal",arguments.length,2);if(s(e)){if(s(t))return e!=t;if(m(t))return e!=t.re||0!=t.im}if(m(e)){if(s(t))return e.re!=t||0!=e.im;if(m(t))return e.re!=t.re||e.im!=t.im}if(e instanceof r){if(s(t)&&(t=c(t),s(t)))return u(e)!=t;if(t instanceof r)return!e.eq(t)}if(t instanceof r){if(s(e)&&(e=c(e),s(e)))return e!=u(t);if(e instanceof r)return!e.eq(t)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value!=t.value}if(l(e)||l(t))return e!=t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);throw new n.error.UnsupportedTypeError("unequal",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],147:[function(e,t){t.exports=function(t){function n(e,t){for(var n,r,i,o=0,a=1,s=1,u=0;t;)r=Math.floor(e/t),i=e%t,n=o,o=a-r*o,a=n,n=s,s=u-r*s,u=n,e=t,t=i;return 0>e?[-e,e?-a:0,-u]:[e,e?a:0,u]}var r=e("../../util/index"),i=e("bignumber.js"),o=r.number.toNumber,a=r.number.isNumber,s=r.boolean.isBoolean,u=r.number.isInteger;t.xgcd=function c(e,t){if(2==arguments.length){if(a(e)&&a(t)){if(!u(e)||!u(t))throw new Error("Parameters in function xgcd must be integer numbers");return n(e,t)}if(e instanceof i){if(e=o(e),a(e))return c(e,t);throw Error("Parameters in function xgcd must be integer numbers.")}if(t instanceof i){if(t=o(t),a(t))return c(e,t);throw Error("Parameters in function xgcd must be integer numbers.")}if(s(e))return c(+e,t);if(s(t))return c(e,+t);throw new r.error.UnsupportedTypeError("xgcd",e,t)}throw new SyntaxError("Function xgcd expects two arguments")}}},{"../../util/index":212,"bignumber.js":217}],148:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=o.isCollection,c=i.isComplex;t.arg=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("arg",arguments.length,1);if(a(e))return Math.atan2(0,e);if(c(e))return Math.atan2(e.im,e.re);if(u(e))return o.deepMap(e,f);if(s(e))return f(+e);if(e instanceof r)return f(n.number.toNumber(e));throw new n.error.UnsupportedTypeError("arg",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],149:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.object,s=n.number.isNumber,u=n.boolean.isBoolean,c=o.isCollection,f=i.isComplex;t.conj=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("conj",arguments.length,1);return s(e)?e:e instanceof r?new r(e):f(e)?new i(e.re,-e.im):c(e)?o.deepMap(e,l):u(e)?+e:a.clone(e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],150:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=o.isCollection,c=i.isComplex;t.im=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("im",arguments.length,1);return a(e)?0:e instanceof r?new r(0):c(e)?e.im:u(e)?o.deepMap(e,f):s(e)?0:0}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],151:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=n.object,s=n.number.isNumber,u=n.boolean.isBoolean,c=o.isCollection,f=i.isComplex;t.re=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("re",arguments.length,1);return s(e)?e:e instanceof r?new r(e):f(e)?e.re:c(e)?o.deepMap(e,l):u(e)?+e:a.clone(e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],152:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=n.number.isNumber,s=n.string.isString,u=n.boolean.isBoolean;"function"!=typeof r.prototype.clone&&(r.prototype.clone=function(){return new r(this)}),t.bignumber=function c(e){if(arguments.length>1)throw new n.error.ArgumentsError("bignumber",arguments.length,0,1);if(e instanceof r||a(e)||s(e))return new r(e);if(u(e))return new r(+e);if(o(e))return i.deepMap(e,c);if(0==arguments.length)return new r(0);throw new n.error.UnsupportedTypeError("bignumber",e)}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],153:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=n.number.isNumber,s=n.string.isString;t["boolean"]=function u(e){if(1!=arguments.length)throw new n.error.ArgumentsError("boolean",arguments.length,0,1);if("true"===e||e===!0)return!0;if("false"===e||e===!1)return!1;if(e instanceof Boolean)return e?!0:!1;if(a(e))return 0!==e;if(e instanceof r)return!e.isZero();if(s(e)){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var c=Number(e);if(""!=e&&!isNaN(c))return 0!==c}if(o(e))return i.deepMap(e,u);throw new SyntaxError(e.toString()+" is no valid boolean")}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],154:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=o.isCollection,s=n.number.isNumber,u=n.number.toNumber,c=n.string.isString,f=i.isComplex;t.complex=function l(){switch(arguments.length){case 0:return new i(0,0);case 1:var e=arguments[0];if(s(e))return new i(e,0);if(e instanceof r)return new i(u(e),0);if(f(e))return e.clone();if(c(e)){var t=i.parse(e);if(t)return t;throw new SyntaxError('String "'+e+'" is no valid complex number')}if(a(e))return o.deepMap(e,l);throw new TypeError("Two numbers or a single string expected in function complex");case 2:var m=arguments[0],p=arguments[1];if(m instanceof r&&(m=u(m),!s(m)))throw new TypeError("Cannot convert BigNumber "+m+" to Number");if(p instanceof r&&(p=u(p),!s(p)))throw new TypeError("Cannot convert BigNumber "+p+" to Number");if(s(m)&&s(p))return new i(m,p);throw new TypeError("Two numbers or a single string expected in function complex");default:throw new n.error.ArgumentsError("complex",arguments.length,0,2)}}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],155:[function(e,t){t.exports=function(t){var n=(e("../../util/index"),e("../../type/Index"));t.index=function(){var e=new n;return n.apply(e,arguments),e}}},{"../../type/Index":204,"../../util/index":212}],156:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Matrix");t.matrix=function(e){if(arguments.length>1)throw new n.error.ArgumentsError("matrix",arguments.length,0,1);return new r(e)}}},{"../../type/Matrix":205,"../../util/index":212}],157:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=n.number.toNumber;t.number=function s(e){switch(arguments.length){case 0:return 0;case 1:if(o(e))return i.deepMap(e,s);if(e instanceof r)return a(e);var t=Number(e);if(isNaN(t)&&(t=Number(e.valueOf())),isNaN(t))throw new SyntaxError(e.toString()+" is no valid number");return t;default:throw new n.error.ArgumentsError("number",arguments.length,0,1)}}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],158:[function(e,t){t.exports=function(t){var n=(e("../../util/index"),e("../../expression/Parser"));t.parser=function(){return new n(t)}}},{"../../expression/Parser":4,"../../util/index":212}],159:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/collection"),i=n.number,o=n.number.isNumber,a=r.isCollection;t.string=function s(e){switch(arguments.length){case 0:return"";case 1:return o(e)?i.format(e):a(e)?r.deepMap(e,s):null===e?"null":e.toString();default:throw new n.error.ArgumentsError("string",arguments.length,0,1)}}}},{"../../type/collection":208,"../../util/index":212}],160:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Unit"),o=e("../../type/collection"),a=o.isCollection,s=n.number.toNumber,u=n.number.isNumber,c=(n.boolean.isBoolean,n.string.isString);t.unit=function f(e){switch(arguments.length){case 1:var t=arguments[0];if(t instanceof i)return t.clone();if(c(t)){if(i.isPlainUnit(t))return new i(null,t);var l=i.parse(t);if(l)return l;throw new SyntaxError('String "'+t+'" is no valid unit')}if(a(e))return o.deepMap(e,f);throw new TypeError("A string or a number and string expected in function unit");case 2:var m=arguments[0],p=arguments[1];if(m instanceof r&&(m=s(m),!u(m)))throw new TypeError("Cannot convert BigNumber "+m+" to Number");return new i(m,p);default:throw new n.error.ArgumentsError("unit",arguments.length,1,2)}}}},{"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],161:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../expression/Scope"),i=e("../../type/collection"),o=n.string.isString,a=i.isCollection;t.eval=function(e,s){if(1!=arguments.length&&2!=arguments.length)throw new n.error.ArgumentsError("eval",arguments.length,1,2);var u;if(u=s?s instanceof r?s:new r(t,s):new r(t),o(e)){var c=t.parse(e,u);return c.eval()}if(a(e))return i.deepMap(e,function(e){var n=t.parse(e,u);return n.eval()});throw new TypeError("String or matrix expected")}}},{"../../expression/Scope":5,"../../type/collection":208,"../../util/index":212}],162:[function(e,t){t.exports=function(t){var n=(e("../../util/index"),e("../../type/Help"));t.help=function(e){if(1!=arguments.length)throw new SyntaxError("Wrong number of arguments in function help ("+arguments.length+" provided, 1 expected)");var r=null;if(e instanceof String||"string"==typeof e)r=e;else{var i;for(i in t)if(t.hasOwnProperty(i)&&e===t[i]){r=i;break}if(!r)for(i in t.type)if(t.type.hasOwnProperty(i)&&e===t.type[i]){r=i;break}}if(r){var o=t.expression.docs[r];if(!o)throw new Error('No documentation found on "'+r+'"');return new n(t,o)}throw new Error('Could not find search term "'+e+'"')}}},{"../../type/Help":203,"../../util/index":212}],163:[function(e,t){t.exports=function(t,n){function r(){ft=0,lt=ct.charAt(0)}function i(){ft++,lt=ct.charAt(ft)}function o(){return ct.charAt(ft+1)}function a(){for(pt=at.NULL,mt="";" "==lt||" "==lt;)i();if("#"==lt)for(;"\n"!=lt&&""!=lt;)i();if(""==lt)return pt=at.DELIMITER,void 0;var e=lt+o();if(st[e])return pt=at.DELIMITER,mt=e,i(),i(),void 0;if(st[lt])return pt=at.DELIMITER,mt=lt,i(),void 0;if(!u(lt)){if(s(lt)){for(;s(lt)||c(lt);)mt+=lt,i();return pt=ut[mt]?at.DELIMITER:at.SYMBOL,void 0}for(pt=at.UNKNOWN;""!=lt;)mt+=lt,i();throw B('Syntax error in part "'+mt+'"')}if(pt=at.NUMBER,"."==lt)mt+=lt,i(),c(lt)||(pt=at.UNKNOWN);else{for(;c(lt);)mt+=lt,i();"."==lt&&(mt+=lt,i())}for(;c(lt);)mt+=lt,i();if("E"==lt||"e"==lt)for(mt+=lt,i(),("+"==lt||"-"==lt)&&(mt+=lt,i()),c(lt)||(pt=at.UNKNOWN);c(lt);)mt+=lt,i()}function s(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function u(e){return e>="0"&&"9">=e||"."==e}function c(e){return e>="0"&&"9">=e}function f(e){r(),a();var t;if(t=""==mt?new $(void 0):l(e),""!=mt)throw pt==at.DELIMITER?P("Unknown operator "+mt):B('Unexpected part "'+mt+'"');return t}function l(e){var t,n,r;for("\n"!=mt&&";"!=mt&&""!=mt&&(t=m(e));"\n"==mt||";"==mt;)n||(n=new K,t&&(r=";"!=mt,n.add(t,r))),a(),"\n"!=mt&&";"!=mt&&""!=mt&&(t=m(e),r=";"!=mt,n.add(t,r));return n?n:(t||(t=m(e)),t)}function m(e){var t=p(e),n="ans";return new Z(n,t,e)}function p(e){if(pt==at.SYMBOL&&"function"==mt){if(a(),pt!=at.SYMBOL)throw B("Function name expected");var t=mt;if(a(),"("!=mt)throw B("Opening parenthesis ( expected");for(var n=e.createSubScope(),r=[];;)if(a(),pt==at.SYMBOL&&(r.push(mt),a()),","!=mt){if(")"==mt)break;throw B('Comma , or closing parenthesis ) expected"')}if(a(),"="!=mt)throw B("Equal sign = expected");a();var i=h(n);return new X(t,r,i,n,e)}return h(e)}function h(e){var n,r,i,o,s=g(e);if("="==mt){if(s instanceof rt)return a(),n=s.name,r=null,o=h(e),new Z(n,o,e);if(s instanceof tt&&s.object instanceof rt)return a(),n=s.object.name,r=s.params,i=s.paramScopes,o=h(e),new it(t,n,r,i,o,e);throw B("Symbol expected at the left hand side of assignment operator =")}return s}function g(e){var n,r=[];if(n=":"==mt?new $(1):x(e),":"==mt){for(r.push(n);":"==mt;)a(),")"==mt||","==mt||""==mt?r.push(new rt("end",e)):r.push(x(e));r.length&&(n=new nt(t,r))}return n}function x(e){var t=d(e);return t}function d(e){var n,r,i,o,s;for(n=y(e),r={"==":t.equal,"!=":t.unequal,"<":t.smaller,">":t.larger,"<=":t.smallereq,">=":t.largereq};void 0!==r[mt];)i=mt,o=r[i],a(),s=[n,y(e)],n=new et(i,o,s);return n}function y(e){var n,r,i,o,s;for(n=b(e),r={"in":t["in"]};void 0!==r[mt];)i=mt,o=r[i],a(),s=[n,b(e)],n=new et(i,o,s);return n}function b(e){var n,r,i,o,s;for(n=v(e),r={"+":t.add,"-":t.subtract};void 0!==r[mt];)i=mt,o=r[i],a(),s=[n,v(e)],n=new et(i,o,s);return n}function v(e){var n,r,i,o,s;for(n=w(e),r={"*":t.multiply,".*":t.emultiply,"/":t.divide,"./":t.edivide,"%":t.mod,mod:t.mod};void 0!==r[mt];)i=mt,o=r[i],a(),s=[n,w(e)],n=new et(i,o,s);return n}function w(e){var n,r,i;return"-"==mt?(n=mt,r=t.unary,a(),i=[w(e)],new et(n,r,i)):E(e)}function E(e){var n,r,i,o,s,u,c;for(i=[N(e)],o=[];"^"==mt||".^"==mt;)o.push(mt),a(),i.push(N(e));for(n=i.pop();i.length;)r=i.pop(),s=o.pop(),u="^"==s?t.pow:t.epow,c=[r,n],n=new et(s,u,c);return n}function N(e){var n,r,i,o;for(n=M(e);"!"==mt;)r=mt,i=t.factorial,a(),o=[n],n=new et(r,i,o);return n}function M(e){var n,r,i,o;for(n=j(e);"'"==mt;)r=mt,i=t.transpose,a(),o=[n],n=new et(r,i,o);return n}function j(e){var t,n,r,i;if(pt==at.SYMBOL&&ot[mt]){if(i=ot[mt],a(),"("==mt){if(t=[],n=[],a(),")"!=mt)for(r=e.createSubScope(),n.push(r),t.push(g(r));","==mt;)a(),r=e.createSubScope(),n.push(r),t.push(g(r));if(")"!=mt)throw B("Parenthesis ) expected");a()}return new i(t,n)}return C(e)}function C(e){var t,n;return pt==at.SYMBOL?(n=mt,a(),t=new rt(n,e),A(e,t)):O(e)}function A(e,n){for(var r,i,o,s;"("==mt;){if(r=mt,i=[],o=[],a(),")"!=mt)for(s=e.createSubScope(),o.push(s),i.push(g(s));","==mt;)a(),s=e.createSubScope(),o.push(s),i.push(g(s));if("("==r&&")"!=mt)throw B("Parenthesis ) expected");a(),n=new tt(t,n,i,o)}return n}function O(e){var t,n,r;if('"'==mt){for(n="",r="";""!=lt&&('"'!=lt||"\\"==r);)n+=lt,r=lt,i();if(a(),'"'!=mt)throw B('End of string " expected');return a(),t=new $(n),t=A(e,t)}return S(e)}function S(e){var t,r,i,o;if("["==mt){for(a();"\n"==mt;)a();if("]"!=mt){var s=T(e);if(";"==mt){for(i=1,r=[s];";"==mt;){for(a();"\n"==mt;)a();for(r[i]=T(e),i++;"\n"==mt;)a()}if("]"!=mt)throw B("End of matrix ] expected");a(),o=r.length>0?r[0].length:0;for(var u=1;i>u;u++)if(r[u].length!=o)throw P("Number of columns must match ("+r[u].length+" != "+o+")");t=new J(n,r)}else{if("]"!=mt)throw B("End of matrix ] expected");a(),t=s}}else a(),t=new J(n,[]);return t=A(e,t)}return U(e)}function T(e){for(var t=[h(e)],r=1;","==mt;){for(a();"\n"==mt;)a();for(t[r]=h(e),r++;"\n"==mt;)a()}return new J(n,t)}function U(e){var t,r,i;if(pt==at.NUMBER){if(i="bignumber"==n.number.defaultType?new D("."==mt?0:mt):"."==mt?0:Number(mt),a(),pt==at.SYMBOL){if("i"==mt||"I"==mt)return r=new H(0,i),a(),new $(r);if(Y.isPlainUnit(mt))return r=new Y(i,mt),a(),new $(r);throw _('Unknown unit "'+mt+'"')}return t=new $(i),t=A(e,t)}return q(e)}function q(e){var t;if("("==mt){if(a(),t=h(e),")"!=mt)throw B("Parenthesis ) expected");return a(),t=A(e,t)}return z(e)}function z(){throw""==mt?B("Unexpected end of expression"):B("Value expected")}function R(){return void 0}function I(){return ft-mt.length+1}function L(e){var t=R(),n=I();return void 0===t?void 0===n?e:e+" (char "+n+")":e+" (line "+t+", char "+n+")"}function B(e){return new SyntaxError(L(e))}function _(e){return new TypeError(L(e))}function P(e){return new Error(L(e))}var k=e("../../util/index"),F=k.string.isString,G=Array.isArray,D=e("bignumber.js"),H=e("./../../type/Complex"),V=e("./../../type/Matrix"),Y=e("./../../type/Unit"),W=e("../../type/collection"),Q=e("./../../expression/Scope"),Z=e("../../expression/node/AssignmentNode"),K=e("../../expression/node/BlockNode"),$=e("../../expression/node/ConstantNode"),X=e("../../expression/node/FunctionNode"),J=e("../../expression/node/ArrayNode"),et=e("../../expression/node/OperatorNode"),tt=e("../../expression/node/ParamsNode"),nt=e("../../expression/node/RangeNode"),rt=e("../../expression/node/SymbolNode"),it=e("../../expression/node/UpdateNode"),ot=e("../../expression/node/handlers");t.parse=function(e,n){if(1!=arguments.length&&2!=arguments.length)throw new k.error.ArgumentsError("parse",arguments.length,1,2);var r;if(r=n?n instanceof Q?n:new Q(t,n):new Q(t),F(e))return ct=e||"",f(r);if(G(e)||e instanceof V)return W.deepMap(e,function(e){return ct=e||"",f(r)});throw new TypeError("String or matrix expected")};var at={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},st={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,"\n":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"!":!0,"'":!0,"=":!0,":":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0},ut={mod:!0,"in":!0},ct="",ft=0,lt="",mt="",pt=at.NULL}},{"../../expression/node/ArrayNode":104,"../../expression/node/AssignmentNode":105,"../../expression/node/BlockNode":106,"../../expression/node/ConstantNode":107,"../../expression/node/FunctionNode":108,"../../expression/node/OperatorNode":110,"../../expression/node/ParamsNode":111,"../../expression/node/RangeNode":112,"../../expression/node/SymbolNode":113,"../../expression/node/UpdateNode":114,"../../expression/node/handlers":115,"../../type/collection":208,"../../util/index":212,"./../../expression/Scope":5,"./../../type/Complex":202,"./../../type/Matrix":205,"./../../type/Unit":207,"bignumber.js":217}],164:[function(e,t){t.exports=function(t){function n(e,t,r,i){if(r>i){if(e.length!=t.length)throw new Error("Dimensions mismatch ("+e.length+" != "+t.length+")");for(var o=[],a=0;ae;e++){var h=arguments[e];if(h instanceof i&&(m=!0),e==o-1&&u(h)){if(t=l,l=h,!c(l)||0>l)throw new TypeError("Dimension number must be a positive integer (dim = "+l+")");if(e>0&&l>t)throw new RangeError("Dimension out of range ("+l+" > "+t+")")}else{if(!f(h))throw new r.error.UnsupportedTypeError("concat",h);var g=a.clone(h).valueOf(),x=s.size(h.valueOf());if(p[e]=g,t=l,l=x.length-1,e>0&&l!=t)throw new RangeError("Dimension mismatch ("+t+" != "+l+")")}}if(0==p.length)throw new SyntaxError("At least one matrix expected");for(var d=p.shift();p.length;)d=n(d,p.shift(),l,0);return m?new i(d):d}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],165:[function(e,t){t.exports=function(t){function n(e,n,r){if(1==n)return e[0][0];if(2==n)return t.subtract(t.multiply(e[0][0],e[1][1]),t.multiply(e[1][0],e[0][1]));for(var o=1,a=0,s=0;n>s&&!(a>=r);s++){for(var u=s;0==e[u][a];)if(u++,u==n&&(u=s,a++,a==r))return i.deepEqual(e,eye(n).valueOf())?t.round(o,6):0;if(u!=s){for(var c=0;r>c;c++){var f=e[u][c];e[u][c]=e[s][c],e[s][c]=f}o*=-1}for(var l=e[s][a],c=0;r>c;c++)e[s][c]=e[s][c]/l;o*=l;for(var m=0;n>m;m++)if(m!=s)for(var p=e[m][a],c=0;r>c;c++)e[m][c]=e[m][c]-e[s][c]*p;a++}return i.deepEqual(e,t.eye(n).valueOf())?t.round(o,6):0}var r=e("../../util/index"),i=(e("../../type/Matrix"),r.object),o=r.array,a=r.string;t.det=function(e){if(1!=arguments.length)throw new r.error.ArgumentsError("det",arguments.length,1);var t=o.size(e.valueOf());switch(t.length){case 0:return i.clone(e);case 1:if(1==t[0])return i.clone(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+a.format(t)+")");case 2:var s=t[0],u=t[1];if(s==u)return n(e.valueOf(),s,u);throw new RangeError("Matrix must be square (size: "+a.format(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+a.format(t)+")")}}}},{"../../type/Matrix":205,"../../util/index":212}],166:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Matrix"),o=(e("../../type/collection"),r.object),a=r.array.isArray,s=r.number.isNumber,u=r.number.isInteger;t.diag=function(e,t){var c,f,l,m;if(1!=arguments.length&&2!=arguments.length)throw new r.error.ArgumentsError("diag",arguments.length,1,2);if(t){if(!s(t)||!u(t))throw new TypeError("Second parameter in function diag must be an integer")}else t=0;var p=t>0?t:0,h=0>t?-t:0;if(e instanceof i);else{if(!a(e))throw new TypeError("First parameter in function diag must be a Matrix or Array");e=new i(e)}var g=e.size();switch(g.length){case 1:f=e.valueOf();var x=new i,d=0;for(x.resize([f.length+h,f.length+p],d),c=x.valueOf(),m=f.length,l=0;m>l;l++)c[l+h][l+p]=o.clone(f[l]);return"array"===n.matrix.defaultType?x.valueOf():x;case 2:for(f=[],c=e.valueOf(),m=Math.min(g[0]-h,g[1]-p),l=0;m>l;l++)f[l]=o.clone(c[l+h][l+p]);return"array"===n.matrix.defaultType?f:new i(f);default:throw new RangeError("Matrix for function diag must be 2 dimensional")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],167:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Matrix"),o=e("../../type/collection"),a=r.number.isNumber,s=r.number.isInteger,u=Array.isArray;t.eye=function(e){var c=o.argsToArray(arguments),f=e instanceof i?!0:u(e)?!1:"matrix"===n.matrix.defaultType;if(0==c.length)return f?new i:[];if(1==c.length)c[1]=c[0];else if(c.length>2)throw new r.error.ArgumentsError("eye",c.length,0,2);var l=c[0],m=c[1];if(!a(l)||!s(l)||1>l)throw new Error("Parameters in function eye must be positive integers");if(m&&(!a(m)||!s(m)||1>m))throw new Error("Parameters in function eye must be positive integers");var p=new i,h=0;p.resize(c,h);for(var g=t.min(c),x=p.valueOf(),d=0;g>d;d++)x[d][d]=1;return f?p:p.valueOf()}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],168:[function(e,t){t.exports=function(t){function n(e,n,r){var i,o,a,s,u;if(1==n){if(s=e[0][0],0==s)throw Error("Cannot calculate inverse, determinant is zero");return[[t.divide(1,s)]]}if(2==n){var c=t.det(e);if(0==c)throw Error("Cannot calculate inverse, determinant is zero");return[[t.divide(e[1][1],c),t.divide(t.unary(e[0][1]),c)],[t.divide(t.unary(e[1][0]),c),t.divide(e[0][0],c)]]}var f=e.concat();for(i=0;n>i;i++)f[i]=f[i].concat();for(var l=t.eye(n).valueOf(),m=0;r>m;m++){for(i=m;n>i&&0==f[i][m];)i++;if(i==n||0==f[i][m])throw Error("Cannot calculate inverse, determinant is zero");i!=m&&(u=f[m],f[m]=f[i],f[i]=u,u=l[m],l[m]=l[i],l[i]=u);var p=f[m],h=l[m];for(i=0;n>i;i++){var g=f[i],x=l[i];if(i!=m){if(0!=g[m]){for(a=t.divide(t.unary(g[m]),p[m]),o=m;r>o;o++)g[o]=t.add(g[o],t.multiply(a,p[o])); -for(o=0;r>o;o++)x[o]=t.add(x[o],t.multiply(a,h[o]))}}else{for(a=p[m],o=m;r>o;o++)g[o]=t.divide(g[o],a);for(o=0;r>o;o++)x[o]=t.divide(x[o],a)}}}return l}var r=e("../../util/index"),i=e("../../type/Matrix"),o=(e("../../type/collection"),r.string);t.inv=function(e){if(1!=arguments.length)throw new r.error.ArgumentsError("inv",arguments.length,1);var a=t.size(e).valueOf();switch(a.length){case 0:return t.divide(1,e);case 1:if(1==a[0])return e instanceof i?new i([t.divide(1,e.valueOf()[0])]):[t.divide(1,e[0])];throw new RangeError("Matrix must be square (size: "+o.format(a)+")");case 2:var s=a[0],u=a[1];if(s==u)return e instanceof i?new i(n(e.valueOf(),s,u)):n(e,s,u);throw new RangeError("Matrix must be square (size: "+o.format(a)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+o.format(a)+")")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],169:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Matrix"),o=e("../../type/collection"),a=r.array,s=Array.isArray;t.ones=function(e){var t=o.argsToArray(arguments),r=e instanceof i?!0:s(e)?!1:"matrix"===n.matrix.defaultType;if(0==t.length)return r?new i:[];var u=[],c=1;return u=a.resize(u,t,c),r?new i(u):u}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],170:[function(e,t){t.exports=function(t,n){function r(e){var t=e.split(":"),n=t.map(function(e){return Number(e)}),r=n.some(function(e){return isNaN(e)});if(r)return null;switch(n.length){case 2:return{start:n[0],end:n[1],step:1};case 3:return{start:n[0],end:n[2],step:n[1]};default:return null}}var i=e("../../util/index"),o=e("../../type/Matrix"),a=(e("../../type/collection"),i.string.isString),s=i.number.isNumber;t.range=function(e){var t,u,c;switch(arguments.length){case 1:if(!a(e))throw new TypeError("Two or three numbers or a single string expected in function range");var f=r(e);if(!f)throw new SyntaxError('String "'+f+'" is no valid range');t=f.start,u=f.end,c=f.step;break;case 2:t=arguments[0],u=arguments[1],c=1;break;case 3:t=arguments[0],u=arguments[1],c=arguments[2];break;default:throw new i.error.ArgumentsError("range",arguments.length,2,3)}if(!s(t))throw new TypeError("Parameter start must be a number");if(!s(u))throw new TypeError("Parameter end must be a number");if(!s(c))throw new TypeError("Parameter step must be a number");var l=[],m=t;if(c>0)for(;u>m;)l.push(m),m+=c;else if(0>c)for(;m>u;)l.push(m),m+=c;return"array"===n.matrix.defaultType?l:new o(l)}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],171:[function(e,t){t.exports=function(t,n){function r(e,t,n){if(void 0!==n){if(!u(n)||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==t.length)throw new Error("Dimension mismatch: ("+t.length+" != 1)");var r=t[0];if(!c(r)||!f(r))throw new TypeError("Size must contain numbers");if(e.length>r)return e.substring(0,r);if(e.lengtho;o++)i+=n;return i}return e}var i=e("../../util/index"),o=e("../../type/Matrix"),a=i.array,s=i.object.clone,u=i.string.isString,c=i.number.isNumber,f=i.number.isInteger,l=a.isArray;t.resize=function(e,t,c){if(2!=arguments.length&&3!=arguments.length)throw new i.error.ArgumentsError("resize",arguments.length,2,3);var f=e instanceof o?!0:l(e)?!1:"array"!==n.matrix.defaultType;if(e instanceof o&&(e=e.valueOf()),t instanceof o&&(t=t.valueOf()),u(e))return r(e,t,c);if(0==t.length){for(;l(e);)e=e[0];return s(e)}l(e)||(e=[e]),e=s(e);var m=a.resize(e,t,c);return f?new o(m):m}}},{"../../type/Matrix":205,"../../util/index":212}],172:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/Matrix"),s=r.array,u=r.number.isNumber,c=r.boolean.isBoolean,f=r.string.isString,l=i.isComplex,m=o.isUnit;t.size=function(e){if(1!=arguments.length)throw new r.error.ArgumentsError("size",arguments.length,1);var t="array"===n.matrix.defaultType;if(u(e)||l(e)||m(e)||c(e)||null==e)return t?[]:new a([]);if(f(e))return t?[e.length]:new a([e.length]);if(Array.isArray(e))return s.size(e);if(e instanceof a)return new a(e.size());throw new r.error.UnsupportedTypeError("size",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../util/index":212}],173:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Matrix"),i=n.object,o=n.array,a=Array.isArray;t.squeeze=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("squeeze",arguments.length,1);if(a(e))return o.squeeze(i.clone(e));if(e instanceof r){var t=o.squeeze(e.toArray());return a(t)?new r(t):t}return i.clone(e)}}},{"../../type/Matrix":205,"../../util/index":212}],174:[function(e,t){t.exports=function(t){function n(e,t){var n,i;if(l(e))return n=new s(e),i=n.subset(t),i.valueOf();if(e instanceof s)return e.subset(t);if(f(e))return r(e,t);throw new a.error.UnsupportedTypeError("subset",e)}function r(e,t){if(!(t instanceof u))throw new TypeError("Index expected");if(1!=t.size().length)throw new RangeError("Dimension mismatch ("+t.size().length+" != 1)");var n=t.range(0),r="",i=e.length;return n.forEach(function(t){c.validateIndex(t,i),r+=e.charAt(t)}),r}function i(e,n,r,i){var u;if(l(e))return u=new s(t.clone(e)),u.subset(n,r,i),u.valueOf();if(e instanceof s)return e.clone().subset(n,r,i);if(f(e))return o(e,n,r,i);throw new a.error.UnsupportedTypeError("subset",e)}function o(e,t,n,r){if(!(t instanceof u))throw new TypeError("Index expected");if(1!=t.size().length)throw new RangeError("Dimension mismatch ("+t.size().length+" != 1)");if(void 0!==r){if(!f(r)||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var i=t.range(0),o=i.size()[0];if(o!=n.length)throw new RangeError("Dimension mismatch ("+i.size()[0]+" != "+n.length+")");for(var a=e.length,s=[],l=0;a>l;l++)s[l]=e.charAt(l);if(i.forEach(function(e,t){c.validateIndex(e),s[e]=n.charAt(t)}),s.length>a)for(l=a-1,o=s.length;o>l;l++)s[l]||(s[l]=r);return s.join("")}var a=e("../../util/index"),s=e("../../type/Matrix"),u=e("../../type/Index"),c=a.array,f=a.string.isString,l=Array.isArray;t.subset=function(){switch(arguments.length){case 2:return n(arguments[0],arguments[1]);case 3:case 4:return i(arguments[0],arguments[1],arguments[2],arguments[3]);default:throw new a.error.ArgumentsError("subset",arguments.length,2,4)}}}},{"../../type/Index":204,"../../type/Matrix":205,"../../util/index":212}],175:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Matrix"),i=(e("../../type/collection"),n.object),o=n.string;t.transpose=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("transpose",arguments.length,1);var a=t.size(e).valueOf();switch(a.length){case 0:return i.clone(e);case 1:return i.clone(e);case 2:var s,u=a[1],c=a[0],f=e instanceof r,l=e.valueOf(),m=[],p=i.clone;if(0===u)throw new RangeError("Cannot transpose a 2D matrix with no rows(size: "+o.format(a)+")");for(var h=0;u>h;h++){s=m[h]=[];for(var g=0;c>g;g++)s[g]=p(l[g][h])}return 0==c&&(m[0]=[]),f?new r(m):m;default:throw new RangeError("Matrix must be two dimensional (size: "+o.format(a)+")")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],176:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Matrix"),o=e("../../type/collection"),a=r.array,s=Array.isArray;t.zeros=function(e){var t=o.argsToArray(arguments),r=e instanceof i?!0:s(e)?!1:"matrix"===n.matrix.defaultType;if(0==t.length)return r?new i:[];var u=[],c=0;return u=a.resize(u,t,c),r?new i(u):u}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],177:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/collection"),i=n.number.isNumber,o=n.boolean.isBoolean,a=n.number.isInteger,s=r.isCollection;t.factorial=function u(e){if(1!=arguments.length)throw new n.error.ArgumentsError("factorial",arguments.length,1);if(i(e)){if(!a(e)||0>e)throw new TypeError("Positive integer value expected in function factorial");var t=e,c=t;for(t--;t>1;)c*=t,t--;return 0==c&&(c=1),c}if(o(e))return 1;if(s(e))return r.deepMap(e,u);throw new n.error.UnsupportedTypeError("factorial",e)}}},{"../../type/collection":208,"../../util/index":212}],178:[function(e,t){t.exports=function(t,n){var r=e("../../util/index"),i=e("../../type/Matrix"),o=(e("../../type/collection"),{uniform:function(){return Math.random},normal:function(){return function(){for(var e,t,n=-1;0>n||n>1;)e=Math.random(),t=Math.random(),n=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*t)+.5;return n}}});t.distribution=function(e){if(!o.hasOwnProperty(e))throw new Error("unknown distribution "+e);var t=Array.prototype.slice.call(arguments,1),a=o[e].apply(this,t);return function(e){var t={random:function(e,t,a){var u,c,f;if(arguments.length>3)throw new r.error.ArgumentsError("random",arguments.length,0,3);if(1===arguments.length?Array.isArray(e)?u=e:f=e:2===arguments.length?Array.isArray(e)?u=e:(c=e,f=t):(u=e,c=t,f=a),void 0===f&&(f=1),void 0===c&&(c=0),void 0!==u){var l=s(u,c,f,o);return"array"===n.matrix.defaultType?l:new i(l)}return o(c,f)},randomInt:function(e,t,o){var u,c,f;if(arguments.length>3||arguments.length<1)throw new r.error.ArgumentsError("randomInt",arguments.length,1,3);if(1===arguments.length?f=e:2===arguments.length?"[object Array]"===Object.prototype.toString.call(e)?u=e:(c=e,f=t):(u=e,c=t,f=o),void 0===c&&(c=0),void 0!==u){var l=s(u,c,f,a);return"array"===n.matrix.defaultType?l:new i(l)}return a(c,f)},pickRandom:function(e){if(1!==arguments.length)throw new r.error.ArgumentsError("pickRandom",arguments.length,1);if(!Array.isArray(e))throw new r.error.UnsupportedTypeError("pickRandom",e);return e[Math.floor(Math.random()*e.length)]}},o=function(t,n){return t+e()*(n-t)},a=function(t,n){return Math.floor(t+e()*(n-t))},s=function(e,t,n,r){var i,o,a=[];if(e=e.slice(0),e.length>1)for(o=0,i=e.shift();i>o;o++)a.push(s(e,t,n,r));else for(o=0,i=e.shift();i>o;o++)a.push(r(t,n));return a};return t}(a)};var a=t.distribution("uniform");t.random=a.random,t.randomInt=a.randomInt,t.pickRandom=a.pickRandom}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],179:[function(e,t){t.exports=function(t){function n(e,n){return t.larger(e,n)?e:n}function r(e){var n=null;if(i.deepForEach(e,function(e){(null===n||t.larger(e,n))&&(n=e)}),null===n)throw new Error("Cannot calculate max of an empty array");return n}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;t.max=function(e){if(0==arguments.length)throw new SyntaxError("Function max requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return i.reduce(arguments[0],arguments[1],n);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],180:[function(e,t){t.exports=function(t){function n(e,n){var r;return r=i.reduce(e,n,t.add),t.divide(r,size(e)[n])}function r(e){var n=0,r=0;if(i.deepForEach(e,function(e){n=t.add(n,e),r++}),0===r)throw new Error("Cannot calculate mean of an empty array");return t.divide(n,r)}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;t.mean=function(e){if(0==arguments.length)throw new SyntaxError("Function mean requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return n(arguments[0],arguments[1]);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],181:[function(e,t){t.exports=function(t){function n(e,n){return t.smaller(e,n)?e:n}function r(e){var n=null;if(i.deepForEach(e,function(e){(null===n||t.smaller(e,n))&&(n=e)}),null===n)throw new Error("Cannot calculate min of an empty array");return n}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;t.min=function(e){if(0==arguments.length)throw new SyntaxError("Function min requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return i.reduce(arguments[0],arguments[1],n);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],182:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/collection"),o=n.number.isNumber,a=n.boolean.isBoolean,s=r.isComplex,u=i.isCollection;t.acos=function c(e){if(1!=arguments.length)throw new n.error.ArgumentsError("acos",arguments.length,1);if(o(e))return e>=-1&&1>=e?Math.acos(e):c(new r(e,0));if(s(e)){var f,l=new r(e.im*e.im-e.re*e.re+1,-2*e.re*e.im),m=t.sqrt(l);f=m instanceof r?new r(m.re-e.im,m.im+e.re):new r(m-e.im,e.re);var p=t.log(f);return p instanceof r?new r(1.5707963267948966-p.im,p.re):new r(1.5707963267948966,p)}if(u(e))return i.deepMap(e,c);if(a(e))return Math.acos(e);throw new n.error.UnsupportedTypeError("acos",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],183:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/collection"),o=n.number.isNumber,a=n.boolean.isBoolean,s=r.isComplex,u=i.isCollection;t.asin=function c(e){if(1!=arguments.length)throw new n.error.ArgumentsError("asin",arguments.length,1);if(o(e))return e>=-1&&1>=e?Math.asin(e):c(new r(e,0));if(s(e)){var f,l=e.re,m=e.im,p=new r(m*m-l*l+1,-2*l*m),h=t.sqrt(p);f=h instanceof r?new r(h.re-m,h.im+l):new r(h-m,l);var g=t.log(f);return g instanceof r?new r(g.im,-g.re):new r(0,-g)}if(u(e))return i.deepMap(e,c);if(a(e))return Math.asin(e);throw new n.error.UnsupportedTypeError("asin",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],184:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/collection"),o=n.number.isNumber,a=n.boolean.isBoolean,s=r.isComplex,u=i.isCollection;t.atan=function c(e){if(1!=arguments.length)throw new n.error.ArgumentsError("atan",arguments.length,1);if(o(e))return Math.atan(e);if(s(e)){var f=e.re,l=e.im,m=f*f+(1-l)*(1-l),p=new r((1-l*l-f*f)/m,-2*f/m),h=t.log(p);return h instanceof r?new r(-.5*h.im,.5*h.re):new r(0,.5*h)}if(u(e))return i.deepMap(e,c);if(a(e))return Math.atan(e);throw new n.error.UnsupportedTypeError("atan",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],185:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/collection"),o=n.number.isNumber,a=n.boolean.isBoolean,s=r.isComplex,u=i.isCollection;t.atan2=function c(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("atan2",arguments.length,2);if(o(e)){if(o(t))return Math.atan2(e,t)}else if(s(e)&&o(t))return Math.atan2(e.re,t);if(u(e)||u(t))return i.deepMap2(e,t,c);if(a(e))return c(+e,t);if(a(t))return c(e,+t);throw new n.error.UnsupportedTypeError("atan2",e,t)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212}],186:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.cos=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cos",arguments.length,1);if(a(e))return Math.cos(e);if(u(e))return new r(.5*Math.cos(e.re)*(Math.exp(-e.im)+Math.exp(e.im)),.5*Math.sin(e.re)*(Math.exp(-e.im)-Math.exp(e.im)));if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.cos(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return Math.cos(e);throw new n.error.UnsupportedTypeError("cos",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],187:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.cot=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cot",arguments.length,1);if(a(e))return 1/Math.tan(e);if(u(e)){var t=Math.exp(-4*e.im)-2*Math.exp(-2*e.im)*Math.cos(2*e.re)+1;return new r(2*Math.exp(-2*e.im)*Math.sin(2*e.re)/t,(Math.exp(-4*e.im)-1)/t)}if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return 1/Math.tan(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return l(+e);throw new n.error.UnsupportedTypeError("cot",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],188:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.csc=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("csc",arguments.length,1);if(a(e))return 1/Math.sin(e);if(u(e)){var t=.25*(Math.exp(-2*e.im)+Math.exp(2*e.im))-.5*Math.cos(2*e.re);return new r(.5*Math.sin(e.re)*(Math.exp(-e.im)+Math.exp(e.im))/t,.5*Math.cos(e.re)*(Math.exp(-e.im)-Math.exp(e.im))/t)}if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return 1/Math.sin(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return l(+e);throw new n.error.UnsupportedTypeError("csc",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],189:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.sec=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sec",arguments.length,1);if(a(e))return 1/Math.cos(e);if(u(e)){var t=.25*(Math.exp(-2*e.im)+Math.exp(2*e.im))+.5*Math.cos(2*e.re);return new r(.5*Math.cos(e.re)*(Math.exp(-e.im)+Math.exp(e.im))/t,.5*Math.sin(e.re)*(Math.exp(e.im)-Math.exp(-e.im))/t)}if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return 1/Math.cos(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return l(+e);throw new n.error.UnsupportedTypeError("sec",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],190:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.sin=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sin",arguments.length,1);if(a(e))return Math.sin(e);if(u(e))return new r(.5*Math.sin(e.re)*(Math.exp(-e.im)+Math.exp(e.im)),.5*Math.cos(e.re)*(Math.exp(e.im)-Math.exp(-e.im)));if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return Math.sin(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return Math.sin(e);throw new n.error.UnsupportedTypeError("sin",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],191:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Complex"),i=e("../../type/Unit"),o=e("../../type/collection"),a=n.number.isNumber,s=n.boolean.isBoolean,u=r.isComplex,c=i.isUnit,f=o.isCollection;t.tan=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("tan",arguments.length,1);if(a(e))return Math.tan(e);if(u(e)){var t=Math.exp(-4*e.im)+2*Math.exp(-2*e.im)*Math.cos(2*e.re)+1;return new r(2*Math.exp(-2*e.im)*Math.sin(2*e.re)/t,(1-Math.exp(-4*e.im))/t)}if(c(e)){if(!e.hasBase(i.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return Math.tan(e.value)}if(f(e))return o.deepMap(e,l);if(s(e))return Math.tan(e);throw new n.error.UnsupportedTypeError("tan",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],192:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("../../type/Unit"),i=e("../../type/collection"),o=n.string.isString,a=r.isUnit,s=i.isCollection;t["in"]=function u(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("in",arguments.length,2);if(a(e)&&(a(t)||o(t)))return e["in"](t);if(s(e)||s(t))return i.deepMap2(e,t,u);throw new n.error.UnsupportedTypeError("in",e,t)}}},{"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],193:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=n.object;t.clone=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("clone",arguments.length,1);return r.clone(e)}}},{"../../util/index":212}],194:[function(e,t){t.exports=function(t){function n(e,t){var n=[],r=function(i,o){Array.isArray(i)?i.forEach(function(e,t){n[o]=t,r(e,o+1)}):t(i,n,e)};r(e,0)}var r=e("../../util/error"),i=e("../../type/Matrix").isMatrix;t.forEach=function(e,t){if(2!=arguments.length)throw new r.ArgumentsError("forEach",arguments.length,2);if(Array.isArray(e))return n(e,t);if(i(e))return e.forEach(t);throw new r.UnsupportedTypeError("forEach",e)}}},{"../../type/Matrix":205,"../../util/error":211}],195:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=n.string;t.format=function(e,t){var i=arguments.length;if(1!==i&&2!==i)throw new n.error.ArgumentsError("format",i,1,2);return r.format(e,t)}}},{"../../util/index":212}],196:[function(e,t){t.exports=function(t){function n(e,n,r){(r.override||void 0===t[e])&&(t[e]=r.wrap&&"function"==typeof n?function(){for(var e=[],r=0,i=arguments.length;i>r;r++)e[r]=arguments[r].valueOf();return n.apply(t,e)}:n,t.chaining.Selector.createProxy(e,n))}function r(e){return"function"==typeof e||s(e)||u(e)||c(e)||f(e)}var i=e("../../util/index"),o=e("../../type/Complex"),a=e("../../type/Unit"),s=i.number.isNumber,u=i.string.isString,c=o.isComplex,f=a.isUnit;t["import"]=function l(o,a){var s,c={override:!1,wrap:!0};if(a&&a instanceof Object&&i.object.extend(c,a),u(o)){if("undefined"==typeof e)throw new Error("Cannot load file: require not available.");var f=e(o);l(f)}else if(r(o)){if(s=o.name,!s)throw new Error("Cannot import an unnamed function or object");(c.override||void 0===t[s])&&n(s,o,c)}else if(o instanceof Object)for(s in o)if(o.hasOwnProperty(s)){var m=o[s];r(m)?n(s,m,c):l(m)}}}},{"../../type/Complex":202,"../../type/Unit":207,"../../util/index":212}],197:[function(e,t){t.exports=function(t){function n(e,t){var n=[],r=function(i,o){return Array.isArray(i)?i.map(function(e,t){return n[o]=t,r(e,o+1)}):t(i,n,e)};return r(e,0)}var r=e("../../util/error"),i=e("../../type/Matrix").isMatrix;t.map=function(e,t){if(2!=arguments.length)throw new r.ArgumentsError("map",arguments.length,2);if(Array.isArray(e))return n(e,t);if(i(e))return e.map(t);throw new r.UnsupportedTypeError("map",e)}}},{"../../type/Matrix":205,"../../util/error":211}],198:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=n.string,i=r.isString;t.print=function(e,r,o){var a=arguments.length;if(2!=a&&3!=a)throw new n.error.ArgumentsError("print",a,2,3);if(!i(e))throw new TypeError("String expected as first parameter in function format");if(!(r instanceof Object))throw new TypeError("Object expected as second parameter in function format");return e.replace(/\$([\w\.]+)/g,function(e,n){for(var a=n.split("."),s=r[a.shift()];a.length&&void 0!==s;){var u=a.shift();s=u?s[u]:s+"."}return void 0!==s?i(s)?s:t.format(s,o):e})}}},{"../../util/index":212}],199:[function(e,t){t.exports=function(e){e.select=function(t){return new e.chaining.Selector(t)}}},{}],200:[function(e,t){t.exports=function(t){var n=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Matrix"),a=e("../../type/Unit"),s=e("../../type/Index"),u=e("../../type/Range"),c=e("../../type/Help");t["typeof"]=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("typeof",arguments.length,1);var f=n.types.type(e);if("object"===f){if(e instanceof i)return"complex";if(e instanceof r)return"bignumber";if(e instanceof o)return"matrix";if(e instanceof a)return"unit";if(e instanceof s)return"index";if(e instanceof u)return"range";if(e instanceof c)return"matrix";if(e instanceof t.chaining.Selector)return"selector"}return f}}},{"../../type/Complex":202,"../../type/Help":203,"../../type/Index":204,"../../type/Matrix":205,"../../type/Range":206,"../../type/Unit":207,"../../util/index":212,"bignumber.js":217}],201:[function(e,t){function n(t){var n={},i={matrix:{defaultType:"matrix"},number:{defaultType:"number"}};return n.config=function(t){var n=e("bignumber.js");if(t&&(r.deepExtend(i,t),t.number&&t.number.precision&&n.config({DECIMAL_PLACES:t.number.precision}),t.matrix&&t.matrix.default))throw new Error("setting matrix.default is deprecated. Use matrix.defaultType instead.");var o=r.clone(i);return o.number.precision=n.config().DECIMAL_PLACES,o},n.config(t),n.expression={},n.expression.node=e("./expression/node/index.js"),n.expression.Scope=e("./expression/Scope.js"),n.expression.Parser=e("./expression/Parser.js"),n.expression.docs=e("./expression/docs/index.js"),n.expr={},n.expr.Scope=function(){throw new Error("Moved to math.expression.Scope")},n.expr.Parser=function(){throw new Error("Moved to math.expression.Parser")},n.type={},n.type.BigNumber=e("bignumber.js"),n.type.Complex=e("./type/Complex.js"),n.type.Range=e("./type/Range.js"),n.type.Index=e("./type/Index.js"),n.type.Matrix=e("./type/Matrix.js"),n.type.Unit=e("./type/Unit.js"),n.type.Help=e("./type/Help.js"),n.collection=e("./type/collection.js"),e("./function/expression/eval.js")(n,i),e("./function/expression/help.js")(n,i),e("./function/expression/parse.js")(n,i),e("./function/arithmetic/abs.js")(n,i),e("./function/arithmetic/add.js")(n,i),e("./function/arithmetic/add.js")(n,i),e("./function/arithmetic/ceil.js")(n,i),e("./function/arithmetic/cube.js")(n,i),e("./function/arithmetic/divide.js")(n,i),e("./function/arithmetic/edivide.js")(n,i),e("./function/arithmetic/emultiply.js")(n,i),e("./function/arithmetic/epow.js")(n,i),e("./function/arithmetic/equal.js")(n,i),e("./function/arithmetic/exp.js")(n,i),e("./function/arithmetic/fix.js")(n,i),e("./function/arithmetic/floor.js")(n,i),e("./function/arithmetic/gcd.js")(n,i),e("./function/arithmetic/larger.js")(n,i),e("./function/arithmetic/largereq.js")(n,i),e("./function/arithmetic/lcm.js")(n,i),e("./function/arithmetic/log.js")(n,i),e("./function/arithmetic/log10.js")(n,i),e("./function/arithmetic/mod.js")(n,i),e("./function/arithmetic/multiply.js")(n,i),e("./function/arithmetic/pow.js")(n,i),e("./function/arithmetic/round.js")(n,i),e("./function/arithmetic/sign.js")(n,i),e("./function/arithmetic/smaller.js")(n,i),e("./function/arithmetic/smallereq.js")(n,i),e("./function/arithmetic/sqrt.js")(n,i),e("./function/arithmetic/square.js")(n,i),e("./function/arithmetic/subtract.js")(n,i),e("./function/arithmetic/unary.js")(n,i),e("./function/arithmetic/unequal.js")(n,i),e("./function/arithmetic/xgcd.js")(n,i),e("./function/complex/arg.js")(n,i),e("./function/complex/conj.js")(n,i),e("./function/complex/re.js")(n,i),e("./function/complex/im.js")(n,i),e("./function/construction/bignumber")(n,i),e("./function/construction/boolean.js")(n,i),e("./function/construction/complex.js")(n,i),e("./function/construction/index.js")(n,i),e("./function/construction/matrix.js")(n,i),e("./function/construction/number.js")(n,i),e("./function/construction/parser.js")(n,i),e("./function/construction/string.js")(n,i),e("./function/construction/unit.js")(n,i),e("./function/matrix/concat.js")(n,i),e("./function/matrix/det.js")(n,i),e("./function/matrix/diag.js")(n,i),e("./function/matrix/eye.js")(n,i),e("./function/matrix/inv.js")(n,i),e("./function/matrix/ones.js")(n,i),e("./function/matrix/range.js")(n,i),e("./function/matrix/resize.js")(n,i),e("./function/matrix/size.js")(n,i),e("./function/matrix/squeeze.js")(n,i),e("./function/matrix/subset.js")(n,i),e("./function/matrix/transpose.js")(n,i),e("./function/matrix/zeros.js")(n,i),e("./function/probability/factorial.js")(n,i),e("./function/probability/random.js")(n,i),e("./function/statistics/min.js")(n,i),e("./function/statistics/max.js")(n,i),e("./function/statistics/mean.js")(n,i),e("./function/trigonometry/acos.js")(n,i),e("./function/trigonometry/asin.js")(n,i),e("./function/trigonometry/atan.js")(n,i),e("./function/trigonometry/atan2.js")(n,i),e("./function/trigonometry/cos.js")(n,i),e("./function/trigonometry/cot.js")(n,i),e("./function/trigonometry/csc.js")(n,i),e("./function/trigonometry/sec.js")(n,i),e("./function/trigonometry/sin.js")(n,i),e("./function/trigonometry/tan.js")(n,i),e("./function/units/in.js")(n,i),e("./function/utils/clone.js")(n,i),e("./function/utils/format.js")(n,i),e("./function/utils/import.js")(n,i),e("./function/utils/map.js")(n,i),e("./function/utils/print.js")(n,i),e("./function/utils/select.js")(n,i),e("./function/utils/typeof.js")(n,i),e("./function/utils/forEach.js")(n,i),e("./constants.js")(n,i),n.chaining={},n.chaining.Selector=e("./chaining/Selector.js")(n,i),n.expr.Selector=function(){throw new Error("Moved to math.expression.Selector")},n}var r=e("./util/object");t.exports=n;var i=function(){throw new Error('Static function calls are deprecated. Create an instance of math.js:\n "var math = require(\'mathjs\')();" on node.js, \n "var math = mathjs();" in the browser.')},o=n();for(var a in o)if(o.hasOwnProperty(a)){var s=o[a];"function"==typeof s?n[a]=i:Object.defineProperty&&Object.defineProperty(n,a,{get:i,set:i,enumerable:!0,configurable:!1})}"undefined"!=typeof window&&(window.math=n)},{"./chaining/Selector.js":2,"./constants.js":3,"./expression/Parser.js":4,"./expression/Scope.js":5,"./expression/docs/index.js":103,"./expression/node/index.js":116,"./function/arithmetic/abs.js":117,"./function/arithmetic/add.js":118,"./function/arithmetic/ceil.js":119,"./function/arithmetic/cube.js":120,"./function/arithmetic/divide.js":121,"./function/arithmetic/edivide.js":122,"./function/arithmetic/emultiply.js":123,"./function/arithmetic/epow.js":124,"./function/arithmetic/equal.js":125,"./function/arithmetic/exp.js":126,"./function/arithmetic/fix.js":127,"./function/arithmetic/floor.js":128,"./function/arithmetic/gcd.js":129,"./function/arithmetic/larger.js":130,"./function/arithmetic/largereq.js":131,"./function/arithmetic/lcm.js":132,"./function/arithmetic/log.js":133,"./function/arithmetic/log10.js":134,"./function/arithmetic/mod.js":135,"./function/arithmetic/multiply.js":136,"./function/arithmetic/pow.js":137,"./function/arithmetic/round.js":138,"./function/arithmetic/sign.js":139,"./function/arithmetic/smaller.js":140,"./function/arithmetic/smallereq.js":141,"./function/arithmetic/sqrt.js":142,"./function/arithmetic/square.js":143,"./function/arithmetic/subtract.js":144,"./function/arithmetic/unary.js":145,"./function/arithmetic/unequal.js":146,"./function/arithmetic/xgcd.js":147,"./function/complex/arg.js":148,"./function/complex/conj.js":149,"./function/complex/im.js":150,"./function/complex/re.js":151,"./function/construction/bignumber":152,"./function/construction/boolean.js":153,"./function/construction/complex.js":154,"./function/construction/index.js":155,"./function/construction/matrix.js":156,"./function/construction/number.js":157,"./function/construction/parser.js":158,"./function/construction/string.js":159,"./function/construction/unit.js":160,"./function/expression/eval.js":161,"./function/expression/help.js":162,"./function/expression/parse.js":163,"./function/matrix/concat.js":164,"./function/matrix/det.js":165,"./function/matrix/diag.js":166,"./function/matrix/eye.js":167,"./function/matrix/inv.js":168,"./function/matrix/ones.js":169,"./function/matrix/range.js":170,"./function/matrix/resize.js":171,"./function/matrix/size.js":172,"./function/matrix/squeeze.js":173,"./function/matrix/subset.js":174,"./function/matrix/transpose.js":175,"./function/matrix/zeros.js":176,"./function/probability/factorial.js":177,"./function/probability/random.js":178,"./function/statistics/max.js":179,"./function/statistics/mean.js":180,"./function/statistics/min.js":181,"./function/trigonometry/acos.js":182,"./function/trigonometry/asin.js":183,"./function/trigonometry/atan.js":184,"./function/trigonometry/atan2.js":185,"./function/trigonometry/cos.js":186,"./function/trigonometry/cot.js":187,"./function/trigonometry/csc.js":188,"./function/trigonometry/sec.js":189,"./function/trigonometry/sin.js":190,"./function/trigonometry/tan.js":191,"./function/units/in.js":192,"./function/utils/clone.js":193,"./function/utils/forEach.js":194,"./function/utils/format.js":195,"./function/utils/import.js":196,"./function/utils/map.js":197,"./function/utils/print.js":198,"./function/utils/select.js":199,"./function/utils/typeof.js":200,"./type/Complex.js":202,"./type/Help.js":203,"./type/Index.js":204,"./type/Matrix.js":205,"./type/Range.js":206,"./type/Unit.js":207,"./type/collection.js":208,"./util/object":214,"bignumber.js":217}],202:[function(e,t,n){function r(e,t){if(!(this instanceof r))throw new SyntaxError("Complex constructor must be called with the new operator"); -switch(arguments.length){case 0:this.re=0,this.im=0;break;case 2:if(!p(e)||!p(t))throw new TypeError("Two numbers expected in Complex constructor");this.re=e,this.im=t;break;default:if(0!=arguments.length&&2!=arguments.length)throw new SyntaxError("Two or zero arguments expected in Complex constructor")}}function i(){for(;" "==d||" "==d;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){x++,d=g.charAt(x)}function u(e){x=e,d=g.charAt(x)}function c(){var e,t="";if(e=x,"+"==d?s():"-"==d&&(t+=d,s()),!o(d))return u(e),null;if("."==d){if(t+=d,s(),!a(d))return u(e),null}else{for(;a(d);)t+=d,s();"."==d&&(t+=d,s())}for(;a(d);)t+=d,s();if("E"==d||"e"==d){if(t+=d,s(),("+"==d||"-"==d)&&(t+=d,s()),!a(d))return u(e),null;for(;a(d);)t+=d,s()}return t}function f(){var e=g.charAt(x+1);if("I"==d||"i"==d)return s(),"1";if(!("+"!=d&&"-"!=d||"I"!=e&&"i"!=e)){var t="+"==d?"1":"-1";return s(),s(),t}return null}var l=e("../util/index"),m=l.number,p=l.number.isNumber,h=l.string.isString;r.isComplex=function(e){return e instanceof r};var g,x,d;r.parse=function(e){if(g=e,x=-1,d="",!h(g))return null;s(),i();var t=c();if(t){if("I"==d||"i"==d)return s(),i(),d?null:new r(0,Number(t));i();var n=d;if("+"!=n&&"-"!=n)return i(),d?null:new r(Number(t),0);s(),i();var o=c();if(o){if("I"!=d&&"i"!=d)return null;s()}else if(o=f(),!o)return null;return"-"==n&&(o="-"==o[0]?"+"+o.substring(1):"-"+o),s(),i(),d?null:new r(Number(t),Number(o))}return(t=f())?(i(),d?null:new r(0,Number(t))):null},r.prototype.clone=function(){return new r(this.re,this.im)},r.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},r.prototype.format=function(e){var t="",n=m.format(this.re,e),r=m.format(this.im,e);return t=0==this.im?n:0==this.re?1==this.im?"i":-1==this.im?"-i":r+"i":this.im>0?1==this.im?n+" + i":n+" + "+r+"i":-1==this.im?n+" - i":n+" - "+r.substring(1)+"i"},r.prototype.toString=function(){return this.format()},t.exports=r,n.isComplex=r.isComplex,n.parse=r.parse},{"../util/index":212}],203:[function(e,t,n){function r(e,t){this.math=e,this.doc=t}var i=e("../util/index"),o=i.object,a=i.string;r.isHelp=function(e){return e instanceof r},r.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){var n=this.math.parser();t+="Examples:\n";for(var i=0;ie;e++){var n=arguments[e];if(n instanceof a)this._ranges.push(n);else if(n&&(n=n.valueOf()),f(n))this._ranges.push(i(n));else{if(!u(n))throw new TypeError("Range expected as Array, Number, or String");this._ranges.push(i([n,n+1]))}}}function i(e){for(var t=e.length,n=0;t>n;n++)if(!u(e[n])||!c(e[n]))throw new TypeError("Index parameters must be integer numbers");switch(e.length){case 2:return new a(e[0],e[1]);case 3:return new a(e[0],e[1],e[2]);default:throw new SyntaxError("Wrong number of arguments in Index (2 or 3 expected)")}}{var o=e("../util/index"),a=e("./Range"),s=o.number,u=s.isNumber,c=s.isInteger,f=Array.isArray;o.array.validateIndex}r.prototype.clone=function(){var e=new r;return e._ranges=o.object.clone(this._ranges),e},r.isIndex=function(e){return e instanceof r},r.create=function(e){var t=new r;return r.apply(t,e),t},r.prototype.size=function l(){for(var l=[],e=0,t=this._ranges.length;t>e;e++){var n=this._ranges[e];l[e]=n.size()[0]}return l},r.prototype.max=function(){for(var e=[],t=0,n=this._ranges.length;n>t;t++){var r=this._ranges[t];e[t]=r.max()}return e},r.prototype.min=function(){for(var e=[],t=0,n=this._ranges.length;n>t;t++){var r=this._ranges[t];e[t]=r.min()}return e},r.prototype.forEach=function(e){for(var t=0,n=this._ranges.length;n>t;t++)e(this._ranges[t],t,this)},r.prototype.range=function(e){return this._ranges[e]},r.prototype.isScalar=function(){for(var e=this.size(),t=0,n=e.length;n>t;t++)if(1!==e[t])return!1;return!0},r.prototype.toArray=function(){for(var e=[],t=0,n=this._ranges.length;n>t;t++){var r=this._ranges[t],i=[],o=r.start,a=r.end,s=r.step;if(s>0)for(;a>o;)i.push(o),o+=s;else if(0>s)for(;o>a;)i.push(o),o+=s;e.push(i)}return e},r.prototype.valueOf=r.prototype.toArray,r.prototype.toString=function(){for(var e=[],t=0,n=this._ranges.length;n>t;t++){var r=this._ranges[t],i=s.format(r.start);1!=r.step&&(i+=":"+s.format(r.step)),i+=":"+s.format(r.end),e.push(i)}return"["+e.join(",")+"]"},t.exports=r,n.isIndex=r.isIndex,n.create=r.create},{"../util/index":212,"./Range":206}],205:[function(e,t,n){function r(e){if(!(this instanceof r))throw new SyntaxError("Matrix constructor must be called with the new operator");if(e instanceof r)this._data=e.clone()._data;else if(h(e))this._data=e;else{if(null!=e)throw new TypeError("Unsupported type of data ("+c.types.type(e)+")");this._data=[]}this._size=m.size(this._data)}function i(e,t){if(!(t instanceof f))throw new TypeError("Invalid index");var n=t.isScalar();if(n)return e.get(t.min());var i=t.size();if(i.length!=e._size.length)throw new RangeError("Dimension mismatch ("+i.length+" != "+e._size.length+")");for(var a=new r(o(e._data,t,i.length,0));h(a._data)&&1==a._data.length;)a._data=a._data[0],a._size.shift();return a}function o(e,t,n,r){var i=r==n-1,a=t.range(r);return i?a.map(function(t){return g(t,e.length),e[t]}):a.map(function(i){g(i,e.length);var a=e[i];return o(a,t,n,r+1)})}function a(e,t,n,i){if(!(t instanceof f))throw new TypeError("Invalid index");var o,a=t.size(),c=t.isScalar();if(n instanceof r?(o=n.size(),n=n.valueOf()):o=m.size(n),c){if(0!=o.length)throw new TypeError("Scalar value expected");e.set(t.min(),n,i)}else{if(a.lengthh;h++)n=[n],o.unshift(1);if(!p.deepEqual(a,o))throw new RangeError("Dimensions mismatch ("+l.format(a)+" != "+l.format(o)+")");var x=t.max().map(function(e){return e+1});u(e,x,i);var d=a.length,y=0;s(e._data,t,n,d,y)}return e}function s(e,t,n,r,i){var o=i==r-1,a=t.range(i);o?a.forEach(function(t,r){g(t),e[t]=n[r]}):a.forEach(function(o,a){g(o),s(e[o],t,n[a],r,i+1)})}function u(e,t,n){if(!h(t))throw new Error("Array expected");for(var r=p.clone(e._size),i=!1;r.lengtho;o++)t[o]>r[o]&&(r[o]=t[o],i=!0);i&&e.resize(r,n)}var c=e("../util/index"),f=e("./Index"),l=(c.number,c.string),m=c.array,p=c.object,h=Array.isArray,g=m.validateIndex;r.isMatrix=function(e){return e instanceof r},r.prototype.subset=function(e,t,n){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return a(this,e,t,n);default:throw new c.error.ArgumentsError("subset",arguments.length,1,3)}},r.prototype.get=function(e){if(!h(e))throw new Error("Array expected");if(e.length!=this._size.length)throw new RangeError("Dimension mismatch ("+e.length+" != "+this._size.length+")");for(var t=this._data,n=0,r=e.length;r>n;n++){var i=e[n];g(i,t.length),t=t[i]}return p.clone(t)},r.prototype.set=function(e,t,n){var r,i;if(!h(e))throw new Error("Array expected");if(e.lengthr;r++){var s=e[r];g(s,a.length),a=a[s]}return s=e[e.length-1],g(s,a.length),a[s]=t,this},r.prototype.resize=function(e,t){return this._size=p.clone(e),this._data=m.resize(this._data,this._size,t),this},r.prototype.clone=function(){var e=new r;return e._data=p.clone(this._data),e._size=p.clone(this._size),e},r.prototype.size=function(){return this._size},r.prototype.map=function(e){var t=this,n=new r,i=[],o=function(n,r){return h(n)?n.map(function(e,t){return i[r]=t,o(e,r+1)}):e(n,i,t)};return n._data=o(this._data,0),n._size=p.clone(this._size),n},r.prototype.forEach=function(e){var t=this,n=[],r=function(i,o){h(i)?i.forEach(function(e,t){n[o]=t,r(e,o+1)}):e(i,n,t)};r(this._data,0)},r.prototype.toArray=function(){return p.clone(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return l.format(this._data,e)},r.prototype.toString=function(){return l.format(this._data)},t.exports=r,n.isMatrix=r.isMatrix},{"../util/index":212,"./Index":204}],206:[function(e,t,n){function r(e,t,n){if(!(this instanceof r))throw new SyntaxError("Range constructor must be called with the new operator");if(null!=e&&!o.isNumber(e))throw new TypeError("Parameter start must be a number");if(null!=t&&!o.isNumber(t))throw new TypeError("Parameter end must be a number");if(null!=n&&!o.isNumber(n))throw new TypeError("Parameter step must be a number");this.start=null!=e?parseFloat(e):0,this.end=null!=t?parseFloat(t):0,this.step=null!=n?parseFloat(n):1}{var i=e("../util/index"),o=i.number,a=i.string;i.array}r.parse=function(e){if(!a.isString(e))return null;var t=e.split(":"),n=t.map(function(e){return parseFloat(e)}),i=n.some(function(e){return isNaN(e)});if(i)return null;switch(n.length){case 2:return new r(n[0],n[1]);case 3:return new r(n[0],n[2],n[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.isRange=function(e){return e instanceof r},r.prototype.size=function(){var e=0,t=this.start,n=this.step,r=this.end,i=r-t;return o.sign(n)==o.sign(i)?e=Math.ceil(i/n):0==i&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},r.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},r.prototype.forEach=function(e){var t=this.start,n=this.step,r=this.end,i=0;if(n>0)for(;r>t;)e(t,i,this),t+=n,i++;else if(0>n)for(;t>r;)e(t,i,this),t+=n,i++},r.prototype.map=function(e){var t=[];return this.forEach(function(n,r,i){t[r]=e(n,r,i)}),t},r.prototype.toArray=function(){var e=[];return this.forEach(function(t,n){e[n]=t}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var t=o.format(this.start,e);return 1!=this.step&&(t+=":"+o.format(this.step,e)),t+=":"+o.format(this.end,e)},r.prototype.toString=function(){return this.format()},t.exports=r,n.isRange=r.isRange,n.parse=r.parse},{"../util/index":212}],207:[function(e,t,n){function r(e,t){if(!(this instanceof r))throw new Error("Unit constructor must be called with the new operator");if(null!=e&&!y(e))throw new TypeError("First parameter in Unit constructor must be a number");if(null!=t&&!b(t))throw new TypeError("Second parameter in Unit constructor must be a string");if(null!=t){var n=l(t);if(!n)throw new SyntaxError('String "'+t+'" is no unit');this.unit=n.unit,this.prefix=n.prefix}else this.unit=UNIT_NONE,this.prefix=w;null!=e?(this.value=this._normalize(e),this.fixPrefix=!1):(this.value=null,this.fixPrefix=!0)}function i(){for(;" "==h||" "==h;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){p++,h=m.charAt(p)}function u(e){p=e,h=m.charAt(p)}function c(){var e,t="";if(e=p,"+"==h?s():"-"==h&&(t+=h,s()),!o(h))return u(e),null;if("."==h){if(t+=h,s(),!a(h))return u(e),null}else{for(;a(h);)t+=h,s();"."==h&&(t+=h,s())}for(;a(h);)t+=h,s();if("E"==h||"e"==h){if(t+=h,s(),("+"==h||"-"==h)&&(t+=h,s()),!a(h))return u(e),null;for(;a(h);)t+=h,s()}return t}function f(){var e="";for(i();h&&" "!=h&&" "!=h;)e+=h,s();return e||null}function l(e){for(var t=0,n=N.length;n>t;t++){var r=N[t];if(d.endsWith(e,r.name)){var i=e.length-r.name.length,o=e.substring(0,i),a=r.prefixes[o];if(void 0!==a)return{unit:r,prefix:a}}}return null}var m,p,h,g=e("../util/index"),x=g.number,d=g.string,y=g.number.isNumber,b=g.string.isString;r.parse=function(e){if(m=e,p=-1,h="",!b(m))return null;s(),i();var t,n=c();return n?(t=f(),s(),i(),h?null:n&&t?new r(Number(n),t):null):(t=f(),s(),i(),h?null:new r(null,t))},r.isUnit=function(e){return e instanceof r},r.prototype.clone=function(){var e=new r;for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},r.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},r.prototype._unnormalize=function(e,t){return void 0==t?e/this.unit.value/this.prefix.value-this.unit.offset:e/this.unit.value/t-this.unit.offset},r.isPlainUnit=function(e){return null!=l(e)},r.prototype.hasBase=function(e){return void 0===this.unit.base?void 0===e:this.unit.base===e},r.prototype.equalBase=function(e){return this.unit.base===e.unit.base},r.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},r.prototype["in"]=function(e){var t;if(b(e)){if(t=new r(null,e),!this.equalBase(t))throw new Error("Units do not match");return t.value=this.value,t}if(e instanceof r){if(!this.equalBase(e))throw new Error("Units do not match");if(null!=e.value)throw new Error("Cannot convert to a unit with a value");if(null==e.unit)throw new Error("Unit expected on the right hand side of function in");return t=e.clone(),t.value=this.value,t.fixPrefix=!0,t}throw new Error("String or Unit expected as parameter")},r.prototype.toNumber=function(e){var t=this["in"](e),n=this.fixPrefix?t._bestPrefix():t.prefix;return t._unnormalize(t.value,n.value)},r.prototype.toString=function(){return this.format()},r.prototype.format=function(e){var t,n;if(this.fixPrefix)t=this._unnormalize(this.value),n=null!=this.value?x.format(t,e)+" ":"",n+=this.prefix.name+this.unit.name;else{var r=this._bestPrefix();t=this._unnormalize(this.value,r.value),n=null!=this.value?x.format(t,e)+" ":"",n+=r.name+this.unit.name}return n},r.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),t=w,n=Math.abs(Math.log(e/t.value)/Math.LN10-1.2),r=this.unit.prefixes;for(var i in r)if(r.hasOwnProperty(i)){var o=r[i];if(o.scientific){var a=Math.abs(Math.log(e/o.value)/Math.LN10-1.2);n>a&&(t=o,n=a)}}return t};var v={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1024,scientific:!0},M:{name:"M",value:Math.pow(1024,2),scientific:!0},G:{name:"G",value:Math.pow(1024,3),scientific:!0},T:{name:"T",value:Math.pow(1024,4),scientific:!0},P:{name:"P",value:Math.pow(1024,5),scientific:!0},E:{name:"E",value:Math.pow(1024,6),scientific:!0},Z:{name:"Z",value:Math.pow(1024,7),scientific:!0},Y:{name:"Y",value:Math.pow(1024,8),scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1024,scientific:!0},mega:{name:"mega",value:Math.pow(1024,2),scientific:!0},giga:{name:"giga",value:Math.pow(1024,3),scientific:!0},tera:{name:"tera",value:Math.pow(1024,4),scientific:!0},peta:{name:"peta",value:Math.pow(1024,5),scientific:!0},exa:{name:"exa",value:Math.pow(1024,6),scientific:!0},zetta:{name:"zetta",value:Math.pow(1024,7),scientific:!0},yotta:{name:"yotta",value:Math.pow(1024,8),scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}}},w={name:"",value:1,scientific:!0},E={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}};BASE_UNIT_NONE={},UNIT_NONE={name:"",base:BASE_UNIT_NONE,value:1,offset:0};var N=[{name:"meter",base:E.LENGTH,prefixes:v.LONG,value:1,offset:0},{name:"inch",base:E.LENGTH,prefixes:v.NONE,value:.0254,offset:0},{name:"foot",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},{name:"yard",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},{name:"mile",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},{name:"link",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},{name:"rod",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},{name:"chain",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},{name:"angstrom",base:E.LENGTH,prefixes:v.NONE,value:1e-10,offset:0},{name:"m",base:E.LENGTH,prefixes:v.SHORT,value:1,offset:0},{name:"ft",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},{name:"yd",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},{name:"mi",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},{name:"li",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},{name:"rd",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},{name:"ch",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},{name:"mil",base:E.LENGTH,prefixes:v.NONE,value:254e-7,offset:0},{name:"m2",base:E.SURFACE,prefixes:v.SHORT,value:1,offset:0},{name:"sqin",base:E.SURFACE,prefixes:v.NONE,value:64516e-8,offset:0},{name:"sqft",base:E.SURFACE,prefixes:v.NONE,value:.09290304,offset:0},{name:"sqyd",base:E.SURFACE,prefixes:v.NONE,value:.83612736,offset:0},{name:"sqmi",base:E.SURFACE,prefixes:v.NONE,value:2589988.110336,offset:0},{name:"sqrd",base:E.SURFACE,prefixes:v.NONE,value:25.29295,offset:0},{name:"sqch",base:E.SURFACE,prefixes:v.NONE,value:404.6873,offset:0},{name:"sqmil",base:E.SURFACE,prefixes:v.NONE,value:6.4516e-10,offset:0},{name:"m3",base:E.VOLUME,prefixes:v.SHORT,value:1,offset:0},{name:"L",base:E.VOLUME,prefixes:v.SHORT,value:.001,offset:0},{name:"litre",base:E.VOLUME,prefixes:v.LONG,value:.001,offset:0},{name:"cuin",base:E.VOLUME,prefixes:v.NONE,value:16387064e-12,offset:0},{name:"cuft",base:E.VOLUME,prefixes:v.NONE,value:.028316846592,offset:0},{name:"cuyd",base:E.VOLUME,prefixes:v.NONE,value:.764554857984,offset:0},{name:"teaspoon",base:E.VOLUME,prefixes:v.NONE,value:5e-6,offset:0},{name:"tablespoon",base:E.VOLUME,prefixes:v.NONE,value:15e-6,offset:0},{name:"minim",base:E.VOLUME,prefixes:v.NONE,value:6.161152e-8,offset:0},{name:"fluiddram",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},{name:"fluidounce",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},{name:"gill",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},{name:"cup",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},{name:"pint",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},{name:"quart",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},{name:"gallon",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},{name:"beerbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},{name:"oilbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},{name:"hogshead",base:E.VOLUME,prefixes:v.NONE,value:.238481,offset:0},{name:"fldr",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},{name:"floz",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},{name:"gi",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},{name:"cp",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},{name:"pt",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},{name:"qt",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},{name:"gal",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},{name:"bbl",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},{name:"obl",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},{name:"g",base:E.MASS,prefixes:v.SHORT,value:.001,offset:0},{name:"gram",base:E.MASS,prefixes:v.LONG,value:.001,offset:0},{name:"ton",base:E.MASS,prefixes:v.SHORT,value:907.18474,offset:0},{name:"tonne",base:E.MASS,prefixes:v.SHORT,value:1e3,offset:0},{name:"grain",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},{name:"dram",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},{name:"ounce",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},{name:"poundmass",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},{name:"hundredweight",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},{name:"stick",base:E.MASS,prefixes:v.NONE,value:.115,offset:0},{name:"gr",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},{name:"dr",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},{name:"oz",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},{name:"lbm",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},{name:"cwt",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},{name:"s",base:E.TIME,prefixes:v.SHORT,value:1,offset:0},{name:"min",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"h",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"seconds",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"second",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"sec",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"minutes",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"minute",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"hours",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"hour",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"day",base:E.TIME,prefixes:v.NONE,value:86400,offset:0},{name:"days",base:E.TIME,prefixes:v.NONE,value:86400,offset:0},{name:"rad",base:E.ANGLE,prefixes:v.NONE,value:1,offset:0},{name:"deg",base:E.ANGLE,prefixes:v.NONE,value:.017453292519943295,offset:0},{name:"grad",base:E.ANGLE,prefixes:v.NONE,value:.015707963267948967,offset:0},{name:"cycle",base:E.ANGLE,prefixes:v.NONE,value:6.283185307179586,offset:0},{name:"A",base:E.CURRENT,prefixes:v.SHORT,value:1,offset:0},{name:"ampere",base:E.CURRENT,prefixes:v.LONG,value:1,offset:0},{name:"K",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},{name:"degC",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},{name:"degF",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},{name:"degR",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},{name:"kelvin",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},{name:"celsius",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},{name:"fahrenheit",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},{name:"rankine",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},{name:"mol",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},{name:"mole",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},{name:"cd",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},{name:"candela",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},{name:"N",base:E.FORCE,prefixes:v.SHORT,value:1,offset:0},{name:"newton",base:E.FORCE,prefixes:v.LONG,value:1,offset:0},{name:"lbf",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},{name:"poundforce",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},{name:"b",base:E.BIT,prefixes:v.BINARY_SHORT,value:1,offset:0},{name:"bits",base:E.BIT,prefixes:v.BINARY_LONG,value:1,offset:0},{name:"B",base:E.BIT,prefixes:v.BINARY_SHORT,value:8,offset:0},{name:"bytes",base:E.BIT,prefixes:v.BINARY_LONG,value:8,offset:0}];r.PREFIXES=v,r.BASE_UNITS=E,r.UNITS=N,t.exports=r,n.isUnit=r.isUnit,n.isPlainUnit=r.isPlainUnit,n.parse=r.parse},{"../util/index":212}],208:[function(e,t,n){function r(e,t,n){var o,a,u,c;if(0>=t){if(s(e[0])){for(c=i(e),a=[],o=0;on;n++){var a=[];for(t=0;r>t;t++)a.push(e[t][n]);o.push(a)}return o}{var o=e("../util/index"),a=e("./Matrix"),s=o.array.isArray;o.string.isString}n.argsToArray=function(e){var t;return 0==e.length?t=[]:1==e.length?(t=e[0],t instanceof a&&(t=t.valueOf()),s(t)||(t=[t])):t=Array.prototype.slice.apply(e),t},n.isCollection=function(e){return s(e)||e instanceof a},n.deepMap=function u(e,t){return e&&"function"==typeof e.map?e.map(function(e){return u(e,t)}):t(e)},n.deepMap2=function c(e,t,n){var r,i,o;if(s(e))if(s(t)){if(e.length!=t.length)throw new RangeError("Dimension mismatch ("+e.length+" != "+t.length+")");for(r=[],i=e.length,o=0;i>o;o++)r[o]=c(e[o],t[o],n)}else{if(t instanceof a)return r=c(e,t.valueOf(),n),new a(r);for(r=[],i=e.length,o=0;i>o;o++)r[o]=c(e[o],t,n)}else{if(e instanceof a)return t instanceof a?(r=c(e.valueOf(),t.valueOf(),n),new a(r)):(r=c(e.valueOf(),t,n),new a(r));if(s(t))for(r=[],i=t.length,o=0;i>o;o++)r[o]=c(e,t[o],n);else r=n(e,t)}return r},n.reduce=function(e,t,n){return e instanceof a?new a(r(e.valueOf(),t,n)):r(e,t,n)},n.deepForEach=function f(e,t){e instanceof a&&(e=e.valueOf());for(var n=0,r=e.length;r>n;n++){var i=e[n];s(i)?f(i,t):t(i)}}},{"../util/index":212,"./Matrix":205}],209:[function(e,t,n){function r(e){for(var t=[];c(e);)t.push(e.length),e=e[0];return t}function i(e,t,n){var r,o=e.length;if(o!=t[n])throw new RangeError("Dimension mismatch ("+o+" != "+t[n]+")");if(nr;r++){var s=e[r];if(!c(s))throw new RangeError("Dimension mismatch ("+(t.length-1)+" < "+t.length+")");i(e[r],t,a)}}else for(r=0;o>r;r++)if(c(e[r]))throw new RangeError("Dimension mismatch ("+(t.length+1)+" > "+t.length+")")}function o(e,t,n,r){if(!c(e))throw Error("Array expected");var i,a,s=e.length,f=t[n],l=Math.min(s,f);if(e.length=f,ni;i++)a=e[i],o(a,t,m,r);for(i=l;f>i;i++)a=[],e[i]=a,o(a,t,m,r)}else if(void 0!==r)for(i=s;f>i;i++)e[i]=u.clone(r)}var a=e("./number"),s=e("./string"),u=e("./object"),c=(e("./types"),Array.isArray);n.size=function(e){var t=r(e);return n.validate(e,t),t},n.validate=function(e,t){var n=0==t.length;if(n){if(c(e))throw new RangeError("Dimension mismatch ("+e.length+" != 0)")}else i(e,t,0)},n.validateIndex=function(e,t){if(!a.isNumber(e)||!a.isInteger(e))throw new TypeError("Index must be an integer (value: "+e+")");if(0>e)throw new RangeError("Index out of range ("+e+" < 0)");if(void 0!==t&&e>=t)throw new RangeError("Index out of range ("+e+" > "+(t-1)+")")},n.resize=function(e,t,n){if(!c(e)||!c(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");t.forEach(function(e){if(!a.isNumber(e)||!a.isInteger(e)||0>e)throw new TypeError("Invalid size, must contain positive integers (size: "+s.format(t)+")")});for(var r=1,i=e[0];c(i);)r++,i=i[0];for(;rt.length;)e=e[0],r--;return o(e,t,0,n),e},n.squeeze=function(e){for(;c(e)&&1===e.length;)e=e[0];return e},n.unsqueeze=function(e,t){for(var r=n.size(e),i=0,o=t-r.length;o>i;i++)e=[e];return e},n.isArray=c},{"./number":213,"./object":214,"./string":215,"./types":216}],210:[function(e,t,n){n.isBoolean=function(e){return e instanceof Boolean||"boolean"==typeof e}},{}],211:[function(e,t,n){var r=e("./types");n.UnsupportedTypeError=function(e,t){if(2==arguments.length){var n=r.type(t);this.message="Function "+e+"("+n+") not supported"}else if(arguments.length>2){for(var i=[],o=1;o=t&&n>r)}var o=e("bignumber.js");n.isNumber=function(e){return e instanceof Number||"number"==typeof e},n.isInteger=function(e){return e==Math.round(e)},n.sign=function(e){return e>0?1:0>e?-1:0},n.format=function(e,t){if("function"==typeof t)return t(e);if(1/0===e)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",s=void 0;switch(void 0!==t&&(t.notation&&(a=t.notation),t&&(n.isNumber(t)?s=t:t.precision&&(s=t.precision))),a){case"fixed":return e.toFixed(s||0);case"scientific":return n.toScientific(e,s);case"auto":var u=.001,c=1e5;if(t&&t.scientific&&(void 0!==t.scientific.lower&&(u=t.scientific.lower),void 0!==t.scientific.upper&&(c=t.scientific.upper)),r(e))return"0";var f;return f=i(e,u,c)?e instanceof o?new o(e.toPrecision(s)).toString():parseFloat(e.toPrecision(s))+"":n.toScientific(e,s),f.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "scientific", or "fixed".')}},n.toScientific=function(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()},n.digits=function(e){return e.toExponential().replace(/e[\+\-0-9]*$/,"").replace(/^0\.0*|\./,"").length},n.toBigNumber=function(e){return n.digits(e)>15?e:new o(e)},n.toNumber=function(e){return parseFloat(e.valueOf())}},{"bignumber.js":217}],214:[function(e,t,n){var r=e("./number"),i=e("./string"),o=e("./boolean");n.clone=function a(e){if(null==e)return e;if("function"==typeof e.clone)return e.clone();if(r.isNumber(e)||i.isString(e)||o.isBoolean(e))return e;if(Array.isArray(e))return e.map(function(e){return a(e)});if(e instanceof Object){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=a(e[n])); -return e}throw new TypeError("Cannot clone "+e)},n.extend=function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},n.deepExtend=function s(e,t){for(var n in t)t.hasOwnProperty(n)&&(t[n]&&t[n].constructor===Object?(void 0===e[n]&&(e[n]={}),e[n].constructor===Object?s(e[n],t[n]):e[n]=t[n]):e[n]=t[n]);return e},n.deepEqual=function(e,t){var r,i,o;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!=t.length)return!1;for(i=0,o=e.length;o>i;i++)if(!n.deepEqual(e[i],t[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(r in e)if(e.hasOwnProperty(r)&&!n.deepEqual(e[r],t[r]))return!1;for(r in t)if(t.hasOwnProperty(r)&&!n.deepEqual(e[r],t[r]))return!1;return!0}return e==t}},{"./boolean":210,"./number":213,"./string":215}],215:[function(e,t,n){function r(e,t){if(Array.isArray(e)){for(var i="[",o=e.length,a=0;o>a;a++)0!=a&&(i+=", "),i+=r(e[a],t);return i+="]"}return n.format(e,t)}var i=e("./number"),o=e("bignumber.js");n.isString=function(e){return e instanceof String||"string"==typeof e},n.endsWith=function(e,t){var n=e.length-t.length,r=e.length;return e.substring(n,r)===t},n.format=function(e,t){return i.isNumber(e)||e instanceof o?i.format(e,t):Array.isArray(e)?r(e,t):n.isString(e)?'"'+e+'"':e instanceof Object?"function"==typeof e.format?e.format(t):e.toString():String(e)}},{"./number":213,"bignumber.js":217}],216:[function(e,t,n){n.type=function r(e){var r=typeof e;if("object"===r){if(null===e)return"null";if(e instanceof Boolean)return"boolean";if(e instanceof Number)return"number";if(e instanceof String)return"string";if(Array.isArray(e))return"array";if(e instanceof Date)return"date"}return r}},{}],217:[function(t,n){!function(t){"use strict";function r(e,t){var n,a,s,u,l,m,g=this;if(!(g instanceof r))return new r(e,t);if(e instanceof r){if(N=0,t===n)return g.s=e.s,g.e=e.e,g.c=(e=e.c)?e.slice():e,void 0;e+=""}if("string"!=typeof e&&(e=(s="number"==typeof e||"[object Number]"==Object.prototype.toString.call(e))&&0===e&&0>1/e?"-0":e+""),m=e,t===n&&M.test(e))g.s="-"==e.charAt(0)?(e=e.slice(1),-1):1;else{if(10==t)return c(e,p,h);if(e=j.call(e).replace(/^\+(?!-)/,""),g.s="-"==e.charAt(0)?(e=e.replace(/^-(?!-)/,""),-1):1,null!=t?t!=(0|t)&&b||(f=!(t>=2&&65>t))?(i(t,2),l=M.test(e)):(u="["+E.slice(0,t=0|t)+"]+",e=e.replace(/\.$/,"").replace(/^\./,"0."),(l=new RegExp("^"+u+"(?:\\."+u+")?$",37>t?"i":"").test(e))?(s&&(e.replace(/^0\.0*|\./,"").length>15&&i(m,0),s=!s),e=o(e,10,t,g.s)):"Infinity"!=e&&"NaN"!=e&&(i(m,1,t),e="NaN")):l=M.test(e),!l)return g.c=g.e=null,"Infinity"!=e&&("NaN"!=e&&i(m,3),g.s=null),N=0,void 0}for((n=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(0>n&&(n=a),n+=+e.slice(a+1),e=e.substring(0,a)):0>n&&(n=e.length),a=0;"0"==e.charAt(a);a++);if(t=e.length,s&&t>15&&e.slice(a).length>15&&i(m,0),N=0,(n-=a+1)>y)g.c=g.e=null;else if(a==t||d>n)g.c=[g.e=0];else{for(;"0"==e.charAt(--t););for(g.e=n,g.c=[],n=0;t>=a;g.c[n++]=+e.charAt(a++));}}function i(e,t,n,r,i,o){if(b){var a,s=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFr"][N?0>N?-N:N:0>1/N?1:0]+"()",u=f?" out of range":" not a"+(i?" non-zero":"n")+" integer";throw u=([s+" number type has more than 15 significant digits",s+" not a base "+n+" number",s+" base"+u,s+" not a number"][t]||n+"() "+t+(o?" not a boolean or binary digit":u+(r?" or not ["+(f?" negative, positive":" integer, integer")+" ]":"")))+": "+e,f=N=0,a=new Error(u),a.name="BigNumber Error",a}}function o(e,t,n,i){function o(e,r){var i,o,a=0,s=e.length,u=[0];for(r=r||n;s>a;a++){for(o=u.length,i=0;o>i;u[i]*=r,i++);for(u[0]+=E.indexOf(e.charAt(a)),i=0;it-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/t^0,u[i]%=t)}return u.reverse()}function s(e){for(var t=0,n=e.length,r="";n>t;r+=E.charAt(e[t++]));return r}var u,c,f,l,m,p;if(37>n&&(e=e.toLowerCase()),(u=e.indexOf("."))>-1)if(u=e.length-u-1,c=o(new r(n).pow(u).toF(),10),l=e.split("."),f=o(l[1]),l=o(l[0]),p=a(f,c,f.length-c.length,i,t,1&l[l.length-1]),m=p.c,u=p.e){for(;++u;m.unshift(0));e=s(l)+"."+s(m)}else m[0]?l[u=l.length-1]M?0:M;v++f;f++){if(s!=(v=b.length))l=s>v?1:-1;else for(m=-1,l=0;++mb[m]?1:-1;break}if(!(0>l))break;for(c=v==s?t:h;v;){if(b[--v]M&&u(w,p,o,a,null!=b[0]),w.e>y?w.c=w.e=null:w.e++t&&u(e,i,10),i=0==o[0]?i+1:n?t:e.e+i+1;o.length=i)?(e.s<0&&o[0]?"-":"")+(o.length>1?(o.splice(1,0,"."),o.join("")):o[0])+(0>i?"e":"e+")+i:e.toS()}function u(e,t,n,r,i){var o=e.c,a=e.s<0,s=n/2,u=e.e+t+1,c=o[u],f=i||0>u||null!=o[u+1];if(i=4>h?(null!=c||f)&&(0==h||2==h&&!a||3==h&&a):c>s||c==s&&(4==h||f||6==h&&(1&o[u-1]||!t&&r)||7==h&&!a||8==h&&a),1>u||!o[0])return o.length=0,o.push(0),i?(o[0]=1,e.e=-t):e.e=0,e;if(o.length=u--,i)for(--n;++o[u]>n;)o[u]=0,u--||(++e.e,o.unshift(1));for(u=o.length;!o[--u];o.pop());return e}function c(e,t,n){var i=h;return h=n,e=new r(e),e.c&&u(e,t,10),h=i,e}var f,l=1e9,m=1e6,p=20,h=4,g=-7,x=21,d=-l,y=l,b=!0,v=parseInt,w=r.prototype,E="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",N=0,M=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,j=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},C=r(1);r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.config=function(){var e,t,n=0,r={},o=arguments,a=o[0],s="config",u=function(e,t,n){return!((f=t>e||e>n)||v(e)!=e&&0!==e)},c=a&&"object"==typeof a?function(){return a.hasOwnProperty(t)?null!=(e=a[t]):void 0}:function(){return o.length>n?null!=(e=o[n++]):void 0};return c(t="DECIMAL_PLACES")&&(u(e,0,l)?p=0|e:i(e,t,s)),r[t]=p,c(t="ROUNDING_MODE")&&(u(e,0,8)?h=0|e:i(e,t,s)),r[t]=h,c(t="EXPONENTIAL_AT")&&(u(e,-l,l)?g=-(x=~~(0>e?-e:+e)):!f&&e&&u(e[0],-l,0)&&u(e[1],0,l)?(g=~~e[0],x=~~e[1]):i(e,t,s,1)),r[t]=[g,x],c(t="RANGE")&&(u(e,-l,l)&&~~e?d=-(y=~~(0>e?-e:+e)):!f&&e&&u(e[0],-l,-1)&&u(e[1],1,l)?(d=~~e[0],y=~~e[1]):i(e,t,s,1,1)),r[t]=[d,y],c(t="ERRORS")&&(e===!!e||1===e||0===e?(f=N=0,v=(b=!!e)?parseInt:parseFloat):i(e,t,s,0,0,1)),r[t]=b,r},w.abs=w.absoluteValue=function(){var e=new r(this);return e.s<0&&(e.s=1),e},w.ceil=function(){return c(this,0,2)},w.comparedTo=w.cmp=function(e,t){var n,i=this,o=i.c,a=(N=-N,e=new r(e,t)).c,s=i.s,u=e.s,c=i.e,f=e.e;if(!s||!u)return null;if(n=o&&!o[0],t=a&&!a[0],n||t)return n?t?0:-u:s;if(s!=u)return s;if(n=0>s,t=c==f,!o||!a)return t?0:!o^n?1:-1;if(!t)return c>f^n?1:-1;for(s=-1,u=(c=o.length)<(f=a.length)?c:f;++sa[s]^n?1:-1;return c==f?0:c>f^n?1:-1},w.dividedBy=w.div=function(e,t){var n=this.c,i=this.e,o=this.s,s=(N=2,e=new r(e,t)).c,u=e.e,c=e.s,f=o==c?1:-1;return(i||n&&n[0])&&(u||s&&s[0])?a(n,s,i-u,f,10):new r(o&&c&&(n?!s||n[0]!=s[0]:s)?n&&0==n[0]||!s?0*f:f/0:0/0)},w.equals=w.eq=function(e,t){return N=3,0===this.cmp(e,t)},w.floor=function(){return c(this,0,3)},w.greaterThan=w.gt=function(e,t){return N=4,this.cmp(e,t)>0},w.greaterThanOrEqualTo=w.gte=function(e,t){return N=5,1==(t=this.cmp(e,t))||0===t},w.isFinite=w.isF=function(){return!!this.c},w.isNaN=function(){return!this.s},w.isNegative=w.isNeg=function(){return this.s<0},w.isZero=w.isZ=function(){return!!this.c&&0==this.c[0]},w.lessThan=w.lt=function(e,t){return N=6,this.cmp(e,t)<0},w.lessThanOrEqualTo=w.lte=function(e,t){return N=7,-1==(t=this.cmp(e,t))||0===t},w.minus=function(e,t){var n,i,o,a,s=this,u=s.s;if(t=(N=8,e=new r(e,t)).s,!u||!t)return new r(0/0);if(u!=t)return e.s=-t,s.plus(e);var c=s.c,f=s.e,l=e.c,m=e.e;if(!f||!m){if(!c||!l)return c?(e.s=-t,e):new r(l?s:0/0);if(!c[0]||!l[0])return l[0]?(e.s=-t,e):new r(c[0]?s:3==h?-0:0)}if(c=c.slice(),u=f-m){for(n=(a=0>u)?(u=-u,c):(m=f,l),n.reverse(),t=u;t--;n.push(0));n.reverse()}else for(o=((a=c.lengtht;t++)if(c[t]!=l[t]){a=c[t]0)for(;t--;c[o++]=0);for(t=l.length;t>u;){if(c[--t]m||!c[0])&&(c[0]||(e.s=3==h?-1:1),c=[m=0]),e.c=c,e.e=m,e},w.modulo=w.mod=function(e,t){var n=this,i=n.c,o=(N=9,e=new r(e,t)).c,a=n.s,s=e.s;return t=!a||!s||o&&!o[0],t||i&&!i[0]?new r(t?0/0:n):(n.s=e.s=1,t=1==e.cmp(n),n.s=a,e.s=s,t?new r(n):(a=p,s=h,p=0,h=1,n=n.div(e),p=a,h=s,this.minus(n.times(e))))},w.negated=w.neg=function(){var e=new r(this);return e.s=-e.s||null,e},w.plus=function(e,t){var n,i=this,o=i.s;if(t=(N=10,e=new r(e,t)).s,!o||!t)return new r(0/0);if(o!=t)return e.s=-t,i.minus(e);var a=i.e,s=i.c,u=e.e,c=e.c;if(!a||!u){if(!s||!c)return new r(o/0);if(!s[0]||!c[0])return c[0]?e:new r(s[0]?i:0*o)}if(s=s.slice(),o=a-u){for(n=o>0?(u=a,c):(o=-o,s),n.reverse();o--;n.push(0));n.reverse()}for(s.length-c.length<0&&(n=c,c=s,s=n),o=c.length,t=0;o;t=(s[--o]=s[o]+c[o]+t)/10^0,s[o]%=10);for(t&&(s.unshift(t),++u>y&&(s=u=null)),o=s.length;0==s[--o];s.pop());return e.c=s,e.e=u,e},w.toPower=w.pow=function(e){var t=0*e==0?0|e:e,n=new r(this),o=new r(C);if(((f=-m>e||e>m)&&(t=1*e/0)||v(e)!=e&&0!==e&&!(t=0/0))&&!i(e,"exponent","pow")||!t)return new r(Math.pow(n.toS(),t));for(t=0>t?-t:t;1&t&&(o=o.times(n)),t>>=1,t;)n=n.times(n);return 0>e?C.div(o):o},w.round=function(e,t){return e=null==e||((f=0>e||e>l)||v(e)!=e)&&!i(e,"decimal places","round")?0:0|e,t=null==t||((f=0>t||t>8)||v(t)!=t&&0!==t)&&!i(t,"mode","round")?h:0|t,c(this,e,t)},w.squareRoot=w.sqrt=function(){var e,t,n,i,o=this,a=o.c,s=o.s,c=o.e,f=p,l=h,m=new r("0.5");if(1!==s||!a||!a[0])return new r(!s||0>s&&(!a||a[0])?0/0:a?o:1/0);for(s=Math.sqrt(o.toS()),h=1,0==s||s==1/0?(e=a.join(""),e.length+c&1||(e+="0"),t=new r(Math.sqrt(e)+""),t.c||(t.c=[1]),t.e=((c+1)/2|0)-(0>c||1&c)):t=new r(e=s.toString()),n=t.e,s=n+(p+=4),3>s&&(s=0),c=s;;)if(i=t,t=m.times(i.plus(o.div(i))),i.c.slice(0,s).join("")===t.c.slice(0,s).join("")){if(a=t.c,s-=e&&t.ec-2&&(a.length=c-2),t.times(t).eq(o)))){for(;a.length-1;s--){for(t=0,u=c+s;u>s;t=n[u]+a[s]*o[u-s-1]+t,n[u--]=t%10|0,t=t/10|0);t&&(n[u]=(n[u]+t)%10)}for(t&&++e.e,!n[0]&&n.shift(),u=n.length;!n[--u];n.pop());return e.c=e.e>y?e.e=null:e.ee||e>l)||v(e)!=e&&0!==e)&&!i(e,"decimal places","toE"))&&this.c?this.c.length-1:0|e,1)},w.toFixed=w.toF=function(e){var t,n,r,o=this;return null==e||((f=0>e||e>l)||v(e)!=e&&0!==e)&&!i(e,"decimal places","toF")||(r=o.e+(0|e)),t=g,e=x,g=-(x=1/0),r==n?n=o.toS():(n=s(o,r),o.s<0&&o.c&&(o.c[0]?n.indexOf("-")<0&&(n="-"+n):n=n.replace(/^-/,""))),g=t,x=e,n},w.toFraction=w.toFr=function(e){var t,n,o,a,s,u,c,l=a=new r(C),m=o=new r("0"),g=this,x=g.c,d=y,v=p,w=h,E=new r(C);if(!x)return g.toS();for(c=E.e=x.length-g.e-1,(null==e||(!(N=12,u=new r(e)).s||(f=u.cmp(l)<0||!u.c)||b&&u.e0)&&(e=c>0?E:l),y=1/0,u=new r(x.join("")),p=0,h=1;t=u.div(E),s=a.plus(t.times(m)),1!=s.cmp(e);)a=m,m=s,l=o.plus(t.times(s=l)),o=s,E=u.minus(t.times(s=E)),u=s;return s=e.minus(a).div(m),o=o.plus(s.times(l)),a=a.plus(s.times(m)),o.s=l.s=g.s,p=2*c,h=w,n=l.div(m).minus(g).abs().cmp(o.div(a).minus(g).abs())<1?[l.toS(),m.toS()]:[o.toS(),a.toS()],y=d,p=v,n},w.toPrecision=w.toP=function(e){return null==e||((f=1>e||e>l)||v(e)!=e)&&!i(e,"precision","toP")?this.toS():s(this,0|--e,2)},w.toString=w.toS=function(e){var t,n,r,a=this,u=a.e;if(null===u)n=a.s?"Infinity":"NaN";else{if(e===t&&(g>=u||u>=x))return s(a,a.c.length-1,1);if(n=a.c.join(""),0>u){for(;++u;n="0"+n);n="0."+n}else if(r=n.length,u>0)if(++u>r)for(u-=r;u--;n+="0");else r>u&&(n=n.slice(0,u)+"."+n.slice(u));else if(t=n.charAt(0),r>1)n=t+"."+n.slice(1);else if("0"==t)return t;if(null!=e)if((f=!(e>=2&&65>e))||e!=(0|e)&&b)i(e,"base","toS");else if(n=o(n,0|e,10,a.s),"0"==n)return n}return a.s<0?"-"+n:n},w.valueOf=function(){return this.toS()},"undefined"!=typeof n&&n.exports?n.exports=r:"function"==typeof e&&e.amd?e(function(){return r}):t.BigNumber=r}(this)},{}]},{},[1])(1)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var t=0;tn;++n)e.call(t||this,this[n],n,this)}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Array.prototype.map||(Array.prototype.map=function(e,t){var n,r,i;if(null==this)throw new TypeError(" this is null or not defined");var o=Object(this),a=o.length>>>0;if("function"!=typeof e)throw new TypeError(e+" is not a function");for(t&&(n=t),r=new Array(a),i=0;a>i;){var s,u;i in o&&(s=o[i],u=e.call(n,s,i,o),r[i]=u),i++}return r}),Array.prototype.every||(Array.prototype.every=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=arguments[1],i=0;n>i;i++)if(i in t&&!e.call(r,t[i],i,t))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e){"use strict";if(null==this)throw new TypeError;var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=arguments[1],i=0;n>i;i++)if(i in t&&e.call(r,t[i],i,t))return!0;return!1}),Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,r=function(){},i=function(){return n.apply(this instanceof r&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return r.prototype=this.prototype,i.prototype=new r,i}); \ No newline at end of file +!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.mathjs=e():"undefined"!=typeof global?global.mathjs=e():"undefined"!=typeof self&&(self.mathjs=e())}(function(){var e;return function n(e,t,r){function i(a,s){if(!t[a]){if(!e[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw new Error("Cannot find module '"+a+"'")}var c=t[a]={exports:{}};e[a][0].call(c.exports,function(n){var t=e[a][1][n];return i(t?t:n)},c,c.exports,n,e,t,r)}return t[a].exports}for(var o="function"==typeof require&&require,a=0;ar;r++)t[r].clear();this.clearCache()},clearCache:function(){this.cache={}}},t.context=[],n.exports=t},{"../type/Unit":207}],6:[function(e,n){n.exports={name:"Infinity",category:"Constants",syntax:["Infinity"],description:"Infinity, a number which is larger than the maximum number that can be handled by a floating point number.",examples:["Infinity","1 / 0"],seealso:[]}},{}],7:[function(e,n){n.exports={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]}},{}],8:[function(e,n){n.exports={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]}},{}],9:[function(e,n){n.exports={name:"LOG10E",category:"Constants",syntax:["LOG10E"],description:"Returns the base-10 logarithm of E, approximately equal to 0.434",examples:["LOG10E","log(e, 10)"],seealso:[]}},{}],10:[function(e,n){n.exports={name:"LOG2E",category:"Constants",syntax:["LOG2E"],description:"Returns the base-2 logarithm of E, approximately equal to 1.442",examples:["LOG2E","log(e, 2)"],seealso:[]}},{}],11:[function(e,n){n.exports={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]}},{}],12:[function(e,n){n.exports={name:"SQRT1_2",category:"Constants",syntax:["SQRT1_2"],description:"Returns the square root of 1/2, approximately equal to 0.707",examples:["SQRT1_2","sqrt(1/2)"],seealso:[]}},{}],13:[function(e,n){n.exports={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]}},{}],14:[function(e,n){n.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"]}},{}],15:[function(e,n){n.exports={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]}},{}],16:[function(e,n){n.exports={name:"i",category:"Constants",syntax:["i"],description:"Imaginary unit, defined as i*i=-1. A complex number is described as a + b*i, where a is the real part, and b is the imaginary part.",examples:["i","i * i","sqrt(-1)"],seealso:[]}},{}],17:[function(e,n){n.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"]}},{}],18:[function(e,n){n.exports={name:"tau",category:"Constants",syntax:["pi"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]}},{}],19:[function(e,n){n.exports={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]}},{}],20:[function(e,n){n.exports={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]}},{}],21:[function(e,n){n.exports={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["2.1 + 3.6","ans - 3.6","3 + 2i",'"hello" + " world"',"3 cm + 2 inch"],seealso:["subtract"]}},{}],22:[function(e,n){n.exports={name:"ceil",category:"Arithmetic",syntax:["ceil(x)"],description:"Round a value towards plus infinity.If x is complex, both real and imaginary part are rounded towards plus infinity.",examples:["ceil(3.2)","ceil(3.8)","ceil(-4.2)"],seealso:["floor","fix","round"]}},{}],23:[function(e,n){n.exports={name:"cube",category:"Arithmetic",syntax:["cube(x)"],description:"Compute the cube of a value. The cube of x is x * x * x.",examples:["cube(2)","2^3","2 * 2 * 2"],seealso:["multiply","square","pow"]}},{}],24:[function(e,n){n.exports={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["2 / 3","ans * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]}},{}],25:[function(e,n){n.exports={name:"edivide",category:"Operators",syntax:["x ./ y","edivide(x, y)"],description:"divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","emultiply","divide"]}},{}],26:[function(e,n){n.exports={name:"emultiply",category:"Operators",syntax:["x .* y","emultiply(x, y)"],description:"multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","edivide"]}},{}],27:[function(e,n){n.exports={name:"epow",category:"Operators",syntax:["x .^ y","epow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]}},{}],28:[function(e,n){n.exports={name:"equal",category:"Operators",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns 1 if the values are equal, and 0 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"]}},{}],29:[function(e,n){n.exports={name:"exp",category:"Arithmetic",syntax:["exp(x)"],description:"Calculate the exponent of a value.",examples:["exp(1.3)","e ^ 1.3","log(exp(1.3))","x = 2.4","(exp(i*x) == cos(x) + i*sin(x)) # Euler's formula"],seealso:["square","multiply","log"]}},{}],30:[function(e,n){n.exports={name:"fix",category:"Arithmetic",syntax:["fix(x)"],description:"Round a value towards zero.If x is complex, both real and imaginary part are rounded towards zero.",examples:["fix(3.2)","fix(3.8)","fix(-4.2)","fix(-4.8)"],seealso:["ceil","floor","round"]}},{}],31:[function(e,n){n.exports={name:"floor",category:"Arithmetic",syntax:["floor(x)"],description:"Round a value towards minus infinity.If x is complex, both real and imaginary part are rounded towards minus infinity.",examples:["floor(3.2)","floor(3.8)","floor(-4.2)"],seealso:["ceil","fix","round"]}},{}],32:[function(e,n){n.exports={name:"gcd",category:"Arithmetic",syntax:["gcd(a, b)","gcd(a, b, c, ...)"],description:"Compute the greatest common divisor.",examples:["gcd(8, 12)","gcd(-4, 6)","gcd(25, 15, -10)"],seealso:["lcm","xgcd"]}},{}],33:[function(e,n){n.exports={name:"larger",category:"Operators",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns 1 if x is larger than y, and 0 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"]}},{}],34:[function(e,n){n.exports={name:"largereq",category:"Operators",syntax:["x >= y","largereq(x, y)"],description:"Check if value x is larger or equal to y. Returns 1 if x is larger or equal to y, and 0 if not.",examples:["2 > 1+1","2 >= 1+1","a = 3.2","b = 6-2.8","(a > b)"],seealso:["equal","unequal","smallereq","smaller","largereq"]}},{}],35:[function(e,n){n.exports={name:"lcm",category:"Arithmetic",syntax:["lcm(x, y)"],description:"Compute the least common multiple.",examples:["lcm(4, 6)","lcm(6, 21)","lcm(6, 21, 5)"],seealso:["gcd"]}},{}],36:[function(e,n){n.exports={name:"log",category:"Arithmetic",syntax:["log(x)","log(x, base)"],description:"Compute the logarithm of a value. If no base is provided, the natural logarithm of x is calculated. If base if provided, the logarithm is calculated for the specified base. log(x, base) is defined as log(x) / log(base).",examples:["log(3.5)","a = log(2.4)","exp(a)","10 ^ 3","log(1000, 10)","log(1000) / log(10)","b = logb(1024, 2)","2 ^ b"],seealso:["exp","log10"]}},{}],37:[function(e,n){n.exports={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(1000)","10 ^ 3","log10(0.01)","log(1000) / log(10)","log(1000, 10)"],seealso:["exp","log"]}},{}],38:[function(e,n){n.exports={name:"mod",category:"Operators",syntax:["x % y","x mod y","mod(x, y)"],description:"Calculates the modulus, the remainder of an integer division.",examples:["7 % 3","11 % 2","10 mod 4","function isOdd(x) = x % 2","isOdd(2)","isOdd(3)"],seealso:[]}},{}],39:[function(e,n){n.exports={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["2.1 * 3.6","ans / 3.6","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]}},{}],40:[function(e,n){n.exports={name:"pow",category:"Operators",syntax:["x ^ y","pow(x, y)"],description:"Calculates the power of x to y, x^y.",examples:["2^3 = 8","2*2*2","1 + e ^ (pi * i)"],seealso:["unequal","smaller","larger","smallereq","largereq"]}},{}],41:[function(e,n){n.exports={name:"round",category:"Arithmetic",syntax:["round(x)","round(x, n)"],description:"round a value towards the nearest integer.If x is complex, both real and imaginary part are rounded towards the nearest integer. When n is specified, the value is rounded to n decimals.",examples:["round(3.2)","round(3.8)","round(-4.2)","round(-4.8)","round(pi, 3)","round(123.45678, 2)"],seealso:["ceil","floor","fix"]}},{}],42:[function(e,n){n.exports={name:"sign",category:"Arithmetic",syntax:["sign(x)"],description:"Compute the sign of a value. The sign of a value x is 1 when x>1, -1 when x<0, and 0 when x=0.",examples:["sign(3.5)","sign(-4.2)","sign(0)"],seealso:["abs"]}},{}],43:[function(e,n){n.exports={name:"smaller",category:"Operators",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns 1 if x is smaller than y, and 0 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"]}},{}],44:[function(e,n){n.exports={name:"smallereq",category:"Operators",syntax:["x <= y","smallereq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns 1 if x is smaller than y, and 0 if not.",examples:["2 < 1+1","2 <= 1+1","a = 3.2","b = 6-2.8","(a < b)"],seealso:["equal","unequal","larger","smaller","largereq"]}},{}],45:[function(e,n){n.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"]}},{}],46:[function(e,n){n.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"]}},{}],47:[function(e,n){n.exports={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["5.3 - 2","ans + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]}},{}],48:[function(e,n){n.exports={name:"unary",category:"Operators",syntax:["-x","unary(x)"],description:"Inverse the sign of a value.",examples:["-4.5","-(-5.6)"],seealso:["add","subtract"]}},{}],49:[function(e,n){n.exports={name:"unequal",category:"Operators",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns 1 if the values are unequal, and 0 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"]}},{}],50:[function(e,n){n.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"]}},{}],51:[function(e,n){n.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"]}},{}],52:[function(e,n){n.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"]}},{}],53:[function(e,n){n.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"]}},{}],54:[function(e,n){n.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"]}},{}],55:[function(e,n){n.exports={name:"bignumber",category:"Type",syntax:["bignumber(x)"],description:"Create a big number from a number or string.",examples:["0.1 + 0.2","bignumber(0.1) + bignumber(0.2)",'bignumber("7.2")','bignumber("7.2e500")',"bignumber([0.1, 0.2, 0.3])"],seealso:["boolean","complex","index","matrix","string","unit"]}},{}],56:[function(e,n){n.exports={name:"boolean",category:"Type",syntax:["x","boolean(x)"],description:"Convert a string or number into a boolean.",examples:["boolean(0)","boolean(1)","boolean(3)",'boolean("true")','boolean("false")',"boolean([1, 0, 1, 1])"],seealso:["bignumber","complex","index","matrix","number","string","unit"]}},{}],57:[function(e,n){n.exports={name:"complex",category:"Type",syntax:["complex()","complex(re, im)","complex(string)"],description:"Create a complex number.",examples:["complex()","complex(2, 3)",'complex("7 - 2i")'],seealso:["bignumber","boolean","index","matrix","number","string","unit"]}},{}],58:[function(e,n){n.exports={name:"index",category:"Type",syntax:["[start]","[start:end]","[start:step:end]","[start1, start 2, ...]","[start1:end1, start2:end2, ...]","[start1:step1:end1, start2:step2:end2, ...]"],description:"Create an index to get or replace a subset of a matrix",examples:["[]","[1, 2, 3]","A = [1, 2, 3; 4, 5, 6]","A[1, :]","A[1, 2] = 50","A[0:2, 0:2] = ones(2, 2)"],seealso:["bignumber","boolean","complex","matrix,","number","range","string","unit"]}},{}],59:[function(e,n){n.exports={name:"matrix",category:"Type",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()","matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])"],seealso:["bignumber","boolean","complex","index","number","string","unit"]}},{}],60:[function(e,n){n.exports={name:"number",category:"Type",syntax:["x","number(x)"],description:"Create a number or convert a string or boolean into a number.",examples:["2","2e3","4.05","number(2)",'number("7.2")',"number(true)","number([true, false, true, true])"],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]}},{}],61:[function(e,n){n.exports={name:"string",category:"Type",syntax:['"text"',"string(x)"],description:"Create a string or convert a value to a string",examples:['"Hello World!"',"string(4.2)","string(3 + 2i)"],seealso:["bignumber","boolean","complex","index","matrix","number","unit"]}},{}],62:[function(e,n){n.exports={name:"unit",category:"Type",syntax:["value unit","unit(value, unit)","unit(string)"],description:"Create a unit.",examples:["5.5 mm","3 inch",'unit(7.1, "kilogram")','unit("23 deg")'],seealso:["bignumber","boolean","complex","index","matrix","number","string"]}},{}],63:[function(e,n){n.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:[]}},{}],64:[function(e,n){n.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:[]}},{}],65:[function(e,n){n.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 first 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)","[a, b]","concat(a, b, 2)","[a; b]"],seealso:["det","diag","eye","inv","ones","range","size","squeeze","subset","transpose","zeros"]}},{}],66:[function(e,n){n.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","transpose","zeros"]}},{}],67:[function(e,n){n.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","transpose","zeros"]}},{}],68:[function(e,n){n.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","transpose","zeros"]}},{}],69:[function(e,n){n.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","transpose","zeros"]}},{}],70:[function(e,n){n.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","transpose","zeros"]}},{}],71:[function(e,n){n.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","transpose","zeros"]}},{}],72:[function(e,n){n.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], 0)","resize(2, [2, 3], 0)",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze"]}},{}],73:[function(e,n){n.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","transpose","zeros"]}},{}],74:[function(e,n){n.exports={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove singleton dimensions from a matrix.",examples:["a = zeros(1,3,2)","size(squeeze(a))","b = zeros(3,1,1)","size(squeeze(b))"],seealso:["concat","det","diag","eye","inv","ones","range","size","subset","transpose","zeros"]}},{}],75:[function(e,n){n.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","transpose","zeros"]}},{}],76:[function(e,n){n.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","zeros"]}},{}],77:[function(e,n){n.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","transpose"]}},{}],78:[function(e,n){n.exports={name:"distribution",category:"Probability",syntax:["distribution(name)","distribution(name, arg1, arg2, ...)"],description:'Create a distribution object of a specific type. A distribution object contains functions `random([size,] [min,] [max])`, `randomInt([size,] [min,] [max])`, and `pickRandom(array)`. Available types of distributions: "uniform", "normal". Note that the function distribution is currently not available via the expression parser.',examples:[],seealso:["random","randomInt"]}},{}],79:[function(e,n){n.exports={name:"factorial",category:"Probability",syntax:["x!","factorial(x)"],description:"Compute the factorial of a value",examples:["5!","5*4*3*2*1","3!"],seealso:[]}},{}],80:[function(e,n){n.exports={name:"pickRandom",category:"Probability",syntax:["pickRandom(array)"],description:"Pick a random entry from a given array.",examples:["pickRandom(0:10)","pickRandom([1, 3, 1, 6])"],seealso:["distribution","random","randomInt"]}},{}],81:[function(e,n){n.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:["distribution","pickRandom","randomInt"]}},{}],82:[function(e,n){n.exports={name:"randInt",category:"Probability",syntax:["randInt()","randInt(max)","randInt(min, max)","randInt(size)","randInt(size, max)","randInt(size, min, max)"],description:"Return a random integer number",examples:["randInt()","randInt(10, 20)","randInt([2, 3], 10)"],seealso:["distribution","pickRandom","random"]}},{}],83:[function(e,n){n.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], 0)","max([2, 5; 4, 3], 1)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","min"]}},{}],84:[function(e,n){n.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], 0)","mean([2, 5; 4, 3], 1)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","min"]}},{}],85:[function(e,n){n.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], 0)","min([2, 5; 4, 3], 1)","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","min"]}},{}],86:[function(e,n){n.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","acos","asin"]}},{}],87:[function(e,n){n.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","asin"]}},{}],88:[function(e,n){n.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"]}},{}],89:[function(e,n){n.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"]}},{}],90:[function(e,n){n.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"]}},{}],91:[function(e,n){n.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"]}},{}],92:[function(e,n){n.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"]}},{}],93:[function(e,n){n.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"]}},{}],94:[function(e,n){n.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"]}},{}],95:[function(e,n){n.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"]}},{}],96:[function(e,n){n.exports={name:"in",category:"Units",syntax:["x in unit","in(x, unit)"],description:"Change the unit of a value.",examples:["5 inch in cm","3.2kg in g","16 bytes in bits"],seealso:[]}},{}],97:[function(e,n){n.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:[]}},{}],98:[function(e,n){n.exports={name:"forEach",category:"Utils",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:[]}},{}],99:[function(e,n){n.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"]}},{}],100:[function(e,n){n.exports={name:"import",category:"Utils",syntax:["import(string)"],description:"Import functions from a file.",examples:['import("numbers")','import("./mylib.js")'],seealso:[]}},{}],101:[function(e,n){n.exports={name:"map",category:"Utils",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 math.max(val, 1.5) })"],seealso:[]}},{}],102:[function(e,n){n.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:[]}},{}],103:[function(e,n,t){t.e=e("./constants/e"),t.E=e("./constants/e"),t["false"]=e("./constants/false"),t.i=e("./constants/i"),t.Infinity=e("./constants/Infinity"),t.LN2=e("./constants/LN2"),t.LN10=e("./constants/LN10"),t.LOG2E=e("./constants/LOG2E"),t.LOG10E=e("./constants/LOG10E"),t.NaN=e("./constants/NaN"),t.pi=e("./constants/pi"),t.PI=e("./constants/pi"),t.SQRT1_2=e("./constants/SQRT1_2"),t.SQRT2=e("./constants/SQRT2"),t.tau=e("./constants/tau"),t["true"]=e("./constants/true"),t.abs=e("./function/arithmetic/abs"),t.add=e("./function/arithmetic/add"),t.ceil=e("./function/arithmetic/ceil"),t.cube=e("./function/arithmetic/cube"),t.divide=e("./function/arithmetic/divide"),t.edivide=e("./function/arithmetic/edivide"),t.emultiply=e("./function/arithmetic/emultiply"),t.epow=e("./function/arithmetic/epow"),t.equal=e("./function/arithmetic/equal"),t.exp=e("./function/arithmetic/exp"),t.fix=e("./function/arithmetic/fix"),t.floor=e("./function/arithmetic/floor"),t.gcd=e("./function/arithmetic/gcd"),t.larger=e("./function/arithmetic/larger"),t.largereq=e("./function/arithmetic/largereq"),t.lcm=e("./function/arithmetic/lcm"),t.log=e("./function/arithmetic/log"),t.log10=e("./function/arithmetic/log10"),t.mod=e("./function/arithmetic/mod"),t.multiply=e("./function/arithmetic/multiply"),t.pow=e("./function/arithmetic/pow"),t.round=e("./function/arithmetic/round"),t.sign=e("./function/arithmetic/sign"),t.smaller=e("./function/arithmetic/smaller"),t.smallereq=e("./function/arithmetic/smallereq"),t.sqrt=e("./function/arithmetic/sqrt"),t.square=e("./function/arithmetic/square"),t.subtract=e("./function/arithmetic/subtract"),t.unary=e("./function/arithmetic/unary"),t.unequal=e("./function/arithmetic/unequal"),t.xgcd=e("./function/arithmetic/xgcd"),t.arg=e("./function/complex/arg"),t.conj=e("./function/complex/conj"),t.re=e("./function/complex/re"),t.im=e("./function/complex/im"),t.bignumber=e("./function/construction/bignumber"),t.boolean=e("./function/construction/boolean"),t.complex=e("./function/construction/complex"),t.index=e("./function/construction/index"),t.matrix=e("./function/construction/matrix"),t.number=e("./function/construction/number"),t.string=e("./function/construction/string"),t.unit=e("./function/construction/unit"),t.eval=e("./function/expression/eval"),t.help=e("./function/expression/help"),t.concat=e("./function/matrix/concat"),t.det=e("./function/matrix/det"),t.diag=e("./function/matrix/diag"),t.eye=e("./function/matrix/eye"),t.inv=e("./function/matrix/inv"),t.ones=e("./function/matrix/ones"),t.range=e("./function/matrix/range"),t.resize=e("./function/matrix/resize"),t.size=e("./function/matrix/size"),t.squeeze=e("./function/matrix/squeeze"),t.subset=e("./function/matrix/subset"),t.transpose=e("./function/matrix/transpose"),t.zeros=e("./function/matrix/zeros"),t.factorial=e("./function/probability/factorial"),t.distribution=e("./function/probability/distribution"),t.pickRandom=e("./function/probability/pickRandom"),t.random=e("./function/probability/random"),t.randomInt=e("./function/probability/randomInt"),t.min=e("./function/statistics/min"),t.mean=e("./function/statistics/mean"),t.max=e("./function/statistics/max"),t.acos=e("./function/trigonometry/acos"),t.asin=e("./function/trigonometry/asin"),t.atan=e("./function/trigonometry/atan"),t.atan2=e("./function/trigonometry/atan2"),t.cos=e("./function/trigonometry/cos"),t.cot=e("./function/trigonometry/cot"),t.csc=e("./function/trigonometry/csc"),t.sec=e("./function/trigonometry/sec"),t.sin=e("./function/trigonometry/sin"),t.tan=e("./function/trigonometry/tan"),t["in"]=e("./function/units/in"),t.clone=e("./function/utils/clone"),t.map=e("./function/utils/map"),t.forEach=e("./function/utils/forEach"),t.format=e("./function/utils/format"),t["import"]=e("./function/utils/import"),t["typeof"]=e("./function/utils/typeof") +},{"./constants/Infinity":6,"./constants/LN10":7,"./constants/LN2":8,"./constants/LOG10E":9,"./constants/LOG2E":10,"./constants/NaN":11,"./constants/SQRT1_2":12,"./constants/SQRT2":13,"./constants/e":14,"./constants/false":15,"./constants/i":16,"./constants/pi":17,"./constants/tau":18,"./constants/true":19,"./function/arithmetic/abs":20,"./function/arithmetic/add":21,"./function/arithmetic/ceil":22,"./function/arithmetic/cube":23,"./function/arithmetic/divide":24,"./function/arithmetic/edivide":25,"./function/arithmetic/emultiply":26,"./function/arithmetic/epow":27,"./function/arithmetic/equal":28,"./function/arithmetic/exp":29,"./function/arithmetic/fix":30,"./function/arithmetic/floor":31,"./function/arithmetic/gcd":32,"./function/arithmetic/larger":33,"./function/arithmetic/largereq":34,"./function/arithmetic/lcm":35,"./function/arithmetic/log":36,"./function/arithmetic/log10":37,"./function/arithmetic/mod":38,"./function/arithmetic/multiply":39,"./function/arithmetic/pow":40,"./function/arithmetic/round":41,"./function/arithmetic/sign":42,"./function/arithmetic/smaller":43,"./function/arithmetic/smallereq":44,"./function/arithmetic/sqrt":45,"./function/arithmetic/square":46,"./function/arithmetic/subtract":47,"./function/arithmetic/unary":48,"./function/arithmetic/unequal":49,"./function/arithmetic/xgcd":50,"./function/complex/arg":51,"./function/complex/conj":52,"./function/complex/im":53,"./function/complex/re":54,"./function/construction/bignumber":55,"./function/construction/boolean":56,"./function/construction/complex":57,"./function/construction/index":58,"./function/construction/matrix":59,"./function/construction/number":60,"./function/construction/string":61,"./function/construction/unit":62,"./function/expression/eval":63,"./function/expression/help":64,"./function/matrix/concat":65,"./function/matrix/det":66,"./function/matrix/diag":67,"./function/matrix/eye":68,"./function/matrix/inv":69,"./function/matrix/ones":70,"./function/matrix/range":71,"./function/matrix/resize":72,"./function/matrix/size":73,"./function/matrix/squeeze":74,"./function/matrix/subset":75,"./function/matrix/transpose":76,"./function/matrix/zeros":77,"./function/probability/distribution":78,"./function/probability/factorial":79,"./function/probability/pickRandom":80,"./function/probability/random":81,"./function/probability/randomInt":82,"./function/statistics/max":83,"./function/statistics/mean":84,"./function/statistics/min":85,"./function/trigonometry/acos":86,"./function/trigonometry/asin":87,"./function/trigonometry/atan":88,"./function/trigonometry/atan2":89,"./function/trigonometry/cos":90,"./function/trigonometry/cot":91,"./function/trigonometry/csc":92,"./function/trigonometry/sec":93,"./function/trigonometry/sin":94,"./function/trigonometry/tan":95,"./function/units/in":96,"./function/utils/clone":97,"./function/utils/forEach":98,"./function/utils/format":99,"./function/utils/import":100,"./function/utils/map":101,"./function/utils/typeof":102}],104:[function(e,n){function t(e,n){this.settings=e,this.nodes=n||[]}var r=e("./Node"),i=(e("../../util/object"),e("../../util/string")),o=(e("../../type/collection"),e("../../type/Matrix"));t.prototype=new r,t.prototype.eval=function(){for(var e=this.nodes,n=[],t=0,r=e.length;r>t;t++){var i=e[t],a=i.eval();n[t]=a instanceof o?a.valueOf():a}return"array"===this.settings.matrix.defaultType?n:new o(n)},t.prototype.find=function(e){var n=[];this.match(e)&&n.push(this);for(var t=this.nodes,r=0,i=t.length;i>r;r++)for(var o=t[r],a=0,s=o.length;s>a;a++)n=n.concat(o[a].find(e));return n},t.prototype.toString=function(){return i.format(this.nodes)},n.exports=t},{"../../type/Matrix":205,"../../type/collection":208,"../../util/object":214,"../../util/string":215,"./Node":109}],105:[function(e,n){function t(e,n,t){this.name=e,this.expr=n,this.scope=t}var r=e("./Node");t.prototype=new r,t.prototype.eval=function(){if(void 0===this.expr)throw new Error("Undefined symbol "+this.name);var e=this.expr.eval();return this.scope.set(this.name,e),e},t.prototype.find=function(e){var n=[];return this.match(e)&&n.push(this),this.expr&&(n=n.concat(this.expr.find(e))),n},t.prototype.toString=function(){return this.name+" = "+this.expr.toString()},n.exports=t},{"./Node":109}],106:[function(e,n){function t(){this.params=[],this.visible=[]}var r=e("./Node");t.prototype=new r,t.prototype.add=function(e,n){var t=this.params.length;this.params[t]=e,this.visible[t]=void 0!=n?n:!0},t.prototype.eval=function(){for(var e=[],n=0,t=this.params.length;t>n;n++){var r=this.params[n].eval();this.visible[n]&&e.push(r)}return e},t.prototype.find=function(e){var n=[];this.match(e)&&n.push(this);var t=this.params;if(t)for(var r=0,i=t.length;i>r;r++)n=n.concat(t[r].find(e));return n},t.prototype.toString=function(){for(var e=[],n=0,t=this.params.length;t>n;n++)this.visible[n]&&e.push("\n "+this.params[n].toString());return"["+e.join(",")+"\n]"},n.exports=t},{"./Node":109}],107:[function(e,n){function t(e){this.value=e}var r=e("./Node"),i=e("../../util/string");t.prototype=new r,t.prototype.eval=function(){return this.value},t.prototype.toString=function(){return i.format(this.value)},n.exports=t},{"../../util/string":215,"./Node":109}],108:[function(e,n){function t(e,n,t,r,i){this.name=e,this.variables=n,this.expr=t,this.scope=i,this.fn=function(){var i=n?n.length:0;if(arguments.length!=i)throw new SyntaxError("Wrong number of arguments in function "+e+" ("+arguments.length+" provided, "+i+" expected)");for(var o=0;i>o;o++)r.set(n[o],arguments[o]);return t.eval()},this.fn.toString=function(){return e+"("+n.join(", ")+")"}}var r=e("./Node");t.prototype=new r,t.prototype.eval=function(){return this.scope.set(this.name,this.fn),this.fn},t.prototype.find=function(e){var n=[];return this.match(e)&&n.push(this),this.expr&&(n=n.concat(this.expr.find(e))),n},t.prototype.toString=function(){return this.fn.toString()},n.exports=t},{"./Node":109}],109:[function(e,n){function t(){}t.prototype.eval=function(){throw new Error("Cannot evaluate a Node interface")},t.prototype.find=function(e){return this.match(e)?[this]:[]},t.prototype.match=function(e){var n=!0;if(e&&(!e.type||this instanceof e.type||(n=!1),n&&e.properties))for(var t in e.properties)if(e.properties.hasOwnProperty(t)&&this[t]!=e.properties[t]){n=!1;break}return n},t.prototype.toString=function(){return""},n.exports=t},{}],110:[function(e,n){function t(e,n,t){this.name=e,this.fn=n,this.params=t}var r=e("./Node");t.prototype=new r,t.prototype.eval=function(){return this.fn.apply(this,this.params.map(function(e){return e.eval()}))},t.prototype.find=function(e){var n=[];this.match(e)&&n.push(this);var t=this.params;if(t)for(var r=0,i=t.length;i>r;r++)n=n.concat(t[r].find(e));return n},t.prototype.toString=function(){var e=this.params;switch(e.length){case 1:return"-"==this.name?"-"+e[0].toString():e[0].toString()+this.name;case 2:var n=e[0].toString();e[0]instanceof t&&(n="("+n+")");var r=e[1].toString();return e[1]instanceof t&&(r="("+r+")"),n+" "+this.name+" "+r;default:return this.name+"("+this.params.join(", ")+")"}},n.exports=t},{"./Node":109}],111:[function(e,n){function t(e,n,t,r){if(this.math=e,this.object=n,this.params=t,this.paramScopes=r,this.hasContextParams=!1,t)for(var i={type:a,properties:{name:"end"}},o=0,s=t.length;s>o;o++)if(t[o].find(i).length>0){this.hasContextParams=!0;break}}var r=e("../../util/number"),i=e("./Node"),o=e("./RangeNode"),a=e("./SymbolNode"),s=e("bignumber.js"),u=e("../../type/Index"),c=e("../../type/Range"),f=r.isNumber,l=r.toNumber;t.prototype=new i,t.prototype.eval=function(){var e,n,t,r,i=this.object;if(void 0==i)throw new Error("Node undefined");var a=i.eval();if(this.hasContextParams&&"function"!=typeof a){var m=this.paramScopes,p=this.math.size(a).valueOf();if(m&&p)for(e=0,n=this.params.length;n>e;e++){var h=m[e];h&&h.set("end",p[e])}}if("function"==typeof a){for(t=this.params,r=[],e=0,n=this.params.length;n>e;e++)r[e]=t[e].eval();return a.apply(this,r)}for(t=this.params,r=[],e=0,n=this.params.length;n>e;e++){var g,x=t[e];if(g=x instanceof o?x.toRange():x.eval(),g instanceof s&&(g=l(g)),g instanceof c)g.start--,g.end--;else{if(!f(g))throw new TypeError("Number or Range expected");g--}r[e]=g}var d=u.create(r);return this.math.subset(a,d)},t.prototype.find=function(e){var n=[];this.match(e)&&n.push(this),this.object&&(n=n.concat(this.object.find(e)));var t=this.params;if(t)for(var r=0,i=t.length;i>r;r++)n=n.concat(t[r].find(e));return n},t.prototype.toString=function(){var e=this.object?this.object.toString():"";return this.params&&(e+="("+this.params.join(", ")+")"),e},n.exports=t},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113,"bignumber.js":217}],112:[function(e,n){function t(e,n,t){if(this.math=e,this.settings=n,this.start=null,this.end=null,this.step=null,2==t.length)this.start=t[0],this.end=t[1];else{if(3!=t.length)throw new SyntaxError("Wrong number of arguments");this.start=t[0],this.step=t[1],this.end=t[2]}}var r=e("../../util/number"),i=e("./Node"),o=e("bignumber.js"),a=e("../../type/Range"),s=e("../../type/Matrix"),u=r.toNumber;t.prototype=new i,t.prototype.eval=function(){var e=this._evalParams(),n=e.start,t=e.step,r=e.end,i=[],o=n;if(t>0)for(;r>=o;)i.push(o),o+=t;else if(0>t)for(;o>=r;)i.push(o),o+=t;return"array"===this.settings.matrix.defaultType?i:new s(i)},t.prototype.toRange=function(){var e=this._evalParams(),n=e.start,t=e.step,r=e.end;return r=this.math.add(r,t>0?1:-1),new a(n,r,t)},t.prototype._evalParams=function(){var e=this.start.eval(),n=this.end.eval(),t=this.step?this.step.eval():1;if(e instanceof o&&(e=u(e)),n instanceof o&&(n=u(n)),t instanceof o&&(t=u(t)),!r.isNumber(e))throw new TypeError("Parameter start must be a number");if(!r.isNumber(n))throw new TypeError("Parameter end must be a number");if(!r.isNumber(t))throw new TypeError("Parameter step must be a number");return{start:e,end:n,step:t}},t.prototype.find=function(e){var n=[];return this.match(e)&&n.push(this),this.start&&(n=n.concat(this.start.find(e))),this.step&&(n=n.concat(this.step.find(e))),this.end&&(n=n.concat(this.end.find(e))),n},t.prototype.toString=function(){var e=this.start.toString();return this.step&&(e+=":"+this.step.toString()),e+=":"+this.end.toString()},n.exports=t},{"../../type/Matrix":205,"../../type/Range":206,"../../util/number":213,"./Node":109,"bignumber.js":217}],113:[function(e,n){function t(e,n){this.name=e,this.scope=n}var r=e("./Node");t.prototype=new r,t.prototype.eval=function(){var e=this.scope.get(this.name);if(void 0===e)throw new Error("Undefined symbol "+this.name);return e},t.prototype.toString=function(){return this.name},n.exports=t},{"./Node":109}],114:[function(e,n){function t(e,n,t,r,i,o){this.math=e,this.name=n,this.params=t,this.paramScopes=r,this.expr=i,this.scope=o,this.hasContextParams=!1;for(var s={type:a,properties:{name:"end"}},u=0,c=t.length;c>u;u++)if(t[u].find(s).length>0){this.hasContextParams=!0;break}}var r=e("../../util/number"),i=e("./Node"),o=e("./RangeNode"),a=e("./SymbolNode"),s=e("bignumber.js"),u=e("../../type/Index"),c=e("../../type/Range"),f=r.isNumber,l=r.toNumber;t.prototype=new i,t.prototype.eval=function(){if(void 0===this.expr)throw new Error("Undefined symbol "+this.name);var e,n=this.scope.get(this.name);if(void 0==n)throw new Error("Undefined symbol "+this.name);if(this.hasContextParams&&"function"!=typeof n){var t=this.paramScopes,r=this.math.size(n).valueOf();if(t&&r)for(var i=0,a=this.params.length;a>i;i++){var m=t[i];m&&m.set("end",r[i])}}var p=[];this.params.forEach(function(e){var n;if(n=e instanceof o?e.toRange():e.eval(),n instanceof s&&(n=l(n)),n instanceof c)n.start--,n.end--;else{if(!f(n))throw new TypeError("Number or Range expected");n--}p.push(n)});var h=this.expr.eval(),g=u.create(p);return e=this.math.subset(n,g,h),this.scope.set(this.name,e),e},t.prototype.find=function(e){var n=[];this.match(e)&&n.push(this);var t=this.params;if(t)for(var r=0,i=t.length;i>r;r++)n=n.concat(t[r].find(e));return this.expr&&(n=n.concat(this.expr.find(e))),n},t.prototype.toString=function(){var e="";return e+=this.name,this.params&&this.params.length&&(e+="("+this.params.join(", ")+")"),e+=" = ",e+=this.expr.toString()},n.exports=t},{"../../type/Index":204,"../../type/Range":206,"../../util/number":213,"./Node":109,"./RangeNode":112,"./SymbolNode":113,"bignumber.js":217}],115:[function(){},{}],116:[function(e,n,t){t.AssignmentNode=e("./AssignmentNode"),t.BlockNode=e("./BlockNode"),t.ConstantNode=e("./ConstantNode"),t.FunctionNode=e("./FunctionNode"),t.ArrayNode=e("./ArrayNode"),t.Node=e("./Node"),t.OperatorNode=e("./OperatorNode"),t.ParamsNode=e("./ParamsNode"),t.RangeNode=e("./RangeNode"),t.SymbolNode=e("./SymbolNode"),t.UpdateNode=e("./UpdateNode"),t.handlers=e("./handlers")},{"./ArrayNode":104,"./AssignmentNode":105,"./BlockNode":106,"./ConstantNode":107,"./FunctionNode":108,"./Node":109,"./OperatorNode":110,"./ParamsNode":111,"./RangeNode":112,"./SymbolNode":113,"./UpdateNode":114,"./handlers":115}],117:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/collection")),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.abs=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("abs",arguments.length,1);if(a(e))return Math.abs(e);if(u(e))return Math.sqrt(e.re*e.re+e.im*e.im);if(e instanceof r)return e.abs();if(c(e))return o.deepMap(e,f);if(s(e))return Math.abs(e);throw new n.error.UnsupportedTypeError("abs",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],118:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/Unit")),a=e("../../type/collection"),s=t.boolean.isBoolean,u=t.number.isNumber,c=t.number.toNumber,f=t.number.toBigNumber,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.add=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("add",arguments.length,2);if(u(e)){if(u(t))return e+t;if(m(t))return new i(e+t.re,t.im)}if(m(e)){if(m(t))return new i(e.re+t.re,e.im+t.im);if(u(t))return new i(e.re+t,e.im)}if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Units do not match");if(null==e.value)throw new Error("Unit on left hand side of operator + has an undefined value");if(null==t.value)throw new Error("Unit on right hand side of operator + has an undefined value");var o=e.clone();return o.value+=t.value,o.fixPrefix=!1,o}if(e instanceof r)return u(t)?t=f(t):s(t)&&(t=new r(t?1:0)),t instanceof r?e.plus(t):g(c(e),t);if(t instanceof r)return u(e)?e=f(e):s(e)&&(e=new r(e?1:0)),e instanceof r?e.plus(t):g(e,c(t));if(l(e)||l(t))return e+t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(s(e))return g(+e,t);if(s(t))return g(e,+t);throw new n.error.UnsupportedTypeError("add",e,t)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],119:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=o.isCollection,c=i.isComplex;n.ceil=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("ceil",arguments.length,1);if(a(e))return Math.ceil(e);if(c(e))return new i(Math.ceil(e.re),Math.ceil(e.im));if(e instanceof r)return e.ceil();if(u(e))return o.deepMap(e,f);if(s(e))return Math.ceil(e);throw new n.error.UnsupportedTypeError("ceil",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],120:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.cube=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cube",arguments.length,1);if(a(e))return e*e*e;if(u(e))return n.multiply(n.multiply(e,e),e);if(e instanceof r)return e.times(e).times(e);if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("cube",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],121:[function(e,n){n.exports=function(n){function t(e,n){var t=n.re*n.re+n.im*n.im;return 0!=t?new o((e.re*n.re+e.im*n.im)/t,(e.im*n.re-e.re*n.im)/t):new o(0!=e.re?e.re/0:0,0!=e.im?e.im/0:0)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=(e("../../type/Matrix"),e("../../type/Unit")),s=e("../../type/collection"),u=r.number.isNumber,c=r.number.toNumber,f=r.number.toBigNumber,l=r.boolean.isBoolean,m=o.isComplex,p=a.isUnit,h=s.isCollection;n.divide=function g(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("divide",arguments.length,2);if(u(e)){if(u(r))return e/r;if(m(r))return t(new o(e,0),r)}if(m(e)){if(m(r))return t(e,r);if(u(r))return t(e,new o(r,0))}if(e instanceof i)return u(r)?r=f(r):l(r)&&(r=new i(r?1:0)),r instanceof i?e.div(r):g(c(e),r);if(r instanceof i)return u(e)?e=f(e):l(e)&&(e=new i(e?1:0)),e instanceof i?e.div(r):g(e,c(r));if(p(e)&&u(r)){var a=e.clone();return a.value/=r,a}if(h(e))return h(r)?n.multiply(e,n.inv(r)):s.deepMap2(e,r,g);if(h(r))return n.multiply(e,n.inv(r));if(l(e))return g(+e,r);if(l(r))return g(e,+r);throw new n.error.UnsupportedTypeError("divide",e,r)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],122:[function(e,n){n.exports=function(n){var t=e("../../type/collection");n.edivide=function(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("edivide",arguments.length,2);return t.deepMap2(e,r,n.divide)}}},{"../../type/collection":208}],123:[function(e,n){n.exports=function(n){var t=e("../../type/collection");n.emultiply=function(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("emultiply",arguments.length,2);return t.deepMap2(e,r,n.multiply)}}},{"../../type/collection":208}],124:[function(e,n){n.exports=function(n){var t=e("../../type/collection");n.epow=function(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("epow",arguments.length,2);return t.deepMap2(e,r,n.pow)}}},{"../../type/collection":208}],125:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.number.toNumber,c=t.number.toBigNumber,f=t.boolean.isBoolean,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.equal=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("equal",arguments.length,2);if(s(e)){if(s(t))return e==t;if(m(t))return e==t.re&&0==t.im}if(m(e)){if(s(t))return e.re==t&&0==e.im;if(m(t))return e.re==t.re&&e.im==t.im}if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?e.eq(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?e.eq(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value==t.value}if(l(e)||l(t))return e==t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);throw new n.error.UnsupportedTypeError("equal",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],126:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/collection")),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.exp=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("exp",arguments.length,1);if(a(e))return Math.exp(e);if(u(e)){var l=Math.exp(e.re);return new i(l*Math.cos(e.im),l*Math.sin(e.im))}if(e instanceof r)return f(t.number.toNumber(e));if(c(e))return o.deepMap(e,f);if(s(e))return Math.exp(e);throw new n.error.UnsupportedTypeError("exp",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],127:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.fix=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("fix",arguments.length,1);if(a(e))return e>0?Math.floor(e):Math.ceil(e);if(u(e))return new i(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im));if(e instanceof r)return e.isNegative()?e.ceil():e.floor();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("fix",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],128:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.floor=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("floor",arguments.length,1);if(a(e))return Math.floor(e);if(u(e))return new i(Math.floor(e.re),Math.floor(e.im));if(e instanceof r)return e.floor();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("floor",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],129:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=t.number.isNumber,a=t.number.toNumber,s=t.boolean.isBoolean,u=t.number.isInteger,c=i.isCollection;n.gcd=function f(){var e,t=arguments[0],l=arguments[1];if(2==arguments.length){if(o(t)&&o(l)){if(!u(t)||!u(l))throw new Error("Parameters in function gcd must be integer numbers");for(;0!=l;)e=t%l,t=l,l=e;return 0>t?-t:t}if(c(t)||c(l))return i.deepMap2(t,l,f);if(t instanceof r)return f(a(t),l);if(l instanceof r)return f(t,a(l));if(s(t))return f(+t,l);if(s(l))return f(t,+l);throw new n.error.UnsupportedTypeError("gcd",t,l)}if(arguments.length>2){for(var m=1;mt;if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?e.gt(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?e.gt(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>t.value}if(l(e)||l(t))return e>t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("larger",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],131:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.number.toNumber,c=t.number.toBigNumber,f=t.boolean.isBoolean,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.largereq=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("largereq",arguments.length,2);if(s(e)&&s(t))return e>=t;if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?e.gte(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?e.gte(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>=t.value}if(l(e)||l(t))return e>=t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("largereq",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],132:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=t.number.isNumber,a=t.number.toNumber,s=t.boolean.isBoolean,u=t.number.isInteger,c=i.isCollection;n.lcm=function f(){var e,t=arguments[0],l=arguments[1];if(2==arguments.length){if(o(t)&&o(l)){if(!u(t)||!u(l))throw new Error("Parameters in function lcm must be integer numbers");if(0==t||0==l)return 0;for(var m=t*l;0!=l;)e=l,l=t%e,t=e;return Math.abs(m/t)}if(c(t)||c(l))return i.deepMap2(t,l,f);if(s(t))return f(+t,l);if(s(l))return f(t,+l);if(t instanceof r)return f(a(t),l);if(l instanceof r)return f(t,a(l));throw new n.error.UnsupportedTypeError("lcm",t,l)}if(arguments.length>2){for(var p=1;p=0?Math.log(e):f(new i(e,0));if(u(e))return new i(Math.log(Math.sqrt(e.re*e.re+e.im*e.im)),Math.atan2(e.im,e.re));if(e instanceof r)return f(t.number.toNumber(e));if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("log",e)}if(2==arguments.length)return n.divide(f(e),f(l));throw new n.error.ArgumentsError("log",arguments.length,1,2)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],134:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.log10=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("log10",arguments.length,1);if(a(e))return e>=0?Math.log(e)/Math.LN10:f(new i(e,0));if(e instanceof r)return f(t.number.toNumber(e));if(u(e))return new i(Math.log(Math.sqrt(e.re*e.re+e.im*e.im))/Math.LN10,Math.atan2(e.im,e.re)/Math.LN10);if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("log10",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],135:[function(e,n){n.exports=function(n){function t(e,n){if(n>0)return e>0?e%n:0==e?0:e-n*Math.floor(e/n);if(0==n)return e;throw new Error("Cannot calculate mod for a negative divisor")}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/collection"),a=r.number.isNumber,s=r.number.toNumber,u=r.number.toBigNumber,c=r.boolean.isBoolean,f=o.isCollection;n.mod=function l(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("mod",arguments.length,2);if(a(e)&&a(r))return t(e,r);if(e instanceof i)return a(r)?r=u(r):c(r)&&(r=new i(r?1:0)),r instanceof i?e.mod(r):l(s(e),r);if(r instanceof i)return a(e)?e=u(e):c(e)&&(e=new i(e?1:0)),e instanceof i?e.mod(r):l(e,s(r));if(f(e)||f(r))return o.deepMap2(e,r,l);if(c(e))return l(+e,r);if(c(r))return l(e,+r);throw new n.error.UnsupportedTypeError("mod",e,r)}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],136:[function(e,n){n.exports=function(n){function t(e,t){for(var r=[],i=e.length,o=t[0].length,a=e[0].length,s=0;i>s;s++){r[s]=[];for(var u=0;o>u;u++){for(var c=null,f=0;a>f;f++){var l=n.multiply(e[s][f],t[f][u]);c=null===c?l:n.add(c,l)}r[s][u]=c}}return r}function r(e,t){for(var r=[],i=t.length,o=t[0].length,a=0;o>a;a++){for(var s=null,u=0;i>u;u++){var c=n.multiply(e[u],t[u][a]);s=0===u?c:n.add(s,c)}r[a]=s}return r}function i(e,t){for(var r=[],i=e.length,o=e[0].length,a=0;i>a;a++){for(var s=null,u=0;o>u;u++){var c=n.multiply(e[a][u],t[u]);s=0===u?c:n.add(s,c)}r[a]=s}return r}function o(e,t){var r=e.length,i=null;if(r){i=0;for(var o=0,a=e.length;a>o;o++)i=n.add(i,n.multiply(e[o],t[o]))}return i}function a(e,n){return 0==e.im?0==n.im?e.re*n.re:0==n.re?new c(0,e.re*n.im):new c(e.re*n.re,e.re*n.im):0==e.re?0==n.im?new c(0,e.im*n.re):0==n.re?-e.im*n.im:new c(-e.im*n.im,e.im*n.re):0==n.im?new c(e.re*n.re,e.im*n.re):0==n.re?new c(-e.im*n.im,e.re*n.im):new c(e.re*n.re-e.im*n.im,e.re*n.im+e.im*n.re)}var s=e("../../util/index"),u=e("bignumber.js"),c=e("../../type/Complex"),f=e("../../type/Matrix"),l=e("../../type/Unit"),m=e("../../type/collection"),p=s.array,h=s.number.isNumber,g=s.number.toNumber,x=s.number.toBigNumber,d=s.boolean.isBoolean,y=c.isComplex,b=Array.isArray,v=l.isUnit;n.multiply=function w(e,s){if(2!=arguments.length)throw new n.error.ArgumentsError("multiply",arguments.length,2);if(h(e)){if(h(s))return e*s;if(y(s))return a(new c(e,0),s);if(v(s))return res=s.clone(),res.value*=e,res}if(y(e)){if(h(s))return a(e,new c(s,0));if(y(s))return a(e,s)}if(e instanceof u)return h(s)?s=x(s):d(s)&&(s=new u(s?1:0)),s instanceof u?e.times(s):w(g(e),s);if(s instanceof u)return h(e)?e=x(e):d(e)&&(e=new u(e?1:0)),e instanceof u?e.times(s):w(e,g(s));if(v(e)&&h(s))return res=e.clone(),res.value*=s,res;if(b(e)){if(b(s)){var l=p.size(e),E=p.size(s);if(1==l.length){if(1==E.length){if(l[0]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Length of A must match length of B (A is "+l[0]+", B is "+E[0]+l[0]+" != "+E[0]+")");return o(e,s)}if(2==E.length){if(l[0]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Length of A must match rows of B (A is "+l[0]+", B is "+E[0]+"x"+E[1]+", "+l[0]+" != "+E[0]+")");return r(e,s)}throw new Error("Can only multiply a 1 or 2 dimensional matrix (B has "+E.length+" dimensions)")}if(2==l.length){if(1==E.length){if(l[1]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Columns of A must match length of B (A is "+l[0]+"x"+l[0]+", B is "+E[0]+", "+l[1]+" != "+E[0]+")");return i(e,s)}if(2==E.length){if(l[1]!=E[0])throw new RangeError("Dimensions mismatch in multiplication. Columns of A must match rows of B (A is "+l[0]+"x"+l[1]+", B is "+E[0]+"x"+E[1]+", "+l[1]+" != "+E[0]+")");return t(e,s)}throw new Error("Can only multiply a 1 or 2 dimensional matrix (B has "+E.length+" dimensions)")}throw new Error("Can only multiply a 1 or 2 dimensional matrix (A has "+l.length+" dimensions)")}return s instanceof f?new f(w(e,s.valueOf())):m.deepMap2(e,s,w)}if(e instanceof f)return s instanceof f?new f(w(e.valueOf(),s.valueOf())):new f(w(e.valueOf(),s));if(b(s))return m.deepMap2(e,s,w);if(s instanceof f)return new f(m.deepMap2(e,s.valueOf(),w));if(d(e))return w(+e,s);if(d(s))return w(e,+s);throw new n.error.UnsupportedTypeError("multiply",e,s)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],137:[function(e,n){n.exports=function(n){function t(e,t){var r=n.log(e),i=n.multiply(r,t);return n.exp(i)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=e("../../type/Matrix"),s=(e("../../type/collection"),r.array),u=r.number.isNumber,c=r.number.toNumber,f=r.number.toBigNumber,l=r.boolean.isBoolean,m=Array.isArray,p=r.number.isInteger,h=o.isComplex; +n.pow=function g(e,r){if(2!=arguments.length)throw new n.error.ArgumentsError("pow",arguments.length,2);if(u(e)){if(u(r))return p(r)||e>=0?Math.pow(e,r):t(new o(e,0),new o(r,0));if(h(r))return t(new o(e,0),r)}if(h(e)){if(u(r))return t(e,new o(r,0));if(h(r))return t(e,r)}if(e instanceof i)return u(r)?r=f(r):l(r)&&(r=new i(r?1:0)),r instanceof i?e.pow(r):g(c(e),r);if(r instanceof i)return u(e)?e=f(e):l(e)&&(e=new i(e?1:0)),e instanceof i?e.pow(r):g(e,c(r));if(m(e)){if(!u(r)||!p(r)||0>r)throw new TypeError("For A^b, b must be a positive integer (value is "+r+")");var x=s.size(e);if(2!=x.length)throw new Error("For A^b, A must be 2 dimensional (A has "+x.length+" dimensions)");if(x[0]!=x[1])throw new Error("For A^b, A must be square (size is "+x[0]+"x"+x[1]+")");if(0==r)return n.eye(x[0]);for(var d=e,y=1;r>y;y++)d=n.multiply(e,d);return d}if(e instanceof a)return new a(g(e.valueOf(),r));if(l(e))return g(+e,r);if(l(r))return g(e,+r);throw new n.error.UnsupportedTypeError("pow",e,r)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],138:[function(e,n){n.exports=function(n){function t(e,n){if(n){var t=Math.pow(10,n);return Math.round(e*t)/t}return Math.round(e)}var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=e("../../type/collection"),s=r.number.isNumber,u=r.number.isInteger,c=r.boolean.isBoolean,f=o.isComplex,l=a.isCollection;n.round=function m(e,r){if(1!=arguments.length&&2!=arguments.length)throw new n.error.ArgumentsError("round",arguments.length,1,2);if(void 0==r){if(s(e))return Math.round(e);if(f(e))return new o(Math.round(e.re),Math.round(e.im));if(e instanceof i)return e.round();if(l(e))return a.deepMap(e,m);if(c(e))return Math.round(e);throw new n.error.UnsupportedTypeError("round",e)}if(r instanceof i&&(r=parseFloat(r.valueOf())),!s(r)||!u(r))throw new TypeError("Number of decimals in function round must be an integer");if(0>r||r>9)throw new Error("Number of decimals in function round must be in te range of 0-9");if(s(e))return t(e,r);if(f(e))return new o(t(e.re,r),t(e.im,r));if(e instanceof i&&s(r))return e.round(r);if(l(e)||l(r))return a.deepMap2(e,r,m);if(c(e))return m(+e,r);if(c(r))return m(e,+r);throw new n.error.UnsupportedTypeError("round",e,r)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],139:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number,s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isCollection;n.sign=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sign",arguments.length,1);if(s(e))return a.sign(e);if(c(e)){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new i(e.re/t,e.im/t)}if(e instanceof r)return new r(e.cmp(0));if(f(e))return o.deepMap(e,l);if(u(e))return a.sign(e);throw new n.error.UnsupportedTypeError("sign",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],140:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.number.toNumber,c=t.number.toBigNumber,f=t.boolean.isBoolean,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.smaller=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("smaller",arguments.length,2);if(s(e)&&s(t))return t>e;if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?e.lt(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?e.lt(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.valuee;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("smaller",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],141:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.number.toNumber,c=t.number.toBigNumber,f=t.boolean.isBoolean,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.smallereq=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("smallereq",arguments.length,2);if(s(e)&&s(t))return t>=e;if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?e.lte(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?e.lte(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value<=t.value}if(l(e)||l(t))return t>=e;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);if(m(e)||m(t))throw new TypeError("No ordering relation is defined for complex numbers");throw new n.error.UnsupportedTypeError("smallereq",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],142:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.sqrt=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sqrt",arguments.length,1);if(a(e))return e>=0?Math.sqrt(e):f(new i(e,0));if(u(e)){var t=Math.sqrt(e.re*e.re+e.im*e.im);return e.im>=0?new i(.5*Math.sqrt(2*(t+e.re)),.5*Math.sqrt(2*(t-e.re))):new i(.5*Math.sqrt(2*(t+e.re)),-.5*Math.sqrt(2*(t-e.re)))}if(e instanceof r)return e.sqrt();if(c(e))return o.deepMap(e,f);if(s(e))return f(+e);throw new n.error.UnsupportedTypeError("sqrt",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],143:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.square=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("square",arguments.length,1);if(a(e))return e*e;if(u(e))return n.multiply(e,e);if(e instanceof r)return e.times(e);if(c(e))return o.deepMap(e,f);if(s(e))return e*e;throw new n.error.UnsupportedTypeError("square",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],144:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=(e("../../type/Matrix"),e("../../type/Unit")),a=e("../../type/collection"),s=t.number.toNumber,u=t.number.toBigNumber,c=t.boolean.isBoolean,f=t.number.isNumber,l=i.isComplex,m=o.isUnit,p=a.isCollection;n.subtract=function h(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("subtract",arguments.length,2);if(f(e)){if(f(t))return e-t;if(l(t))return new i(e-t.re,-t.im)}else if(l(e)){if(f(t))return new i(e.re-t,e.im);if(l(t))return new i(e.re-t.re,e.im-t.im)}if(e instanceof r)return f(t)?t=u(t):c(t)&&(t=new r(t?1:0)),t instanceof r?e.minus(t):h(s(e),t);if(t instanceof r)return f(e)?e=u(e):c(e)&&(e=new r(e?1:0)),e instanceof r?e.minus(t):h(e,s(t));if(m(e)&&m(t)){if(!e.equalBase(t))throw new Error("Units do not match");if(null==e.value)throw new Error("Unit on left hand side of operator - has an undefined value");if(null==t.value)throw new Error("Unit on right hand side of operator - has an undefined value");var o=e.clone();return o.value-=t.value,o.fixPrefix=!1,o}if(p(e)||p(t))return a.deepMap2(e,t,h);if(c(e))return h(+e,t);if(c(t))return h(e,+t);throw new n.error.UnsupportedTypeError("subtract",e,t)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],145:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.unary=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("unary",arguments.length,1);if(s(e))return-e;if(c(e))return new i(-e.re,-e.im);if(e instanceof r)return e.neg();if(f(e)){var t=e.clone();return t.value=-e.value,t}if(l(e))return a.deepMap(e,m);if(u(e))return-e;throw new n.error.UnsupportedTypeError("unary",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],146:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.number.toNumber,c=t.number.toBigNumber,f=t.boolean.isBoolean,l=t.string.isString,m=i.isComplex,p=o.isUnit,h=a.isCollection;n.unequal=function g(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("unequal",arguments.length,2);if(s(e)){if(s(t))return e!=t;if(m(t))return e!=t.re||0!=t.im}if(m(e)){if(s(t))return e.re!=t||0!=e.im;if(m(t))return e.re!=t.re||e.im!=t.im}if(e instanceof r)return s(t)?t=c(t):f(t)&&(t=new r(t?1:0)),t instanceof r?!e.eq(t):g(u(e),t);if(t instanceof r)return s(e)?e=c(e):f(e)&&(e=new r(e?1:0)),e instanceof r?!e.eq(t):g(e,u(t));if(p(e)&&p(t)){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value!=t.value}if(l(e)||l(t))return e!=t;if(h(e)||h(t))return a.deepMap2(e,t,g);if(f(e))return g(+e,t);if(f(t))return g(e,+t);throw new n.error.UnsupportedTypeError("unequal",e,t)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],147:[function(e,n){n.exports=function(n){function t(e,n){for(var t,r,i,o=0,a=1,s=1,u=0;n;)r=Math.floor(e/n),i=e%n,t=o,o=a-r*o,a=t,t=s,s=u-r*s,u=t,e=n,n=i;return 0>e?[-e,e?-a:0,-u]:[e,e?a:0,u]}var r=e("../../util/index"),i=e("bignumber.js"),o=r.number.toNumber,a=r.number.isNumber,s=r.boolean.isBoolean,u=r.number.isInteger;n.xgcd=function c(e,r){if(2==arguments.length){if(a(e)&&a(r)){if(!u(e)||!u(r))throw new Error("Parameters in function xgcd must be integer numbers");return t(e,r)}if(e instanceof i)return c(o(e),r);if(r instanceof i)return c(e,o(r));if(s(e))return c(+e,r);if(s(r))return c(e,+r);throw new n.error.UnsupportedTypeError("xgcd",e,r)}throw new SyntaxError("Function xgcd expects two arguments")}}},{"../../util/index":212,"bignumber.js":217}],148:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=o.isCollection,c=i.isComplex;n.arg=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("arg",arguments.length,1);if(a(e))return Math.atan2(0,e);if(c(e))return Math.atan2(e.im,e.re);if(u(e))return o.deepMap(e,f);if(s(e))return f(+e);if(e instanceof r)return f(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("arg",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],149:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.object,s=t.number.isNumber,u=t.boolean.isBoolean,c=o.isCollection,f=i.isComplex;n.conj=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("conj",arguments.length,1);return s(e)?e:e instanceof r?new r(e):f(e)?new i(e.re,-e.im):c(e)?o.deepMap(e,l):u(e)?+e:a.clone(e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],150:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=o.isCollection,c=i.isComplex;n.im=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("im",arguments.length,1);return a(e)?0:e instanceof r?new r(0):c(e)?e.im:u(e)?o.deepMap(e,f):s(e)?0:0}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],151:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.object,s=t.number.isNumber,u=t.boolean.isBoolean,c=o.isCollection,f=i.isComplex;n.re=function l(e){if(1!=arguments.length)throw new n.error.ArgumentsError("re",arguments.length,1);return s(e)?e:e instanceof r?new r(e):f(e)?e.re:c(e)?o.deepMap(e,l):u(e)?+e:a.clone(e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],152:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=t.number.isNumber,s=t.string.isString,u=t.boolean.isBoolean;"function"!=typeof r.prototype.clone&&(r.prototype.clone=function(){return new r(this)}),n.bignumber=function c(e){if(arguments.length>1)throw new n.error.ArgumentsError("bignumber",arguments.length,0,1);if(e instanceof r||a(e)||s(e))return new r(e);if(u(e))return new r(+e);if(o(e))return i.deepMap(e,c);if(0==arguments.length)return new r(0);throw new n.error.UnsupportedTypeError("bignumber",e)}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],153:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=t.number.isNumber,s=t.string.isString;n["boolean"]=function u(e){if(1!=arguments.length)throw new n.error.ArgumentsError("boolean",arguments.length,0,1);if("true"===e||e===!0)return!0;if("false"===e||e===!1)return!1;if(e instanceof Boolean)return e?!0:!1;if(a(e))return 0!==e;if(e instanceof r)return!e.isZero();if(s(e)){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var c=Number(e);if(""!=e&&!isNaN(c))return 0!==c}if(o(e))return i.deepMap(e,u);throw new SyntaxError(e.toString()+" is no valid boolean")}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],154:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=o.isCollection,s=t.number.isNumber,u=t.number.toNumber,c=t.string.isString,f=i.isComplex;n.complex=function l(){switch(arguments.length){case 0:return new i(0,0);case 1:var e=arguments[0];if(s(e))return new i(e,0);if(e instanceof r)return new i(u(e),0);if(f(e))return e.clone();if(c(e)){var t=i.parse(e);if(t)return t;throw new SyntaxError('String "'+e+'" is no valid complex number')}if(a(e))return o.deepMap(e,l);throw new TypeError("Two numbers or a single string expected in function complex");case 2:var m=arguments[0],p=arguments[1];if(m instanceof r&&(m=u(m)),p instanceof r&&(p=u(p)),s(m)&&s(p))return new i(m,p);throw new TypeError("Two numbers or a single string expected in function complex");default:throw new n.error.ArgumentsError("complex",arguments.length,0,2)}}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],155:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Index"),o=t.number.toNumber;n.index=function(){var e=new i,n=Array.prototype.slice.apply(arguments).map(function(e){return e instanceof r?o(e):Array.isArray(e)?e.map(function(e){return e instanceof r?o(e):e}):e});return i.apply(e,n),e}}},{"../../type/Index":204,"../../util/index":212,"bignumber.js":217}],156:[function(e,n){n.exports=function(n){var t=e("../../type/Matrix");n.matrix=function(e){if(arguments.length>1)throw new n.error.ArgumentsError("matrix",arguments.length,0,1);return new t(e)}}},{"../../type/Matrix":205}],157:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=i.isCollection,a=t.number.toNumber;n.number=function s(e){switch(arguments.length){case 0:return 0;case 1:if(o(e))return i.deepMap(e,s);if(e instanceof r)return a(e);var t=Number(e);if(isNaN(t)&&(t=Number(e.valueOf())),isNaN(t))throw new SyntaxError(e.toString()+" is no valid number");return t;default:throw new n.error.ArgumentsError("number",arguments.length,0,1)}}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],158:[function(e,n){n.exports=function(n){var t=e("../../expression/Parser");n.parser=function(){return new t(n)}}},{"../../expression/Parser":4}],159:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("../../type/collection"),i=t.number,o=t.number.isNumber,a=r.isCollection;n.string=function s(e){switch(arguments.length){case 0:return"";case 1:return o(e)?i.format(e):a(e)?r.deepMap(e,s):null===e?"null":e.toString();default:throw new n.error.ArgumentsError("string",arguments.length,0,1)}}}},{"../../type/collection":208,"../../util/index":212}],160:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Unit"),o=e("../../type/collection"),a=o.isCollection,s=t.number.toNumber,u=t.string.isString;n.unit=function c(e){switch(arguments.length){case 1:var t=arguments[0];if(t instanceof i)return t.clone();if(u(t)){if(i.isPlainUnit(t))return new i(null,t);var f=i.parse(t);if(f)return f;throw new SyntaxError('String "'+t+'" is no valid unit')}if(a(e))return o.deepMap(e,c);throw new TypeError("A string or a number and string expected in function unit");case 2:return arguments[0]instanceof r?new i(s(arguments[0]),arguments[1]):new i(arguments[0],arguments[1]);default:throw new n.error.ArgumentsError("unit",arguments.length,1,2)}}}},{"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],161:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("../../expression/Scope"),i=e("../../type/collection"),o=t.string.isString,a=i.isCollection;n.eval=function(e,t){if(1!=arguments.length&&2!=arguments.length)throw new n.error.ArgumentsError("eval",arguments.length,1,2);var s;if(s=t?t instanceof r?t:new r(n,t):new r(n),o(e)){var u=n.parse(e,s);return u.eval()}if(a(e))return i.deepMap(e,function(e){var t=n.parse(e,s);return t.eval()});throw new TypeError("String or matrix expected")}}},{"../../expression/Scope":5,"../../type/collection":208,"../../util/index":212}],162:[function(e,n){n.exports=function(n){var t=e("../../type/Help");n.help=function(e){if(1!=arguments.length)throw new SyntaxError("Wrong number of arguments in function help ("+arguments.length+" provided, 1 expected)");var r=null;if(e instanceof String||"string"==typeof e)r=e;else{var i;for(i in n)if(n.hasOwnProperty(i)&&e===n[i]){r=i;break}if(!r)for(i in n.type)if(n.type.hasOwnProperty(i)&&e===n.type[i]){r=i;break}}if(r){var o=n.expression.docs[r];if(!o)throw new Error('No documentation found on "'+r+'"');return new t(n,o)}throw new Error('Could not find search term "'+e+'"')}}},{"../../type/Help":203}],163:[function(e,n){n.exports=function(n,t){function r(){mn=0,pn=ln.charAt(0)}function i(){mn++,pn=ln.charAt(mn)}function o(){return ln.charAt(mn+1)}function a(){for(gn=un.NULL,hn="";" "==pn||" "==pn;)i();if("#"==pn)for(;"\n"!=pn&&""!=pn;)i();if(""==pn)return gn=un.DELIMITER,void 0;var e=pn+o();if(cn[e])return gn=un.DELIMITER,hn=e,i(),i(),void 0;if(cn[pn])return gn=un.DELIMITER,hn=pn,i(),void 0;if(!u(pn)){if(s(pn)){for(;s(pn)||c(pn);)hn+=pn,i();return gn=fn[hn]?un.DELIMITER:un.SYMBOL,void 0}for(gn=un.UNKNOWN;""!=pn;)hn+=pn,i();throw B('Syntax error in part "'+hn+'"')}if(gn=un.NUMBER,"."==pn)hn+=pn,i(),c(pn)||(gn=un.UNKNOWN);else{for(;c(pn);)hn+=pn,i();"."==pn&&(hn+=pn,i())}for(;c(pn);)hn+=pn,i();if("E"==pn||"e"==pn)for(hn+=pn,i(),("+"==pn||"-"==pn)&&(hn+=pn,i()),c(pn)||(gn=un.UNKNOWN);c(pn);)hn+=pn,i()}function s(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function u(e){return e>="0"&&"9">=e||"."==e}function c(e){return e>="0"&&"9">=e}function f(e){r(),a();var n;if(n=""==hn?new X(void 0):l(e),""!=hn)throw gn==un.DELIMITER?P("Unknown operator "+hn):B('Unexpected part "'+hn+'"');return n}function l(e){var n,t,r;for("\n"!=hn&&";"!=hn&&""!=hn&&(n=m(e));"\n"==hn||";"==hn;)t||(t=new $,n&&(r=";"!=hn,t.add(n,r))),a(),"\n"!=hn&&";"!=hn&&""!=hn&&(n=m(e),r=";"!=hn,t.add(n,r));return t?t:(n||(n=m(e)),n)}function m(e){var n=p(e),t="ans";return new K(t,n,e)}function p(e){if(gn==un.SYMBOL&&"function"==hn){if(a(),gn!=un.SYMBOL)throw B("Function name expected");var n=hn;if(a(),"("!=hn)throw B("Opening parenthesis ( expected");for(var t=e.createSubScope(),r=[];;)if(a(),gn==un.SYMBOL&&(r.push(hn),a()),","!=hn){if(")"==hn)break;throw B('Comma , or closing parenthesis ) expected"')}if(a(),"="!=hn)throw B("Equal sign = expected");a();var i=h(t);return new J(n,r,i,t,e)}return h(e)}function h(e){var t,r,i,o,s=g(e);if("="==hn){if(s instanceof on)return a(),t=s.name,r=null,o=h(e),new K(t,o,e);if(s instanceof tn&&s.object instanceof on)return a(),t=s.object.name,r=s.params,i=s.paramScopes,o=h(e),new an(n,t,r,i,o,e);throw B("Symbol expected at the left hand side of assignment operator =")}return s}function g(e){var r,i=[];if(":"==hn){var o="bignumber"===t.number.defaultType?new H(1):1;r=new X(o)}else r=x(e);if(":"==hn){for(i.push(r);":"==hn;)a(),")"==hn||","==hn||""==hn?i.push(new on("end",e)):i.push(x(e));i.length&&(r=new rn(n,t,i))}return r}function x(e){var n=d(e);return n}function d(e){var t,r,i,o,s;for(t=y(e),r={"==":n.equal,"!=":n.unequal,"<":n.smaller,">":n.larger,"<=":n.smallereq,">=":n.largereq};void 0!==r[hn];)i=hn,o=r[i],a(),s=[t,y(e)],t=new nn(i,o,s);return t}function y(e){var t,r,i,o,s;for(t=b(e),r={"in":n["in"]};void 0!==r[hn];)i=hn,o=r[i],a(),s=[t,b(e)],t=new nn(i,o,s);return t}function b(e){var t,r,i,o,s;for(t=v(e),r={"+":n.add,"-":n.subtract};void 0!==r[hn];)i=hn,o=r[i],a(),s=[t,v(e)],t=new nn(i,o,s);return t}function v(e){var t,r,i,o,s;for(t=w(e),r={"*":n.multiply,".*":n.emultiply,"/":n.divide,"./":n.edivide,"%":n.mod,mod:n.mod};void 0!==r[hn];)i=hn,o=r[i],a(),s=[t,w(e)],t=new nn(i,o,s);return t}function w(e){var t,r,i;return"-"==hn?(t=hn,r=n.unary,a(),i=[w(e)],new nn(t,r,i)):E(e)}function E(e){var t,r,i,o,s,u,c;for(i=[N(e)],o=[];"^"==hn||".^"==hn;)o.push(hn),a(),i.push(N(e));for(t=i.pop();i.length;)r=i.pop(),s=o.pop(),u="^"==s?n.pow:n.epow,c=[r,t],t=new nn(s,u,c);return t}function N(e){var t,r,i,o;for(t=M(e);"!"==hn;)r=hn,i=n.factorial,a(),o=[t],t=new nn(r,i,o);return t}function M(e){var t,r,i,o;for(t=j(e);"'"==hn;)r=hn,i=n.transpose,a(),o=[t],t=new nn(r,i,o);return t}function j(e){var n,t,r,i;if(gn==un.SYMBOL&&sn[hn]){if(i=sn[hn],a(),"("==hn){if(n=[],t=[],a(),")"!=hn)for(r=e.createSubScope(),t.push(r),n.push(g(r));","==hn;)a(),r=e.createSubScope(),t.push(r),n.push(g(r));if(")"!=hn)throw B("Parenthesis ) expected");a()}return new i(n,t)}return C(e)}function C(e){var n,t;return gn==un.SYMBOL?(t=hn,a(),n=new on(t,e),A(e,n)):O(e)}function A(e,t){for(var r,i,o,s;"("==hn;){if(r=hn,i=[],o=[],a(),")"!=hn)for(s=e.createSubScope(),o.push(s),i.push(g(s));","==hn;)a(),s=e.createSubScope(),o.push(s),i.push(g(s));if("("==r&&")"!=hn)throw B("Parenthesis ) expected");a(),t=new tn(n,t,i,o)}return t}function O(e){var n,t,r;if('"'==hn){for(t="",r="";""!=pn&&('"'!=pn||"\\"==r);)t+=pn,r=pn,i();if(a(),'"'!=hn)throw B('End of string " expected');return a(),n=new X(t),n=A(e,n)}return S(e)}function S(e){var n,r,i,o;if("["==hn){for(a();"\n"==hn;)a();if("]"!=hn){var s=T(e);if(";"==hn){for(i=1,r=[s];";"==hn;){for(a();"\n"==hn;)a();for(r[i]=T(e),i++;"\n"==hn;)a()}if("]"!=hn)throw B("End of matrix ] expected");a(),o=r.length>0?r[0].length:0;for(var u=1;i>u;u++)if(r[u].length!=o)throw P("Number of columns must match ("+r[u].length+" != "+o+")");n=new en(t,r)}else{if("]"!=hn)throw B("End of matrix ] expected");a(),n=s}}else a(),n=new en(t,[]);return n=A(e,n)}return U(e)}function T(e){for(var n=[h(e)],r=1;","==hn;){for(a();"\n"==hn;)a();for(n[r]=h(e),r++;"\n"==hn;)a()}return new en(t,n)}function U(e){var n,r,i;if(gn==un.NUMBER){if(i="bignumber"==t.number.defaultType?new H("."==hn?0:hn):"."==hn?0:Number(hn),a(),gn==un.SYMBOL){if(i=i instanceof H?k(i):i,"i"==hn||"I"==hn)return r=new V(0,i),a(),new X(r);if(Y.isPlainUnit(hn))return r=new Y(i,hn),a(),new X(r);throw _('Unknown unit "'+hn+'"')}return n=new X(i),n=A(e,n)}return q(e)}function q(e){var n;if("("==hn){if(a(),n=h(e),")"!=hn)throw B("Parenthesis ) expected");return a(),n=A(e,n)}return z(e)}function z(){throw""==hn?B("Unexpected end of expression"):B("Value expected")}function R(){return void 0}function I(){return mn-hn.length+1}function L(e){var n=R(),t=I();return void 0===n?void 0===t?e:e+" (char "+t+")":e+" (line "+n+", char "+t+")"}function B(e){return new SyntaxError(L(e))}function _(e){return new TypeError(L(e))}function P(e){return new Error(L(e))}var F=e("../../util/index"),k=F.number.toNumber,G=F.string.isString,D=Array.isArray,H=e("bignumber.js"),V=e("./../../type/Complex"),W=e("./../../type/Matrix"),Y=e("./../../type/Unit"),Q=e("../../type/collection"),Z=e("./../../expression/Scope"),K=e("../../expression/node/AssignmentNode"),$=e("../../expression/node/BlockNode"),X=e("../../expression/node/ConstantNode"),J=e("../../expression/node/FunctionNode"),en=e("../../expression/node/ArrayNode"),nn=e("../../expression/node/OperatorNode"),tn=e("../../expression/node/ParamsNode"),rn=e("../../expression/node/RangeNode"),on=e("../../expression/node/SymbolNode"),an=e("../../expression/node/UpdateNode"),sn=e("../../expression/node/handlers");n.parse=function(e,t){if(1!=arguments.length&&2!=arguments.length)throw new n.error.ArgumentsError("parse",arguments.length,1,2);var r;if(r=t?t instanceof Z?t:new Z(n,t):new Z(n),G(e))return ln=e||"",f(r);if(D(e)||e instanceof W)return Q.deepMap(e,function(e){return ln=e||"",f(r)});throw new TypeError("String or matrix expected")};var un={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},cn={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,"\n":!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"!":!0,"'":!0,"=":!0,":":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0},fn={mod:!0,"in":!0},ln="",mn=0,pn="",hn="",gn=un.NULL}},{"../../expression/node/ArrayNode":104,"../../expression/node/AssignmentNode":105,"../../expression/node/BlockNode":106,"../../expression/node/ConstantNode":107,"../../expression/node/FunctionNode":108,"../../expression/node/OperatorNode":110,"../../expression/node/ParamsNode":111,"../../expression/node/RangeNode":112,"../../expression/node/SymbolNode":113,"../../expression/node/UpdateNode":114,"../../expression/node/handlers":115,"../../type/collection":208,"../../util/index":212,"./../../expression/Scope":5,"./../../type/Complex":202,"./../../type/Matrix":205,"./../../type/Unit":207,"bignumber.js":217}],164:[function(e,n){n.exports=function(n){function t(e,n,r,i){if(r>i){if(e.length!=n.length)throw new Error("Dimensions mismatch ("+e.length+" != "+n.length+")");for(var o=[],a=0;ae;e++){var h=arguments[e];if(h instanceof i&&(m=!0),e==o-1&&u(h)){if(r=l,l=h,!c(l)||0>l)throw new TypeError("Dimension number must be a positive integer (dim = "+l+")");if(e>0&&l>r)throw new RangeError("Dimension out of range ("+l+" > "+r+")")}else{if(!f(h))throw new n.error.UnsupportedTypeError("concat",h);var g=a.clone(h).valueOf(),x=s.size(h.valueOf());if(p[e]=g,r=l,l=x.length-1,e>0&&l!=r)throw new RangeError("Dimension mismatch ("+r+" != "+l+")")}}if(0==p.length)throw new SyntaxError("At least one matrix expected");for(var d=p.shift();p.length;)d=t(d,p.shift(),l,0);return m?new i(d):d}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],165:[function(e,n){n.exports=function(n){function t(e,t,r){if(1==t)return e[0][0];if(2==t)return n.subtract(n.multiply(e[0][0],e[1][1]),n.multiply(e[1][0],e[0][1]));for(var o=1,a=0,s=0;t>s&&!(a>=r);s++){for(var u=s;0==e[u][a];)if(u++,u==t&&(u=s,a++,a==r))return i.deepEqual(e,eye(t).valueOf())?n.round(o,6):0;if(u!=s){for(var c=0;r>c;c++){var f=e[u][c];e[u][c]=e[s][c],e[s][c]=f}o*=-1}for(var l=e[s][a],c=0;r>c;c++)e[s][c]=e[s][c]/l;o*=l;for(var m=0;t>m;m++)if(m!=s)for(var p=e[m][a],c=0;r>c;c++)e[m][c]=e[m][c]-e[s][c]*p;a++}return i.deepEqual(e,n.eye(t).valueOf())?n.round(o,6):0}var r=e("../../util/index"),i=(e("../../type/Matrix"),r.object),o=r.array,a=r.string;n.det=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("det",arguments.length,1);var r=o.size(e.valueOf());switch(r.length){case 0:return i.clone(e);case 1:if(1==r[0])return i.clone(e.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+a.format(r)+")");case 2:var s=r[0],u=r[1];if(s==u)return t(e.valueOf(),s,u);throw new RangeError("Matrix must be square (size: "+a.format(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+a.format(r)+")")}}}},{"../../type/Matrix":205,"../../util/index":212}],166:[function(e,n){n.exports=function(n,t){var r=e("../../util/index"),i=e("../../type/Matrix"),o=(e("../../type/collection"),r.object),a=r.array.isArray,s=r.number.isNumber,u=r.number.isInteger;n.diag=function(e,r){var c,f,l,m;if(1!=arguments.length&&2!=arguments.length)throw new n.error.ArgumentsError("diag",arguments.length,1,2);if(r){if(!s(r)||!u(r))throw new TypeError("Second parameter in function diag must be an integer")}else r=0;var p=r>0?r:0,h=0>r?-r:0;if(e instanceof i);else{if(!a(e))throw new TypeError("First parameter in function diag must be a Matrix or Array");e=new i(e)}var g=e.size();switch(g.length){case 1:f=e.valueOf();var x=new i,d=0;for(x.resize([f.length+h,f.length+p],d),c=x.valueOf(),m=f.length,l=0;m>l;l++)c[l+h][l+p]=o.clone(f[l]);return"array"===t.matrix.defaultType?x.valueOf():x;case 2:for(f=[],c=e.valueOf(),m=Math.min(g[0]-h,g[1]-p),l=0;m>l;l++)f[l]=o.clone(c[l+h][l+p]);return"array"===t.matrix.defaultType?f:new i(f);default:throw new RangeError("Matrix for function diag must be 2 dimensional")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],167:[function(e,n){n.exports=function(n,t){var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Matrix"),a=e("../../type/collection"),s=r.number.toNumber,u=r.number.isNumber,c=r.number.isInteger,f=Array.isArray;n.eye=function(e){var r=a.argsToArray(arguments),l=e instanceof o?!0:f(e)?!1:"matrix"===t.matrix.defaultType;if(0==r.length)return l?new o:[];if(1==r.length)r[1]=r[0];else if(r.length>2)throw new n.error.ArgumentsError("eye",r.length,0,2);var m=r[0]instanceof i,p=r[0],h=r[1];if(p instanceof i&&(p=s(p)),h instanceof i&&(h=s(h)),!u(p)||!c(p)||1>p)throw new Error("Parameters in function eye must be positive integers");if(h&&(!u(h)||!c(h)||1>h))throw new Error("Parameters in function eye must be positive integers");var g=new o,x=m?new i(1):1,d=m?new i(0):0;g.resize(r.map(s),d);for(var y=n.min(r),b=g.valueOf(),v=0;y>v;v++)b[v][v]=x;return l?g:g.valueOf()}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],168:[function(e,n){n.exports=function(n){function t(e,t,r){var i,o,a,s,u;if(1==t){if(s=e[0][0],0==s)throw Error("Cannot calculate inverse, determinant is zero");return[[n.divide(1,s)]]}if(2==t){var c=n.det(e);if(0==c)throw Error("Cannot calculate inverse, determinant is zero");return[[n.divide(e[1][1],c),n.divide(n.unary(e[0][1]),c)],[n.divide(n.unary(e[1][0]),c),n.divide(e[0][0],c)]]}var f=e.concat();for(i=0;t>i;i++)f[i]=f[i].concat();for(var l=n.eye(t).valueOf(),m=0;r>m;m++){for(i=m;t>i&&0==f[i][m];)i++;if(i==t||0==f[i][m])throw Error("Cannot calculate inverse, determinant is zero");i!=m&&(u=f[m],f[m]=f[i],f[i]=u,u=l[m],l[m]=l[i],l[i]=u); +var p=f[m],h=l[m];for(i=0;t>i;i++){var g=f[i],x=l[i];if(i!=m){if(0!=g[m]){for(a=n.divide(n.unary(g[m]),p[m]),o=m;r>o;o++)g[o]=n.add(g[o],n.multiply(a,p[o]));for(o=0;r>o;o++)x[o]=n.add(x[o],n.multiply(a,h[o]))}}else{for(a=p[m],o=m;r>o;o++)g[o]=n.divide(g[o],a);for(o=0;r>o;o++)x[o]=n.divide(x[o],a)}}}return l}{var r=e("../../util/string"),i=e("../../type/Matrix");e("../../type/collection")}n.inv=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("inv",arguments.length,1);var o=n.size(e).valueOf();switch(o.length){case 0:return n.divide(1,e);case 1:if(1==o[0])return e instanceof i?new i([n.divide(1,e.valueOf()[0])]):[n.divide(1,e[0])];throw new RangeError("Matrix must be square (size: "+r.format(o)+")");case 2:var a=o[0],s=o[1];if(a==s)return e instanceof i?new i(t(e.valueOf(),a,s)):t(e,a,s);throw new RangeError("Matrix must be square (size: "+r.format(o)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+r.format(o)+")")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/string":215}],169:[function(e,n){n.exports=function(n,t){var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Matrix"),a=e("../../type/collection"),s=r.array,u=r.number.toNumber,c=Array.isArray;n.ones=function(e){var n=a.argsToArray(arguments),r=e instanceof o?!0:c(e)?!1:"matrix"===t.matrix.defaultType;if(0==n.length)return r?new o:[];var f=[],l=n[0]instanceof i?new i(1):1;return f=s.resize(f,n.map(u),l),r?new o(f):f}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],170:[function(e,n){n.exports=function(n,t){function r(e,n,t){var r=[],i=e;if(t>0)for(;n>i;)r.push(i),i+=t;else if(0>t)for(;i>n;)r.push(i),i+=t;return r}function i(e,n,t){var r=[],i=e.clone(),o=new s(0);if(t.gt(o))for(;i.lt(n);)r.push(i),i=i.plus(t);else if(t.lt(o))for(;i.gt(n);)r.push(i),i=i.plus(t);return r}function o(e){var n=e.split(":"),r=null;if("bignumber"===t.number.defaultType)try{r=n.map(function(e){return new s(e)})}catch(i){return null}else{r=n.map(function(e){return parseFloat(e)});var o=r.some(function(e){return isNaN(e)});if(o)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 a=e("../../util/index"),s=e("bignumber.js"),u=e("../../type/Matrix"),c=(e("../../type/collection"),a.string.isString),f=a.number.isNumber,l=a.number.toNumber,m=a.number.toBigNumber;n.range=function(e){var a,p,h;switch(arguments.length){case 1:if(!c(e))throw new TypeError("Two or three numbers or a single string expected in function range");var g=o(e);if(!g)throw new SyntaxError('String "'+g+'" is no valid range');a=g.start,p=g.end,h=g.step;break;case 2:a=arguments[0],p=arguments[1],h=1;break;case 3:a=arguments[0],p=arguments[1],h=arguments[2];break;default:throw new n.error.ArgumentsError("range",arguments.length,2,3)}if(!(f(a)||a instanceof s))throw new TypeError("Parameter start must be a number");if(!(f(p)||p instanceof s))throw new TypeError("Parameter end must be a number");if(!(f(h)||h instanceof s))throw new TypeError("Parameter step must be a number");if(a instanceof s||p instanceof s||h instanceof s){var x=!0;a instanceof s||(a=m(a)),p instanceof s||(p=m(p)),h instanceof s||(h=m(h)),a instanceof s&&p instanceof s&&h instanceof s||(x=!1,a=l(a),p=l(p),h=l(h))}var d=x?i(a,p,h):r(a,p,h);return"array"===t.matrix.defaultType?d:new u(d)}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],171:[function(e,n){n.exports=function(n,t){function r(e,n,t){if(void 0!==t){if(!c(t)||1!==t.length)throw new TypeError("Single character expected as defaultValue")}else t=" ";if(1!==n.length)throw new Error("Dimension mismatch: ("+n.length+" != 1)");var r=n[0];if(!l(r)||!m(r))throw new TypeError("Size must contain numbers");if(e.length>r)return e.substring(0,r);if(e.lengtho;o++)i+=t;return i}return e}var i=e("../../util/index"),o=e("bignumber.js"),a=e("../../type/Matrix"),s=i.array,u=i.object.clone,c=i.string.isString,f=i.number.toNumber,l=i.number.isNumber,m=i.number.isInteger,p=s.isArray;n.resize=function(e,i,l){if(2!=arguments.length&&3!=arguments.length)throw new n.error.ArgumentsError("resize",arguments.length,2,3);var m=e instanceof a?!0:p(e)?!1:"array"!==t.matrix.defaultType;if(e instanceof a&&(e=e.valueOf()),i instanceof a&&(i=i.valueOf()),i.length&&i[0]instanceof o&&(i=i.map(f)),c(e))return r(e,i,l);if(0==i.length){for(;p(e);)e=e[0];return u(e)}p(e)||(e=[e]),e=u(e);var h=s.resize(e,i,l);return m?new a(h):h}}},{"../../type/Matrix":205,"../../util/index":212,"bignumber.js":217}],172:[function(e,n){n.exports=function(n,t){var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Complex"),a=e("../../type/Unit"),s=e("../../type/Matrix"),u=r.array,c=r.number.isNumber,f=r.boolean.isBoolean,l=r.string.isString,m=o.isComplex,p=a.isUnit;n.size=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("size",arguments.length,1);var r="array"===t.matrix.defaultType;if(c(e)||m(e)||p(e)||f(e)||null==e||e instanceof i)return r?[]:new s([]);if(l(e))return r?[e.length]:new s([e.length]);if(Array.isArray(e))return u.size(e);if(e instanceof s)return new s(e.size());throw new n.error.UnsupportedTypeError("size",e)}}},{"../../type/Complex":202,"../../type/Matrix":205,"../../type/Unit":207,"../../util/index":212,"bignumber.js":217}],173:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("../../type/Matrix"),i=t.object,o=t.array,a=Array.isArray;n.squeeze=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("squeeze",arguments.length,1);if(a(e))return o.squeeze(i.clone(e));if(e instanceof r){var t=o.squeeze(e.toArray());return a(t)?new r(t):t}return i.clone(e)}}},{"../../type/Matrix":205,"../../util/index":212}],174:[function(e,n){n.exports=function(n){function t(e,t){var i,o;if(l(e))return i=new s(e),o=i.subset(t),o.valueOf();if(e instanceof s)return e.subset(t);if(f(e))return r(e,t);throw new n.error.UnsupportedTypeError("subset",e)}function r(e,n){if(!(n instanceof u))throw new TypeError("Index expected");if(1!=n.size().length)throw new RangeError("Dimension mismatch ("+n.size().length+" != 1)");var t=n.range(0),r="",i=e.length;return t.forEach(function(n){c.validateIndex(n,i),r+=e.charAt(n)}),r}function i(e,t,r,i){var a;if(l(e))return a=new s(n.clone(e)),a.subset(t,r,i),a.valueOf();if(e instanceof s)return e.clone().subset(t,r,i);if(f(e))return o(e,t,r,i);throw new n.error.UnsupportedTypeError("subset",e)}function o(e,n,t,r){if(!(n instanceof u))throw new TypeError("Index expected");if(1!=n.size().length)throw new RangeError("Dimension mismatch ("+n.size().length+" != 1)");if(void 0!==r){if(!f(r)||1!==r.length)throw new TypeError("Single character expected as defaultValue")}else r=" ";var i=n.range(0),o=i.size()[0];if(o!=t.length)throw new RangeError("Dimension mismatch ("+i.size()[0]+" != "+t.length+")");for(var a=e.length,s=[],l=0;a>l;l++)s[l]=e.charAt(l);if(i.forEach(function(e,n){c.validateIndex(e),s[e]=t.charAt(n)}),s.length>a)for(l=a-1,o=s.length;o>l;l++)s[l]||(s[l]=r);return s.join("")}var a=e("../../util/index"),s=e("../../type/Matrix"),u=e("../../type/Index"),c=a.array,f=a.string.isString,l=Array.isArray;n.subset=function(){switch(arguments.length){case 2:return t(arguments[0],arguments[1]);case 3:case 4:return i(arguments[0],arguments[1],arguments[2],arguments[3]);default:throw new n.error.ArgumentsError("subset",arguments.length,2,4)}}}},{"../../type/Index":204,"../../type/Matrix":205,"../../util/index":212}],175:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("../../type/Matrix"),i=(e("../../type/collection"),t.object),o=t.string;n.transpose=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("transpose",arguments.length,1);var t=n.size(e).valueOf();switch(t.length){case 0:return i.clone(e);case 1:return i.clone(e);case 2:var a,s=t[1],u=t[0],c=e instanceof r,f=e.valueOf(),l=[],m=i.clone;if(0===s)throw new RangeError("Cannot transpose a 2D matrix with no rows(size: "+o.format(t)+")");for(var p=0;s>p;p++){a=l[p]=[];for(var h=0;u>h;h++)a[h]=m(f[h][p])}return 0==u&&(l[0]=[]),c?new r(l):l;default:throw new RangeError("Matrix must be two dimensional (size: "+o.format(t)+")")}}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212}],176:[function(e,n){n.exports=function(n,t){var r=e("../../util/index"),i=e("bignumber.js"),o=e("../../type/Matrix"),a=e("../../type/collection"),s=r.array,u=r.number.toNumber,c=Array.isArray;n.zeros=function(e){var n=a.argsToArray(arguments),r=e instanceof o?!0:c(e)?!1:"matrix"===t.matrix.defaultType;if(0==n.length)return r?new o:[];var f=[],l=n[0]instanceof i?new i(0):0;return f=s.resize(f,n.map(u),l),r?new o(f):f}}},{"../../type/Matrix":205,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],177:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/collection"),o=t.number.isNumber,a=t.boolean.isBoolean,s=t.number.isInteger,u=i.isCollection;n.factorial=function c(e){var t,f;if(1!=arguments.length)throw new n.error.ArgumentsError("factorial",arguments.length,1);if(o(e)){if(!s(e)||0>e)throw new TypeError("Positive integer value expected in function factorial");for(t=e-1,f=e;t>1;)f*=t,t--;return 0==f&&(f=1),f}if(e instanceof r){if(!e.round().equals(e)||e.lt(0))throw new TypeError("Positive integer value expected in function factorial");var l=new r(1);for(t=e.minus(l),f=e;t.gt(l);)f=f.times(t),t=t.minus(l);return f.equals(0)&&(f=l),f}if(a(e))return 1;if(u(e))return i.deepMap(e,c);throw new n.error.UnsupportedTypeError("factorial",e)}}},{"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],178:[function(e,n){n.exports=function(n,t){var r=e("../../type/Matrix"),i=(e("../../type/collection"),{uniform:function(){return Math.random},normal:function(){return function(){for(var e,n,t=-1;0>t||t>1;)e=Math.random(),n=Math.random(),t=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*n)+.5;return t}}});n.distribution=function(e){if(!i.hasOwnProperty(e))throw new Error("unknown distribution "+e);var o=Array.prototype.slice.call(arguments,1),a=i[e].apply(this,o);return function(e){var i={random:function(e,i,a){var u,c,f;if(arguments.length>3)throw new n.error.ArgumentsError("random",arguments.length,0,3);if(1===arguments.length?Array.isArray(e)?u=e:f=e:2===arguments.length?Array.isArray(e)?u=e:(c=e,f=i):(u=e,c=i,f=a),void 0===f&&(f=1),void 0===c&&(c=0),void 0!==u){var l=s(u,c,f,o);return"array"===t.matrix.defaultType?l:new r(l)}return o(c,f)},randomInt:function(e,i,o){var u,c,f;if(arguments.length>3||arguments.length<1)throw new n.error.ArgumentsError("randomInt",arguments.length,1,3);if(1===arguments.length?f=e:2===arguments.length?"[object Array]"===Object.prototype.toString.call(e)?u=e:(c=e,f=i):(u=e,c=i,f=o),void 0===c&&(c=0),void 0!==u){var l=s(u,c,f,a);return"array"===t.matrix.defaultType?l:new r(l)}return a(c,f)},pickRandom:function(e){if(1!==arguments.length)throw new n.error.ArgumentsError("pickRandom",arguments.length,1);if(!Array.isArray(e))throw new n.error.UnsupportedTypeError("pickRandom",e);return e[Math.floor(Math.random()*e.length)]}},o=function(n,t){return n+e()*(t-n)},a=function(n,t){return Math.floor(n+e()*(t-n))},s=function(e,n,t,r){var i,o,a=[];if(e=e.slice(0),e.length>1)for(o=0,i=e.shift();i>o;o++)a.push(s(e,n,t,r));else for(o=0,i=e.shift();i>o;o++)a.push(r(n,t));return a};return i}(a)};var o=n.distribution("uniform");n.random=o.random,n.randomInt=o.randomInt,n.pickRandom=o.pickRandom}},{"../../type/Matrix":205,"../../type/collection":208}],179:[function(e,n){n.exports=function(n){function t(e,t){return n.larger(e,t)?e:t}function r(e){var t=null;if(i.deepForEach(e,function(e){(null===t||n.larger(e,t))&&(t=e)}),null===t)throw new Error("Cannot calculate max of an empty array");return t}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;n.max=function(e){if(0==arguments.length)throw new SyntaxError("Function max requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return i.reduce(arguments[0],arguments[1],t);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],180:[function(e,n){n.exports=function(n){function t(e,t){var r;return r=i.reduce(e,t,n.add),n.divide(r,size(e)[t])}function r(e){var t=0,r=0;if(i.deepForEach(e,function(e){t=n.add(t,e),r++}),0===r)throw new Error("Cannot calculate mean of an empty array");return n.divide(t,r)}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;n.mean=function(e){if(0==arguments.length)throw new SyntaxError("Function mean requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return t(arguments[0],arguments[1]);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],181:[function(e,n){n.exports=function(n){function t(e,t){return n.smaller(e,t)?e:t}function r(e){var t=null;if(i.deepForEach(e,function(e){(null===t||n.smaller(e,t))&&(t=e)}),null===t)throw new Error("Cannot calculate min of an empty array");return t}var i=(e("../../type/Matrix"),e("../../type/collection")),o=i.isCollection;n.min=function(e){if(0==arguments.length)throw new SyntaxError("Function min requires one or more parameters (0 provided)");if(o(e)){if(1==arguments.length)return r(e);if(2==arguments.length)return i.reduce(arguments[0],arguments[1],t);throw new SyntaxError("Wrong number of parameters")}return r(arguments)}}},{"../../type/Matrix":205,"../../type/collection":208}],182:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.acos=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("acos",arguments.length,1);if(a(e))return e>=-1&&1>=e?Math.acos(e):f(new i(e,0));if(u(e)){var l,m=new i(e.im*e.im-e.re*e.re+1,-2*e.re*e.im),p=n.sqrt(m);l=p instanceof i?new i(p.re-e.im,p.im+e.re):new i(p-e.im,e.re);var h=n.log(l);return h instanceof i?new i(1.5707963267948966-h.im,h.re):new i(1.5707963267948966,h)}if(c(e))return o.deepMap(e,f);if(s(e))return Math.acos(e);if(e instanceof r)return f(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("acos",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],183:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.asin=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("asin",arguments.length,1);if(a(e))return e>=-1&&1>=e?Math.asin(e):f(new i(e,0));if(u(e)){var l,m=e.re,p=e.im,h=new i(p*p-m*m+1,-2*m*p),g=n.sqrt(h);l=g instanceof i?new i(g.re-p,g.im+m):new i(g-p,m);var x=n.log(l);return x instanceof i?new i(x.im,-x.re):new i(0,-x)}if(c(e))return o.deepMap(e,f);if(s(e))return Math.asin(e);if(e instanceof r)return f(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("asin",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],184:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.isNumber,s=t.boolean.isBoolean,u=i.isComplex,c=o.isCollection;n.atan=function f(e){if(1!=arguments.length)throw new n.error.ArgumentsError("atan",arguments.length,1);if(a(e))return Math.atan(e);if(u(e)){var l=e.re,m=e.im,p=l*l+(1-m)*(1-m),h=new i((1-m*m-l*l)/p,-2*l/p),g=n.log(h);return g instanceof i?new i(-.5*g.im,.5*g.re):new i(0,.5*g)}if(c(e))return o.deepMap(e,f);if(s(e))return Math.atan(e);if(e instanceof r)return f(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("atan",e)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],185:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/collection"),a=t.number.toNumber,s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isCollection;n.atan2=function l(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("atan2",arguments.length,2);if(s(e)){if(s(t))return Math.atan2(e,t)}else if(c(e)&&s(t))return Math.atan2(e.re,t);if(f(e)||f(t))return o.deepMap2(e,t,l);if(u(e))return l(+e,t);if(u(t))return l(e,+t);if(e instanceof r)return l(a(e),t);if(t instanceof r)return l(e,a(t));throw new n.error.UnsupportedTypeError("atan2",e,t)}}},{"../../type/Complex":202,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],186:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.cos=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cos",arguments.length,1);if(s(e))return Math.cos(e);if(c(e))return new i(.5*Math.cos(e.re)*(Math.exp(-e.im)+Math.exp(e.im)),.5*Math.sin(e.re)*(Math.exp(-e.im)-Math.exp(e.im)));if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.cos(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return Math.cos(e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("cos",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],187:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.cot=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("cot",arguments.length,1);if(s(e))return 1/Math.tan(e);if(c(e)){var p=Math.exp(-4*e.im)-2*Math.exp(-2*e.im)*Math.cos(2*e.re)+1;return new i(2*Math.exp(-2*e.im)*Math.sin(2*e.re)/p,(Math.exp(-4*e.im)-1)/p)}if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return 1/Math.tan(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return m(+e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("cot",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],188:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.csc=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("csc",arguments.length,1);if(s(e))return 1/Math.sin(e);if(c(e)){var p=.25*(Math.exp(-2*e.im)+Math.exp(2*e.im))-.5*Math.cos(2*e.re);return new i(.5*Math.sin(e.re)*(Math.exp(-e.im)+Math.exp(e.im))/p,.5*Math.cos(e.re)*(Math.exp(-e.im)-Math.exp(e.im))/p)}if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return 1/Math.sin(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return m(+e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("csc",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],189:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.sec=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sec",arguments.length,1);if(s(e))return 1/Math.cos(e);if(c(e)){var p=.25*(Math.exp(-2*e.im)+Math.exp(2*e.im))+.5*Math.cos(2*e.re);return new i(.5*Math.cos(e.re)*(Math.exp(-e.im)+Math.exp(e.im))/p,.5*Math.sin(e.re)*(Math.exp(e.im)-Math.exp(-e.im))/p)}if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return 1/Math.cos(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return m(+e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("sec",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],190:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.sin=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("sin",arguments.length,1);if(s(e))return Math.sin(e);if(c(e))return new i(.5*Math.sin(e.re)*(Math.exp(-e.im)+Math.exp(e.im)),.5*Math.cos(e.re)*(Math.exp(e.im)-Math.exp(-e.im)));if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return Math.sin(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return Math.sin(e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("sin",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],191:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Unit"),a=e("../../type/collection"),s=t.number.isNumber,u=t.boolean.isBoolean,c=i.isComplex,f=o.isUnit,l=a.isCollection;n.tan=function m(e){if(1!=arguments.length)throw new n.error.ArgumentsError("tan",arguments.length,1);if(s(e))return Math.tan(e);if(c(e)){var p=Math.exp(-4*e.im)+2*Math.exp(-2*e.im)*Math.cos(2*e.re)+1;return new i(2*Math.exp(-2*e.im)*Math.sin(2*e.re)/p,(1-Math.exp(-4*e.im))/p)}if(f(e)){if(!e.hasBase(o.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return Math.tan(e.value)}if(l(e))return a.deepMap(e,m);if(u(e))return Math.tan(e);if(e instanceof r)return m(t.number.toNumber(e));throw new n.error.UnsupportedTypeError("tan",e)}}},{"../../type/Complex":202,"../../type/Unit":207,"../../type/collection":208,"../../util/index":212,"bignumber.js":217}],192:[function(e,n){n.exports=function(n){var t=e("../../util/index"),r=e("../../type/Unit"),i=e("../../type/collection"),o=t.string.isString,a=r.isUnit,s=i.isCollection;n["in"]=function u(e,t){if(2!=arguments.length)throw new n.error.ArgumentsError("in",arguments.length,2);if(a(e)&&(a(t)||o(t)))return e["in"](t);if(s(e)||s(t))return i.deepMap2(e,t,u);throw new n.error.UnsupportedTypeError("in",e,t)}}},{"../../type/Unit":207,"../../type/collection":208,"../../util/index":212}],193:[function(e,n){n.exports=function(n){var t=e("../../util/object");n.clone=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("clone",arguments.length,1);return t.clone(e)}}},{"../../util/object":214}],194:[function(e,n){n.exports=function(n){function t(e,n){var t=[],r=function(i,o){Array.isArray(i)?i.forEach(function(e,n){t[o]=n,r(e,o+1)}):n(i,t,e)};r(e,0)}var r=e("../../type/Matrix").isMatrix;n.forEach=function(e,i){if(2!=arguments.length)throw new n.error.ArgumentsError("forEach",arguments.length,2);if(Array.isArray(e))return t(e,i);if(r(e))return e.forEach(i);throw new n.error.UnsupportedTypeError("forEach",e)}}},{"../../type/Matrix":205}],195:[function(e,n){n.exports=function(n){var t=e("../../util/string");n.format=function(e,r){var i=arguments.length;if(1!==i&&2!==i)throw new n.error.ArgumentsError("format",i,1,2);return t.format(e,r)}}},{"../../util/string":215}],196:[function(e,n){n.exports=function(n){function t(e,t,r){(r.override||void 0===n[e])&&(n[e]=r.wrap&&"function"==typeof t?function(){for(var e=[],r=0,i=arguments.length;i>r;r++)e[r]=arguments[r].valueOf();return t.apply(n,e)}:t,n.chaining.Selector.createProxy(e,t))}function r(e){return"function"==typeof e||s(e)||u(e)||c(e)||f(e)}var i=e("../../util/index"),o=e("../../type/Complex"),a=e("../../type/Unit"),s=i.number.isNumber,u=i.string.isString,c=o.isComplex,f=a.isUnit;n["import"]=function l(o,a){var s,c={override:!1,wrap:!0};if(a&&a instanceof Object&&i.object.extend(c,a),u(o)){if("undefined"==typeof e)throw new Error("Cannot load file: require not available.");var f=e(o);l(f)}else if(r(o)){if(s=o.name,!s)throw new Error("Cannot import an unnamed function or object");(c.override||void 0===n[s])&&t(s,o,c)}else if(o instanceof Object)for(s in o)if(o.hasOwnProperty(s)){var m=o[s];r(m)?t(s,m,c):l(m)}}}},{"../../type/Complex":202,"../../type/Unit":207,"../../util/index":212}],197:[function(e,n){n.exports=function(n){function t(e,n){var t=[],r=function(i,o){return Array.isArray(i)?i.map(function(e,n){return t[o]=n,r(e,o+1)}):n(i,t,e)};return r(e,0)}var r=e("../../type/Matrix").isMatrix;n.map=function(e,i){if(2!=arguments.length)throw new n.error.ArgumentsError("map",arguments.length,2);if(Array.isArray(e))return t(e,i);if(r(e))return e.map(i);throw new n.error.UnsupportedTypeError("map",e)}}},{"../../type/Matrix":205}],198:[function(e,n){n.exports=function(n){var t=e("../../util/string"),r=t.isString;n.print=function(e,t,i){var o=arguments.length;if(2!=o&&3!=o)throw new n.error.ArgumentsError("print",o,2,3);if(!r(e))throw new TypeError("String expected as first parameter in function format");if(!(t instanceof Object))throw new TypeError("Object expected as second parameter in function format");return e.replace(/\$([\w\.]+)/g,function(e,o){for(var a=o.split("."),s=t[a.shift()];a.length&&void 0!==s;){var u=a.shift();s=u?s[u]:s+"."}return void 0!==s?r(s)?s:n.format(s,i):e})}}},{"../../util/string":215}],199:[function(e,n){n.exports=function(e){e.select=function(n){return new e.chaining.Selector(n)}}},{}],200:[function(e,n){n.exports=function(n){var t=e("../../util/types"),r=e("bignumber.js"),i=e("../../type/Complex"),o=e("../../type/Matrix"),a=e("../../type/Unit"),s=e("../../type/Index"),u=e("../../type/Range"),c=e("../../type/Help");n["typeof"]=function(e){if(1!=arguments.length)throw new n.error.ArgumentsError("typeof",arguments.length,1);var f=t.type(e);if("object"===f){if(e instanceof i)return"complex";if(e instanceof r)return"bignumber";if(e instanceof o)return"matrix";if(e instanceof a)return"unit";if(e instanceof s)return"index";if(e instanceof u)return"range";if(e instanceof c)return"matrix";if(e instanceof n.chaining.Selector)return"selector"}return f}}},{"../../type/Complex":202,"../../type/Help":203,"../../type/Index":204,"../../type/Matrix":205,"../../type/Range":206,"../../type/Unit":207,"../../util/types":216,"bignumber.js":217}],201:[function(e,n){function t(n){var t={},i={matrix:{defaultType:"matrix"},number:{defaultType:"number"}};return t.config=function(n){var t=e("bignumber.js");if(n&&(r.deepExtend(i,n),n.number&&n.number.precision&&t.config({DECIMAL_PLACES:n.number.precision}),n.matrix&&n.matrix.default))throw new Error("setting matrix.default is deprecated. Use matrix.defaultType instead.");var o=r.clone(i);return o.number.precision=t.config().DECIMAL_PLACES,o},t.config(n),t.expression={},t.expression.node=e("./expression/node/index.js"),t.expression.Scope=e("./expression/Scope.js"),t.expression.Parser=e("./expression/Parser.js"),t.expression.docs=e("./expression/docs/index.js"),t.expr={},t.expr.Scope=function(){throw new Error("Moved to math.expression.Scope")},t.expr.Parser=function(){throw new Error("Moved to math.expression.Parser")},t.type={},t.type.BigNumber=e("bignumber.js"),t.type.Complex=e("./type/Complex"),t.type.Range=e("./type/Range"),t.type.Index=e("./type/Index"),t.type.Matrix=e("./type/Matrix"),t.type.Unit=e("./type/Unit"),t.type.Help=e("./type/Help"),t.collection=e("./type/collection"),e("./type/error")(t),e("./function/expression/eval.js")(t,i),e("./function/expression/help.js")(t,i),e("./function/expression/parse.js")(t,i),e("./function/arithmetic/abs.js")(t,i),e("./function/arithmetic/add.js")(t,i),e("./function/arithmetic/add.js")(t,i),e("./function/arithmetic/ceil.js")(t,i),e("./function/arithmetic/cube.js")(t,i),e("./function/arithmetic/divide.js")(t,i),e("./function/arithmetic/edivide.js")(t,i),e("./function/arithmetic/emultiply.js")(t,i),e("./function/arithmetic/epow.js")(t,i),e("./function/arithmetic/equal.js")(t,i),e("./function/arithmetic/exp.js")(t,i),e("./function/arithmetic/fix.js")(t,i),e("./function/arithmetic/floor.js")(t,i),e("./function/arithmetic/gcd.js")(t,i),e("./function/arithmetic/larger.js")(t,i),e("./function/arithmetic/largereq.js")(t,i),e("./function/arithmetic/lcm.js")(t,i),e("./function/arithmetic/log.js")(t,i),e("./function/arithmetic/log10.js")(t,i),e("./function/arithmetic/mod.js")(t,i),e("./function/arithmetic/multiply.js")(t,i),e("./function/arithmetic/pow.js")(t,i),e("./function/arithmetic/round.js")(t,i),e("./function/arithmetic/sign.js")(t,i),e("./function/arithmetic/smaller.js")(t,i),e("./function/arithmetic/smallereq.js")(t,i),e("./function/arithmetic/sqrt.js")(t,i),e("./function/arithmetic/square.js")(t,i),e("./function/arithmetic/subtract.js")(t,i),e("./function/arithmetic/unary.js")(t,i),e("./function/arithmetic/unequal.js")(t,i),e("./function/arithmetic/xgcd.js")(t,i),e("./function/complex/arg.js")(t,i),e("./function/complex/conj.js")(t,i),e("./function/complex/re.js")(t,i),e("./function/complex/im.js")(t,i),e("./function/construction/bignumber")(t,i),e("./function/construction/boolean.js")(t,i),e("./function/construction/complex.js")(t,i),e("./function/construction/index.js")(t,i),e("./function/construction/matrix.js")(t,i),e("./function/construction/number.js")(t,i),e("./function/construction/parser.js")(t,i),e("./function/construction/string.js")(t,i),e("./function/construction/unit.js")(t,i),e("./function/matrix/concat.js")(t,i),e("./function/matrix/det.js")(t,i),e("./function/matrix/diag.js")(t,i),e("./function/matrix/eye.js")(t,i),e("./function/matrix/inv.js")(t,i),e("./function/matrix/ones.js")(t,i),e("./function/matrix/range.js")(t,i),e("./function/matrix/resize.js")(t,i),e("./function/matrix/size.js")(t,i),e("./function/matrix/squeeze.js")(t,i),e("./function/matrix/subset.js")(t,i),e("./function/matrix/transpose.js")(t,i),e("./function/matrix/zeros.js")(t,i),e("./function/probability/factorial.js")(t,i),e("./function/probability/random.js")(t,i),e("./function/statistics/min.js")(t,i),e("./function/statistics/max.js")(t,i),e("./function/statistics/mean.js")(t,i),e("./function/trigonometry/acos.js")(t,i),e("./function/trigonometry/asin.js")(t,i),e("./function/trigonometry/atan.js")(t,i),e("./function/trigonometry/atan2.js")(t,i),e("./function/trigonometry/cos.js")(t,i),e("./function/trigonometry/cot.js")(t,i),e("./function/trigonometry/csc.js")(t,i),e("./function/trigonometry/sec.js")(t,i),e("./function/trigonometry/sin.js")(t,i),e("./function/trigonometry/tan.js")(t,i),e("./function/units/in.js")(t,i),e("./function/utils/clone.js")(t,i),e("./function/utils/format.js")(t,i),e("./function/utils/import.js")(t,i),e("./function/utils/map.js")(t,i),e("./function/utils/print.js")(t,i),e("./function/utils/select.js")(t,i),e("./function/utils/typeof.js")(t,i),e("./function/utils/forEach.js")(t,i),e("./constants.js")(t,i),t.chaining={},t.chaining.Selector=e("./chaining/Selector.js")(t,i),t.expr.Selector=function(){throw new Error("Moved to math.expression.Selector")},t}var r=e("./util/object");n.exports=t;var i=function(){throw new Error('Static function calls are deprecated. Create an instance of math.js:\n "var math = require(\'mathjs\')();" on node.js, \n "var math = mathjs();" in the browser.')},o=t();for(var a in o)if(o.hasOwnProperty(a)){var s=o[a];"function"==typeof s?t[a]=i:Object.defineProperty&&Object.defineProperty(t,a,{get:i,set:i,enumerable:!0,configurable:!1}) +}"undefined"!=typeof window&&(window.math=t)},{"./chaining/Selector.js":2,"./constants.js":3,"./expression/Parser.js":4,"./expression/Scope.js":5,"./expression/docs/index.js":103,"./expression/node/index.js":116,"./function/arithmetic/abs.js":117,"./function/arithmetic/add.js":118,"./function/arithmetic/ceil.js":119,"./function/arithmetic/cube.js":120,"./function/arithmetic/divide.js":121,"./function/arithmetic/edivide.js":122,"./function/arithmetic/emultiply.js":123,"./function/arithmetic/epow.js":124,"./function/arithmetic/equal.js":125,"./function/arithmetic/exp.js":126,"./function/arithmetic/fix.js":127,"./function/arithmetic/floor.js":128,"./function/arithmetic/gcd.js":129,"./function/arithmetic/larger.js":130,"./function/arithmetic/largereq.js":131,"./function/arithmetic/lcm.js":132,"./function/arithmetic/log.js":133,"./function/arithmetic/log10.js":134,"./function/arithmetic/mod.js":135,"./function/arithmetic/multiply.js":136,"./function/arithmetic/pow.js":137,"./function/arithmetic/round.js":138,"./function/arithmetic/sign.js":139,"./function/arithmetic/smaller.js":140,"./function/arithmetic/smallereq.js":141,"./function/arithmetic/sqrt.js":142,"./function/arithmetic/square.js":143,"./function/arithmetic/subtract.js":144,"./function/arithmetic/unary.js":145,"./function/arithmetic/unequal.js":146,"./function/arithmetic/xgcd.js":147,"./function/complex/arg.js":148,"./function/complex/conj.js":149,"./function/complex/im.js":150,"./function/complex/re.js":151,"./function/construction/bignumber":152,"./function/construction/boolean.js":153,"./function/construction/complex.js":154,"./function/construction/index.js":155,"./function/construction/matrix.js":156,"./function/construction/number.js":157,"./function/construction/parser.js":158,"./function/construction/string.js":159,"./function/construction/unit.js":160,"./function/expression/eval.js":161,"./function/expression/help.js":162,"./function/expression/parse.js":163,"./function/matrix/concat.js":164,"./function/matrix/det.js":165,"./function/matrix/diag.js":166,"./function/matrix/eye.js":167,"./function/matrix/inv.js":168,"./function/matrix/ones.js":169,"./function/matrix/range.js":170,"./function/matrix/resize.js":171,"./function/matrix/size.js":172,"./function/matrix/squeeze.js":173,"./function/matrix/subset.js":174,"./function/matrix/transpose.js":175,"./function/matrix/zeros.js":176,"./function/probability/factorial.js":177,"./function/probability/random.js":178,"./function/statistics/max.js":179,"./function/statistics/mean.js":180,"./function/statistics/min.js":181,"./function/trigonometry/acos.js":182,"./function/trigonometry/asin.js":183,"./function/trigonometry/atan.js":184,"./function/trigonometry/atan2.js":185,"./function/trigonometry/cos.js":186,"./function/trigonometry/cot.js":187,"./function/trigonometry/csc.js":188,"./function/trigonometry/sec.js":189,"./function/trigonometry/sin.js":190,"./function/trigonometry/tan.js":191,"./function/units/in.js":192,"./function/utils/clone.js":193,"./function/utils/forEach.js":194,"./function/utils/format.js":195,"./function/utils/import.js":196,"./function/utils/map.js":197,"./function/utils/print.js":198,"./function/utils/select.js":199,"./function/utils/typeof.js":200,"./type/Complex":202,"./type/Help":203,"./type/Index":204,"./type/Matrix":205,"./type/Range":206,"./type/Unit":207,"./type/collection":208,"./type/error":209,"./util/object":214,"bignumber.js":217}],202:[function(e,n,t){function r(e,n){if(!(this instanceof r))throw new SyntaxError("Complex constructor must be called with the new operator");switch(arguments.length){case 0:this.re=0,this.im=0;break;case 2:if(!p(e)||!p(n))throw new TypeError("Two numbers expected in Complex constructor");this.re=e,this.im=n;break;default:if(0!=arguments.length&&2!=arguments.length)throw new SyntaxError("Two or zero arguments expected in Complex constructor")}}function i(){for(;" "==d||" "==d;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){x++,d=g.charAt(x)}function u(e){x=e,d=g.charAt(x)}function c(){var e,n="";if(e=x,"+"==d?s():"-"==d&&(n+=d,s()),!o(d))return u(e),null;if("."==d){if(n+=d,s(),!a(d))return u(e),null}else{for(;a(d);)n+=d,s();"."==d&&(n+=d,s())}for(;a(d);)n+=d,s();if("E"==d||"e"==d){if(n+=d,s(),("+"==d||"-"==d)&&(n+=d,s()),!a(d))return u(e),null;for(;a(d);)n+=d,s()}return n}function f(){var e=g.charAt(x+1);if("I"==d||"i"==d)return s(),"1";if(!("+"!=d&&"-"!=d||"I"!=e&&"i"!=e)){var n="+"==d?"1":"-1";return s(),s(),n}return null}var l=e("../util/index"),m=l.number,p=l.number.isNumber,h=l.string.isString;r.isComplex=function(e){return e instanceof r};var g,x,d;r.parse=function(e){if(g=e,x=-1,d="",!h(g))return null;s(),i();var n=c();if(n){if("I"==d||"i"==d)return s(),i(),d?null:new r(0,Number(n));i();var t=d;if("+"!=t&&"-"!=t)return i(),d?null:new r(Number(n),0);s(),i();var o=c();if(o){if("I"!=d&&"i"!=d)return null;s()}else if(o=f(),!o)return null;return"-"==t&&(o="-"==o[0]?"+"+o.substring(1):"-"+o),s(),i(),d?null:new r(Number(n),Number(o))}return(n=f())?(i(),d?null:new r(0,Number(n))):null},r.prototype.clone=function(){return new r(this.re,this.im)},r.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},r.prototype.format=function(e){var n="",t=m.format(this.re,e),r=m.format(this.im,e);return n=0==this.im?t:0==this.re?1==this.im?"i":-1==this.im?"-i":r+"i":this.im>0?1==this.im?t+" + i":t+" + "+r+"i":-1==this.im?t+" - i":t+" - "+r.substring(1)+"i"},r.prototype.toString=function(){return this.format()},n.exports=r,t.isComplex=r.isComplex,t.parse=r.parse},{"../util/index":212}],203:[function(e,n,t){function r(e,n){this.math=e,this.doc=n}var i=e("../util/index"),o=i.object,a=i.string;r.isHelp=function(e){return e instanceof r},r.prototype.toString=function(){var e=this.doc||{},n="\n";if(e.name&&(n+="Name: "+e.name+"\n\n"),e.category&&(n+="Category: "+e.category+"\n\n"),e.description&&(n+="Description:\n "+e.description+"\n\n"),e.syntax&&(n+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){var t=this.math.parser();n+="Examples:\n";for(var i=0;ie;e++){var t=arguments[e];if(t instanceof a)this._ranges.push(t);else if(t&&(t=t.valueOf()),f(t))this._ranges.push(i(t));else{if(!u(t))throw new TypeError("Range expected as Array, Number, or String");this._ranges.push(i([t,t+1]))}}}function i(e){for(var n=e.length,t=0;n>t;t++)if(!u(e[t])||!c(e[t]))throw new TypeError("Index parameters must be integer numbers");switch(e.length){case 2:return new a(e[0],e[1]);case 3:return new a(e[0],e[1],e[2]);default:throw new SyntaxError("Wrong number of arguments in Index (2 or 3 expected)")}}{var o=e("../util/index"),a=e("./Range"),s=o.number,u=s.isNumber,c=s.isInteger,f=Array.isArray;o.array.validateIndex}r.prototype.clone=function(){var e=new r;return e._ranges=o.object.clone(this._ranges),e},r.isIndex=function(e){return e instanceof r},r.create=function(e){var n=new r;return r.apply(n,e),n},r.prototype.size=function l(){for(var l=[],e=0,n=this._ranges.length;n>e;e++){var t=this._ranges[e];l[e]=t.size()[0]}return l},r.prototype.max=function(){for(var e=[],n=0,t=this._ranges.length;t>n;n++){var r=this._ranges[n];e[n]=r.max()}return e},r.prototype.min=function(){for(var e=[],n=0,t=this._ranges.length;t>n;n++){var r=this._ranges[n];e[n]=r.min()}return e},r.prototype.forEach=function(e){for(var n=0,t=this._ranges.length;t>n;n++)e(this._ranges[n],n,this)},r.prototype.range=function(e){return this._ranges[e]},r.prototype.isScalar=function(){for(var e=this.size(),n=0,t=e.length;t>n;n++)if(1!==e[n])return!1;return!0},r.prototype.toArray=function(){for(var e=[],n=0,t=this._ranges.length;t>n;n++){var r=this._ranges[n],i=[],o=r.start,a=r.end,s=r.step;if(s>0)for(;a>o;)i.push(o),o+=s;else if(0>s)for(;o>a;)i.push(o),o+=s;e.push(i)}return e},r.prototype.valueOf=r.prototype.toArray,r.prototype.toString=function(){for(var e=[],n=0,t=this._ranges.length;t>n;n++){var r=this._ranges[n],i=s.format(r.start);1!=r.step&&(i+=":"+s.format(r.step)),i+=":"+s.format(r.end),e.push(i)}return"["+e.join(",")+"]"},n.exports=r,t.isIndex=r.isIndex,t.create=r.create},{"../util/index":212,"./Range":206}],205:[function(e,n,t){function r(e){if(!(this instanceof r))throw new SyntaxError("Matrix constructor must be called with the new operator");if(e instanceof r)this._data=e.clone()._data;else if(h(e))this._data=e;else{if(null!=e)throw new TypeError("Unsupported type of data ("+c.types.type(e)+")");this._data=[]}this._size=m.size(this._data)}function i(e,n){if(!(n instanceof f))throw new TypeError("Invalid index");var t=n.isScalar();if(t)return e.get(n.min());var i=n.size();if(i.length!=e._size.length)throw new RangeError("Dimension mismatch ("+i.length+" != "+e._size.length+")");for(var a=new r(o(e._data,n,i.length,0));h(a._data)&&1==a._data.length;)a._data=a._data[0],a._size.shift();return a}function o(e,n,t,r){var i=r==t-1,a=n.range(r);return i?a.map(function(n){return g(n,e.length),e[n]}):a.map(function(i){g(i,e.length);var a=e[i];return o(a,n,t,r+1)})}function a(e,n,t,i){if(!(n instanceof f))throw new TypeError("Invalid index");var o,a=n.size(),c=n.isScalar();if(t instanceof r?(o=t.size(),t=t.valueOf()):o=m.size(t),c){if(0!=o.length)throw new TypeError("Scalar value expected");e.set(n.min(),t,i)}else{if(a.lengthh;h++)t=[t],o.unshift(1);if(!p.deepEqual(a,o))throw new RangeError("Dimensions mismatch ("+l.format(a)+" != "+l.format(o)+")");var x=n.max().map(function(e){return e+1});u(e,x,i);var d=a.length,y=0;s(e._data,n,t,d,y)}return e}function s(e,n,t,r,i){var o=i==r-1,a=n.range(i);o?a.forEach(function(n,r){g(n),e[n]=t[r]}):a.forEach(function(o,a){g(o),s(e[o],n,t[a],r,i+1)})}function u(e,n,t){if(!h(n))throw new Error("Array expected");for(var r=p.clone(e._size),i=!1;r.lengtho;o++)n[o]>r[o]&&(r[o]=n[o],i=!0);i&&e.resize(r,t)}var c=e("../util/index"),f=e("./Index"),l=(c.number,c.string),m=c.array,p=c.object,h=Array.isArray,g=m.validateIndex;r.isMatrix=function(e){return e instanceof r},r.prototype.subset=function(e,n,t){switch(arguments.length){case 1:return i(this,e);case 2:case 3:return a(this,e,n,t);default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.get=function(e){if(!h(e))throw new Error("Array expected");if(e.length!=this._size.length)throw new RangeError("Dimension mismatch ("+e.length+" != "+this._size.length+")");for(var n=this._data,t=0,r=e.length;r>t;t++){var i=e[t];g(i,n.length),n=n[i]}return p.clone(n)},r.prototype.set=function(e,n,t){var r,i;if(!h(e))throw new Error("Array expected");if(e.lengthr;r++){var s=e[r];g(s,a.length),a=a[s]}return s=e[e.length-1],g(s,a.length),a[s]=n,this},r.prototype.resize=function(e,n){return this._size=p.clone(e),this._data=m.resize(this._data,this._size,n),this},r.prototype.clone=function(){var e=new r;return e._data=p.clone(this._data),e._size=p.clone(this._size),e},r.prototype.size=function(){return this._size},r.prototype.map=function(e){var n=this,t=new r,i=[],o=function(t,r){return h(t)?t.map(function(e,n){return i[r]=n,o(e,r+1)}):e(t,i,n)};return t._data=o(this._data,0),t._size=p.clone(this._size),t},r.prototype.forEach=function(e){var n=this,t=[],r=function(i,o){h(i)?i.forEach(function(e,n){t[o]=n,r(e,o+1)}):e(i,t,n)};r(this._data,0)},r.prototype.toArray=function(){return p.clone(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return l.format(this._data,e)},r.prototype.toString=function(){return l.format(this._data)},n.exports=r,t.isMatrix=r.isMatrix},{"../util/index":212,"./Index":204}],206:[function(e,n,t){function r(e,n,t){if(!(this instanceof r))throw new SyntaxError("Range constructor must be called with the new operator");if(null!=e&&!o.isNumber(e))throw new TypeError("Parameter start must be a number");if(null!=n&&!o.isNumber(n))throw new TypeError("Parameter end must be a number");if(null!=t&&!o.isNumber(t))throw new TypeError("Parameter step must be a number");this.start=null!=e?parseFloat(e):0,this.end=null!=n?parseFloat(n):0,this.step=null!=t?parseFloat(t):1}{var i=e("../util/index"),o=i.number,a=i.string;i.array}r.parse=function(e){if(!a.isString(e))return null;var n=e.split(":"),t=n.map(function(e){return parseFloat(e)}),i=t.some(function(e){return isNaN(e)});if(i)return null;switch(t.length){case 2:return new r(t[0],t[1]);case 3:return new r(t[0],t[2],t[1]);default:return null}},r.prototype.clone=function(){return new r(this.start,this.end,this.step)},r.isRange=function(e){return e instanceof r},r.prototype.size=function(){var e=0,n=this.start,t=this.step,r=this.end,i=r-n;return o.sign(t)==o.sign(i)?e=Math.ceil(i/t):0==i&&(e=0),isNaN(e)&&(e=0),[e]},r.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},r.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},r.prototype.forEach=function(e){var n=this.start,t=this.step,r=this.end,i=0;if(t>0)for(;r>n;)e(n,i,this),n+=t,i++;else if(0>t)for(;n>r;)e(n,i,this),n+=t,i++},r.prototype.map=function(e){var n=[];return this.forEach(function(t,r,i){n[r]=e(t,r,i)}),n},r.prototype.toArray=function(){var e=[];return this.forEach(function(n,t){e[t]=n}),e},r.prototype.valueOf=function(){return this.toArray()},r.prototype.format=function(e){var n=o.format(this.start,e);return 1!=this.step&&(n+=":"+o.format(this.step,e)),n+=":"+o.format(this.end,e)},r.prototype.toString=function(){return this.format()},n.exports=r,t.isRange=r.isRange,t.parse=r.parse},{"../util/index":212}],207:[function(e,n,t){function r(e,n){if(!(this instanceof r))throw new Error("Unit constructor must be called with the new operator");if(null!=e&&!y(e))throw new TypeError("First parameter in Unit constructor must be a number");if(null!=n&&!b(n))throw new TypeError("Second parameter in Unit constructor must be a string");if(null!=n){var t=l(n);if(!t)throw new SyntaxError('String "'+n+'" is no unit');this.unit=t.unit,this.prefix=t.prefix}else this.unit=UNIT_NONE,this.prefix=w;null!=e?(this.value=this._normalize(e),this.fixPrefix=!1):(this.value=null,this.fixPrefix=!0)}function i(){for(;" "==h||" "==h;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){p++,h=m.charAt(p)}function u(e){p=e,h=m.charAt(p)}function c(){var e,n="";if(e=p,"+"==h?s():"-"==h&&(n+=h,s()),!o(h))return u(e),null;if("."==h){if(n+=h,s(),!a(h))return u(e),null}else{for(;a(h);)n+=h,s();"."==h&&(n+=h,s())}for(;a(h);)n+=h,s();if("E"==h||"e"==h){if(n+=h,s(),("+"==h||"-"==h)&&(n+=h,s()),!a(h))return u(e),null;for(;a(h);)n+=h,s()}return n}function f(){var e="";for(i();h&&" "!=h&&" "!=h;)e+=h,s();return e||null}function l(e){for(var n=0,t=N.length;t>n;n++){var r=N[n];if(d.endsWith(e,r.name)){var i=e.length-r.name.length,o=e.substring(0,i),a=r.prefixes[o];if(void 0!==a)return{unit:r,prefix:a}}}return null}var m,p,h,g=e("../util/index"),x=g.number,d=g.string,y=g.number.isNumber,b=g.string.isString;r.parse=function(e){if(m=e,p=-1,h="",!b(m))return null;s(),i();var n,t=c();return t?(n=f(),s(),i(),h?null:t&&n?new r(Number(t),n):null):(n=f(),s(),i(),h?null:new r(null,n))},r.isUnit=function(e){return e instanceof r},r.prototype.clone=function(){var e=new r;for(var n in this)this.hasOwnProperty(n)&&(e[n]=this[n]);return e},r.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},r.prototype._unnormalize=function(e,n){return void 0==n?e/this.unit.value/this.prefix.value-this.unit.offset:e/this.unit.value/n-this.unit.offset},r.isPlainUnit=function(e){return null!=l(e)},r.prototype.hasBase=function(e){return void 0===this.unit.base?void 0===e:this.unit.base===e},r.prototype.equalBase=function(e){return this.unit.base===e.unit.base},r.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},r.prototype["in"]=function(e){var n;if(b(e)){if(n=new r(null,e),!this.equalBase(n))throw new Error("Units do not match");return n.value=this.value,n}if(e instanceof r){if(!this.equalBase(e))throw new Error("Units do not match");if(null!=e.value)throw new Error("Cannot convert to a unit with a value");if(null==e.unit)throw new Error("Unit expected on the right hand side of function in");return n=e.clone(),n.value=this.value,n.fixPrefix=!0,n}throw new Error("String or Unit expected as parameter")},r.prototype.toNumber=function(e){var n=this["in"](e),t=this.fixPrefix?n._bestPrefix():n.prefix;return n._unnormalize(n.value,t.value)},r.prototype.toString=function(){return this.format()},r.prototype.format=function(e){var n,t;if(this.fixPrefix)n=this._unnormalize(this.value),t=null!=this.value?x.format(n,e)+" ":"",t+=this.prefix.name+this.unit.name;else{var r=this._bestPrefix();n=this._unnormalize(this.value,r.value),t=null!=this.value?x.format(n,e)+" ":"",t+=r.name+this.unit.name}return t},r.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),n=w,t=Math.abs(Math.log(e/n.value)/Math.LN10-1.2),r=this.unit.prefixes;for(var i in r)if(r.hasOwnProperty(i)){var o=r[i];if(o.scientific){var a=Math.abs(Math.log(e/o.value)/Math.LN10-1.2);t>a&&(n=o,t=a)}}return n};var v={NONE:{"":{name:"",value:1,scientific:!0}},SHORT:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:10,scientific:!1},h:{name:"h",value:100,scientific:!1},k:{name:"k",value:1e3,scientific:!0},M:{name:"M",value:1e6,scientific:!0},G:{name:"G",value:1e9,scientific:!0},T:{name:"T",value:1e12,scientific:!0},P:{name:"P",value:1e15,scientific:!0},E:{name:"E",value:1e18,scientific:!0},Z:{name:"Z",value:1e21,scientific:!0},Y:{name:"Y",value:1e24,scientific:!0},d:{name:"d",value:.1,scientific:!1},c:{name:"c",value:.01,scientific:!1},m:{name:"m",value:.001,scientific:!0},u:{name:"u",value:1e-6,scientific:!0},n:{name:"n",value:1e-9,scientific:!0},p:{name:"p",value:1e-12,scientific:!0},f:{name:"f",value:1e-15,scientific:!0},a:{name:"a",value:1e-18,scientific:!0},z:{name:"z",value:1e-21,scientific:!0},y:{name:"y",value:1e-24,scientific:!0}},LONG:{"":{name:"",value:1,scientific:!0},deca:{name:"deca",value:10,scientific:!1},hecto:{name:"hecto",value:100,scientific:!1},kilo:{name:"kilo",value:1e3,scientific:!0},mega:{name:"mega",value:1e6,scientific:!0},giga:{name:"giga",value:1e9,scientific:!0},tera:{name:"tera",value:1e12,scientific:!0},peta:{name:"peta",value:1e15,scientific:!0},exa:{name:"exa",value:1e18,scientific:!0},zetta:{name:"zetta",value:1e21,scientific:!0},yotta:{name:"yotta",value:1e24,scientific:!0},deci:{name:"deci",value:.1,scientific:!1},centi:{name:"centi",value:.01,scientific:!1},milli:{name:"milli",value:.001,scientific:!0},micro:{name:"micro",value:1e-6,scientific:!0},nano:{name:"nano",value:1e-9,scientific:!0},pico:{name:"pico",value:1e-12,scientific:!0},femto:{name:"femto",value:1e-15,scientific:!0},atto:{name:"atto",value:1e-18,scientific:!0},zepto:{name:"zepto",value:1e-21,scientific:!0},yocto:{name:"yocto",value:1e-24,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},k:{name:"k",value:1024,scientific:!0},M:{name:"M",value:Math.pow(1024,2),scientific:!0},G:{name:"G",value:Math.pow(1024,3),scientific:!0},T:{name:"T",value:Math.pow(1024,4),scientific:!0},P:{name:"P",value:Math.pow(1024,5),scientific:!0},E:{name:"E",value:Math.pow(1024,6),scientific:!0},Z:{name:"Z",value:Math.pow(1024,7),scientific:!0},Y:{name:"Y",value:Math.pow(1024,8),scientific:!0},Ki:{name:"Ki",value:1024,scientific:!0},Mi:{name:"Mi",value:Math.pow(1024,2),scientific:!0},Gi:{name:"Gi",value:Math.pow(1024,3),scientific:!0},Ti:{name:"Ti",value:Math.pow(1024,4),scientific:!0},Pi:{name:"Pi",value:Math.pow(1024,5),scientific:!0},Ei:{name:"Ei",value:Math.pow(1024,6),scientific:!0},Zi:{name:"Zi",value:Math.pow(1024,7),scientific:!0},Yi:{name:"Yi",value:Math.pow(1024,8),scientific:!0}},BINARY_LONG:{"":{name:"",value:1,scientific:!0},kilo:{name:"kilo",value:1024,scientific:!0},mega:{name:"mega",value:Math.pow(1024,2),scientific:!0},giga:{name:"giga",value:Math.pow(1024,3),scientific:!0},tera:{name:"tera",value:Math.pow(1024,4),scientific:!0},peta:{name:"peta",value:Math.pow(1024,5),scientific:!0},exa:{name:"exa",value:Math.pow(1024,6),scientific:!0},zetta:{name:"zetta",value:Math.pow(1024,7),scientific:!0},yotta:{name:"yotta",value:Math.pow(1024,8),scientific:!0},kibi:{name:"kibi",value:1024,scientific:!0},mebi:{name:"mebi",value:Math.pow(1024,2),scientific:!0},gibi:{name:"gibi",value:Math.pow(1024,3),scientific:!0},tebi:{name:"tebi",value:Math.pow(1024,4),scientific:!0},pebi:{name:"pebi",value:Math.pow(1024,5),scientific:!0},exi:{name:"exi",value:Math.pow(1024,6),scientific:!0},zebi:{name:"zebi",value:Math.pow(1024,7),scientific:!0},yobi:{name:"yobi",value:Math.pow(1024,8),scientific:!0}}},w={name:"",value:1,scientific:!0},E={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}};BASE_UNIT_NONE={},UNIT_NONE={name:"",base:BASE_UNIT_NONE,value:1,offset:0};var N=[{name:"meter",base:E.LENGTH,prefixes:v.LONG,value:1,offset:0},{name:"inch",base:E.LENGTH,prefixes:v.NONE,value:.0254,offset:0},{name:"foot",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},{name:"yard",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},{name:"mile",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},{name:"link",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},{name:"rod",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},{name:"chain",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},{name:"angstrom",base:E.LENGTH,prefixes:v.NONE,value:1e-10,offset:0},{name:"m",base:E.LENGTH,prefixes:v.SHORT,value:1,offset:0},{name:"ft",base:E.LENGTH,prefixes:v.NONE,value:.3048,offset:0},{name:"yd",base:E.LENGTH,prefixes:v.NONE,value:.9144,offset:0},{name:"mi",base:E.LENGTH,prefixes:v.NONE,value:1609.344,offset:0},{name:"li",base:E.LENGTH,prefixes:v.NONE,value:.201168,offset:0},{name:"rd",base:E.LENGTH,prefixes:v.NONE,value:5.02921,offset:0},{name:"ch",base:E.LENGTH,prefixes:v.NONE,value:20.1168,offset:0},{name:"mil",base:E.LENGTH,prefixes:v.NONE,value:254e-7,offset:0},{name:"m2",base:E.SURFACE,prefixes:v.SHORT,value:1,offset:0},{name:"sqin",base:E.SURFACE,prefixes:v.NONE,value:64516e-8,offset:0},{name:"sqft",base:E.SURFACE,prefixes:v.NONE,value:.09290304,offset:0},{name:"sqyd",base:E.SURFACE,prefixes:v.NONE,value:.83612736,offset:0},{name:"sqmi",base:E.SURFACE,prefixes:v.NONE,value:2589988.110336,offset:0},{name:"sqrd",base:E.SURFACE,prefixes:v.NONE,value:25.29295,offset:0},{name:"sqch",base:E.SURFACE,prefixes:v.NONE,value:404.6873,offset:0},{name:"sqmil",base:E.SURFACE,prefixes:v.NONE,value:6.4516e-10,offset:0},{name:"m3",base:E.VOLUME,prefixes:v.SHORT,value:1,offset:0},{name:"L",base:E.VOLUME,prefixes:v.SHORT,value:.001,offset:0},{name:"litre",base:E.VOLUME,prefixes:v.LONG,value:.001,offset:0},{name:"cuin",base:E.VOLUME,prefixes:v.NONE,value:16387064e-12,offset:0},{name:"cuft",base:E.VOLUME,prefixes:v.NONE,value:.028316846592,offset:0},{name:"cuyd",base:E.VOLUME,prefixes:v.NONE,value:.764554857984,offset:0},{name:"teaspoon",base:E.VOLUME,prefixes:v.NONE,value:5e-6,offset:0},{name:"tablespoon",base:E.VOLUME,prefixes:v.NONE,value:15e-6,offset:0},{name:"minim",base:E.VOLUME,prefixes:v.NONE,value:6.161152e-8,offset:0},{name:"fluiddram",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},{name:"fluidounce",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},{name:"gill",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},{name:"cup",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},{name:"pint",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},{name:"quart",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},{name:"gallon",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},{name:"beerbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},{name:"oilbarrel",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},{name:"hogshead",base:E.VOLUME,prefixes:v.NONE,value:.238481,offset:0},{name:"fldr",base:E.VOLUME,prefixes:v.NONE,value:36966911e-13,offset:0},{name:"floz",base:E.VOLUME,prefixes:v.NONE,value:2957353e-11,offset:0},{name:"gi",base:E.VOLUME,prefixes:v.NONE,value:.0001182941,offset:0},{name:"cp",base:E.VOLUME,prefixes:v.NONE,value:.0002365882,offset:0},{name:"pt",base:E.VOLUME,prefixes:v.NONE,value:.0004731765,offset:0},{name:"qt",base:E.VOLUME,prefixes:v.NONE,value:.0009463529,offset:0},{name:"gal",base:E.VOLUME,prefixes:v.NONE,value:.003785412,offset:0},{name:"bbl",base:E.VOLUME,prefixes:v.NONE,value:.1173478,offset:0},{name:"obl",base:E.VOLUME,prefixes:v.NONE,value:.1589873,offset:0},{name:"g",base:E.MASS,prefixes:v.SHORT,value:.001,offset:0},{name:"gram",base:E.MASS,prefixes:v.LONG,value:.001,offset:0},{name:"ton",base:E.MASS,prefixes:v.SHORT,value:907.18474,offset:0},{name:"tonne",base:E.MASS,prefixes:v.SHORT,value:1e3,offset:0},{name:"grain",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},{name:"dram",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},{name:"ounce",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},{name:"poundmass",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},{name:"hundredweight",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},{name:"stick",base:E.MASS,prefixes:v.NONE,value:.115,offset:0},{name:"gr",base:E.MASS,prefixes:v.NONE,value:6479891e-11,offset:0},{name:"dr",base:E.MASS,prefixes:v.NONE,value:.0017718451953125,offset:0},{name:"oz",base:E.MASS,prefixes:v.NONE,value:.028349523125,offset:0},{name:"lbm",base:E.MASS,prefixes:v.NONE,value:.45359237,offset:0},{name:"cwt",base:E.MASS,prefixes:v.NONE,value:45.359237,offset:0},{name:"s",base:E.TIME,prefixes:v.SHORT,value:1,offset:0},{name:"min",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"h",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"seconds",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"second",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"sec",base:E.TIME,prefixes:v.LONG,value:1,offset:0},{name:"minutes",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"minute",base:E.TIME,prefixes:v.NONE,value:60,offset:0},{name:"hours",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"hour",base:E.TIME,prefixes:v.NONE,value:3600,offset:0},{name:"day",base:E.TIME,prefixes:v.NONE,value:86400,offset:0},{name:"days",base:E.TIME,prefixes:v.NONE,value:86400,offset:0},{name:"rad",base:E.ANGLE,prefixes:v.NONE,value:1,offset:0},{name:"deg",base:E.ANGLE,prefixes:v.NONE,value:.017453292519943295,offset:0},{name:"grad",base:E.ANGLE,prefixes:v.NONE,value:.015707963267948967,offset:0},{name:"cycle",base:E.ANGLE,prefixes:v.NONE,value:6.283185307179586,offset:0},{name:"A",base:E.CURRENT,prefixes:v.SHORT,value:1,offset:0},{name:"ampere",base:E.CURRENT,prefixes:v.LONG,value:1,offset:0},{name:"K",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},{name:"degC",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},{name:"degF",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},{name:"degR",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},{name:"kelvin",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:0},{name:"celsius",base:E.TEMPERATURE,prefixes:v.NONE,value:1,offset:273.15},{name:"fahrenheit",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:459.67},{name:"rankine",base:E.TEMPERATURE,prefixes:v.NONE,value:1/1.8,offset:0},{name:"mol",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},{name:"mole",base:E.AMOUNT_OF_SUBSTANCE,prefixes:v.NONE,value:1,offset:0},{name:"cd",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},{name:"candela",base:E.LUMINOUS_INTENSITY,prefixes:v.NONE,value:1,offset:0},{name:"N",base:E.FORCE,prefixes:v.SHORT,value:1,offset:0},{name:"newton",base:E.FORCE,prefixes:v.LONG,value:1,offset:0},{name:"lbf",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},{name:"poundforce",base:E.FORCE,prefixes:v.NONE,value:4.4482216152605,offset:0},{name:"b",base:E.BIT,prefixes:v.BINARY_SHORT,value:1,offset:0},{name:"bits",base:E.BIT,prefixes:v.BINARY_LONG,value:1,offset:0},{name:"B",base:E.BIT,prefixes:v.BINARY_SHORT,value:8,offset:0},{name:"bytes",base:E.BIT,prefixes:v.BINARY_LONG,value:8,offset:0}];r.PREFIXES=v,r.BASE_UNITS=E,r.UNITS=N,n.exports=r,t.isUnit=r.isUnit,t.isPlainUnit=r.isPlainUnit,t.parse=r.parse},{"../util/index":212}],208:[function(e,n,t){function r(e,n,t){var o,a,u,c;if(0>=n){if(s(e[0])){for(c=i(e),a=[],o=0;ot;t++){var a=[];for(n=0;r>n;n++)a.push(e[n][t]);o.push(a)}return o}{var o=e("../util/index"),a=e("./Matrix"),s=o.array.isArray;o.string.isString}t.argsToArray=function(e){var n;return 0==e.length?n=[]:1==e.length?(n=e[0],n instanceof a&&(n=n.valueOf()),s(n)||(n=[n])):n=Array.prototype.slice.apply(e),n},t.isCollection=function(e){return s(e)||e instanceof a},t.deepMap=function u(e,n){return e&&"function"==typeof e.map?e.map(function(e){return u(e,n)}):n(e)},t.deepMap2=function c(e,n,t){var r,i,o;if(s(e))if(s(n)){if(e.length!=n.length)throw new RangeError("Dimension mismatch ("+e.length+" != "+n.length+")");for(r=[],i=e.length,o=0;i>o;o++)r[o]=c(e[o],n[o],t)}else{if(n instanceof a)return r=c(e,n.valueOf(),t),new a(r);for(r=[],i=e.length,o=0;i>o;o++)r[o]=c(e[o],n,t)}else{if(e instanceof a)return n instanceof a?(r=c(e.valueOf(),n.valueOf(),t),new a(r)):(r=c(e.valueOf(),n,t),new a(r));if(s(n))for(r=[],i=n.length,o=0;i>o;o++)r[o]=c(e,n[o],t);else{if(n instanceof a)return r=c(e,n.valueOf(),t),new a(r);r=t(e,n)}}return r},t.reduce=function(e,n,t){return e instanceof a?new a(r(e.valueOf(),n,t)):r(e,n,t)},t.deepForEach=function f(e,n){e instanceof a&&(e=e.valueOf());for(var t=0,r=e.length;r>t;t++){var i=e[t];s(i)?f(i,n):n(i)}}},{"../util/index":212,"./Matrix":205}],209:[function(e,n){n.exports=function(n){var t=(e("./../util/types"),{});n.error=t,t.UnsupportedTypeError=function(e,t){if(2==arguments.length){var r=n["typeof"](t);this.message="Function "+e+"("+r+") not supported"}else if(arguments.length>2){var i=Array.prototype.splice.call(arguments,1),o=i.map(function(e){return n["typeof"](e)});this.message="Function "+e+"("+o.join(", ")+") not supported"}else this.message="Unsupported type of argument in function "+e},t.UnsupportedTypeError.prototype=new TypeError,t.UnsupportedTypeError.prototype.name="UnsupportedTypeError",t.ArgumentsError=function(e,n,t,r){this.message="Wrong number of arguments in function "+e+" ("+n+" provided, "+t+(void 0!=r?"-"+r:"")+" expected)"},t.ArgumentsError.prototype=new SyntaxError,t.ArgumentsError.prototype.name="ArgumentError"}},{"./../util/types":216}],210:[function(e,n,t){function r(e){for(var n=[];c(e);)n.push(e.length),e=e[0];return n}function i(e,n,t){var r,o=e.length;if(o!=n[t])throw new RangeError("Dimension mismatch ("+o+" != "+n[t]+")");if(tr;r++){var s=e[r];if(!c(s))throw new RangeError("Dimension mismatch ("+(n.length-1)+" < "+n.length+")");i(e[r],n,a)}}else for(r=0;o>r;r++)if(c(e[r]))throw new RangeError("Dimension mismatch ("+(n.length+1)+" > "+n.length+")")}function o(e,n,t,r){if(!c(e))throw Error("Array expected"); +var i,a,s=e.length,f=n[t],l=Math.min(s,f);if(e.length=f,ti;i++)a=e[i],o(a,n,m,r);for(i=l;f>i;i++)a=[],e[i]=a,o(a,n,m,r)}else if(void 0!==r)for(i=s;f>i;i++)e[i]=u.clone(r)}var a=e("./number"),s=e("./string"),u=e("./object"),c=(e("./types"),Array.isArray);t.size=function(e){var n=r(e);return t.validate(e,n),n},t.validate=function(e,n){var t=0==n.length;if(t){if(c(e))throw new RangeError("Dimension mismatch ("+e.length+" != 0)")}else i(e,n,0)},t.validateIndex=function(e,n){if(!a.isNumber(e)||!a.isInteger(e))throw new TypeError("Index must be an integer (value: "+e+")");if(0>e)throw new RangeError("Index out of range ("+e+" < 0)");if(void 0!==n&&e>=n)throw new RangeError("Index out of range ("+e+" > "+(n-1)+")")},t.resize=function(e,n,t){if(!c(e)||!c(n))throw new TypeError("Array expected");if(0===n.length)throw new Error("Resizing to scalar is not supported");n.forEach(function(e){if(!a.isNumber(e)||!a.isInteger(e)||0>e)throw new TypeError("Invalid size, must contain positive integers (size: "+s.format(n)+")")});for(var r=1,i=e[0];c(i);)r++,i=i[0];for(;rn.length;)e=e[0],r--;return o(e,n,0,t),e},t.squeeze=function(e){for(;c(e)&&1===e.length;)e=e[0];return e},t.unsqueeze=function(e,n){for(var r=t.size(e),i=0,o=n-r.length;o>i;i++)e=[e];return e},t.isArray=c},{"./number":213,"./object":214,"./string":215,"./types":216}],211:[function(e,n,t){t.isBoolean=function(e){return e instanceof Boolean||"boolean"==typeof e}},{}],212:[function(e,n,t){t.array=e("./array"),t.boolean=e("./boolean"),t.number=e("./number"),t.object=e("./object"),t.string=e("./string"),t.types=e("./types")},{"./array":210,"./boolean":211,"./number":213,"./object":214,"./string":215,"./types":216}],213:[function(e,n,t){function r(e){return e instanceof o?e.isZero():0===e}function i(e,n,t){var r;return e instanceof o?(r=e.abs(),r.gte(n)&&r.lt(t)):(r=Math.abs(e),r>=n&&t>r)}var o=e("bignumber.js");t.isNumber=function(e){return e instanceof Number||"number"==typeof e},t.isInteger=function(e){return e==Math.round(e)},t.sign=function(e){return e>0?1:0>e?-1:0},t.format=function(e,n){if("function"==typeof n)return n(e);if(1/0===e)return"Infinity";if(e===-1/0)return"-Infinity";if(isNaN(e))return"NaN";var a="auto",s=void 0;switch(void 0!==n&&(n.notation&&(a=n.notation),n&&(t.isNumber(n)?s=n:n.precision&&(s=n.precision))),a){case"fixed":return t.toFixed(e,s);case"scientific":throw new Error('Format notation "scientific" is deprecated. Use "exponential" instead.');case"exponential":return t.toExponential(e,s);case"auto":var u=.001,c=1e5;if(n&&n.exponential)void 0!==n.exponential.lower&&(u=n.exponential.lower),void 0!==n.exponential.upper&&(c=n.exponential.upper);else if(n&&n.scientific)throw new Error("options.scientific is deprecated, use options.exponential instead.");var f=e instanceof o;if(f){var l=o.config().EXPONENTIAL_AT;o.config({EXPONENTIAL_AT:[Math.round(Math.log(u)/Math.LN10),Math.round(Math.log(c)/Math.LN10)]})}if(r(e))return"0";var m;return m=i(e,u,c)?f?new o(e.toPrecision(s)).toString():parseFloat(e.toPrecision(s?Math.min(s,21):s))+"":t.toExponential(e,s),f&&o.config({EXPONENTIAL_AT:l}),m.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],n=arguments[4];return"."!==e?e+n:n});default:throw new Error('Unknown notation "'+a+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,n){return void 0!==n?e instanceof o?e.toExponential(n-1):e.toExponential(Math.min(n-1,20)):e.toExponential()},t.toFixed=function(e,n){return e instanceof o?e.toFixed(n||0):e.toFixed(Math.min(n,20))},t.digits=function(e){return e.toExponential().replace(/e[\+\-0-9]*$/,"").replace(/^0\.0*|\./,"").length},t.toBigNumber=function(e){return t.digits(e)>15?e:new o(e)},t.toNumber=function(e){return parseFloat(e.valueOf())}},{"bignumber.js":217}],214:[function(e,n,t){var r=e("./number"),i=e("./string"),o=e("./boolean");t.clone=function a(e){if(null==e)return e;if("function"==typeof e.clone)return e.clone();if(r.isNumber(e)||i.isString(e)||o.isBoolean(e))return e;if(Array.isArray(e))return e.map(function(e){return a(e)});if(e instanceof Object){var n={};for(var t in e)e.hasOwnProperty(t)&&(n[t]=a(e[t]));return e}throw new TypeError("Cannot clone "+e)},t.extend=function(e,n){for(var t in n)n.hasOwnProperty(t)&&(e[t]=n[t]);return e},t.deepExtend=function s(e,n){for(var t in n)n.hasOwnProperty(t)&&(n[t]&&n[t].constructor===Object?(void 0===e[t]&&(e[t]={}),e[t].constructor===Object?s(e[t],n[t]):e[t]=n[t]):e[t]=n[t]);return e},t.deepEqual=function(e,n){var r,i,o;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!=n.length)return!1;for(i=0,o=e.length;o>i;i++)if(!t.deepEqual(e[i],n[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(n)||!(n instanceof Object))return!1;for(r in e)if(e.hasOwnProperty(r)&&!t.deepEqual(e[r],n[r]))return!1;for(r in n)if(n.hasOwnProperty(r)&&!t.deepEqual(e[r],n[r]))return!1;return!0}return e==n}},{"./boolean":211,"./number":213,"./string":215}],215:[function(e,n,t){function r(e,n){if(Array.isArray(e)){for(var i="[",o=e.length,a=0;o>a;a++)0!=a&&(i+=", "),i+=r(e[a],n);return i+="]"}return t.format(e,n)}var i=e("./number"),o=e("bignumber.js");t.isString=function(e){return e instanceof String||"string"==typeof e},t.endsWith=function(e,n){var t=e.length-n.length,r=e.length;return e.substring(t,r)===n},t.format=function(e,n){return i.isNumber(e)||e instanceof o?i.format(e,n):Array.isArray(e)?r(e,n):t.isString(e)?'"'+e+'"':e instanceof Object?"function"==typeof e.format?e.format(n):e.toString():String(e)}},{"./number":213,"bignumber.js":217}],216:[function(e,n,t){t.type=function r(e){var r=typeof e;if("object"===r){if(null===e)return"null";if(e instanceof Boolean)return"boolean";if(e instanceof Number)return"number";if(e instanceof String)return"string";if(Array.isArray(e))return"array";if(e instanceof Date)return"date"}return r}},{}],217:[function(n,t){!function(n){"use strict";function r(e,n){var t,a,s,u,l,m,g=this;if(!(g instanceof r))return new r(e,n);if(e instanceof r){if(N=0,n===t)return g.s=e.s,g.e=e.e,g.c=(e=e.c)?e.slice():e,void 0;e+=""}if("string"!=typeof e&&(e=(s="number"==typeof e||"[object Number]"==Object.prototype.toString.call(e))&&0===e&&0>1/e?"-0":e+""),m=e,n===t&&M.test(e))g.s="-"==e.charAt(0)?(e=e.slice(1),-1):1;else{if(10==n)return c(e,p,h);if(e=j.call(e).replace(/^\+(?!-)/,""),g.s="-"==e.charAt(0)?(e=e.replace(/^-(?!-)/,""),-1):1,null!=n?n!=(0|n)&&b||(f=!(n>=2&&65>n))?(i(n,2),l=M.test(e)):(u="["+E.slice(0,n=0|n)+"]+",e=e.replace(/\.$/,"").replace(/^\./,"0."),(l=new RegExp("^"+u+"(?:\\."+u+")?$",37>n?"i":"").test(e))?(s&&(e.replace(/^0\.0*|\./,"").length>15&&i(m,0),s=!s),e=o(e,10,n,g.s)):"Infinity"!=e&&"NaN"!=e&&(i(m,1,n),e="NaN")):l=M.test(e),!l)return g.c=g.e=null,"Infinity"!=e&&("NaN"!=e&&i(m,3),g.s=null),N=0,void 0}for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(a=e.search(/e/i))>0?(0>t&&(t=a),t+=+e.slice(a+1),e=e.substring(0,a)):0>t&&(t=e.length),a=0;"0"==e.charAt(a);a++);if(n=e.length,s&&n>15&&e.slice(a).length>15&&i(m,0),N=0,(t-=a+1)>y)g.c=g.e=null;else if(a==n||d>t)g.c=[g.e=0];else{for(;"0"==e.charAt(--n););for(g.e=t,g.c=[],t=0;n>=a;g.c[t++]=+e.charAt(a++));}}function i(e,n,t,r,i,o){if(b){var a,s=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFr"][N?0>N?-N:N:0>1/N?1:0]+"()",u=f?" out of range":" not a"+(i?" non-zero":"n")+" integer";throw u=([s+" number type has more than 15 significant digits",s+" not a base "+t+" number",s+" base"+u,s+" not a number"][n]||t+"() "+n+(o?" not a boolean or binary digit":u+(r?" or not ["+(f?" negative, positive":" integer, integer")+" ]":"")))+": "+e,f=N=0,a=new Error(u),a.name="BigNumber Error",a}}function o(e,n,t,i){function o(e,r){var i,o,a=0,s=e.length,u=[0];for(r=r||t;s>a;a++){for(o=u.length,i=0;o>i;u[i]*=r,i++);for(u[0]+=E.indexOf(e.charAt(a)),i=0;in-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n^0,u[i]%=n)}return u.reverse()}function s(e){for(var n=0,t=e.length,r="";t>n;r+=E.charAt(e[n++]));return r}var u,c,f,l,m,p;if(37>t&&(e=e.toLowerCase()),(u=e.indexOf("."))>-1)if(u=e.length-u-1,c=o(new r(t).pow(u).toF(),10),l=e.split("."),f=o(l[1]),l=o(l[0]),p=a(f,c,f.length-c.length,i,n,1&l[l.length-1]),m=p.c,u=p.e){for(;++u;m.unshift(0));e=s(l)+"."+s(m)}else m[0]?l[u=l.length-1]M?0:M;v++f;f++){if(s!=(v=b.length))l=s>v?1:-1;else for(m=-1,l=0;++mb[m]?1:-1;break}if(!(0>l))break;for(c=v==s?n:h;v;){if(b[--v]M&&u(w,p,o,a,null!=b[0]),w.e>y?w.c=w.e=null:w.e++n&&u(e,i,10),i=0==o[0]?i+1:t?n:e.e+i+1;o.length=i)?(e.s<0&&o[0]?"-":"")+(o.length>1?(o.splice(1,0,"."),o.join("")):o[0])+(0>i?"e":"e+")+i:e.toS()}function u(e,n,t,r,i){var o=e.c,a=e.s<0,s=t/2,u=e.e+n+1,c=o[u],f=i||0>u||null!=o[u+1];if(i=4>h?(null!=c||f)&&(0==h||2==h&&!a||3==h&&a):c>s||c==s&&(4==h||f||6==h&&(1&o[u-1]||!n&&r)||7==h&&!a||8==h&&a),1>u||!o[0])return o.length=0,o.push(0),i?(o[0]=1,e.e=-n):e.e=0,e;if(o.length=u--,i)for(--t;++o[u]>t;)o[u]=0,u--||(++e.e,o.unshift(1));for(u=o.length;!o[--u];o.pop());return e}function c(e,n,t){var i=h;return h=t,e=new r(e),e.c&&u(e,n,10),h=i,e}var f,l=1e9,m=1e6,p=20,h=4,g=-7,x=21,x=21,d=-l,y=l,b=!0,v=parseInt,w=r.prototype,E="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",N=0,M=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,j=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},C=r(1);r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.config=function(){var e,n,t=0,r={},o=arguments,a=o[0],s="config",u=function(e,n,t){return!((f=n>e||e>t)||v(e)!=e&&0!==e)},c=a&&"object"==typeof a?function(){return a.hasOwnProperty(n)?null!=(e=a[n]):void 0}:function(){return o.length>t?null!=(e=o[t++]):void 0};return c(n="DECIMAL_PLACES")&&(u(e,0,l)?p=0|e:i(e,n,s)),r[n]=p,c(n="ROUNDING_MODE")&&(u(e,0,8)?h=0|e:i(e,n,s)),r[n]=h,c(n="EXPONENTIAL_AT")&&(u(e,-l,l)?g=-(x=~~(0>e?-e:+e)):!f&&e&&u(e[0],-l,0)&&u(e[1],0,l)?(g=~~e[0],x=~~e[1]):i(e,n,s,1)),r[n]=[g,x],c(n="RANGE")&&(u(e,-l,l)&&~~e?d=-(y=~~(0>e?-e:+e)):!f&&e&&u(e[0],-l,-1)&&u(e[1],1,l)?(d=~~e[0],y=~~e[1]):i(e,n,s,1,1)),r[n]=[d,y],c(n="ERRORS")&&(e===!!e||1===e||0===e?(f=N=0,v=(b=!!e)?parseInt:parseFloat):i(e,n,s,0,0,1)),r[n]=b,r},w.abs=w.absoluteValue=function(){var e=new r(this);return e.s<0&&(e.s=1),e},w.ceil=function(){return c(this,0,2)},w.comparedTo=w.cmp=function(e,n){var t,i=this,o=i.c,a=(N=-N,e=new r(e,n)).c,s=i.s,u=e.s,c=i.e,f=e.e;if(!s||!u)return null;if(t=o&&!o[0],n=a&&!a[0],t||n)return t?n?0:-u:s;if(s!=u)return s;if(t=0>s,n=c==f,!o||!a)return n?0:!o^t?1:-1;if(!n)return c>f^t?1:-1;for(s=-1,u=(c=o.length)<(f=a.length)?c:f;++sa[s]^t?1:-1;return c==f?0:c>f^t?1:-1},w.dividedBy=w.div=function(e,n){var t=this.c,i=this.e,o=this.s,s=(N=2,e=new r(e,n)).c,u=e.e,c=e.s,f=o==c?1:-1;return(i||t&&t[0])&&(u||s&&s[0])?a(t,s,i-u,f,10):new r(o&&c&&(t?!s||t[0]!=s[0]:s)?t&&0==t[0]||!s?0*f:f/0:0/0)},w.equals=w.eq=function(e,n){return N=3,0===this.cmp(e,n)},w.floor=function(){return c(this,0,3)},w.greaterThan=w.gt=function(e,n){return N=4,this.cmp(e,n)>0},w.greaterThanOrEqualTo=w.gte=function(e,n){return N=5,1==(n=this.cmp(e,n))||0===n},w.isFinite=w.isF=function(){return!!this.c},w.isNaN=function(){return!this.s},w.isNegative=w.isNeg=function(){return this.s<0},w.isZero=w.isZ=function(){return!!this.c&&0==this.c[0]},w.lessThan=w.lt=function(e,n){return N=6,this.cmp(e,n)<0},w.lessThanOrEqualTo=w.lte=function(e,n){return N=7,-1==(n=this.cmp(e,n))||0===n},w.minus=function(e,n){var t,i,o,a,s=this,u=s.s;if(n=(N=8,e=new r(e,n)).s,!u||!n)return new r(0/0);if(u!=n)return e.s=-n,s.plus(e);var c=s.c,f=s.e,l=e.c,m=e.e;if(!f||!m){if(!c||!l)return c?(e.s=-n,e):new r(l?s:0/0);if(!c[0]||!l[0])return l[0]?(e.s=-n,e):new r(c[0]?s:3==h?-0:0)}if(c=c.slice(),u=f-m){for(t=(a=0>u)?(u=-u,c):(m=f,l),t.reverse(),n=u;n--;t.push(0));t.reverse()}else for(o=((a=c.lengthn;n++)if(c[n]!=l[n]){a=c[n]0)for(;n--;c[o++]=0);for(n=l.length;n>u;){if(c[--n]m||!c[0])&&(c[0]||(e.s=3==h?-1:1),c=[m=0]),e.c=c,e.e=m,e},w.modulo=w.mod=function(e,n){var t=this,i=t.c,o=(N=9,e=new r(e,n)).c,a=t.s,s=e.s;return n=!a||!s||o&&!o[0],n||i&&!i[0]?new r(n?0/0:t):(t.s=e.s=1,n=1==e.cmp(t),t.s=a,e.s=s,n?new r(t):(a=p,s=h,p=0,h=1,t=t.div(e),p=a,h=s,this.minus(t.times(e))))},w.negated=w.neg=function(){var e=new r(this);return e.s=-e.s||null,e},w.plus=function(e,n){var t,i=this,o=i.s;if(n=(N=10,e=new r(e,n)).s,!o||!n)return new r(0/0);if(o!=n)return e.s=-n,i.minus(e);var a=i.e,s=i.c,u=e.e,c=e.c;if(!a||!u){if(!s||!c)return new r(o/0);if(!s[0]||!c[0])return c[0]?e:new r(s[0]?i:0*o)}if(s=s.slice(),o=a-u){for(t=o>0?(u=a,c):(o=-o,s),t.reverse();o--;t.push(0));t.reverse()}for(s.length-c.length<0&&(t=c,c=s,s=t),o=c.length,n=0;o;n=(s[--o]=s[o]+c[o]+n)/10^0,s[o]%=10);for(n&&(s.unshift(n),++u>y&&(s=u=null)),o=s.length;0==s[--o];s.pop());return e.c=s,e.e=u,e},w.toPower=w.pow=function(e){var n=0*e==0?0|e:e,t=new r(this),o=new r(C);if(((f=-m>e||e>m)&&(n=1*e/0)||v(e)!=e&&0!==e&&!(n=0/0))&&!i(e,"exponent","pow")||!n)return new r(Math.pow(t.toS(),n));for(n=0>n?-n:n;1&n&&(o=o.times(t)),n>>=1,n;)t=t.times(t);return 0>e?C.div(o):o},w.round=function(e,n){return e=null==e||((f=0>e||e>l)||v(e)!=e)&&!i(e,"decimal places","round")?0:0|e,n=null==n||((f=0>n||n>8)||v(n)!=n&&0!==n)&&!i(n,"mode","round")?h:0|n,c(this,e,n)},w.squareRoot=w.sqrt=function(){var e,n,t,i,o=this,a=o.c,s=o.s,c=o.e,f=p,l=h,m=new r("0.5");if(1!==s||!a||!a[0])return new r(!s||0>s&&(!a||a[0])?0/0:a?o:1/0);for(s=Math.sqrt(o.toS()),h=1,0==s||s==1/0?(e=a.join(""),e.length+c&1||(e+="0"),n=new r(Math.sqrt(e)+""),n.c||(n.c=[1]),n.e=((c+1)/2|0)-(0>c||1&c)):n=new r(e=s.toString()),t=n.e,s=t+(p+=4),3>s&&(s=0),c=s;;)if(i=n,n=m.times(i.plus(o.div(i))),i.c.slice(0,s).join("")===n.c.slice(0,s).join("")){if(a=n.c,s-=e&&n.ec-2&&(a.length=c-2),n.times(n).eq(o)))){for(;a.length-1;s--){for(n=0,u=c+s;u>s;n=t[u]+a[s]*o[u-s-1]+n,t[u--]=n%10|0,n=n/10|0);n&&(t[u]=(t[u]+n)%10)}for(n&&++e.e,!t[0]&&t.shift(),u=t.length;!t[--u];t.pop());return e.c=e.e>y?e.e=null:e.ee||e>l)||v(e)!=e&&0!==e)&&!i(e,"decimal places","toE"))&&this.c?this.c.length-1:0|e,1)},w.toFixed=w.toF=function(e){var n,t,r,o=this;return null==e||((f=0>e||e>l)||v(e)!=e&&0!==e)&&!i(e,"decimal places","toF")||(r=o.e+(0|e)),n=g,e=x,g=-(x=1/0),r==t?t=o.toS():(t=s(o,r),o.s<0&&o.c&&(o.c[0]?t.indexOf("-")<0&&(t="-"+t):t=t.replace(/^-/,""))),g=n,x=e,t},w.toFraction=w.toFr=function(e){var n,t,o,a,s,u,c,l=a=new r(C),m=o=new r("0"),g=this,x=g.c,d=y,v=p,w=h,E=new r(C);if(!x)return g.toS();for(c=E.e=x.length-g.e-1,(null==e||(!(N=12,u=new r(e)).s||(f=u.cmp(l)<0||!u.c)||b&&u.e0)&&(e=c>0?E:l),y=1/0,u=new r(x.join("")),p=0,h=1;n=u.div(E),s=a.plus(n.times(m)),1!=s.cmp(e);)a=m,m=s,l=o.plus(n.times(s=l)),o=s,E=u.minus(n.times(s=E)),u=s;return s=e.minus(a).div(m),o=o.plus(s.times(l)),a=a.plus(s.times(m)),o.s=l.s=g.s,p=2*c,h=w,t=l.div(m).minus(g).abs().cmp(o.div(a).minus(g).abs())<1?[l.toS(),m.toS()]:[o.toS(),a.toS()],y=d,p=v,t},w.toPrecision=w.toP=function(e){return null==e||((f=1>e||e>l)||v(e)!=e)&&!i(e,"precision","toP")?this.toS():s(this,0|--e,2)},w.toString=w.toS=function(e){var n,t,r,a=this,u=a.e;if(null===u)t=a.s?"Infinity":"NaN";else{if(e===n&&(g>=u||u>=x))return s(a,a.c.length-1,1);if(t=a.c.join(""),0>u){for(;++u;t="0"+t);t="0."+t}else if(r=t.length,u>0)if(++u>r)for(u-=r;u--;t+="0");else r>u&&(t=t.slice(0,u)+"."+t.slice(u));else if(n=t.charAt(0),r>1)t=n+"."+t.slice(1);else if("0"==n)return n;if(null!=e)if((f=!(e>=2&&65>e))||e!=(0|e)&&b)i(e,"base","toS");else if(t=o(t,0|e,10,a.s),"0"==t)return t}return a.s<0?"-"+t:t},w.valueOf=function(){return this.toS()},"undefined"!=typeof t&&t.exports?t.exports=r:"function"==typeof e&&e.amd?e(function(){return r}):n.BigNumber=r}(this)},{}]},{},[1])(1)}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){for(var n=0;nt;++t)e.call(n||this,this[t],t,this)}),Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Array.prototype.map||(Array.prototype.map=function(e,n){var t,r,i;if(null==this)throw new TypeError(" this is null or not defined");var o=Object(this),a=o.length>>>0;if("function"!=typeof e)throw new TypeError(e+" is not a function");for(n&&(t=n),r=new Array(a),i=0;a>i;){var s,u;i in o&&(s=o[i],u=e.call(t,s,i,o),r[i]=u),i++}return r}),Array.prototype.every||(Array.prototype.every=function(e){"use strict";if(null==this)throw new TypeError;var n=Object(this),t=n.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=arguments[1],i=0;t>i;i++)if(i in n&&!e.call(r,n[i],i,n))return!1;return!0}),Array.prototype.some||(Array.prototype.some=function(e){"use strict";if(null==this)throw new TypeError;var n=Object(this),t=n.length>>>0;if("function"!=typeof e)throw new TypeError;for(var r=arguments[1],i=0;t>i;i++)if(i in n&&e.call(r,n[i],i,n))return!0;return!1}),Function.prototype.bind||(Function.prototype.bind=function(e){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var n=Array.prototype.slice.call(arguments,1),t=this,r=function(){},i=function(){return t.apply(this instanceof r&&e?this:e,n.concat(Array.prototype.slice.call(arguments)))};return r.prototype=this.prototype,i.prototype=new r,i}); \ No newline at end of file diff --git a/package.json b/package.json index 1febe7f6d..776cc899d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mathjs", - "version": "0.16.0-SNAPSHOT", + "version": "0.16.0", "description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.", "author": "Jos de Jong (https://github.com/josdejong)", "contributors": [