From ef36222f1aea958db78b0b8f5cb92faf2eccfb7e Mon Sep 17 00:00:00 2001 From: rjbaucells Date: Sat, 2 May 2015 00:36:09 -0400 Subject: [PATCH] dist --- dist/math.js | 54790 ++++++++++++++++++++++++--------------------- dist/math.map | 2 +- dist/math.min.js | 27 +- 3 files changed, 28844 insertions(+), 25975 deletions(-) diff --git a/dist/math.js b/dist/math.js index 3989e96a7..680e2f937 100644 --- a/dist/math.js +++ b/dist/math.js @@ -7,7 +7,7 @@ * mathematical functions, and a flexible expression parser. * * @version 2.0.0-SNAPSHOT - * @date 2015-04-28 + * @date 2015-05-02 * * @license * Copyright (C) 2013-2015 Jos de Jong @@ -97,227 +97,57 @@ return /******/ (function(modules) { // webpackBootstrap */ function create (config) { // create a new, empty math.js instance + // TODO: pass config here var math = loader.create(); math.create = create; - var _config = math._config; // TODO: cleanup as soon as redundant - // util methods for Arrays and Matrices math.import(__webpack_require__(2)); - // expression (parse, Parser, nodes, docs) - math.expression = {}; - math.expression.node = __webpack_require__(15); - math.import(__webpack_require__(13)); - math.import(__webpack_require__(14)); - math.expression.docs = __webpack_require__(16); - // data types (Matrix, Complex, Unit, ...) - math.type.Complex = __webpack_require__(3); - math.type.Range = __webpack_require__(4); - math.type.Index = __webpack_require__(5); + math.import(__webpack_require__(3)); + math.import(__webpack_require__(4)); + math.import(__webpack_require__(5)); math.import(__webpack_require__(6)); - math.type.Unit = __webpack_require__(7); - math.type.Help = __webpack_require__(8); - math.type.ResultSet = __webpack_require__(9); + math.import(__webpack_require__(12)); + math.import(__webpack_require__(13)); + math.import(__webpack_require__(14)); // sparse accumulator + math.import(__webpack_require__(7)); + math.import(__webpack_require__(8)); + math.import(__webpack_require__(9)); math.import(__webpack_require__(10)); math.import(__webpack_require__(11)); - - // matrix storage formats + + // FIXME: load constants via math.import() like all functions (problem: it must be reloaded when config changes) + // constants + math.import(__webpack_require__(15)); + + // expression (expression.parse, expression.Parser, expression.node.*, expression.docs.*) math.import(__webpack_require__(17)); + + // serialization utilities (math.json.reviver) math.import(__webpack_require__(18)); - // sparse accumulator + // functions math.import(__webpack_require__(19)); - - // serialization utilities - // math.json.* math.import(__webpack_require__(20)); - - // functions - algebra/decomposition - math.import(__webpack_require__(164)); - - // functions - algebra/solver - math.import(__webpack_require__(165)); - - // functions - arithmetic + math.import(__webpack_require__(21)); + math.import(__webpack_require__(22)); + math.import(__webpack_require__(23)); + math.import(__webpack_require__(24)); + math.import(__webpack_require__(25)); + math.import(__webpack_require__(26)); + math.import(__webpack_require__(27)); + math.import(__webpack_require__(28)); + math.import(__webpack_require__(29)); + math.import(__webpack_require__(30)); math.import(__webpack_require__(31)); - math.import(__webpack_require__(32)); - math.import(__webpack_require__(33)); - math.import(__webpack_require__(34)); - math.import(__webpack_require__(35)); - math.import(__webpack_require__(36)); - math.import(__webpack_require__(37)); - math.import(__webpack_require__(38)); - math.import(__webpack_require__(39)); - math.import(__webpack_require__(40)); - math.import(__webpack_require__(41)); - math.import(__webpack_require__(42)); - math.import(__webpack_require__(43)); - math.import(__webpack_require__(44)); - math.import(__webpack_require__(45)); - math.import(__webpack_require__(46)); - math.import(__webpack_require__(47)); - math.import(__webpack_require__(48)); - math.import(__webpack_require__(49)); - math.import(__webpack_require__(50)); - math.import(__webpack_require__(51)); - math.import(__webpack_require__(52)); - math.import(__webpack_require__(53)); - math.import(__webpack_require__(54)); - math.import(__webpack_require__(55)); - math.import(__webpack_require__(56)); - math.import(__webpack_require__(57)); - math.import(__webpack_require__(58)); - - // functions - bitwise - math.import(__webpack_require__(59)); - math.import(__webpack_require__(60)); - math.import(__webpack_require__(61)); - math.import(__webpack_require__(62)); - math.import(__webpack_require__(63)); - math.import(__webpack_require__(64)); - math.import(__webpack_require__(65)); - - // functions - complex - math.import(__webpack_require__(66)); - math.import(__webpack_require__(67)); - math.import(__webpack_require__(68)); - math.import(__webpack_require__(69)); - - // functions - construction - math.import(__webpack_require__(70)); - math.import(__webpack_require__(71)); - math.import(__webpack_require__(72)); - math.import(__webpack_require__(73)); - math.import(__webpack_require__(74)); - math.import(__webpack_require__(75)); - math.import(__webpack_require__(76)); - math.import(__webpack_require__(77)); - math.import(__webpack_require__(78)); - math.import(__webpack_require__(79)); - math.import(__webpack_require__(80)); - - // expression parser - math.import(__webpack_require__(81)); - math.import(__webpack_require__(82)); - math.import(__webpack_require__(83)); - math.import(__webpack_require__(84)); - - // functions - logical - math.import(__webpack_require__(85)); - math.import(__webpack_require__(86)); - math.import(__webpack_require__(87)); - math.import(__webpack_require__(88)); - - // functions - matrix - math.import(__webpack_require__(89)); - math.import(__webpack_require__(90)); - math.import(__webpack_require__(91)); - math.import(__webpack_require__(92)); - math.import(__webpack_require__(93)); - math.import(__webpack_require__(94)); - math.import(__webpack_require__(95)); - math.import(__webpack_require__(96)); - __webpack_require__(97)(math, _config); - __webpack_require__(98)(math, _config); - __webpack_require__(99)(math, _config); - math.import(__webpack_require__(100)); - math.import(__webpack_require__(101)); - __webpack_require__(102)(math, _config); - math.import(__webpack_require__(103)); - math.import(__webpack_require__(104)); - __webpack_require__(105)(math, _config); - - // functions - probability - //math.import(require('./lib/function/probability/distribution')); // TODO: rethink math.distribution - math.import(__webpack_require__(106)); - math.import(__webpack_require__(107)); - math.import(__webpack_require__(108)); - math.import(__webpack_require__(109)); - math.import(__webpack_require__(110)); - math.import(__webpack_require__(111)); - math.import(__webpack_require__(112)); - - // functions - relational - math.import(__webpack_require__(113)); - math.import(__webpack_require__(114)); - math.import(__webpack_require__(115)); - math.import(__webpack_require__(116)); - math.import(__webpack_require__(117)); - math.import(__webpack_require__(118)); - math.import(__webpack_require__(119)); - math.import(__webpack_require__(120)); - - // functions - statistics - math.import(__webpack_require__(121)); - math.import(__webpack_require__(122)); - math.import(__webpack_require__(123)); - math.import(__webpack_require__(124)); - math.import(__webpack_require__(125)); - math.import(__webpack_require__(126)); - math.import(__webpack_require__(127)); - math.import(__webpack_require__(128)); - - // functions - trigonometry - math.import(__webpack_require__(129)); - math.import(__webpack_require__(130)); - math.import(__webpack_require__(131)); - math.import(__webpack_require__(132)); - math.import(__webpack_require__(133)); - math.import(__webpack_require__(134)); - math.import(__webpack_require__(135)); - math.import(__webpack_require__(136)); - math.import(__webpack_require__(137)); - math.import(__webpack_require__(138)); - math.import(__webpack_require__(139)); - math.import(__webpack_require__(140)); - math.import(__webpack_require__(141)); - math.import(__webpack_require__(142)); - math.import(__webpack_require__(143)); - math.import(__webpack_require__(144)); - math.import(__webpack_require__(145)); - math.import(__webpack_require__(146)); - math.import(__webpack_require__(147)); - math.import(__webpack_require__(148)); - math.import(__webpack_require__(149)); - math.import(__webpack_require__(150)); - math.import(__webpack_require__(151)); - math.import(__webpack_require__(152)); - math.import(__webpack_require__(153)); - - // functions - units - math.import(__webpack_require__(154)); - - // functions - utils - math.import(__webpack_require__(155)); - math.import(__webpack_require__(156)); - math.import(__webpack_require__(157)); - math.import(__webpack_require__(158)); - // note: import is already loaded by loader.js - math.import(__webpack_require__(159)); - math.import(__webpack_require__(160)); - math.import(__webpack_require__(161)); - math.import(__webpack_require__(162)); - math.import(__webpack_require__(163)); - - // attach transform functions (for converting one-based indices to zero-based) - math.expression.transform = { - concat: __webpack_require__(21)(math, _config), - filter: __webpack_require__(22)(math, _config), - forEach:__webpack_require__(23)(math, _config), - index: __webpack_require__(24)(math, _config), - map: __webpack_require__(25)(math, _config), - max: __webpack_require__(26)(math, _config), - mean: __webpack_require__(27)(math, _config), - min: __webpack_require__(28)(math, _config), - range: __webpack_require__(29)(math, _config), - subset: __webpack_require__(30)(math, _config) - }; + math.import(__webpack_require__(32)); // contains the config function // create Chain, and create proxies for all functions/constants in the math // namespace. - math.type.Chain = __webpack_require__(12)(); + // TODO: load Chain via math.import + math.type.Chain = __webpack_require__(16)(); math.type.Chain.createProxy(math); // apply custom options @@ -334,13 +164,14 @@ return /******/ (function(modules) { // webpackBootstrap /* 1 */ /***/ function(module, exports, __webpack_require__) { - var isFactory = __webpack_require__(166).isFactory; + var isFactory = __webpack_require__(33).isFactory; /** * Math.js loader. Creates a new, empty math.js instance * @returns {Object} Returns a math.js instance containing * a function `import` to add new functions */ + // TODO: support passing config here exports.create = function create () { // simple test for ES5 support if (typeof Object.create !== 'function') { @@ -358,7 +189,7 @@ return /******/ (function(modules) { // webpackBootstrap }; // create a new typed instance - var typed = __webpack_require__(167).create(math); + var typed = __webpack_require__(34).create(math); // create configuration options. These are private var _config = { @@ -414,17 +245,11 @@ return /******/ (function(modules) { // webpackBootstrap // load the import function, which can be used to load all other functions, // constants, and types - math['import'] = load(__webpack_require__(168)); + math['import'] = load(__webpack_require__(35)); + // TODO: automatically load config method too? Like import? - // FIXME: load constants via math.import() like all functions (problem: it must be reloaded when config changes) - // constants - __webpack_require__(169)(math, _config); - - math._config = _config; // TODO: cleanup when everything is refactored - - // TODO: remove errors from the namespace as soon as all functions are refactored // errors - math.error = __webpack_require__(170); + math.error = __webpack_require__(50); return math; }; @@ -437,50 +262,16 @@ return /******/ (function(modules) { // webpackBootstrap // utility methods for arrays and matrices 'use strict'; - var util = __webpack_require__(171); - var arraySize = __webpack_require__(172).size; - var IndexError = __webpack_require__(173); - var DimensionError = __webpack_require__(174); + var util = __webpack_require__(36); + var arraySize = __webpack_require__(37).size; + var IndexError = __webpack_require__(38); + var DimensionError = __webpack_require__(39); function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); + var matrix = load(__webpack_require__(40)); var collection = {}; - /** - * Convert function arguments to an array. Arguments can have the following - * signature: - * fn() - * fn(n) - * fn(m, n, p, ...) - * fn([m, n, p, ...]) - * @param {...Number | Array | Matrix} args - * @returns {Array} array - */ - collection.argsToArray = function(args) { - if (args.length === 0) { - // fn() - return []; - } - else if (args.length == 1) { - // fn(n) - // fn([m, n, p, ...]) - var array = args[0]; - if (array instanceof type.Matrix) { - array = array.valueOf(); - } - if (!Array.isArray(array)) { - array = [array]; - } - return array; - } - else { - // fn(m, n, p, ...) - return util.array.argsToArray(args); - } - }; - - /** * Test whether a value is a collection: an Array or Matrix * @param {*} x @@ -710,477 +501,488 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171), - Unit = __webpack_require__(7), - number = util.number, + var util = __webpack_require__(36); + var number = util.number; - isNumber = util.number.isNumber, - isUnit = Unit.isUnit, - isString = util.string.isString; + var isNumber = util.number.isNumber; + var isString = util.string.isString; - /** - * @constructor Complex - * - * A complex value can be constructed in the following ways: - * var a = new Complex(); - * var b = new Complex(re, im); - * var c = Complex.parse(str); - * - * Example usage: - * var a = new Complex(3, -4); // 3 - 4i - * a.re = 5; // a = 5 - 4i - * var i = a.im; // -4; - * var b = Complex.parse('2 + 6i'); // 2 + 6i - * var c = new Complex(); // 0 + 0i - * var d = math.add(a, b); // 5 + 2i - * - * @param {Number} re The real part of the complex value - * @param {Number} [im] The imaginary part of the complex value - */ - function Complex(re, im) { - if (!(this instanceof Complex)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } + function factory (type, config, load, typed) { + // TODO: remove dependency on Unit, not good for modularization + var Unit = load(__webpack_require__(7)); + var isUnit = Unit.isUnit; - switch (arguments.length) { - case 0: - this.re = 0; - this.im = 0; - break; + /** + * @constructor Complex + * + * A complex value can be constructed in the following ways: + * var a = new Complex(); + * var b = new Complex(re, im); + * var c = Complex.parse(str); + * + * Example usage: + * var a = new Complex(3, -4); // 3 - 4i + * a.re = 5; // a = 5 - 4i + * var i = a.im; // -4; + * var b = Complex.parse('2 + 6i'); // 2 + 6i + * var c = new Complex(); // 0 + 0i + * var d = math.add(a, b); // 5 + 2i + * + * @param {Number} re The real part of the complex value + * @param {Number} [im] The imaginary part of the complex value + */ + function Complex(re, im) { + if (!(this instanceof Complex)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } - case 1: - var arg = arguments[0]; - if (typeof arg === 'object') { - if('re' in arg && 'im' in arg) { - var construct = new Complex(arg.re, arg.im); // pass on input validation - this.re = construct.re; - this.im = construct.im; - break; - } else if ('r' in arg && 'phi' in arg) { - var construct = Complex.fromPolar(arg.r, arg.phi); - this.re = construct.re; - this.im = construct.im; - break; + switch (arguments.length) { + case 0: + this.re = 0; + this.im = 0; + break; + + case 1: + var arg = arguments[0]; + if (typeof arg === 'object') { + if ('re' in arg && 'im' in arg) { + var construct = new Complex(arg.re, arg.im); // pass on input validation + this.re = construct.re; + this.im = construct.im; + break; + } else if ('r' in arg && 'phi' in arg) { + var construct = Complex.fromPolar(arg.r, arg.phi); + this.re = construct.re; + this.im = construct.im; + break; + } } - } - throw new SyntaxError('Object with the re and im or r and phi properties expected.'); + throw new SyntaxError('Object with the re and im or r and phi properties expected.'); - case 2: - if (!isNumber(re) || !isNumber(im)) { - throw new TypeError('Two numbers expected in Complex constructor'); - } - this.re = re; - this.im = im; - break; + case 2: + if (!isNumber(re) || !isNumber(im)) { + throw new TypeError('Two numbers expected in Complex constructor'); + } + this.re = re; + this.im = im; + break; - default: - throw new SyntaxError('One, two or three arguments expected in Complex constructor'); - } - } - - /** - * Test whether value is a Complex value - * @param {*} value - * @return {Boolean} isComplex - */ - Complex.isComplex = function (value) { - return (value instanceof Complex); - }; - - // private variables and functions for the parser - var text, index, c; - - function skipWhitespace() { - while (c == ' ' || c == '\t') { - next(); - } - } - - function isDigitDot (c) { - return ((c >= '0' && c <= '9') || c == '.'); - } - - function isDigit (c) { - return ((c >= '0' && c <= '9')); - } - - function next() { - index++; - c = text.charAt(index); - } - - function revert(oldIndex) { - index = oldIndex; - c = text.charAt(index); - } - - function parseNumber () { - var number = ''; - var oldIndex; - oldIndex = index; - - if (c == '+') { - next(); - } - else if (c == '-') { - number += c; - next(); - } - - if (!isDigitDot(c)) { - // a + or - must be followed by a digit - revert(oldIndex); - return null; - } - - // get number, can have a single dot - if (c == '.') { - number += c; - next(); - if (!isDigit(c)) { - // this is no legal number, it is just a dot - revert(oldIndex); - return null; + default: + throw new SyntaxError('One, two or three arguments expected in Complex constructor'); } } - else { - while (isDigit(c)) { + + /** + * Test whether value is a Complex value + * @param {*} value + * @return {Boolean} isComplex + */ + Complex.isComplex = function (value) { + return (value instanceof Complex); + }; + + // private variables and functions for the parser + var text, index, c; + + function skipWhitespace() { + while (c == ' ' || c == '\t') { + next(); + } + } + + function isDigitDot(c) { + return ((c >= '0' && c <= '9') || c == '.'); + } + + function isDigit(c) { + return ((c >= '0' && c <= '9')); + } + + function next() { + index++; + c = text.charAt(index); + } + + function revert(oldIndex) { + index = oldIndex; + c = text.charAt(index); + } + + function parseNumber() { + var number = ''; + var oldIndex; + oldIndex = index; + + if (c == '+') { + next(); + } + else if (c == '-') { number += c; next(); } + + if (!isDigitDot(c)) { + // a + or - must be followed by a digit + revert(oldIndex); + return null; + } + + // get number, can have a single dot if (c == '.') { number += c; next(); + if (!isDigit(c)) { + // this is no legal number, it is just a dot + revert(oldIndex); + return null; + } } - } - while (isDigit(c)) { - number += c; - next(); - } - - // check for exponential notation like "2.3e-4" or "1.23e50" - if (c == 'E' || c == 'e') { - number += c; - next(); - - if (c == '+' || c == '-') { - number += c; - next(); + else { + while (isDigit(c)) { + number += c; + next(); + } + if (c == '.') { + number += c; + next(); + } } - - // Scientific notation MUST be followed by an exponent - if (!isDigit(c)) { - // this is no legal number, exponent is missing. - revert(oldIndex); - return null; - } - while (isDigit(c)) { number += c; next(); } - } - return number; - } + // check for exponential notation like "2.3e-4" or "1.23e50" + if (c == 'E' || c == 'e') { + number += c; + next(); + + if (c == '+' || c == '-') { + number += c; + next(); + } + + // Scientific notation MUST be followed by an exponent + if (!isDigit(c)) { + // this is no legal number, exponent is missing. + revert(oldIndex); + return null; + } + + while (isDigit(c)) { + number += c; + next(); + } + } - function parseComplex () { - // check for 'i', '-i', '+i' - var cnext = text.charAt(index + 1); - if (c == 'I' || c == 'i') { - next(); - return '1'; - } - else if ((c == '+' || c == '-') && (cnext == 'I' || cnext == 'i')) { - var number = (c == '+') ? '1' : '-1'; - next(); - next(); return number; } - return null; - } + function parseComplex() { + // check for 'i', '-i', '+i' + var cnext = text.charAt(index + 1); + if (c == 'I' || c == 'i') { + next(); + return '1'; + } + else if ((c == '+' || c == '-') && (cnext == 'I' || cnext == 'i')) { + var number = (c == '+') ? '1' : '-1'; + next(); + next(); + return number; + } - /** - * Parse a complex number from a string. For example Complex.parse("2 + 3i") - * will return a Complex value where re = 2, im = 3. - * Returns null if provided string does not contain a valid complex number. - * @param {String} str - * @returns {Complex | null} complex - */ - Complex.parse = function (str) { - text = str; - index = -1; - c = ''; - - if (!isString(text)) { return null; } - next(); - skipWhitespace(); - var first = parseNumber(); - if (first) { - if (c == 'I' || c == 'i') { - // pure imaginary number - next(); - skipWhitespace(); - if (c) { - // garbage at the end. not good. - return null; - } + /** + * Parse a complex number from a string. For example Complex.parse("2 + 3i") + * will return a Complex value where re = 2, im = 3. + * Returns null if provided string does not contain a valid complex number. + * @param {String} str + * @returns {Complex | null} complex + */ + Complex.parse = function (str) { + text = str; + index = -1; + c = ''; - return new Complex(0, Number(first)); + if (!isString(text)) { + return null; } - else { - // complex and real part - skipWhitespace(); - var separator = c; - if (separator != '+' && separator != '-') { - // pure real number + + next(); + skipWhitespace(); + var first = parseNumber(); + if (first) { + if (c == 'I' || c == 'i') { + // pure imaginary number + next(); skipWhitespace(); if (c) { // garbage at the end. not good. return null; } - return new Complex(Number(first), 0); + return new Complex(0, Number(first)); } else { // complex and real part - next(); skipWhitespace(); - var second = parseNumber(); - if (second) { - if (c != 'I' && c != 'i') { - // 'i' missing at the end of the complex number + var separator = c; + if (separator != '+' && separator != '-') { + // pure real number + skipWhitespace(); + if (c) { + // garbage at the end. not good. return null; } - next(); + + return new Complex(Number(first), 0); } else { - second = parseComplex(); - if (!second) { - // imaginary number missing after separator - return null; - } - } - - if (separator == '-') { - if (second[0] == '-') { - second = '+' + second.substring(1); + // complex and real part + next(); + skipWhitespace(); + var second = parseNumber(); + if (second) { + if (c != 'I' && c != 'i') { + // 'i' missing at the end of the complex number + return null; + } + next(); } else { - second = '-' + second; + second = parseComplex(); + if (!second) { + // imaginary number missing after separator + return null; + } } - } - next(); + if (separator == '-') { + if (second[0] == '-') { + second = '+' + second.substring(1); + } + else { + second = '-' + second; + } + } + + next(); + skipWhitespace(); + if (c) { + // garbage at the end. not good. + return null; + } + + return new Complex(Number(first), Number(second)); + } + } + } + else { + // check for 'i', '-i', '+i' + first = parseComplex(); + if (first) { skipWhitespace(); if (c) { // garbage at the end. not good. return null; } - return new Complex(Number(first), Number(second)); + return new Complex(0, Number(first)); } } - } - else { - // check for 'i', '-i', '+i' - first = parseComplex(); - if (first) { - skipWhitespace(); - if (c) { - // garbage at the end. not good. - return null; - } - return new Complex(0, Number(first)); - } - } - - return null; - }; - - /** - * Create a complex number from polar coordinates - * - * Usage: - * - * Complex.fromPolar(r: Number, phi: Number) : Complex - * Complex.fromPolar({r: Number, phi: Number}) : Complex - * - * @param {*} args... - * @return {Complex} - */ - Complex.fromPolar = function (args) { - switch (arguments.length) { - case 1: - var arg = arguments[0]; - if(typeof arg === 'object') { - return Complex.fromPolar(arg.r, arg.phi); - } - throw new TypeError('Input has to be an object with r and phi keys.'); - - case 2: - var r = arguments[0], - phi = arguments[1]; - if(isNumber(r)) { - if (isUnit(phi) && phi.hasBase(Unit.BASE_UNITS.ANGLE)) { - // convert unit to a number in radians - phi = phi.toNumber('rad'); - } - - if(isNumber(phi)) { - return new Complex(r * Math.cos(phi), r * Math.sin(phi)); - } - - throw new TypeError('Phi is not a number nor an angle unit.'); - } else { - throw new TypeError('Radius r is not a number.'); - } - - default: - throw new SyntaxError('Wrong number of arguments in function fromPolar'); - } - }; - - /* - * Return the value of the complex number in polar notation - * The angle phi will be set in the interval of [-pi, pi]. - * @return {{r: number, phi: number}} Returns and object with properties r and phi. - */ - Complex.prototype.toPolar = function() { - return { - r: Math.sqrt(this.re * this.re + this.im * this.im), - phi: Math.atan2(this.im, this.re) + return null; }; - }; - /** - * Create a copy of the complex value - * @return {Complex} clone - */ - Complex.prototype.clone = function () { - return new Complex(this.re, this.im); - }; + /** + * Create a complex number from polar coordinates + * + * Usage: + * + * Complex.fromPolar(r: Number, phi: Number) : Complex + * Complex.fromPolar({r: Number, phi: Number}) : Complex + * + * @param {*} args... + * @return {Complex} + */ + Complex.fromPolar = function (args) { + switch (arguments.length) { + case 1: + var arg = arguments[0]; + if (typeof arg === 'object') { + return Complex.fromPolar(arg.r, arg.phi); + } + throw new TypeError('Input has to be an object with r and phi keys.'); - /** - * Test whether this complex number equals an other complex value. - * Two complex numbers are equal when both their real and imaginary parts - * are equal. - * @param {Complex} other - * @return {boolean} isEqual - */ - Complex.prototype.equals = function (other) { - return (this.re === other.re) && (this.im === other.im); - }; + case 2: + var r = arguments[0], + phi = arguments[1]; + if (isNumber(r)) { + if (isUnit(phi) && phi.hasBase(Unit.BASE_UNITS.ANGLE)) { + // convert unit to a number in radians + phi = phi.toNumber('rad'); + } - /** - * Get a string representation of the complex number, - * with optional formatting options. - * @param {Object | Number | Function} [options] Formatting options. See - * lib/util/number:format for a - * description of the available - * options. - * @return {String} str - */ - Complex.prototype.format = function (options) { - var str = ''; - var im = this.im; - var re = this.re; - var strRe = number.format(this.re, options); - var strIm = number.format(this.im, options); + if (isNumber(phi)) { + return new Complex(r * Math.cos(phi), r * Math.sin(phi)); + } - // round either re or im when smaller than the configured precision - var precision = isNumber(options) ? options : options ? options.precision : null; - if (precision !== null) { - var epsilon = Math.pow(10, -precision); - if (Math.abs(re / im) < epsilon) {re = 0;} - if (Math.abs(im / re) < epsilon) {im = 0;} - } + throw new TypeError('Phi is not a number nor an angle unit.'); + } else { + throw new TypeError('Radius r is not a number.'); + } - if (im == 0) { - // real value - str = strRe; - } - else if (re == 0) { - // purely complex value - if (im == 1) { - str = 'i'; + default: + throw new SyntaxError('Wrong number of arguments in function fromPolar'); } - else if (im == -1) { - str = '-i'; + }; + + /* + * Return the value of the complex number in polar notation + * The angle phi will be set in the interval of [-pi, pi]. + * @return {{r: number, phi: number}} Returns and object with properties r and phi. + */ + Complex.prototype.toPolar = function () { + return { + r: Math.sqrt(this.re * this.re + this.im * this.im), + phi: Math.atan2(this.im, this.re) + }; + }; + + /** + * Create a copy of the complex value + * @return {Complex} clone + */ + Complex.prototype.clone = function () { + return new Complex(this.re, this.im); + }; + + /** + * Test whether this complex number equals an other complex value. + * Two complex numbers are equal when both their real and imaginary parts + * are equal. + * @param {Complex} other + * @return {boolean} isEqual + */ + Complex.prototype.equals = function (other) { + return (this.re === other.re) && (this.im === other.im); + }; + + /** + * Get a string representation of the complex number, + * with optional formatting options. + * @param {Object | Number | Function} [options] Formatting options. See + * lib/util/number:format for a + * description of the available + * options. + * @return {String} str + */ + Complex.prototype.format = function (options) { + var str = ''; + var im = this.im; + var re = this.re; + var strRe = number.format(this.re, options); + var strIm = number.format(this.im, options); + + // round either re or im when smaller than the configured precision + var precision = isNumber(options) ? options : options ? options.precision : null; + if (precision !== null) { + var epsilon = Math.pow(10, -precision); + if (Math.abs(re / im) < epsilon) { + re = 0; + } + if (Math.abs(im / re) < epsilon) { + im = 0; + } } - else { - str = strIm + 'i'; + + if (im == 0) { + // real value + str = strRe; } - } - else { - // complex value - if (im > 0) { + else if (re == 0) { + // purely complex value if (im == 1) { - str = strRe + ' + i'; + str = 'i'; + } + else if (im == -1) { + str = '-i'; } else { - str = strRe + ' + ' + strIm + 'i'; + str = strIm + 'i'; } } else { - if (im == -1) { - str = strRe + ' - i'; + // complex value + if (im > 0) { + if (im == 1) { + str = strRe + ' + i'; + } + else { + str = strRe + ' + ' + strIm + 'i'; + } } else { - str = strRe + ' - ' + strIm.substring(1) + 'i'; + if (im == -1) { + str = strRe + ' - i'; + } + else { + str = strRe + ' - ' + strIm.substring(1) + 'i'; + } } } - } - return str; - }; - - /** - * Get a string representation of the complex number. - * @return {String} str - */ - Complex.prototype.toString = function () { - return this.format(); - }; - - /** - * Get a JSON representation of the complex number - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Complex", "re": 2, "im": 3}` - */ - Complex.prototype.toJSON = function () { - return { - mathjs: 'Complex', - re: this.re, - im: this.im + return str; }; - }; - /** - * Create a Complex number from a JSON object - * @param {Object} json A JSON Object structured as - * {"mathjs": "Complex", "re": 2, "im": 3} - * All properties are optional, default values - * for `re` and `im` are 0. - * @return {Complex} Returns a new Complex number - */ - Complex.fromJSON = function (json) { - return new Complex(json); - }; + /** + * Get a string representation of the complex number. + * @return {String} str + */ + Complex.prototype.toString = function () { + return this.format(); + }; - /** - * Returns a string representation of the complex number. - * @return {String} str - */ - Complex.prototype.valueOf = Complex.prototype.toString; + /** + * Get a JSON representation of the complex number + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Complex", "re": 2, "im": 3}` + */ + Complex.prototype.toJSON = function () { + return { + mathjs: 'Complex', + re: this.re, + im: this.im + }; + }; - // exports - module.exports = Complex; + /** + * Create a Complex number from a JSON object + * @param {Object} json A JSON Object structured as + * {"mathjs": "Complex", "re": 2, "im": 3} + * All properties are optional, default values + * for `re` and `im` are 0. + * @return {Complex} Returns a new Complex number + */ + Complex.fromJSON = function (json) { + return new Complex(json); + }; + + /** + * Returns a string representation of the complex number. + * @return {String} str + */ + Complex.prototype.valueOf = Complex.prototype.toString; + + return Complex; + } + + exports.name = 'Complex'; + exports.path = 'type'; + exports.factory = factory; /***/ }, @@ -1189,297 +991,301 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171); + var number = __webpack_require__(41); - var number = util.number; - var string = util.string; - var array = util.array; + function factory (type, config, load, typed) { + /** + * @constructor Range + * Create a range. A range has a start, step, and end, and contains functions + * to iterate over the range. + * + * A range can be constructed as: + * var range = new Range(start, end); + * var range = new Range(start, end, step); + * + * To get the result of the range: + * range.forEach(function (x) { + * console.log(x); + * }); + * range.map(function (x) { + * return math.sin(x); + * }); + * range.toArray(); + * + * Example usage: + * var c = new Range(2, 6); // 2:1:5 + * c.toArray(); // [2, 3, 4, 5] + * var d = new Range(2, -3, -1); // 2:-1:-2 + * d.toArray(); // [2, 1, 0, -1, -2] + * + * @param {Number} start included lower bound + * @param {Number} end excluded upper bound + * @param {Number} [step] step size, default value is 1 + */ + function Range(start, end, step) { + if (!(this instanceof Range)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } - /** - * @constructor Range - * Create a range. A range has a start, step, and end, and contains functions - * to iterate over the range. - * - * A range can be constructed as: - * var range = new Range(start, end); - * var range = new Range(start, end, step); - * - * To get the result of the range: - * range.forEach(function (x) { - * console.log(x); - * }); - * range.map(function (x) { - * return math.sin(x); - * }); - * range.toArray(); - * - * Example usage: - * var c = new Range(2, 6); // 2:1:5 - * c.toArray(); // [2, 3, 4, 5] - * var d = new Range(2, -3, -1); // 2:-1:-2 - * d.toArray(); // [2, 1, 0, -1, -2] - * - * @param {Number} start included lower bound - * @param {Number} end excluded upper bound - * @param {Number} [step] step size, default value is 1 - */ - function Range(start, end, step) { - if (!(this instanceof Range)) { - throw new SyntaxError('Constructor must be called with the new operator'); + if (start != null && typeof start !== 'number') { + throw new TypeError('Parameter start must be a number'); + } + if (end != null && typeof end !== 'number') { + throw new TypeError('Parameter end must be a number'); + } + if (step != null && typeof step !== 'number') { + throw new TypeError('Parameter step must be a number'); + } + + this.start = (start != null) ? parseFloat(start) : 0; + this.end = (end != null) ? parseFloat(end) : 0; + this.step = (step != null) ? parseFloat(step) : 1; } - if (start != null && !number.isNumber(start)) { - throw new TypeError('Parameter start must be a number'); - } - if (end != null && !number.isNumber(end)) { - throw new TypeError('Parameter end must be a number'); - } - if (step != null && !number.isNumber(step)) { - throw new TypeError('Parameter step must be a number'); - } + /** + * Parse a string into a range, + * The string contains the start, optional step, and end, separated by a colon. + * If the string does not contain a valid range, null is returned. + * For example str='0:2:11'. + * @param {String} str + * @return {Range | null} range + */ + Range.parse = function (str) { + if (typeof str !== 'string') { + return null; + } - this.start = (start != null) ? parseFloat(start) : 0; - this.end = (end != null) ? parseFloat(end) : 0; - this.step = (step != null) ? parseFloat(step) : 1; + var args = str.split(':'); + var nums = args.map(function (arg) { + return parseFloat(arg); + }); + + var invalid = nums.some(function (num) { + return isNaN(num); + }); + if (invalid) { + return null; + } + + switch (nums.length) { + case 2: + return new Range(nums[0], nums[1]); + case 3: + return new Range(nums[0], nums[2], nums[1]); + default: + return null; + } + }; + + /** + * Create a clone of the range + * @return {Range} clone + */ + Range.prototype.clone = function () { + return new Range(this.start, this.end, this.step); + }; + + /** + * Test whether an object is a Range + * @param {*} object + * @return {Boolean} isRange + */ + Range.isRange = function (object) { + return (object instanceof Range); + }; + + /** + * Retrieve the size of the range. + * Returns an array containing one number, the number of elements in the range. + * @returns {Number[]} size + */ + Range.prototype.size = function () { + var len = 0, + start = this.start, + step = this.step, + end = this.end, + diff = end - start; + + if (number.sign(step) == number.sign(diff)) { + len = Math.ceil((diff) / step); + } + else if (diff == 0) { + len = 0; + } + + if (isNaN(len)) { + len = 0; + } + return [len]; + }; + + /** + * Calculate the minimum value in the range + * @return {Number | undefined} min + */ + Range.prototype.min = function () { + var size = this.size()[0]; + + if (size > 0) { + if (this.step > 0) { + // positive step + return this.start; + } + else { + // negative step + return this.start + (size - 1) * this.step; + } + } + else { + return undefined; + } + }; + + /** + * Calculate the maximum value in the range + * @return {Number | undefined} max + */ + Range.prototype.max = function () { + var size = this.size()[0]; + + if (size > 0) { + if (this.step > 0) { + // positive step + return this.start + (size - 1) * this.step; + } + else { + // negative step + return this.start; + } + } + else { + return undefined; + } + }; + + + /** + * Execute a callback function for each value in the range. + * @param {function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + */ + Range.prototype.forEach = function (callback) { + var x = this.start; + var step = this.step; + var end = this.end; + var i = 0; + + if (step > 0) { + while (x < end) { + callback(x, i, this); + x += step; + i++; + } + } + else if (step < 0) { + while (x > end) { + callback(x, i, this); + x += step; + i++; + } + } + }; + + /** + * Execute a callback function for each value in the Range, and return the + * results as an array + * @param {function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix being traversed. + * @returns {Array} array + */ + Range.prototype.map = function (callback) { + var array = []; + this.forEach(function (value, index, obj) { + array[index] = callback(value, index, obj); + }); + return array; + }; + + /** + * Create an Array with a copy of the Ranges data + * @returns {Array} array + */ + Range.prototype.toArray = function () { + var array = []; + this.forEach(function (value, index) { + array[index] = value; + }); + return array; + }; + + /** + * Get the primitive value of the Range, a one dimensional array + * @returns {Array} array + */ + Range.prototype.valueOf = function () { + // TODO: implement a caching mechanism for range.valueOf() + return this.toArray(); + }; + + /** + * Get a string representation of the range, with optional formatting options. + * Output is formatted as 'start:step:end', for example '2:6' or '0:0.2:11' + * @param {Object | Number | Function} [options] Formatting options. See + * lib/util/number:format for a + * description of the available + * options. + * @returns {String} str + */ + Range.prototype.format = function (options) { + var str = number.format(this.start, options); + + if (this.step != 1) { + str += ':' + number.format(this.step, options); + } + str += ':' + number.format(this.end, options); + return str; + }; + + /** + * Get a string representation of the range. + * @returns {String} + */ + Range.prototype.toString = function () { + return this.format(); + }; + + /** + * Get a JSON representation of the range + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` + */ + Range.prototype.toJSON = function () { + return { + mathjs: 'Range', + start: this.start, + end: this.end, + step: this.step + }; + }; + + /** + * Instantiate a Range from a JSON object + * @param {Object} json A JSON object structured as: + * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` + * @return {Range} + */ + Range.fromJSON = function (json) { + return new Range(json.start, json.end, json.step); + }; + + return Range; } - /** - * Parse a string into a range, - * The string contains the start, optional step, and end, separated by a colon. - * If the string does not contain a valid range, null is returned. - * For example str='0:2:11'. - * @param {String} str - * @return {Range | null} range - */ - Range.parse = function (str) { - if (!string.isString(str)) { - return null; - } - - var args = str.split(':'); - var nums = args.map(function (arg) { - return parseFloat(arg); - }); - - var invalid = nums.some(function (num) { - return isNaN(num); - }); - if(invalid) { - return null; - } - - switch (nums.length) { - case 2: return new Range(nums[0], nums[1]); - case 3: return new Range(nums[0], nums[2], nums[1]); - default: return null; - } - }; - - /** - * Create a clone of the range - * @return {Range} clone - */ - Range.prototype.clone = function () { - return new Range(this.start, this.end, this.step); - }; - - /** - * Test whether an object is a Range - * @param {*} object - * @return {Boolean} isRange - */ - Range.isRange = function (object) { - return (object instanceof Range); - }; - - /** - * Retrieve the size of the range. - * Returns an array containing one number, the number of elements in the range. - * @returns {Number[]} size - */ - Range.prototype.size = function () { - var len = 0, - start = this.start, - step = this.step, - end = this.end, - diff = end - start; - - if (number.sign(step) == number.sign(diff)) { - len = Math.ceil((diff) / step); - } - else if (diff == 0) { - len = 0; - } - - if (isNaN(len)) { - len = 0; - } - return [len]; - }; - - /** - * Calculate the minimum value in the range - * @return {Number | undefined} min - */ - Range.prototype.min = function () { - var size = this.size()[0]; - - if (size > 0) { - if (this.step > 0) { - // positive step - return this.start; - } - else { - // negative step - return this.start + (size - 1) * this.step; - } - } - else { - return undefined; - } - }; - - /** - * Calculate the maximum value in the range - * @return {Number | undefined} max - */ - Range.prototype.max = function () { - var size = this.size()[0]; - - if (size > 0) { - if (this.step > 0) { - // positive step - return this.start + (size - 1) * this.step; - } - else { - // negative step - return this.start; - } - } - else { - return undefined; - } - }; - - - /** - * Execute a callback function for each value in the range. - * @param {function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - */ - Range.prototype.forEach = function (callback) { - var x = this.start; - var step = this.step; - var end = this.end; - var i = 0; - - if (step > 0) { - while (x < end) { - callback(x, i, this); - x += step; - i++; - } - } - else if (step < 0) { - while (x > end) { - callback(x, i, this); - x += step; - i++; - } - } - }; - - /** - * Execute a callback function for each value in the Range, and return the - * results as an array - * @param {function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix being traversed. - * @returns {Array} array - */ - Range.prototype.map = function (callback) { - var array = []; - this.forEach(function (value, index, obj) { - array[index] = callback(value, index, obj); - }); - return array; - }; - - /** - * Create an Array with a copy of the Ranges data - * @returns {Array} array - */ - Range.prototype.toArray = function () { - var array = []; - this.forEach(function (value, index) { - array[index] = value; - }); - return array; - }; - - /** - * Get the primitive value of the Range, a one dimensional array - * @returns {Array} array - */ - Range.prototype.valueOf = function () { - // TODO: implement a caching mechanism for range.valueOf() - return this.toArray(); - }; - - /** - * Get a string representation of the range, with optional formatting options. - * Output is formatted as 'start:step:end', for example '2:6' or '0:0.2:11' - * @param {Object | Number | Function} [options] Formatting options. See - * lib/util/number:format for a - * description of the available - * options. - * @returns {String} str - */ - Range.prototype.format = function (options) { - var str = number.format(this.start, options); - - if (this.step != 1) { - str += ':' + number.format(this.step, options); - } - str += ':' + number.format(this.end, options); - return str; - }; - - /** - * Get a string representation of the range. - * @returns {String} - */ - Range.prototype.toString = function () { - return this.format(); - }; - - /** - * Get a JSON representation of the range - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` - */ - Range.prototype.toJSON = function () { - return { - mathjs: 'Range', - start: this.start, - end: this.end, - step: this.step - }; - }; - - /** - * Instantiate a Range from a JSON object - * @param {Object} json A JSON object structured as: - * `{"mathjs": "Range", "start": 2, "end": 4, "step": 1}` - * @return {Range} - */ - Range.fromJSON = function (json) { - return new Range(json.start, json.end, json.step); - }; - - // exports - module.exports = Range; + exports.name = 'Range'; + exports.path = 'type'; + exports.factory = factory; /***/ }, @@ -1488,295 +1294,296 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171), + var clone = __webpack_require__(33).clone; + var format = __webpack_require__(41).format; + var isInteger = __webpack_require__(41).isInteger; - Range = __webpack_require__(4), + function factory (type, config, load, typed) { + var Range = type.Range; - number = util.number, - - isNumber = number.isNumber, - isInteger = number.isInteger, - isArray = Array.isArray; - - /** - * @Constructor Index - * Create an index. An Index can store ranges having start, step, and end - * for multiple dimensions. - * Matrix.get, Matrix.set, and math.subset accept an Index as input. - * - * Usage: - * var index = new Index(range1, range2, ...); - * - * Where each range can be any of: - * An array [start, end] - * An array [start, end, step] - * A number - * An instance of Range - * - * The parameters start, end, and step must be integer numbers. - * - * @param {...*} ranges - */ - function Index(ranges) { - if (!(this instanceof Index)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this._ranges = []; - this._isScalar = true; - - for (var i = 0, ii = arguments.length; i < ii; i++) { - var arg = arguments[i]; - - if (arg instanceof Range) { - this._ranges.push(arg); - this._isScalar = false; + /** + * @Constructor Index + * Create an index. An Index can store ranges having start, step, and end + * for multiple dimensions. + * Matrix.get, Matrix.set, and math.subset accept an Index as input. + * + * Usage: + * var index = new Index(range1, range2, ...); + * + * Where each range can be any of: + * An array [start, end] + * An array [start, end, step] + * A number + * An instance of Range + * + * The parameters start, end, and step must be integer numbers. + * + * @param {...*} ranges + */ + function Index(ranges) { + if (!(this instanceof Index)) { + throw new SyntaxError('Constructor must be called with the new operator'); } - else if (isArray(arg)) { - this._ranges.push(_createRange(arg)); - this._isScalar = false; - } - else if (isNumber(arg)) { - this._ranges.push(_createRange([arg, arg + 1])); - } - // TODO: implement support for wildcard '*' - else { - var primitive = arg.valueOf(); // for example turn a Matrix into an Array - if (isArray(primitive)) { - this._ranges.push(_createRange(primitive)); + + this._ranges = []; + this._isScalar = true; + + for (var i = 0, ii = arguments.length; i < ii; i++) { + var arg = arguments[i]; + + if (arg instanceof Range) { + this._ranges.push(arg); this._isScalar = false; } + else if (Array.isArray(arg)) { + this._ranges.push(_createRange(arg)); + this._isScalar = false; + } + else if (typeof arg === 'number') { + this._ranges.push(_createRange([arg, arg + 1])); + } + // TODO: implement support for wildcard '*' else { - throw new TypeError('Ranges must be an Array, Number, or Range'); + var primitive = arg.valueOf(); // for example turn a Matrix into an Array + if (Array.isArray(primitive)) { + this._ranges.push(_createRange(primitive)); + this._isScalar = false; + } + else { + throw new TypeError('Ranges must be an Array, Number, or Range'); + } } } } - } - /** - * Parse an argument into a range and validate the range - * @param {Array} arg An array with [start: Number, end: Number] and - * optional a third element step:Number - * @return {Range} range - * @private - */ - function _createRange(arg) { - // TODO: make function _createRange simpler/faster + /** + * Parse an argument into a range and validate the range + * @param {Array} arg An array with [start: Number, end: Number] and + * optional a third element step:Number + * @return {Range} range + * @private + */ + function _createRange(arg) { + // TODO: make function _createRange simpler/faster - // test whether all arguments are integers - var num = arg.length; - for (var i = 0; i < num; i++) { - if (!isNumber(arg[i]) || !isInteger(arg[i])) { - throw new TypeError('Index parameters must be integer numbers'); - } - } - - switch (arg.length) { - case 2: - return new Range(arg[0], arg[1]); // start, end - case 3: - return new Range(arg[0], arg[1], arg[2]); // start, end, step - default: - // TODO: improve error message - throw new SyntaxError('Wrong number of arguments in Index (2 or 3 expected)'); - } - } - - /** - * Create a clone of the index - * @return {Index} clone - */ - Index.prototype.clone = function () { - var index = new Index(); - index._ranges = util.object.clone(this._ranges); - index._isScalar = this._isScalar; - return index; - }; - - /** - * Test whether an object is an Index - * @param {*} object - * @return {Boolean} isIndex - */ - Index.isIndex = function (object) { - return (object instanceof Index); - }; - - /** - * Create an index from an array with ranges/numbers - * @param {Array.} ranges - * @return {Index} index - * @private - */ - Index.create = function (ranges) { - var index = new Index(); - Index.apply(index, ranges); - return index; - }; - - /** - * Retrieve the size of the index, the number of elements for each dimension. - * @returns {Number[]} size - */ - Index.prototype.size = function () { - var size = []; - - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - var range = this._ranges[i]; - - size[i] = range.size()[0]; - } - - return size; - }; - - /** - * Get the maximum value for each of the indexes ranges. - * @returns {Number[]} max - */ - Index.prototype.max = function () { - var values = []; - - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - var range = this._ranges[i]; - values[i] = range.max(); - } - - return values; - }; - - /** - * Get the minimum value for each of the indexes ranges. - * @returns {Number[]} min - */ - Index.prototype.min = function () { - var values = []; - - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - var range = this._ranges[i]; - - values[i] = range.min(); - } - - return values; - }; - - /** - * Loop over each of the ranges of the index - * @param {function} callback Called for each range with a Range as first - * argument, the dimension as second, and the - * index object as third. - */ - Index.prototype.forEach = function (callback) { - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - callback(this._ranges[i], i, this); - } - }; - - /** - * Retrieve the range for a given dimension number from the index - * @param {Number} dim Number of the dimension - * @returns {Range | null} range - */ - Index.prototype.range = function(dim) { - return this._ranges[dim] || null; - }; - - /** - * Test whether this index contains only a single value. - * - * This is the case when the index is created with only scalar values as ranges, - * not for ranges resolving into a single value. - * @return {boolean} isScalar - */ - Index.prototype.isScalar = function () { - return this._isScalar; - }; - - /** - * Expand the Index into an array. - * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] - * @returns {Array} array - */ - Index.prototype.toArray = function () { - var array = []; - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - var range = this._ranges[i], - row = [], - x = range.start, - end = range.end, - step = range.step; - - if (step > 0) { - while (x < end) { - row.push(x); - x += step; - } - } - else if (step < 0) { - while (x > end) { - row.push(x); - x += step; + // test whether all arguments are integers + var num = arg.length; + for (var i = 0; i < num; i++) { + if (typeof arg[i] !== 'number' || !isInteger(arg[i])) { + throw new TypeError('Index parameters must be integer numbers'); } } - array.push(row); - } - - return array; - }; - - /** - * Get the primitive value of the Index, a two dimensional array. - * Equivalent to Index.toArray(). - * @returns {Array} array - */ - Index.prototype.valueOf = Index.prototype.toArray; - - /** - * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7]' - * @returns {String} str - */ - Index.prototype.toString = function () { - var strings = []; - - for (var i = 0, ii = this._ranges.length; i < ii; i++) { - var range = this._ranges[i]; - var str = number.format(range.start); - if (range.step != 1) { - str += ':' + number.format(range.step); + switch (arg.length) { + case 2: + return new Range(arg[0], arg[1]); // start, end + case 3: + return new Range(arg[0], arg[1], arg[2]); // start, end, step + default: + // TODO: improve error message + throw new SyntaxError('Wrong number of arguments in Index (2 or 3 expected)'); } - str += ':' + number.format(range.end); - strings.push(str); } - return '[' + strings.join(', ') + ']'; - }; - - /** - * Get a JSON representation of the Index - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` - */ - Index.prototype.toJSON = function () { - return { - mathjs: 'Index', - ranges: this._ranges + /** + * Create a clone of the index + * @return {Index} clone + */ + Index.prototype.clone = function () { + var index = new Index(); + index._ranges = clone(this._ranges); + index._isScalar = this._isScalar; + return index; }; - }; - /** - * Instantiate an Index from a JSON object - * @param {Object} json A JSON object structured as: - * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` - * @return {Index} - */ - Index.fromJSON = function (json) { - return Index.create(json.ranges); - }; + /** + * Test whether an object is an Index + * @param {*} object + * @return {Boolean} isIndex + */ + Index.isIndex = function (object) { + return (object instanceof Index); + }; - // exports - module.exports = Index; + /** + * Create an index from an array with ranges/numbers + * @param {Array.} ranges + * @return {Index} index + * @private + */ + Index.create = function (ranges) { + var index = new Index(); + Index.apply(index, ranges); + return index; + }; + + /** + * Retrieve the size of the index, the number of elements for each dimension. + * @returns {Number[]} size + */ + Index.prototype.size = function () { + var size = []; + + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + var range = this._ranges[i]; + + size[i] = range.size()[0]; + } + + return size; + }; + + /** + * Get the maximum value for each of the indexes ranges. + * @returns {Number[]} max + */ + Index.prototype.max = function () { + var values = []; + + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + var range = this._ranges[i]; + values[i] = range.max(); + } + + return values; + }; + + /** + * Get the minimum value for each of the indexes ranges. + * @returns {Number[]} min + */ + Index.prototype.min = function () { + var values = []; + + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + var range = this._ranges[i]; + + values[i] = range.min(); + } + + return values; + }; + + /** + * Loop over each of the ranges of the index + * @param {function} callback Called for each range with a Range as first + * argument, the dimension as second, and the + * index object as third. + */ + Index.prototype.forEach = function (callback) { + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + callback(this._ranges[i], i, this); + } + }; + + /** + * Retrieve the range for a given dimension number from the index + * @param {Number} dim Number of the dimension + * @returns {Range | null} range + */ + Index.prototype.range = function (dim) { + return this._ranges[dim] || null; + }; + + /** + * Test whether this index contains only a single value. + * + * This is the case when the index is created with only scalar values as ranges, + * not for ranges resolving into a single value. + * @return {boolean} isScalar + */ + Index.prototype.isScalar = function () { + return this._isScalar; + }; + + /** + * Expand the Index into an array. + * For example new Index([0,3], [2,7]) returns [[0,1,2], [2,3,4,5,6]] + * @returns {Array} array + */ + Index.prototype.toArray = function () { + var array = []; + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + var range = this._ranges[i], + row = [], + x = range.start, + end = range.end, + step = range.step; + + if (step > 0) { + while (x < end) { + row.push(x); + x += step; + } + } + else if (step < 0) { + while (x > end) { + row.push(x); + x += step; + } + } + + array.push(row); + } + + return array; + }; + + /** + * Get the primitive value of the Index, a two dimensional array. + * Equivalent to Index.toArray(). + * @returns {Array} array + */ + Index.prototype.valueOf = Index.prototype.toArray; + + /** + * Get the string representation of the index, for example '[2:6]' or '[0:2:10, 4:7]' + * @returns {String} str + */ + Index.prototype.toString = function () { + var strings = []; + + for (var i = 0, ii = this._ranges.length; i < ii; i++) { + var range = this._ranges[i]; + var str = format(range.start); + if (range.step != 1) { + str += ':' + format(range.step); + } + str += ':' + format(range.end); + strings.push(str); + } + + return '[' + strings.join(', ') + ']'; + }; + + /** + * Get a JSON representation of the Index + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` + */ + Index.prototype.toJSON = function () { + return { + mathjs: 'Index', + ranges: this._ranges + }; + }; + + /** + * Instantiate an Index from a JSON object + * @param {Object} json A JSON object structured as: + * `{"mathjs": "Index", "ranges": [{"mathjs": "Range", start: 0, end: 10, step:1}, ...]}` + * @return {Index} + */ + Index.fromJSON = function (json) { + return Index.create(json.ranges); + }; + + return Index; + } + + exports.name = 'Index'; + exports.path = 'type'; + exports.factory = factory; /***/ }, @@ -1785,7 +1592,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171); + var util = __webpack_require__(36); var string = util.string; @@ -2037,897 +1844,1544 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171), + var format = __webpack_require__(41).format; + var endsWith = __webpack_require__(42).endsWith; - number = util.number, - string = util.string, - isNumber = util.number.isNumber, - isString = util.string.isString; - - /** - * @constructor Unit - * - * A unit can be constructed in the following ways: - * var a = new Unit(value, name); - * var b = new Unit(null, name); - * var c = Unit.parse(str); - * - * Example usage: - * var a = new Unit(5, 'cm'); // 50 mm - * var b = Unit.parse('23 kg'); // 23 kg - * var c = math.in(a, new Unit(null, 'm'); // 0.05 m - * - * @param {Number} [value] A value like 5.2 - * @param {String} [name] A unit name like "cm" or "inch". Can include a prefix - */ - function Unit(value, name) { - if (!(this instanceof Unit)) { - throw new Error('Constructor must be called with the new operator'); - } - - if (value != undefined && !isNumber(value)) { - throw new TypeError('First parameter in Unit constructor must be a number'); - } - if (name != undefined && (!isString(name) || name == '')) { - throw new TypeError('Second parameter in Unit constructor must be a string'); - } - - if (name != undefined) { - // find the unit and prefix from the string - var res = _findUnit(name); - if (!res) { - throw new SyntaxError('Unknown unit "' + name + '"'); + function factory (type, config, load, typed) { + /** + * @constructor Unit + * + * A unit can be constructed in the following ways: + * var a = new Unit(value, name); + * var b = new Unit(null, name); + * var c = Unit.parse(str); + * + * Example usage: + * var a = new Unit(5, 'cm'); // 50 mm + * var b = Unit.parse('23 kg'); // 23 kg + * var c = math.in(a, new Unit(null, 'm'); // 0.05 m + * + * @param {Number} [value] A value like 5.2 + * @param {String} [name] A unit name like "cm" or "inch". Can include a prefix + */ + function Unit(value, name) { + if (!(this instanceof Unit)) { + throw new Error('Constructor must be called with the new operator'); } - this.unit = res.unit; - this.prefix = res.prefix; - } - else { - this.unit = UNIT_NONE; - this.prefix = PREFIX_NONE; // link to a list with supported prefixes + + if (value != undefined && typeof value !== 'number') { + throw new TypeError('First parameter in Unit constructor must be a number'); + } + if (name != undefined && (typeof name !== 'string' || name == '')) { + throw new TypeError('Second parameter in Unit constructor must be a string'); + } + + if (name != undefined) { + // find the unit and prefix from the string + var res = _findUnit(name); + if (!res) { + throw new SyntaxError('Unknown unit "' + name + '"'); + } + this.unit = res.unit; + this.prefix = res.prefix; + } + else { + this.unit = UNIT_NONE; + this.prefix = PREFIX_NONE; // link to a list with supported prefixes + } + + this.value = (value != undefined) ? this._normalize(value) : null; + this.fixPrefix = false; // if true, function format will not search for the + // best prefix but leave it as initially provided. + // fixPrefix is set true by the method Unit.to } - this.value = (value != undefined) ? this._normalize(value) : null; - this.fixPrefix = false; // if true, function format will not search for the - // best prefix but leave it as initially provided. - // fixPrefix is set true by the method Unit.to - } + // private variables and functions for the Unit parser + var text, index, c; - // private variables and functions for the Unit parser - var text, index, c; - - function skipWhitespace() { - while (c == ' ' || c == '\t') { - next(); - } - } - - function isDigitDot (c) { - return ((c >= '0' && c <= '9') || c == '.'); - } - - function isDigit (c) { - return ((c >= '0' && c <= '9')); - } - - function next() { - index++; - c = text.charAt(index); - } - - function revert(oldIndex) { - index = oldIndex; - c = text.charAt(index); - } - - function parseNumber () { - var number = ''; - var oldIndex; - oldIndex = index; - - if (c == '+') { - next(); - } - else if (c == '-') { - number += c; - next(); - } - - if (!isDigitDot(c)) { - // a + or - must be followed by a digit - revert(oldIndex); - return null; - } - - // get number, can have a single dot - if (c == '.') { - number += c; - next(); - if (!isDigit(c)) { - // this is no legal number, it is just a dot - revert(oldIndex); - return null; + function skipWhitespace() { + while (c == ' ' || c == '\t') { + next(); } } - else { - while (isDigit(c)) { + + function isDigitDot(c) { + return ((c >= '0' && c <= '9') || c == '.'); + } + + function isDigit(c) { + return ((c >= '0' && c <= '9')); + } + + function next() { + index++; + c = text.charAt(index); + } + + function revert(oldIndex) { + index = oldIndex; + c = text.charAt(index); + } + + function parseNumber() { + var number = ''; + var oldIndex; + oldIndex = index; + + if (c == '+') { + next(); + } + else if (c == '-') { number += c; next(); } + + if (!isDigitDot(c)) { + // a + or - must be followed by a digit + revert(oldIndex); + return null; + } + + // get number, can have a single dot if (c == '.') { number += c; next(); + if (!isDigit(c)) { + // this is no legal number, it is just a dot + revert(oldIndex); + return null; + } } - } - while (isDigit(c)) { - number += c; - next(); - } - - // check for exponential notation like "2.3e-4" or "1.23e50" - if (c == 'E' || c == 'e') { - number += c; - next(); - - if (c == '+' || c == '-') { - number += c; - next(); + else { + while (isDigit(c)) { + number += c; + next(); + } + if (c == '.') { + number += c; + next(); + } } - - // Scientific notation MUST be followed by an exponent - if (!isDigit(c)) { - // this is no legal number, exponent is missing. - revert(oldIndex); - return null; - } - while (isDigit(c)) { number += c; next(); } + + // check for exponential notation like "2.3e-4" or "1.23e50" + if (c == 'E' || c == 'e') { + number += c; + next(); + + if (c == '+' || c == '-') { + number += c; + next(); + } + + // Scientific notation MUST be followed by an exponent + if (!isDigit(c)) { + // this is no legal number, exponent is missing. + revert(oldIndex); + return null; + } + + while (isDigit(c)) { + number += c; + next(); + } + } + + return number; } - return number; - } + function parseUnit() { + var unitName = ''; - function parseUnit() { - var unitName = ''; + skipWhitespace(); + while (c && c != ' ' && c != '\t') { + unitName += c; + next(); + } + + return unitName || null; + } + + /** + * Parse a string into a unit. Returns null if the provided string does not + * contain a valid unit. + * @param {String} str A string like "5.2 inch", "4e2 kg" + * @return {Unit | null} unit + */ + Unit.parse = function (str) { + text = str; + index = -1; + c = ''; + + if (typeof text !== 'string') { + return null; + } - skipWhitespace(); - while (c && c != ' ' && c != '\t') { - unitName += c; next(); - } + skipWhitespace(); + var value = parseNumber(); + var name; + if (value) { + name = parseUnit(); - return unitName || null; - } + next(); + skipWhitespace(); + if (c) { + // garbage at the end. not good. + return null; + } - /** - * Parse a string into a unit. Returns null if the provided string does not - * contain a valid unit. - * @param {String} str A string like "5.2 inch", "4e2 kg" - * @return {Unit | null} unit - */ - Unit.parse = function(str) { - text = str; - index = -1; - c = ''; + if (value && name) { + try { + // constructor will throw an error when unit is not found + return new Unit(Number(value), name); + } + catch (err) { + } + } + } + else { + name = parseUnit(); + + next(); + skipWhitespace(); + if (c) { + // garbage at the end. not good. + return null; + } + + if (name) { + try { + // constructor will throw an error when unit is not found + return new Unit(null, name); + } + catch (err) { + } + } + } + + return null; + }; + + /** + * Test whether value is of type Unit + * @param {*} value + * @return {Boolean} isUnit + */ + Unit.isUnit = function (value) { + return (value instanceof Unit); + }; + + /** + * create a copy of this unit + * @return {Unit} clone + */ + Unit.prototype.clone = function () { + var clone = new Unit(); + + for (var p in this) { + if (this.hasOwnProperty(p)) { + clone[p] = this[p]; + } + } + + return clone; + }; + + /** + * Normalize a value, based on its currently set unit + * @param {Number} value + * @return {Number} normalized value + * @private + */ + Unit.prototype._normalize = function (value) { + return (value + this.unit.offset) * this.unit.value * this.prefix.value; + }; + + /** + * Denormalize a value, based on its currently set unit + * @param {Number} value + * @param {Number} [prefixValue] Optional prefix value to be used + * @return {Number} denormalized value + * @private + */ + Unit.prototype._denormalize = function (value, prefixValue) { + if (prefixValue == undefined) { + return value / this.unit.value / this.prefix.value - this.unit.offset; + } + else { + return value / this.unit.value / prefixValue - this.unit.offset; + } + }; + + /** + * Find a unit from a string + * @param {String} str A string like 'cm' or 'inch' + * @returns {Object | null} result When found, an object with fields unit and + * prefix is returned. Else, null is returned. + * @private + */ + function _findUnit(str) { + for (var name in UNITS) { + if (UNITS.hasOwnProperty(name)) { + if (endsWith(str, name)) { + var unit = UNITS[name]; + var prefixLen = (str.length - name.length); + var prefixName = str.substring(0, prefixLen); + var prefix = unit.prefixes[prefixName]; + if (prefix !== undefined) { + // store unit, prefix, and value + return { + unit: unit, + prefix: prefix + }; + } + } + } + } - if (!isString(text)) { return null; } - next(); - skipWhitespace(); - var value = parseNumber(); - var name; - if (value) { - name = parseUnit(); - - next(); - skipWhitespace(); - if (c) { - // garbage at the end. not good. - return null; - } - - if (value && name) { - try { - // constructor will throw an error when unit is not found - return new Unit(Number(value), name); - } - catch (err) {} - } - } - else { - name = parseUnit(); - - next(); - skipWhitespace(); - if (c) { - // garbage at the end. not good. - return null; - } - - if (name) { - try { - // constructor will throw an error when unit is not found - return new Unit(null, name); - } - catch (err) {} - } - } - - return null; - }; - - /** - * Test whether value is of type Unit - * @param {*} value - * @return {Boolean} isUnit - */ - Unit.isUnit = function(value) { - return (value instanceof Unit); - }; - - /** - * create a copy of this unit - * @return {Unit} clone - */ - Unit.prototype.clone = function () { - var clone = new Unit(); - - for (var p in this) { - if (this.hasOwnProperty(p)) { - clone[p] = this[p]; - } - } - - return clone; - }; - - /** - * Normalize a value, based on its currently set unit - * @param {Number} value - * @return {Number} normalized value - * @private - */ - Unit.prototype._normalize = function(value) { - return (value + this.unit.offset) * this.unit.value * this.prefix.value; - }; - - /** - * Denormalize a value, based on its currently set unit - * @param {Number} value - * @param {Number} [prefixValue] Optional prefix value to be used - * @return {Number} denormalized value - * @private - */ - Unit.prototype._denormalize = function (value, prefixValue) { - if (prefixValue == undefined) { - return value / this.unit.value / this.prefix.value - this.unit.offset; - } - else { - return value / this.unit.value / prefixValue - this.unit.offset; - } - }; - - /** - * Find a unit from a string - * @param {String} str A string like 'cm' or 'inch' - * @returns {Object | null} result When found, an object with fields unit and - * prefix is returned. Else, null is returned. - * @private - */ - function _findUnit(str) { - for (var name in UNITS) { - if (UNITS.hasOwnProperty(name)) { - if (string.endsWith(str, name) ) { - var unit = UNITS[name]; - var prefixLen = (str.length - name.length); - var prefixName = str.substring(0, prefixLen); - var prefix = unit.prefixes[prefixName]; - if (prefix !== undefined) { - // store unit, prefix, and value - return { - unit: unit, - prefix: prefix - }; - } - } - } - } - - return null; - } - - /** - * Test if the given expression is a unit. - * The unit can have a prefix but cannot have a value. - * @param {String} name A string to be tested whether it is a value less unit. - * The unit can have prefix, like "cm" - * @return {Boolean} true if the given string is a unit - */ - Unit.isValuelessUnit = function (name) { - return (_findUnit(name) != null); - }; - - /** - * check if this unit has given base unit - * @param {BASE_UNITS | undefined} base - */ - Unit.prototype.hasBase = function(base) { - return (this.unit.base === base); - }; - - /** - * Check if this unit has a base equal to another base - * @param {Unit} other - * @return {Boolean} true if equal base - */ - Unit.prototype.equalBase = function(other) { - return (this.unit.base === other.unit.base); - }; - - /** - * Check if this unit equals another unit - * @param {Unit} other - * @return {Boolean} true if both units are equal - */ - Unit.prototype.equals = function(other) { - return (this.equalBase(other) && this.value == other.value); - }; - - /** - * Create a clone of this unit with a representation - * @param {String | Unit} valuelessUnit A unit without value. Can have prefix, like "cm" - * @returns {Unit} unit having fixed, specified unit - */ - Unit.prototype.to = function (valuelessUnit) { - var other; - var value = this.value == null ? this._normalize(1) : this.value; - if (isString(valuelessUnit)) { - other = new Unit(null, valuelessUnit); - - if (!this.equalBase(other)) { - throw new Error('Units do not match'); - } - - other.value = value; - other.fixPrefix = true; - return other; - } - else if (valuelessUnit instanceof Unit) { - if (!this.equalBase(valuelessUnit)) { - throw new Error('Units do not match'); - } - if (valuelessUnit.value !== null) { - throw new Error('Cannot convert to a unit with a value'); - } - - other = valuelessUnit.clone(); - other.value = value; - other.fixPrefix = true; - return other; - } - else { - throw new Error('String or Unit expected as parameter'); - } - }; - - /** - * Return the value of the unit when represented with given valueless unit - * @param {String | Unit} valuelessUnit For example 'cm' or 'inch' - * @return {Number} value - */ - Unit.prototype.toNumber = function (valuelessUnit) { - var other = this.to(valuelessUnit); - return other._denormalize(other.value, other.prefix.value); - }; - - - /** - * Get a string representation of the unit. - * @return {String} - */ - Unit.prototype.toString = function() { - return this.format(); - }; - - /** - * Get a JSON representation of the unit - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}` - */ - Unit.prototype.toJSON = function () { - return { - mathjs: 'Unit', - value: this._denormalize(this.value), - unit: this.prefix.name + this.unit.name, - fixPrefix: this.fixPrefix + /** + * Test if the given expression is a unit. + * The unit can have a prefix but cannot have a value. + * @param {String} name A string to be tested whether it is a value less unit. + * The unit can have prefix, like "cm" + * @return {Boolean} true if the given string is a unit + */ + Unit.isValuelessUnit = function (name) { + return (_findUnit(name) != null); }; - }; - /** - * Instantiate a Unit from a JSON object - * @param {Object} json A JSON object structured as: - * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}` - * @return {Unit} - */ - Unit.fromJSON = function (json) { - var unit = new Unit(json.value, json.unit); - unit.fixPrefix = json.fixPrefix || false; - return unit; - }; + /** + * check if this unit has given base unit + * @param {BASE_UNITS | undefined} base + */ + Unit.prototype.hasBase = function (base) { + return (this.unit.base === base); + }; - /** - * Returns the string representation of the unit. - * @return {String} - */ - Unit.prototype.valueOf = Unit.prototype.toString; + /** + * Check if this unit has a base equal to another base + * @param {Unit} other + * @return {Boolean} true if equal base + */ + Unit.prototype.equalBase = function (other) { + return (this.unit.base === other.unit.base); + }; - /** - * Get a string representation of the Unit, with optional formatting options. - * @param {Object | Number | Function} [options] Formatting options. See - * lib/util/number:format for a - * description of the available - * options. - * @return {String} - */ - Unit.prototype.format = function(options) { - var value, - str; + /** + * Check if this unit equals another unit + * @param {Unit} other + * @return {Boolean} true if both units are equal + */ + Unit.prototype.equals = function (other) { + return (this.equalBase(other) && this.value == other.value); + }; - if (this.value !== null && !this.fixPrefix) { - var bestPrefix = this._bestPrefix(); - value = this._denormalize(this.value, bestPrefix.value); - str = number.format(value, options) + ' '; - str += bestPrefix.name + this.unit.name; - } - else { - value = this._denormalize(this.value); - str = (this.value !== null) ? (number.format(value, options) + ' ') : ''; - str += this.prefix.name + this.unit.name; - } + /** + * Create a clone of this unit with a representation + * @param {String | Unit} valuelessUnit A unit without value. Can have prefix, like "cm" + * @returns {Unit} unit having fixed, specified unit + */ + Unit.prototype.to = function (valuelessUnit) { + var other; + var value = this.value == null ? this._normalize(1) : this.value; + if (typeof valuelessUnit === 'string') { + other = new Unit(null, valuelessUnit); - return str; - }; + if (!this.equalBase(other)) { + throw new Error('Units do not match'); + } - /** - * Calculate the best prefix using current value. - * @returns {Object} prefix - * @private - */ - Unit.prototype._bestPrefix = function () { - // find the best prefix value (resulting in the value of which - // the absolute value of the log10 is closest to zero, - // though with a little offset of 1.2 for nicer values: you get a - // sequence 1mm 100mm 500mm 0.6m 1m 10m 100m 500m 0.6km 1km ... - var absValue = Math.abs(this.value / this.unit.value); - var bestPrefix = PREFIX_NONE; - var bestDiff = Math.abs( - Math.log(absValue / bestPrefix.value) / Math.LN10 - 1.2); + other.value = value; + other.fixPrefix = true; + return other; + } + else if (valuelessUnit instanceof Unit) { + if (!this.equalBase(valuelessUnit)) { + throw new Error('Units do not match'); + } + if (valuelessUnit.value !== null) { + throw new Error('Cannot convert to a unit with a value'); + } - var prefixes = this.unit.prefixes; - for (var p in prefixes) { - if (prefixes.hasOwnProperty(p)) { - var prefix = prefixes[p]; - if (prefix.scientific) { - var diff = Math.abs( - Math.log(absValue / prefix.value) / Math.LN10 - 1.2); + other = valuelessUnit.clone(); + other.value = value; + other.fixPrefix = true; + return other; + } + else { + throw new Error('String or Unit expected as parameter'); + } + }; - if (diff < bestDiff) { - bestPrefix = prefix; - bestDiff = diff; + /** + * Return the value of the unit when represented with given valueless unit + * @param {String | Unit} valuelessUnit For example 'cm' or 'inch' + * @return {Number} value + */ + Unit.prototype.toNumber = function (valuelessUnit) { + var other = this.to(valuelessUnit); + return other._denormalize(other.value, other.prefix.value); + }; + + + /** + * Get a string representation of the unit. + * @return {String} + */ + Unit.prototype.toString = function () { + return this.format(); + }; + + /** + * Get a JSON representation of the unit + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}` + */ + Unit.prototype.toJSON = function () { + return { + mathjs: 'Unit', + value: this._denormalize(this.value), + unit: this.prefix.name + this.unit.name, + fixPrefix: this.fixPrefix + }; + }; + + /** + * Instantiate a Unit from a JSON object + * @param {Object} json A JSON object structured as: + * `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}` + * @return {Unit} + */ + Unit.fromJSON = function (json) { + var unit = new Unit(json.value, json.unit); + unit.fixPrefix = json.fixPrefix || false; + return unit; + }; + + /** + * Returns the string representation of the unit. + * @return {String} + */ + Unit.prototype.valueOf = Unit.prototype.toString; + + /** + * Get a string representation of the Unit, with optional formatting options. + * @param {Object | Number | Function} [options] Formatting options. See + * lib/util/number:format for a + * description of the available + * options. + * @return {String} + */ + Unit.prototype.format = function (options) { + var value, + str; + + if (this.value !== null && !this.fixPrefix) { + var bestPrefix = this._bestPrefix(); + value = this._denormalize(this.value, bestPrefix.value); + str = format(value, options) + ' '; + str += bestPrefix.name + this.unit.name; + } + else { + value = this._denormalize(this.value); + str = (this.value !== null) ? (format(value, options) + ' ') : ''; + str += this.prefix.name + this.unit.name; + } + + return str; + }; + + /** + * Calculate the best prefix using current value. + * @returns {Object} prefix + * @private + */ + Unit.prototype._bestPrefix = function () { + // find the best prefix value (resulting in the value of which + // the absolute value of the log10 is closest to zero, + // though with a little offset of 1.2 for nicer values: you get a + // sequence 1mm 100mm 500mm 0.6m 1m 10m 100m 500m 0.6km 1km ... + var absValue = Math.abs(this.value / this.unit.value); + var bestPrefix = PREFIX_NONE; + var bestDiff = Math.abs( + Math.log(absValue / bestPrefix.value) / Math.LN10 - 1.2); + + var prefixes = this.unit.prefixes; + for (var p in prefixes) { + if (prefixes.hasOwnProperty(p)) { + var prefix = prefixes[p]; + if (prefix.scientific) { + var diff = Math.abs( + Math.log(absValue / prefix.value) / Math.LN10 - 1.2); + + if (diff < bestDiff) { + bestPrefix = prefix; + bestDiff = diff; + } } } } + + return bestPrefix; + }; + + var PREFIXES = { + NONE: { + '': {name: '', value: 1, scientific: true} + }, + SHORT: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e1, scientific: false}, + 'h': {name: 'h', value: 1e2, scientific: false}, + 'k': {name: 'k', value: 1e3, scientific: true}, + 'M': {name: 'M', value: 1e6, scientific: true}, + 'G': {name: 'G', value: 1e9, scientific: true}, + 'T': {name: 'T', value: 1e12, scientific: true}, + 'P': {name: 'P', value: 1e15, scientific: true}, + 'E': {name: 'E', value: 1e18, scientific: true}, + 'Z': {name: 'Z', value: 1e21, scientific: true}, + 'Y': {name: 'Y', value: 1e24, scientific: true}, + + 'd': {name: 'd', value: 1e-1, scientific: false}, + 'c': {name: 'c', value: 1e-2, scientific: false}, + 'm': {name: 'm', value: 1e-3, scientific: true}, + 'u': {name: 'u', value: 1e-6, scientific: true}, + 'n': {name: 'n', value: 1e-9, scientific: true}, + 'p': {name: 'p', value: 1e-12, scientific: true}, + 'f': {name: 'f', value: 1e-15, scientific: true}, + 'a': {name: 'a', value: 1e-18, scientific: true}, + 'z': {name: 'z', value: 1e-21, scientific: true}, + 'y': {name: 'y', value: 1e-24, scientific: true} + }, + LONG: { + '': {name: '', value: 1, scientific: true}, + + 'deca': {name: 'deca', value: 1e1, scientific: false}, + 'hecto': {name: 'hecto', value: 1e2, scientific: false}, + 'kilo': {name: 'kilo', value: 1e3, scientific: true}, + 'mega': {name: 'mega', value: 1e6, scientific: true}, + 'giga': {name: 'giga', value: 1e9, scientific: true}, + 'tera': {name: 'tera', value: 1e12, scientific: true}, + 'peta': {name: 'peta', value: 1e15, scientific: true}, + 'exa': {name: 'exa', value: 1e18, scientific: true}, + 'zetta': {name: 'zetta', value: 1e21, scientific: true}, + 'yotta': {name: 'yotta', value: 1e24, scientific: true}, + + 'deci': {name: 'deci', value: 1e-1, scientific: false}, + 'centi': {name: 'centi', value: 1e-2, scientific: false}, + 'milli': {name: 'milli', value: 1e-3, scientific: true}, + 'micro': {name: 'micro', value: 1e-6, scientific: true}, + 'nano': {name: 'nano', value: 1e-9, scientific: true}, + 'pico': {name: 'pico', value: 1e-12, scientific: true}, + 'femto': {name: 'femto', value: 1e-15, scientific: true}, + 'atto': {name: 'atto', value: 1e-18, scientific: true}, + 'zepto': {name: 'zepto', value: 1e-21, scientific: true}, + 'yocto': {name: 'yocto', value: 1e-24, scientific: true} + }, + SQUARED: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e2, scientific: false}, + 'h': {name: 'h', value: 1e4, scientific: false}, + 'k': {name: 'k', value: 1e6, scientific: true}, + 'M': {name: 'M', value: 1e12, scientific: true}, + 'G': {name: 'G', value: 1e18, scientific: true}, + 'T': {name: 'T', value: 1e24, scientific: true}, + 'P': {name: 'P', value: 1e30, scientific: true}, + 'E': {name: 'E', value: 1e36, scientific: true}, + 'Z': {name: 'Z', value: 1e42, scientific: true}, + 'Y': {name: 'Y', value: 1e48, scientific: true}, + + 'd': {name: 'd', value: 1e-2, scientific: false}, + 'c': {name: 'c', value: 1e-4, scientific: false}, + 'm': {name: 'm', value: 1e-6, scientific: true}, + 'u': {name: 'u', value: 1e-12, scientific: true}, + 'n': {name: 'n', value: 1e-18, scientific: true}, + 'p': {name: 'p', value: 1e-24, scientific: true}, + 'f': {name: 'f', value: 1e-30, scientific: true}, + 'a': {name: 'a', value: 1e-36, scientific: true}, + 'z': {name: 'z', value: 1e-42, scientific: true}, + 'y': {name: 'y', value: 1e-42, scientific: true} + }, + CUBIC: { + '': {name: '', value: 1, scientific: true}, + + 'da': {name: 'da', value: 1e3, scientific: false}, + 'h': {name: 'h', value: 1e6, scientific: false}, + 'k': {name: 'k', value: 1e9, scientific: true}, + 'M': {name: 'M', value: 1e18, scientific: true}, + 'G': {name: 'G', value: 1e27, scientific: true}, + 'T': {name: 'T', value: 1e36, scientific: true}, + 'P': {name: 'P', value: 1e45, scientific: true}, + 'E': {name: 'E', value: 1e54, scientific: true}, + 'Z': {name: 'Z', value: 1e63, scientific: true}, + 'Y': {name: 'Y', value: 1e72, scientific: true}, + + 'd': {name: 'd', value: 1e-3, scientific: false}, + 'c': {name: 'c', value: 1e-6, scientific: false}, + 'm': {name: 'm', value: 1e-9, scientific: true}, + 'u': {name: 'u', value: 1e-18, scientific: true}, + 'n': {name: 'n', value: 1e-27, scientific: true}, + 'p': {name: 'p', value: 1e-36, scientific: true}, + 'f': {name: 'f', value: 1e-45, scientific: true}, + 'a': {name: 'a', value: 1e-54, scientific: true}, + 'z': {name: 'z', value: 1e-63, scientific: true}, + 'y': {name: 'y', value: 1e-72, scientific: true} + }, + BINARY_SHORT: { + '': {name: '', value: 1, scientific: true}, + 'k': {name: 'k', value: 1e3, scientific: true}, + 'M': {name: 'M', value: 1e6, scientific: true}, + 'G': {name: 'G', value: 1e9, scientific: true}, + 'T': {name: 'T', value: 1e12, scientific: true}, + 'P': {name: 'P', value: 1e15, scientific: true}, + 'E': {name: 'E', value: 1e18, scientific: true}, + 'Z': {name: 'Z', value: 1e21, scientific: true}, + 'Y': {name: 'Y', value: 1e24, scientific: true}, + + 'Ki': {name: 'Ki', value: 1024, scientific: true}, + 'Mi': {name: 'Mi', value: Math.pow(1024, 2), scientific: true}, + 'Gi': {name: 'Gi', value: Math.pow(1024, 3), scientific: true}, + 'Ti': {name: 'Ti', value: Math.pow(1024, 4), scientific: true}, + 'Pi': {name: 'Pi', value: Math.pow(1024, 5), scientific: true}, + 'Ei': {name: 'Ei', value: Math.pow(1024, 6), scientific: true}, + 'Zi': {name: 'Zi', value: Math.pow(1024, 7), scientific: true}, + 'Yi': {name: 'Yi', value: Math.pow(1024, 8), scientific: true} + }, + BINARY_LONG: { + '': {name: '', value: 1, scientific: true}, + 'kilo': {name: 'kilo', value: 1e3, scientific: true}, + 'mega': {name: 'mega', value: 1e6, scientific: true}, + 'giga': {name: 'giga', value: 1e9, scientific: true}, + 'tera': {name: 'tera', value: 1e12, scientific: true}, + 'peta': {name: 'peta', value: 1e15, scientific: true}, + 'exa': {name: 'exa', value: 1e18, scientific: true}, + 'zetta': {name: 'zetta', value: 1e21, scientific: true}, + 'yotta': {name: 'yotta', value: 1e24, scientific: true}, + + 'kibi': {name: 'kibi', value: 1024, scientific: true}, + 'mebi': {name: 'mebi', value: Math.pow(1024, 2), scientific: true}, + 'gibi': {name: 'gibi', value: Math.pow(1024, 3), scientific: true}, + 'tebi': {name: 'tebi', value: Math.pow(1024, 4), scientific: true}, + 'pebi': {name: 'pebi', value: Math.pow(1024, 5), scientific: true}, + 'exi': {name: 'exi', value: Math.pow(1024, 6), scientific: true}, + 'zebi': {name: 'zebi', value: Math.pow(1024, 7), scientific: true}, + 'yobi': {name: 'yobi', value: Math.pow(1024, 8), scientific: true} + } + }; + + var PREFIX_NONE = {name: '', value: 1, scientific: true}; + + var BASE_UNITS = { + NONE: {}, + + LENGTH: {}, // meter + MASS: {}, // kilogram + TIME: {}, // second + CURRENT: {}, // ampere + TEMPERATURE: {}, // kelvin + LUMINOUS_INTENSITY: {}, // candela + AMOUNT_OF_SUBSTANCE: {}, // mole + + FORCE: {}, // Newton + SURFACE: {}, // m2 + VOLUME: {}, // m3 + ANGLE: {}, // rad + BIT: {} // bit (digital) + }; + + var BASE_UNIT_NONE = {}; + + var UNIT_NONE = {name: '', base: BASE_UNIT_NONE, value: 1, offset: 0}; + + var UNITS = { + // length + meter: { + name: 'meter', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + inch: { + name: 'inch', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0254, + offset: 0 + }, + foot: { + name: 'foot', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.3048, + offset: 0 + }, + yard: { + name: 'yard', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.9144, + offset: 0 + }, + mile: { + name: 'mile', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1609.344, + offset: 0 + }, + link: { + name: 'link', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.201168, + offset: 0 + }, + rod: { + name: 'rod', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 5.029210, + offset: 0 + }, + chain: { + name: 'chain', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 20.1168, + offset: 0 + }, + angstrom: { + name: 'angstrom', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1e-10, + offset: 0 + }, + + m: { + name: 'm', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + 'in': { + name: 'in', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0254, + offset: 0 + }, + ft: { + name: 'ft', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.3048, + offset: 0 + }, + yd: { + name: 'yd', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.9144, + offset: 0 + }, + mi: { + name: 'mi', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 1609.344, + offset: 0 + }, + li: { + name: 'li', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.201168, + offset: 0 + }, + rd: { + name: 'rd', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 5.029210, + offset: 0 + }, + ch: { + name: 'ch', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 20.1168, + offset: 0 + }, + mil: { + name: 'mil', + base: BASE_UNITS.LENGTH, + prefixes: PREFIXES.NONE, + value: 0.0000254, + offset: 0 + }, // 1/1000 inch + + // Surface + m2: { + name: 'm2', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.SQUARED, + value: 1, + offset: 0 + }, + sqin: { + name: 'sqin', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.00064516, + offset: 0 + }, // 645.16 mm2 + sqft: { + name: 'sqft', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.09290304, + offset: 0 + }, // 0.09290304 m2 + sqyd: { + name: 'sqyd', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 0.83612736, + offset: 0 + }, // 0.83612736 m2 + sqmi: { + name: 'sqmi', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 2589988.110336, + offset: 0 + }, // 2.589988110336 km2 + sqrd: { + name: 'sqrd', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 25.29295, + offset: 0 + }, // 25.29295 m2 + sqch: { + name: 'sqch', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 404.6873, + offset: 0 + }, // 404.6873 m2 + sqmil: { + name: 'sqmil', + base: BASE_UNITS.SURFACE, + prefixes: PREFIXES.NONE, + value: 6.4516e-10, + offset: 0 + }, // 6.4516 * 10^-10 m2 + + // Volume + m3: { + name: 'm3', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.CUBIC, + value: 1, + offset: 0 + }, + L: { + name: 'L', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, // litre + l: { + name: 'l', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, // litre + litre: { + name: 'litre', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.LONG, + value: 0.001, + offset: 0 + }, + cuin: { + name: 'cuin', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 1.6387064e-5, + offset: 0 + }, // 1.6387064e-5 m3 + cuft: { + name: 'cuft', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.028316846592, + offset: 0 + }, // 28.316 846 592 L + cuyd: { + name: 'cuyd', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.764554857984, + offset: 0 + }, // 764.554 857 984 L + teaspoon: { + name: 'teaspoon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.000005, + offset: 0 + }, // 5 mL + tablespoon: { + name: 'tablespoon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.000015, + offset: 0 + }, // 15 mL + //{name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup + drop: { + name: 'drop', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 5e-8, + offset: 0 + }, // 0.05 mL = 5e-8 m3 + gtt: { + name: 'gtt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 5e-8, + offset: 0 + }, // 0.05 mL = 5e-8 m3 + + // Liquid volume + minim: { + name: 'minim', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00000006161152, + offset: 0 + }, // 0.06161152 mL + fluiddram: { + name: 'fluiddram', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0000036966911, + offset: 0 + }, // 3.696691 mL + fluidounce: { + name: 'fluidounce', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00002957353, + offset: 0 + }, // 29.57353 mL + gill: { + name: 'gill', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0001182941, + offset: 0 + }, // 118.2941 mL + cc: { + name: 'cc', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 1e-6, + offset: 0 + }, // 1e-6 L + cup: { + name: 'cup', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0002365882, + offset: 0 + }, // 236.5882 mL + pint: { + name: 'pint', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0004731765, + offset: 0 + }, // 473.1765 mL + quart: { + name: 'quart', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0009463529, + offset: 0 + }, // 946.3529 mL + gallon: { + name: 'gallon', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.003785412, + offset: 0 + }, // 3.785412 L + beerbarrel: { + name: 'beerbarrel', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1173478, + offset: 0 + }, // 117.3478 L + oilbarrel: { + name: 'oilbarrel', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1589873, + offset: 0 + }, // 158.9873 L + hogshead: { + name: 'hogshead', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.2384810, + offset: 0 + }, // 238.4810 L + + //{name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute + fldr: { + name: 'fldr', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0000036966911, + offset: 0 + }, // 3.696691 mL + floz: { + name: 'floz', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.00002957353, + offset: 0 + }, // 29.57353 mL + gi: { + name: 'gi', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0001182941, + offset: 0 + }, // 118.2941 mL + cp: { + name: 'cp', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0002365882, + offset: 0 + }, // 236.5882 mL + pt: { + name: 'pt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0004731765, + offset: 0 + }, // 473.1765 mL + qt: { + name: 'qt', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.0009463529, + offset: 0 + }, // 946.3529 mL + gal: { + name: 'gal', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.003785412, + offset: 0 + }, // 3.785412 L + bbl: { + name: 'bbl', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1173478, + offset: 0 + }, // 117.3478 L + obl: { + name: 'obl', + base: BASE_UNITS.VOLUME, + prefixes: PREFIXES.NONE, + value: 0.1589873, + offset: 0 + }, // 158.9873 L + //{name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh? + + // Mass + g: { + name: 'g', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 0.001, + offset: 0 + }, + gram: { + name: 'gram', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.LONG, + value: 0.001, + offset: 0 + }, + + ton: { + name: 'ton', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 907.18474, + offset: 0 + }, + tonne: { + name: 'tonne', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.SHORT, + value: 1000, + offset: 0 + }, + + grain: { + name: 'grain', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 64.79891e-6, + offset: 0 + }, + dram: { + name: 'dram', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 1.7718451953125e-3, + offset: 0 + }, + ounce: { + name: 'ounce', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 28.349523125e-3, + offset: 0 + }, + poundmass: { + name: 'poundmass', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 453.59237e-3, + offset: 0 + }, + hundredweight: { + name: 'hundredweight', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 45.359237, + offset: 0 + }, + stick: { + name: 'stick', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 115e-3, + offset: 0 + }, + stone: { + name: 'stone', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 6350, + offset: 0 + }, + + gr: { + name: 'gr', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 64.79891e-6, + offset: 0 + }, + dr: { + name: 'dr', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 1.7718451953125e-3, + offset: 0 + }, + oz: { + name: 'oz', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 28.349523125e-3, + offset: 0 + }, + lbm: { + name: 'lbm', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 453.59237e-3, + offset: 0 + }, + cwt: { + name: 'cwt', + base: BASE_UNITS.MASS, + prefixes: PREFIXES.NONE, + value: 45.359237, + offset: 0 + }, + + // Time + s: { + name: 's', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + min: { + name: 'min', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 60, + offset: 0 + }, + h: { + name: 'h', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 3600, + offset: 0 + }, + second: { + name: 'second', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + sec: { + name: 'sec', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + minute: { + name: 'minute', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 60, + offset: 0 + }, + hour: { + name: 'hour', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 3600, + offset: 0 + }, + day: { + name: 'day', + base: BASE_UNITS.TIME, + prefixes: PREFIXES.NONE, + value: 86400, + offset: 0 + }, + + // Angle + rad: { + name: 'rad', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888 + deg: { + name: 'deg', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: 0.017453292519943295769236907684888, + offset: 0 + }, + // grad = rad / (2*pi) * 400 = rad / 0.015707963267948966192313216916399 + grad: { + name: 'grad', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: 0.015707963267948966192313216916399, + offset: 0 + }, + // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793 + cycle: { + name: 'cycle', + base: BASE_UNITS.ANGLE, + prefixes: PREFIXES.NONE, + value: 6.2831853071795864769252867665793, + offset: 0 + }, + + // Electric current + A: { + name: 'A', + base: BASE_UNITS.CURRENT, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + ampere: { + name: 'ampere', + base: BASE_UNITS.CURRENT, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + + // Temperature + // K(C) = °C + 273.15 + // K(F) = (°F + 459.67) / 1.8 + // K(R) = °R / 1.8 + K: { + name: 'K', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + degC: { + name: 'degC', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 273.15 + }, + degF: { + name: 'degF', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 459.67 + }, + degR: { + name: 'degR', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 0 + }, + kelvin: { + name: 'kelvin', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + celsius: { + name: 'celsius', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 273.15 + }, + fahrenheit: { + name: 'fahrenheit', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 459.67 + }, + rankine: { + name: 'rankine', + base: BASE_UNITS.TEMPERATURE, + prefixes: PREFIXES.NONE, + value: 1 / 1.8, + offset: 0 + }, + + // amount of substance + mol: { + name: 'mol', + base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + mole: { + name: 'mole', + base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + + // luminous intensity + cd: { + name: 'cd', + base: BASE_UNITS.LUMINOUS_INTENSITY, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + candela: { + name: 'candela', + base: BASE_UNITS.LUMINOUS_INTENSITY, + prefixes: PREFIXES.NONE, + value: 1, + offset: 0 + }, + // TODO: units STERADIAN + //{name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, + //{name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, + + // Force + N: { + name: 'N', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.SHORT, + value: 1, + offset: 0 + }, + newton: { + name: 'newton', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.LONG, + value: 1, + offset: 0 + }, + lbf: { + name: 'lbf', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.NONE, + value: 4.4482216152605, + offset: 0 + }, + poundforce: { + name: 'poundforce', + base: BASE_UNITS.FORCE, + prefixes: PREFIXES.NONE, + value: 4.4482216152605, + offset: 0 + }, + + // Binary + b: { + name: 'b', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_SHORT, + value: 1, + offset: 0 + }, + bits: { + name: 'bits', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_LONG, + value: 1, + offset: 0 + }, + B: { + name: 'B', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_SHORT, + value: 8, + offset: 0 + }, + bytes: { + name: 'bytes', + base: BASE_UNITS.BIT, + prefixes: PREFIXES.BINARY_LONG, + value: 8, + offset: 0 + } + }; + + // plurals + var PLURALS = { + meters: 'meter', + inches: 'inch', + feet: 'foot', + yards: 'yard', + miles: 'mile', + links: 'link', + rods: 'rod', + chains: 'chain', + angstroms: 'angstrom', + + litres: 'litre', + teaspoons: 'teaspoon', + tablespoons: 'tablespoon', + minims: 'minim', + fluiddrams: 'fluiddram', + fluidounces: 'fluidounce', + gills: 'gill', + cups: 'cup', + pints: 'pint', + quarts: 'quart', + gallons: 'gallon', + beerbarrels: 'beerbarrel', + oilbarrels: 'oilbarrel', + hogsheads: 'hogshead', + gtts: 'gtt', + + grams: 'gram', + tons: 'ton', + tonnes: 'tonne', + grains: 'grain', + drams: 'dram', + ounces: 'ounce', + poundmasses: 'poundmass', + hundredweights: 'hundredweight', + sticks: 'stick', + + seconds: 'second', + minutes: 'minute', + hours: 'hour', + days: 'day', + + radians: 'rad', + degrees: 'deg', + gradients: 'grad', + cycles: 'cycle', + + amperes: 'ampere', + moles: 'mole' + }; + + for (var name in PLURALS) { + /* istanbul ignore next (we cannot really test next statement) */ + if (PLURALS.hasOwnProperty(name)) { + var unit = UNITS[PLURALS[name]]; + var plural = Object.create(unit); + plural.name = name; + UNITS[name] = plural; + } } - return bestPrefix; - }; + // aliases + UNITS.lt = UNITS.l; + UNITS.liter = UNITS.litre; + UNITS.liters = UNITS.litres; + UNITS.lb = UNITS.lbm; + UNITS.lbs = UNITS.lbm; - var PREFIXES = { - NONE: { - '': {name: '', value: 1, scientific: true} - }, - SHORT: { - '': {name: '', value: 1, scientific: true}, + Unit.PREFIXES = PREFIXES; + Unit.BASE_UNITS = BASE_UNITS; + Unit.UNITS = UNITS; - 'da': {name: 'da', value: 1e1, scientific: false}, - 'h': {name: 'h', value: 1e2, scientific: false}, - 'k': {name: 'k', value: 1e3, scientific: true}, - 'M': {name: 'M', value: 1e6, scientific: true}, - 'G': {name: 'G', value: 1e9, scientific: true}, - 'T': {name: 'T', value: 1e12, scientific: true}, - 'P': {name: 'P', value: 1e15, scientific: true}, - 'E': {name: 'E', value: 1e18, scientific: true}, - 'Z': {name: 'Z', value: 1e21, scientific: true}, - 'Y': {name: 'Y', value: 1e24, scientific: true}, - - 'd': {name: 'd', value: 1e-1, scientific: false}, - 'c': {name: 'c', value: 1e-2, scientific: false}, - 'm': {name: 'm', value: 1e-3, scientific: true}, - 'u': {name: 'u', value: 1e-6, scientific: true}, - 'n': {name: 'n', value: 1e-9, scientific: true}, - 'p': {name: 'p', value: 1e-12, scientific: true}, - 'f': {name: 'f', value: 1e-15, scientific: true}, - 'a': {name: 'a', value: 1e-18, scientific: true}, - 'z': {name: 'z', value: 1e-21, scientific: true}, - 'y': {name: 'y', value: 1e-24, scientific: true} - }, - LONG: { - '': {name: '', value: 1, scientific: true}, - - 'deca': {name: 'deca', value: 1e1, scientific: false}, - 'hecto': {name: 'hecto', value: 1e2, scientific: false}, - 'kilo': {name: 'kilo', value: 1e3, scientific: true}, - 'mega': {name: 'mega', value: 1e6, scientific: true}, - 'giga': {name: 'giga', value: 1e9, scientific: true}, - 'tera': {name: 'tera', value: 1e12, scientific: true}, - 'peta': {name: 'peta', value: 1e15, scientific: true}, - 'exa': {name: 'exa', value: 1e18, scientific: true}, - 'zetta': {name: 'zetta', value: 1e21, scientific: true}, - 'yotta': {name: 'yotta', value: 1e24, scientific: true}, - - 'deci': {name: 'deci', value: 1e-1, scientific: false}, - 'centi': {name: 'centi', value: 1e-2, scientific: false}, - 'milli': {name: 'milli', value: 1e-3, scientific: true}, - 'micro': {name: 'micro', value: 1e-6, scientific: true}, - 'nano': {name: 'nano', value: 1e-9, scientific: true}, - 'pico': {name: 'pico', value: 1e-12, scientific: true}, - 'femto': {name: 'femto', value: 1e-15, scientific: true}, - 'atto': {name: 'atto', value: 1e-18, scientific: true}, - 'zepto': {name: 'zepto', value: 1e-21, scientific: true}, - 'yocto': {name: 'yocto', value: 1e-24, scientific: true} - }, - SQUARED: { - '': {name: '', value: 1, scientific: true}, - - 'da': {name: 'da', value: 1e2, scientific: false}, - 'h': {name: 'h', value: 1e4, scientific: false}, - 'k': {name: 'k', value: 1e6, scientific: true}, - 'M': {name: 'M', value: 1e12, scientific: true}, - 'G': {name: 'G', value: 1e18, scientific: true}, - 'T': {name: 'T', value: 1e24, scientific: true}, - 'P': {name: 'P', value: 1e30, scientific: true}, - 'E': {name: 'E', value: 1e36, scientific: true}, - 'Z': {name: 'Z', value: 1e42, scientific: true}, - 'Y': {name: 'Y', value: 1e48, scientific: true}, - - 'd': {name: 'd', value: 1e-2, scientific: false}, - 'c': {name: 'c', value: 1e-4, scientific: false}, - 'm': {name: 'm', value: 1e-6, scientific: true}, - 'u': {name: 'u', value: 1e-12, scientific: true}, - 'n': {name: 'n', value: 1e-18, scientific: true}, - 'p': {name: 'p', value: 1e-24, scientific: true}, - 'f': {name: 'f', value: 1e-30, scientific: true}, - 'a': {name: 'a', value: 1e-36, scientific: true}, - 'z': {name: 'z', value: 1e-42, scientific: true}, - 'y': {name: 'y', value: 1e-42, scientific: true} - }, - CUBIC: { - '': {name: '', value: 1, scientific: true}, - - 'da': {name: 'da', value: 1e3, scientific: false}, - 'h': {name: 'h', value: 1e6, scientific: false}, - 'k': {name: 'k', value: 1e9, scientific: true}, - 'M': {name: 'M', value: 1e18, scientific: true}, - 'G': {name: 'G', value: 1e27, scientific: true}, - 'T': {name: 'T', value: 1e36, scientific: true}, - 'P': {name: 'P', value: 1e45, scientific: true}, - 'E': {name: 'E', value: 1e54, scientific: true}, - 'Z': {name: 'Z', value: 1e63, scientific: true}, - 'Y': {name: 'Y', value: 1e72, scientific: true}, - - 'd': {name: 'd', value: 1e-3, scientific: false}, - 'c': {name: 'c', value: 1e-6, scientific: false}, - 'm': {name: 'm', value: 1e-9, scientific: true}, - 'u': {name: 'u', value: 1e-18, scientific: true}, - 'n': {name: 'n', value: 1e-27, scientific: true}, - 'p': {name: 'p', value: 1e-36, scientific: true}, - 'f': {name: 'f', value: 1e-45, scientific: true}, - 'a': {name: 'a', value: 1e-54, scientific: true}, - 'z': {name: 'z', value: 1e-63, scientific: true}, - 'y': {name: 'y', value: 1e-72, scientific: true} - }, - BINARY_SHORT: { - '': {name: '', value: 1, scientific: true}, - 'k': {name: 'k', value: 1e3, scientific: true}, - 'M': {name: 'M', value: 1e6, scientific: true}, - 'G': {name: 'G', value: 1e9, scientific: true}, - 'T': {name: 'T', value: 1e12, scientific: true}, - 'P': {name: 'P', value: 1e15, scientific: true}, - 'E': {name: 'E', value: 1e18, scientific: true}, - 'Z': {name: 'Z', value: 1e21, scientific: true}, - 'Y': {name: 'Y', value: 1e24, scientific: true}, - - 'Ki': {name: 'Ki', value: 1024, scientific: true}, - 'Mi': {name: 'Mi', value: Math.pow(1024, 2), scientific: true}, - 'Gi': {name: 'Gi', value: Math.pow(1024, 3), scientific: true}, - 'Ti': {name: 'Ti', value: Math.pow(1024, 4), scientific: true}, - 'Pi': {name: 'Pi', value: Math.pow(1024, 5), scientific: true}, - 'Ei': {name: 'Ei', value: Math.pow(1024, 6), scientific: true}, - 'Zi': {name: 'Zi', value: Math.pow(1024, 7), scientific: true}, - 'Yi': {name: 'Yi', value: Math.pow(1024, 8), scientific: true} - }, - BINARY_LONG: { - '': {name: '', value: 1, scientific: true}, - 'kilo': {name: 'kilo', value: 1e3, scientific: true}, - 'mega': {name: 'mega', value: 1e6, scientific: true}, - 'giga': {name: 'giga', value: 1e9, scientific: true}, - 'tera': {name: 'tera', value: 1e12, scientific: true}, - 'peta': {name: 'peta', value: 1e15, scientific: true}, - 'exa': {name: 'exa', value: 1e18, scientific: true}, - 'zetta': {name: 'zetta', value: 1e21, scientific: true}, - 'yotta': {name: 'yotta', value: 1e24, scientific: true}, - - 'kibi': {name: 'kibi', value: 1024, scientific: true}, - 'mebi': {name: 'mebi', value: Math.pow(1024, 2), scientific: true}, - 'gibi': {name: 'gibi', value: Math.pow(1024, 3), scientific: true}, - 'tebi': {name: 'tebi', value: Math.pow(1024, 4), scientific: true}, - 'pebi': {name: 'pebi', value: Math.pow(1024, 5), scientific: true}, - 'exi': {name: 'exi', value: Math.pow(1024, 6), scientific: true}, - 'zebi': {name: 'zebi', value: Math.pow(1024, 7), scientific: true}, - 'yobi': {name: 'yobi', value: Math.pow(1024, 8), scientific: true} - } - }; - - var PREFIX_NONE = {name: '', value: 1, scientific: true}; - - var BASE_UNITS = { - NONE: {}, - - LENGTH: {}, // meter - MASS: {}, // kilogram - TIME: {}, // second - CURRENT: {}, // ampere - TEMPERATURE: {}, // kelvin - LUMINOUS_INTENSITY: {}, // candela - AMOUNT_OF_SUBSTANCE: {}, // mole - - FORCE: {}, // Newton - SURFACE: {}, // m2 - VOLUME: {}, // m3 - ANGLE: {}, // rad - BIT: {} // bit (digital) - }; - - var BASE_UNIT_NONE = {}; - - var UNIT_NONE = {name: '', base: BASE_UNIT_NONE, value: 1, offset: 0}; - - var UNITS = { - // length - meter: {name: 'meter', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.LONG, value: 1, offset: 0}, - inch: {name: 'inch', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.0254, offset: 0}, - foot: {name: 'foot', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.3048, offset: 0}, - yard: {name: 'yard', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.9144, offset: 0}, - mile: {name: 'mile', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 1609.344, offset: 0}, - link: {name: 'link', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.201168, offset: 0}, - rod: {name: 'rod', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 5.029210, offset: 0}, - chain: {name: 'chain', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 20.1168, offset: 0}, - angstrom: {name: 'angstrom', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 1e-10, offset: 0}, - - m: {name: 'm', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.SHORT, value: 1, offset: 0}, - 'in': {name: 'in', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.0254, offset: 0}, - ft: {name: 'ft', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.3048, offset: 0}, - yd: {name: 'yd', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.9144, offset: 0}, - mi: {name: 'mi', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 1609.344, offset: 0}, - li: {name: 'li', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.201168, offset: 0}, - rd: {name: 'rd', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 5.029210, offset: 0}, - ch: {name: 'ch', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 20.1168, offset: 0}, - mil: {name: 'mil', base: BASE_UNITS.LENGTH, prefixes: PREFIXES.NONE, value: 0.0000254, offset: 0}, // 1/1000 inch - - // Surface - m2: {name: 'm2', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.SQUARED, value: 1, offset: 0}, - sqin: {name: 'sqin', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 0.00064516, offset: 0}, // 645.16 mm2 - sqft: {name: 'sqft', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 0.09290304, offset: 0}, // 0.09290304 m2 - sqyd: {name: 'sqyd', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 0.83612736, offset: 0}, // 0.83612736 m2 - sqmi: {name: 'sqmi', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 2589988.110336, offset: 0}, // 2.589988110336 km2 - sqrd: {name: 'sqrd', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 25.29295, offset: 0}, // 25.29295 m2 - sqch: {name: 'sqch', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 404.6873, offset: 0}, // 404.6873 m2 - sqmil: {name: 'sqmil', base: BASE_UNITS.SURFACE, prefixes: PREFIXES.NONE, value: 6.4516e-10, offset: 0}, // 6.4516 * 10^-10 m2 - - // Volume - m3: {name: 'm3', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.CUBIC, value: 1, offset: 0}, - L: {name: 'L', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.SHORT, value: 0.001, offset: 0}, // litre - l: {name: 'l', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.SHORT, value: 0.001, offset: 0}, // litre - litre: {name: 'litre', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.LONG, value: 0.001, offset: 0}, - cuin: {name: 'cuin', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 1.6387064e-5, offset: 0}, // 1.6387064e-5 m3 - cuft: {name: 'cuft', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.028316846592, offset: 0}, // 28.316 846 592 L - cuyd: {name: 'cuyd', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.764554857984, offset: 0}, // 764.554 857 984 L - teaspoon: {name: 'teaspoon', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000005, offset: 0}, // 5 mL - tablespoon: {name: 'tablespoon', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000015, offset: 0}, // 15 mL - //{name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.000240, offset: 0}, // 240 mL // not possible, we have already another cup - drop: {name: 'drop', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 5e-8, offset: 0}, // 0.05 mL = 5e-8 m3 - gtt: {name: 'gtt', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 5e-8, offset: 0}, // 0.05 mL = 5e-8 m3 - - // Liquid volume - minim: {name: 'minim', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL - fluiddram: {name: 'fluiddram', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0000036966911, offset: 0}, // 3.696691 mL - fluidounce: {name: 'fluidounce', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00002957353, offset: 0}, // 29.57353 mL - gill: {name: 'gill', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0001182941, offset: 0}, // 118.2941 mL - cc: {name: 'cc', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 1e-6, offset: 0}, // 1e-6 L - cup: {name: 'cup', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0002365882, offset: 0}, // 236.5882 mL - pint: {name: 'pint', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0004731765, offset: 0}, // 473.1765 mL - quart: {name: 'quart', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0009463529, offset: 0}, // 946.3529 mL - gallon: {name: 'gallon', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.003785412, offset: 0}, // 3.785412 L - beerbarrel: {name: 'beerbarrel', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.1173478, offset: 0}, // 117.3478 L - oilbarrel: {name: 'oilbarrel', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.1589873, offset: 0}, // 158.9873 L - hogshead: {name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L - - //{name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute - fldr: {name: 'fldr', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0000036966911, offset: 0}, // 3.696691 mL - floz: {name: 'floz', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00002957353, offset: 0}, // 29.57353 mL - gi: {name: 'gi', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0001182941, offset: 0}, // 118.2941 mL - cp: {name: 'cp', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0002365882, offset: 0}, // 236.5882 mL - pt: {name: 'pt', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0004731765, offset: 0}, // 473.1765 mL - qt: {name: 'qt', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.0009463529, offset: 0}, // 946.3529 mL - gal: {name: 'gal', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.003785412, offset: 0}, // 3.785412 L - bbl: {name: 'bbl', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.1173478, offset: 0}, // 117.3478 L - obl: {name: 'obl', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.1589873, offset: 0}, // 158.9873 L - //{name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh? - - // Mass - g: {name: 'g', base: BASE_UNITS.MASS, prefixes: PREFIXES.SHORT, value: 0.001, offset: 0}, - gram: {name: 'gram', base: BASE_UNITS.MASS, prefixes: PREFIXES.LONG, value: 0.001, offset: 0}, - - ton: {name: 'ton', base: BASE_UNITS.MASS, prefixes: PREFIXES.SHORT, value: 907.18474, offset: 0}, - tonne: {name: 'tonne', base: BASE_UNITS.MASS, prefixes: PREFIXES.SHORT, value: 1000, offset: 0}, - - grain: {name: 'grain', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 64.79891e-6, offset: 0}, - dram: {name: 'dram', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 1.7718451953125e-3, offset: 0}, - ounce: {name: 'ounce', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 28.349523125e-3, offset: 0}, - poundmass: {name: 'poundmass', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 453.59237e-3, offset: 0}, - hundredweight: {name: 'hundredweight', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 45.359237, offset: 0}, - stick: {name: 'stick', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 115e-3, offset: 0}, - stone: {name: 'stone', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 6350, offset: 0}, - - gr: {name: 'gr', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 64.79891e-6, offset: 0}, - dr: {name: 'dr', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 1.7718451953125e-3, offset: 0}, - oz: {name: 'oz', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 28.349523125e-3, offset: 0}, - lbm: {name: 'lbm', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 453.59237e-3, offset: 0}, - cwt: {name: 'cwt', base: BASE_UNITS.MASS, prefixes: PREFIXES.NONE, value: 45.359237, offset: 0}, - - // Time - s: {name: 's', base: BASE_UNITS.TIME, prefixes: PREFIXES.SHORT, value: 1, offset: 0}, - min: {name: 'min', base: BASE_UNITS.TIME, prefixes: PREFIXES.NONE, value: 60, offset: 0}, - h: {name: 'h', base: BASE_UNITS.TIME, prefixes: PREFIXES.NONE, value: 3600, offset: 0}, - second: {name: 'second', base: BASE_UNITS.TIME, prefixes: PREFIXES.LONG, value: 1, offset: 0}, - sec: {name: 'sec', base: BASE_UNITS.TIME, prefixes: PREFIXES.LONG, value: 1, offset: 0}, - minute: {name: 'minute', base: BASE_UNITS.TIME, prefixes: PREFIXES.NONE, value: 60, offset: 0}, - hour: {name: 'hour', base: BASE_UNITS.TIME, prefixes: PREFIXES.NONE, value: 3600, offset: 0}, - day: {name: 'day', base: BASE_UNITS.TIME, prefixes: PREFIXES.NONE, value: 86400, offset: 0}, - - // Angle - rad: {name: 'rad', base: BASE_UNITS.ANGLE, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - // deg = rad / (2*pi) * 360 = rad / 0.017453292519943295769236907684888 - deg: {name: 'deg', base: BASE_UNITS.ANGLE, prefixes: PREFIXES.NONE, value: 0.017453292519943295769236907684888, offset: 0}, - // grad = rad / (2*pi) * 400 = rad / 0.015707963267948966192313216916399 - grad: {name: 'grad', base: BASE_UNITS.ANGLE, prefixes: PREFIXES.NONE, value: 0.015707963267948966192313216916399, offset: 0}, - // cycle = rad / (2*pi) = rad / 6.2831853071795864769252867665793 - cycle: {name: 'cycle', base: BASE_UNITS.ANGLE, prefixes: PREFIXES.NONE, value: 6.2831853071795864769252867665793, offset: 0}, - - // Electric current - A: {name: 'A', base: BASE_UNITS.CURRENT, prefixes: PREFIXES.SHORT, value: 1, offset: 0}, - ampere: {name: 'ampere', base: BASE_UNITS.CURRENT, prefixes: PREFIXES.LONG, value: 1, offset: 0}, - - // Temperature - // K(C) = °C + 273.15 - // K(F) = (°F + 459.67) / 1.8 - // K(R) = °R / 1.8 - K: {name: 'K', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - degC: {name: 'degC', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 273.15}, - degF: {name: 'degF', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1/1.8, offset: 459.67}, - degR: {name: 'degR', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1/1.8, offset: 0}, - kelvin: {name: 'kelvin', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - celsius: {name: 'celsius', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1, offset: 273.15}, - fahrenheit: {name: 'fahrenheit', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1/1.8, offset: 459.67}, - rankine: {name: 'rankine', base: BASE_UNITS.TEMPERATURE, prefixes: PREFIXES.NONE, value: 1/1.8, offset: 0}, - - // amount of substance - mol: {name: 'mol', base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - mole: {name: 'mole', base: BASE_UNITS.AMOUNT_OF_SUBSTANCE, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - - // luminous intensity - cd: {name: 'cd', base: BASE_UNITS.LUMINOUS_INTENSITY, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - candela: {name: 'candela', base: BASE_UNITS.LUMINOUS_INTENSITY, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - // TODO: units STERADIAN - //{name: 'sr', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - //{name: 'steradian', base: BASE_UNITS.STERADIAN, prefixes: PREFIXES.NONE, value: 1, offset: 0}, - - // Force - N: {name: 'N', base: BASE_UNITS.FORCE, prefixes: PREFIXES.SHORT, value: 1, offset: 0}, - newton: {name: 'newton', base: BASE_UNITS.FORCE, prefixes: PREFIXES.LONG, value: 1, offset: 0}, - lbf: {name: 'lbf', base: BASE_UNITS.FORCE, prefixes: PREFIXES.NONE, value: 4.4482216152605, offset: 0}, - poundforce: {name: 'poundforce', base: BASE_UNITS.FORCE, prefixes: PREFIXES.NONE, value: 4.4482216152605, offset: 0}, - - // Binary - b: {name: 'b', base: BASE_UNITS.BIT, prefixes: PREFIXES.BINARY_SHORT, value: 1, offset: 0}, - bits: {name: 'bits', base: BASE_UNITS.BIT, prefixes: PREFIXES.BINARY_LONG, value: 1, offset: 0}, - B: {name: 'B', base: BASE_UNITS.BIT, prefixes: PREFIXES.BINARY_SHORT, value: 8, offset: 0}, - bytes: {name: 'bytes', base: BASE_UNITS.BIT, prefixes: PREFIXES.BINARY_LONG, value: 8, offset: 0} - }; - - // plurals - var PLURALS = { - meters: 'meter', - inches: 'inch', - feet: 'foot', - yards: 'yard', - miles: 'mile', - links: 'link', - rods: 'rod', - chains: 'chain', - angstroms: 'angstrom', - - litres: 'litre', - teaspoons: 'teaspoon', - tablespoons: 'tablespoon', - minims: 'minim', - fluiddrams: 'fluiddram', - fluidounces: 'fluidounce', - gills: 'gill', - cups: 'cup', - pints: 'pint', - quarts: 'quart', - gallons: 'gallon', - beerbarrels: 'beerbarrel', - oilbarrels: 'oilbarrel', - hogsheads: 'hogshead', - gtts: 'gtt', - - grams: 'gram', - tons: 'ton', - tonnes: 'tonne', - grains: 'grain', - drams: 'dram', - ounces: 'ounce', - poundmasses: 'poundmass', - hundredweights: 'hundredweight', - sticks: 'stick', - - seconds: 'second', - minutes: 'minute', - hours: 'hour', - days: 'day', - - radians: 'rad', - degrees: 'deg', - gradients: 'grad', - cycles: 'cycle', - - amperes: 'ampere', - moles: 'mole' - }; - - for (var name in PLURALS) { - /* istanbul ignore next (we cannot really test next statement) */ - if (PLURALS.hasOwnProperty(name)) { - var unit = UNITS[PLURALS[name]]; - var plural = Object.create(unit); - plural.name = name; - UNITS[name] = plural; - } + return Unit; } - // aliases - UNITS.lt = UNITS.l; - UNITS.liter = UNITS.litre; - UNITS.liters = UNITS.litres; - UNITS.lb = UNITS.lbm; - UNITS.lbs = UNITS.lbm; - - - Unit.PREFIXES = PREFIXES; - Unit.BASE_UNITS = BASE_UNITS; - Unit.UNITS = UNITS; - - // end of unit aliases - - - // exports - module.exports = Unit; + exports.name = 'Unit'; + exports.path = 'type'; + exports.factory = factory; /***/ }, @@ -2936,70 +3390,69 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - var util = __webpack_require__(171); - var object = util.object; - var string = util.string; + var object = __webpack_require__(33); + var string = __webpack_require__(42); - /** - * Documentation object - * @param {Object} doc Object containing properties: - * {String} name - * {String} category - * {String} description - * {String[]} syntax - * {String[]} examples - * {String[]} seealso - * @constructor - */ - function Help (doc) { - if (!(this instanceof Help)) { - throw new SyntaxError('Constructor must be called with the new operator'); + function factory (type, config, load, typed) { + var parser = load(__webpack_require__(43))(); + + /** + * Documentation object + * @param {Object} doc Object containing properties: + * {String} name + * {String} category + * {String} description + * {String[]} syntax + * {String[]} examples + * {String[]} seealso + * @constructor + */ + function Help(doc) { + if (!(this instanceof Help)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (!doc) throw new Error('Argument "doc" missing'); + + this.doc = doc; } - if (!doc) throw new Error('Argument "doc" missing'); + /** + * Test whether a value is an instance of Help + * @param {*} value + * @return {Boolean} isHelp + */ + Help.isHelp = function (value) { + return (value instanceof Help); + }; - this.doc = doc; - } + /** + * Generate a string representation of the Help object + * @return {String} Returns a string + * @private + */ + Help.prototype.toString = function () { + var doc = this.doc || {}; + var desc = '\n'; - /** - * Test whether a value is an instance of Help - * @param {*} value - * @return {Boolean} isHelp - */ - Help.isHelp = function (value) { - return (value instanceof Help); - }; + if (doc.name) { + desc += 'Name: ' + doc.name + '\n\n'; + } + if (doc.category) { + desc += 'Category: ' + doc.category + '\n\n'; + } + if (doc.description) { + desc += 'Description:\n ' + doc.description + '\n\n'; + } + if (doc.syntax) { + desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n'; + } + if (doc.examples) { + desc += 'Examples:\n'; + for (var i = 0; i < doc.examples.length; i++) { + var expr = doc.examples[i]; + desc += ' ' + expr + '\n'; - /** - * Generate readable description from a Help object - * @param {Object} [math] A math instance, used to evaluate the examples - * @return {String} readableDoc - * @private - */ - Help.prototype.toText = function (math) { - var doc = this.doc || {}; - var desc = '\n'; - - if (doc.name) { - desc += 'Name: ' + doc.name + '\n\n'; - } - if (doc.category) { - desc += 'Category: ' + doc.category + '\n\n'; - } - if (doc.description) { - desc += 'Description:\n ' + doc.description + '\n\n'; - } - if (doc.syntax) { - desc += 'Syntax:\n ' + doc.syntax.join('\n ') + '\n\n'; - } - if (doc.examples) { - var parser = math && math.parser(); - desc += 'Examples:\n'; - for (var i = 0; i < doc.examples.length; i++) { - var expr = doc.examples[i]; - desc += ' ' + expr + '\n'; - - if (parser) { var res; try { res = parser.eval(expr); @@ -3011,56 +3464,50 @@ return /******/ (function(modules) { // webpackBootstrap desc += ' ' + string.format(res, {precision: 14}) + '\n'; } } + desc += '\n'; } - desc += '\n'; - } - if (doc.seealso) { - desc += 'See also: ' + doc.seealso.join(', ') + '\n'; - } - - return desc; - }; - - /** - * Generate a string representation of the Help object - * @return {String} Returns a string - * @private - */ - Help.prototype.toString = function () { - return this.toText(); - }; - - /** - * Export the help object to JSON - */ - Help.prototype.toJSON = function () { - var obj = object.clone(this.doc); - obj.mathjs = 'Help'; - return obj; - }; - - /** - * Instantiate a Help object from a JSON object - * @param {Object} json - * @returns {Help} Returns a new Help object - */ - Help.fromJSON = function (json) { - var doc = {}; - for (var prop in json) { - if (prop !== 'mathjs') { // ignore mathjs field - doc[prop] = json[prop]; + if (doc.seealso) { + desc += 'See also: ' + doc.seealso.join(', ') + '\n'; } - } - return new Help(doc); - }; - /** - * Returns a string representation of the Help object - */ - Help.prototype.valueOf = Help.prototype.toString; + return desc; + }; - // exports - module.exports = Help; + /** + * Export the help object to JSON + */ + Help.prototype.toJSON = function () { + var obj = object.clone(this.doc); + obj.mathjs = 'Help'; + return obj; + }; + + /** + * Instantiate a Help object from a JSON object + * @param {Object} json + * @returns {Help} Returns a new Help object + */ + Help.fromJSON = function (json) { + var doc = {}; + for (var prop in json) { + if (prop !== 'mathjs') { // ignore mathjs field + doc[prop] = json[prop]; + } + } + return new Help(doc); + }; + + /** + * Returns a string representation of the Help object + */ + Help.prototype.valueOf = Help.prototype.toString; + + return Help; + } + + exports.name = 'Help'; + exports.path = 'type'; + exports.factory = factory; /***/ }, @@ -3069,66 +3516,72 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - /** - * A ResultSet contains a list or results - * @param {Array} entries - * @constructor - */ - function ResultSet(entries) { - if (!(this instanceof ResultSet)) { - throw new SyntaxError('Constructor must be called with the new operator'); + function factory (type, config, load, typed) { + /** + * A ResultSet contains a list or results + * @param {Array} entries + * @constructor + */ + function ResultSet(entries) { + if (!(this instanceof ResultSet)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + this.entries = entries || []; } - this.entries = entries || []; + /** + * Returns the array with results hold by this ResultSet + * @returns {Array} entries + */ + ResultSet.prototype.valueOf = function () { + return this.entries; + }; + + /** + * Returns the stringified results of the ResultSet + * @returns {String} string + */ + ResultSet.prototype.toString = function () { + return '[' + this.entries.join(', ') + ']'; + }; + + /** + * Get a JSON representation of the ResultSet + * @returns {Object} Returns a JSON object structured as: + * `{"mathjs": "ResultSet", "entries": [...]}` + */ + ResultSet.prototype.toJSON = function () { + return { + mathjs: 'ResultSet', + entries: this.entries + }; + }; + + /** + * Instantiate a ResultSet from a JSON object + * @param {Object} json A JSON object structured as: + * `{"mathjs": "ResultSet", "entries": [...]}` + * @return {ResultSet} + */ + ResultSet.fromJSON = function (json) { + return new ResultSet(json.entries); + }; + + return ResultSet; } - /** - * Returns the array with results hold by this ResultSet - * @returns {Array} entries - */ - ResultSet.prototype.valueOf = function () { - return this.entries; - }; - - /** - * Returns the stringified results of the ResultSet - * @returns {String} string - */ - ResultSet.prototype.toString = function () { - return '[' + this.entries.join(', ') + ']'; - }; - - /** - * Get a JSON representation of the ResultSet - * @returns {Object} Returns a JSON object structured as: - * `{"mathjs": "ResultSet", "entries": [...]}` - */ - ResultSet.prototype.toJSON = function () { - return { - mathjs: 'ResultSet', - entries: this.entries - }; - }; - - /** - * Instantiate a ResultSet from a JSON object - * @param {Object} json A JSON object structured as: - * `{"mathjs": "ResultSet", "entries": [...]}` - * @return {ResultSet} - */ - ResultSet.fromJSON = function (json) { - return new ResultSet(json.entries); - }; - - module.exports = ResultSet; + exports.name = 'ResultSet'; + exports.path = 'type'; + exports.factory = factory; /***/ }, /* 10 */ /***/ function(module, exports, __webpack_require__) { - var Decimal = __webpack_require__(351); - var digits = __webpack_require__(175).digits; + var Decimal = __webpack_require__(191); + var digits = __webpack_require__(41).digits; function factory (type, config, load, typed) { var BigNumber = Decimal.constructor(config); @@ -3195,8 +3648,8 @@ return /******/ (function(modules) { // webpackBootstrap function factory (type, config, load, typed) { - var smaller = load(__webpack_require__(118)); - var larger = load(__webpack_require__(116)); + var smaller = load(__webpack_require__(44)); + var larger = load(__webpack_require__(45)); var oneOverLogPhi = 1.0 / Math.log((1.0 + Math.sqrt(5.0)) / 2.0); @@ -3527,1867 +3980,8 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - // TODO: change to exports.create = function () {...} - module.exports = function () { - var string = __webpack_require__(176); - - /** - * @constructor Chain - * Wrap any value in a chain, allowing to perform chained operations on - * the value. - * - * All methods available in the math.js library can be called upon the chain, - * and then will be evaluated with the value itself as first argument. - * The chain can be closed by executing chain.done(), which will return - * the final value. - * - * The Chain has a number of special functions: - * - done() Finalize the chained operation and return the - * chain's value. - * - valueOf() The same as done() - * - toString() Returns a string representation of the chain's value. - * - * @param {*} [value] - */ - function Chain (value) { - if (!(this instanceof Chain)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (value instanceof Chain) { - this.value = value.value; - } - else { - this.value = value; - } - } - - /** - * Close the chain. Returns the final value. - * Does the same as method valueOf() - * @returns {*} value - */ - Chain.prototype.done = function () { - return this.value; - }; - - /** - * Close the chain. Returns the final value. - * Does the same as method done() - * @returns {*} value - */ - Chain.prototype.valueOf = function () { - return this.value; - }; - - /** - * Get a string representation of the value in the chain - * @returns {String} - */ - Chain.prototype.toString = function () { - return string.format(this.value); - }; - - /** - * Create a proxy method for the chain - * @param {String} name - * @param {*} value The value or function to be proxied - */ - function createProxy(name, value) { - var slice = Array.prototype.slice; - if (typeof value === 'function') { - // a function - Chain.prototype[name] = function () { - var args = [this.value].concat(slice.call(arguments, 0)); - return new Chain(value.apply(this, args)); - } - } - else { - // a constant - Chain.prototype[name] = new Chain(value); - } - } - - /** - * Create a proxy for a single method, or an object with multiple methods. - * Example usage: - * - * Chain.createProxy('add', function add (x, y) {...}); - * Chain.createProxy({ - * add: function add (x, y) {...}, - * subtract: function subtract (x, y) {...} - * } - * - * - * @param {String | Object} arg0 A function name (string), or an object with - * methods - * @param {*} [arg1] Function or value, when arg0 is a name - */ - Chain.createProxy = function (arg0, arg1) { - if (typeof arg0 === 'string') { - // createProxy(name, value) - createProxy(arg0, arg1); - } - else { - // createProxy(values) - for (var prop in arg0) { - if (arg0.hasOwnProperty(prop)) { - createProxy(prop, arg0[prop]); - } - } - } - }; - - return Chain; - }; - - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - - var ArgumentsError = __webpack_require__(177); - - var isString = util.string.isString; - - var ArrayNode = __webpack_require__(178); - var AssignmentNode = __webpack_require__(179); - var BlockNode = __webpack_require__(180); - var ConditionalNode = __webpack_require__(181); - var ConstantNode = __webpack_require__(182); - var FunctionAssignmentNode = __webpack_require__(183); - var IndexNode = __webpack_require__(184); - var OperatorNode = __webpack_require__(185); - var FunctionNode = __webpack_require__(186); - var RangeNode = __webpack_require__(187); - var SymbolNode = __webpack_require__(188); - var UpdateNode = __webpack_require__(189); - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Parse an expression. Returns a node tree, which can be evaluated by - * invoking node.eval(); - * - * Syntax: - * - * parse(expr) - * parse(expr, options) - * parse([expr1, expr2, expr3, ...]) - * parse([expr1, expr2, expr3, ...], options) - * - * Example: - * - * var node = parse('sqrt(3^2 + 4^2)'); - * node.compile(math).eval(); // 5 - * - * var scope = {a:3, b:4} - * var node = parse('a * b'); // 12 - * var code = node.compile(math); - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); - * nodes[2].compile(math).eval(); // 12 - * - * @param {String | String[] | Matrix} expr - * @param {{nodes: Object}} [options] Available options: - * - `nodes` a set of custom nodes - * @return {Node | Node[]} node - * @throws {Error} - */ - function parse (expr, options) { - if (arguments.length != 1 && arguments.length != 2) { - throw new ArgumentsError('parse', arguments.length, 1, 2); - } - - // pass extra nodes - extra_nodes = (options && options.nodes) ? options.nodes : {}; - - if (isString(expr)) { - // parse a single expression - expression = expr; - return parseStart(); - } - else if (Array.isArray(expr) || expr instanceof type.Matrix) { - // parse an array or matrix with expressions - return collection.deepMap(expr, function (elem) { - if (!isString(elem)) throw new TypeError('String expected'); - - expression = elem; - return parseStart(); - }); - } - else { - // oops - throw new TypeError('String or matrix expected'); - } - } - - // token types enumeration - var TOKENTYPE = { - NULL : 0, - DELIMITER : 1, - NUMBER : 2, - SYMBOL : 3, - UNKNOWN : 4 - }; - - // map with all delimiters - var DELIMITERS = { - ',': true, - '(': true, - ')': true, - '[': true, - ']': true, - '\"': true, - ';': true, - - '+': true, - '-': true, - '*': true, - '.*': true, - '/': true, - './': true, - '%': true, - '^': true, - '.^': true, - '~': true, - '!': true, - '&': true, - '|': true, - '^|': true, - '\'': true, - '=': true, - ':': true, - '?': true, - - '==': true, - '!=': true, - '<': true, - '>': true, - '<=': true, - '>=': true, - - '<<': true, - '>>': true, - '>>>': true - }; - - // map with all named delimiters - var NAMED_DELIMITERS = { - 'mod': true, - 'to': true, - 'in': true, - 'and': true, - 'xor': true, - 'or': true, - 'not': true - }; - - var extra_nodes = {}; // current extra nodes - var expression = ''; // current expression - var index = 0; // current index in expr - var c = ''; // current token character in expr - var token = ''; // current token - var token_type = TOKENTYPE.NULL; // type of the token - var nesting_level = 0; // level of nesting inside parameters, used to ignore newline characters - var conditional_level = null; // when a conditional is being parsed, the level of the conditional is stored here - - /** - * Get the first character from the expression. - * The character is stored into the char c. If the end of the expression is - * reached, the function puts an empty string in c. - * @private - */ - function first() { - index = 0; - c = expression.charAt(0); - nesting_level = 0; - conditional_level = null; - } - - /** - * Get the next character from the expression. - * The character is stored into the char c. If the end of the expression is - * reached, the function puts an empty string in c. - * @private - */ - function next() { - index++; - c = expression.charAt(index); - } - - /** - * Preview the next character from the expression. - * @return {String} cNext - * @private - */ - function nextPreview() { - return expression.charAt(index + 1); - } - - /** - * Preview the second next character from the expression. - * @return {String} cNext - * @private - */ - function nextNextPreview() { - return expression.charAt(index + 2); - } - - /** - * Get next token in the current string expr. - * The token and token type are available as token and token_type - * @private - */ - function getToken() { - token_type = TOKENTYPE.NULL; - token = ''; - - // skip over whitespaces - // space, tab, and newline when inside parameters - while (c == ' ' || c == '\t' || (c == '\n' && nesting_level)) { - // TODO: also take '\r' carriage return as newline? Or does that give problems on mac? - next(); - } - - // skip comment - if (c == '#') { - while (c != '\n' && c != '') { - next(); - } - } - - // check for end of expression - if (c == '') { - // token is still empty - token_type = TOKENTYPE.DELIMITER; - return; - } - - // check for new line character - if (c == '\n' && !nesting_level) { - token_type = TOKENTYPE.DELIMITER; - token = c; - next(); - return; - } - - // check for delimiters consisting of 3 characters - var c2 = c + nextPreview(); - var c3 = c2 + nextNextPreview(); - if (c3.length == 3 && DELIMITERS[c3]) { - token_type = TOKENTYPE.DELIMITER; - token = c3; - next(); - next(); - next(); - return; - } - - // check for delimiters consisting of 2 characters - if (c2.length == 2 && DELIMITERS[c2]) { - token_type = TOKENTYPE.DELIMITER; - token = c2; - next(); - next(); - return; - } - - // check for delimiters consisting of 1 character - if (DELIMITERS[c]) { - token_type = TOKENTYPE.DELIMITER; - token = c; - next(); - return; - } - - // check for a number - if (isDigitDot(c)) { - token_type = TOKENTYPE.NUMBER; - - // get number, can have a single dot - if (c == '.') { - token += c; - next(); - - if (!isDigit(c)) { - // this is no legal number, it is just a dot - token_type = TOKENTYPE.UNKNOWN; - } - } - else { - while (isDigit(c)) { - token += c; - next(); - } - if (c == '.') { - token += c; - next(); - } - } - while (isDigit(c)) { - token += c; - next(); - } - - // check for exponential notation like "2.3e-4", "1.23e50" or "2e+4" - c2 = nextPreview(); - if ((c == 'E' || c == 'e') && (isDigit(c2) || c2 == '-' || c2 == '+')) { - token += c; - next(); - - if (c == '+' || c == '-') { - token += c; - next(); - } - - // Scientific notation MUST be followed by an exponent - if (!isDigit(c)) { - // this is no legal number, exponent is missing. - token_type = TOKENTYPE.UNKNOWN; - } - - while (isDigit(c)) { - token += c; - next(); - } - } - - return; - } - - // check for variables, functions, named operators - if (isAlpha(c)) { - while (isAlpha(c) || isDigit(c)) { - token += c; - next(); - } - - if (NAMED_DELIMITERS[token]) { - token_type = TOKENTYPE.DELIMITER; - } - else { - token_type = TOKENTYPE.SYMBOL; - } - - return; - } - - // something unknown is found, wrong characters -> a syntax error - token_type = TOKENTYPE.UNKNOWN; - while (c != '') { - token += c; - next(); - } - throw createSyntaxError('Syntax error in part "' + token + '"'); - } - - /** - * Get next token and skip newline tokens - */ - function getTokenSkipNewline () { - do { - getToken(); - } - while (token == '\n'); - } - - /** - * Open parameters. - * New line characters will be ignored until closeParams() is called - */ - function openParams() { - nesting_level++; - } - - /** - * Close parameters. - * New line characters will no longer be ignored - */ - function closeParams() { - nesting_level--; - } - - /** - * checks if the given char c is a letter (upper or lower case) - * or underscore - * @param {String} c a string with one character - * @return {Boolean} - * @private - */ - function isAlpha (c) { - return ((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - c == '_'); - } - - /** - * checks if the given char c is a digit or dot - * @param {String} c a string with one character - * @return {Boolean} - * @private - */ - function isDigitDot (c) { - return ((c >= '0' && c <= '9') || - c == '.'); - } - - /** - * checks if the given char c is a digit - * @param {String} c a string with one character - * @return {Boolean} - * @private - */ - function isDigit (c) { - return ((c >= '0' && c <= '9')); - } - - /** - * Start of the parse levels below, in order of precedence - * @return {Node} node - * @private - */ - function parseStart () { - // get the first character in expression - first(); - - getToken(); - - var node = parseBlock(); - - // check for garbage at the end of the expression - // an expression ends with a empty character '' and token_type DELIMITER - if (token != '') { - if (token_type == TOKENTYPE.DELIMITER) { - // user entered a not existing operator like "//" - - // TODO: give hints for aliases, for example with "<>" give as hint " did you mean != ?" - throw createError('Unexpected operator ' + token); - } - else { - throw createSyntaxError('Unexpected part "' + token + '"'); - } - } - - return node; - } - - /** - * Parse a block with expressions. Expressions can be separated by a newline - * character '\n', or by a semicolon ';'. In case of a semicolon, no output - * of the preceding line is returned. - * @return {Node} node - * @private - */ - function parseBlock () { - var node; - var blocks = []; - var visible; - - if (token == '') { - // empty expression - return new ConstantNode('undefined', 'undefined'); - } - - if (token != '\n' && token != ';') { - node = parseFunctionAssignment(); - } - - // TODO: simplify this loop - while (token == '\n' || token == ';') { - if (blocks.length == 0 && node) { - visible = (token != ';'); - blocks.push({ - node: node, - visible: visible - }); - } - - getToken(); - if (token != '\n' && token != ';' && token != '') { - node = parseFunctionAssignment(); - - visible = (token != ';'); - blocks.push({ - node: node, - visible: visible - }); - } - } - - if (blocks.length > 0) { - return new BlockNode(blocks); - } - else { - return node; - } - } - - /** - * Parse a function assignment like "function f(a,b) = a*b" - * @return {Node} node - * @private - */ - function parseFunctionAssignment () { - // TODO: function assignment using keyword 'function' is deprecated since version 0.18.0, cleanup some day - if (token_type == TOKENTYPE.SYMBOL && token == 'function') { - throw createSyntaxError('Deprecated keyword "function". ' + - 'Functions can now be assigned without it, like "f(x) = x^2".'); - } - - return parseAssignment(); - } - - /** - * Assignment of a variable, can be a variable like "a=2.3" or a updating an - * existing variable like "matrix(2,3:5)=[6,7,8]" - * @return {Node} node - * @private - */ - function parseAssignment () { - var name, args, expr, valid; - - var node = parseConditional(); - - if (token == '=') { - if (node instanceof SymbolNode) { - // parse a variable assignment like 'a = 2/3' - name = node.name; - getTokenSkipNewline(); - expr = parseAssignment(); - return new AssignmentNode(name, expr); - } - else if (node instanceof IndexNode) { - // parse a matrix subset assignment like 'A[1,2] = 4' - getTokenSkipNewline(); - expr = parseAssignment(); - return new UpdateNode(node, expr); - } - else if (node instanceof FunctionNode) { - // parse function assignment like 'f(x) = x^2' - valid = true; - args = []; - - name = node.name; - node.args.forEach(function (arg, index) { - if (arg instanceof SymbolNode) { - args[index] = arg.name; - } - else { - valid = false; - } - }); - - if (valid) { - getTokenSkipNewline(); - expr = parseAssignment(); - return new FunctionAssignmentNode(name, args, expr); - } - } - - throw createSyntaxError('Invalid left hand side of assignment operator ='); - } - - return node; - } - - /** - * conditional operation - * - * condition ? truePart : falsePart - * - * Note: conditional operator is right-associative - * - * @return {Node} node - * @private - */ - function parseConditional () { - var node = parseLogicalOr(); - - while (token == '?') { - // set a conditional level, the range operator will be ignored as long - // as conditional_level == nesting_level. - var prev = conditional_level; - conditional_level = nesting_level; - getTokenSkipNewline(); - - var condition = node; - var trueExpr = parseLogicalOr(); - - if (token != ':') throw createSyntaxError('False part of conditional expression expected'); - - conditional_level = null; - getTokenSkipNewline(); - - var falseExpr = parseConditional(); // Note: check for conditional operator again, right associativity - - node = new ConditionalNode(condition, trueExpr, falseExpr); - - // restore the previous conditional level - conditional_level = prev; - } - - return node; - } - - /** - * logical or, 'x or y' - * @return {Node} node - * @private - */ - function parseLogicalOr() { - var node = parseLogicalXor(); - - while (token == 'or') { - getTokenSkipNewline(); - node = new OperatorNode('or', 'or', [node, parseLogicalXor()]); - } - - return node; - } - - /** - * logical exclusive or, 'x xor y' - * @return {Node} node - * @private - */ - function parseLogicalXor() { - var node = parseLogicalAnd(); - - while (token == 'xor') { - getTokenSkipNewline(); - node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd()]); - } - - return node; - } - - /** - * logical and, 'x and y' - * @return {Node} node - * @private - */ - function parseLogicalAnd() { - var node = parseBitwiseOr(); - - while (token == 'and') { - getTokenSkipNewline(); - node = new OperatorNode('and', 'and', [node, parseBitwiseOr()]); - } - - return node; - } - - /** - * bitwise or, 'x | y' - * @return {Node} node - * @private - */ - function parseBitwiseOr() { - var node = parseBitwiseXor(); - - while (token == '|') { - getTokenSkipNewline(); - node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor()]); - } - - return node; - } - - /** - * bitwise exclusive or (xor), 'x ^| y' - * @return {Node} node - * @private - */ - function parseBitwiseXor() { - var node = parseBitwiseAnd(); - - while (token == '^|') { - getTokenSkipNewline(); - node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd()]); - } - - return node; - } - - /** - * bitwise and, 'x & y' - * @return {Node} node - * @private - */ - function parseBitwiseAnd () { - var node = parseRelational(); - - while (token == '&') { - getTokenSkipNewline(); - node = new OperatorNode('&', 'bitAnd', [node, parseRelational()]); - } - - return node; - } - - /** - * relational operators - * @return {Node} node - * @private - */ - function parseRelational () { - var node, operators, name, fn, params; - - node = parseShift(); - - operators = { - '==': 'equal', - '!=': 'unequal', - '<': 'smaller', - '>': 'larger', - '<=': 'smallerEq', - '>=': 'largerEq' - }; - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseShift()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift - * @return {Node} node - * @private - */ - function parseShift () { - var node, operators, name, fn, params; - - node = parseConversion(); - - operators = { - '<<' : 'leftShift', - '>>' : 'rightArithShift', - '>>>' : 'rightLogShift' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseConversion()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * conversion operators 'to' and 'in' - * @return {Node} node - * @private - */ - function parseConversion () { - var node, operators, name, fn, params; - - node = parseRange(); - - operators = { - 'to' : 'to', - 'in' : 'to' // alias of 'to' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseRange()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * parse range, "start:end", "start:step:end", ":", "start:", ":end", etc - * @return {Node} node - * @private - */ - function parseRange () { - var node, params = []; - - if (token == ':') { - // implicit start=1 (one-based) - node = new ConstantNode('1', 'number'); - } - else { - // explicit start - node = parseAddSubtract(); - } - - if (token == ':' && (conditional_level !== nesting_level)) { - // we ignore the range operator when a conditional operator is being processed on the same level - params.push(node); - - // parse step and end - while (token == ':' && params.length < 3) { - getTokenSkipNewline(); - - if (token == ')' || token == ']' || token == ',' || token == '') { - // implicit end - params.push(new SymbolNode('end')); - } - else { - // explicit end - params.push(parseAddSubtract()); - } - } - - if (params.length == 3) { - // params = [start, step, end] - node = new RangeNode(params[0], params[2], params[1]); // start, end, step - } - else { // length == 2 - // params = [start, end] - node = new RangeNode(params[0], params[1]); // start, end - } - } - - return node; - } - - /** - * add or subtract - * @return {Node} node - * @private - */ - function parseAddSubtract () { - var node, operators, name, fn, params; - - node = parseMultiplyDivide(); - - operators = { - '+': 'add', - '-': 'subtract' - }; - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseMultiplyDivide()]; - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * multiply, divide, modulus - * @return {Node} node - * @private - */ - function parseMultiplyDivide () { - var node, operators, name, fn, params; - - node = parseUnary(); - - operators = { - '*': 'multiply', - '.*': 'dotMultiply', - '/': 'divide', - './': 'dotDivide', - '%': 'mod', - 'mod': 'mod' - }; - - if (token in operators) { - while (token in operators) { - name = token; - fn = operators[name]; - - getTokenSkipNewline(); - params = [node, parseUnary()]; - node = new OperatorNode(name, fn, params); - } - } - - // parse implicit multiplication - if ((token_type == TOKENTYPE.SYMBOL) || - (token == 'in' && (node instanceof ConstantNode)) || - (token_type == TOKENTYPE.NUMBER && !(node instanceof ConstantNode)) || - (token == '(' || token == '[')) { - // symbol: implicit multiplication like '2a', '(2+3)a', 'a b' - // number: implicit multiplication like '(2+3)2' - // Note: we don't allow implicit multiplication between numbers, - // like '2 3'. I'm not sure whether that is a good idea. - // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)', '2[1,2,3]' - node = new OperatorNode('*', 'multiply', [node, parseMultiplyDivide()]); - } - - return node; - } - - /** - * Unary plus and minus, and logical and bitwise not - * @return {Node} node - * @private - */ - function parseUnary () { - var name, params; - var fn = { - '-': 'unaryMinus', - '+': 'unaryPlus', - '~': 'bitNot', - 'not': 'not' - }[token]; - - if (fn) { - name = token; - - getTokenSkipNewline(); - params = [parseUnary()]; - - return new OperatorNode(name, fn, params); - } - - return parsePow(); - } - - /** - * power - * Note: power operator is right associative - * @return {Node} node - * @private - */ - function parsePow () { - var node, name, fn, params; - - node = parseLeftHandOperators(); - - if (token == '^' || token == '.^') { - name = token; - fn = (name == '^') ? 'pow' : 'dotPow'; - - getTokenSkipNewline(); - params = [node, parseUnary()]; // Go back to unary, we can have '2^-3' - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * Left hand operators: factorial x!, transpose x' - * @return {Node} node - * @private - */ - function parseLeftHandOperators () { - var node, operators, name, fn, params; - - node = parseCustomNodes(); - - operators = { - '!': 'factorial', - '\'': 'transpose' - }; - - while (token in operators) { - name = token; - fn = operators[name]; - - getToken(); - params = [node]; - - node = new OperatorNode(name, fn, params); - } - - return node; - } - - /** - * Parse a custom node handler. A node handler can be used to process - * nodes in a custom way, for example for handling a plot. - * - * A handler must be passed as second argument of the parse function. - * - must extend math.expression.node.Node - * - must contain a function _compile(defs: Object) : String - * - must contain a function find(filter: Object) : Node[] - * - must contain a function toString() : String - * - the constructor is called with a single argument containing all parameters - * - * For example: - * - * nodes = { - * 'plot': PlotHandler - * }; - * - * The constructor of the handler is called as: - * - * node = new PlotHandler(params); - * - * The handler will be invoked when evaluating an expression like: - * - * node = math.parse('plot(sin(x), x)', nodes); - * - * @return {Node} node - * @private - */ - function parseCustomNodes () { - var params = [], handler; - - if (token_type == TOKENTYPE.SYMBOL && extra_nodes[token]) { - handler = extra_nodes[token]; - - getToken(); - - // parse parameters - if (token == '(') { - params = []; - - openParams(); - getToken(); - - if (token != ')') { - params.push(parseConditional()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseConditional()); - } - } - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - } - - // create a new node handler - //noinspection JSValidateTypes - return new handler(params); - } - - return parseSymbol(); - } - - /** - * parse symbols: functions, variables, constants, units - * @return {Node} node - * @private - */ - function parseSymbol () { - var node, name; - - if (token_type == TOKENTYPE.SYMBOL || - (token_type == TOKENTYPE.DELIMITER && token in NAMED_DELIMITERS)) { - name = token; - - getToken(); - - // parse function parameters and matrix index - node = parseFunctions(name); - node = parseIndex(node); - return node; - } - - return parseString(); - } - - /** - * parse a function call like fn(a, b, c) - * @param {string} name Function name - * @return {FunctionNode | SymbolNode} node - * @private - */ - function parseFunctions (name) { - var params; - - if (token == '(') { - params = []; - - openParams(); - getToken(); - - if (token != ')') { - params.push(parseConditional()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseConditional()); - } - } - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - - return new FunctionNode(name, params); - } - - return new SymbolNode(name); - } - - /** - * parse index parameters, enclosed in square brackets [...], for example A[2,3] - * @param {Node} node Node on which to apply the parameters. If there - * are no parameters in the expression, the node - * itself is returned - * @return {Node} node - * @private - */ - function parseIndex (node) { - var params; - - while (token == '[') { - params = []; - - openParams(); - getToken(); - - if (token != ']') { - params.push(parseConditional()); - - // parse a list with parameters - while (token == ',') { - getToken(); - params.push(parseConditional()); - } - } - - if (token != ']') { - throw createSyntaxError('Parenthesis ] expected'); - } - closeParams(); - getToken(); - - node = new IndexNode(node, params); - } - - return node; - } - - /** - * parse a string. - * A string is enclosed by double quotes - * @return {Node} node - * @private - */ - function parseString () { - var node, str, tPrev; - - if (token == '"') { - // string "..." - str = ''; - tPrev = ''; - while (c != '' && (c != '\"' || tPrev == '\\')) { // also handle escape character - str += c; - tPrev = c; - next(); - } - - getToken(); - if (token != '"') { - throw createSyntaxError('End of string " expected'); - } - getToken(); - - // create constant - node = new ConstantNode(str, 'string'); - - // parse index parameters - node = parseIndex(node); - - return node; - } - - return parseMatrix(); - } - - /** - * parse the matrix - * @return {Node} node - * @private - */ - function parseMatrix () { - var array, params, rows, cols; - - if (token == '[') { - // matrix [...] - openParams(); - getToken(); - - if (token != ']') { - // this is a non-empty matrix - var row = parseRow(); - - if (token == ';') { - // 2 dimensional array - rows = 1; - params = [row]; - - // the rows of the matrix are separated by dot-comma's - while (token == ';') { - getToken(); - - params[rows] = parseRow(); - rows++; - } - - if (token != ']') { - throw createSyntaxError('End of matrix ] expected'); - } - closeParams(); - getToken(); - - // check if the number of columns matches in all rows - cols = params[0].nodes.length; - for (var r = 1; r < rows; r++) { - if (params[r].nodes.length != cols) { - throw createError('Column dimensions mismatch ' + - '(' + params[r].nodes.length + ' != ' + cols + ')'); - } - } - - array = new ArrayNode(params); - } - else { - // 1 dimensional vector - if (token != ']') { - throw createSyntaxError('End of matrix ] expected'); - } - closeParams(); - getToken(); - - array = row; - } - } - else { - // this is an empty matrix "[ ]" - closeParams(); - getToken(); - array = new ArrayNode([]); - } - - return array; - } - - return parseNumber(); - } - - /** - * Parse a single comma-separated row from a matrix, like 'a, b, c' - * @return {ArrayNode} node - */ - function parseRow () { - var params = [parseAssignment()]; - var len = 1; - - while (token == ',') { - getToken(); - - // parse expression - params[len] = parseAssignment(); - len++; - } - - return new ArrayNode(params); - } - - /** - * parse a number - * @return {Node} node - * @private - */ - function parseNumber () { - var number; - - if (token_type == TOKENTYPE.NUMBER) { - // this is a number - number = token; - getToken(); - - return new ConstantNode(number, 'number'); - } - - return parseParentheses(); - } - - /** - * parentheses - * @return {Node} node - * @private - */ - function parseParentheses () { - var node; - - // check if it is a parenthesized expression - if (token == '(') { - // parentheses (...) - openParams(); - getToken(); - - node = parseAssignment(); // start again - - if (token != ')') { - throw createSyntaxError('Parenthesis ) expected'); - } - closeParams(); - getToken(); - - return node; - } - - return parseEnd(); - } - - /** - * Evaluated when the expression is not yet ended but expected to end - * @return {Node} res - * @private - */ - function parseEnd () { - if (token == '') { - // syntax error or unexpected end of expression - throw createSyntaxError('Unexpected end of expression'); - } else { - throw createSyntaxError('Value expected'); - } - } - - /** - * Shortcut for getting the current row value (one based) - * Returns the line of the currently handled expression - * @private - */ - /* TODO: implement keeping track on the row number - function row () { - return null; - } - */ - - /** - * Shortcut for getting the current col value (one based) - * Returns the column (position) where the last token starts - * @private - */ - function col () { - return index - token.length + 1; - } - - /** - * Create an error - * @param {String} message - * @return {SyntaxError} instantiated error - * @private - */ - function createSyntaxError (message) { - var c = col(); - var error = new SyntaxError(message + ' (char ' + c + ')'); - error['char'] = c; - - return error; - } - - /** - * Create an error - * @param {String} message - * @return {Error} instantiated error - * @private - */ - function createError (message) { - var c = col(); - var error = new Error(message + ' (char ' + c + ')'); - error['char'] = c; - - return error; - } - - return parse; - }; - - exports.name = 'parse'; - exports.path = 'expression'; - exports.factory = factory; - - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var _parse = load(__webpack_require__(13)); - - /** - * @constructor Parser - * Parser contains methods to evaluate or parse expressions, and has a number - * of convenience methods to get, set, and remove variables from memory. Parser - * keeps a scope containing variables in memory, which is used for all - * evaluations. - * - * Methods: - * var result = parser.eval(expr); // evaluate an expression - * var value = parser.get(name); // retrieve a variable from the parser - * parser.set(name, value); // set a variable in the parser - * parser.remove(name); // clear a variable from the - * // parsers scope - * parser.clear(); // clear the parsers scope - * - * Example usage: - * var parser = new Parser(); - * // Note: there is a convenience method which can be used instead: - * // var parser = new math.parser(); - * - * // evaluate expressions - * parser.eval('sqrt(3^2 + 4^2)'); // 5 - * parser.eval('sqrt(-4)'); // 2i - * parser.eval('2 inch in cm'); // 5.08 cm - * parser.eval('cos(45 deg)'); // 0.7071067811865476 - * - * // define variables and functions - * parser.eval('x = 7 / 2'); // 3.5 - * parser.eval('x + 3'); // 6.5 - * parser.eval('function f(x, y) = x^y'); // f(x, y) - * parser.eval('f(2, 3)'); // 8 - * - * // get and set variables and functions - * var x = parser.get('x'); // 7 - * var f = parser.get('f'); // function - * var g = f(3, 2); // 9 - * parser.set('h', 500); - * var i = parser.eval('h / 2'); // 250 - * parser.set('hello', function (name) { - * return 'hello, ' + name + '!'; - * }); - * parser.eval('hello("user")'); // "hello, user!" - * - * // clear defined functions and variables - * parser.clear(); - * - */ - function Parser() { - if (!(this instanceof Parser)) { - throw new SyntaxError( - 'Constructor must be called with the new operator'); - } - this.scope = {}; - } - - /** - * Parse an expression and return the parsed function node. - * The node tree can be compiled via `code = node.compile(math)`, - * and the compiled code can be executed as `code.eval([scope])` - * @param {String} expr - * @return {Node} node - * @throws {Error} - */ - Parser.prototype.parse = function (expr) { - throw new Error('Parser.parse is deprecated. Use math.parse instead.'); - }; - - /** - * Parse and compile an expression, return the compiled javascript code. - * The node can be evaluated via code.eval([scope]) - * @param {String} expr - * @return {{eval: function}} code - * @throws {Error} - */ - Parser.prototype.compile = function (expr) { - throw new Error('Parser.compile is deprecated. Use math.compile instead.'); - }; - - /** - * Parse and evaluate the given expression - * @param {String} expr A string containing an expression, for example "2+3" - * @return {*} result The result, or undefined when the expression was empty - * @throws {Error} - */ - Parser.prototype.eval = function (expr) { - // TODO: validate arguments - return _parse(expr) - .compile(math) - .eval(this.scope); - }; - - /** - * Get a variable (a function or variable) by name from the parsers scope. - * Returns undefined when not found - * @param {String} name - * @return {* | undefined} value - */ - Parser.prototype.get = function (name) { - // TODO: validate arguments - return this.scope[name]; - }; - - /** - * Set a symbol (a function or variable) by name from the parsers scope. - * @param {String} name - * @param {* | undefined} value - */ - Parser.prototype.set = function (name, value) { - // TODO: validate arguments - return this.scope[name] = value; - }; - - /** - * Remove a variable from the parsers scope - * @param {String} name - */ - Parser.prototype.remove = function (name) { - // TODO: validate arguments - delete this.scope[name]; - }; - - /** - * Clear the scope with variables and functions - */ - Parser.prototype.clear = function () { - for (var name in this.scope) { - if (this.scope.hasOwnProperty(name)) { - delete this.scope[name]; - } - } - }; - - return Parser; - } - - exports.name = 'Parser'; - exports.path = 'expression'; - exports.factory = factory; - exports.math = true; // requires the math namespace as 5th argument - - -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.ArrayNode = __webpack_require__(178); - exports.AssignmentNode = __webpack_require__(179); - exports.BlockNode = __webpack_require__(180); - exports.ConditionalNode = __webpack_require__(181); - exports.ConstantNode = __webpack_require__(182); - exports.IndexNode = __webpack_require__(184); - exports.FunctionAssignmentNode = __webpack_require__(183); - exports.FunctionNode = __webpack_require__(186); - exports.Node = __webpack_require__(190); - exports.OperatorNode = __webpack_require__(185); - exports.RangeNode = __webpack_require__(187); - exports.SymbolNode = __webpack_require__(188); - exports.UpdateNode = __webpack_require__(189); - - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - // constants - exports.e = __webpack_require__(191); - exports.E = __webpack_require__(191); - exports['false'] = __webpack_require__(192); - exports.i = __webpack_require__(193); - exports['Infinity'] = __webpack_require__(194); - exports.LN2 = __webpack_require__(195); - exports.LN10 = __webpack_require__(196); - exports.LOG2E = __webpack_require__(197); - exports.LOG10E = __webpack_require__(198); - exports.NaN = __webpack_require__(199); - exports['null'] = __webpack_require__(200); - exports.pi = __webpack_require__(201); - exports.PI = __webpack_require__(201); - exports.phi = __webpack_require__(202); - exports.SQRT1_2 = __webpack_require__(203); - exports.SQRT2 = __webpack_require__(204); - exports.tau = __webpack_require__(205); - exports['true'] = __webpack_require__(206); - exports.version = __webpack_require__(207); - - // functions - arithmetic - exports.abs = __webpack_require__(219); - exports.add = __webpack_require__(220); - exports.ceil = __webpack_require__(221); - exports.cube = __webpack_require__(222); - exports.divide = __webpack_require__(223); - exports.dotDivide = __webpack_require__(224); - exports.dotMultiply = __webpack_require__(225); - exports.dotPow = __webpack_require__(226); - exports.exp = __webpack_require__(227); - exports.fix = __webpack_require__(228); - exports.floor = __webpack_require__(229); - exports.gcd = __webpack_require__(230); - exports.lcm = __webpack_require__(231); - exports.log = __webpack_require__(232); - exports.log10 = __webpack_require__(233); - exports.mod = __webpack_require__(234); - exports.multiply = __webpack_require__(235); - exports.norm = __webpack_require__(236); - exports.nthRoot = __webpack_require__(237); - exports.pow = __webpack_require__(238); - exports.round = __webpack_require__(239); - exports.sign = __webpack_require__(240); - exports.sqrt = __webpack_require__(241); - exports.square = __webpack_require__(242); - exports.subtract = __webpack_require__(243); - exports.unaryMinus = __webpack_require__(244); - exports.unaryPlus = __webpack_require__(245); - exports.xgcd = __webpack_require__(246); - - // functions - bitwise - exports.bitAnd = __webpack_require__(247); - exports.bitNot = __webpack_require__(248); - exports.bitOr = __webpack_require__(249); - exports.bitXor = __webpack_require__(250); - exports.leftShift = __webpack_require__(251); - exports.rightArithShift = __webpack_require__(252); - exports.rightLogShift = __webpack_require__(253); - - // functions - complex - exports.arg = __webpack_require__(254); - exports.conj = __webpack_require__(255); - exports.re = __webpack_require__(256); - exports.im = __webpack_require__(257); - - // functions - construction - exports.bignumber = __webpack_require__(258); - exports['boolean'] = __webpack_require__(259); - exports.complex = __webpack_require__(260); - exports.index = __webpack_require__(261); - exports.matrix = __webpack_require__(262); - exports.number = __webpack_require__(263); - exports.sparse = __webpack_require__(264); - exports.string = __webpack_require__(265); - exports.unit = __webpack_require__(266); - - // functions - expression - exports['eval'] = __webpack_require__(267); - exports.help = __webpack_require__(268); - - // functions - logical - exports['and'] = __webpack_require__(269); - exports['not'] = __webpack_require__(270); - exports['or'] = __webpack_require__(271); - exports['xor'] = __webpack_require__(272); - - // functions - matrix - exports['concat'] = __webpack_require__(273); - exports.cross = __webpack_require__(274); - exports.det = __webpack_require__(275); - exports.diag = __webpack_require__(276); - exports.dot = __webpack_require__(277); - exports.eye = __webpack_require__(278); - exports.flatten = __webpack_require__(279); - exports.inv = __webpack_require__(280); - exports.ones = __webpack_require__(281); - exports.range = __webpack_require__(282); - exports.resize = __webpack_require__(283); - exports.size = __webpack_require__(284); - exports.squeeze = __webpack_require__(285); - exports.subset = __webpack_require__(286); - exports.trace = __webpack_require__(287); - exports.transpose = __webpack_require__(288); - exports.zeros = __webpack_require__(289); - - // functions - probability - exports.combinations = __webpack_require__(290); - //exports.distribution = require('./function/probability/distribution'); - exports.factorial = __webpack_require__(291); - exports.gamma = __webpack_require__(292); - exports.permutations = __webpack_require__(293); - exports.pickRandom = __webpack_require__(294); - exports.random = __webpack_require__(295); - exports.randomInt = __webpack_require__(296); - - // functions - relational - exports.compare = __webpack_require__(297); - exports.deepEqual = __webpack_require__(298); - exports['equal'] = __webpack_require__(299); - exports.larger = __webpack_require__(300); - exports.largerEq = __webpack_require__(301); - exports.smaller = __webpack_require__(302); - exports.smallerEq = __webpack_require__(303); - exports.unequal = __webpack_require__(304); - - // functions - statistics - exports.max = __webpack_require__(305); - exports.mean = __webpack_require__(306); - exports.median = __webpack_require__(307); - exports.min = __webpack_require__(308); - exports.prod = __webpack_require__(309); - exports.std = __webpack_require__(310); - exports.sum = __webpack_require__(311); - exports['var'] = __webpack_require__(312); - - // functions - trigonometry - exports.acos = __webpack_require__(313); - exports.acosh = __webpack_require__(314); - exports.acot = __webpack_require__(315); - exports.acoth = __webpack_require__(316); - exports.acsc = __webpack_require__(317); - exports.acsch = __webpack_require__(318); - exports.asec = __webpack_require__(319); - exports.asech = __webpack_require__(320); - exports.asin = __webpack_require__(321); - exports.asinh = __webpack_require__(322); - exports.atan = __webpack_require__(323); - exports.atanh = __webpack_require__(324); - exports.atan2 = __webpack_require__(325); - exports.cos = __webpack_require__(326); - exports.cosh = __webpack_require__(327); - exports.cot = __webpack_require__(328); - exports.coth = __webpack_require__(329); - exports.csc = __webpack_require__(330); - exports.csch = __webpack_require__(331); - exports.sec = __webpack_require__(332); - exports.sech = __webpack_require__(333); - exports.sin = __webpack_require__(334); - exports.sinh = __webpack_require__(335); - exports.tan = __webpack_require__(336); - exports.tanh = __webpack_require__(337); - - // functions - units - exports.to = __webpack_require__(338); - - // functions - utils - exports.clone = __webpack_require__(339); - exports.map = __webpack_require__(340); - exports.filter = __webpack_require__(341); - exports.forEach = __webpack_require__(342); - exports.format = __webpack_require__(343); - // exports.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects. - exports['import'] = __webpack_require__(344); - exports.sort = __webpack_require__(345); - exports['typeof'] = __webpack_require__(346); - - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - var DimensionError = __webpack_require__(174); + var util = __webpack_require__(36); + var DimensionError = __webpack_require__(39); var array = util.array; var object = util.object; @@ -5402,11 +3996,9 @@ return /******/ (function(modules) { // webpackBootstrap var validateIndex = array.validateIndex; function factory (type, config, load) { + + var equal = load(__webpack_require__(46)); - var equal = load(__webpack_require__(115)); - - var Index = type.Index; - var BigNumber = type.BigNumber; var Matrix = type.Matrix; /** @@ -5528,7 +4120,7 @@ return /******/ (function(modules) { // webpackBootstrap matrix._size = [rows, columns]; }; - SparseMatrix.prototype = new Matrix(); + SparseMatrix.prototype = new type.Matrix(); SparseMatrix.prototype.type = 'SparseMatrix'; @@ -5591,7 +4183,7 @@ return /******/ (function(modules) { // webpackBootstrap var _getsubset = function (matrix, index) { // check index - if (!(index instanceof Index)) { + if (!(index instanceof type.Index)) { throw new TypeError('Invalid index'); } @@ -5625,7 +4217,7 @@ return /******/ (function(modules) { // webpackBootstrap var _setsubset = function (matrix, index, submatrix, defaultValue) { // check index - if (!(index instanceof Index)) { + if (!(index instanceof type.Index)) { throw new TypeError('Invalid index'); } @@ -5635,7 +4227,7 @@ return /******/ (function(modules) { // webpackBootstrap // calculate the size of the submatrix, and convert it into an Array if needed var sSize; - if (submatrix instanceof Matrix) { + if (submatrix instanceof type.Matrix) { // submatrix size sSize = submatrix.size(); // use array representation @@ -5985,7 +4577,8 @@ return /******/ (function(modules) { // webpackBootstrap values: this._values ? object.clone(this._values) : undefined, index: object.clone(this._index), ptr: object.clone(this._ptr), - size: object.clone(this._size) + size: object.clone(this._size), + datatype: this._datatype }); return m; }; @@ -6250,7 +4843,7 @@ return /******/ (function(modules) { // webpackBootstrap // validate k if any if (k) { // convert BigNumber to a number - if (k instanceof BigNumber) + if (k instanceof type.BigNumber) k = k.toNumber(); // is must be an integer if (!isNumber(k) || !isInteger(k)) { @@ -6338,7 +4931,7 @@ return /******/ (function(modules) { // webpackBootstrap // map size & validate size = size.map(function (s) { // check it is a big number - if (s instanceof BigNumber) { + if (s instanceof type.BigNumber) { // convert it s = s.toNumber(); } @@ -6352,7 +4945,7 @@ return /******/ (function(modules) { // webpackBootstrap // validate k if any if (k) { // convert BigNumber to a number - if (k instanceof BigNumber) + if (k instanceof type.BigNumber) k = k.toNumber(); // is must be an integer if (!isNumber(k) || !isInteger(k)) { @@ -6390,7 +4983,7 @@ return /******/ (function(modules) { // webpackBootstrap return value[i]; }; } - else if (value instanceof Matrix) { + else if (value instanceof type.Matrix) { // matrix size var ms = value.size(); // validate matrix @@ -6557,7 +5150,7 @@ return /******/ (function(modules) { // webpackBootstrap }; // register this type in the base class Matrix - Matrix._storage.sparse = SparseMatrix; + type.Matrix._storage.sparse = SparseMatrix; return SparseMatrix; } @@ -6568,13 +5161,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 18 */ +/* 13 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var util = __webpack_require__(171); - var DimensionError = __webpack_require__(174); + var util = __webpack_require__(36); + var DimensionError = __webpack_require__(39); var string = util.string; var array = util.array; @@ -6588,12 +5181,10 @@ return /******/ (function(modules) { // webpackBootstrap var validateIndex = array.validateIndex; - function factory (type, config, load) { + function factory (type) { - var Index = type.Index; - var BigNumber = type.BigNumber; var Matrix = type.Matrix; - + function DenseMatrix(data, datatype) { if (!(this instanceof DenseMatrix)) throw new SyntaxError('Constructor must be called with the new operator'); @@ -6768,7 +5359,7 @@ return /******/ (function(modules) { // webpackBootstrap * @private */ function _get (matrix, index) { - if (!(index instanceof Index)) { + if (!(index instanceof type.Index)) { throw new TypeError('Invalid index'); } @@ -6837,7 +5428,7 @@ return /******/ (function(modules) { // webpackBootstrap * @private */ function _set (matrix, index, submatrix, defaultValue) { - if (!(index instanceof Index)) { + if (!(index instanceof type.Index)) { throw new TypeError('Invalid index'); } @@ -6847,7 +5438,7 @@ return /******/ (function(modules) { // webpackBootstrap // calculate the size of the submatrix, and convert it into an Array if needed var sSize; - if (submatrix instanceof Matrix) { + if (submatrix instanceof type.Matrix) { sSize = submatrix.size(); submatrix = submatrix.valueOf(); } @@ -7141,7 +5732,7 @@ return /******/ (function(modules) { // webpackBootstrap // validate k if any if (k) { // convert BigNumber to a number - if (k instanceof BigNumber) + if (k instanceof type.BigNumber) k = k.toNumber(); // is must be an integer if (!isNumber(k) || !isInteger(k)) { @@ -7197,7 +5788,7 @@ return /******/ (function(modules) { // webpackBootstrap // map size & validate size = size.map(function (s) { // check it is a big number - if (s instanceof BigNumber) { + if (s instanceof type.BigNumber) { // convert it s = s.toNumber(); } @@ -7211,7 +5802,7 @@ return /******/ (function(modules) { // webpackBootstrap // validate k if any if (k) { // convert BigNumber to a number - if (k instanceof BigNumber) + if (k instanceof type.BigNumber) k = k.toNumber(); // is must be an integer if (!isNumber(k) || !isInteger(k)) { @@ -7249,7 +5840,7 @@ return /******/ (function(modules) { // webpackBootstrap return value[i]; }; } - else if (value instanceof Matrix) { + else if (value instanceof type.Matrix) { // matrix size var ms = value.size(); // validate matrix @@ -7360,7 +5951,7 @@ return /******/ (function(modules) { // webpackBootstrap if (isArray(elem)) { data[i] = preprocess(elem); } - else if (elem instanceof Matrix) { + else if (elem instanceof type.Matrix) { data[i] = preprocess(elem.valueOf()); } } @@ -7368,8 +5959,8 @@ return /******/ (function(modules) { // webpackBootstrap return data; } // register this type in the base class Matrix - Matrix._storage.dense = DenseMatrix; - Matrix._storage['default'] = DenseMatrix; + type.Matrix._storage.dense = DenseMatrix; + type.Matrix._storage['default'] = DenseMatrix; // exports return DenseMatrix; @@ -7381,15 +5972,15 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 19 */ +/* 14 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; function factory (type, config, load, typed) { - var add = load(__webpack_require__(32)); - var equal = load(__webpack_require__(115)); + var add = load(__webpack_require__(47)); + var equal = load(__webpack_require__(46)); /** * An ordered Sparse Accumulator is a representation for a sparse vector that includes a dense array @@ -7524,992 +6115,460 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 20 */ +/* 15 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - function factory (type, config, load, typed) { - /** - * Instantiate mathjs data types from their JSON representation - * @param {string} key - * @param {*} value - * @returns {*} Returns the revived object - */ - return function reviver(key, value) { - var constructor = type[value && value.mathjs]; - if (constructor && typeof constructor.fromJSON === 'function') { - return constructor.fromJSON(value); - } + var object = __webpack_require__(33); + var bignumber = __webpack_require__(48); - return value; + function factory (type, config, load, typed, math) { + math['true'] = true; + math['false'] = false; + math['null'] = null; + math['uninitialized'] = __webpack_require__(37).UNINITIALIZED; + + if (config.number === 'bignumber') { + math['Infinity'] = new type.BigNumber(Infinity); + math['NaN'] = new type.BigNumber(NaN); + + object.lazy(math, 'pi', function () {return bignumber.pi(config.precision)}); + object.lazy(math, 'tau', function () {return bignumber.tau(config.precision)}); + object.lazy(math, 'e', function () {return bignumber.e(config.precision)}); + object.lazy(math, 'phi', function () {return bignumber.phi(config.precision)}); // golden ratio, (1+sqrt(5))/2 + + // uppercase constants (for compatibility with built-in Math) + object.lazy(math, 'E', function () {return math.e;}); + object.lazy(math, 'LN2', function () {return new type.BigNumber(2).ln();}); + object.lazy(math, 'LN10', function () {return new type.BigNumber(10).ln()}); + object.lazy(math, 'LOG2E', function () {return new type.BigNumber(1).div(new type.BigNumber(2).ln());}); + object.lazy(math, 'LOG10E', function () {return new type.BigNumber(1).div(new type.BigNumber(10).ln())}); + object.lazy(math, 'PI', function () {return math.pi}); + object.lazy(math, 'SQRT1_2', function () {return new type.BigNumber('0.5').sqrt()}); + object.lazy(math, 'SQRT2', function () {return new type.BigNumber(2).sqrt()}); } + else { + math['Infinity'] = Infinity; + math['NaN'] = NaN; + + math.pi = Math.PI; + math.tau = Math.PI * 2; + math.e = Math.E; + math.phi = 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2 + + // uppercase constants (for compatibility with built-in Math) + math.E = math.e; + math.LN2 = Math.LN2; + math.LN10 = Math.LN10; + math.LOG2E = Math.LOG2E; + math.LOG10E = Math.LOG10E; + math.PI = math.pi; + math.SQRT1_2 = Math.SQRT1_2; + math.SQRT2 = Math.SQRT2; + } + + // complex i + math.i = new type.Complex(0, 1); + + // meta information + math.version = __webpack_require__(49); } - exports.name = 'reviver'; - exports.path = 'json'; exports.factory = factory; + exports.math = true; // request access to the math namespace + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // TODO: change to exports.create = function () {...} + module.exports = function () { + var string = __webpack_require__(42); + + /** + * @constructor Chain + * Wrap any value in a chain, allowing to perform chained operations on + * the value. + * + * All methods available in the math.js library can be called upon the chain, + * and then will be evaluated with the value itself as first argument. + * The chain can be closed by executing chain.done(), which will return + * the final value. + * + * The Chain has a number of special functions: + * - done() Finalize the chained operation and return the + * chain's value. + * - valueOf() The same as done() + * - toString() Returns a string representation of the chain's value. + * + * @param {*} [value] + */ + function Chain (value) { + if (!(this instanceof Chain)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (value instanceof Chain) { + this.value = value.value; + } + else { + this.value = value; + } + } + + /** + * Close the chain. Returns the final value. + * Does the same as method valueOf() + * @returns {*} value + */ + Chain.prototype.done = function () { + return this.value; + }; + + /** + * Close the chain. Returns the final value. + * Does the same as method done() + * @returns {*} value + */ + Chain.prototype.valueOf = function () { + return this.value; + }; + + /** + * Get a string representation of the value in the chain + * @returns {String} + */ + Chain.prototype.toString = function () { + return string.format(this.value); + }; + + /** + * Create a proxy method for the chain + * @param {String} name + * @param {*} value The value or function to be proxied + */ + function createProxy(name, value) { + var slice = Array.prototype.slice; + if (typeof value === 'function') { + // a function + Chain.prototype[name] = function () { + var args = [this.value].concat(slice.call(arguments, 0)); + return new Chain(value.apply(this, args)); + } + } + else { + // a constant + Chain.prototype[name] = new Chain(value); + } + } + + /** + * Create a proxy for a single method, or an object with multiple methods. + * Example usage: + * + * Chain.createProxy('add', function add (x, y) {...}); + * Chain.createProxy({ + * add: function add (x, y) {...}, + * subtract: function subtract (x, y) {...} + * } + * + * + * @param {String | Object} arg0 A function name (string), or an object with + * methods + * @param {*} [arg1] Function or value, when arg0 is a name + */ + Chain.createProxy = function (arg0, arg1) { + if (typeof arg0 === 'string') { + // createProxy(name, value) + createProxy(arg0, arg1); + } + else { + // createProxy(values) + for (var prop in arg0) { + if (arg0.hasOwnProperty(prop)) { + createProxy(prop, arg0[prop]); + } + } + } + }; + + return Chain; + }; + + +/***/ }, +/* 17 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(183), + __webpack_require__(51), + __webpack_require__(52), + __webpack_require__(184), + __webpack_require__(185) + ]; + + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(53) + ]; + + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + // decomposition + __webpack_require__(54), + + // solver + __webpack_require__(55) + ]; + + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(56), + __webpack_require__(47), + __webpack_require__(57), + __webpack_require__(58), + __webpack_require__(59), + __webpack_require__(60), + __webpack_require__(61), + __webpack_require__(62), + __webpack_require__(63), + __webpack_require__(64), + __webpack_require__(65), + __webpack_require__(66), + __webpack_require__(67), + __webpack_require__(68), + __webpack_require__(69), + __webpack_require__(70), + __webpack_require__(71), + __webpack_require__(72), + __webpack_require__(73), + __webpack_require__(74), + __webpack_require__(75), + __webpack_require__(76), + __webpack_require__(77), + __webpack_require__(78), + __webpack_require__(79), + __webpack_require__(80), + __webpack_require__(81), + __webpack_require__(82) + ]; /***/ }, /* 21 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var BigNumber = __webpack_require__(351); - var errorTransform = __webpack_require__(208).transform; - var isNumber = __webpack_require__(175).isNumber; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.range - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function concat - * from one-based to zero based - * @param {Object} math - */ - module.exports = function (math) { - var transform = function () { - // copy arguments into an array - var args = argsToArray(arguments); - - // change last argument from one-based to zero-based - var lastIndex = args.length - 1; - var last = args[lastIndex]; - if (isNumber(last)) { - args[lastIndex] = last - 1; - } - else if (last instanceof BigNumber) { - args[lastIndex] = last.minus(1); - } - - try { - return math.concat.apply(math, args); - } - catch (err) { - throw errorTransform(err); - } - }; - - math.concat.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(83), + __webpack_require__(84), + __webpack_require__(85), + __webpack_require__(86), + __webpack_require__(87), + __webpack_require__(88), + __webpack_require__(89) + ]; /***/ }, /* 22 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var SymbolNode = __webpack_require__(188); - var isBoolean = __webpack_require__(209).isBoolean; - var argsToArray = __webpack_require__(172).argsToArray; - var ArgumentsError = __webpack_require__(177); - - /** - * Attach a transform function to math.filter - * Adds a property transform containing the transform function. - * - * This transform adds support for equations as test function for math.filter, - * so you can do something like 'filter([3, -2, 5], x > 0)'. - * @param {Object} math - */ - module.exports = function (math) { - var _filter = math.filter; - - var transform = function (args, math, scope) { - if (args.length !== 2) { - throw new ArgumentsError('filter', arguments.length, 2); - } - - var x = args[0].compile(math).eval(scope); - var test; - if (args[1] instanceof SymbolNode) { - // a function pointer, like filter([3, -2, 5], myTestFunction); - test = args[1].compile(math).eval(scope); - } - else { - // an equation like filter([3, -2, 5], x > 0) - - // find an undefined symbol - var _scope = scope || {}; - var symbol = args[1] - .filter(function (node) { - return (node instanceof SymbolNode) && - !(node.name in math) && - !(node.name in _scope); - })[0]; - - // create a test function for this equation - var sub = Object.create(_scope); - var eq = args[1].compile(math); - if (symbol) { - var name = symbol.name; - test = function (x) { - sub[name] = x; - return eq.eval(sub); - } - } - else { - throw new Error('No undefined variable found in filter equation'); - } - } - - return _filter(x, test); - }; - - transform.rawArgs = true; - math.filter.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(90), + __webpack_require__(91), + __webpack_require__(92), + __webpack_require__(93) + ]; /***/ }, /* 23 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - /** - * Attach a transform function to math.forEach - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - * @param {Object} math - */ - module.exports = function (math) { - - var Matrix = math.type.Matrix; - - var transform = function (x, callback) { - if (arguments.length != 2) { - throw new math.error.ArgumentsError('forEach', arguments.length, 2); - } - - if (Array.isArray(x)) { - _forEachArray(x, callback, x); - } else if (x instanceof Matrix) { - _forEachArray(x.valueOf(), callback, x); - } else { - throw new math.error.UnsupportedTypeError('forEach', math['typeof'](x)); - } - }; - - function _forEachArray (array, callback, arrayOrig) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - value.forEach(function (child, i) { - // we create a copy of the index array and append the new index value - recurse(child, index.concat(i + 1)); // one based index, hence i+1 - }); - } - else { - callback(value, index, arrayOrig); - } - }; - recurse(array, []); - } - - math.forEach.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(119), + __webpack_require__(120), + __webpack_require__(121), + __webpack_require__(122), + __webpack_require__(123), + __webpack_require__(40), + __webpack_require__(124), + __webpack_require__(43), + __webpack_require__(125), + __webpack_require__(126), + __webpack_require__(127) + ]; /***/ }, /* 24 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var BigNumber = __webpack_require__(351); - var Range = __webpack_require__(4); - var Index = __webpack_require__(5); - var isNumber = __webpack_require__(175).isNumber; - - /** - * Attach a transform function to math.index - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - * @param {Object} math - */ - module.exports = function (math) { - var transform = function () { - var args = []; - for (var i = 0, ii = arguments.length; i < ii; i++) { - var arg = arguments[i]; - - // change from one-based to zero based, and convert BigNumber to number - if (arg instanceof Range) { - arg.start--; - arg.end -= (arg.step > 0 ? 0 : 2); - } - else if (isNumber(arg)) { - arg--; - } - else if (arg instanceof BigNumber) { - arg = arg.toNumber() - 1; - } - else { - throw new TypeError('Ranges must be a Number or Range'); - } - - args[i] = arg; - } - - var res = new Index(); - Index.apply(res, args); - return res; - }; - - math.index.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(98), + __webpack_require__(99), + __webpack_require__(100), + __webpack_require__(101) + ]; /***/ }, /* 25 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - /** - * Attach a transform function to math.map - * Adds a property transform containing the transform function. - * - * This transform creates a one-based index instead of a zero-based index - * @param {Object} math - */ - module.exports = function (math) { - - var Matrix = math.type.Matrix; - - var transform = function (x, callback) { - if (arguments.length != 2) { - throw new math.error.ArgumentsError('map', arguments.length, 2); - } - - if (Array.isArray(x)) { - return _mapArray(x, callback, x); - } else if (x instanceof Matrix) { - return math.matrix(_mapArray(x.valueOf(), callback, x)); - } else { - throw new math.error.UnsupportedTypeError('map', math['typeof'](x)); - } - }; - - function _mapArray (arrayIn, callback, arrayOrig) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - return value.map(function (child, i) { - // we create a copy of the index array and append the new index value - return recurse(child, index.concat(i + 1)); // one based index, hence i + 1 - }); - } - else { - return callback(value, index, arrayOrig); - } - }; - - return recurse(arrayIn, []); - } - - math.map.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(94), + __webpack_require__(95), + __webpack_require__(96), + __webpack_require__(97) + ]; /***/ }, /* 26 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var BigNumber = __webpack_require__(351); - var errorTransform = __webpack_require__(208).transform; - var isNumber = __webpack_require__(175).isNumber; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.max - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function max - * from one-based to zero based - * @param {Object} math - */ - module.exports = function (math) { - - var isCollection = math.collection.isCollection; - - var transform = function () { - var args = argsToArray(arguments); - - // change last argument dim from one-based to zero-based - if (args.length == 2 && isCollection(args[0])) { - var dim = args[1]; - if (isNumber(dim)) { - args[1] = dim - 1; - } - else if (dim instanceof BigNumber) { - args[1] = dim.minus(1); - } - } - - try { - return math.max.apply(math, args); - } - catch (err) { - throw errorTransform(err); - } - }; - - math.max.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(102), + __webpack_require__(103), + __webpack_require__(104), + __webpack_require__(105), + __webpack_require__(106), + __webpack_require__(107), + __webpack_require__(108), + __webpack_require__(109), + __webpack_require__(110), + __webpack_require__(111), + __webpack_require__(112), + __webpack_require__(113), + __webpack_require__(114), + __webpack_require__(115), + __webpack_require__(116), + __webpack_require__(117), + __webpack_require__(118) + ]; /***/ }, /* 27 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var BigNumber = __webpack_require__(351); - var errorTransform = __webpack_require__(208).transform; - var isNumber = __webpack_require__(175).isNumber; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.mean - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function mean - * from one-based to zero based - * @param {Object} math - */ - module.exports = function (math) { - - var isCollection = math.collection.isCollection; - - var transform = function () { - var args = argsToArray(arguments); - - // change last argument dim from one-based to zero-based - if (args.length == 2 && isCollection(args[0])) { - var dim = args[1]; - if (isNumber(dim)) { - args[1] = dim - 1; - } - else if (dim instanceof BigNumber) { - args[1] = dim.minus(1); - } - } - - try { - return math.mean.apply(math, args); - } - catch (err) { - throw errorTransform(err); - } - }; - - math.mean.transform = transform; - - return transform; - }; + module.exports = [ + //require('./distribution'), // TODO: rethink math.distribution + __webpack_require__(128), + __webpack_require__(129), + __webpack_require__(130), + __webpack_require__(131), + __webpack_require__(132), + __webpack_require__(133), + __webpack_require__(134) + ]; /***/ }, /* 28 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var BigNumber = __webpack_require__(351); - var errorTransform = __webpack_require__(208).transform; - var isNumber = __webpack_require__(175).isNumber; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.min - * Adds a property transform containing the transform function. - * - * This transform changed the last `dim` parameter of function min - * from one-based to zero based - * @param {Object} math - */ - module.exports = function (math) { - - var isCollection = math.collection.isCollection; - - var transform = function () { - var args = argsToArray(arguments); - - // change last argument dim from one-based to zero-based - if (args.length == 2 && isCollection(args[0])) { - var dim = args[1]; - if (isNumber(dim)) { - args[1] = dim - 1; - } - else if (dim instanceof BigNumber) { - args[1] = dim.minus(1); - } - } - - try { - return math.min.apply(math, args); - } - catch (err) { - throw errorTransform(err); - } - }; - - math.min.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(168), + __webpack_require__(169), + __webpack_require__(46), + __webpack_require__(45), + __webpack_require__(170), + __webpack_require__(44), + __webpack_require__(171), + __webpack_require__(172) + ]; /***/ }, /* 29 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var isBoolean = __webpack_require__(209).isBoolean; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.range - * Adds a property transform containing the transform function. - * - * This transform creates a range which includes the end value - * @param {Object} math - */ - module.exports = function (math) { - var transform = function () { - var args = argsToArray(arguments); - - var lastIndex = args.length - 1; - var last = args[lastIndex]; - if (!isBoolean(last)) { - args.push(true); // append a parameter includeEnd=true - } - - return math.range.apply(math, args); - }; - - math.range.transform = transform; - - return transform; - }; - + module.exports = [ + __webpack_require__(135), + __webpack_require__(136), + __webpack_require__(137), + __webpack_require__(138), + __webpack_require__(139), + __webpack_require__(140), + __webpack_require__(141), + __webpack_require__(142) + ]; /***/ }, /* 30 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var errorTransform = __webpack_require__(208).transform; - var isBoolean = __webpack_require__(209).isBoolean; - var argsToArray = __webpack_require__(172).argsToArray; - - /** - * Attach a transform function to math.subset - * Adds a property transform containing the transform function. - * - * This transform creates a range which includes the end value - * @param {Object} math - */ - module.exports = function (math) { - var transform = function () { - try { - return math.subset.apply(math, argsToArray(arguments)); - } - catch (err) { - throw errorTransform(err); - } - }; - - math.subset.transform = transform; - - return transform; - }; + module.exports = [ + __webpack_require__(143), + __webpack_require__(144), + __webpack_require__(145), + __webpack_require__(146), + __webpack_require__(147), + __webpack_require__(148), + __webpack_require__(149), + __webpack_require__(150), + __webpack_require__(151), + __webpack_require__(152), + __webpack_require__(153), + __webpack_require__(154), + __webpack_require__(155), + __webpack_require__(156), + __webpack_require__(157), + __webpack_require__(158), + __webpack_require__(159), + __webpack_require__(160), + __webpack_require__(161), + __webpack_require__(162), + __webpack_require__(163), + __webpack_require__(164), + __webpack_require__(165), + __webpack_require__(166), + __webpack_require__(167) + ]; /***/ }, /* 31 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the absolute value of a number. For matrices, the function is - * evaluated element wise. - * - * Syntax: - * - * math.abs(x) - * - * Examples: - * - * math.abs(3.5); // returns Number 3.5 - * math.abs(-4.2); // returns Number 4.2 - * - * math.abs([3, -5, -1, 0, 2]); // returns Array [3, 5, 1, 0, 2] - * - * See also: - * - * sign - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * A number or matrix for which to get the absolute value - * @return {Number | BigNumber | Complex | Array | Matrix} - * Absolute value of `x` - */ - var abs = typed('abs', { - 'number': Math.abs, - - 'Complex': function (x) { - var re = Math.abs(x.re); - var im = Math.abs(x.im); - if (re < 1000 && im < 1000) { - return Math.sqrt(re * re + im * im); - } - else { - // prevent overflow for large numbers - if (re >= im) { - var i = im / re; - return re * Math.sqrt(1 + i * i); - } - else { - var j = re / im; - return im * Math.sqrt(1 + j * j); - } - } - }, - - 'BigNumber': function (x) { - return x.abs(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since abs(0) = 0 - return collection.deepMap(x, abs, true); - } - }); - - return abs; - } - - exports.name = 'abs'; - exports.factory = factory; - + module.exports = [ + __webpack_require__(173) + ]; /***/ }, /* 32 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var clone = __webpack_require__(166).clone; - var DimensionError = __webpack_require__(174); - - function factory (type, config, load, typed) { - - var collection = load(__webpack_require__(2)); - var matrix = load(__webpack_require__(75)); - var equal = load(__webpack_require__(115)); - var sparseScatter = load(__webpack_require__(210)); - var addScalar = load(__webpack_require__(211)); - var multiplyScalar = load(__webpack_require__(212)); - - var DenseMatrix = type.DenseMatrix, - SparseMatrix = type.SparseMatrix; - - /** - * Add two values, `x + y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.add(x, y) - * - * Examples: - * - * math.add(2, 3); // returns Number 5 - * - * var a = math.complex(2, 3); - * var b = math.complex(-4, 1); - * math.add(a, b); // returns Complex -2 + 4i - * - * math.add([1, 2, 3], 4); // returns Array [5, 6, 7] - * - * var c = math.unit('5 cm'); - * var d = math.unit('2.1 mm'); - * math.add(c, d); // returns Unit 52.1 mm - * - * See also: - * - * subtract - * - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null} x First value to add - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null} y Second value to add - * @return {Number | BigNumber | Complex | Unit | String | Array | Matrix} Sum of `x` and `y` - */ - var add = typed('add', { - - 'any, any': addScalar, - - 'Matrix, Matrix': function (x, y) { - // matrix sizes - var xsize = x.size(); - var ysize = y.size(); - - // check dimensions - if (xsize.length !== ysize.length) - throw new DimensionError(xsize.length, ysize.length); - - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = _addSparseMatrixSparseMatrix(x, y, xsize, ysize); - break; - default: - c = _addSparseMatrixMatrix(x, y.valueOf(), xsize, ysize); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // sparse + sparse - c = _addMatrixSparseMatrix(x.valueOf(), y, xsize, ysize); - break; - default: - c = _addMatrixMatrix(x.valueOf(), y.valueOf(), x.storage()); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return add(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return add(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return add(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = _addSparseMatrixScalar(x, y, x.size()); - break; - default: - c = collection.deepMap2(x, y, add); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = _addSparseMatrixScalar(y, x, y.size()); - break; - default: - c = collection.deepMap2(x, y, add); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - return collection.deepMap2(x, y, add); - }, - - 'any, Array': function (x, y) { - return collection.deepMap2(x, y, add); - } - }); - - /** - * C = A + B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Scalar} b Scalar value - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _addSparseMatrixScalar = function (a, b, asize) { - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - // check b is zero - if (!equal(b, 0)) { - // c arrays - var cvalues = []; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // loop columns - for (var j = 0; j < n; j++) { - // ptr for column j - cptr[j] = cindex.length; - // loop values for column j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // sum values - var v = addScalar(avalues[k], b); - // compare with zero - if (!equal(v, 0)) { - // push to c - cindex.push(aindex[k]); - cvalues.push(v); - } - } - } - // update ptr - cptr[n] = cindex.length; - // return matrix - return c; - } - // return clone - return a.clone(); - }; - - /** - * C = A + B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b SparseMatrix (MxN) - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _addSparseMatrixSparseMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a arrays - var avalues = a._values; - var adt = a._datatype; - // b arrays - var bvalues = b._values; - var bdt = b._datatype; - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply scalar implementation - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] : addScalar; - // flag indicating both matrices (a & b) contain data - var values = avalues && bvalues; - // c arrays - var cvalues = values ? [] : undefined; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // column vector (store matrix values) - var x = values ? new Array(m) : undefined; - // column vector to signal row values in column j - var w = new Array(m); - // loop columns - for (var j = 0; j < n; j++) { - // init ptr for j - cptr[j] = cindex.length; - // process column j of a and write it to x - sparseScatter(a, j, 1, w, x, j + 1, c, mf, af); - // process column j of b and write it to x - sparseScatter(b, j, 1, w, x, j + 1, c, mf, af); - // check matrix contains values (pattern matrix) - if (values) { - // loop column values in C - for (var p0 = cptr[j], p1 = cindex.length, p = p0; p < p1; p++) { - // copy x[i] to c[i, j] - cvalues.push(x[cindex[p]]); - } - } - } - // finish cptr - cptr[n] = cindex.length; - // return matrix - return c; - }; - - /** - * C = A + B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b DenseMatrix (MxN) - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _addSparseMatrixMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // b array - var data = b; - // c arrays - var cvalues = []; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // column vector (store matrix values) - var x = new Array(m); - // column vector to signal row values in column j - var w = new Array(m); - // loop columns - for (var j = 0; j < n; j++) { - // init ptr for j - cptr[j] = cindex.length; - // copy matrix b column to x - for (var i = 0; i < m; i++) { - // value - var v = data[i][j]; - // check for zero - if (!equal(v, 0)) { - x[i] = v; - w[i] = j + 1; - cindex.push(i); - } - } - // process column j of a and write it to x - sparseScatter(a, j, 1, w, x, j + 1, c, multiplyScalar, addScalar); - // loop column values in C - for (var p0 = cptr[j], p1 = cindex.length, p = p0; p < p1; p++) { - // copy x[i] to c[i, j] - cvalues.push(x[cindex[p]]); - } - } - // finish cptr - cptr[n] = cindex.length; - // return matrix - return c; - }; - - /** - * C = A + B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b SparseMatrix (MxN) - * - * @return {Matrix} DenseMatrix (MxN) - */ - var _addMatrixSparseMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a array - var data = a; - // b arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - // c arrays - var cdata = clone(data); - // c matrix - var c = new DenseMatrix({ - data: cdata, - size: [m, n] - }); - // loop columns - for (var j = 0; j < n; j++) { - // loop values for column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - var i = bindex[k]; - // aggregate value - cdata[i][j] = addScalar(cdata[i][j], bvalues[k]); - } - } - // return matrix - return c; - }; - - /** - * C = A + B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b DenseMatrix (MxN) - * - * @return {Matrix} DenseMatrix (MxN) - */ - var _addMatrixMatrix = function (a, b, format) { - // TODO: find a better implementation - return matrix(collection.deepMap2(a, b, add), format); - }; - - return add; - } - - exports.name = 'add'; - exports.factory = factory; + module.exports = [ + __webpack_require__(174), + __webpack_require__(175), + __webpack_require__(176), + __webpack_require__(177), + // note: import is already loaded by loader.js + __webpack_require__(178), + __webpack_require__(179), + __webpack_require__(180), + __webpack_require__(181), + __webpack_require__(182) + ]; /***/ }, @@ -8518,13216 +6577,7 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Round a value towards plus infinity - * If `x` is complex, both real and imaginary part are rounded towards plus infinity. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.ceil(x) - * - * Examples: - * - * math.ceil(3.2); // returns Number 4 - * math.ceil(3.8); // returns Number 4 - * math.ceil(-4.2); // returns Number -4 - * math.ceil(-4.7); // returns Number -4 - * - * var c = math.complex(3.2, -2.7); - * math.ceil(c); // returns Complex 4 - 2i - * - * math.ceil([3.2, 3.8, -4.7]); // returns Array [4, 4, -4] - * - * See also: - * - * floor, fix, round - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded - * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value - */ - var ceil = typed('ceil', { - 'number': Math.ceil, - - 'Complex': function (x) { - return new x.constructor( - Math.ceil(x.re), - Math.ceil(x.im) - ); - }, - - 'BigNumber': function (x) { - return x.ceil(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since ceil(0) = 0 - return collection.deepMap(x, ceil, true); - } - }); - - return ceil; - } - - exports.name = 'ceil'; - exports.factory = factory; - - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var collection = load(__webpack_require__(2)); - var complexMultiply = load(__webpack_require__(212)).signatures['Complex,Complex']; - - /** - * Compute the cube of a value, `x * x * x`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cube(x) - * - * Examples: - * - * math.cube(2); // returns Number 8 - * math.pow(2, 3); // returns Number 8 - * math.cube(4); // returns Number 64 - * 4 * 4 * 4; // returns Number 64 - * - * math.cube([1, 2, 3, 4]); // returns Array [1, 8, 27, 64] - * - * See also: - * - * multiply, square, pow - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number for which to calculate the cube - * @return {Number | BigNumber | Complex | Array | Matrix} Cube of x - */ - var cube = typed('cube', { - 'number': function (x) { - return x * x * x; - }, - - 'Complex': function (x) { - return complexMultiply(complexMultiply(x, x), x); - }, - - 'BigNumber': function (x) { - return x.times(x).times(x); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since cube(0) = 0 - return collection.deepMap(x, cube, true); - } - }); - - return cube; - } - - exports.name = 'cube'; - exports.factory = factory; - - -/***/ }, -/* 35 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var divideScalar = load(__webpack_require__(213)); - var multiply = load(__webpack_require__(47)); - var inv = load(__webpack_require__(96)); - - /** - * Divide two values, `x / y`. - * To divide matrices, `x` is multiplied with the inverse of `y`: `x * inv(y)`. - * - * Syntax: - * - * math.divide(x, y) - * - * Examples: - * - * math.divide(2, 3); // returns Number 0.6666666666666666 - * - * var a = math.complex(5, 14); - * var b = math.complex(4, 1); - * math.divide(a, b); // returns Complex 2 + 3i - * - * var c = [[7, -6], [13, -4]]; - * var d = [[1, 2], [4, 3]]; - * math.divide(c, d); // returns Array [[-9, 4], [-11, 6]] - * - * var e = math.unit('18 km'); - * math.divide(e, 4.5); // returns Unit 4 km - * - * See also: - * - * multiply - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Numerator - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} y Denominator - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Quotient, `x / y` - */ - return typed('divide', { - 'any, any': divideScalar, - - 'Array | Matrix, Array | Matrix': function (x, y) { - // TODO: implement matrix right division using pseudo inverse - // http://www.mathworks.nl/help/matlab/ref/mrdivide.html - // http://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html - // http://stackoverflow.com/questions/12263932/how-does-gnu-octave-matrix-division-work-getting-unexpected-behaviour - return multiply(x, inv(y)); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, divideScalar); - }, - - 'any, Array | Matrix': function (x, y) { - return multiply(x, inv(y)); - } - }); - } - - exports.name = 'divide'; - exports.factory = factory; - - -/***/ }, -/* 36 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var divideScalar = load(__webpack_require__(213)); - - /** - * Divide two matrices element wise. The function accepts both matrices and - * scalar values. - * - * Syntax: - * - * math.dotDivide(x, y) - * - * Examples: - * - * math.dotDivide(2, 4); // returns 0.5 - * - * a = [[9, 5], [6, 1]]; - * b = [[3, 2], [5, 2]]; - * - * math.dotDivide(a, b); // returns [[3, 2.5], [1.2, 0.5]] - * math.divide(a, b); // returns [[1.75, 0.75], [-1.75, 2.25]] - * - * See also: - * - * divide, multiply, dotMultiply - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Numerator - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Denominator - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Quotient, `x ./ y` - */ - return typed('dotDivide', { - 'any, any': function (x, y) { - return collection.deepMap2(x, y, divideScalar); - } - }); - } - - exports.name = 'dotDivide'; - exports.factory = factory; - - -/***/ }, -/* 37 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var multiply = load(__webpack_require__(47)); - - /** - * Multiply two matrices element wise. The function accepts both matrices and - * scalar values. - * - * Syntax: - * - * math.dotMultiply(x, y) - * - * Examples: - * - * math.dotMultiply(2, 4); // returns 8 - * - * a = [[9, 5], [6, 1]]; - * b = [[3, 2], [5, 2]]; - * - * math.dotMultiply(a, b); // returns [[27, 10], [30, 2]] - * math.multiply(a, b); // returns [[52, 28], [23, 14]] - * - * See also: - * - * multiply, divide, dotDivide - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Left hand value - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Right hand value - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` - */ - return typed('dotMultiply', { - 'any, any': function (x, y) { - return collection.deepMap2(x, y, multiply); - } - }); - } - - exports.name = 'dotMultiply'; - exports.factory = factory; - - -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var pow = load(__webpack_require__(50)); - - /** - * Calculates the power of x to y element wise. - * - * Syntax: - * - * math.dotPow(x, y) - * - * Examples: - * - * math.dotPow(2, 3); // returns Number 8 - * - * var a = [[1, 2], [4, 3]]; - * math.dotPow(a, 2); // returns Array [[1, 4], [16, 9]] - * math.pow(a, 2); // returns Array [[9, 8], [16, 17]] - * - * See also: - * - * pow, sqrt, multiply - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x The base - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y The exponent - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} The value of `x` to the power `y` - */ - return typed('dotMultiply', { - 'any, any': function (x, y) { - return collection.deepMap2(x, y, pow); - } - }); - } - - exports.name = 'dotPow'; - exports.factory = factory; - - -/***/ }, -/* 39 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the exponent of a value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.exp(x) - * - * Examples: - * - * math.exp(2); // returns Number 7.3890560989306495 - * math.pow(math.e, 2); // returns Number 7.3890560989306495 - * math.log(math.exp(2)); // returns Number 2 - * - * math.exp([1, 2, 3]); - * // returns Array [ - * // 2.718281828459045, - * // 7.3890560989306495, - * // 20.085536923187668 - * // ] - * - * See also: - * - * log, pow - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x A number or matrix to exponentiate - * @return {Number | BigNumber | Complex | Array | Matrix} Exponent of `x` - */ - var exp = typed('exp', { - 'number': Math.exp, - - 'Complex': function (x) { - var r = Math.exp(x.re); - return new type.Complex( - r * Math.cos(x.im), - r * Math.sin(x.im) - ); - }, - - 'BigNumber': function (x) { - return x.exp(); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, exp); - } - }); - - return exp; - } - - exports.name = 'exp'; - exports.factory = factory; - - -/***/ }, -/* 40 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Round a value towards zero. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.fix(x) - * - * Examples: - * - * math.fix(3.2); // returns Number 3 - * math.fix(3.8); // returns Number 3 - * math.fix(-4.2); // returns Number -4 - * math.fix(-4.7); // returns Number -4 - * - * var c = math.complex(3.2, -2.7); - * math.fix(c); // returns Complex 3 - 2i - * - * math.fix([3.2, 3.8, -4.7]); // returns Array [3, 3, -4] - * - * See also: - * - * ceil, floor, round - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded - * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value - */ - var fix = typed('fix', { - 'number': function (x) { - return (x > 0) ? Math.floor(x) : Math.ceil(x); - }, - - 'Complex': function (x) { - return new x.constructor( - (x.re > 0) ? Math.floor(x.re) : Math.ceil(x.re), - (x.im > 0) ? Math.floor(x.im) : Math.ceil(x.im) - ); - }, - - 'BigNumber': function (x) { - return x.isNegative() ? x.ceil() : x.floor(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since fix(0) = 0 - return collection.deepMap(x, fix, true); - } - }); - - return fix; - } - - exports.name = 'fix'; - exports.factory = factory; - -/***/ }, -/* 41 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Round a value towards minus infinity. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.floor(x) - * - * Examples: - * - * math.floor(3.2); // returns Number 3 - * math.floor(3.8); // returns Number 3 - * math.floor(-4.2); // returns Number -5 - * math.floor(-4.7); // returns Number -5 - * - * var c = math.complex(3.2, -2.7); - * math.floor(c); // returns Complex 3 - 3i - * - * math.floor([3.2, 3.8, -4.7]); // returns Array [3, 3, -5] - * - * See also: - * - * ceil, fix, round - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded - * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value - */ - var floor = typed('floor', { - 'number': Math.floor, - - 'Complex': function (x) { - return new x.constructor( - Math.floor(x.re), - Math.floor(x.im) - ); - }, - - 'BigNumber': function (x) { - return x.floor(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since floor(0) = 0 - return collection.deepMap(x, floor, true); - } - }); - - return floor; - } - - exports.name = 'floor'; - exports.factory = factory; - -/***/ }, -/* 42 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the greatest common divisor for two or more values or arrays. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.gcd(a, b) - * math.gcd(a, b, c, ...) - * - * Examples: - * - * math.gcd(8, 12); // returns 4 - * math.gcd(-4, 6); // returns 2 - * math.gcd(25, 15, -10); // returns 5 - * - * math.gcd([8, -4], [12, 6]); // returns [4, 2] - * - * See also: - * - * lcm, xgcd - * - * @param {... Number | BigNumber | Boolean | Array | Matrix | null} args Two or more integer numbers - * @return {Number | BigNumber | Array | Matrix} The greatest common divisor - */ - var gcd = typed('gcd', { - 'number, number': _gcd, - - 'BigNumber, BigNumber': _gcdBigNumber, - - 'Array | Matrix, Array | Matrix | number | BigNumber': function (a, b) { - return collection.deepMap2(a, b, gcd); - }, - - 'number | BigNumber, Array | Matrix': function (a, b) { - return collection.deepMap2(a, b, gcd); - }, - - // TODO: need a smarter notation here - 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { - var res = gcd(a, b); - for (var i = 0; i < args.length; i++) { - res = gcd(res, args[i]); - } - return res; - } - }); - - return gcd; - - /** - * Calculate gcd for BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @returns {BigNumber} Returns greatest common denominator of a and b - * @private - */ - function _gcdBigNumber(a, b) { - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function gcd must be integer numbers'); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - var zero = new type.BigNumber(0); - while (!b.isZero()) { - var r = a.mod(b); - a = b; - b = r; - } - return a.lt(zero) ? a.neg() : a; - } - } - - /** - * Calculate gcd for numbers - * @param {number} a - * @param {number} b - * @returns {number} Returns the greatest common denominator of a and b - * @private - */ - function _gcd(a, b) { - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function gcd must be integer numbers'); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - var r; - while (b != 0) { - r = a % b; - a = b; - b = r; - } - return (a < 0) ? -a : a; - } - - exports.name = 'gcd'; - exports.factory = factory; - -/***/ }, -/* 43 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the least common multiple for two or more values or arrays. - * - * lcm is defined as: - * - * lcm(a, b) = abs(a * b) / gcd(a, b) - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.lcm(a, b) - * math.lcm(a, b, c, ...) - * - * Examples: - * - * math.lcm(4, 6); // returns 12 - * math.lcm(6, 21); // returns 42 - * math.lcm(6, 21, 5); // returns 210 - * - * math.lcm([4, 6], [6, 21]); // returns [12, 42] - * - * See also: - * - * gcd, xgcd - * - * @param {... Number | BigNumber | Boolean | Array | Matrix | null} args Two or more integer numbers - * @return {Number | BigNumber | Array | Matrix} The least common multiple - */ - var lcm = typed('lcm', { - 'number, number': _lcm, - - 'BigNumber, BigNumber': _lcmBigNumber, - - 'Array | Matrix, Array | Matrix | number | BigNumber': function (a, b) { - return collection.deepMap2(a, b, lcm); - }, - - 'number | BigNumber, Array | Matrix': function (a, b) { - return collection.deepMap2(a, b, lcm); - }, - - // TODO: need a smarter notation here - 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { - var res = lcm(a, b); - for (var i = 0; i < args.length; i++) { - res = lcm(res, args[i]); - } - return res; - } - }); - - return lcm; - - /** - * Calculate lcm for two BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @returns {BigNumber} Returns the least common multiple of a and b - * @private - */ - function _lcmBigNumber(a, b) { - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function lcm must be integer numbers'); - } - - if (a.isZero() || b.isZero()) { - return new type.BigNumber(0); - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - // evaluate lcm here inline to reduce overhead - var prod = a.times(b); - while (!b.isZero()) { - var t = b; - b = a.mod(t); - a = t; - } - return prod.div(a).abs(); - } - } - - /** - * Calculate lcm for two numbers - * @param {number} a - * @param {number} b - * @returns {number} Returns the least common multiple of a and b - * @private - */ - function _lcm (a, b) { - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function lcm must be integer numbers'); - } - - if (a == 0 || b == 0) { - return 0; - } - - // http://en.wikipedia.org/wiki/Euclidean_algorithm - // evaluate lcm here inline to reduce overhead - var t; - var prod = a * b; - while (b != 0) { - t = b; - b = a % t; - a = t; - } - return Math.abs(prod / a); - } - - exports.name = 'lcm'; - exports.factory = factory; - -/***/ }, -/* 44 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var divideScalar = load(__webpack_require__(213)); - - /** - * Calculate the logarithm of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.log(x) - * math.log(x, base) - * - * Examples: - * - * math.log(3.5); // returns 1.252762968495368 - * math.exp(math.log(2.4)); // returns 2.4 - * - * math.pow(10, 4); // returns 10000 - * math.log(10000, 10); // returns 4 - * math.log(10000) / math.log(10); // returns 4 - * - * math.log(1024, 2); // returns 10 - * math.pow(2, 10); // returns 1024 - * - * See also: - * - * exp, log10 - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * Value for which to calculate the logarithm. - * @param {Number | BigNumber | Boolean | Complex | null} [base=e] - * Optional base for the logarithm. If not provided, the natural - * logarithm of `x` is calculated. - * @return {Number | BigNumber | Complex | Array | Matrix} - * Returns the logarithm of `x` - */ - var log = typed('log', { - 'number': _logNumber, - - 'Complex': function (x) { - return new type.Complex ( - Math.log(Math.sqrt(x.re * x.re + x.im * x.im)), - Math.atan2(x.im, x.re) - ); - }, - - 'BigNumber': function (x) { - return x.ln(); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, log); - }, - - 'any, any': function (x, base) { - // calculate logarithm for a specified base, log(x, base) - return divideScalar(log(x), log(base)); - } - }); - - /** - * Calculate the natural logarithm of a number - * @param {number} x - * @returns {number | Complex} - * @private - */ - function _logNumber(x) { - if (x >= 0) { - return Math.log(x); - } - else { - // negative value -> complex value computation - return log(new type.Complex(x, 0)); - } - } - - return log; - } - - exports.name = 'log'; - exports.factory = factory; - - -/***/ }, -/* 45 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the 10-base of a value. This is the same as calculating `log(x, 10)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.log10(x) - * - * Examples: - * - * math.log10(0.00001); // returns -5 - * math.log10(10000); // returns 4 - * math.log(10000) / math.log(10); // returns 4 - * math.pow(10, 4); // returns 10000 - * - * See also: - * - * exp, log - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * Value for which to calculate the logarithm. - * @return {Number | BigNumber | Complex | Array | Matrix} - * Returns the 10-base logarithm of `x` - */ - var log10 = typed('log10', { - 'number': function (x) { - if (x >= 0) { - return Math.log(x) / Math.LN10; - } - else { - // negative value -> complex value computation - return log10(new type.Complex(x, 0)); - } - }, - - 'Complex': _log10Complex, - - 'BigNumber': function (x) { - if (x.isNegative()) { - // downgrade to number, return Complex valued result - return _log10Complex(new type.Complex(x.toNumber(), 0)); - } - else { - return x.log(); - } - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, log10); - } - }); - - return log10; - - /** - * Calculate log10 for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _log10Complex(x) { - return new type.Complex ( - Math.log(Math.sqrt(x.re * x.re + x.im * x.im)) / Math.LN10, - Math.atan2(x.im, x.re) / Math.LN10 - ); - } - } - - exports.name = 'log10'; - exports.factory = factory; - - - -/***/ }, -/* 46 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculates the modulus, the remainder of an integer division. - * - * For matrices, the function is evaluated element wise. - * - * The modulus is defined as: - * - * x - y * floor(x / y) - * - * See http://en.wikipedia.org/wiki/Modulo_operation. - * - * Syntax: - * - * math.mod(x, y) - * - * Examples: - * - * math.mod(8, 3); // returns 2 - * math.mod(11, 2); // returns 1 - * - * function isOdd(x) { - * return math.mod(x, 2) != 0; - * } - * - * isOdd(2); // returns false - * isOdd(3); // returns true - * - * See also: - * - * divide - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Dividend - * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Divisor - * @return {Number | BigNumber | Array | Matrix} Returns the remainder of `x` divided by `y`. - */ - var mod = typed('mod', { - 'number, number': _mod, - - 'BigNumber, BigNumber': function (x, y) { - return y.isZero() ? x : x.mod(y); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, mod); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, mod); - } - }); - - return mod; - - /** - * Calculate the modulus of two numbers - * @param {Number} x - * @param {Number} y - * @returns {number} res - * @private - */ - function _mod(x, y) { - if (y > 0) { - // We don't use JavaScript's % operator here as this doesn't work - // correctly for x < 0 and x == 0 - // see http://en.wikipedia.org/wiki/Modulo_operation - return x - y * Math.floor(x / y); - } - else if (y === 0) { - return x; - } - else { // y < 0 - // TODO: implement mod for a negative divisor - throw new Error('Cannot calculate mod for a negative divisor'); - } - } - } - - exports.name = 'mod'; - exports.factory = factory; - - -/***/ }, -/* 47 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - - var array = util.array; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var addScalar = load(__webpack_require__(211)); - var multiplyScalar = load(__webpack_require__(212)); - var equal = load(__webpack_require__(115)); - - var collection = load(__webpack_require__(2)); - - var DenseMatrix = type.DenseMatrix; - var SparseMatrix = type.SparseMatrix; - - /** - * Multiply two values, `x * y`. The result is squeezed. - * For matrices, the matrix product is calculated. - * - * Syntax: - * - * math.multiply(x, y) - * - * Examples: - * - * math.multiply(4, 5.2); // returns Number 20.8 - * - * var a = math.complex(2, 3); - * var b = math.complex(4, 1); - * math.multiply(a, b); // returns Complex 5 + 14i - * - * var c = [[1, 2], [4, 3]]; - * var d = [[1, 2, 3], [3, -4, 7]]; - * math.multiply(c, d); // returns Array [[7, -6, 17], [13, -4, 33]] - * - * var e = math.unit('2.1 km'); - * math.multiply(3, e); // returns Unit 6.3 km - * - * See also: - * - * divide - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to multiply - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to multiply - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` - */ - var multiply = typed('multiply', { - - 'any, any': multiplyScalar, - - 'Array, Array': function (x, y) { - // check dimensions - _validateMatrixDimensions(array.size(x), array.size(y)); - - // use dense matrix implementation - var m = multiply(matrix(x), matrix(y)); - // return array or scalar - return m instanceof type.Matrix ? m.valueOf() : m; - }, - - 'Matrix, Matrix': function (x, y) { - // dimensions - var xsize = x.size(); - var ysize = y.size(); - - // check dimensions - _validateMatrixDimensions(xsize, ysize); - - // process dimensions - if (xsize.length === 1) { - // process y dimensions - if (ysize.length === 1) { - // Vector * Vector - return _multiplyVectorVector(x, y, xsize[0]); - } - // Vector * Matrix - return _multiplyVectorMatrix(x, y); - } - // process y dimensions - if (ysize.length === 1) { - // Matrix * Vector - return _multiplyMatrixVector(x, y); - } - // Matrix * Matrix - return _multiplyMatrixMatrix(x, y); - }, - - 'Matrix, Array': function (x, y) { - // use Matrix * Matrix implementation - return multiply(x, matrix(y)); - }, - - 'Array, Matrix': function (x, y) { - // use Matrix * Matrix implementation - return multiply(matrix(x, y.storage()), y); - }, - - 'Array, any': function (x, y) { - return collection.deepMap2(x, y, multiply); - }, - - 'Matrix, any': function (x, y) { - // use matrix map, skip zeros since 0 * X = 0 - return x.map(function (v) { - return multiply(v, y); - }, true); - }, - - 'any, Array | Matrix': function (x, y) { - // use matrix map, skip zeros since 0 * X = 0 - return y.map(function (v) { - return multiply(v, x); - }, true); - } - }); - - var _validateMatrixDimensions = function (size1, size2) { - // check left operand dimensions - switch (size1.length) { - case 1: - // check size2 - switch (size2.length) { - case 1: - // Vector x Vector - if (size1[0] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Vectors must have the same length'); - } - break; - case 2: - // Vector x Matrix - if (size1[0] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Vector length (' + size1[0] + ') must match Matrix rows (' + size2[0] + ')'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); - } - break; - case 2: - // check size2 - switch (size2.length) { - case 1: - // Matrix x Vector - if (size1[1] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Matrix columns (' + size1[1] + ') must match Vector length (' + size2[0] + ')'); - } - break; - case 2: - // Matrix x Matrix - if (size1[1] !== size2[0]) { - // throw error - throw new RangeError('Dimension mismatch in multiplication. Matrix A columns (' + size1[1] + ') must match Matrix B rows (' + size2[0] + ')'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); - } - break; - default: - throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix A has ' + size1.length + ' dimensions)'); - } - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (N) - * @param {Matrix} b Dense Vector (N) - * - * @return {Number} Scalar value - */ - var _multiplyVectorVector = function (a, b, n) { - // check empty vector - if (n === 0) - throw new Error('Cannot multiply two empty vectors'); - - // a dense - var adata = a._data; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bdt = b._datatype; - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // result (do not initialize it with zero) - var c = mf(adata[0], bdata[0]); - // loop data - for (var i = 1; i < n; i++) { - // multiply and accumulate - c = af(c, mf(adata[i], bdata[i])); - } - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (M) - * @param {Matrix} b Matrix (MxN) - * - * @return {Matrix} Dense Vector (N) - */ - var _multiplyVectorMatrix = function (a, b) { - // process storage - switch (b.storage()) { - case 'dense': - return _multiplyVectorDenseMatrix(a, b); - } - throw new Error('Not implemented'); - }; - - /** - * C = A * B - * - * @param {Matrix} a Dense Vector (M) - * @param {Matrix} b Dense Matrix (MxN) - * - * @return {Matrix} Dense Vector (N) - */ - var _multiplyVectorDenseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bsize = b._size; - var bdt = b._datatype; - // rows & columns - var alength = asize[0]; - var bcolumns = bsize[1]; - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // result - var c = new Array(bcolumns); - - // loop matrix columns - for (var j = 0; j < bcolumns; j++) { - // sum (do not initialize it with zero) - var sum = mf(adata[0], bdata[0][j]); - // loop vector - for (var i = 1; i < alength; i++) { - // multiply & accumulate - sum = af(sum, mf(adata[i], bdata[i][j])); - } - c[j] = sum; - } - - // check we need to squeeze the result into a scalar - if (bcolumns === 1) - return c[0]; - - // return matrix - return new DenseMatrix({ - data: c, - size: [bcolumns], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a Matrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} Dense Vector (M) - */ - var _multiplyMatrixVector = function (a, b) { - // process storage - switch (a.storage()) { - case 'dense': - return _multiplyDenseMatrixVector(a, b); - case 'sparse': - return _multiplySparseMatrixVector(a, b); - } - }; - - /** - * C = A * B - * - * @param {Matrix} a Matrix (MxN) - * @param {Matrix} b Matrix (NxC) - * - * @return {Matrix} Matrix (MxC) - */ - var _multiplyMatrixMatrix = function (a, b) { - // process storage - switch (a.storage()) { - case 'dense': - // process storage - switch (b.storage()) { - case 'dense': - return _multiplyDenseMatrixDenseMatrix(a, b); - case 'sparse': - return _multiplyDenseMatrixSparseMatrix(a, b); - } - break; - case 'sparse': - // process storage - switch (b.storage()) { - case 'dense': - return _multiplySparseMatrixDenseMatrix(a, b); - case 'sparse': - return _multiplySparseMatrixSparseMatrix(a, b); - } - break; - } - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} Dense Vector (M) - */ - var _multiplyDenseMatrixVector = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = asize[0]; - var acolumns = asize[1]; - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // result - var c = new Array(arows); - - // loop matrix a rows - for (var i = 0; i < arows; i++) { - // current row - var row = adata[i]; - // sum (do not initialize it with zero) - var sum = mf(row[0], bdata[0]); - // loop matrix a columns - for (var j = 1; j < acolumns; j++) { - // multiply & accumulate - sum = af(sum, mf(row[j], bdata[j])); - } - c[i] = sum; - } - // check we need to squeeze the result into a scalar - if (arows === 1) - return c[0]; - - // return matrix - return new DenseMatrix({ - data: c, - size: [arows], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b DenseMatrix (NxC) - * - * @return {Matrix} DenseMatrix (MxC) - */ - var _multiplyDenseMatrixDenseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b dense - var bdata = b._data; - var bsize = b._size; - var bdt = b._datatype; - // rows & columns - var arows = asize[0]; - var acolumns = asize[1]; - var bcolumns = bsize[1]; - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // result - var c = new Array(arows); - - // loop matrix a rows - for (var i = 0; i < arows; i++) { - // current row - var row = adata[i]; - // initialize row array - c[i] = new Array(bcolumns); - // loop matrix b columns - for (var j = 0; j < bcolumns; j++) { - // sum (avoid initializing sum to zero) - var sum = mf(row[0], bdata[0][j]); - // loop matrix a columns - for (var x = 1; x < acolumns; x++) { - // multiply & accumulate - sum = af(sum, mf(row[x], bdata[x][j])); - } - c[i][j] = sum; - } - } - // check we need to squeeze the result into a scalar - if (arows === 1 && bcolumns === 1) - return c[0][0]; - - // return matrix - return new DenseMatrix({ - data: c, - size: [arows, bcolumns], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b SparseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplyDenseMatrixSparseMatrix = function (a, b) { - // a dense - var adata = a._data; - var asize = a._size; - var adt = a._datatype; - // b sparse - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bsize = b._size; - var bdt = b._datatype; - // validate b matrix - if (!bvalues) - throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix'); - // rows & columns - var arows = asize[0]; - var bcolumns = bsize[1]; - // result - var cvalues = []; - var cindex = []; - var cptr = new Array(bcolumns + 1); - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // indeces in column jb - var kb0 = bptr[jb]; - var kb1 = bptr[jb + 1]; - // do not process column jb if no data exists - if (kb1 > kb0) { - // last row mark processed - var last = 0; - // loop a rows - for (var i = 0; i < arows; i++) { - // column mark - var mark = i + 1; - // C[i, jb] - var cij; - // values in b column j - for (var kb = kb0; kb < kb1; kb++) { - // row - var ib = bindex[kb]; - // check value has been initialized - if (last !== mark) { - // first value in column jb - cij = mf(adata[i][ib], bvalues[kb]); - // update mark - last = mark; - } - else { - // accumulate value - cij = af(cij, mf(adata[i][ib], bvalues[kb])); - } - } - // check column has been processed and value != 0 - if (last === mark && !equal(cij, 0)) { - // push row & value - cindex.push(i); - cvalues.push(cij); - } - } - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // check we need to squeeze the result into a scalar - if (arows === 1 && bcolumns === 1) - return cvalues.length === 1 ? cvalues[0] : 0; - - // return sparse matrix - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b Dense Vector (N) - * - * @return {Matrix} SparseMatrix (M, 1) - */ - var _multiplySparseMatrixVector = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // validate a matrix - if (!avalues) - throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = a._size[0]; - var brows = b._size[0]; - // result - var cvalues = []; - var cindex = []; - var cptr = new Array(2); - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // workspace - var x = new Array(arows); - // vector with marks indicating a value x[i] exists in a given column - var w = new Array(arows); - - // update ptr - cptr[0] = 0; - // rows in b - for (var ib = 0; ib < brows; ib++) { - // b[ib] - var vbi = bdata[ib]; - // check b[ib] != 0, avoid loops - if (!equal(vbi, 0)) { - // A values & index in ib column - for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // a row - var ia = aindex[ka]; - // check value exists in current j - if (!w[ia]) { - // ia is new entry in j - w[ia] = true; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(vbi, avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(vbi, avalues[ka])); - } - } - } - } - // copy values from x to column jb of c - for (var p1 = cindex.length, p = 0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - // update ptr - cptr[1] = cindex.length; - - // check we need to squeeze the result into a scalar - if (arows === 1) - return cvalues.length === 1 ? cvalues[0] : 0; - - // return sparse matrix - return new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, 1], - datatype: dt - }); - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b DenseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplySparseMatrixDenseMatrix = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // validate a matrix - if (!avalues) - throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); - // b dense - var bdata = b._data; - var bdt = b._datatype; - // rows & columns - var arows = a._size[0]; - var brows = b._size[0]; - var bcolumns = b._size[1]; - - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - - // result - var cvalues = []; - var cindex = []; - var cptr = new Array(bcolumns + 1); - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - // workspace - var x = new Array(arows); - // vector with marks indicating a value x[i] exists in a given column - var w = new Array(arows); - - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // mark in workspace for current column - var mark = jb + 1; - // rows in jb - for (var ib = 0; ib < brows; ib++) { - // b[ib, jb] - var vbij = bdata[ib][jb]; - // check b[ib, jb] != 0, avoid loops - if (!equal(vbij, 0)) { - // A values & index in ib column - for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // a row - var ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(vbij, avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(vbij, avalues[ka])); - } - } - } - } - // copy values from x to column jb of c - for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // check we need to squeeze the result into a scalar - if (arows === 1 && bcolumns === 1) - return cvalues.length === 1 ? cvalues[0] : 0; - - // return sparse matrix - return c; - }; - - /** - * C = A * B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b SparseMatrix (NxC) - * - * @return {Matrix} SparseMatrix (MxC) - */ - var _multiplySparseMatrixSparseMatrix = function (a, b) { - // a sparse - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - var adt = a._datatype; - // b sparse - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - var bdt = b._datatype; - // process data types - var dt = adt && bdt && adt === bdt ? adt : undefined; - // multiply & add scalar implementations - var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; - var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; - // rows & columns - var arows = a._size[0]; - var bcolumns = b._size[1]; - // flag indicating both matrices (a & b) contain data - var values = avalues && bvalues; - // result - var cvalues = values ? [] : undefined; - var cindex = []; - var cptr = new Array(bcolumns + 1); - // c matrix - var c = new SparseMatrix({ - values : cvalues, - index: cindex, - ptr: cptr, - size: [arows, bcolumns], - datatype: dt - }); - // workspace - var x = values ? new Array(arows) : undefined; - // vector with marks indicating a value x[i] exists in a given column - var w = new Array(arows); - // variables - var ka, ka0, ka1, kb, kb0, kb1, ia, ib; - // loop b columns - for (var jb = 0; jb < bcolumns; jb++) { - // update ptr - cptr[jb] = cindex.length; - // mark in workspace for current column - var mark = jb + 1; - // B values & index in j - for (kb0 = bptr[jb], kb1 = bptr[jb + 1], kb = kb0; kb < kb1; kb++) { - // b row - ib = bindex[kb]; - // check we need to process values - if (values) { - // loop values in a[:,ib] - for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // row - ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - // x(ia) = A - x[ia] = mf(bvalues[kb], avalues[ka]); - } - else { - // i exists in C already - x[ia] = af(x[ia], mf(bvalues[kb], avalues[ka])); - } - } - } - else { - // loop values in a[:,ib] - for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { - // row - ia = aindex[ka]; - // check value exists in current j - if (w[ia] !== mark) { - // ia is new entry in j - w[ia] = mark; - // add i to pattern of C - cindex.push(ia); - } - } - } - } - // check we need to process matrix values (pattern matrix) - if (values) { - // copy values from x to column jb of c - for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { - // row - var ic = cindex[p]; - // copy value - cvalues[p] = x[ic]; - } - } - } - // update ptr - cptr[bcolumns] = cindex.length; - - // check we need to squeeze the result into a scalar - if (arows === 1 && bcolumns === 1 && values) - return cvalues.length === 1 ? cvalues[0] : 0; - - // return sparse matrix - return c; - }; - - return multiply; - } - - exports.name = 'multiply'; - exports.factory = factory; - - -/***/ }, -/* 48 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var abs = load(__webpack_require__(31)); - var add = load(__webpack_require__(32)); - var pow = load(__webpack_require__(50)); - var sqrt = load(__webpack_require__(53)); - var multiply = load(__webpack_require__(47)); - var equal = load(__webpack_require__(115)); - var larger = load(__webpack_require__(116)); - var smaller = load(__webpack_require__(118)); - var matrix = load(__webpack_require__(75)); - var trace = load(__webpack_require__(103)); - var transpose = load(__webpack_require__(104)); - - var complexAbs = abs.signatures['Complex']; - - /** - * Calculate the norm of a number, vector or matrix. - * - * The second parameter p is optional. If not provided, it defaults to 2. - * - * Syntax: - * - * math.norm(x) - * math.norm(x, p) - * - * Examples: - * - * math.abs(-3.5); // returns 3.5 - * math.norm(-3.5); // returns 3.5 - * - * math.norm(math.complex(3, -4)); // returns 5 - * - * math.norm([1, 2, -3], Infinity); // returns 3 - * math.norm([1, 2, -3], -Infinity); // returns 1 - * - * math.norm([3, 4], 2); // returns 5 - * - * math.norm([[1, 2], [3, 4]], 1) // returns 6 - * math.norm([[1, 2], [3, 4]], 'inf'); // returns 7 - * math.norm([[1, 2], [3, 4]], 'fro'); // returns 5.477225575051661 - * - * See also: - * - * abs - * - * @param {Number | BigNumber | Complex | Boolean | Array | Matrix | null} x - * Value for which to calculate the norm - * @param {Number | BigNumber | String} [p=2] - * Vector space. - * Supported numbers include Infinity and -Infinity. - * Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) - * @return {Number | BigNumber} the p-norm - */ - var norm = typed('norm', { - 'number': Math.abs, - - 'Complex': complexAbs, - - 'BigNumber': function (x) { - // norm(x) = abs(x) - return x.abs(); - }, - - 'boolean | null' : function (x) { - // norm(x) = abs(x) - return Math.abs(x); - }, - - 'Array': function (x) { - return _norm(matrix(x), 2); - }, - - 'Matrix': function (x) { - return _norm(x, 2); - }, - - 'number | Complex | BigNumber | boolean | null, number | BigNumber | string': function (x) { - // ignore second parameter, TODO: remove the option of second parameter for these types - return norm(x); - }, - - 'Array, number | BigNumber | string': function (x, p) { - return _norm(matrix(x), p); - }, - - 'Matrix, number | BigNumber | string': function (x, p) { - return _norm(x, p); - } - }); - - /** - * Calculate the norm for an array - * @param {Array} x - * @param {number | string} p - * @returns {number} Returns the norm - * @private - */ - function _norm (x, p) { - // size - var sizeX = x.size(); - - // check if it is a vector - if (sizeX.length == 1) { - // check p - if (p === Number.POSITIVE_INFINITY || p === 'inf') { - // norm(x, Infinity) = max(abs(x)) - var pinf = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - var v = abs(value); - if (larger(v, pinf)) - pinf = v; - }, - true); - return pinf; - } - if (p === Number.NEGATIVE_INFINITY || p === '-inf') { - // norm(x, -Infinity) = min(abs(x)) - var ninf; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - var v = abs(value); - if (!ninf || smaller(v, ninf)) - ninf = v; - }, - true); - return ninf || 0; - } - if (p === 'fro') { - return _norm(x, 2); - } - if (typeof p === 'number' && !isNaN(p)) { - // check p != 0 - if (!equal(p, 0)) { - // norm(x, p) = sum(abs(xi) ^ p) ^ 1/p - var n = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value) { - n = add(pow(abs(value), p), n); - }, - true); - return pow(n, 1 / p); - } - return Number.POSITIVE_INFINITY; - } - // invalid parameter value - throw new Error('Unsupported parameter value'); - } - // MxN matrix - if (sizeX.length == 2) { - // check p - if (p === 1) { - // norm(x) = the largest column sum - var c = []; - // result - var maxc = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value, index) { - var j = index[1]; - var cj = add(c[j] || 0, abs(value)); - if (larger(cj, maxc)) - maxc = cj; - c[j] = cj; - }, - true); - return maxc; - } - if (p === Number.POSITIVE_INFINITY || p === 'inf') { - // norm(x) = the largest row sum - var r = []; - // result - var maxr = 0; - // skip zeros since abs(0) == 0 - x.forEach( - function (value, index) { - var i = index[0]; - var ri = add(r[i] || 0, abs(value)); - if (larger(ri, maxr)) - maxr = ri; - r[i] = ri; - }, - true); - return maxr; - } - if (p === 'fro') { - // norm(x) = sqrt(sum(diag(x'x))) - return sqrt(trace(multiply(transpose(x), x))); - } - if (p === 2) { - // not implemented - throw new Error('Unsupported parameter value, missing implementation of matrix singular value decomposition'); - } - // invalid parameter value - throw new Error('Unsupported parameter value'); - } - } - - return norm; - } - - exports.name = 'norm'; - exports.factory = factory; - - -/***/ }, -/* 49 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the nth root of a value. - * The principal nth root of a positive real number A, is the positive real - * solution of the equation - * - * x^root = A - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.nthRoot(a) - * math.nthRoot(a, root) - * - * Examples: - * - * math.nthRoot(9, 2); // returns 3, as 3^2 == 9 - * math.sqrt(9); // returns 3, as 3^2 == 9 - * math.nthRoot(64, 3); // returns 4, as 4^3 == 64 - * - * See also: - * - * sqrt, pow - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} a - * Value for which to calculate the nth root - * @param {Number | BigNumber | Boolean | null} [root=2] The root. - * @return {Number | Complex | Array | Matrix} Returns the nth root of `a` - */ - var nthRoot = typed('nthRoot', { - 'number': function (x) { - return _nthRoot(x, 2); - }, - 'number, number': _nthRoot, - - 'BigNumber': function (x) { - return _bigNthRoot(x, new type.BigNumber(2)); - }, - 'BigNumber, BigNumber': _bigNthRoot, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, nthRoot); - }, - - 'Array | Matrix, any': function (x, root) { - return collection.deepMap2(x, root, nthRoot); - }, - - 'any, Array | Matrix': function (x, root) { - return collection.deepMap2(x, root, nthRoot); - } - }); - - return nthRoot; - - /** - * Calculate the nth root of a for BigNumbers, solve x^root == a - * http://rosettacode.org/wiki/Nth_root#JavaScript - * @param {BigNumber} a - * @param {BigNumber} root - * @private - */ - function _bigNthRoot(a, root) { - var zero = new type.BigNumber(0); - var one = new type.BigNumber(1); - var inv = root.isNegative(); - if (inv) root = root.negated(); - - if (root.isZero()) throw new Error('Root must be non-zero'); - if (a.isNegative() && !root.abs().mod(2).equals(1)) throw new Error('Root must be odd when a is negative.'); - - // edge cases zero and infinity - if (a.isZero()) return zero; - if (!a.isFinite()) - { - return inv ? zero : a; - } - - var x = one; // Initial guess - var i = 0; - var iMax = 100; - do { - var xPrev = x; - var delta = a.div(x.pow(root.minus(1))).minus(x).div(root); - x = x.plus(delta); - i++; - } - while (!x.equals(xPrev) && i < iMax); - - return inv ? one.div(x) : x; - } - } - - /** - * Calculate the nth root of a, solve x^root == a - * http://rosettacode.org/wiki/Nth_root#JavaScript - * @param {number} a - * @param {number} root - * @private - */ - function _nthRoot(a, root) { - var inv = root < 0; - if (inv) root = -root; - - if (root === 0) throw new Error('Root must be non-zero'); - if (a < 0 && (Math.abs(root) % 2 != 1)) throw new Error('Root must be odd when a is negative.'); - - // edge cases zero and infinity - if (a == 0) return 0; - if (!Number.isFinite(a)) { - return inv ? 0 : a; - } - - var epsilon = 1e-16; - var x = 1; // Initial guess - var i = 0; - var iMax = 100; - do { - var delta = (a / Math.pow(x, root - 1) - x) / root; - x = x + delta; - i++; - } - while (Math.abs(delta) > epsilon && i < iMax); - - return inv ? 1 / x : x; - } - - exports.name = 'nthRoot'; - exports.factory = factory; - - -/***/ }, -/* 50 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var exp = load(__webpack_require__(39)); - var eye = load(__webpack_require__(94)); - var log = load(__webpack_require__(44)); - var multiply = load(__webpack_require__(47)); - var matrix = load(__webpack_require__(75)); - - /** - * Calculates the power of x to y, `x ^ y`. - * Matrix exponentiation is supported for square matrices `x`, and positive - * integer exponents `y`. - * - * Syntax: - * - * math.pow(x, y) - * - * Examples: - * - * math.pow(2, 3); // returns Number 8 - * - * var a = math.complex(2, 3); - * math.pow(a, 2) // returns Complex -5 + 12i - * - * var b = [[1, 2], [4, 3]]; - * math.pow(b, 2); // returns Array [[9, 8], [16, 17]] - * - * See also: - * - * multiply, sqrt - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x The base - * @param {Number | BigNumber | Boolean | Complex | null} y The exponent - * @return {Number | BigNumber | Complex | Array | Matrix} The value of `x` to the power `y` - */ - var pow = typed('pow', { - 'number, number': function (x, y) { - if (isInteger(y) || x >= 0) { - return Math.pow(x, y); - } - else { - return _powComplex(new type.Complex(x, 0), new type.Complex(y, 0)); - } - }, - - 'BigNumber, BigNumber': function (x, y) { - if (isInteger(y) || x >= 0) { - return x.pow(y); - } - else { - return _powComplex(new type.Complex(x.toNumber(), 0), new type.Complex(y.toNumber(), 0)); - } - }, - - 'Complex, Complex': _powComplex, - - 'Array, number': _powArray, - - 'Array, BigNumber': function (x, y) { - return _powArray(x, y.toNumber()); - }, - - 'Matrix, number': _powMatrix, - - 'Matrix, BigNumber': function (x, y) { - return _powMatrix(x, y.toNumber()); - } - }); - - /** - * Calculates the power of x to y, x^y, for two complex numbers. - * @param {Complex} x - * @param {Complex} y - * @return {Complex} res - * @private - */ - function _powComplex (x, y) { - // complex computation - // x^y = exp(log(x)*y) = exp((abs(x)+i*arg(x))*y) - // TODO: we can optimize this as we know x and y are Complex - // expComplex = exp.signatures['Complex,Complex'] - // multiplyComplex = multiply.signatures['Complex,Complex'] - // logComplex = log.signatures['Complex,Complex'] - // return expComplex(multiplyComplex(logComplex(x), y)); - return exp(multiply(log(x), y)); - } - - /** - * Calculate the power of a 2d array - * @param {Array} x must be a 2 dimensional, square matrix - * @param {number} y a positive, integer value - * @returns {Array} - * @private - */ - function _powArray(x, y) { - if (!isInteger(y) || y < 0) { - throw new TypeError('For A^b, b must be a positive integer (value is ' + y + ')'); - } - // verify that A is a 2 dimensional square matrix - var s = size(x); - if (s.length != 2) { - throw new Error('For A^b, A must be 2 dimensional (A has ' + s.length + ' dimensions)'); - } - if (s[0] != s[1]) { - throw new Error('For A^b, A must be square (size is ' + s[0] + 'x' + s[1] + ')'); - } - - var res = eye(s[0]).valueOf(); - var px = x; - while (y >= 1) { - if ((y & 1) == 1) { - res = multiply(px, res); - } - y >>= 1; - px = multiply(px, px); - } - return res; - } - - /** - * Calculate the power of a 2d matrix - * @param {Matrix} x must be a 2 dimensional, square matrix - * @param {number} y a positive, integer value - * @returns {Matrix} - * @private - */ - function _powMatrix (x, y) { - return matrix(_powArray(x.valueOf(), y)); - } - - return pow; - } - - exports.name = 'pow'; - exports.factory = factory; - - -/***/ }, -/* 51 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var toFixed = __webpack_require__(175).toFixed; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Round a value towards the nearest integer. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.round(x) - * math.round(x, n) - * - * Examples: - * - * math.round(3.2); // returns Number 3 - * math.round(3.8); // returns Number 4 - * math.round(-4.2); // returns Number -4 - * math.round(-4.7); // returns Number -5 - * math.round(math.pi, 3); // returns Number 3.142 - * math.round(123.45678, 2); // returns Number 123.46 - * - * var c = math.complex(3.2, -2.7); - * math.round(c); // returns Complex 3 - 3i - * - * math.round([3.2, 3.8, -4.7]); // returns Array [3, 4, -5] - * - * See also: - * - * ceil, fix, floor - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded - * @param {Number | BigNumber | Boolean | Array | null} [n=0] Number of decimals - * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value - */ - var round = typed('round', { - 'number': Math.round, - - 'number, number': function (x, n) { - if (!isInteger(n)) {throw new TypeError('Number of decimals in function round must be an integer');} - if (n < 0 || n > 15) {throw new Error('Number of decimals in function round must be in te range of 0-15');} - - return _round(x, n); - }, - - 'Complex': function (x) { - return new type.Complex ( - Math.round(x.re), - Math.round(x.im) - ); - }, - - 'Complex, number': function (x, n) { - return new type.Complex ( - _round(x.re, n), - _round(x.im, n) - ); - }, - - 'Complex, BigNumber': function (x, n) { - var _n = n.toNumber(); - return new type.Complex ( - _round(x.re, _n), - _round(x.im, _n) - ); - }, - - 'BigNumber': function (x) { - return x.toDecimalPlaces(0); - }, - - 'BigNumber, BigNumber': function (x, n) { - if (!n.isInteger()) {throw new TypeError('Number of decimals in function round must be an integer');} - - return x.toDecimalPlaces(n.toNumber()); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since round(0) = 0 - return collection.deepMap(x, round, true); - }, - - 'Array | Matrix, number | BigNumber': function (x, n) { - return collection.deepMap2(x, n, round); - }, - - 'number | Complex | BigNumber, Array | Matrix': function (x, n) { - return collection.deepMap2(x, n, round); - } - }); - - return round; - } - - /** - * round a number to the given number of decimals, or to zero if decimals is - * not provided - * @param {Number} value - * @param {Number} decimals number of decimals, between 0 and 15 (0 by default) - * @return {Number} roundedValue - * @private - */ - function _round (value, decimals) { - return parseFloat(toFixed(value, decimals)); - } - - exports.name = 'round'; - exports.factory = factory; - - -/***/ }, -/* 52 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(175); - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Compute the sign of a value. The sign of a value x is: - * - * - 1 when x > 1 - * - -1 when x < 0 - * - 0 when x == 0 - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sign(x) - * - * Examples: - * - * math.sign(3.5); // returns 1 - * math.sign(-4.2); // returns -1 - * math.sign(0); // returns 0 - * - * math.sign([3, 5, -2, 0, 2]); // returns [1, 1, -1, 0, 1] - * - * See also: - * - * abs - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * The number for which to determine the sign - * @return {Number | BigNumber | Complex | Array | Matrix}e - * The sign of `x` - */ - var sign = typed('sign', { - 'number': number.sign, - - 'Complex': function (x) { - var abs = Math.sqrt(x.re * x.re + x.im * x.im); - return new x.constructor(x.re / abs, x.im / abs); - }, - - 'BigNumber': function (x) { - return new x.constructor(x.cmp(0)); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sign(0) = 0 - return collection.deepMap(x, sign, true); - } - }); - - return sign; - } - - exports.name = 'sign'; - exports.factory = factory; - - - -/***/ }, -/* 53 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the square root of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sqrt(x) - * - * Examples: - * - * math.sqrt(25); // returns 5 - * math.square(5); // returns 25 - * math.sqrt(-4); // returns Complex -2i - * - * See also: - * - * square, multiply - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * Value for which to calculate the square root. - * @return {Number | BigNumber | Complex | Array | Matrix} - * Returns the square root of `x` - */ - var sqrt = typed('sqrt', { - 'number': _sqrtNumber, - - 'Complex': _sqrtComplex, - - 'BigNumber': function (x) { - if (x.isNegative()) { - // negative value -> downgrade to number to do complex value computation - return _sqrtNumber(x.toNumber()); - } - else { - return x.sqrt(); - } - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sqrt(0) = 0 - return collection.deepMap(x, sqrt, true); - } - }); - - /** - * Calculate sqrt for a number - * @param {Number} x - * @returns {Number | Complex} Returns the square root of x - * @private - */ - function _sqrtNumber(x) { - if (x >= 0) { - return Math.sqrt(x); - } - else { - return _sqrtComplex(new type.Complex(x, 0)); - } - } - - /** - * Calculate sqrt for a complex number - * @param {Complex} x - * @returns {Complex} Returns the square root of x - * @private - */ - function _sqrtComplex(x) { - var r = Math.sqrt(x.re * x.re + x.im * x.im); - - var re, im; - - if (x.re >= 0) { - re = 0.5 * Math.sqrt(2.0 * (r + x.re)); - } - else { - re = Math.abs(x.im) / Math.sqrt(2 * (r - x.re)); - } - - if (x.re <= 0) { - im = 0.5 * Math.sqrt(2.0 * (r - x.re)); - } - else { - im = Math.abs(x.im) / Math.sqrt(2 * (r + x.re)); - } - - if (x.im >= 0) { - return new type.Complex(re, im); - } - else { - return new type.Complex(re, -im); - } - } - - return sqrt; - } - - exports.name = 'sqrt'; - exports.factory = factory; - - -/***/ }, -/* 54 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Compute the square of a value, `x * x`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.square(x) - * - * Examples: - * - * math.square(2); // returns Number 4 - * math.square(3); // returns Number 9 - * math.pow(3, 2); // returns Number 9 - * math.multiply(3, 3); // returns Number 9 - * - * math.square([1, 2, 3, 4]); // returns Array [1, 4, 9, 16] - * - * See also: - * - * multiply, cube, sqrt, pow - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x - * Number for which to calculate the square - * @return {Number | BigNumber | Complex | Array | Matrix} - * Squared value - */ - var square = typed('square', { - 'number': function (x) { - return x * x; - }, - - 'Complex': function (x) { - return new x.constructor( - x.re * x.re - x.im * x.im, - x.re * x.im + x.im * x.re - ); - }, - - 'BigNumber': function (x) { - return x.times(x); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since square(0) = 0 - return collection.deepMap(x, square, true); - } - }); - - return square; - } - - exports.name = 'square'; - exports.factory = factory; - - -/***/ }, -/* 55 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(166).clone; - var DimensionError = __webpack_require__(174); - - function factory (type, config, load, typed) { - - var unaryMinus = load(__webpack_require__(56)); - var matrix = load(__webpack_require__(75)); - var equal = load(__webpack_require__(115)); - var sparseScatter = load(__webpack_require__(210)); - var addScalar = load(__webpack_require__(211)); - var multiplyScalar = load(__webpack_require__(212)); - - var collection = load(__webpack_require__(2)); - - var DenseMatrix = type.DenseMatrix, - SparseMatrix = type.SparseMatrix; - - /** - * Subtract two values, `x - y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.subtract(x, y) - * - * Examples: - * - * math.subtract(5.3, 2); // returns Number 3.3 - * - * var a = math.complex(2, 3); - * var b = math.complex(4, 1); - * math.subtract(a, b); // returns Complex -2 + 2i - * - * math.subtract([5, 7, 4], 4); // returns Array [1, 3, 0] - * - * var c = math.unit('2.1 km'); - * var d = math.unit('500m'); - * math.subtract(c, d); // returns Unit 1.6 km - * - * See also: - * - * add - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x - * Initial value - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y - * Value to subtract from `x` - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} - * Subtraction of `x` and `y` - */ - var subtract = typed('subtract', { - - 'number, number': function (x, y) { - return x - y; - }, - - 'Complex, Complex': function (x, y) { - return new type.Complex ( - x.re - y.re, - x.im - y.im - ); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.minus(y); - }, - - 'Unit, Unit': function (x, y) { - if (x.value == null) { - throw new Error('Parameter x contains a unit with undefined value'); - } - - if (y.value == null) { - throw new Error('Parameter y contains a unit with undefined value'); - } - - if (!x.equalBase(y)) { - throw new Error('Units do not match'); - } - - var res = x.clone(); - res.value -= y.value; - res.fixPrefix = false; - - return res; - }, - - 'Matrix, Matrix': function (x, y) { - // matrix sizes - var xsize = x.size(); - var ysize = y.size(); - - // check dimensions - if (xsize.length !== ysize.length) - throw new DimensionError(xsize.length, ysize.length); - - // result - var c; - - // process matrix storage - switch (x.storage()) { - case 'sparse': - switch (y.storage()) { - case 'sparse': - // sparse - sparse - c = _subtractSparseMatrixSparseMatrix(x, y, xsize, ysize); - break; - default: - c = _subtractSparseMatrixMatrix(x, y.valueOf(), xsize, ysize); - break; - } - break; - default: - switch (y.storage()) { - case 'sparse': - // sparse - sparse - c = _subtractMatrixSparseMatrix(x.valueOf(), y, xsize, ysize); - break; - default: - c = _subtractMatrixMatrix(x.valueOf(), y.valueOf(), x.storage()); - break; - } - break; - } - return c; - }, - - 'Array, Array': function (x, y) { - // use matrix implementation - return subtract(matrix(x), matrix(y)).valueOf(); - }, - - 'Array, Matrix': function (x, y) { - // use matrix implementation - return subtract(matrix(x), y); - }, - - 'Matrix, Array': function (x, y) { - // use matrix implementation - return subtract(x, matrix(y)); - }, - - 'Matrix, any': function (x, y) { - // result - var c; - // check storage format - switch (x.storage()) { - case 'sparse': - c = _subtractSparseMatrixScalar(x, y, x.size()); - break; - default: - c = collection.deepMap2(x, y, subtract); - break; - } - return c; - }, - - 'any, Matrix': function (x, y) { - // result - var c; - // check storage format - switch (y.storage()) { - case 'sparse': - c = _subtractScalarSparseMatrix(x, y, y.size()); - break; - default: - c = collection.deepMap2(x, y, subtract); - break; - } - return c; - }, - - 'Array, any': function (x, y) { - return collection.deepMap2(x, y, subtract); - }, - - 'any, Array': function (x, y) { - return collection.deepMap2(x, y, subtract); - } - }); - - /** - * C = A - B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Scalar} b Scalar value - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _subtractSparseMatrixScalar = function (a, b, asize) { - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - // check b is zero - if (!equal(b, 0)) { - // c arrays - var cvalues = []; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // loop columns - for (var j = 0; j < n; j++) { - // ptr for column j - cptr[j] = cindex.length; - // loop values for column j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // subtract values - var v = subtract(avalues[k], b); - // compare with zero - if (!equal(v, 0)) { - // push to c - cindex.push(aindex[k]); - cvalues.push(v); - } - } - } - // update ptr - cptr[n] = cindex.length; - // return matrix - return c; - } - // return clone - return a.clone(); - }; - - /** - * C = A - B - * - * @param {Scalar} a Scalar value - * @param {Matrix} b SparseMatrix (MxN) - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _subtractScalarSparseMatrix = function (a, b, asize) { - // rows and columns - var m = asize[0]; - var n = asize[1]; - // b arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - // check a is zero - if (!equal(a, 0)) { - // c arrays - var cvalues = []; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // loop columns - for (var j = 0; j < n; j++) { - // ptr for column j - cptr[j] = cindex.length; - // loop values for column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // subtract values - var v = subtract(a, bvalues[k]); - // compare with zero - if (!equal(v, 0)) { - // push to c - cindex.push(bindex[k]); - cvalues.push(v); - } - } - } - // update ptr - cptr[n] = cindex.length; - // return matrix - return c; - } - // return clone - return b.clone(); - }; - - /** - * C = A - B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b SparseMatrix (MxN) - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _subtractSparseMatrixSparseMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a arrays - var avalues = a._values; - // b arrays - var bvalues = b._values; - // flag indicating both matrices (a & b) contain data - var values = avalues && bvalues; - // c arrays - var cvalues = values ? [] : undefined; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // column vector (store matrix values) - var x = values ? new Array(m) : undefined; - // column vector to signal row values in column j - var w = new Array(m); - // loop columns - for (var j = 0; j < n; j++) { - // init ptr for j - cptr[j] = cindex.length; - // process column j of a and write it to x - sparseScatter(a, j, 1, w, x, j + 1, c, multiplyScalar, addScalar); - // process column j of b and write it to x (multiply value by negative one) - sparseScatter(b, j, -1, w, x, j + 1, c, multiplyScalar, addScalar); - // check matrix contains values (pattern matrix) - if (values) { - // loop column values in C - for (var p0 = cptr[j], p1 = cindex.length, p = p0; p < p1; p++) { - // copy x[i] to c[i, j] - cvalues.push(x[cindex[p]]); - } - } - } - // finish cptr - cptr[n] = cindex.length; - // return matrix - return c; - }; - - /** - * C = A - B - * - * @param {Matrix} a SparseMatrix (MxN) - * @param {Matrix} b DenseMatrix (MxN) - * - * @return {Matrix} SparseMatrix (MxN) - */ - var _subtractSparseMatrixMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // b array - var data = b; - // c arrays - var cvalues = []; - var cindex = []; - var cptr = new Array(n); - // c matrix - var c = new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [m, n] - }); - // column vector (store matrix values) - var x = new Array(m); - // column vector to signal row values in column j - var w = new Array(m); - // loop columns - for (var j = 0; j < n; j++) { - // init ptr for j - cptr[j] = cindex.length; - // copy matrix b column to x - for (var i = 0; i < m; i++) { - // -value - var v = unaryMinus(data[i][j]); - // check for zero - if (!equal(v, 0)) { - x[i] = v; - w[i] = j + 1; - cindex.push(i); - } - } - // process column j of a and write it to x - sparseScatter(a, j, 1, w, x, j + 1, c, multiplyScalar, addScalar); - // loop column values in C - for (var p0 = cptr[j], p1 = cindex.length, p = p0; p < p1; p++) { - // copy x[i] to c[i, j] - cvalues.push(x[cindex[p]]); - } - } - // finish cptr - cptr[n] = cindex.length; - // return matrix - return c; - }; - - /** - * C = A - B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b SparseMatrix (MxN) - * - * @return {Matrix} DenseMatrix (MxN) - */ - var _subtractMatrixSparseMatrix = function (a, b, asize, bsize) { - // check dimensions - if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) - throw new RangeError('Dimension mismatch in add. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); - // rows and columns - var m = asize[0]; - var n = asize[1]; - // a array - var data = a; - // b arrays - var bvalues = b._values; - var bindex = b._index; - var bptr = b._ptr; - // c arrays - var cdata = clone(data); - // c matrix - var c = new DenseMatrix({ - data: cdata, - size: [m, n] - }); - // loop columns - for (var j = 0; j < n; j++) { - // loop values for column j - for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { - // row - var i = bindex[k]; - // subtract value - cdata[i][j] = subtract(cdata[i][j], bvalues[k]); - } - } - // return matrix - return c; - }; - - /** - * C = A - B - * - * @param {Matrix} a DenseMatrix (MxN) - * @param {Matrix} b DenseMatrix (MxN) - * - * @return {Matrix} DenseMatrix (MxN) - */ - var _subtractMatrixMatrix = function (a, b, format) { - // TODO: find a better implementation - return matrix(collection.deepMap2(a, b, subtract), format); - }; - - return subtract; - } - - exports.name = 'subtract'; - exports.factory = factory; - - -/***/ }, -/* 56 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Inverse the sign of a value, apply a unary minus operation. - * - * For matrices, the function is evaluated element wise. Boolean values and - * strings will be converted to a number. For complex numbers, both real and - * complex value are inverted. - * - * Syntax: - * - * math.unaryMinus(x) - * - * Examples: - * - * math.unaryMinus(3.5); // returns -3.5 - * math.unaryMinus(-4.2); // returns 4.2 - * - * See also: - * - * add, subtract, unaryPlus - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Number to be inverted. - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Returns the value with inverted sign. - */ - var unaryMinus = typed('unaryMinus', { - 'number': function (x) { - return -x; - }, - - 'Complex': function (x) { - return new x.constructor(-x.re, -x.im); - }, - - 'BigNumber': function (x) { - return x.neg(); - }, - - 'Unit': function (x) { - var res = x.clone(); - res.value = -x.value; - return res; - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since unaryMinus(0) = 0 - return collection.deepMap(x, unaryMinus, true); - } - - // TODO: add support for string - }); - - return unaryMinus; - } - - exports.name = 'unaryMinus'; - exports.factory = factory; - - -/***/ }, -/* 57 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Unary plus operation. - * Boolean values and strings will be converted to a number, numeric values will be returned as is. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.unaryPlus(x) - * - * Examples: - * - * math.unaryPlus(3.5); // returns 3.5 - * math.unaryPlus(1); // returns 1 - * - * See also: - * - * unaryMinus, add, subtract - * - * @param {Number | BigNumber | Boolean | String | Complex | Unit | Array | Matrix | null} x - * Input value - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} - * Returns the input value when numeric, converts to a number when input is non-numeric. - */ - var unaryPlus = typed('unaryPlus', { - 'number': function (x) { - return x; - }, - - 'Complex': function (x) { - return x.clone(); - }, - - 'BigNumber': function (x) { - return x; - }, - - 'Unit': function (x) { - return x.clone(); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since unaryPlus(0) = 0 - return collection.deepMap(x, unaryPlus, true); - }, - - 'boolean | string | null': function (x) { - // convert to a number or bignumber - return (config.number == 'bignumber') ? new type.BigNumber(+x): +x; - } - }); - - return unaryPlus; - } - - exports.name = 'unaryPlus'; - exports.factory = factory; - - -/***/ }, -/* 58 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var matrix = load(__webpack_require__(75)); - - /** - * Calculate the extended greatest common divisor for two values. - * See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm. - * - * Syntax: - * - * math.xgcd(a, b) - * - * Examples: - * - * math.xgcd(8, 12); // returns [4, -1, 1] - * math.gcd(8, 12); // returns 4 - * math.xgcd(36163, 21199); // returns [1247, -7, 12] - * - * See also: - * - * gcd, lcm - * - * @param {Number | BigNumber | Boolean} a An integer number - * @param {Number | BigNumber | Boolean} b An integer number - * @return {Array} Returns an array containing 3 integers `[div, m, n]` - * where `div = gcd(a, b)` and `a*m + b*n = div` - */ - return typed('xgcd', { - 'number, number': _xgcd, - 'BigNumber, BigNumber': _xgcdBigNumber - }); - - /** - * Calculate xgcd for two numbers - * @param {Number} a - * @param {Number} b - * @return {Number} result - * @private - */ - function _xgcd (a, b) { - // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm - var t, // used to swap two variables - q, // quotient - r, // remainder - x = 0, lastx = 1, - y = 1, lasty = 0; - - if (!isInteger(a) || !isInteger(b)) { - throw new Error('Parameters in function xgcd must be integer numbers'); - } - - while (b) { - q = Math.floor(a / b); - r = a % b; - - t = x; - x = lastx - q * x; - lastx = t; - - t = y; - y = lasty - q * y; - lasty = t; - - a = b; - b = r; - } - - var res; - if (a < 0) { - res = [-a, -lastx, -lasty]; - } - else { - res = [a, a ? lastx : 0, lasty]; - } - return (config.matrix === 'array') ? res : matrix(res); - } - - /** - * Calculate xgcd for two BigNumbers - * @param {BigNumber} a - * @param {BigNumber} b - * @return {BigNumber[]} result - * @private - */ - function _xgcdBigNumber(a, b) { - // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm - var t, // used to swap two variables - q, // quotient - r, // remainder - zero = new type.BigNumber(0), - x = new type.BigNumber(0), lastx = new type.BigNumber(1), - y = new type.BigNumber(1), lasty = new type.BigNumber(0); - - if (!a.isInt() || !b.isInt()) { - throw new Error('Parameters in function xgcd must be integer numbers'); - } - - while (!b.isZero()) { - q = a.div(b).floor(); - r = a.mod(b); - - t = x; - x = lastx.minus(q.times(x)); - lastx = t; - - t = y; - y = lasty.minus(q.times(y)); - lasty = t; - - a = b; - b = r; - } - - var res; - if (a.lt(zero)) { - res = [a.neg(), lastx.neg(), lasty.neg()]; - } - else { - res = [a, !a.isZero() ? lastx : 0, lasty]; - } - return (config.matrix === 'array') ? res : matrix(res); - } - } - - exports.name = 'xgcd'; - exports.factory = factory; - -/***/ }, -/* 59 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigBitAnd = __webpack_require__(214).and; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise AND two values, `x & y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.bitAnd(x, y) - * - * Examples: - * - * math.bitAnd(53, 131); // returns Number 1 - * - * math.bitAnd([1, 12, 31], 42); // returns Array [0, 8, 10] - * - * See also: - * - * bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to and - * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to and - * @return {Number | BigNumber | Array | Matrix} AND of `x` and `y` - */ - var bitAnd = typed('bitAnd', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitAnd'); - } - - return x & y; - }, - - 'BigNumber, BigNumber': bigBitAnd, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, bitAnd); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, bitAnd); - } - }); - - return bitAnd; - } - - exports.name = 'bitAnd'; - exports.factory = factory; - - -/***/ }, -/* 60 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigBitNot = __webpack_require__(214).not; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise NOT value, `~x`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.bitNot(x) - * - * Examples: - * - * math.bitNot(1); // returns Number -2 - * - * math.bitNot([2, -3, 4]); // returns Array [-3, 2, 5] - * - * See also: - * - * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to not - * @return {Number | BigNumber | Array | Matrix} NOT of `x` - */ - var bitNot = typed('bitNot', { - 'number': function (x) { - if (!isInteger(x)) { - throw new Error('Integer expected in function bitNot'); - } - - return ~x; - }, - - 'BigNumber': bigBitNot, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, bitNot); - } - }); - - return bitNot; - } - - exports.name = 'bitNot'; - exports.factory = factory; - - -/***/ }, -/* 61 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigBitOr = __webpack_require__(214).or; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise OR two values, `x | y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the lowest print base. - * - * Syntax: - * - * math.bitOr(x, y) - * - * Examples: - * - * math.bitOr(1, 2); // returns Number 3 - * - * math.bitOr([1, 2, 3], 4); // returns Array [5, 6, 7] - * - * See also: - * - * bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to or - * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to or - * @return {Number | BigNumber | Array | Matrix} OR of `x` and `y` - */ - var bitOr = typed('bitOr', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitOr'); - } - - return x | y; - }, - - 'BigNumber, BigNumber': bigBitOr, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, bitOr); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, bitOr); - } - }); - - return bitOr; - } - - exports.name = 'bitOr'; - exports.factory = factory; - - -/***/ }, -/* 62 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigBitXor = __webpack_require__(214).xor; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise XOR two values, `x ^ y`. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.bitXor(x, y) - * - * Examples: - * - * math.bitXor(1, 2); // returns Number 3 - * - * math.bitXor([2, 3, 4], 4); // returns Array [6, 7, 0] - * - * See also: - * - * bitAnd, bitNot, bitOr, leftShift, rightArithShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to xor - * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to xor - * @return {Number | BigNumber | Array | Matrix} XOR of `x` and `y` - */ - var bitXor = typed('bitXor', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function bitXor'); - } - - return x ^ y; - }, - - 'BigNumber, BigNumber': bigBitXor, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, bitXor); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, bitXor); - } - }); - - return bitXor; - } - - exports.name = 'bitXor'; - exports.factory = factory; - - -/***/ }, -/* 63 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigLeftShift = __webpack_require__(214).leftShift; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise left logical shift of a value x by y number of bits, `x << y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.leftShift(x, y) - * - * Examples: - * - * math.leftShift(1, 2); // returns Number 4 - * - * math.leftShift([1, 2, 3], 4); // returns Array [16, 32, 64] - * - * See also: - * - * bitAnd, bitNot, bitOr, bitXor, rightArithShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to be shifted - * @param {Number | BigNumber | Boolean | null} y Amount of shifts - * @return {Number | BigNumber | Array | Matrix} `x` shifted left `y` times - */ - var leftShift = typed('leftShift', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function leftShift'); - } - - return x << y; - }, - - 'BigNumber, BigNumber': bigLeftShift, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, leftShift); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, leftShift); - } - }); - - return leftShift; - } - - exports.name = 'leftShift'; - exports.factory = factory; - - -/***/ }, -/* 64 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - var bigRightArithShift = __webpack_require__(214).rightArithShift; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.rightArithShift(x, y) - * - * Examples: - * - * math.rightArithShift(4, 2); // returns Number 1 - * - * math.rightArithShift([16, -32, 64], 4); // returns Array [1, -2, 3] - * - * See also: - * - * bitAnd, bitNot, bitOr, bitXor, leftShift, rightLogShift - * - * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to be shifted - * @param {Number | BigNumber | Boolean | null} y Amount of shifts - * @return {Number | BigNumber | Array | Matrix} `x` sign-filled shifted right `y` times - */ - var rightArithShift = typed('rightArithShift', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function rightArithShift'); - } - - return x >> y; - }, - - 'BigNumber, BigNumber': bigRightArithShift, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, rightArithShift); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, rightArithShift); - } - }); - - return rightArithShift; - } - - exports.name = 'rightArithShift'; - exports.factory = factory; - - -/***/ }, -/* 65 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Bitwise right logical shift of value x by y number of bits, `x >>> y`. - * For matrices, the function is evaluated element wise. - * For units, the function is evaluated on the best prefix base. - * - * Syntax: - * - * math.rightLogShift(x, y) - * - * Examples: - * - * math.rightLogShift(4, 2); // returns Number 1 - * - * math.rightLogShift([16, -32, 64], 4); // returns Array [1, 2, 3] - * - * See also: - * - * bitAnd, bitNot, bitOr, bitXor, leftShift, rightArithShift - * - * @param {Number | Boolean | Array | Matrix | null} x Value to be shifted - * @param {Number | Boolean | null} y Amount of shifts - * @return {Number | Array | Matrix} `x` zero-filled shifted right `y` times - */ - - var rightLogShift = typed('rightLogShift', { - 'number, number': function (x, y) { - if (!isInteger(x) || !isInteger(y)) { - throw new Error('Integers expected in function rightLogShift'); - } - - return x >>> y; - }, - - // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, rightLogShift); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, rightLogShift); - } - }); - - return rightLogShift; - } - - exports.name = 'rightLogShift'; - exports.factory = factory; - - -/***/ }, -/* 66 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Compute the argument of a complex value. - * For a complex number `a + bi`, the argument is computed as `atan2(b, a)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.arg(x) - * - * Examples: - * - * var a = math.complex(2, 2); - * math.arg(a) / math.pi; // returns Number 0.25 - * - * var b = math.complex('2 + 3i'); - * math.arg(b); // returns Number 0.982793723247329 - * math.atan2(3, 2); // returns Number 0.982793723247329 - * - * See also: - * - * re, im, conj, abs - * - * @param {Number | Complex | Array | Matrix | Boolean | null} x - * A complex number or array with complex numbers - * @return {Number | Array | Matrix} The argument of x - */ - var arg = typed('arg', { - 'number': function (x) { - return Math.atan2(0, x); - }, - - // FIXME: must arg(Complex return a complex or a number? - 'Complex': function (x) { - return Math.atan2(x.im, x.re); - }, - - // TODO: implement BigNumber support for function arg - - 'Array | Matrix': function (x) { - return collection.deepMap(x, arg); - } - }); - - return arg; - } - - exports.name = 'arg'; - exports.factory = factory; - - -/***/ }, -/* 67 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Compute the complex conjugate of a complex value. - * If `x = a+bi`, the complex conjugate of `x` is `a - bi`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.conj(x) - * - * Examples: - * - * math.conj(math.complex('2 + 3i')); // returns Complex 2 - 3i - * math.conj(math.complex('2 - 3i')); // returns Complex 2 + 3i - * math.conj(math.complex('-5.2i')); // returns Complex 5.2i - * - * See also: - * - * re, im, arg, abs - * - * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x - * A complex number or array with complex numbers - * @return {Number | BigNumber | Complex | Array | Matrix} - * The complex conjugate of x - */ - var conj = typed('conj', { - 'number': function (x) { - return x; - }, - - 'BigNumber': function (x) { - return x; - }, - - 'Complex': function (x) { - return new x.constructor(x.re, -x.im); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, conj); - } - }); - - return conj; - } - - exports.name = 'conj'; - exports.factory = factory; - - -/***/ }, -/* 68 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Get the real part of a complex number. - * For a complex number `a + bi`, the function returns `a`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.re(x) - * - * Examples: - * - * var a = math.complex(2, 3); - * math.re(a); // returns Number 2 - * math.im(a); // returns Number 3 - * - * math.re(math.complex('-5.2i')); // returns Number 0 - * math.re(math.complex(2.4)); // returns Number 2.4 - * - * See also: - * - * im, conj, abs, arg - * - * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x - * A complex number or array with complex numbers - * @return {Number | BigNumber | Array | Matrix} The real part of x - */ - var re = typed('re', { - 'number': function (x) { - return x; - }, - - 'BigNumber': function (x) { - return x; - }, - - 'Complex': function (x) { - return x.re; - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, re); - } - }); - - return re; - } - - exports.name = 're'; - exports.factory = factory; - - -/***/ }, -/* 69 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Get the imaginary part of a complex number. - * For a complex number `a + bi`, the function returns `b`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.im(x) - * - * Examples: - * - * var a = math.complex(2, 3); - * math.re(a); // returns Number 2 - * math.im(a); // returns Number 3 - * - * math.re(math.complex('-5.2i')); // returns Number -5.2 - * math.re(math.complex(2.4)); // returns Number 0 - * - * See also: - * - * re, conj, abs, arg - * - * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x - * A complex number or array with complex numbers - * @return {Number | BigNumber | Array | Matrix} The imaginary part of x - */ - var im = typed('im', { - 'number': function (x) { - return 0; - }, - - 'BigNumber': function (x) { - return new x.constructor(0); - }, - - 'Complex': function (x) { - return x.im; - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, im); - } - }); - - return im; - } - - exports.name = 'im'; - exports.factory = factory; - - -/***/ }, -/* 70 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a BigNumber, which can store numbers with arbitrary precision. - * When a matrix is provided, all elements will be converted to BigNumber. - * - * Syntax: - * - * math.bignumber(x) - * - * Examples: - * - * 0.1 + 0.2; // returns Number 0.30000000000000004 - * math.bignumber(0.1) + math.bignumber(0.2); // returns BigNumber 0.3 - * - * - * 7.2e500; // returns Number Infinity - * math.bignumber('7.2e500'); // returns BigNumber 7.2e500 - * - * See also: - * - * boolean, complex, index, matrix, string, unit - * - * @param {Number | String | Array | Matrix | Boolean | null} [value] Value for the big number, - * 0 by default. - * @returns {BigNumber} The created bignumber - */ - var bignumber = typed('bignumber', { - '': function () { - return new type.BigNumber(0); - }, - - 'number': function (x) { - // convert to string to prevent errors in case of >15 digits - return new type.BigNumber(x + ''); - }, - - 'string': function (x) { - return new type.BigNumber(x); - }, - - 'BigNumber': function (x) { - // we assume a BigNumber is immutable - return x; - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, bignumber); - } - }); - - return bignumber; - } - - exports.name = 'bignumber'; - exports.factory = factory; - - -/***/ }, -/* 71 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a boolean or convert a string or number to a boolean. - * In case of a number, `true` is returned for non-zero numbers, and `false` in - * case of zero. - * Strings can be `'true'` or `'false'`, or can contain a number. - * When value is a matrix, all elements will be converted to boolean. - * - * Syntax: - * - * math.boolean(x) - * - * Examples: - * - * math.boolean(0); // returns false - * math.boolean(1); // returns true - * math.boolean(-3); // returns true - * math.boolean('true'); // returns true - * math.boolean('false'); // returns false - * math.boolean([1, 0, 1, 1]); // returns [true, false, true, true] - * - * See also: - * - * bignumber, complex, index, matrix, string, unit - * - * @param {String | Number | Boolean | Array | Matrix | null} value A value of any type - * @return {Boolean | Array | Matrix} The boolean value - */ - var bool = typed('bool', { - '': function () { - return false; - }, - - 'boolean': function (x) { - return x; - }, - - 'number': function (x) { - return !!x; - }, - - 'BigNumber': function (x) { - return !x.isZero(); - }, - - 'string': function (x) { - // try case insensitive - var lcase = x.toLowerCase(); - if (lcase === 'true') { - return true; - } - else if (lcase === 'false') { - return false; - } - - // test whether value is a valid number - var num = Number(x); - if (x != '' && !isNaN(num)) { - return !!num; - } - - throw new Error('Cannot convert "' + x + '" to a boolean'); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, bool); - } - }); - - return bool; - } - - exports.name = 'boolean'; - exports.factory = factory; - - -/***/ }, -/* 72 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Wrap any value in a chain, allowing to perform chained operations on - * the value. - * - * All methods available in the math.js library can be called upon the chain, - * and then will be evaluated with the value itself as first argument. - * The chain can be closed by executing `chain.done()`, which returns - * the final value. - * - * The chain has a number of special functions: - * - * - `done()` Finalize the chain and return the chain's value. - * - `valueOf()` The same as `done()` - * - `toString()` Executes `math.format()` onto the chain's value, returning - * a string representation of the value. - * - * Syntax: - * - * math.chain(value) - * - * Examples: - * - * math.chain(3) - * .add(4) - * .subtract(2) - * .done(); // 5 - * - * math.chain( [[1, 2], [3, 4]] ) - * .subset(math.index(0, 0), 8) - * .multiply(3) - * .done(); // [[24, 6], [9, 12]] - * - * @param {*} [value] A value of any type on which to start a chained operation. - * @return {math.type.Chain} The created chain - */ - return typed('chain', { - '': function() { - return new type.Chain(); - }, - - 'any': function(value) { - return new type.Chain(value); - } - }); - } - - exports.name = 'chain'; - exports.factory = factory; - - -/***/ }, -/* 73 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a complex value or convert a value to a complex value. - * - * Syntax: - * - * math.complex() // creates a complex value with zero - * // as real and imaginary part. - * math.complex(re : number, im : string) // creates a complex value with provided - * // values for real and imaginary part. - * math.complex(re : number) // creates a complex value with provided - * // real value and zero imaginary part. - * math.complex(complex : Complex) // clones the provided complex value. - * math.complex(arg : string) // parses a string into a complex value. - * math.complex(array : Array) // converts the elements of the array - * // or matrix element wise into a - * // complex value. - * math.complex({re: number, im: number}) // creates a complex value with provided - * // values for real an imaginary part. - * math.complex({r: number, phi: number}) // creates a complex value with provided - * // polar coordinates - * - * Examples: - * - * var a = math.complex(3, -4); // a = Complex 3 - 4i - * a.re = 5; // a = Complex 5 - 4i - * var i = a.im; // Number -4; - * var b = math.complex('2 + 6i'); // Complex 2 + 6i - * var c = math.complex(); // Complex 0 + 0i - * var d = math.add(a, b); // Complex 5 + 2i - * - * See also: - * - * bignumber, boolean, index, matrix, number, string, unit - * - * @param {* | Array | Matrix} [args] - * Arguments specifying the real and imaginary part of the complex number - * @return {Complex | Array | Matrix} Returns a complex value - */ - var complex = typed('complex', { - '': function () { - return new type.Complex(0, 0); - }, - - 'number': function (x) { - return new type.Complex(x, 0); - }, - - 'number, number': function (re, im) { - return new type.Complex(re, im); - }, - - // TODO: this signature should be redundant - 'BigNumber, BigNumber': function (re, im) { - return new type.Complex(re.toNumber(), im.toNumber()); - }, - - 'Complex': function (x) { - return x.clone(); - }, - - 'string': function (x) { - var c = type.Complex.parse(x); - if (c) { - return c; - } - - throw new SyntaxError('String "' + x + '" is no valid complex number'); - }, - - 'Object': function (x) { - if('re' in x && 'im' in x) { - return new type.Complex(x.re, x.im); - } - - if ('r' in x && 'phi' in x) { - return type.Complex.fromPolar(x.r, x.phi); - } - - throw new Error('Expected object with either properties re and im, or properties r and phi.'); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, complex); - } - }); - - return complex; - } - - exports.name = 'complex'; - exports.factory = factory; - - -/***/ }, -/* 74 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create an index. An Index can store ranges having start, step, and end - * for multiple dimensions. - * Matrix.get, Matrix.set, and math.subset accept an Index as input. - * - * Syntax: - * - * math.index(range1, range2, ...) - * - * Where: - * - * Each range can be any of: - * - * - An array [start, end] - * - An array [start, end, step] - * - A number - * - An instance of `Range` - * - * The parameters start, end, and step must be integer numbers. Start and end - * are zero based. The start of a range is included, the end is excluded. - * - * Examples: - * - * var math = math.js - * - * var b = [1, 2, 3, 4, 5]; - * math.subset(b, math.index([1, 3])); // returns [2, 3] - * - * var a = math.matrix([[1, 2], [3, 4]]); - * a.subset(math.index(0, 1)); // returns 2 - * a.subset(math.index(1, null)); // returns [3, 4] - * - * See also: - * - * bignumber, boolean, complex, matrix, number, string, unit - * - * @param {...*} ranges Zero or more ranges or numbers. - * @return {Index} Returns the created index - */ - return typed('index', { - '...number | BigNumber | Range | Array': function (args) { - var ranges = args.map(function (arg) { - if (arg instanceof type.BigNumber) { - return arg.toNumber(); // convert BigNumber to Number - } - else if (Array.isArray(arg)) { - return arg.map(function (elem) { - // convert BigNumber to Number - return (elem instanceof type.BigNumber) ? elem.toNumber() : elem; - }); - } - else { - return arg; - } - }); - - var res = new type.Index(); - type.Index.apply(res, ranges); - return res; - } - }); - } - - exports.name = 'index'; - exports.factory = factory; - - -/***/ }, -/* 75 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create a Matrix. The function creates a new `math.type.Matrix` object from - * an `Array`. A Matrix has utility functions to manipulate the data in the - * matrix, like getting the size and getting or setting values in the matrix. - * Supported storage formats are 'dense' and 'sparse'. - * - * Syntax: - * - * math.matrix() // creates an empty matrix using default storage format (dense). - * math.matrix(data) // creates a matrix with initial data using default storage format (dense). - * math.matrix('dense') // creates an empty matrix using the given storage format. - * math.matrix(data, 'dense') // creates a matrix with initial data using the given storage format. - * math.matrix(data, 'sparse') // creates a sparse matrix with initial data. - * math.matrix(data, 'sparse', 'number') // creates a sparse matrix with initial data, number data type. - * - * Examples: - * - * var m = math.matrix([[1, 2], [3, 4]]); - * m.size(); // Array [2, 2] - * m.resize([3, 2], 5); - * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] - * m.get([1, 0]) // number 3 - * - * See also: - * - * bignumber, boolean, complex, index, number, string, unit, sparse - * - * @param {Array | Matrix} [data] A multi dimensional array - * @param {string} [format] The Matrix storage format - * - * @return {Matrix} The created matrix - */ - return typed('matrix', { - '': function () { - return _create([]); - }, - - 'string': function (format) { - return _create([], format); - }, - - 'string, string': function (format, datatype) { - return _create([], format, datatype); - }, - - 'Array': function (data) { - return _create(data); - }, - - 'Matrix': function (data) { - return _create(data, data.storage()); - }, - - 'Array | Matrix, string': _create, - - 'Array | Matrix, string, string': _create - }); - - /** - * Create a new Matrix with given storage format - * @param {Array} data - * @param {string} [format] - * @param {string} [datatype] - * @returns {Matrix} Returns a new Matrix - * @private - */ - function _create(data, format, datatype) { - // get storage format constructor - var M = type.Matrix.storage(format || 'default'); - - // create instance - return new M(data, datatype); - } - } - - exports.name = 'matrix'; - exports.factory = factory; - - -/***/ }, -/* 76 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a number or convert a string, boolean, or unit to a number. - * When value is a matrix, all elements will be converted to number. - * - * Syntax: - * - * math.number(value) - * math.number(unit, valuelessUnit) - * - * Examples: - * - * math.number(2); // returns number 2 - * math.number('7.2'); // returns number 7.2 - * math.number(true); // returns number 1 - * math.number([true, false, true, true]); // returns [1, 0, 1, 1] - * math.number(math.unit('52cm'), 'm'); // returns 0.52 - * - * See also: - * - * bignumber, boolean, complex, index, matrix, string, unit - * - * @param {String | Number | Boolean | Array | Matrix | Unit | null} [value] Value to be converted - * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number - * @return {Number | Array | Matrix} The created number - */ - var number = typed('number', { - '': function () { - return 0; - }, - - 'number': function (x) { - return x; - }, - - 'string': function (x) { - var num = Number(x); - if (isNaN(num)) { - throw new SyntaxError('String "' + x + '" is no valid number'); - } - return num; - }, - - 'BigNumber': function (x) { - return x.toNumber(); - }, - - 'Unit': function (x) { - throw new Error('Second argument with valueless unit expected'); - }, - - 'Unit, string | Unit': function (unit, valuelessUnit) { - return unit.toNumber(valuelessUnit); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, number); - } - }); - - return number; - } - - exports.name = 'number'; - exports.factory = factory; - - -/***/ }, -/* 77 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var Parser = load(__webpack_require__(14)); - - /** - * Create a parser. The function creates a new `math.expression.Parser` object. - * - * Syntax: - * - * math.parser() - * - * Examples: - * - * var parser = new math.parser(); - * - * // evaluate expressions - * var a = parser.eval('sqrt(3^2 + 4^2)'); // 5 - * var b = parser.eval('sqrt(-4)'); // 2i - * var c = parser.eval('2 inch in cm'); // 5.08 cm - * var d = parser.eval('cos(45 deg)'); // 0.7071067811865476 - * - * // define variables and functions - * parser.eval('x = 7 / 2'); // 3.5 - * parser.eval('x + 3'); // 6.5 - * parser.eval('function f(x, y) = x^y'); // f(x, y) - * parser.eval('f(2, 3)'); // 8 - * - * // get and set variables and functions - * var x = parser.get('x'); // 7 - * var f = parser.get('f'); // function - * var g = f(3, 2); // 9 - * parser.set('h', 500); - * var i = parser.eval('h / 2'); // 250 - * parser.set('hello', function (name) { - * return 'hello, ' + name + '!'; - * }); - * parser.eval('hello("user")'); // "hello, user!" - * - * // clear defined functions and variables - * parser.clear(); - * - * See also: - * - * eval, compile, parse - * - * @return {Parser} Parser - */ - return typed('parser', { - '': function () { - return new Parser(math); - } - }); - } - - exports.name = 'parser'; - exports.factory = factory; - exports.math = true; // requires the math namespace as 5th argument - - -/***/ }, -/* 78 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var SparseMatrix = type.SparseMatrix; - - /** - * Create a Sparse Matrix. The function creates a new `math.type.Matrix` object from - * an `Array`. A Matrix has utility functions to manipulate the data in the - * matrix, like getting the size and getting or setting values in the matrix. - * - * Syntax: - * - * math.sparse() // creates an empty sparse matrix. - * math.sparse(data) // creates a sparse matrix with initial data. - * math.sparse(data, 'number') // creates a sparse matrix with initial data, number datatype. - * - * Examples: - * - * var m = math.sparse([[1, 2], [3, 4]]); - * m.size(); // Array [2, 2] - * m.resize([3, 2], 5); - * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] - * m.get([1, 0]) // number 3 - * - * See also: - * - * bignumber, boolean, complex, index, number, string, unit, matrix - * - * @param {Array | Matrix} [data] A two dimensional array - * - * @return {Matrix} The created matrix - */ - return typed('sparse', { - '': function () { - return new SparseMatrix([]); - }, - - 'string': function (datatype) { - return new SparseMatrix([], datatype); - }, - - 'Array | Matrix': function (data) { - return new SparseMatrix(data); - }, - - 'Array | Matrix, string': function (data, datatype) { - return new SparseMatrix(data, datatype); - } - }); - } - - exports.name = 'sparse'; - exports.factory = factory; - - -/***/ }, -/* 79 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(175); - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a string or convert any object into a string. - * Elements of Arrays and Matrices are processed element wise. - * - * Syntax: - * - * math.string(value) - * - * Examples: - * - * math.string(4.2); // returns string '4.2' - * math.string(math.complex(3, 2); // returns string '3 + 2i' - * - * var u = math.unit(5, 'km'); - * math.string(u.to('m')); // returns string '5000 m' - * - * math.string([true, false]); // returns ['true', 'false'] - * - * See also: - * - * bignumber, boolean, complex, index, matrix, number, unit - * - * @param {* | Array | Matrix | null} [value] A value to convert to a string - * @return {String | Array | Matrix} The created string - */ - var string = typed('string', { - '': function () { - return ''; - }, - - 'number': number.format, - - 'null': function (x) { - return 'null'; - }, - - 'boolean': function (x) { - return x + ''; - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, string); - }, - - 'any': function (x) { - return String(x); - } - }); - - return string; - } - - exports.name = 'string'; - exports.factory = factory; - - -/***/ }, -/* 80 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Create a unit. Depending on the passed arguments, the function - * will create and return a new math.type.Unit object. - * When a matrix is provided, all elements will be converted to units. - * - * Syntax: - * - * math.unit(unit : string) - * math.unit(value : number, unit : string) - * - * Examples: - * - * var a = math.unit(5, 'cm'); // returns Unit 50 mm - * var b = math.unit('23 kg'); // returns Unit 23 kg - * a.to('m'); // returns Unit 0.05 m - * - * See also: - * - * bignumber, boolean, complex, index, matrix, number, string - * - * @param {* | Array | Matrix} args A number and unit. - * @return {Unit | Array | Matrix} The created unit - */ - - var unit = typed('unit', { - 'Unit': function (x) { - return x.clone(); - }, - - 'string': function (x) { - if (type.Unit.isValuelessUnit(x)) { - return new type.Unit(null, x); // a pure unit - } - - var u = type.Unit.parse(x); // a unit with value, like '5cm' - if (u) { - return u; - } - - throw new SyntaxError('String "' + x + '" is no valid unit'); - }, - - 'number, string': function (value, unit) { - return new type.Unit(value, unit); - }, - - 'BigNumber, string': function (value, unit) { - return new type.Unit(value.toNumber(), unit); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, unit); - } - }); - - return unit; - } - - exports.name = 'unit'; - exports.factory = factory; - - -/***/ }, -/* 81 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var collection = load(__webpack_require__(2)); - var parse = load(__webpack_require__(13)); - - /** - * Parse and compile an expression. - * Returns a an object with a function `eval([scope])` to evaluate the - * compiled expression. - * - * Syntax: - * - * math.compile(expr) // returns one node - * math.compile([expr1, expr2, expr3, ...]) // returns an array with nodes - * - * Examples: - * - * var code = math.compile('sqrt(3^2 + 4^2)'); - * code.eval(); // 5 - * - * var scope = {a: 3, b: 4} - * var code = math.compile('a * b'); // 12 - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.compile(['a = 3', 'b = 4', 'a * b']); - * nodes[2].eval(); // 12 - * - * See also: - * - * parse, eval - * - * @param {String | String[] | Array | Matrix} expr - * The expression to be compiled - * @return {{eval: Function} | Array.<{eval: Function}>} code - * An object with the compiled expression - * @throws {Error} - */ - return typed('compile', { - 'string': function (expr) { - return parse(expr).compile(math); - }, - - 'Array | Matrix': function (expr) { - return collection.deepMap(expr, function (entry) { - return parse(entry).compile(math); - }); - } - }); - } - - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.name = 'compile'; - exports.factory = factory; - - -/***/ }, -/* 82 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed, math) { - var collection = load(__webpack_require__(2)); - var parse = load(__webpack_require__(13)); - - /** - * Evaluate an expression. - * - * Syntax: - * - * math.eval(expr) - * math.eval(expr, scope) - * math.eval([expr1, expr2, expr3, ...]) - * math.eval([expr1, expr2, expr3, ...], scope) - * - * Example: - * - * math.eval('(2+3)/4'); // 1.25 - * math.eval('sqrt(3^2 + 4^2)'); // 5 - * math.eval('sqrt(-4)'); // 2i - * math.eval(['a=3', 'b=4', 'a*b']);, // [3, 4, 12] - * - * var scope = {a:3, b:4}; - * math.eval('a * b', scope); // 12 - * - * See also: - * - * parse, compile - * - * @param {String | String[] | Matrix} expr The expression to be evaluated - * @param {Object} [scope] Scope to read/write variables - * @return {*} The result of the expression - * @throws {Error} - */ - return typed('compile', { - 'string': function (expr) { - var scope = {}; - return parse(expr).compile(math).eval(scope); - }, - - 'string, Object': function (expr, scope) { - return parse(expr).compile(math).eval(scope); - }, - - 'Array | Matrix': function (expr) { - var scope = {}; - return collection.deepMap(expr, function (entry) { - return parse(entry).compile(math).eval(scope); - }); - }, - - 'Array | Matrix, Object': function (expr, scope) { - return collection.deepMap(expr, function (entry) { - return parse(entry).compile(math).eval(scope); - }); - } - }); - } - - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.name = 'eval'; - exports.factory = factory; - -/***/ }, -/* 83 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var docs = __webpack_require__(16); - - function factory (type, config, load, typed, math) { - /** - * Retrieve help on a function or data type. - * Help files are retrieved from the documentation in math.expression.docs. - * - * Syntax: - * - * math.help(search) - * - * Examples: - * - * console.log(math.help('sin').toString()); - * console.log(math.help(math.add).toString()); - * console.log(math.help(math.add).toJSON()); - * - * @param {function | string | Object} search A function or function name - * for which to get help - * @return {Help} A help object - */ - return typed('help', { - 'any': function (search) { - var prop; - var name = search; - - if (typeof search !== 'string') { - for (prop in math) { - // search in functions and constants - if (math.hasOwnProperty(prop) && (search === math[prop])) { - name = prop; - break; - } - } - - /* TODO: implement help for data types - if (!text) { - // search data type - for (prop in math.type) { - if (math.type.hasOwnProperty(prop)) { - if (search === math.type[prop]) { - text = prop; - break; - } - } - } - } - */ - } - - var doc = docs[name]; - if (!doc) { - throw new Error('No documentation found on "' + name + '"'); - } - return new type.Help(doc); - } - }); - } - - exports.math = true; // request access to the math namespace as 5th argument of the factory function - exports.name = 'help'; - exports.factory = factory; - - -/***/ }, -/* 84 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var parse = load(__webpack_require__(13)); - - /** - * Parse an expression. Returns a node tree, which can be evaluated by - * invoking node.eval(); - * - * Syntax: - * - * parse(expr) - * parse(expr, options) - * parse([expr1, expr2, expr3, ...]) - * parse([expr1, expr2, expr3, ...], options) - * - * Example: - * - * var node = parse('sqrt(3^2 + 4^2)'); - * node.compile(math).eval(); // 5 - * - * var scope = {a:3, b:4} - * var node = parse('a * b'); // 12 - * var code = node.compile(math); - * code.eval(scope); // 12 - * scope.a = 5; - * code.eval(scope); // 20 - * - * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); - * nodes[2].compile(math).eval(); // 12 - * - * @param {String | String[] | Matrix} expr Expression to be parsed - * @param {{nodes: Object}} [options] Available options: - * - `nodes` a set of custom nodes - * @return {Node | Node[]} node - * @throws {Error} - */ - return typed('parse', { - 'string | Array | Matrix': parse, - 'string | Array | Matrix, Object': parse - }); - } - - exports.name = 'parse'; - exports.factory = factory; - - -/***/ }, -/* 85 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Logical `and`. Test whether two values are both defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.and(x, y) - * - * Examples: - * - * math.and(2, 4); // returns true - * - * a = [2, 0, 0]; - * b = [3, 7, 0]; - * c = 0; - * - * math.and(a, b); // returns [true, false, false] - * math.and(a, c); // returns [false, false, false] - * - * See also: - * - * not, or, xor - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check - * @return {Boolean | Array | Matrix} - * Returns true when both inputs are defined with a nonzero/nonempty value. - */ - var and = typed('and', { - 'number, number': function (x, y) { - return !!(x && y); - }, - - 'Complex, Complex': function (x, y) { - return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0); - }, - - 'BigNumber, BigNumber': function (x, y) { - return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN(); - }, - - 'Unit, Unit': function (x, y) { - return (x.value !== 0 && x.value !== null) && (y.value !== 0 && y.value !== null); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, and); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, and); - } - }); - - return and; - } - - exports.name = 'and'; - exports.factory = factory; - - -/***/ }, -/* 86 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Logical `not`. Flips boolean value of a given parameter. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.not(x) - * - * Examples: - * - * math.not(2); // returns false - * math.not(0); // returns true - * math.not(true); // returns false - * - * a = [2, -7, 0]; - * math.not(a); // returns [false, false, true] - * - * See also: - * - * and, or, xor - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check - * @return {Boolean | Array | Matrix} - * Returns true when input is a zero or empty value. - */ - var not = typed('not', { - 'number': function (x) { - return !x; - }, - - 'Complex': function (x) { - return x.re === 0 && x.im === 0; - }, - - 'BigNumber': function (x) { - return x.isZero() || x.isNaN(); - }, - - 'Unit': function (x) { - return x.value === null || x.value == 0; - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, not); - } - }); - - return not; - } - - exports.name = 'not'; - exports.factory = factory; - - -/***/ }, -/* 87 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Logical `or`. Test if at least one value is defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.or(x, y) - * - * Examples: - * - * math.or(2, 4); // returns true - * - * a = [2, 5, 0]; - * b = [0, 22, 0]; - * c = 0; - * - * math.or(a, b); // returns [true, true, false] - * math.or(b, c); // returns [false, true, false] - * - * See also: - * - * and, not, xor - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check - * @return {Boolean | Array | Matrix} - * Returns true when one of the inputs is defined with a nonzero/nonempty value. - */ - var or = typed('or', { - 'number, number': function (x, y) { - return !!(x || y); - }, - - 'Complex, Complex': function (x, y) { - return (x.re !== 0 || x.im !== 0) || (y.re !== 0 || y.im !== 0); - }, - - 'BigNumber, BigNumber': function (x, y) { - return (!x.isZero() && !x.isNaN()) || (!y.isZero() && !y.isNaN()); - }, - - 'Unit, Unit': function (x, y) { - return (x.value !== 0 && x.value !== null) || (y.value !== 0 && y.value !== null); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, or); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, or); - } - }); - - return or; - } - - exports.name = 'or'; - exports.factory = factory; - - -/***/ }, -/* 88 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Logical `xor`. Test whether one and only one value is defined with a nonzero/nonempty value. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.xor(x, y) - * - * Examples: - * - * math.xor(2, 4); // returns false - * - * a = [2, 0, 0]; - * b = [2, 7, 0]; - * c = 0; - * - * math.xor(a, b); // returns [false, true, false] - * math.xor(a, c); // returns [true, false, false] - * - * See also: - * - * and, not, or - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check - * @return {Boolean | Array | Matrix} - * Returns true when one and only one input is defined with a nonzero/nonempty value. - */ - var xor = typed('xor', { - 'number, number': function (x, y) { - return !!(!!x ^ !!y); - }, - - 'Complex, Complex': function (x, y) { - return !!((x.re !== 0 || x.im !== 0) ^ (y.re !== 0 || y.im !== 0)); - }, - - 'BigNumber, BigNumber': function (x, y) { - return !!((!x.isZero() && !x.isNaN()) ^ (!y.isZero() && !y.isNaN())); - }, - - 'Unit, Unit': function (x, y) { - return !!((x.value !== 0 && x.value !== null) ^ (y.value !== 0 && y.value !== null)); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, xor); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, xor); - } - }); - - return xor; - } - - exports.name = 'xor'; - exports.factory = factory; - - -/***/ }, -/* 89 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(166).clone; - var isInteger = __webpack_require__(175).isInteger; - var array = __webpack_require__(172); - var IndexError = __webpack_require__(173); - var DimensionError = __webpack_require__(174); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - - /** - * Concatenate two or more matrices. - * - * Syntax: - * - * math.concat(A, B, C, ...) - * math.concat(A, B, C, ..., dim) - * - * Where: - * - * - `dim: number` is a zero-based dimension over which to concatenate the matrices. - * By default the last dimension of the matrices. - * - * Examples: - * - * var A = [[1, 2], [5, 6]]; - * var B = [[3, 4], [7, 8]]; - * - * math.concat(A, B); // returns [[1, 2, 3, 4], [5, 6, 7, 8]] - * math.concat(A, B, 0); // returns [[1, 2], [5, 6], [3, 4], [7, 8]] - * - * See also: - * - * size, squeeze, subset, transpose - * - * @param {... Array | Matrix} args Two or more matrices - * @return {Array | Matrix} Concatenated matrix - */ - return typed('concat', { - // TODO: change signature to '...Array | Matrix, dim?' when supported - '...Array | Matrix | number | BigNumber': function (args) { - var i; - var len = args.length; - var dim = -1; // zero-based dimension - var prevDim; - var asMatrix = false; - var matrices = []; // contains multi dimensional arrays - - for (i = 0; i < len; i++) { - var arg = args[i]; - - // test whether we need to return a Matrix (if not we return an Array) - if (arg instanceof type.Matrix) { - asMatrix = true; - } - - if (typeof arg === 'number' || arg instanceof type.BigNumber) { - if (i !== len - 1) { - throw new Error('Dimension must be specified as last argument'); - } - - // last argument contains the dimension on which to concatenate - prevDim = dim; - dim = arg.valueOf(); // change BigNumber to number - - if (!isInteger(dim)) { - throw new TypeError('Integer number expected for dimension'); - } - - if (dim < 0) { - // TODO: would be more clear when throwing a DimensionError here - throw new IndexError(dim); - } - if (i > 0 && dim > prevDim) { - // TODO: would be more clear when throwing a DimensionError here - throw new IndexError(dim, prevDim + 1); - } - } - else { - // this is a matrix or array - var m = clone(arg).valueOf(); - var size = array.size(m); - matrices[i] = m; - prevDim = dim; - dim = size.length - 1; - - // verify whether each of the matrices has the same number of dimensions - if (i > 0 && dim != prevDim) { - throw new DimensionError(prevDim + 1, dim + 1); - } - } - } - - if (matrices.length == 0) { - throw new SyntaxError('At least one matrix expected'); - } - - var res = matrices.shift(); - while (matrices.length) { - res = _concat(res, matrices.shift(), dim, 0); - } - - return asMatrix ? matrix(res) : res; - } - }); - } - - /** - * Recursively concatenate two matrices. - * The contents of the matrices is not cloned. - * @param {Array} a Multi dimensional array - * @param {Array} b Multi dimensional array - * @param {Number} concatDim The dimension on which to concatenate (zero-based) - * @param {Number} dim The current dim (zero-based) - * @return {Array} c The concatenated matrix - * @private - */ - function _concat(a, b, concatDim, dim) { - if (dim < concatDim) { - // recurse into next dimension - if (a.length != b.length) { - throw new DimensionError(a.length, b.length); - } - - var c = []; - for (var i = 0; i < a.length; i++) { - c[i] = _concat(a[i], b[i], concatDim, dim + 1); - } - return c; - } - else { - // concatenate this dimension - return a.concat(b); - } - } - - exports.name = 'concat'; - exports.factory = factory; - - -/***/ }, -/* 90 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - var subtract = load(__webpack_require__(55)); - var multiply = load(__webpack_require__(47)); - - /** - * Calculate the cross product for two vectors in three dimensional space. - * The cross product of `A = [a1, a2, a3]` and `B =[b1, b2, b3]` is defined - * as: - * - * cross(A, B) = [ - * a2 * b3 - a3 * b2, - * a3 * b1 - a1 * b3, - * a1 * b2 - a2 * b1 - * ] - * - * Syntax: - * - * math.cross(x, y) - * - * Examples: - * - * math.cross([1, 1, 0], [0, 1, 1]); // Returns [1, -1, 1] - * math.cross([3, -3, 1], [4, 9, 2]); // Returns [-15, -2, 39] - * math.cross([2, 3, 4], [5, 6, 7]); // Returns [-3, 6, -3] - * - * See also: - * - * dot, multiply - * - * @param {Array | Matrix} x First vector - * @param {Array | Matrix} y Second vector - * @return {Array | Matrix} Returns the cross product of `x` and `y` - */ - return typed('cross', { - 'Matrix, Matrix': function (x, y) { - return matrix(_cross(x.toArray(), y.toArray())); - }, - - 'Matrix, Array': function (x, y) { - return matrix(_cross(x.toArray(), y)); - }, - - 'Array, Matrix': function (x, y) { - return matrix(_cross(x, y.toArray())); - }, - - 'Array, Array': _cross - }); - - /** - * Calculate the cross product for two arrays - * @param {Array} x First vector - * @param {Array} y Second vector - * @returns {Array} Returns the cross product of x and y - * @private - */ - function _cross(x, y) { - var xSize= size(x); - var ySize = size(y); - - if (xSize.length != 1 || ySize.length != 1 || xSize[0] != 3 || ySize[0] != 3) { - throw new RangeError('Vectors with length 3 expected ' + - '(Size A = [' + xSize.join(', ') + '], B = [' + ySize.join(', ') + '])'); - } - - return [ - subtract(multiply(x[1], y[2]), multiply(x[2], y[1])), - subtract(multiply(x[2], y[0]), multiply(x[0], y[2])), - subtract(multiply(x[0], y[1]), multiply(x[1], y[0])) - ]; - } - } - - exports.name = 'cross'; - exports.factory = factory; - - -/***/ }, -/* 91 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - var object = util.object; - var string = util.string; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var matrix = load(__webpack_require__(75)); - var add = load(__webpack_require__(32)); - var subtract = load(__webpack_require__(55)); - var multiply = load(__webpack_require__(47)); - var unaryMinus = load(__webpack_require__(56)); - - /** - * Calculate the determinant of a matrix. - * - * Syntax: - * - * math.det(x) - * - * Examples: - * - * math.det([[1, 2], [3, 4]]); // returns -2 - * - * var A = [ - * [-2, 2, 3], - * [-1, 1, 3], - * [2, 0, -1] - * ] - * math.det(A); // returns 6 - * - * See also: - * - * inv - * - * @param {Array | Matrix} x A matrix - * @return {Number} The determinant of `x` - */ - return typed('det', { - 'any': function (x) { - return object.clone(x); - }, - - 'Array | Matrix': function det (x) { - var size; - if (x instanceof type.Matrix) { - size = x.size(); - } - else if (x instanceof Array) { - x = matrix(x); - size = x.size(); - } - else { - // a scalar - size = []; - } - - switch (size.length) { - case 0: - // scalar - return object.clone(x); - - case 1: - // vector - if (size[0] == 1) { - return object.clone(x.valueOf()[0]); - } - else { - throw new RangeError('Matrix must be square ' + - '(size: ' + string.format(size) + ')'); - } - - case 2: - // two dimensional array - var rows = size[0]; - var cols = size[1]; - if (rows == cols) { - return _det(x.clone().valueOf(), rows, cols); - } - else { - throw new RangeError('Matrix must be square ' + - '(size: ' + string.format(size) + ')'); - } - - default: - // multi dimensional array - throw new RangeError('Matrix must be two dimensional ' + - '(size: ' + string.format(size) + ')'); - } - } - }); - - /** - * Calculate the determinant of a matrix - * @param {Array[]} matrix A square, two dimensional matrix - * @param {Number} rows Number of rows of the matrix (zero-based) - * @param {Number} cols Number of columns of the matrix (zero-based) - * @returns {Number} det - * @private - */ - function _det (matrix, rows, cols) { - if (rows == 1) { - // this is a 1 x 1 matrix - return object.clone(matrix[0][0]); - } - else if (rows == 2) { - // this is a 2 x 2 matrix - // the determinant of [a11,a12;a21,a22] is det = a11*a22-a21*a12 - return subtract( - multiply(matrix[0][0], matrix[1][1]), - multiply(matrix[1][0], matrix[0][1]) - ); - } - else { - // this is an n x n matrix - var compute_mu = function (matrix) { - var i, j; - - // Compute the matrix with zero lower triangle, same upper triangle, - // and diagonals given by the negated sum of the below diagonal - // elements. - var mu = new Array(matrix.length); - var sum = 0; - for (i = 1; i < matrix.length; i++) { - sum = add(sum, matrix[i][i]); - } - - for (i = 0; i < matrix.length; i++) { - mu[i] = new Array(matrix.length); - mu[i][i] = unaryMinus(sum); - - for (j = 0; j < i; j++) { - mu[i][j] = 0; // TODO: make bignumber 0 in case of bignumber computation - } - - for (j = i + 1; j < matrix.length; j++) { - mu[i][j] = matrix[i][j]; - } - - if (i+1 < matrix.length) { - sum = subtract(sum, matrix[i + 1][i + 1]); - } - } - - return mu; - }; - - var fa = matrix; - for (var i = 0; i < rows - 1; i++) { - fa = multiply(compute_mu(fa), matrix); - } - - if (rows % 2 == 0) { - return unaryMinus(fa[0][0]); - } else { - return fa[0][0]; - } - } - } - } - - exports.name = 'det'; - exports.factory = factory; - - - -/***/ }, -/* 92 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(172); - var clone = __webpack_require__(166).clone; - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - - /** - * Create a diagonal matrix or retrieve the diagonal of a matrix - * - * When `x` is a vector, a matrix with vector `x` on the diagonal will be returned. - * When `x` is a two dimensional matrix, the matrixes `k`th diagonal will be returned as vector. - * When k is positive, the values are placed on the super diagonal. - * When k is negative, the values are placed on the sub diagonal. - * - * Syntax: - * - * math.diag(X) - * math.diag(X, format) - * math.diag(X, k) - * math.diag(X, k, format) - * - * Examples: - * - * // create a diagonal matrix - * math.diag([1, 2, 3]); // returns [[1, 0, 0], [0, 2, 0], [0, 0, 3]] - * math.diag([1, 2, 3], 1); // returns [[0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]] - * math.diag([1, 2, 3], -1); // returns [[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]] - * - * // retrieve the diagonal from a matrix - * var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; - * math.diag(a); // returns [1, 5, 9] - * - * See also: - * - * ones, zeros, eye - * - * @param {Matrix | Array} x A two dimensional matrix or a vector - * @param {Number | BigNumber} [k=0] The diagonal where the vector will be filled - * in or retrieved. - * @param {string} [format='dense'] The matrix storage format. - * - * @returns {Matrix | Array} Diagonal matrix from input vector, or diagonal from input matrix. - */ - return typed('diag', { - // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments - - 'Array': function (x) { - return _diag(x, 0, array.size(x), null); - }, - - 'Array, number': function (x, k) { - return _diag(x, k, array.size(x), null); - }, - - 'Array, BigNumber': function (x, k) { - return _diag(x, k.toNumber(), array.size(x), null); - }, - - 'Array, string': function (x, format) { - return _diag(x, 0, array.size(x), format); - }, - - 'Array, number, string': function (x, k, format) { - return _diag(x, k, array.size(x), format); - }, - - 'Array, BigNumber, string': function (x, k, format) { - return _diag(x, k.toNumber(), array.size(x), format); - }, - - 'Matrix': function (x) { - return _diag(x, 0, x.size(), x.storage()); - }, - - 'Matrix, number': function (x, k) { - return _diag(x, k, x.size(), x.storage()); - }, - - 'Matrix, BigNumber': function (x, k) { - return _diag(x, k.toNumber(), x.size(), x.storage()); - }, - - 'Matrix, string': function (x, format) { - return _diag(x, 0, x.size(), format); - }, - - 'Matrix, number, string': function (x, k, format) { - return _diag(x, k, x.size(), format); - }, - - 'Matrix, BigNumber, string': function (x, k, format) { - return _diag(x, k.toNumber(), x.size(), format); - } - }); - - /** - * Creeate diagonal matrix from a vector or vice versa - * @param {Array | Matrix} x - * @param {number} k - * @param {string} format Storage format for matrix. If null, - * an Array is returned - * @returns {Array | Matrix} - * @private - */ - function _diag (x, k, size, format) { - if (!isInteger(k)) { - throw new TypeError ('Second parameter in function diag must be an integer'); - } - - var kSuper = k > 0 ? k : 0; - var kSub = k < 0 ? -k : 0; - - // check dimensions - switch (size.length) { - case 1: - return _createDiagonalMatrix(x, k, format, size[0], kSub, kSuper); - case 2: - return _getDiagonal(x, k, format, size, kSub, kSuper); - } - throw new RangeError('Matrix for function diag must be 2 dimensional'); - } - - function _createDiagonalMatrix(x, k, format, l, kSub, kSuper) { - // matrix size - var ms = [l + kSub, l + kSuper]; - // get matrix constructor - var F = type.Matrix.storage(format || 'dense'); - // create diagonal matrix - var m = F.diagonal(ms, x, k); - // check we need to return a matrix - return format !== null ? m : m.valueOf(); - } - - function _getDiagonal(x, k, format, s, kSub, kSuper) { - // check x is a Matrix - if (x instanceof type.Matrix) { - // get diagonal matrix - var dm = x.diagonal(k); - // check we need to return a matrix - if (format !== null) { - // check we need to change matrix format - if (format !== dm.storage()) - return matrix(dm, format); - return dm; - } - return dm.valueOf(); - } - // vector size - var n = Math.min(s[0] - kSub, s[1] - kSuper); - // diagonal values - var vector = new Array(n); - // loop diagonal - for (var i = 0; i < n; i++) { - vector[i] = clone(x[i + kSub][i + kSuper]); - } - // check we need to return a matrix - return format !== null ? matrix(vector) : vector; - } - } - - exports.name = 'diag'; - exports.factory = factory; - - -/***/ }, -/* 93 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(32)); - var multiply = load(__webpack_require__(47)); - - /** - * Calculate the dot product of two vectors. The dot product of - * `A = [a1, a2, a3, ..., an]` and `B = [b1, b2, b3, ..., bn]` is defined as: - * - * dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn - * - * Syntax: - * - * math.dot(x, y) - * - * Examples: - * - * math.dot([2, 4, 1], [2, 2, 3]); // returns Number 15 - * math.multiply([2, 4, 1], [2, 2, 3]); // returns Number 15 - * - * See also: - * - * multiply, cross - * - * @param {Array | Matrix} x First vector - * @param {Array | Matrix} y Second vector - * @return {Number} Returns the dot product of `x` and `y` - */ - return typed('dot', { - 'Matrix, Matrix': function (x, y) { - return _dot(x.toArray(), y.toArray()); - }, - - 'Matrix, Array': function (x, y) { - return _dot(x.toArray(), y); - }, - - 'Array, Matrix': function (x, y) { - return _dot(x, y.toArray()); - }, - - 'Array, Array': _dot - }); - - /** - * Calculate the dot product for two arrays - * @param {Array} x First vector - * @param {Array} y Second vector - * @returns {Number} Returns the dot product of x and y - * @private - */ - // TODO: double code with math.multiply - function _dot(x, y) { - var xSize= size(x); - var ySize = size(y); - var len = xSize[0]; - - if (xSize.length !== 1 || ySize.length !== 1) throw new RangeError('Vector expected'); // TODO: better error message - if (xSize[0] != ySize[0]) throw new RangeError('Vectors must have equal length (' + xSize[0] + ' != ' + ySize[0] + ')'); - if (len == 0) throw new RangeError('Cannot calculate the dot product of empty vectors'); - - var prod = 0; - for (var i = 0; i < len; i++) { - prod = add(prod, multiply(x[i], y[i])); - } - - return prod; - } - } - - exports.name = 'dot'; - exports.factory = factory; - - -/***/ }, -/* 94 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(172); - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - - /** - * Create a 2-dimensional identity matrix with size m x n or n x n. - * The matrix has ones on the diagonal and zeros elsewhere. - * - * Syntax: - * - * math.eye(n) - * math.eye(n, format) - * math.eye(m, n) - * math.eye(m, n, format) - * math.eye([m, n]) - * math.eye([m, n], format) - * - * Examples: - * - * math.eye(3); // returns [[1, 0, 0], [0, 1, 0], [0, 0, 1]] - * math.eye(3, 2); // returns [[1, 0], [0, 1], [0, 0]] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.eye(math.size(b)); // returns [[1, 0, 0], [0, 1, 0]] - * - * See also: - * - * diag, ones, zeros, size, range - * - * @param {...Number | Matrix | Array} size The size for the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Matrix | Array | Number} A matrix with ones on the diagonal. - */ - return typed('eye', { - '': function () { - return (config.matrix === 'matrix') ? matrix([]) : []; - }, - - 'string': function (format) { - return matrix(format); - }, - - 'number | BigNumber': function (rows) { - return _eye(rows, rows, config.matrix === 'matrix' ? 'default' : undefined); - }, - - 'number | BigNumber, string': function (rows, format) { - return _eye(rows, rows, format); - }, - - 'number | BigNumber, number | BigNumber': function (rows, cols) { - return _eye(rows, cols, config.matrix === 'matrix' ? 'default' : undefined); - }, - - 'number | BigNumber, number | BigNumber, string': function (rows, cols, format) { - return _eye(rows, cols, format); - }, - - 'Array': function (size) { - return _eyeVector(size); - }, - - 'Array, string': function (size, format) { - return _eyeVector(size, format); - }, - - 'Matrix': function (size) { - return _eyeVector(size.valueOf(), size.storage()); - }, - - 'Matrix, string': function (size, format) { - return _eyeVector(size.valueOf(), format); - } - }); - - function _eyeVector (size, format) { - switch (size.length) { - case 0: return format ? matrix(format) : []; - case 1: return _eye(size[0], size[0], format); - case 2: return _eye(size[0], size[1], format); - default: throw new Error('Vector containing two values expected'); - } - } - - /** - * Create an identity matrix - * @param {number | BigNumber} rows - * @param {number | BigNumber} cols - * @param {string} [format] - * @returns {Matrix} - * @private - */ - function _eye (rows, cols, format) { - // BigNumber constructor with the right precision - var Big = rows instanceof type.BigNumber ? rows.constructor : - cols instanceof type.BigNumber ? cols.constructor : null; - - if (rows instanceof type.BigNumber) rows = rows.toNumber(); - if (cols instanceof type.BigNumber) cols = cols.toNumber(); - - if (!isInteger(rows) || rows < 1) { - throw new Error('Parameters in function eye must be positive integers'); - } - if (!isInteger(cols) || cols < 1) { - throw new Error('Parameters in function eye must be positive integers'); - } - - var one = Big ? new type.BigNumber(1) : 1; - var defaultValue = Big ? new Big(0) : 0; - var size = [rows, cols]; - - // check we need to return a matrix - if (format) { - // get matrix storage constructor - var F = type.Matrix.storage(format); - // create diagonal matrix (use optimized implementation for storage format) - return F.diagonal(size, one, 0, defaultValue); - } - - // create and resize array - var res = array.resize([], size, defaultValue); - // fill in ones on the diagonal - var minimum = rows < cols ? rows : cols; - // fill diagonal - for (var d = 0; d < minimum; d++) { - res[d][d] = one; - } - return res; - } - } - - exports.name = 'eye'; - exports.factory = factory; - - -/***/ }, -/* 95 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(166).clone; - var _flatten = __webpack_require__(172).flatten; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - - /** - * Flatten a multi dimensional matrix into a single dimensional matrix. - * - * Syntax: - * - * math.flatten(x) - * - * Examples: - * - * math.flatten([[1,2], [3,4]]); // returns [1, 2, 3, 4] - * - * See also: - * - * concat, resize, size, squeeze - * - * @param {Matrix | Array} x Matrix to be flattened - * @return {Matrix | Array} Returns the flattened matrix - */ - return typed('flatten', { - 'Array': function (x) { - return _flatten(clone(x)); - }, - - 'Matrix': function (x) { - var flat = _flatten(clone(x.toArray())); - // TODO: return the same matrix type as x - return matrix(flat); - } - }); - } - - exports.name = 'flatten'; - exports.factory = factory; - - -/***/ }, -/* 96 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var matrix = load(__webpack_require__(75)); - var divideScalar = load(__webpack_require__(213)); - var add = load(__webpack_require__(32)); - var multiply = load(__webpack_require__(47)); - var unaryMinus = load(__webpack_require__(56)); - var det = load(__webpack_require__(91)); - var eye = load(__webpack_require__(94)); - - /** - * Calculate the inverse of a square matrix. - * - * Syntax: - * - * math.inv(x) - * - * Examples: - * - * math.inv([[1, 2], [3, 4]]); // returns [[-2, 1], [1.5, -0.5]] - * math.inv(4); // returns 0.25 - * 1 / 4; // returns 0.25 - * - * See also: - * - * det, transpose - * - * @param {Number | Complex | Array | Matrix} x Matrix to be inversed - * @return {Number | Complex | Array | Matrix} The inverse of `x`. - */ - var inv = typed('inv', { - 'Array | Matrix': function (x) { - var size = x instanceof type.Matrix ? x.size() : util.array.size(x); - switch (size.length) { - case 1: - // vector - if (size[0] == 1) { - if (x instanceof type.Matrix) { - return matrix([ - divideScalar(1, x.valueOf()[0]) - ]); - } - else { - return [ - divideScalar(1, x[0]) - ]; - } - } - else { - throw new RangeError('Matrix must be square ' + - '(size: ' + util.string.format(size) + ')'); - } - - case 2: - // two dimensional array - var rows = size[0]; - var cols = size[1]; - if (rows == cols) { - if (x instanceof type.Matrix) { - return matrix( - _inv(x.valueOf(), rows, cols), - x.storage() - ); - } - else { - // return an Array - return _inv(x, rows, cols); - } - } - else { - throw new RangeError('Matrix must be square ' + - '(size: ' + util.string.format(size) + ')'); - } - - default: - // multi dimensional array - throw new RangeError('Matrix must be two dimensional ' + - '(size: ' + util.string.format(size) + ')'); - } - }, - - 'any': function (x) { - // scalar - return divideScalar(1, x); // FIXME: create a BigNumber one when configured for bignumbers - } - }); - - /** - * Calculate the inverse of a square matrix - * @param {Array[]} mat A square matrix - * @param {Number} rows Number of rows - * @param {Number} cols Number of columns, must equal rows - * @return {Array[]} inv Inverse matrix - * @private - */ - function _inv (mat, rows, cols){ - var r, s, f, value, temp; - - if (rows == 1) { - // this is a 1 x 1 matrix - value = mat[0][0]; - if (value == 0) { - throw Error('Cannot calculate inverse, determinant is zero'); - } - return [[ - divideScalar(1, value) - ]]; - } - else if (rows == 2) { - // this is a 2 x 2 matrix - var d = det(mat); - if (d == 0) { - throw Error('Cannot calculate inverse, determinant is zero'); - } - return [ - [ - divideScalar(mat[1][1], d), - divideScalar(unaryMinus(mat[0][1]), d) - ], - [ - divideScalar(unaryMinus(mat[1][0]), d), - divideScalar(mat[0][0], d) - ] - ]; - } - else { - // this is a matrix of 3 x 3 or larger - // calculate inverse using gauss-jordan elimination - // http://en.wikipedia.org/wiki/Gaussian_elimination - // http://mathworld.wolfram.com/MatrixInverse.html - // http://math.uww.edu/~mcfarlat/inverse.htm - - // make a copy of the matrix (only the arrays, not of the elements) - var A = mat.concat(); - for (r = 0; r < rows; r++) { - A[r] = A[r].concat(); - } - - // create an identity matrix which in the end will contain the - // matrix inverse - var B = eye(rows).valueOf(); - - // loop over all columns, and perform row reductions - for (var c = 0; c < cols; c++) { - // element Acc should be non zero. if not, swap content - // with one of the lower rows - r = c; - while (r < rows && A[r][c] == 0) { - r++; - } - if (r == rows || A[r][c] == 0) { - // TODO: in case of zero det, just return a matrix wih Infinity values? (like octave) - throw Error('Cannot calculate inverse, determinant is zero'); - } - if (r != c) { - temp = A[c]; A[c] = A[r]; A[r] = temp; - temp = B[c]; B[c] = B[r]; B[r] = temp; - } - - // eliminate non-zero values on the other rows at column c - var Ac = A[c], - Bc = B[c]; - for (r = 0; r < rows; r++) { - var Ar = A[r], - Br = B[r]; - if(r != c) { - // eliminate value at column c and row r - if (Ar[c] != 0) { - f = divideScalar(unaryMinus(Ar[c]), Ac[c]); - - // add (f * row c) to row r to eliminate the value - // at column c - for (s = c; s < cols; s++) { - Ar[s] = add(Ar[s], multiply(f, Ac[s])); - } - for (s = 0; s < cols; s++) { - Br[s] = add(Br[s], multiply(f, Bc[s])); - } - } - } - else { - // normalize value at Acc to 1, - // divide each value on row r with the value at Acc - f = Ac[c]; - for (s = c; s < cols; s++) { - Ar[s] = divideScalar(Ar[s], f); - } - for (s = 0; s < cols; s++) { - Br[s] = divideScalar(Br[s], f); - } - } - } - } - return B; - } - } - - return inv; - } - - exports.name = 'inv'; - exports.factory = factory; - - -/***/ }, -/* 97 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = function (math, config) { - var util = __webpack_require__(171), - - BigNumber = math.type.BigNumber, - Matrix = math.type.Matrix, - collection = math.collection, - - array = util.array, - isNumber = util.number.isNumber, - isInteger = util.number.isInteger, - isString = util.string.isString, - isArray = Array.isArray; - - /** - * Create a matrix filled with ones. The created matrix can have one or - * multiple dimensions. - * - * Syntax: - * - * math.ones(m) - * math.ones(m, format) - * math.ones(m, n) - * math.ones(m, n, format) - * math.ones([m, n]) - * math.ones([m, n], format) - * math.ones([m, n, p, ...]) - * math.ones([m, n, p, ...], format) - * - * Examples: - * - * math.ones(3); // returns [1, 1, 1] - * math.ones(3, 2); // returns [[1, 1], [1, 1], [1, 1]] - * math.ones(3, 2, 'dense'); // returns Dense Matrix [[1, 1], [1, 1], [1, 1]] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.zeros(math.size(A)); // returns [[1, 1, 1], [1, 1, 1]] - * - * See also: - * - * zeros, eye, size, range - * - * @param {...Number | Array} size The size of each dimension of the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Array | Matrix | Number} A matrix filled with ones - */ - math.ones = function ones (size, format) { - // process arguments - var args = collection.argsToArray(arguments); - // matrix storage format - var f; - // check format was provided - if (args.length > 0 && isString(args[args.length - 1])) { - // set format - f = args[args.length - 1]; - // re-process arguments, ignore last one - args = collection.argsToArray(args.slice(0, args.length - 1)); - } - else if (size instanceof Matrix) { - // use matrix format - f = size.storage(); - } - else if (!isArray(size) && config.matrix === 'matrix') { - // use default matrix format - f = 'default'; - } - - // convert arguments from bignumber to numbers if needed - var asBigNumber = false; - // map arguments & validate - args = args.map(function (value) { - // check it is a big number - if (value instanceof BigNumber) { - // set flag - asBigNumber = true; - // convert it - value = value.toNumber(); - } - // validate arguments - if (!isNumber(value) || !isInteger(value) || value < 0) { - throw new Error('Parameters in function eye must be positive integers'); - } - return value; - }); - - // default value - var defaultValue = asBigNumber ? new BigNumber(1) : 1; - - // check we need to return a matrix - if (f) { - // create empty matrix - var m = math.matrix(f); - // check we need to resize matrix - if (args.length > 0) { - // resize it to correct size - return m.resize(args, defaultValue); - } - return m; - } - // empty array - var res = []; - // check we need to resize array - if (args.length > 0) { - // resize array - return array.resize(res, args, defaultValue); - } - return res; - }; - }; - - -/***/ }, -/* 98 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = function (math, config) { - var util = __webpack_require__(171), - - BigNumber = math.type.BigNumber, - Matrix = math.type.Matrix, - collection = math.collection, - - isBoolean = util['boolean'].isBoolean, - isString = util.string.isString, - isNumber = util.number.isNumber; - - /** - * Create an array from a range. - * By default, the range end is excluded. This can be customized by providing - * an extra parameter `includeEnd`. - * - * Syntax: - * - * math.range(str [, includeEnd]) // Create a range from a string, - * // where the string contains the - * // start, optional step, and end, - * // separated by a colon. - * math.range(start, end [, includeEnd]) // Create a range with start and - * // end and a step size of 1. - * math.range(start, end, step [, includeEnd]) // Create a range with start, step, - * // and end. - * - * Where: - * - * - `str: String` - * A string 'start:end' or 'start:step:end' - * - `start: {Number | BigNumber}` - * Start of the range - * - `end: Number | BigNumber` - * End of the range, excluded by default, included when parameter includeEnd=true - * - `step: Number | BigNumber` - * Step size. Default value is 1. - * - `includeEnd: boolean` - * Option to specify whether to include the end or not. False by default. - * - * Examples: - * - * math.range(2, 6); // [2, 3, 4, 5] - * math.range(2, -3, -1); // [2, 1, 0, -1, -2] - * math.range('2:1:6'); // [2, 3, 4, 5] - * math.range(2, 6, true); // [2, 3, 4, 5, 6] - * - * See also: - * - * ones, zeros, size, subset - * - * @param {*} args Parameters describing the ranges `start`, `end`, and optional `step`. - * @return {Array | Matrix} range - */ - math.range = function range(args) { - var params = Array.prototype.slice.call(arguments), - start, - end, - step, - includeEnd = false; - - // read the includeEnd parameter - if (isBoolean(params[params.length - 1])) { - includeEnd = params.pop() ? true : false; - } - - switch (params.length) { - case 1: - // range(str) - // parse string into a range - if (isString(params[0])) { - var r = _parse(params[0]); - if (!r){ - throw new SyntaxError('String "' + params[0] + '" is no valid range'); - } - - start = r.start; - end = r.end; - step = r.step; - } - else { - throw new TypeError('Two or three numbers or a single string expected in function range'); - } - break; - - case 2: - // range(str, end) - // range(start, end) - start = params[0]; - end = params[1]; - step = 1; - break; - - case 3: - // range(start, end, step) - start = params[0]; - end = params[1]; - step = params[2]; - break; - - case 4: - throw new TypeError('Parameter includeEnd must be a boolean'); - - default: - throw new math.error.ArgumentsError('range', arguments.length, 2, 4); - } - - // verify type of parameters - if (!isNumber(start) && !(start instanceof BigNumber)) { - throw new TypeError('Parameter start must be a number'); - } - if (!isNumber(end) && !(end instanceof BigNumber)) { - throw new TypeError('Parameter end must be a number'); - } - 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 = BigNumber.convert(start); - if (!(end instanceof BigNumber)) end = BigNumber.convert(end); - if (!(step instanceof BigNumber)) step = BigNumber.convert(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; - if (start instanceof BigNumber) start = start.toNumber(); - if (end instanceof BigNumber) end = end.toNumber(); - if (step instanceof BigNumber) step = step.toNumber(); - } - } - - // generate the range - var fn = asBigNumber ? - (includeEnd ? _bigRangeInc : _bigRange) : - (includeEnd ? _rangeInc : _range); - var array = fn(start, end, step); - - // return as array or matrix - return (config.matrix === 'array') ? array : math.matrix(array); - }; - - /** - * Create a range with numbers. End is excluded - * @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) { - while (x < end) { - array.push(x); - x += step; - } - } - else if (step < 0) { - while (x > end) { - array.push(x); - x += step; - } - } - - return array; - } - - /** - * Create a range with numbers. End is included - * @param {Number} start - * @param {Number} end - * @param {Number} step - * @returns {Array} range - * @private - */ - function _rangeInc (start, end, step) { - var array = [], - x = start; - if (step > 0) { - while (x <= end) { - array.push(x); - x += step; - } - } - else if (step < 0) { - while (x >= end) { - array.push(x); - x += step; - } - } - - return array; - } - - /** - * Create a range with big numbers. End is excluded - * @param {BigNumber} start - * @param {BigNumber} end - * @param {BigNumber} step - * @returns {Array} range - * @private - */ - function _bigRange (start, end, step) { - var array = [], - x = start, - 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; - } - - /** - * Create a range with big numbers. End is included - * @param {BigNumber} start - * @param {BigNumber} end - * @param {BigNumber} step - * @returns {Array} range - * @private - */ - function _bigRangeInc (start, end, step) { - var array = [], - x = start, - zero = new BigNumber(0); - if (step.gt(zero)) { - while (x.lte(end)) { - array.push(x); - x = x.plus(step); - } - } - else if (step.lt(zero)) { - while (x.gte(end)) { - array.push(x); - x = x.plus(step); - } - } - - return array; - } - - /** - * Parse a string into a range, - * The string contains the start, optional step, and end, separated by a colon. - * If the string does not contain a valid range, null is returned. - * For example str='0:2:11'. - * @param {String} str - * @return {Object | null} range Object containing properties start, end, step - * @private - */ - function _parse (str) { - var args = str.split(':'), - nums = null; - - if (config.number === 'bignumber') { - // bignumber - try { - nums = args.map(function (arg) { - return new BigNumber(arg); - }); - } - catch (err) { - return null; - } - } - else { - // number - nums = args.map(function (arg) { - // use Number and not parseFloat as Number returns NaN on invalid garbage in the string - return Number(arg); - }); - - var invalid = nums.some(function (num) { - return isNaN(num); - }); - if(invalid) { - return null; - } - } - - switch (nums.length) { - case 2: - return { - start: nums[0], - end: nums[1], - step: 1 - }; - - case 3: - return { - start: nums[0], - end: nums[2], - step: nums[1] - }; - - default: - return null; - } - } - - }; - - -/***/ }, -/* 99 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = function (math, config) { - var util = __webpack_require__(171), - - BigNumber = math.type.BigNumber, - Matrix = math.type.Matrix, - - array = util.array, - clone = util.object.clone, - string = util.string, - isString = util.string.isString, - isNumber = util.number.isNumber, - isInteger = util.number.isInteger, - isArray = array.isArray; - - /** - * Resize a matrix - * - * Syntax: - * - * math.resize(x, size) - * math.resize(x, size, defaultValue) - * - * Examples: - * - * math.resize([1, 2, 3, 4, 5], [3]); // returns Array [1, 2, 3] - * math.resize([1, 2, 3], [5], 0); // returns Array [1, 2, 3, 0, 0] - * math.resize(2, [2, 3], 0); // returns Matrix [[2, 0, 0], [0, 0, 0]] - * math.resize("hello", [8], "!"); // returns String 'hello!!!' - * - * See also: - * - * size, squeeze, subset - * - * @param {Array | Matrix | *} x Matrix to be resized - * @param {Array | Matrix} size One dimensional array with numbers - * @param {Number | String} [defaultValue=0] Zero by default, except in - * case of a string, in that case - * defaultValue = ' ' - * @return {* | Array | Matrix} A resized clone of matrix `x` - */ - math.resize = function resize (x, size, defaultValue) { - if (arguments.length != 2 && arguments.length != 3) { - throw new math.error.ArgumentsError('resize', arguments.length, 2, 3); - } - - if (size instanceof Matrix) { - size = size.valueOf(); // get Array - } - - if (size.length && size[0] instanceof BigNumber) { - // convert bignumbers to numbers - size = size.map(function (value) { - return (value instanceof BigNumber) ? value.toNumber() : value; - }); - } - - // check x is a Matrix - if (x instanceof Matrix) { - // use optimized matrix implementation, return copy - return x.resize(size, defaultValue, true); - } - - if (isString(x)) { - // resize string - return _resizeString(x, size, defaultValue); - } - - // check result should be a matrix - var asMatrix = isArray(x) ? false : (config.matrix !== 'array'); - - if (size.length == 0) { - // output a scalar - while (isArray(x)) { - x = x[0]; - } - - return clone(x); - } - else { - // output an array/matrix - if (!isArray(x)) { - x = [x]; - } - x = clone(x); - - var res = array.resize(x, size, defaultValue); - return asMatrix ? math.matrix(res) : res; - } - }; - - /** - * Resize a string - * @param {String} str - * @param {Number[]} size - * @param {string} [defaultChar=' '] - * @private - */ - function _resizeString(str, size, defaultChar) { - if (defaultChar !== undefined) { - if (!isString(defaultChar) || defaultChar.length !== 1) { - throw new TypeError('Single character expected as defaultValue'); - } - } - else { - defaultChar = ' '; - } - - if (size.length !== 1) { - throw new math.error.DimensionError(size.length, 1); - } - var len = size[0]; - if (!isNumber(len) || !isInteger(len)) { - throw new TypeError('Invalid size, must contain positive integers ' + - '(size: ' + string.format(size) + ')'); - } - - if (str.length > len) { - return str.substring(0, len); - } - else if (str.length < len) { - var res = str; - for (var i = 0, ii = len - str.length; i < ii; i++) { - res += defaultChar; - } - return res; - } - else { - return str; - } - } - }; - - -/***/ }, -/* 100 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var array = __webpack_require__(172); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - - /** - * Calculate the size of a matrix or scalar. - * - * Syntax: - * - * math.size(x) - * - * Examples: - * - * math.size(2.3); // returns [] - * math.size('hello world'); // returns [11] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.size(A); // returns [2, 3] - * math.size(math.range(1,6)); // returns [5] - * - * See also: - * - * resize, squeeze, subset - * - * @param {Boolean | Number | Complex | Unit | String | Array | Matrix} x A matrix - * @return {Array | Matrix} A vector with size of `x`. - */ - return typed('size', { - 'Matrix': function (x) { - // TODO: return the same matrix type as the input - return matrix(x.size()); - }, - - 'Array': array.size, - - 'string': function (x) { - return (config.matrix === 'array') ? [x.length] : matrix([x.length]); - }, - - 'number | Complex | BigNumber | Unit | boolean | null': function (x) { - // scalar - return (config.matrix === 'array') ? [] : matrix([]); - } - }); - } - - exports.name = 'size'; - exports.factory = factory; - - -/***/ }, -/* 101 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(166); - var array = __webpack_require__(172); - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - - /** - * Squeeze a matrix, remove inner and outer singleton dimensions from a matrix. - * - * Syntax: - * - * math.squeeze(x) - * - * Examples: - * - * math.squeeze([3]); // returns 3 - * math.squeeze([[3]]); // returns 3 - * - * var A = math.zeros(3, 1); // returns [[0], [0], [0]] (size 3x1) - * math.squeeze(A); // returns [0, 0, 0] (size 3) - * - * var B = math.zeros(1, 3); // returns [[0, 0, 0]] (size 1x3) - * math.squeeze(B); // returns [0, 0, 0] (size 3) - * - * // only inner and outer dimensions are removed - * var C = math.zeros(2, 1, 3); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) - * math.squeeze(C); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) - * - * See also: - * - * subset - * - * @param {Matrix | Array} x Matrix to be squeezed - * @return {Matrix | Array} Squeezed matrix - */ - return typed('squeeze', { - 'Array': function (x) { - return array.squeeze(object.clone(x)); - }, - - 'Matrix': function (x) { - var res = array.squeeze(x.toArray()); - // FIXME: return the same type of matrix as the input - return Array.isArray(res) ? matrix(res) : res; - }, - - 'any': function (x) { - // scalar - return object.clone(x); - } - }); - } - - exports.name = 'squeeze'; - exports.factory = factory; - - -/***/ }, -/* 102 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = function (math, config) { - - var util = __webpack_require__(171), - - Matrix = math.type.Matrix, - Index = __webpack_require__(5), - - array = util.array, - isString = util.string.isString, - isArray = Array.isArray; - - /** - * Get or set a subset of a matrix or string. - * - * Syntax: - * math.subset(value, index) // retrieve a subset - * math.subset(value, index, replacement [, defaultValue]) // replace a subset - * - * Examples: - * - * // get a subset - * var d = [[1, 2], [3, 4]]; - * math.subset(d, math.index(1, 0)); // returns 3 - * math.subset(d, math.index([0, 2], 1)); // returns [[2], [4]] - * - * // replace a subset - * var e = []; - * var f = math.subset(e, math.index(0, [0, 2]), [5, 6]); // f = [[5, 6]] - * var g = math.subset(f, math.index(1, 1), 7, 0); // g = [[5, 6], [0, 7]] - * - * See also: - * - * size, resize, squeeze, index - * - * @param {Array | Matrix | String} matrix An array, matrix, or string - * @param {Index} index An index containing ranges for each - * dimension - * @param {*} [replacement] An array, matrix, or scalar. - * If provided, the subset is replaced with replacement. - * If not provided, the subset is returned - * @param {*} [defaultValue=undefined] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * math.matrix elements will be left undefined. - * @return {Array | Matrix | String} Either the retrieved subset or the updated matrix. - */ - math.subset = function subset (matrix, index, replacement, defaultValue) { - switch (arguments.length) { - case 2: // get subset - return _getSubset(arguments[0], arguments[1]); - - // intentional fall through - case 3: // set subset - case 4: // set subset with default value - return _setSubset(arguments[0], arguments[1], arguments[2], arguments[3]); - - default: // wrong number of arguments - throw new math.error.ArgumentsError('subset', arguments.length, 2, 4); - } - }; - - /** - * Retrieve a subset of an value such as an Array, Matrix, or String - * @param {Array | Matrix | String} value Object from which to get a subset - * @param {Index} index An index containing ranges for each - * dimension - * @returns {Array | Matrix | *} subset - * @private - */ - function _getSubset(value, index) { - var m, subset; - - if (isArray(value)) { - m = math.matrix(value); - subset = m.subset(index); // returns a Matrix - return subset && subset.valueOf(); // return an Array (like the input) - } - else if (value instanceof Matrix) { - return value.subset(index); - } - else if (isString(value)) { - return _getSubstring(value, index); - } - else { - throw new math.error.UnsupportedTypeError('subset', math['typeof'](value)); - } - } - - /** - * Retrieve a subset of a string - * @param {String} str String from which to get a substring - * @param {Index} index An index containing ranges for each dimension - * @returns {string} substring - * @private - */ - function _getSubstring(str, index) { - if (!(index instanceof Index)) { - // TODO: better error message - throw new TypeError('Index expected'); - } - if (index.size().length != 1) { - throw new math.error.DimensionError(index.size().length, 1); - } - - // validate whether the range is out of range - var strLen = str.length; - array.validateIndex(index.min()[0], strLen); - array.validateIndex(index.max()[0], strLen); - - var range = index.range(0); - - var substr = ''; - range.forEach(function (v) { - substr += str.charAt(v); - }); - - return substr; - } - - /** - * Replace a subset in an value such as an Array, Matrix, or String - * @param {Array | Matrix | String} value Object to be replaced - * @param {Index} index An index containing ranges for each - * dimension - * @param {Array | Matrix | *} replacement - * @param {*} [defaultValue=0] Default value, filled in on new entries when - * the matrix is resized. If not provided, - * math.matrix elements will be filled with zeros. - * @returns {*} result - * @private - */ - function _setSubset(value, index, replacement, defaultValue) { - var m; - - if (isArray(value)) { - m = math.matrix(math.clone(value)); - m.subset(index, replacement, defaultValue); - return m.valueOf(); - } - else if (value instanceof Matrix) { - return value.clone().subset(index, replacement, defaultValue); - } - else if (isString(value)) { - return _setSubstring(value, index, replacement, defaultValue); - } - else { - throw new math.error.UnsupportedTypeError('subset', math['typeof'](value)); - } - } - - /** - * Replace a substring in a string - * @param {String} str String to be replaced - * @param {Index} index An index containing ranges for each dimension - * @param {String} replacement Replacement string - * @param {String} [defaultValue] Default value to be uses when resizing - * the string. is ' ' by default - * @returns {string} result - * @private - */ - function _setSubstring(str, index, replacement, defaultValue) { - if (!(index instanceof Index)) { - // TODO: better error message - throw new TypeError('Index expected'); - } - if (index.size().length != 1) { - throw new math.error.DimensionError(index.size().length, 1); - } - if (defaultValue !== undefined) { - if (!isString(defaultValue) || defaultValue.length !== 1) { - throw new TypeError('Single character expected as defaultValue'); - } - } - else { - defaultValue = ' '; - } - - var range = index.range(0); - var len = range.size()[0]; - - if (len != replacement.length) { - throw new math.error.DimensionError(range.size()[0], replacement.length); - } - - // validate whether the range is out of range - var strLen = str.length; - array.validateIndex(index.min()[0]); - array.validateIndex(index.max()[0]); - - // copy the string into an array with characters - var chars = []; - for (var i = 0; i < strLen; i++) { - chars[i] = str.charAt(i); - } - - range.forEach(function (v, i) { - chars[v] = replacement.charAt(i); - }); - - // initialize undefined characters with a space - if (chars.length > strLen) { - for (i = strLen - 1, len = chars.length; i < len; i++) { - if (!chars[i]) { - chars[i] = defaultValue; - } - } - } - - return chars.join(''); - } - }; - - -/***/ }, -/* 103 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(166).clone; - var format = __webpack_require__(176).format; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var add = load(__webpack_require__(32)); - - /** - * Calculate the trace of a matrix: the sum of the elements on the main - * diagonal of a square matrix. - * - * Syntax: - * - * math.trace(x) - * - * Examples: - * - * math.trace([[1, 2], [3, 4]]); // returns 5 - * - * var A = [ - * [1, 2, 3], - * [-1, 2, 3], - * [2, 0, 3] - * ] - * math.trace(A); // returns 6 - * - * See also: - * - * diag - * - * @param {Array | Matrix} x A matrix - * - * @return {Number} The trace of `x` - */ - var trace = typed('trace', { - - 'Array': function (x) { - // use dense matrix implementation - return trace(matrix(x)); - }, - - 'Matrix': function (x) { - // result - var c; - // process storage format - switch (x.storage()) { - case 'dense': - c = _denseTrace(x); - break; - case 'sparse': - c = _sparseTrace(x); - break; - } - return c; - }, - - 'any': clone - }); - - var _denseTrace = function (m) { - // matrix size & data - var size = m._size; - var data = m._data; - - // process dimensions - switch (size.length) { - case 1: - // vector - if (size[0] == 1) { - // return data[0] - return clone(data[0]); - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - case 2: - // two dimensional - var rows = size[0]; - var cols = size[1]; - if (rows === cols) { - // calulate sum - var sum = 0; - // loop diagonal - for (var i = 0; i < rows; i++) - sum = add(sum, data[i][i]); - // return trace - return sum; - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - default: - // multi dimensional - throw new RangeError('Matrix must be two dimensional (size: ' + format(size) + ')'); - } - }; - - var _sparseTrace = function (m) { - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - var size = m._size; - // check dimensions - var rows = size[0]; - var columns = size[1]; - // matrix must be square - if (rows === columns) { - // calulate sum - var sum = 0; - // check we have data (avoid looping columns) - if (values.length > 0) { - // loop columns - for (var j = 0; j < columns; j++) { - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // loop k within [k0, k1[ - for (var k = k0; k < k1; k++) { - // row index - var i = index[k]; - // check row - if (i === j) { - // accumulate value - sum = add(sum, values[k]); - // exit loop - break; - } - if (i > j) { - // exit loop, no value on the diagonal for column j - break; - } - } - } - } - // return trace - return sum; - } - throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); - }; - - return trace; - } - - exports.name = 'trace'; - exports.factory = factory; - - -/***/ }, -/* 104 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var clone = __webpack_require__(166).clone; - var format = __webpack_require__(176).format; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - - var DenseMatrix = type.DenseMatrix, - SparseMatrix = type.SparseMatrix; - - /** - * Transpose a matrix. All values of the matrix are reflected over its - * main diagonal. Only two dimensional matrices are supported. - * - * Syntax: - * - * math.transpose(x) - * - * Examples: - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.transpose(A); // returns [[1, 4], [2, 5], [3, 6]] - * - * See also: - * - * diag, inv, subset, squeeze - * - * @param {Array | Matrix} x Matrix to be transposed - * @return {Array | Matrix} The transposed matrix - */ - var transpose = typed('transpose', { - - 'Array': function (x) { - // use dense matrix implementation - return transpose(matrix(x)).valueOf(); - }, - - 'Matrix': function (x) { - // matrix size - var size = x.size(); - - // result - var c; - - // process dimensions - switch (size.length) { - case 1: - // vector - c = x.clone(); - break; - - case 2: - // rows and columns - var rows = size[0]; - var columns = size[1]; - - // check columns - if (columns === 0) { - // throw exception - throw new RangeError('Cannot transpose a 2D matrix with no columns (size: ' + format(size) + ')'); - } - - // process storage format - switch (x.storage()) { - case 'dense': - c = _denseTranspose(x, rows, columns); - break; - case 'sparse': - c = _sparseTranspose(x, rows, columns); - break; - } - break; - - default: - // multi dimensional - throw new RangeError('Matrix must be a vector or two dimensional (size: ' + format(this._size) + ')'); - } - return c; - }, - - // scalars - 'any': function (x) { - return clone(x); - } - }); - - var _denseTranspose = function (m, rows, columns) { - // matrix array - var data = m._data; - // transposed matrix data - var transposed = []; - var transposedRow; - // loop columns - for (var j = 0; j < columns; j++) { - // initialize row - transposedRow = transposed[j] = []; - // loop rows - for (var i = 0; i < rows; i++) { - // set data - transposedRow[i] = clone(data[i][j]); - } - } - // return matrix - return new DenseMatrix({ - data: transposed, - size: [columns, rows] - }); - }; - - var _sparseTranspose = function (m, rows, columns) { - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // result matrices - var cvalues = []; - var cindex = []; - var cptr = []; - // row counts - var w = new Array(rows); - for (var x = 0; x < rows; x++) - w[x] = 0; - // vars - var p, l, j; - // loop values in matrix - for (p = 0, l = index.length; p < l; p++) { - // number of values in row - w[index[p]]++; - } - // cumulative sum - var sum = 0; - // initialize cptr with the cummulative sum of row counts - for (var i = 0; i < rows; i++) { - // update cptr - cptr.push(sum); - // update sum - sum += w[i]; - // update w - w[i] = cptr[i]; - } - // update cptr - cptr.push(sum); - // loop columns - for (j = 0; j < columns; j++) { - // values & index in column - for (var k0 = ptr[j], k1 = ptr[j + 1], k = k0; k < k1; k++) { - // C values & index - var q = w[index[k]]++; - // C[j, i] = A[i, j] - cindex[q] = j; - cvalues[q] = clone(values[k]); - } - } - // return matrix - return new SparseMatrix({ - values: cvalues, - index: cindex, - ptr: cptr, - size: [columns, rows] - }); - }; - - return transpose; - } - - exports.name = 'transpose'; - exports.factory = factory; - - -/***/ }, -/* 105 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - module.exports = function (math, config) { - var util = __webpack_require__(171), - - BigNumber = math.type.BigNumber, - Matrix = math.type.Matrix, - collection = math.collection, - - array = util.array, - isNumber = util.number.isNumber, - isInteger = util.number.isInteger, - isString = util.string.isString, - isArray = Array.isArray; - - /** - * Create a matrix filled with zeros. The created matrix can have one or - * multiple dimensions. - * - * Syntax: - * - * math.zeros(m) - * math.zeros(m, format) - * math.zeros(m, n) - * math.zeros(m, n, format) - * math.zeros([m, n]) - * math.zeros([m, n], format) - * - * Examples: - * - * math.zeros(3); // returns [0, 0, 0] - * math.zeros(3, 2); // returns [[0, 0], [0, 0], [0, 0]] - * math.zeros(3, 'dense'); // returns [0, 0, 0] - * - * var A = [[1, 2, 3], [4, 5, 6]]; - * math.zeros(math.size(A)); // returns [[0, 0, 0], [0, 0, 0]] - * - * See also: - * - * ones, eye, size, range - * - * @param {...Number | Array} size The size of each dimension of the matrix - * @param {string} [format] The Matrix storage format - * - * @return {Array | Matrix} A matrix filled with zeros - */ - math.zeros = function zeros (size) { - // process arguments - var args = collection.argsToArray(arguments); - // matrix storage format - var f; - // check format was provided - if (args.length > 0 && isString(args[args.length - 1])) { - // set format - f = args[args.length - 1]; - // re-process arguments, ignore last one - args = collection.argsToArray(args.slice(0, args.length - 1)); - } - else if (size instanceof Matrix) { - // use matrix format - f = size.storage(); - } - else if (!isArray(size) && config.matrix === 'matrix') { - // use default matrix format - f = 'default'; - } - - // convert arguments from bignumber to numbers if needed - var asBigNumber = false; - // map arguments & validate - args = args.map(function (value) { - // check it is a big number - if (value instanceof BigNumber) { - // set flag - asBigNumber = true; - // convert it - value = value.toNumber(); - } - // validate arguments - if (!isNumber(value) || !isInteger(value) || value < 0) { - throw new Error('Parameters in function eye must be positive integers'); - } - return value; - }); - - // default value - var defaultValue = asBigNumber ? new BigNumber(0) : 0; - - // check we need to return a matrix - if (f) { - // create empty matrix - var m = math.matrix(f); - // check we need to resize matrix - if (args.length > 0) { - // resize it to correct size - return m.resize(args, defaultValue); - } - return m; - } - // empty array - var res = []; - // check we need to resize array - if (args.length > 0) { - // resize array - return array.resize(res, args, defaultValue); - } - return res; - }; - }; - - -/***/ }, -/* 106 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - /** - * Compute the number of ways of picking `k` unordered outcomes from `n` - * possibilities. - * - * Combinations only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * Syntax: - * - * math.combinations(n, k) - * - * Examples: - * - * math.combinations(7, 5); // returns 21 - * - * See also: - * - * permutations, factorial - * - * @param {Number | BigNumber} n Total number of objects in the set - * @param {Number | BigNumber} k Number of objects in the subset - * @return {Number | BigNumber} Number of possible combinations. - */ - return typed('combinations', { - 'number, number': function (n, k) { - var max, result, i; - - if (!isInteger(n) || n < 0) { - throw new TypeError('Positive integer value expected in function combinations'); - } - if (k > n) { - throw new TypeError('k must be less than or equal to n'); - } - - max = Math.max(k, n - k); - result = 1; - for (i = 1; i <= n - max; i++) { - result = result * (max + i) / i; - } - - return result; - }, - - 'BigNumber, BigNumber': function (n, k) { - var max, result, i, ii; - var one = new type.BigNumber(1); - - if (!isPositiveInteger(n) || !isPositiveInteger(k)) { - throw new TypeError('Positive integer value expected in function combinations'); - } - if (k.gt(n)) { - throw new TypeError('k must be less than n in function combinations'); - } - - max = n.minus(k); - if (k.lt(max)) max = k; - result = one; - for (i = one, ii = n.minus(max); i.lte(ii); i = i.plus(1)) { - result = result.times(max.plus(i)).dividedBy(i); - } - - return result; - } - - // TODO: implement support for collection in combinations - }); - } - - /** - * Test whether BigNumber n is a positive integer - * @param {BigNumber} n - * @returns {boolean} isPositiveInteger - */ - function isPositiveInteger(n) { - return n.isInteger() && n.gte(0); - } - - exports.name = 'combinations'; - exports.factory = factory; - - -/***/ }, -/* 107 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bignumber = __webpack_require__(214); - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var gamma = load(__webpack_require__(108)); - - /** - * Compute the factorial of a value - * - * Factorial only supports an integer value as argument. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.factorial(n) - * - * Examples: - * - * math.factorial(5); // returns 120 - * math.factorial(3); // returns 6 - * - * See also: - * - * combinations, gamma, permutations - * - * @param {Number | BigNumber | Array | Matrix | Boolean | null} n An integer number - * @return {Number | BigNumber | Array | Matrix} The factorial of `n` - */ - var factorial = typed('factorial', { - 'number': function (n) { - if (n === Number.POSITIVE_INFINITY) { - return Math.sqrt(2 * Math.PI); - } - - return gamma(n + 1); - }, - - 'BigNumber': function (n) { - if (!n.isFinite() && !n.isNegative()) { - return bignumber.tau(config.precision).sqrt(); - } - - return gamma(n.plus(1)); - }, - - 'Array | Matrix': function (n) { - return collection.deepMap(n, factorial); - } - }); - - return factorial; - } - - exports.name = 'factorial'; - exports.factory = factory; - - -/***/ }, -/* 108 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var multiply = load(__webpack_require__(47)); - var pow = load(__webpack_require__(50)); - - /** - * Compute the gamma function of a value using Lanczos approximation for - * small values, and an extended Stirling approximation for large values. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.gamma(n) - * - * Examples: - * - * math.gamma(5); // returns 24 - * math.gamma(-0.5); // returns -3.5449077018110335 - * math.gamma(math.i); // returns -0.15494982830180973 - 0.49801566811835596i - * - * See also: - * - * combinations, factorial, permutations - * - * @param {Number | Array | Matrix | Boolean | null} n A real or complex number - * @return {Number | Array | Matrix} The gamma of `n` - */ - var gamma = typed('gamma', { - 'number': function (n) { - var t, x; - - if (isInteger(n)) { - if (n <= 0) { - return isFinite(n) ? Infinity : NaN; - } - - if (n > 171) { - return Infinity; // Will overflow - } - - var value = n - 2; - var res = n - 1; - while (value > 1) { - res *= value; - value--; - } - - if (res == 0) { - res = 1; // 0! is per definition 1 - } - - return res; - } - - if (n < 0.5) { - return Math.PI / (Math.sin(Math.PI * n) * gamma(1-n)); - } - - if (n >= 171.35) { - return Infinity; // will overflow - } - - if (n > 85.0) { // Extended Stirling Approx - var twoN = n*n; - var threeN = twoN*n; - var fourN = threeN*n; - var fiveN = fourN*n; - return Math.sqrt(2*Math.PI/n) * Math.pow((n/Math.E), n) * - (1 + 1/(12*n) + 1/(288*twoN) - 139/(51840*threeN) - - 571/(2488320*fourN) + 163879/(209018880*fiveN) + - 5246819/(75246796800*fiveN*n)); - } - - --n; - x = p[0]; - for (var i = 1; i < p.length; ++i) { - x += p[i] / (n+i); - } - - t = n + g + 0.5; - return Math.sqrt(2*Math.PI) * Math.pow(t, n+0.5) * Math.exp(-t) * x; - }, - - 'Complex': function (n) { - var t, x; - - if (n.im == 0) { - return gamma(n.re); - } - - n = new type.Complex(n.re - 1, n.im); - x = new type.Complex(p[0], 0); - for (var i = 1; i < p.length; ++i) { - var real = n.re + i; // x += p[i]/(n+i) - var den = real*real + n.im*n.im; - if (den != 0) { - x.re += p[i] * real / den; - x.im += -(p[i] * n.im) / den; - } else { - x.re = p[i] < 0 - ? -Infinity - : Infinity; - } - } - - t = new type.Complex(n.re + g + 0.5, n.im); - var twoPiSqrt = Math.sqrt(2*Math.PI); - - n.re += 0.5; - var result = pow(t, n); - if (result.im == 0) { // sqrt(2*PI)*result - result.re *= twoPiSqrt; - } else if (result.re == 0) { - result.im *= twoPiSqrt; - } else { - result.re *= twoPiSqrt; - result.im *= twoPiSqrt; - } - - var r = Math.exp(-t.re); // exp(-t) - t.re = r * Math.cos(-t.im); - t.im = r * Math.sin(-t.im); - - return multiply(multiply(result, t), x); - }, - - 'BigNumber': function (n) { - if (n.isInteger()) { - return (n.isNegative() || n.isZero()) - ? new type.BigNumber(Infinity) - : bigFactorial(n.minus(1)); - } - - if (!n.isFinite()) { - return new type.BigNumber(n.isNegative() ? NaN : Infinity); - } - - throw new Error('Integer BigNumber expected'); - }, - - 'Array | Matrix': function (n) { - return collection.deepMap(n, gamma); - } - }); - - /** - * Calculate factorial for a BigNumber - * @param {BigNumber} n - * @returns {BigNumber} Returns the factorial of n - */ - function bigFactorial(n) { - var value, res, preciseFacs; - - var num = n.toNumber(); // should definitely be below Number.MAX_VALUE - if (num < smallBigFacs.length) { - return new type.BigNumber(smallBigFacs[num]).toSD(config.precision); - } - - // be wary of round-off errors - var precision = config.precision + (Math.log(num) | 0); - var Big = type.BigNumber.constructor({precision: precision}); - - // adjust n do align with the precision specific tables - num -= smallBigFacs.length; - if (preciseFacs = bigBigFacs[precision]) { - if (preciseFacs[num]) { - return new type.BigNumber(preciseFacs[num].toPrecision(config.precision)); - } - res = preciseFacs[preciseFacs.length-1]; - } else { - preciseFacs = bigBigFacs[precision] = []; - res = new Big(smallBigFacs[smallBigFacs.length-1]) - .toSD(precision); - } - - var one = new Big(1); - value = new Big(preciseFacs.length + smallBigFacs.length); - for (var i = preciseFacs.length; i < num; ++i) { - preciseFacs[i] = res = res.times(value); - value = value.plus(one); - } - - preciseFacs[num] = res.times(value); - return new type.BigNumber(preciseFacs[num].toPrecision(config.precision)); - } - - return gamma; - } - - // TODO: comment on the variables g and p - - var g = 4.7421875; - - var p = [ - 0.99999999999999709182, - 57.156235665862923517, - -59.597960355475491248, - 14.136097974741747174, - -0.49191381609762019978, - 0.33994649984811888699e-4, - 0.46523628927048575665e-4, - -0.98374475304879564677e-4, - 0.15808870322491248884e-3, - -0.21026444172410488319e-3, - 0.21743961811521264320e-3, - -0.16431810653676389022e-3, - 0.84418223983852743293e-4, - -0.26190838401581408670e-4, - 0.36899182659531622704e-5 - ]; - - // 21! >= values for each precision - var bigBigFacs = []; - - // 0-20! values - var smallBigFacs = [ - 1, - 1, - 2, - 6, - 24, - 120, - 720, - 5040, - 40320, - 362880, - 3628800, - 39916800, - 479001600, - 6227020800, - 87178291200, - 1307674368000, - 20922789888000, - 355687428096000, - 6402373705728000, - 121645100408832000, - 2432902008176640000 - ]; - - exports.name = 'gamma'; - exports.factory = factory; - - -/***/ }, -/* 109 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isInteger = __webpack_require__(175).isInteger; - - function factory (type, config, load, typed) { - var factorial = load(__webpack_require__(107)); - - /** - * Compute the number of ways of obtaining an ordered subset of `k` elements - * from a set of `n` elements. - * - * Permutations only takes integer arguments. - * The following condition must be enforced: k <= n. - * - * Syntax: - * - * math.permutations(n) - * math.permutations(n, k) - * - * Examples: - * - * math.permutations(5); // 120 - * math.permutations(5, 3); // 60 - * - * See also: - * - * combinations, factorial - * - * @param {Number | BigNumber} n The number of objects in total - * @param {Number | BigNumber} [k] The number of objects in the subset - * @return {Number | BigNumber} The number of permutations - */ - return typed('permutations', { - 'number | BigNumber': factorial, - - 'number, number': function (n, k) { - var result, i; - - if (!isInteger(n) || n < 0) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (!isInteger(k) || k < 0) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (k > n) { - throw new TypeError('second argument k must be less than or equal to first argument n'); - } - - // Permute n objects, k at a time - result = 1; - for (i = n - k + 1; i <= n; i++) { - result = result * i; - } - - return result; - }, - - 'BigNumber, BigNumber': function (n, k) { - var result, i; - - if (!isPositiveInteger(n) || !isPositiveInteger(k)) { - throw new TypeError('Positive integer value expected in function permutations'); - } - if (k.gt(n)) { - throw new TypeError('second argument k must be less than or equal to first argument n'); - } - - result = new type.BigNumber(1); - for (i = n.minus(k).plus(1); i.lte(n); i = i.plus(1)) { - result = result.times(i); - } - - return result; - } - - // TODO: implement support for collection in permutations - }); - } - - /** - * Test whether BigNumber n is a positive integer - * @param {BigNumber} n - * @returns {boolean} isPositiveInteger - */ - function isPositiveInteger(n) { - return n.isInteger() && n.gte(0); - } - - exports.name = 'permutations'; - exports.factory = factory; - - -/***/ }, -/* 110 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(215)); - - /** - * Random pick a value from a one dimensional array. - * Array element is picked using a random function with uniform distribution. - * - * Syntax: - * - * math.pickRandom(array) - * - * Examples: - * - * math.pickRandom([3, 6, 12, 2]); // returns one of the values in the array - * - * See also: - * - * random, randomInt - * - * @param {Array} array A one dimensional array - * @return {Number} One of the elements of the provided input array - */ - // TODO: rework pickRandom to a typed-function - return distribution('uniform').pickRandom; - } - - exports.name = 'pickRandom'; - exports.factory = factory; - - -/***/ }, -/* 111 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(215)); - - /** - * Return a random number larger or equal to `min` and smaller than `max` - * using a uniform distribution. - * - * Syntax: - * - * math.random() // generate a random number between 0 and 1 - * math.random(max) // generate a random number between 0 and max - * math.random(min, max) // generate a random number between min and max - * math.random(size) // generate a matrix with random numbers between 0 and 1 - * math.random(size, max) // generate a matrix with random numbers between 0 and max - * math.random(size, min, max) // generate a matrix with random numbers between min and max - * - * Examples: - * - * math.random(); // returns a random number between 0 and 1 - * math.random(100); // returns a random number between 0 and 100 - * math.random(30, 40); // returns a random number between 30 and 40 - * math.random([2, 3]); // returns a 2x3 matrix with random numbers between 0 and 1 - * - * See also: - * - * randomInt, pickRandom - * - * @param {Array | Matrix} [size] If provided, an array or matrix with given - * size and filled with random values is returned - * @param {Number} [min] Minimum boundary for the random value, included - * @param {Number} [max] Maximum boundary for the random value, excluded - * @return {Number | Array | Matrix} A random number - */ - // TODO: rework random to a typed-function - return distribution('uniform').random; - } - - exports.name = 'random'; - exports.factory = factory; - - -/***/ }, -/* 112 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var distribution = load(__webpack_require__(215)); - - /** - * Return a random integer number larger or equal to `min` and smaller than `max` - * using a uniform distribution. - * - * Syntax: - * - * math.randomInt() // generate a random integer between 0 and 1 - * math.randomInt(max) // generate a random integer between 0 and max - * math.randomInt(min, max) // generate a random integer between min and max - * math.randomInt(size) // generate a matrix with random integer between 0 and 1 - * math.randomInt(size, max) // generate a matrix with random integer between 0 and max - * math.randomInt(size, min, max) // generate a matrix with random integer between min and max - * - * Examples: - * - * math.randomInt(); // returns a random integer between 0 and 1 - * math.randomInt(100); // returns a random integer between 0 and 100 - * math.randomInt(30, 40); // returns a random integer between 30 and 40 - * math.randomInt([2, 3]); // returns a 2x3 matrix with random integers between 0 and 1 - * - * See also: - * - * random, pickRandom - * - * @param {Array | Matrix} [size] If provided, an array or matrix with given - * size and filled with random values is returned - * @param {Number} [min] Minimum boundary for the random value, included - * @param {Number} [max] Maximum boundary for the random value, excluded - * @return {Number | Array | Matrix} A random integer value - */ - // TODO: rework randomInt to a typed-function - return distribution('uniform').randomInt; - } - - exports.name = 'randomInt'; - exports.factory = factory; - - -/***/ }, -/* 113 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y. - * - * x and y are considered equal when the relative difference between x and y - * is smaller than the configured epsilon. The function cannot be used to - * compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.compare(x, y) - * - * Examples: - * - * math.compare(6, 1); // returns 1 - * math.compare(2, 3); // returns -1 - * math.compare(7, 7); // returns 0 - * - * var a = math.unit('5 cm'); - * var b = math.unit('40 mm'); - * math.compare(a, b); // returns 1 - * - * math.compare(2, [1, 2, 3]); // returns [1, 0, -1] - * - * See also: - * - * equal, unequal, smaller, smallerEq, larger, largerEq - * - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare - * @return {Number | BigNumber | Array | Matrix} Returns the result of the comparison: 1, 0 or -1. - */ - var compare = typed('compare', { - 'boolean, boolean': function (x, y) { - return x === y ? 0 : (x > y ? 1 : -1); - }, - - 'number, number': function (x, y) { - return (x === y || nearlyEqual(x, y, config.epsilon)) ? 0 : (x > y ? 1 : -1); - }, - - 'BigNumber, BigNumber': function (x, y) { - return new x.constructor(x.cmp(y)); - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return (x.value === y.value || nearlyEqual(x.value, y.value, config.epsilon)) ? 0 : (x.value > y.value ? 1 : -1); - }, - - 'string, string': function (x, y) { - return x === y ? 0 : (x > y ? 1 : -1); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, compare); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, compare); - } - }); - - return compare; - } - - exports.name = 'compare'; - exports.factory = factory; - - -/***/ }, -/* 114 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var equal = load(__webpack_require__(115)); - - /** - * Test element wise whether two matrices are equal. - * The function accepts both matrices and scalar values. - * - * Syntax: - * - * math.deepEqual(x, y) - * - * Examples: - * - * math.deepEqual(2, 4); // returns false - * - * a = [2, 5, 1]; - * b = [2, 7, 1]; - * - * math.deepEqual(a, b); // returns false - * math.equal(a, b); // returns [true, false, true] - * - * See also: - * - * equal, unequal - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First matrix to compare - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second matrix to compare - * @return {Number | BigNumber | Complex | Unit | Array | Matrix} - * Returns true when the input matrices have the same size and each of their elements is equal. - */ - return typed('deepEqual', { - 'any, any': function (x, y) { - return _deepEqual(x.valueOf(), y.valueOf()); - } - }); - - /** - * Test whether two arrays have the same size and all elements are equal - * @param {Array | *} x - * @param {Array | *} y - * @return {boolean} Returns true if both arrays are deep equal - */ - function _deepEqual(x, y) { - if (Array.isArray(x)) { - if (Array.isArray(y)) { - var len = x.length; - if (len !== y.length) { - return false; - } - - for (var i = 0; i < len; i++) { - if (!_deepEqual(x[i], y[i])) { - return false; - } - } - - return true; - } - else { - return false; - } - } - else { - if (Array.isArray(y)) { - return false; - } - else { - return equal(x, y); - } - } - } - } - - exports.name = 'deepEqual'; - exports.factory = factory; - - -/***/ }, -/* 115 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - /** - * Test whether two values are equal. - * - * The function tests whether the relative difference between x and y is - * smaller than the configured epsilon. The function cannot be used to - * compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * In case of complex numbers, x.re must equal y.re, and x.im must equal y.im. - * - * Values `null` and `undefined` are compared strictly, thus `null` is only - * equal to `null` and nothing else, and `undefined` is only equal to - * `undefined` and nothing else. - * - * Syntax: - * - * math.equal(x, y) - * - * Examples: - * - * math.equal(2 + 2, 3); // returns false - * math.equal(2 + 2, 4); // returns true - * - * var a = math.unit('50 cm'); - * var b = math.unit('5 m'); - * math.equal(a, b); // returns true - * - * var c = [2, 5, 1]; - * var d = [2, 7, 1]; - * - * math.equal(c, d); // returns [true, false, true] - * math.deepEqual(c, d); // returns false - * - * math.equal(0, null); // returns false - * - * See also: - * - * unequal, smaller, smallerEq, larger, largerEq, compare, deepEqual - * - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} x First value to compare - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the compared values are equal, else returns false - */ - var equal = typed('equal', { - 'any, any': function (x, y) { - // strict equality for null and undefined? - if (x === null) { return y === null; } - if (y === null) { return x === null; } - if (x === undefined) { return y === undefined; } - if (y === undefined) { return x === undefined; } - - return _equal(x, y); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, _equal); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, _equal); - } - }); - - var _equal = typed('_equal', { - 'boolean, boolean': function (x, y) { - return x === y; - }, - - 'number, number': function (x, y) { - return x === y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.eq(y); - }, - - 'Complex, Complex': function (x, y) { - return (x.re === y.re || nearlyEqual(x.re, y.re, config.epsilon)) && - (x.im === y.im || nearlyEqual(x.im, y.im, config.epsilon)); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return x.value === y.value || nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x === y; - } - }); - - return equal; - } - - exports.name = 'equal'; - exports.factory = factory; - - -/***/ }, -/* 116 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Test whether value x is larger than y. - * - * The function returns true when x is larger than y and the relative - * difference between x and y is larger than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.larger(x, y) - * - * Examples: - * - * math.larger(2, 3); // returns false - * math.larger(5, 2 + 2); // returns true - * - * var a = math.unit('5 cm'); - * var b = math.unit('2 inch'); - * math.larger(a, b); // returns false - * - * See also: - * - * equal, unequal, smaller, smallerEq, largerEq, compare - * - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the x is larger than y, else returns false - */ - var larger = typed('larger', { - 'boolean, boolean': function (x, y) { - return x > y; - }, - - 'number, number': function (x, y) { - return x > y && !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.gt(y); - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return x.value > y.value && !nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x > y; - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, larger); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, larger); - } - }); - - return larger; - } - - exports.name = 'larger'; - exports.factory = factory; - - -/***/ }, -/* 117 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Test whether value x is larger or equal to y. - * - * The function returns true when x is larger than y or the relative - * difference between x and y is smaller than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.largerEq(x, y) - * - * Examples: - * - * math.larger(2, 1 + 1); // returns false - * math.largerEq(2, 1 + 1); // returns true - * - * See also: - * - * equal, unequal, smaller, smallerEq, larger, compare - * - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the x is larger or equal to y, else returns false - */ - var largerEq = typed('largerEq', { - 'boolean, boolean': function (x, y) { - return x >= y; - }, - - 'number, number': function (x, y) { - return x >= y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.gte(y); - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return x.value >= y.value || nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x >= y; - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, largerEq); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, largerEq); - } - }); - - return largerEq; - } - - exports.name = 'largerEq'; - exports.factory = factory; - - -/***/ }, -/* 118 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Test whether value x is smaller than y. - * - * The function returns true when x is smaller than y and the relative - * difference between x and y is larger than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.smaller(x, y) - * - * Examples: - * - * math.smaller(2, 3); // returns true - * math.smaller(5, 2 * 2); // returns false - * - * var a = math.unit('5 cm'); - * var b = math.unit('2 inch'); - * math.smaller(a, b); // returns true - * - * See also: - * - * equal, unequal, smallerEq, larger, largerEq, compare - * - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false - */ - var smaller = typed('smaller', { - 'boolean, boolean': function (x, y) { - return x < y; - }, - - 'number, number': function (x, y) { - return x < y && !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.lt(y); - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return x.value < y.value && !nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x < y; - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, smaller); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, smaller); - } - }); - - return smaller; - } - - exports.name = 'smaller'; - exports.factory = factory; - - -/***/ }, -/* 119 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Test whether value x is smaller or equal to y. - * - * The function returns true when x is smaller than y or the relative - * difference between x and y is smaller than the configured epsilon. The - * function cannot be used to compare values smaller than approximately 2.22e-16. - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.smallerEq(x, y) - * - * Examples: - * - * math.smaller(1 + 2, 3); // returns false - * math.smallerEq(1 + 2, 3); // returns true - * - * See also: - * - * equal, unequal, smaller, larger, largerEq, compare - * - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare - * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false - */ - var smallerEq = typed('smallerEq', { - 'boolean, boolean': function (x, y) { - return x <= y; - }, - - 'number, number': function (x, y) { - return x <= y || nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return x.lte(y); - }, - - 'Complex, Complex': function (x, y) { - throw new TypeError('No ordering relation is defined for complex numbers'); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return x.value <= y.value || nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x <= y; - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, smallerEq); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, smallerEq); - } - }); - - return smallerEq; - } - - exports.name = 'smallerEq'; - exports.factory = factory; - - -/***/ }, -/* 120 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var nearlyEqual = __webpack_require__(175).nearlyEqual; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Test whether two values are unequal. - * - * The function tests whether the relative difference between x and y is - * larger than the configured epsilon. The function cannot be used to compare - * values smaller than approximately 2.22e-16. - * - * For matrices, the function is evaluated element wise. - * In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im. - * - * Values `null` and `undefined` are compared strictly, thus `null` is unequal - * with everything except `null`, and `undefined` is unequal with everying - * except. `undefined`. - * - * Syntax: - * - * math.unequal(x, y) - * - * Examples: - * - * math.unequal(2 + 2, 3); // returns true - * math.unequal(2 + 2, 4); // returns false - * - * var a = math.unit('50 cm'); - * var b = math.unit('5 m'); - * math.unequal(a, b); // returns false - * - * var c = [2, 5, 1]; - * var d = [2, 7, 1]; - * - * math.unequal(c, d); // returns [false, true, false] - * math.deepEqual(c, d); // returns false - * - * math.unequal(0, null); // returns true - * See also: - * - * equal, deepEqual, smaller, smallerEq, larger, largerEq, compare - * - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} x First value to compare - * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} y Second value to compare - * @return {Boolean | Array | Matrix} Returns true when the compared values are unequal, else returns false - */ - var unequal = typed('unequal', { - 'any, any': function (x, y) { - // strict equality for null and undefined? - if (x === null) { return y !== null; } - if (y === null) { return x !== null; } - if (x === undefined) { return y !== undefined; } - if (y === undefined) { return x !== undefined; } - - return _unequal(x, y); - }, - - 'Array | Matrix, any': function (x, y) { - return collection.deepMap2(x, y, _unequal); - }, - - 'any, Array | Matrix': function (x, y) { - return collection.deepMap2(x, y, _unequal); - } - }); - - var _unequal = typed('_unequal', { - 'boolean, boolean': function (x, y) { - return x !== y; - }, - - 'number, number': function (x, y) { - return !nearlyEqual(x, y, config.epsilon); - }, - - 'BigNumber, BigNumber': function (x, y) { - return !x.eq(y); - }, - - 'Complex, Complex': function (x, y) { - return !nearlyEqual(x.re, y.re, config.epsilon) || - !nearlyEqual(x.im, y.im, config.epsilon); - }, - - 'Unit, Unit': function (x, y) { - if (!x.equalBase(y)) { - throw new Error('Cannot compare units with different base'); - } - return !nearlyEqual(x.value, y.value, config.epsilon); - }, - - 'string, string': function (x, y) { - return x !== y; - } - }); - - return unequal; - } - - exports.name = 'unequal'; - exports.factory = factory; - - -/***/ }, -/* 121 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var larger = load(__webpack_require__(116)); - - /** - * Compute the maximum value of a matrix or a list with values. - * In case of a multi dimensional array, the maximum of the flattened array - * will be calculated. When `dim` is provided, the maximum over the selected - * dimension will be calculated. Parameter `dim` is zero-based. - * - * Syntax: - * - * math.max(a, b, c, ...) - * math.max(A) - * math.max(A, dim) - * - * Examples: - * - * math.max(2, 1, 4, 3); // returns 4 - * math.max([2, 1, 4, 3]); // returns 4 - * - * // maximum over a specified dimension (zero-based) - * math.max([[2, 5], [4, 3], [1, 7]], 0); // returns [4, 7] - * math.max([[2, 5], [4, 3]], [1, 7], 1); // returns [5, 4, 7] - * - * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 - * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 - * - * See also: - * - * mean, median, min, prod, std, sum, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The maximum value - */ - return typed('max', { - // max([a, b, c, d, ...]) - 'Array | Matrix': _max, - - // max([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - return collection.reduce(array, dim.valueOf(), _largest); - }, - - // max(a, b, c, d, ...) - '...': function () { - return _max(arguments); - } - }); - - /** - * Return the largest of two values - * @param {*} x - * @param {*} y - * @returns {*} Returns x when x is largest, or y when y is largest - * @private - */ - function _largest(x, y){ - return larger(x, y) ? x : y; - } - - /** - * Recursively calculate the maximum value in an n-dimensional array - * @param {Array} array - * @return {Number} max - * @private - */ - function _max(array) { - var max = undefined; - - collection.deepForEach(array, function (value) { - if (max === undefined || larger(value, max)) { - max = value; - } - }); - - if (max === undefined) { - throw new Error('Cannot calculate max of an empty array'); - } - - return max; - } - } - - exports.name = 'max'; - exports.factory = factory; - - -/***/ }, -/* 122 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var add = load(__webpack_require__(32)); - var divide = load(__webpack_require__(35)); - - /** - * Compute the mean value of matrix or a list with values. - * In case of a multi dimensional array, the mean of the flattened array - * will be calculated. When `dim` is provided, the maximum over the selected - * dimension will be calculated. Parameter `dim` is zero-based. - * - * Syntax: - * - * math.mean(a, b, c, ...) - * math.mean(A) - * math.mean(A, dim) - * - * Examples: - * - * math.mean(2, 1, 4, 3); // returns 2.5 - * math.mean([1, 2.7, 3.2, 4]); // returns 2.725 - * - * math.mean([[2, 5], [6, 3], [1, 7]], 0); // returns [3, 5] - * math.mean([[2, 5], [6, 3], [1, 7]], 1); // returns [3.5, 4.5, 4] - * - * See also: - * - * median, min, max, sum, prod, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The mean of all values - */ - return typed('mean', { - // mean([a, b, c, d, ...]) - 'Array | Matrix': _mean, - - // mean([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': _nmean, - - // mean(a, b, c, d, ...) - '...': function () { - return _mean(arguments); - } - }); - - /** - * Calculate the mean value in an n-dimensional array, returning a - * n-1 dimensional array - * @param {Array} array - * @param {Number} dim - * @return {Number} mean - * @private - */ - function _nmean(array, dim){ - var sum = collection.reduce(array, dim, add); - var s = Array.isArray(array) ? size(array) : array.size(); - return divide(sum, s[dim]); - } - - /** - * Recursively calculate the mean value in an n-dimensional array - * @param {Array} array - * @return {Number} mean - * @private - */ - function _mean(array) { - var sum = 0; - var num = 0; - - collection.deepForEach(array, function (value) { - sum = add(sum, value); - num++; - }); - - if (num === 0) { - throw new Error('Cannot calculate mean of an empty array'); - } - - return divide(sum, num); - } - } - - exports.name = 'mean'; - exports.factory = factory; - - -/***/ }, -/* 123 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var flatten = __webpack_require__(172).flatten; - - function factory (type, config, load, typed) { - var add = load(__webpack_require__(32)); - var divide = load(__webpack_require__(35)); - var compare = load(__webpack_require__(113)); - - /** - * Compute the median of a matrix or a list with values. The values are - * sorted and the middle value is returned. In case of an even number of - * values, the average of the two middle values is returned. - * Supported types of values are: Number, BigNumber, Unit - * - * In case of a (multi dimensional) array or matrix, the median of all - * elements will be calculated. - * - * Syntax: - * - * math.median(a, b, c, ...) - * math.median(A) - * - * Examples: - * - * math.median(5, 2, 7); // returns 5 - * math.median([3, -1, 5, 7]); // returns 4 - * - * See also: - * - * mean, min, max, sum, prod, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The median - */ - var median = typed('median', { - // median([a, b, c, d, ...]) - 'Array | Matrix': _median, - - // median([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - // TODO: implement median(A, dim) - throw new Error('median(A, dim) is not yet supported'); - //return collection.reduce(arguments[0], arguments[1], ...); - }, - - // median(a, b, c, d, ...) - '...': function () { - return _median(Array.prototype.slice.call(arguments)); - } - }); - - /** - * Recursively calculate the median of an n-dimensional array - * @param {Array | Matrix} array - * @return {Number} median - * @private - */ - function _median(array) { - var flat = flatten(array.valueOf()); - - flat.sort(compare); - - var num = flat.length; - - if (num == 0) { - throw new Error('Cannot calculate median of an empty array'); - } - - if (num % 2 == 0) { - // even: return the average of the two middle values - return middle2(flat[num / 2 - 1], flat[num / 2]); - } - else { - // odd: return the middle value - return middle(flat[(num - 1) / 2]); - } - } - - // helper function to type check the middle value of the array - var middle = typed('number | BigNumber | Unit', function (value) { - return value; - }); - - // helper function to type check the two middle value of the array - var middle2 = typed('number | BigNumber | Unit, number | BigNumber | Unit', function (left, right) { - return divide(add(left, right), 2); - }); - - return median; - } - - exports.name = 'median'; - exports.factory = factory; - - -/***/ }, -/* 124 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var smaller = load(__webpack_require__(118)); - - /** - * Compute the maximum value of a matrix or a list of values. - * In case of a multi dimensional array, the maximum of the flattened array - * will be calculated. When `dim` is provided, the maximum over the selected - * dimension will be calculated. Parameter `dim` is zero-based. - * - * Syntax: - * - * math.min(a, b, c, ...) - * math.min(A) - * math.min(A, dim) - * - * Examples: - * - * math.min(2, 1, 4, 3); // returns 1 - * math.min([2, 1, 4, 3]); // returns 1 - * - * // maximum over a specified dimension (zero-based) - * math.min([[2, 5], [4, 3], [1, 7]], 0); // returns [1, 3] - * math.min([[2, 5], [4, 3], [1, 7]], 1); // returns [2, 3, 1] - * - * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 - * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 - * - * See also: - * - * mean, median, max, prod, std, sum, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The minimum value - */ - return typed('min', { - // min([a, b, c, d, ...]) - 'Array | Matrix': _min, - - // min([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - return collection.reduce(array, dim.valueOf(), _smallest); - }, - - // min(a, b, c, d, ...) - '...': function () { - return _min(arguments); - } - }); - - /** - * Return the smallest of two values - * @param {*} x - * @param {*} y - * @returns {*} Returns x when x is smallest, or y when y is smallest - * @private - */ - function _smallest(x, y) { - return smaller(x, y) ? x : y; - } - - /** - * Recursively calculate the minimum value in an n-dimensional array - * @param {Array} array - * @return {Number} min - * @private - */ - function _min(array) { - var min = undefined; - - collection.deepForEach(array, function (value) { - if (min === undefined || smaller(value, min)) { - min = value; - } - }); - - if (min === undefined) { - throw new Error('Cannot calculate min of an empty array'); - } - - return min; - } - } - - exports.name = 'min'; - exports.factory = factory; - - -/***/ }, -/* 125 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var multiply = load(__webpack_require__(47)); - - /** - * Compute the product of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the sum of all - * elements will be calculated. - * - * Syntax: - * - * math.prod(a, b, c, ...) - * math.prod(A) - * - * Examples: - * - * math.multiply(2, 3); // returns 6 - * math.prod(2, 3); // returns 6 - * math.prod(2, 3, 4); // returns 24 - * math.prod([2, 3, 4]); // returns 24 - * math.prod([[2, 5], [4, 3]]); // returns 120 - * - * See also: - * - * mean, median, min, max, sum, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The product of all values - */ - return typed('prod', { - // prod([a, b, c, d, ...]) - 'Array | Matrix': _prod, - - // prod([a, b, c, d, ...], dim) - 'Array | Matrix, number | BigNumber': function (array, dim) { - // TODO: implement prod(A, dim) - throw new Error('prod(A, dim) is not yet supported'); - //return collection.reduce(arguments[0], arguments[1], math.prod); - }, - - // prod(a, b, c, d, ...) - '...': function () { - return _prod(arguments); - } - }); - - /** - * Recursively calculate the product of an n-dimensional array - * @param {Array} array - * @return {Number} prod - * @private - */ - function _prod(array) { - var prod = undefined; - - collection.deepForEach(array, function (value) { - prod = (prod === undefined) ? value : multiply(prod, value); - }); - - if (prod === undefined) { - throw new Error('Cannot calculate prod of an empty array'); - } - - return prod; - } - } - - exports.name = 'prod'; - exports.factory = factory; - - -/***/ }, -/* 126 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var sqrt = load(__webpack_require__(53)); - var variance = load(__webpack_require__(128)); - - /** - * Compute the standard deviation of a matrix or a list with values. - * The standard deviations is defined as the square root of the variance: - * `std(A) = sqrt(var(A))`. - * In case of a (multi dimensional) array or matrix, the standard deviation - * over all elements will be calculated. - * - * Optionally, the type of normalization can be specified as second - * parameter. The parameter `normalization` can be one of the following values: - * - * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - * - * Syntax: - * - * math.std(a, b, c, ...) - * math.std(A) - * math.std(A, normalization) - * - * Examples: - * - * math.std(2, 4, 6); // returns 2 - * math.std([2, 4, 6, 8]); // returns 2.581988897471611 - * math.std([2, 4, 6, 8], 'uncorrected'); // returns 2.23606797749979 - * math.std([2, 4, 6, 8], 'biased'); // returns 2 - * - * math.std([[1, 2, 3], [4, 5, 6]]); // returns 1.8708286933869707 - * - * See also: - * - * mean, median, max, min, prod, sum, var - * - * @param {Array | Matrix} array - * A single matrix or or multiple scalar values - * @param {String} [normalization='unbiased'] - * Determines how to normalize the variance. - * Choose 'unbiased' (default), 'uncorrected', or 'biased'. - * @return {*} The standard deviation - */ - return typed('std', { - // std([a, b, c, d, ...]) - 'Array | Matrix': _std, - - // std([a, b, c, d, ...], normalization) - 'Array | Matrix, string': _std, - - // std(a, b, c, d, ...) - '...': function () { - return _std(Array.prototype.slice.call(arguments)); - } - }); - - function _std(array, normalization) { - if (array.length == 0) { - throw new SyntaxError('Function std requires one or more parameters (0 provided)'); - } - - return sqrt(variance.apply(null, arguments)); - } - } - - exports.name = 'std'; - exports.factory = factory; - - -/***/ }, -/* 127 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var add = load(__webpack_require__(32)); - - /** - * Compute the sum of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the sum of all - * elements will be calculated. - * - * Syntax: - * - * math.sum(a, b, c, ...) - * math.sum(A) - * - * Examples: - * - * math.sum(2, 1, 4, 3); // returns 10 - * math.sum([2, 1, 4, 3]); // returns 10 - * math.sum([[2, 5], [4, 3], [1, 7]]); // returns 22 - * - * See also: - * - * mean, median, min, max, prod, std, var - * - * @param {... *} args A single matrix or or multiple scalar values - * @return {*} The sum of all values - */ - return typed('sum', { - 'Array | Matrix': function (args) { - // sum([a, b, c, d, ...]) - return _sum(args); - }, - - 'Array | Matrix, number | BigNumber': function () { - // sum([a, b, c, d, ...], dim) - // TODO: implement sum(A, dim) - throw new Error('sum(A, dim) is not yet supported'); - }, - - '...': function () { - // sum(a, b, c, d, ...) - return _sum(arguments); - } - }); - - /** - * Recursively calculate the sum of an n-dimensional array - * @param {Array} array - * @return {Number} sum - * @private - */ - function _sum(array) { - var sum = undefined; - - collection.deepForEach(array, function (value) { - sum = (sum === undefined) ? value : add(sum, value); - }); - - if (sum === undefined) { - throw new Error('Cannot calculate sum of an empty array'); - } - return sum; - } - } - - exports.name = 'sum'; - exports.factory = factory; - - -/***/ }, -/* 128 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var DEFAULT_NORMALIZATION = 'unbiased'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var add = load(__webpack_require__(32)); - var subtract = load(__webpack_require__(55)); - var multiply = load(__webpack_require__(47)); - var divide = load(__webpack_require__(35)); - - /** - * Compute the variance of a matrix or a list with values. - * In case of a (multi dimensional) array or matrix, the variance over all - * elements will be calculated. - * - * Optionally, the type of normalization can be specified as second - * parameter. The parameter `normalization` can be one of the following values: - * - * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - - * Note that older browser may not like the variable name `var`. In that - * case, the function can be called as `math['var'](...)` instead of - * `math.var(...)`. - * - * Syntax: - * - * math.var(a, b, c, ...) - * math.var(A) - * math.var(A, normalization) - * - * Examples: - * - * math.var(2, 4, 6); // returns 4 - * math.var([2, 4, 6, 8]); // returns 6.666666666666667 - * math.var([2, 4, 6, 8], 'uncorrected'); // returns 5 - * math.var([2, 4, 6, 8], 'biased'); // returns 4 - * - * math.var([[1, 2, 3], [4, 5, 6]]); // returns 3.5 - * - * See also: - * - * mean, median, max, min, prod, std, sum - * - * @param {Array | Matrix} array - * A single matrix or or multiple scalar values - * @param {String} [normalization='unbiased'] - * Determines how to normalize the variance. - * Choose 'unbiased' (default), 'uncorrected', or 'biased'. - * @return {*} The variance - */ - return typed('variance', { - // var([a, b, c, d, ...]) - 'Array | Matrix': function (array) { - return _var(array, DEFAULT_NORMALIZATION); - }, - - // var([a, b, c, d, ...], normalization) - 'Array | Matrix, string': _var, - - // var(a, b, c, d, ...) - '...': function () { - return _var(arguments, DEFAULT_NORMALIZATION); - } - }); - - /** - * Recursively calculate the variance of an n-dimensional array - * @param {Array} array - * @param {String} normalization - * Determines how to normalize the variance: - * - 'unbiased' The sum of squared errors is divided by (n - 1) - * - 'uncorrected' The sum of squared errors is divided by n - * - 'biased' The sum of squared errors is divided by (n + 1) - * @return {Number | BigNumber} variance - * @private - */ - function _var(array, normalization) { - var sum = 0; - var num = 0; - - if (array.length == 0) { - throw new SyntaxError('Function var requires one or more parameters (0 provided)'); - } - - // calculate the mean and number of elements - collection.deepForEach(array, function (value) { - sum = add(sum, value); - num++; - }); - if (num === 0) throw new Error('Cannot calculate var of an empty array'); - - var mean = divide(sum, num); - - // calculate the variance - sum = 0; - collection.deepForEach(array, function (value) { - var diff = subtract(value, mean); - sum = add(sum, multiply(diff, diff)); - }); - - switch (normalization) { - case 'uncorrected': - return divide(sum, num); - - case 'biased': - return divide(sum, num + 1); - - case 'unbiased': - var zero = (sum instanceof type.BigNumber) ? new type.BigNumber(0) : 0; - return (num == 1) ? zero : divide(sum, num - 1); - - default: - throw new Error('Unknown normalization "' + normalization + '". ' + - 'Choose "unbiased" (default), "uncorrected", or "biased".'); - } - } - } - - exports.name = 'var'; - exports.factory = factory; - - -/***/ }, -/* 129 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcCos = __webpack_require__(214).arccos_arcsec; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexSqrt = load(__webpack_require__(53)).signatures['Complex']; - var complexLog = load(__webpack_require__(44)).signatures['Complex']; - - /** - * Calculate the inverse cosine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acos(x) - * - * Examples: - * - * math.acos(0.5); // returns Number 1.0471975511965979 - * math.acos(math.cos(1.5)); // returns Number 1.5 - * - * math.acos(2); // returns Complex 0 + 1.3169578969248166 i - * - * See also: - * - * cos, atan, asin - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} The arc cosine of x - */ - var acos = typed('acos', { - 'number': function (x) { - if (x >= -1 && x <= 1) { - return Math.acos(x); - } - else { - return _complexAcos(new type.Complex(x, 0)); - } - }, - - 'Complex': _complexAcos, - - 'BigNumber': function (x) { - return bigArcCos(x, type.BigNumber, false); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acos); - } - }); - - /** - * Calculate acos for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAcos(x) { - // acos(z) = 0.5*pi + i*log(iz + sqrt(1-z^2)) - var temp1 = new type.Complex( - x.im * x.im - x.re * x.re + 1.0, - -2.0 * x.re * x.im - ); - var temp2 = complexSqrt(temp1); - var temp3 = new type.Complex( - temp2.re - x.im, - temp2.im + x.re - ); - var temp4 = complexLog(temp3); - - // 0.5*pi = 1.5707963267948966192313216916398 - return new type.Complex( - 1.57079632679489661923 - temp4.im, - temp4.re - ); - } - - return acos; - } - - exports.name = 'acos'; - exports.factory = factory; - - -/***/ }, -/* 130 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAcosh = __webpack_require__(214).acosh_asinh_asech_acsch; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexAcos = load(__webpack_require__(129)).signatures['Complex']; - - /** - * Calculate the hyperbolic arccos of a value, - * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acosh(x) - * - * Examples: - * - * math.acosh(1.5); // returns 0.9624236501192069 - * - * See also: - * - * cosh, asinh, atanh - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arccosine of x - */ - var acosh = typed('acosh', { - 'number': function (x) { - if (x >= 1) { - return Math.log(Math.sqrt(x*x - 1) + x); - } - if (x <= -1) { - return new type.Complex(Math.log(Math.sqrt(x*x - 1) - x), Math.PI); - } - return _complexAcosh(new type.Complex(x, 0)); - }, - - 'Complex': _complexAcosh, - - 'BigNumber': function (x) { - return bigAcosh(x, type.BigNumber, false, false); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acosh); - } - }); - - /** - * Calculate acosh for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAcosh(x) { - // acosh(z) = (-acos(z).im, acos(z).re) for acos(z).im <= 0 - // ( acos(z).im, -acos(z).re) otherwise - var temp; - var res = complexAcos(x); - if (res.im <= 0) { - temp = res.re; - res.re = -res.im; - res.im = temp; - } else { - temp = res.im; - res.im = -res.re; - res.re = temp; - } - - return res; - } - - return acosh; - } - - exports.name = 'acosh'; - exports.factory = factory; - - -/***/ }, -/* 131 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcCot = __webpack_require__(214).arctan_arccot; - - var HALF_PI = 1.5707963267948966; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexAtan = load(__webpack_require__(139)).signatures['Complex']; - - /** - * Calculate the inverse cotangent of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acot(x) - * - * Examples: - * - * math.acot(0.5); // returns Number 0.4636476090008061 - * math.acot(math.cot(1.5)); // returns Number 1.5 - * - * math.acot(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * cot, atan - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} The arc cotangent of x - */ - var acot = typed('acot', { - 'number': function (x) { - return (x) ? Math.atan(1 / x) : HALF_PI; - }, - - 'Complex': function (x) { - if (x.im == 0) { - return new type.Complex(x.re ? Math.atan(1 / x.re) : HALF_PI, 0); - } - - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re = x.re / den, - x.im = -x.im / den) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0); - - return complexAtan(x); - }, - - 'BigNumber': function (x) { - return bigArcCot(x, type.BigNumber, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acot); - } - }); - - return acot; - } - - exports.name = 'acot'; - exports.factory = factory; - - -/***/ }, -/* 132 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAcoth = __webpack_require__(214).atanh_acoth; - - var HALF_PI = 1.5707963267948966; - - function factory (type, config, load, typed) { - var atanh = load(__webpack_require__(141)).signatures['Complex']; - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic arccotangent of a value, - * defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acoth(x) - * - * Examples: - * - * math.acoth(0.5); // returns 0.8047189562170503 - * - * See also: - * - * acsch, asech - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arccotangent of x - */ - var acoth = typed('acoth', { - 'number': function (x) { - if (x >= 1 || x <= -1) { - return isFinite(x) ? (Math.log((x+1)/x) + Math.log(x/(x-1))) / 2 : 0; - } - return x !== 0 ? _complexAcoth(new type.Complex(x, 0)) : new type.Complex(0, HALF_PI); - }, - - 'Complex': _complexAcoth, - - 'BigNumber': function (x) { - return bigAcoth(x, type.BigNumber, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acoth); - } - }); - - /** - * Calculate the hyperbolic arccotangent of a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAcoth (x) { - if (x.re == 0 && x.im == 0) { - return new type.Complex(0, HALF_PI); - } - - // acoth(z) = -i*atanh(1/z) - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re / den, - -x.im / den - ) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0 - ); - - return atanh(x); - } - - return acoth; - } - - exports.name = 'acoth'; - exports.factory = factory; - - -/***/ }, -/* 133 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcCsc = __webpack_require__(214).arcsin_arccsc; - - var HALF_PI = 1.5707963267948966; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexAsin = load(__webpack_require__(137)).signatures['Complex']; - - /** - * Calculate the inverse cosecant of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acsc(x) - * - * Examples: - * - * math.acsc(0.5); // returns Number 0.5235987755982989 - * math.acsc(math.csc(1.5)); // returns Number ~1.5 - * - * math.acsc(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * csc, asin, asec - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} The arc cosecant of x - */ - var acsc = typed('acsc', { - 'number': function (x) { - if (x <= -1 || x >= 1) { - return Math.asin(1 / x); - } - return _complexAcsc(new type.Complex(x, 0)); - }, - - 'Complex': _complexAcsc, - - 'BigNumber': function (x) { - return bigArcCsc(x, type.BigNumber, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acsc); - } - }); - - /** - * Calculate acsc for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAcsc (x) { - if (x.re == 0 && x.im == 0) { - return new type.Complex(HALF_PI, Infinity); - } - - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re = x.re / den, - x.im = -x.im / den) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0); - - return complexAsin(x); - } - - return acsc; - } - - exports.name = 'acsc'; - exports.factory = factory; - - -/***/ }, -/* 134 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAcsch = __webpack_require__(214).acosh_asinh_asech_acsch; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var asinh = load(__webpack_require__(138)).signatures['Complex']; - - /** - * Calculate the hyperbolic arccosecant of a value, - * defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.acsch(x) - * - * Examples: - * - * math.acsch(0.5); // returns 1.4436354751788103 - * - * See also: - * - * asech, acoth - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arccosecant of x - */ - var acsch = typed('acsch', { - 'number': function (x) { - x = 1 / x; - return Math.log(x + Math.sqrt(x*x + 1)); - }, - - 'Complex': function (x) { - if (x.im == 0) { - x = (x.re != 0) - ? Math.log(x.re + Math.sqrt(x.re*x.re + 1)) - : Infinity; - return new type.Complex(x, 0); - } - - // acsch(z) = -i*asinh(1/z) - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re / den, - -x.im / den - ) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0 - ); - - return asinh(x); - }, - - 'BigNumber': function (x) { - return bigAcsch(x, type.BigNumber, true, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, acsch); - } - }); - - return acsch; - } - - exports.name = 'acsch'; - exports.factory = factory; - - -/***/ }, -/* 135 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcSec = __webpack_require__(214).arccos_arcsec; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexAcos = load(__webpack_require__(129)).signatures['Complex']; - - /** - * Calculate the inverse secant of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asec(x) - * - * Examples: - * - * math.asec(0.5); // returns 1.0471975511965979 - * math.asec(math.sec(1.5)); // returns 1.5 - * - * math.asec(2); // returns 0 + 1.3169578969248166 i - * - * See also: - * - * acos, acot, acsc - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} The arc secant of x - */ - var asec = typed('asec', { - 'number': function (x) { - if (x <= -1 || x >= 1) { - return Math.acos(1 / x); - } - return _complexAsec(new type.Complex(x, 0)); - }, - - 'Complex': _complexAsec, - - 'BigNumber': function (x) { - return bigArcSec(x, type.BigNumber, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, asec); - } - }); - - /** - * Calculate asec for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAsec (x) { - if (x.re == 0 && x.im == 0) { - return new type.Complex(0, Infinity); - } - - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re = x.re / den, - x.im = -x.im / den) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0); - - return complexAcos(x); - } - - return asec; - } - - exports.name = 'asec'; - exports.factory = factory; - - -/***/ }, -/* 136 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAsech = __webpack_require__(214).acosh_asinh_asech_acsch; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var acosh = load(__webpack_require__(130)).signatures['Complex']; - - /** - * Calculate the hyperbolic arcsecant of a value, - * defined as `asech(x) = ln(sqrt(1/x^2 - 1) + 1/x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asech(x) - * - * Examples: - * - * math.asech(0.5); // returns 1.3169578969248166 - * - * See also: - * - * acsch, acoth - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arcsecant of x - */ - var asech = typed('asech', { - 'number': function (x) { - if (x <= 1 && x >= -1) { - x = 1 / x; - - var ret = Math.sqrt(x*x - 1); - if (x > 0) { - return Math.log(ret + x); - } - - return new type.Complex(Math.log(ret - x), Math.PI); - } - - return _complexAsech(new type.Complex(x, 0)); - }, - - 'Complex': _complexAsech, - - 'BigNumber': function (x) { - return bigAsech(x, type.BigNumber, false, true); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, asech); - } - }); - - /** - * Calculate the hyperbolic arcsecant of a number - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAsech (x) { - if (x.re == 0 && x.im == 0) { - return new type.Complex(Infinity, 0); - } - - // acsch(z) = -i*asinh(1/z) - var den = x.re*x.re + x.im*x.im; - x = (den != 0) - ? new type.Complex( - x.re / den, - -x.im / den - ) - : new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? -(x.im / 0) : 0 - ); - - return acosh(x); - } - - return asech; - } - - exports.name = 'asech'; - exports.factory = factory; - - -/***/ }, -/* 137 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcSin = __webpack_require__(214).arcsin_arccsc; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexSqrt = load(__webpack_require__(53)).signatures['Complex']; - var complexLog = load(__webpack_require__(44)).signatures['Complex']; - - /** - * Calculate the inverse sine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asin(x) - * - * Examples: - * - * math.asin(0.5); // returns Number 0.5235987755982989 - * math.asin(math.sin(1.5)); // returns Number ~1.5 - * - * math.asin(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * sin, atan, acos - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} The arc sine of x - */ - var asin = typed('asin', { - 'number': function (x) { - if (x >= -1 && x <= 1) { - return Math.asin(x); - } - else { - return _complexAsin(new type.Complex(x, 0)); - } - }, - - 'Complex': _complexAsin, - - 'BigNumber': function (x) { - return bigArcSin(x, type.BigNumber, false); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since asin(0) = 0 - return collection.deepMap(x, asin, true); - } - }); - - /** - * Calculate asin for a complex value - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAsin(x) { - // asin(z) = -i*log(iz + sqrt(1-z^2)) - var re = x.re; - var im = x.im; - var temp1 = new type.Complex( - im * im - re * re + 1.0, - -2.0 * re * im - ); - var temp2 = complexSqrt(temp1); - var temp3 = new type.Complex( - temp2.re - im, - temp2.im + re - ); - var temp4 = complexLog(temp3); - - return new type.Complex(temp4.im, -temp4.re); - } - - return asin; - } - - exports.name = 'asin'; - exports.factory = factory; - - -/***/ }, -/* 138 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAsinh = __webpack_require__(214).acosh_asinh_asech_acsch; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexAsin = load(__webpack_require__(137)).signatures['Complex']; - - /** - * Calculate the hyperbolic arcsine of a value, - * defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.asinh(x) - * - * Examples: - * - * math.asinh(0.5); // returns 0.48121182505960347 - * - * See also: - * - * acosh, atanh - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arcsine of x - */ - var asinh = typed('asinh', { - 'number': function (x) { - return Math.log(Math.sqrt(x*x + 1) + x); - }, - - 'Complex': function (x) { - // asinh(z) = (-asin((z.im, -z.re)).im, asin((z.im, -z.re)).re) - var temp = x.im; - x.im = -x.re; - x.re = temp; - - var res = complexAsin(x); - - // restore original values - x.re = -x.im; - x.im = temp; - - temp = res.re; - res.re = -res.im; - res.im = temp; - - return res; - }, - - 'BigNumber': function (x) { - return bigAsinh(x, type.BigNumber, true, false); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since asinh(0) = 0 - return collection.deepMap(x, asinh, true); - } - }); - - return asinh; - } - - exports.name = 'asinh'; - exports.factory = factory; - - -/***/ }, -/* 139 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigArcTan = __webpack_require__(214).arctan_arccot; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var complexLog = load(__webpack_require__(44)).signatures['Complex']; - - /** - * Calculate the inverse tangent of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atan(x) - * - * Examples: - * - * math.atan(0.5); // returns Number 0.4636476090008061 - * math.atan(math.tan(1.5)); // returns Number 1.5 - * - * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * tan, asin, acos - * - * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} The arc tangent of x - */ - var atan = typed('atan', { - 'number': function (x) { - return Math.atan(x); - }, - - 'Complex': function (x) { - if (x.re == 0) { - if (x.im == 1) { - return new type.Complex(0, Infinity); - } - if (x.im == -1) { - return new type.Complex(0, -Infinity); - } - } - - // atan(z) = 1/2 * i * (ln(1-iz) - ln(1+iz)) - var re = x.re; - var im = x.im; - var den = re * re + (1.0 - im) * (1.0 - im); - - var temp1 = new type.Complex( - (1.0 - im * im - re * re) / den, - (-2.0 * re) / den - ); - var temp2 = complexLog(temp1); - - return new type.Complex( - -0.5 * temp2.im, - 0.5 * temp2.re - ); - }, - - 'BigNumber': function (x) { - return bigArcTan(x, type.BigNumber, false); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since atan(0) = 0 - return collection.deepMap(x, atan, true); - } - }); - - return atan; - } - - exports.name = 'atan'; - exports.factory = factory; - - -/***/ }, -/* 140 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAtan2 = __webpack_require__(214).arctan2; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the inverse tangent function with two arguments, y/x. - * By providing two arguments, the right quadrant of the computed angle can be - * determined. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atan2(y, x) - * - * Examples: - * - * math.atan2(2, 2) / math.pi; // returns number 0.25 - * - * var angle = math.unit(60, 'deg'); // returns Unit 60 deg - * var x = math.cos(angle); - * var y = math.sin(angle); - * - * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i - * - * See also: - * - * tan, atan, sin, cos - * - * @param {Number | Boolean | Array | Matrix | null} y Second dimension - * @param {Number | Boolean | Array | Matrix | null} x First dimension - * @return {Number | Array | Matrix} Four-quadrant inverse tangent - */ - var atan2 = typed('atan2', { - 'number, number': Math.atan2, - - // TODO: implement atan2 for complex numbers - - 'BigNumber, BigNumber': function (y, x) { - return bigAtan2(y, x, type.BigNumber); - }, - - 'Array | Matrix, any': function (y, x) { - return collection.deepMap2(y, x, atan2); - }, - - 'any, Array | Matrix': function (y, x) { - return collection.deepMap2(y, x, atan2); - } - }); - - return atan2; - } - - exports.name = 'atan2'; - exports.factory = factory; - - -/***/ }, -/* 141 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigAtanh = __webpack_require__(214).atanh_acoth; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic arctangent of a value, - * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.atanh(x) - * - * Examples: - * - * math.atanh(0.5); // returns 0.5493061443340549 - * - * See also: - * - * acosh, asinh - * - * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic arctangent of x - */ - var atanh = typed('atanh', { - 'number': function (x) { - if (x <= 1 && x >= -1) { - return Math.log((1 + x)/(1 - x)) / 2; - } - return _complexAtanh(new type.Complex(x, 0)); - }, - - 'Complex': _complexAtanh, - - 'BigNumber': function (x) { - return bigAtanh(x, type.BigNumber, false); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since atanh(0) = 0 - return collection.deepMap(x, atanh, true); - } - }); - - /** - * Calculate the hyperbolic arctangent of a complex number - * @param {Complex} x - * @returns {Complex} - * @private - */ - function _complexAtanh (x) { - // x.im should equal -pi / 2 in this case - var noIM = x.re > 1 && x.im == 0; - - var oneMinus = 1 - x.re; - var onePlus = 1 + x.re; - var den = oneMinus*oneMinus + x.im*x.im; - x = (den != 0) - ? new type.Complex( - (onePlus*oneMinus - x.im*x.im) / den, - (x.im*oneMinus + onePlus*x.im) / den - ) - : new type.Complex( - (x.re != -1) ? (x.re / 0) : 0, - (x.im != 0) ? (x.im / 0) : 0 - ); - - var temp = x.re; - x.re = Math.log(Math.sqrt(x.re*x.re + x.im*x.im)) / 2; - x.im = Math.atan2(x.im, temp) / 2; - - if (noIM) { - x.im = -x.im; - } - return x; - } - - return atanh; - } - - exports.name = 'atanh'; - exports.factory = factory; - - -/***/ }, -/* 142 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCos = __webpack_require__(214).cos_sin_sec_csc; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - var cosh = load(__webpack_require__(143)).signatures['number']; - var sinh = load(__webpack_require__(151)).signatures['number']; - - /** - * Calculate the cosine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cos(x) - * - * Examples: - * - * math.cos(2); // returns Number -0.4161468365471422 - * math.cos(math.pi / 4); // returns Number 0.7071067811865475 - * math.cos(math.unit(180, 'deg')); // returns Number -1 - * math.cos(math.unit(60, 'deg')); // returns Number 0.5 - * - * var angle = 0.2; - * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns Number ~1 - * - * See also: - * - * cos, tan - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Cosine of x - */ - var cos = typed('cos', { - 'number': Math.cos, - - 'Complex': function (x) { - // cos(z) = (exp(iz) + exp(-iz)) / 2 - return new type.Complex( - Math.cos(x.re) * cosh(-x.im), - Math.sin(x.re) * sinh(-x.im) - ); - }, - - 'BigNumber': function (x) { - return bigCos(x, type.BigNumber, 0, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cos is no angle'); - } - return Math.cos(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, cos); - } - }); - - return cos; - } - - exports.name = 'cos'; - exports.factory = factory; - - -/***/ }, -/* 143 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCosh = __webpack_require__(214).cosh_sinh_csch_sech; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic cosine of a value, - * defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cosh(x) - * - * Examples: - * - * math.cosh(0.5); // returns Number 1.1276259652063807 - * - * See also: - * - * sinh, tanh - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic cosine of x - */ - var cosh = typed('cosh', { - 'number': _cosh, - - 'Complex': function (x) { - var ep = Math.exp(x.re); - var en = Math.exp(-x.re); - return new type.Complex(Math.cos(x.im) * (ep + en) / 2, Math.sin(x.im) * (ep - en) / 2); - }, - - 'BigNumber': function (x) { - return bigCosh(x, type.BigNumber, false, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cosh is no angle'); - } - return _cosh(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, cosh); - } - }); - - return cosh; - } - - /** - * Calculate the hyperbolic cosine of a number - * @param {number} x - * @returns {number} - * @private - */ - function _cosh(x) { - return (Math.exp(x) + Math.exp(-x)) / 2; - } - - exports.name = 'cosh'; - exports.factory = factory; - - -/***/ }, -/* 144 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCot = __webpack_require__(214).tan_cot; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the cotangent of a value. `cot(x)` is defined as `1 / tan(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.cot(x) - * - * Examples: - * - * math.cot(2); // returns Number -0.45765755436028577 - * 1 / math.tan(2); // returns Number -0.45765755436028577 - * - * See also: - * - * tan, sec, csc - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Cotangent of x - */ - var cot = typed('cot', { - 'number': function (x) { - return 1 / Math.tan(x); - }, - - 'Complex': function (x) { - var den = - Math.exp(-4 * x.im) - - 2 * Math.exp(-2 * x.im) * Math.cos(2 * x.re) + 1; - - return new type.Complex( - 2 * Math.exp(-2 * x.im) * Math.sin(2 * x.re) / den, - (Math.exp(-4 * x.im) - 1) / den - ); - }, - - 'BigNumber': function (x) { - return bigCot(x, type.BigNumber, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function cot is no angle'); - } - return 1 / Math.tan(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, cot); - } - }); - - return cot; - } - - exports.name = 'cot'; - exports.factory = factory; - - -/***/ }, -/* 145 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCoth = __webpack_require__(214).tanh_coth; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic cotangent of a value, - * defined as `coth(x) = 1 / tanh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.coth(x) - * - * Examples: - * - * // coth(x) = 1 / tanh(x) - * math.coth(2); // returns 1.0373147207275482 - * 1 / math.tanh(2); // returns 1.0373147207275482 - * - * See also: - * - * sinh, tanh, cosh - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic cotangent of x - */ - var coth = typed('coth', { - 'number': _coth, - - 'Complex': function (x) { - var r = Math.exp(2 * x.re); - var re = r * Math.cos(2 * x.im); - var im = r * Math.sin(2 * x.im); - var den = (re - 1) * (re - 1) + im * im; - return new type.Complex( - ((re + 1) * (re - 1) + im * im) / den, - -2 * im / den - ); - }, - - 'BigNumber': function (x) { - return bigCoth(x, type.BigNumber, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function coth is no angle'); - } - return _coth(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, coth); - } - }); - - return coth; - } - - /** - * Calculate the hyperbolic cosine of a number - * @param {number} x - * @returns {number} - * @private - */ - function _coth(x) { - var e = Math.exp(2 * x); - return (e + 1) / (e - 1); - } - - exports.name = 'coth'; - exports.factory = factory; - - -/***/ }, -/* 146 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCsc = __webpack_require__(214).cos_sin_sec_csc; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.csc(x) - * - * Examples: - * - * math.csc(2); // returns Number 1.099750170294617 - * 1 / math.sin(2); // returns Number 1.099750170294617 - * - * See also: - * - * sin, sec, cot - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Cosecant of x - */ - var csc = typed('csc', { - 'number': function (x) { - return 1 / Math.sin(x); - }, - - 'Complex': function (x) { - // csc(z) = 1/sin(z) = (2i) / (exp(iz) - exp(-iz)) - var den = - 0.25 * (Math.exp(-2 * x.im) + Math.exp(2 * x.im)) - - 0.5 * Math.cos(2 * x.re); - - return new type.Complex ( - 0.5 * Math.sin(x.re) * (Math.exp(-x.im) + Math.exp(x.im)) / den, - 0.5 * Math.cos(x.re) * (Math.exp(-x.im) - Math.exp(x.im)) / den - ); - }, - - 'BigNumber': function (x) { - return bigCsc(x, type.BigNumber, 1, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function csc is no angle'); - } - return 1 / Math.sin(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, csc); - } - }); - - return csc; - } - - exports.name = 'csc'; - exports.factory = factory; - - -/***/ }, -/* 147 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigCsch = __webpack_require__(214).cosh_sinh_csch_sech; - var sign = __webpack_require__(175).sign; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic cosecant of a value, - * defined as `csch(x) = 1 / sinh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.csch(x) - * - * Examples: - * - * // csch(x) = 1/ sinh(x) - * math.csch(0.5); // returns 1.9190347513349437 - * 1 / math.sinh(0.5); // returns 1.9190347513349437 - * - * See also: - * - * sinh, sech, coth - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic cosecant of x - */ - var csch = typed('csch', { - 'number': _csch, - - 'Complex': function (x) { - var ep = Math.exp(x.re); - var en = Math.exp(-x.re); - var re = Math.cos(x.im) * (ep - en); - var im = Math.sin(x.im) * (ep + en); - var den = re * re + im * im; - return new type.Complex(2 * re / den, -2 * im /den); - }, - - 'BigNumber': function (x) { - return bigCsch(x, type.BigNumber, true, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function csch is no angle'); - } - return _csch(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, csch); - } - }); - - return csch; - } - - /** - * Calculate the hyperbolic cosecant of a number - * @param {number} x - * @returns {number} - * @private - */ - function _csch(x) { - // consider values close to zero (+/-) - if (x == 0) { - return Number.POSITIVE_INFINITY; - } - else { - return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x); - } - } - - exports.name = 'csch'; - exports.factory = factory; - - -/***/ }, -/* 148 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigSec = __webpack_require__(214).cos_sin_sec_csc; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sec(x) - * - * Examples: - * - * math.sec(2); // returns Number -2.4029979617223822 - * 1 / math.cos(2); // returns Number -2.4029979617223822 - * - * See also: - * - * cos, csc, cot - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Secant of x - */ - var sec = typed('sec', { - 'number': function (x) { - return 1 / Math.cos(x); - }, - - 'Complex': function (x) { - // sec(z) = 1/cos(z) = 2 / (exp(iz) + exp(-iz)) - var den = - 0.25 * (Math.exp(-2 * x.im) + Math.exp(2 * x.im)) + - 0.5 * Math.cos(2 * x.re); - - return new type.Complex( - 0.5 * Math.cos(x.re) * (Math.exp(-x.im) + Math.exp( x.im)) / den, - 0.5 * Math.sin(x.re) * (Math.exp( x.im) - Math.exp(-x.im)) / den - ); - }, - - 'BigNumber': function (x) { - return bigSec(x, type.BigNumber, 0, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sec is no angle'); - } - return 1 / Math.cos(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, sec); - } - }); - - return sec; - } - - exports.name = 'sec'; - exports.factory = factory; - - -/***/ }, -/* 149 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigSech = __webpack_require__(214).cosh_sinh_csch_sech; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic secant of a value, - * defined as `sech(x) = 1 / cosh(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sech(x) - * - * Examples: - * - * // sech(x) = 1/ cosh(x) - * math.sech(0.5); // returns 0.886818883970074 - * 1 / math.cosh(0.5); // returns 0.886818883970074 - * - * See also: - * - * cosh, csch, coth - * - * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | Complex | Array | Matrix} Hyperbolic secant of x - */ - var sech = typed('sech', { - 'number': _sech, - - 'Complex': function (x) { - var ep = Math.exp(x.re); - var en = Math.exp(-x.re); - var re = Math.cos(x.im) * (ep + en); - var im = Math.sin(x.im) * (ep - en); - var den = re * re + im * im; - return new type.Complex(2 * re / den, -2 * im / den); - }, - - 'BigNumber': function (x) { - return bigSech(x, type.BigNumber, false, true); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sech is no angle'); - } - return _sech(x.value); - }, - - 'Array | Matrix': function (x) { - return collection.deepMap(x, sech); - } - }); - - return sech; - } - - /** - * Calculate the hyperbolic secant of a number - * @param {number} x - * @returns {number} - * @private - */ - function _sech(x) { - return 2 / (Math.exp(x) + Math.exp(-x)); - } - - exports.name = 'sech'; - exports.factory = factory; - - -/***/ }, -/* 150 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigSin = __webpack_require__(214).cos_sin_sec_csc; - - function factory (type, config, load, typed) { - var cosh = load(__webpack_require__(143)).signatures['number']; - var sinh = load(__webpack_require__(151)).signatures['number']; - var collection = load(__webpack_require__(2)); - - /** - * Calculate the sine of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sin(x) - * - * Examples: - * - * math.sin(2); // returns Number 0.9092974268256813 - * math.sin(math.pi / 4); // returns Number 0.7071067811865475 - * math.sin(math.unit(90, 'deg')); // returns Number 1 - * math.sin(math.unit(30, 'deg')); // returns Number 0.5 - * - * var angle = 0.2; - * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns Number ~1 - * - * See also: - * - * cos, tan - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Sine of x - */ - var sin = typed('sin', { - 'number': Math.sin, - - 'Complex': function (x) { - return new type.Complex( - Math.sin(x.re) * cosh(-x.im), - Math.cos(x.re) * sinh(x.im) - ); - }, - - 'BigNumber': function (x) { - return bigSin(x, type.BigNumber, 1, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sin is no angle'); - } - return Math.sin(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sin(0) = 0 - return collection.deepMap(x, sin, true); - } - }); - - return sin; - } - - exports.name = 'sin'; - exports.factory = factory; - - -/***/ }, -/* 151 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigSinh = __webpack_require__(214).cosh_sinh_csch_sech; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic sine of a value, - * defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.sinh(x) - * - * Examples: - * - * math.sinh(0.5); // returns Number 0.5210953054937474 - * - * See also: - * - * cosh, tanh - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic sine of x - */ - var sinh = typed('sinh', { - 'number': _sinh, - - 'Complex': function (x) { - var cim = Math.cos(x.im); - var sim = Math.sin(x.im); - var ep = Math.exp(x.re); - var en = Math.exp(-x.re); - return new type.Complex(cim * (ep - en) / 2, sim * (ep + en) / 2); - }, - - 'BigNumber': function (x) { - return bigSinh(x, type.BigNumber, true, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function sinh is no angle'); - } - return _sinh(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since sinh(0) = 0 - return collection.deepMap(x, sinh, true); - } - }); - - return sinh; - } - - /** - * Calculate the hyperbolic sine of a number - * @param {number} x - * @returns {number} - * @private - */ - function _sinh (x) { - if (Math.abs(x) < 1) { - return x + (x * x * x) / 6 + (x * x * x * x * x) / 120; - } else { - return (Math.exp(x) - Math.exp(-x)) / 2; - } - } - - exports.name = 'sinh'; - exports.factory = factory; - - -/***/ }, -/* 152 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigTan = __webpack_require__(214).tan_cot; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the tangent of a value. `tan(x)` is equal to `sin(x) / cos(x)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.tan(x) - * - * Examples: - * - * math.tan(0.5); // returns Number 0.5463024898437905 - * math.sin(0.5) / math.cos(0.5); // returns Number 0.5463024898437905 - * math.tan(math.pi / 4); // returns Number 1 - * math.tan(math.unit(45, 'deg')); // returns Number 1 - * - * See also: - * - * atan, sin, cos - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Tangent of x - */ - var tan = typed('tan', { - 'number': Math.tan, - - 'Complex': function (x) { - var den = - Math.exp(-4 * x.im) + - 2 * Math.exp(-2 * x.im) * Math.cos(2 * x.re) + - 1; - - return new type.Complex( - 2 * Math.exp(-2 * x.im) * Math.sin(2 * x.re) / den, - (1 - Math.exp(-4 * x.im)) / den - ); - }, - - 'BigNumber': function (x) { - return bigTan(x, type.BigNumber, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function tan is no angle'); - } - return Math.tan(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since tan(0) = 0 - return collection.deepMap(x, tan, true); - } - }); - - return tan; - } - - exports.name = 'tan'; - exports.factory = factory; - - -/***/ }, -/* 153 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var bigTanh = __webpack_require__(214).tanh_coth; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Calculate the hyperbolic tangent of a value, - * defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.tanh(x) - * - * Examples: - * - * // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x) - * math.tanh(0.5); // returns 0.46211715726000974 - * math.sinh(0.5) / math.cosh(0.5); // returns 0.46211715726000974 - * 1 / math.coth(0.5); // returns 0.46211715726000974 - * - * See also: - * - * sinh, cosh, coth - * - * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input - * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic tangent of x - */ - var tanh = typed('tanh', { - 'number': _tanh, - - 'Complex': function (x) { - var r = Math.exp(2 * x.re); - var re = r * Math.cos(2 * x.im); - var im = r * Math.sin(2 * x.im); - var den = (re + 1) * (re + 1) + im * im; - return new type.Complex( - ((re - 1) * (re + 1) + im * im) / den, - im * 2 / den - ); - }, - - 'BigNumber': function (x) { - return bigTanh(x, type.BigNumber, false); - }, - - 'Unit': function (x) { - if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { - throw new TypeError ('Unit in function tanh is no angle'); - } - return _tanh(x.value); - }, - - 'Array | Matrix': function (x) { - // deep map collection, skip zeros since tanh(0) = 0 - return collection.deepMap(x, tanh, true); - } - }); - - return tanh; - } - - /** - * Calculate the hyperbolic tangent of a number - * @param {number} x - * @returns {number} - * @private - */ - function _tanh (x) { - var e = Math.exp(2 * x); - return (e - 1) / (e + 1); - } - - exports.name = 'tanh'; - exports.factory = factory; - - -/***/ }, -/* 154 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - var collection = load(__webpack_require__(2)); - - /** - * Change the unit of a value. - * - * For matrices, the function is evaluated element wise. - * - * Syntax: - * - * math.to(x, unit) - * - * Examples: - * - * math.to(math.unit('2 inch'), 'cm'); // returns Unit 5.08 cm - * math.to(math.unit('2 inch'), math.unit(null, 'cm')); // returns Unit 5.08 cm - * math.to(math.unit(16, 'bytes'), 'bits'); // returns Unit 128 bits - * - * See also: - * - * unit - * - * @param {Unit | Array | Matrix} x The unit to be converted. - * @param {Unit | Array | Matrix} unit New unit. Can be a string like "cm" - * or a unit without value. - * @return {Unit | Array | Matrix} value with changed, fixed unit. - */ - var to = typed('to', { - 'Unit, Unit | string': function (x, unit) { - return x.to(unit); - }, - - 'Array | Matrix, any': function (x, unit) { - return collection.deepMap2(x, unit, to); - }, - - 'any, Array | Matrix': function (x, unit) { - return collection.deepMap2(x, unit, to); - } - }); - - return to; - } - - exports.name = 'to'; - exports.factory = factory; - - -/***/ }, -/* 155 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object= __webpack_require__(166); - - function factory (type, config, load, typed) { - /** - * Clone an object. - * - * Syntax: - * - * math.clone(x) - * - * Examples: - * - * math.clone(3.5); // returns number 3.5 - * math.clone(math.complex('2 - 4i'); // returns Complex 2 - 4i - * math.clone(math.unit(45, 'deg')); // returns Unit 45 deg - * math.clone([[1, 2], [3, 4]]); // returns Array [[1, 2], [3, 4]] - * math.clone("hello world"); // returns string "hello world" - * - * @param {*} x Object to be cloned - * @return {*} A clone of object x - */ - return typed('clone', { - 'any': object.clone - }); - } - - exports.name = 'clone'; - exports.factory = factory; - - -/***/ }, -/* 156 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var object = __webpack_require__(166); - - function factory (type, config, load, typed, math) { - /** - * Set configuration options for math.js, and get current options - * @param {Object} [options] Available options: - * {String} matrix - * A string 'matrix' (default) or 'array'. - * {String} number - * A string 'number' (default) or 'bignumber' - * {Number} precision - * The number of significant digits for BigNumbers. - * Not applicable for Numbers. - * @return {Object} Returns the current configuration - */ - return function _config(options) { - if (options) { - // merge options - object.deepExtend(config, options); - - if (options.precision && type.BigNumber) { - type.BigNumber.config({ - precision: options.precision - }); - } - - // reload the constants (they depend on option number and precision) - // this must be done after math.type.BigNumber.config is applied - // TODO: this is an ugly solution, refreshing the constants like this - __webpack_require__(169)(math, config); - } - - // return a clone of the settings - return object.clone(config); - }; - } - - exports.name = 'config'; - exports.math = true; // request the math namespace as fifth argument - exports.factory = factory; - - -/***/ }, -/* 157 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - - /** - * Sort the items in a matrix. - * - * Syntax: - * - * math.filter(x, test) - * - * Examples: - * - * function isPositive (x) { - * return x > 0; - * } - * math.filter([6, -2, -1, 4, 3], isPositive); // returns [6, 4, 3] - * - * math.filter(["23", "foo", "100", "55", "bar"], /[0-9]+/); // returns ["23", "100", "55"] - * - * See also: - * - * forEach, map, sort - * - * @param {Matrix | Array} x A one dimensional matrix or array to filter - * @param {function | RegExp} test - * A function or regular expression to test items. - * When `test` is a function, it must return a boolean. - * All entries for which `test` returns true are returned. - * @return {Matrix | Array} Returns the filtered matrix. - */ - return typed('filter', { - 'Array, function': _filterCallback, - - 'Array, RegExp': _filterRegExp, - - 'Matrix, function': function (x, test) { - return matrix(_filterCallback(x.toArray(), test)); - }, - - 'Matrix, RegExp': function (x, test) { - return matrix(_filterRegExp(x.toArray(), test)); - } - }); - } - - /** - * Filter values in a callback given a callback function - * @param {Array} x - * @param {function} callback - * @return {Array} Returns the filtered array - * @private - */ - function _filterCallback (x, callback) { - if (size(x).length !== 1) { - throw new Error('Only one dimensional matrices supported'); - } - - return x.filter(function (entry) { - return callback(entry); - }); - } - - /** - * Filter values in a callback given a regular expression - * @param {Array} x - * @param {function} regexp - * @return {Array} Returns the filtered array - * @private - */ - function _filterRegExp (x, regexp) { - if (size(x).length !== 1) { - throw new Error('Only one dimensional matrices supported'); - } - - return x.filter(function (entry) { - return regexp.test(entry); - }); - } - - exports.name = 'filter'; - exports.factory = factory; - - -/***/ }, -/* 158 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var string = __webpack_require__(176); - - function factory (type, config, load, typed) { - /** - * Format a value of any type into a string. - * - * Syntax: - * - * math.format(value) - * math.format(value, options) - * math.format(value, precision) - * math.format(value, fn) - * - * Where: - * - * - `value: *` - * The value to be formatted - * - `options: Object` - * An object with formatting options. Available options: - * - `notation: String` - * Number notation. Choose from: - * - 'fixed' - * Always use regular number notation. - * For example '123.40' and '14000000' - * - '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 exponential notation elsewhere. - * Lower bound is included, upper bound is excluded. - * For example '123.4' and '1.4e7'. - * - `precision: Number` - * A number between 0 and 16 to round the digits of the number. In case - * of notations 'exponential' and 'auto', `precision` defines the total - * number of significant digits returned and is undefined by default. - * In case of notation 'fixed', `precision` defines the number of - * significant digits after the decimal point, and is 0 by default. - * - `exponential: Object` - * An object containing two parameters, {Number} lower and {Number} upper, - * used by notation 'auto' to determine when to return exponential - * notation. Default values are `lower=1e-3` and `upper=1e5`. Only - * applicable for notation `auto`. - * - `fn: Function` - * A custom formatting function. Can be used to override the built-in notations. - * Function `fn` is called with `value` as parameter and must return a string. - * Is useful for example to format all values inside a matrix in a particular way. - * - * Examples: - * - * math.format(6.4); // returns '6.4' - * math.format(1240000); // returns '1.24e6' - * math.format(1/3); // returns '0.3333333333333333' - * math.format(1/3, 3); // returns '0.333' - * math.format(21385, 2); // returns '21000' - * math.format(12.071, {notation: 'fixed'}); // returns '12' - * math.format(2.3, {notation: 'fixed', precision: 2}); // returns '2.30' - * math.format(52.8, {notation: 'exponential'}); // returns '5.28e+1' - * - * See also: - * - * print - * - * @param {*} value Value to be stringified - * @param {Object | Function | Number} [options] Formatting options - * @return {String} The formatted value - */ - return typed('format', { - 'any': string.format, - 'any, Object | function | number': string.format - }); - } - - exports.name = 'format'; - exports.factory = factory; - - -/***/ }, -/* 159 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Create a new matrix or array with the results of the callback function executed on - * each entry of the matrix/array. - * - * Syntax: - * - * math.map(x, callback) - * - * Examples: - * - * math.map([1, 2, 3], function(value) { - * return value * value; - * }); // returns [1, 4, 9] - * - * See also: - * - * filter, forEach, sort - * - * @param {Matrix | Array} x The matrix to iterate on. - * @param {Function} callback The callback method is invoked with three - * parameters: the value of the element, the index - * of the element, and the matrix being traversed. - * @return {Matrix | array} Transformed map of x - */ - return typed('map', { - 'Array, function': _map, - - 'Matrix, function': function (x, callback) { - return x.map(callback); - } - }); - } - - /** - * Map for a multi dimensional array - * @param {Array} array - * @param {function} callback - * @return {Array} - * @private - */ - function _map (array, callback) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - return value.map(function (child, i) { - // we create a copy of the index array and append the new index value - return recurse(child, index.concat(i)); - }); - } - else { - return callback(value, index, array); - } - }; - - return recurse(array, []); - } - - exports.name = 'map'; - exports.factory = factory; - - -/***/ }, -/* 160 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isString = __webpack_require__(176).isString; - var format = __webpack_require__(176).format; - - function factory (type, config, load, typed) { - /** - * Interpolate values into a string template. - * - * Syntax: - * - * math.print(template, values) - * math.print(template, values, precision) - * - * Example usage: - * - * // the following outputs: 'Lucy is 5 years old' - * math.print('Lucy is $age years old', {age: 5}); - * - * // the following outputs: 'The value of pi is 3.141592654' - * math.print('The value of pi is $pi', {pi: math.pi}, 10); - * - * // the following outputs: 'hello Mary! The date is 2013-03-23' - * math.print('Hello $user.name! The date is $date', { - * user: { - * name: 'Mary', - * }, - * date: new Date(2013, 2, 23).toISOString().substring(0, 10) - * }); - * - * See also: - * - * format - * - * @param {String} template A string containing variable placeholders. - * @param {Object} values An object containing variables which will - * be filled in in the template. - * @param {Number} [precision] Number of digits to format numbers. - * If not provided, the value will not be rounded. - * @return {String} Interpolated string - */ - return typed ('print', { - 'string, Object': _print, - 'string, Object, number': _print - }); - } - - /** - * Interpolate values into a string template. - * @param {string} template - * @param {Object} values - * @param {number} [precision] - * @returns {string} Interpolated string - * @private - */ - function _print(template, values, precision) { - return template.replace(/\$([\w\.]+)/g, function (original, key) { - var keys = key.split('.'); - var value = values[keys.shift()]; - while (keys.length && value !== undefined) { - var k = keys.shift(); - value = k ? value[k] : value + '.'; - } - - if (value !== undefined) { - if (!isString(value)) { - return format(value, precision); - } - else { - return value; - } - } - - return original; - } - ); - } - - exports.name = 'print'; - exports.factory = factory; - - -/***/ }, -/* 161 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var size = __webpack_require__(172).size; - - function factory (type, config, load, typed) { - var matrix = load(__webpack_require__(75)); - var asc = load(__webpack_require__(113)); - var desc = function (a, b) { - return -asc(a, b); - }; - - /** - * Sort the items in a matrix. - * - * Syntax: - * - * math.sort(x) - * math.sort(x, compare) - * - * Examples: - * - * math.sort([5, 10, 1]); // returns [1, 5, 10] - * math.sort(['C', 'B', 'A', 'D']); // returns ['A', 'B', 'C', 'D'] - * - * function sortByLength (a, b) { - * return a.length - b.length; - * } - * math.sort(['Langdon', 'Tom', 'Sara'], sortByLength); // returns ['Tom', 'Sara', 'Langdon'] - * - * See also: - * - * filter, forEach, map - * - * @param {Matrix | Array} x A one dimensional matrix or array to sort - * @param {Function | 'asc' | 'desc'} [compare='asc'] - * An optional _comparator function. The function is called as - * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, - * and 0 when a == b. - * @return {Matrix | Array} Returns the sorted matrix. - */ - return typed('sort', { - 'Array': function (x) { - _arrayIsVector(x); - return x.sort(asc); - }, - - 'Matrix': function (x) { - _matrixIsVector(x); - return matrix(x.toArray().sort(asc), x.storage()); - }, - - 'Array, function': function (x, _comparator) { - _arrayIsVector(x); - return x.sort(_comparator); - }, - - 'Matrix, function': function (x, _comparator) { - _matrixIsVector(x); - return matrix(x.toArray().sort(_comparator), x.storage()); - }, - - 'Array, string': function (x, order) { - _arrayIsVector(x); - return x.sort(_comparator(order)); - }, - - 'Matrix, string': function (x, order) { - _matrixIsVector(x); - return matrix(x.toArray().sort(_comparator(order)), x.storage()); - } - }); - - /** - * Get the comparator for given order ('asc' or 'desc') - * @param {'asc' | 'desc'} order - * @return {function} Returns a _comparator function - */ - function _comparator (order) { - if (order === 'asc') { - return asc; - } - else if (order === 'desc') { - return desc; - } - else { - throw new Error('String "asc" or "desc" expected'); - } - } - - /** - * Validate whether an array is one dimensional - * Throws an error when this is not the case - * @param {Array} array - * @private - */ - function _arrayIsVector (array) { - if (size(array).length !== 1) { - throw new Error('One dimensional array expected'); - } - } - - /** - * Validate whether a matrix is one dimensional - * Throws an error when this is not the case - * @param {Matrix} matrix - * @private - */ - function _matrixIsVector (matrix) { - if (matrix.size().length !== 1) { - throw new Error('One dimensional matrix expected'); - } - } - } - - exports.name = 'sort'; - exports.factory = factory; - - -/***/ }, -/* 162 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var types = __webpack_require__(216); - - function factory (type, config, load, typed) { - /** - * Determine the type of a variable. - * - * Function `typeof` recognizes the following types of objects: - * - * Object | Returns | Example - * ---------------------- | ------------- | ------------------------------------------ - * Array | `'array'` | `math.typeof ([1, 2, 3])` - * boolean | `'boolean'` | `math.typeof (true)` - * Date | `'date'` | `math.typeof (new Date())` - * null | `'null'` | `math.typeof(null)` - * number | `'number'` | `math.typeof(3.5)` - * Object | `'object'` | `math.typeof ({a: 2, b: 3})` - * RegExp | `'regexp'` | `math.typeof (/a regexp/)` - * string | `'string'` | `math.typeof ('hello world')` - * undefined | `'undefined'` | `math.typeof(undefined)` - * math.type.BigNumber | `'bignumber'` | `math.typeof (math.bignumber('2.3e500'))` - * math.type.Chain | `'chain'` | `math.typeof (math.chain(2))` - * math.type.Complex | `'complex'` | `math.typeof (math.complex(2, 3))` - * math.type.Help | `'help'` | `math.typeof (math.help('sqrt'))` - * math.type.Index | `'index'` | `math.typeof (math.index(1, 3))` - * math.type.Matrix | `'matrix'` | `math.typeof (math.matrix([[1,2], [3, 4]]))` - * math.type.Range | `'range'` | `math.typeof (math.range(0, 10))` - * math.type.Unit | `'unit'` | `math.typeof (math.unit('45 deg'))` - * - * Syntax: - * - * math.typeof(x) - * - * Examples: - * - * math.typeof(3.5); // returns 'number' - * math.typeof(math.complex('2 - 4i')); // returns 'complex' - * math.typeof(math.unit('45 deg')); // returns 'unit' - * math.typeof('hello world'); // returns 'string' - * - * @param {*} x The variable for which to test the type. - * @return {String} Lower case type, for example 'number', 'string', 'array'. - */ - return typed('_typeof', { - 'any': function (x) { - // JavaScript types - var t = types.type(x); - - // math.js types - if (t === 'object') { - if (x instanceof type.Complex) return 'complex'; - if (x instanceof type.Matrix) return 'matrix'; - if (x instanceof type.Unit) return 'unit'; - if (x instanceof type.Index) return 'index'; - if (x instanceof type.Range) return 'range'; - if (x instanceof type.Help) return 'help'; - - // the following types are different instances per math.js instance - if (x instanceof type.BigNumber) return 'bignumber'; - if (x instanceof type.Chain) return 'chain'; - } - - return t; - } - }); - } - - exports.name = 'typeof'; - exports.factory = factory; - - -/***/ }, -/* 163 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - /** - * Iterate over all elements of a matrix/array, and executes the given callback function. - * - * Syntax: - * - * math.forEach(x, callback) - * - * Examples: - * - * math.forEach([1, 2, 3], function(value) { - * console.log(value); - * }); - * // outputs 1, 2, 3 - * - * See also: - * - * filter, map, sort - * - * @param {Matrix | Array} x The matrix to iterate on. - * @param {Function} callback The callback function is invoked with three - * parameters: the value of the element, the index - * of the element, and the Matrix/array being traversed. - */ - return typed('forEach', { - 'Array, function': _forEach, - - 'Matrix, function': function (x, callback) { - return x.forEach(callback); - } - }); - } - - /** - * forEach for a multi dimensional array - * @param {Array} array - * @param {function} callback - * @private - */ - function _forEach (array, callback) { - var recurse = function (value, index) { - if (Array.isArray(value)) { - value.forEach(function (child, i) { - // we create a copy of the index array and append the new index value - recurse(child, index.concat(i)); - }); - } - else { - callback(value, index, array); - } - }; - recurse(array, []); - } - - exports.name = 'forEach'; - exports.factory = factory; - - -/***/ }, -/* 164 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var util = __webpack_require__(171); - - var object = util.object; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var abs = load(__webpack_require__(31)); - var add = load(__webpack_require__(32)); - var divideScalar = load(__webpack_require__(213)); - var multiply = load(__webpack_require__(47)); - var subtract = load(__webpack_require__(55)); - var larger = load(__webpack_require__(116)); - var equal = load(__webpack_require__(115)); - var unaryMinus = load(__webpack_require__(56)); - - var SparseMatrix = type.SparseMatrix; - var DenseMatrix = type.DenseMatrix; - var Spa = type.Spa; - - /** - * Calculate the Matrix LU decomposition with pivoting. Matrix A is decomposed in three matrices (L, U, P) where - * A * P = L * U - * - * @param {Matrix | Array} A two dimensional matrix or array for which to get the LUP decomposition. - * - * @return {Array} The lower triangular matrix, the upper triangular matrix and the permutation matrix. - */ - var lup = typed('lup', { - 'Matrix': function (m) { - // process matrix storage format - switch (m.storage()) { - case 'dense': - return _denseLUP(m); - case 'sparse': - return _sparseLUP(m); - } - }, - 'Array': function (a) { - // create dense matrix from array - var m = matrix(a); - // lup, use matrix implementation - var r = lup(m); - // result - return { - L: r.L.valueOf(), - U: r.U.valueOf(), - P: r.P.valueOf() - }; - } - }); - - var _denseLUP = function (m) { - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // minimum rows and columns - var n = Math.min(rows, columns); - // matrix array, clone original data - var data = object.clone(m._data); - // l matrix arrays - var ldata = []; - var lsize = [rows, n]; - // u matrix arrays - var udata = []; - var usize = [n, columns]; - // p (eye [n, n]) - var p = DenseMatrix.diagonal([rows, rows], 1, 0); - // vars - var i, j, k; - // loop columns - for (j = 0; j < columns; j++) { - // skip first column in upper triangular matrix - if (j > 0) { - // loop rows - for (i = 0; i < rows; i++) { - // min i,j - var min = Math.min(i, j); - // v[i, j] - var s = 0; - // loop up to min - for (k = 0; k < min; k++) { - // s = l[i, k] - data[k, j] - s = add(s, multiply(data[i][k], data[k][j])); - } - data[i][j] = subtract(data[i][j], s); - } - } - // row with larger value in cvector, row >= j - var pi = j; - var pabsv = 0; - var vjj = 0; - // loop rows - for (i = j; i < rows; i++) { - // data @ i, j - var v = data[i][j]; - // absolute value - var absv = abs(v); - // value is greater than pivote value - if (larger(absv, pabsv)) { - // store row - pi = i; - // update max value - pabsv = absv; - // value @ [j, j] - vjj = v; - } - } - // swap rows (j <-> pi) - if (j !== pi) { - // swap values j <-> pi in P - DenseMatrix._swapRows(j, pi, p._data); - // swap j <-> pi in data - DenseMatrix._swapRows(j, pi, data); - } - // check column is in lower triangular matrix - if (j < rows) { - // loop rows (lower triangular matrix) - for (i = j + 1; i < rows; i++) { - // value @ i, j - var vij = data[i][j]; - if (!equal(vij, 0)) { - // update data - data[i][j] = divideScalar(data[i][j], vjj); - } - } - } - } - // loop columns - for (j = 0; j < columns; j++) { - // loop rows - for (i = 0; i < rows; i++) { - // initialize row in arrays - if (j === 0) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i] = []; - } - // L - ldata[i] = []; - } - // check we are in the upper triangular matrix - if (i < j) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = data[i][j]; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = 0; - } - continue; - } - // diagonal value - if (i === j) { - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = data[i][j]; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = 1; - } - continue; - } - // check row exists in upper triangular matrix - if (i < columns) { - // U - udata[i][j] = 0; - } - // check column exists in lower triangular matrix - if (j < rows) { - // L - ldata[i][j] = data[i][j]; - } - } - } - // l matrix - var l = new DenseMatrix({ - data: ldata, - size: lsize - }); - // u matrix - var u = new DenseMatrix({ - data: udata, - size: usize - }); - // return matrices - return { - L: l, - U: u, - P: p, - toString: function () { - return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.P.toString(); - } - }; - }; - - var _sparseLUP = function (m) { - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // minimum rows and columns - var n = Math.min(rows, columns); - // matrix arrays (will not be modified, thanks to permutation vector) - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // l matrix arrays - var lvalues = []; - var lindex = []; - var lptr = []; - var lsize = [rows, n]; - // u matrix arrays - var uvalues = []; - var uindex = []; - var uptr = []; - var usize = [n, columns]; - // p matrix arrays - var pvalues = []; - var pindex = []; - var pptr = []; - var psize = [rows, rows]; - // vars - var i, j, k; - // permutation vectors, (current index -> original index) and (original index -> current index) - var pv_co = new Array(rows); - var pv_oc = new Array(rows); - for (i = 0; i < rows; i++) { - pv_co[i] = i; - pv_oc[i] = i; - } - // swap indices in permutation vectors (condition x < y)! - var swapIndeces = function (x, y) { - // find pv indeces getting data from x and y - var kx = pv_oc[x]; - var ky = pv_oc[y]; - // update permutation vector current -> original - pv_co[kx] = y; - pv_co[ky] = x; - // update permutation vector original -> current - pv_oc[x] = ky; - pv_oc[y] = kx; - }; - // loop columns - for (j = 0; j < columns; j++) { - // sparse accumulator - var spa = new Spa(rows); - // check lower triangular matrix has a value @ column j - if (j < rows) { - // update ptr - lptr.push(lvalues.length); - // first value in j column for lower triangular matrix - lvalues.push(1); - lindex.push(j); - } - // update ptr - uptr.push(uvalues.length); - // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] - var k0 = ptr[j]; - var k1 = ptr[j + 1]; - // copy column j into sparse accumulator - for (k = k0; k < k1; k++) { - // row - i = index[k]; - // copy column values into sparse accumulator (use permutation vector) - spa.set(pv_co[i], values[k]); - } - // skip first column in upper triangular matrix - if (j > 0) { - // loop rows in column j (above diagonal) - spa.forEach(0, j - 1, function (k, vkj) { - // loop rows in column k (L) - SparseMatrix._forEachRow(k, lvalues, lindex, lptr, function (i, vik) { - // check row is below k - if (i > k) { - // update spa value - spa.accumulate(i, unaryMinus(multiply(vik, vkj))); - } - }); - }); - } - // row with larger value in spa, row >= j - var pi = j; - var vjj = spa.get(j); - var pabsv = abs(vjj); - // loop values in spa (order by row, below diagonal) - spa.forEach(j + 1, rows - 1, function (x, v) { - // absolute value - var absv = abs(v); - // value is greater than pivote value - if (larger(absv, pabsv)) { - // store row - pi = x; - // update max value - pabsv = absv; - // value @ [j, j] - vjj = v; - } - }); - // swap rows (j <-> pi) - if (j !== pi) { - // swap values j <-> pi in L - SparseMatrix._swapRows(j, pi, lsize[1], lvalues, lindex, lptr); - // swap values j <-> pi in U - SparseMatrix._swapRows(j, pi, usize[1], uvalues, uindex, uptr); - // swap values in spa - spa.swap(j, pi); - // update permutation vector (swap values @ j, pi) - swapIndeces(j, pi); - } - // loop values in spa (order by row) - spa.forEach(0, rows - 1, function (x, v) { - // check we are above diagonal - if (x <= j) { - // update upper triangular matrix - uvalues.push(v); - uindex.push(x); - } - else { - // update value - v = divideScalar(v, vjj); - // check value is non zero - if (!equal(v, 0)) { - // update lower triangular matrix - lvalues.push(v); - lindex.push(x); - } - } - }); - } - // update ptrs - lptr.push(lvalues.length); - uptr.push(uvalues.length); - // generate P matrix - for (i = 0; i < rows; i++) { - // ptr - pptr.push(pvalues.length); - // value - pvalues.push(1); - // row - pindex.push(pv_co[i]); - } - // close ptr - pptr.push(pvalues.length); - // return matrices - return { - L: new SparseMatrix({ - values: lvalues, - index: lindex, - ptr: lptr, - size: lsize - }), - U: new SparseMatrix({ - values: uvalues, - index: uindex, - ptr: uptr, - size: usize - }), - P: new SparseMatrix({ - values: pvalues, - index: pindex, - ptr: pptr, - size: psize - }), - toString: function () { - return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.P.toString(); - } - }; - }; - - return lup; - } - - exports.name = 'lup'; - exports.factory = factory; - - -/***/ }, -/* 165 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var isArray = Array.isArray; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var lup = load(__webpack_require__(164)); - var multiply = load(__webpack_require__(47)); - - var backwardSubstitution = load(__webpack_require__(217)); - var forwardSubstitution = load(__webpack_require__(218)); - - /** - * Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector. - * - * Syntax: - * - * var x = math.lusolve(matrix, b) // returns column vector with the solution to the linear system A * x = b - * - * var x = math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A) - * - * Examples: - * - * var m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]; - * - * var x = math.lusolve(m, [-1, -1, -1, -1]); // x = [-1, -0.5, -1/3, -0.25] - * - * var f = math.lup(m); - * var x1 = math.lusolve(f, [-1, -1, -1, -1]); // x1 = [-1, -0.5, -1/3, -0.25] - * var x2 = math.lusolve(f, [1, 2, 1, -1]); // x2 = [1, 1, 1/3, -0.25] - * - * See also: - * - * lup - * - * @param {Matrix | Array | Object} a Invertible Matrix or the Matrix LUP decomposition - * @param {Matrix | Array} b Column Vector - * - * @return {Matrix | Array} Column vector with the solution to the linear system A * x = b - */ - var lusolve = typed('lusolve', { - 'Array, Array | Matrix': function (a, b) { - // convert a to matrix - a = matrix(a); - // matrix lup decomposition - var d = lup(a); - // solve - var x = _lusolve(d.L, d.U, d.P, b); - // convert result to array - return x.valueOf(); - }, - 'Matrix, Array | Matrix': function (a, b) { - // matrix lup decomposition - var d = lup(a); - // solve - return _lusolve(d.L, d.U, d.P, b); - }, - 'Object, Array | Matrix': function (d, b) { - // solve - return _lusolve(d.L, d.U, d.P, b); - } - }); - - var _toMatrix = function (a) { - // check it is a matrix - if (a instanceof type.Matrix) - return a; - // check array - if (isArray(a)) - return matrix(a); - // throw - throw new TypeError('Invalid Matrix LUP decomposition'); - }; - - var _lusolve = function (l, u, p, b) { - // verify L, U, P - l = _toMatrix(l); - u = _toMatrix(u); - p = _toMatrix(p); - // modify column vector applying permutations - b = multiply(p, b); - // use forward substitution to resolve L * y = b - var y = forwardSubstitution(l, b); - // use backward substitution to resolve U * x = y - return backwardSubstitution(u, y); - }; - - return lusolve; - } - - exports.name = 'lusolve'; - exports.factory = factory; - - -/***/ }, -/* 166 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var BigNumber = __webpack_require__(351); + var BigNumber = __webpack_require__(191); /** * Clone an object @@ -21953,23 +6803,28 @@ return /******/ (function(modules) { // webpackBootstrap }; /** - * Test whether an object is a factory function. This is the case - * when it has properties name:string, factory:function, and optionally - * path:string. - * @param object + * Test whether an object is a factory. a factory has fields: + * + * - factory: function (type: Object, config: Object, load: function, typed: function [, math: Object]) (required) + * - name: string (optional) + * - path: string A dot separated path (optional) + * - math: boolean If true (false by default), the math namespace is passed + * as fifth argument of the factory function + * + * @param {*} object * @returns {boolean} */ exports.isFactory = function (object) { - return typeof object.name === 'string' && typeof object.factory === 'function'; + return object && typeof object.factory === 'function'; }; /***/ }, -/* 167 */ +/* 34 */ /***/ function(module, exports, __webpack_require__) { - var typed = __webpack_require__(357); - var digits = __webpack_require__(175).digits; + var typed = __webpack_require__(368); + var digits = __webpack_require__(41).digits; /** * Factory function for creating a new typed instance @@ -22071,13 +6926,13 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 168 */ +/* 35 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var isFactory = __webpack_require__(166).isFactory; - var traverse = __webpack_require__(166).traverse; + var isFactory = __webpack_require__(33).isFactory; + var traverse = __webpack_require__(33).traverse; // TODO: rework the import function to a typed function @@ -22123,7 +6978,7 @@ return /******/ (function(modules) { // webpackBootstrap * * math.fibonacci(7); // returns 13 * - * @param {String | Object} object Object with functions to be imported. + * @param {String | Object | Array} object Object with functions to be imported. * @param {Object} [options] Import options. * @return {Object} Returns the imported objects */ @@ -22147,12 +7002,18 @@ return /******/ (function(modules) { // webpackBootstrap } // load the module using require - var _module = __webpack_require__(347)(object); + var _module = __webpack_require__(186)(object); return math_import(_module, options); } else if (isFactory(object)) { return _importFactory(object); } + else if (Array.isArray(object)) { + // TODO: what to return? An array? or a merged object? + return object.map(function (entry) { + return math_import(entry, options); + }); + } else if (typeof object === 'object') { // a map with functions var imported = {}; @@ -22210,11 +7071,6 @@ return /******/ (function(modules) { // webpackBootstrap math[name] = value; } - // register the transform function if any - if (value && value.transform) { - math.expression.transform[name] = value.transform; - } - // create a proxy for the chain math.type.Chain.createProxy(name, value); @@ -22224,26 +7080,30 @@ return /******/ (function(modules) { // webpackBootstrap /** * Import an instance of a factory into math.js - * @param {{name: string, factory: function}} factory + * @param {{factory: function, name: string, path: string, math: boolean}} factory * @returns {*} Returns the created and imported instance * @private */ function _importFactory(factory) { var instance = load(factory); - var namespace = factory.path ? traverse(math, factory.path) : math; - if (namespace[factory.name]) { - // TODO: add support for merging typed-functions - throw new Error('"' + factory.name + '" already exists'); + if (typeof factory.name === 'string') { + var namespace = factory.path ? traverse(math, factory.path) : math; + + // TODO: make factory.name optional, if not provided, do not add to math namespace but just return -> remove the names from all transform functions + if (namespace[factory.name]) { + // TODO: add support for merging typed-functions + throw new Error('"' + factory.name + '" already exists'); + } + namespace[factory.name] = instance; } - namespace[factory.name] = instance; return instance; } /** - * Check whether given object is a supported type - * @param object + * Check whether given object is a type which can be imported + * @param {function | number | string | boolean | null | Unit | Complex} object * @return {Boolean} * @private */ @@ -22266,114 +7126,34 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 169 */ +/* 36 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - module.exports = function (math, config) { - var object = __webpack_require__(166); - var bignumber = __webpack_require__(214); - var Complex = __webpack_require__(3); - var BigNumber = math.type.BigNumber; - - math['true'] = true; - math['false'] = false; - math['null'] = null; - math['uninitialized'] = __webpack_require__(172).UNINITIALIZED; - - if (config.number === 'bignumber') { - math['Infinity'] = new BigNumber(Infinity); - math['NaN'] = new BigNumber(NaN); - - object.lazy(math, 'pi', function () {return bignumber.pi(config.precision)}); - object.lazy(math, 'tau', function () {return bignumber.tau(config.precision)}); - object.lazy(math, 'e', function () {return bignumber.e(config.precision)}); - object.lazy(math, 'phi', function () {return bignumber.phi(config.precision)}); // golden ratio, (1+sqrt(5))/2 - - // uppercase constants (for compatibility with built-in Math) - object.lazy(math, 'E', function () {return math.e;}); - object.lazy(math, 'LN2', function () {return new BigNumber(2).ln();}); - object.lazy(math, 'LN10', function () {return new BigNumber(10).ln()}); - object.lazy(math, 'LOG2E', function () {return new BigNumber(1).div(new BigNumber(2).ln());}); - object.lazy(math, 'LOG10E', function () {return new BigNumber(1).div(new BigNumber(10).ln())}); - object.lazy(math, 'PI', function () {return math.pi}); - object.lazy(math, 'SQRT1_2', function () {return new BigNumber('0.5').sqrt()}); - object.lazy(math, 'SQRT2', function () {return new BigNumber(2).sqrt()}); - } - else { - math['Infinity'] = Infinity; - math['NaN'] = NaN; - - math.pi = Math.PI; - math.tau = Math.PI * 2; - math.e = Math.E; - math.phi = 1.61803398874989484820458683436563811772030917980576286213545; // golden ratio, (1+sqrt(5))/2 - - // uppercase constants (for compatibility with built-in Math) - math.E = math.e; - math.LN2 = Math.LN2; - math.LN10 = Math.LN10; - math.LOG2E = Math.LOG2E; - math.LOG10E = Math.LOG10E; - math.PI = math.pi; - math.SQRT1_2 = Math.SQRT1_2; - math.SQRT2 = Math.SQRT2; - } - - // complex i - math.i = new Complex(0, 1); - - // meta information - math.version = __webpack_require__(348); - }; + exports.array = __webpack_require__(37); + exports['boolean'] = __webpack_require__(187); + exports['function'] = __webpack_require__(188); + exports.number = __webpack_require__(41); + exports.bignumber = __webpack_require__(48); + exports.object = __webpack_require__(33); + exports.string = __webpack_require__(42); + exports.types = __webpack_require__(189); /***/ }, -/* 170 */ +/* 37 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - exports.ArgumentsError = __webpack_require__(177); - exports.DimensionError = __webpack_require__(174); - exports.IndexError = __webpack_require__(173); - exports.UnsupportedTypeError = __webpack_require__(349); + var number = __webpack_require__(41); + var string = __webpack_require__(42); + var object = __webpack_require__(33); + var types = __webpack_require__(189); - // TODO: implement an InvalidValueError? - - -/***/ }, -/* 171 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - exports.array = __webpack_require__(172); - exports['boolean'] = __webpack_require__(209); - exports['function'] = __webpack_require__(350); - exports.number = __webpack_require__(175); - exports.bignumber = __webpack_require__(214); - exports.object = __webpack_require__(166); - exports.string = __webpack_require__(176); - exports.types = __webpack_require__(216); - - -/***/ }, -/* 172 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var number = __webpack_require__(175); - var string = __webpack_require__(176); - var object = __webpack_require__(166); - var types = __webpack_require__(216); - - var DimensionError = __webpack_require__(174); - var IndexError = __webpack_require__(173); - - var isArray = Array.isArray; + var DimensionError = __webpack_require__(39); + var IndexError = __webpack_require__(38); /** * Calculate the size of a multi dimensional array. @@ -22384,7 +7164,7 @@ return /******/ (function(modules) { // webpackBootstrap function _size(x) { var size = []; - while (isArray(x)) { + while (Array.isArray(x)) { size.push(x.length); x = x[0]; } @@ -22433,7 +7213,7 @@ return /******/ (function(modules) { // webpackBootstrap var dimNext = dim + 1; for (i = 0; i < len; i++) { var child = array[i]; - if (!isArray(child)) { + if (!Array.isArray(child)) { throw new DimensionError(size.length - 1, size.length, '<'); } _validate(array[i], size, dimNext); @@ -22442,7 +7222,7 @@ return /******/ (function(modules) { // webpackBootstrap else { // last dimension. none of the childs may be an array for (i = 0; i < len; i++) { - if (isArray(array[i])) { + if (Array.isArray(array[i])) { throw new DimensionError(size.length + 1, size.length, '>'); } } @@ -22460,7 +7240,7 @@ return /******/ (function(modules) { // webpackBootstrap var isScalar = (size.length == 0); if (isScalar) { // scalar - if (isArray(array)) { + if (Array.isArray(array)) { throw new DimensionError(array.length, 0); } } @@ -22503,7 +7283,7 @@ return /******/ (function(modules) { // webpackBootstrap // TODO: add support for scalars, having size=[] ? // check the type of the arguments - if (!isArray(array) || !isArray(size)) { + if (!Array.isArray(array) || !Array.isArray(size)) { throw new TypeError('Array expected'); } if (size.length === 0) { @@ -22552,7 +7332,7 @@ return /******/ (function(modules) { // webpackBootstrap for (i = 0; i < minLen; i++) { // resize child array elem = array[i]; - if (!isArray(elem)) { + if (!Array.isArray(elem)) { elem = [elem]; // add a dimension array[i] = elem; } @@ -22574,7 +7354,7 @@ return /******/ (function(modules) { // webpackBootstrap // remove dimensions of existing values for (i = 0; i < minLen; i++) { - while (isArray(array[i])) { + while (Array.isArray(array[i])) { array[i] = array[i][0]; } } @@ -22598,7 +7378,7 @@ return /******/ (function(modules) { // webpackBootstrap var s = size || exports.size(array); // squeeze outer dimensions - while (isArray(array) && array.length === 1) { + while (Array.isArray(array) && array.length === 1) { array = array[0]; s.shift(); } @@ -22636,7 +7416,7 @@ return /******/ (function(modules) { // webpackBootstrap } } else { - while (isArray(array)) { + while (Array.isArray(array)) { array = array[0]; } } @@ -22684,7 +7464,7 @@ return /******/ (function(modules) { // webpackBootstrap function _unsqueeze (array, dims, dim) { var i, ii; - if (isArray(array)) { + if (Array.isArray(array)) { var next = dim + 1; for (i = 0, ii = array.length; i < ii; i++) { array[i] = _unsqueeze(array[i], dims, next); @@ -22703,45 +7483,36 @@ return /******/ (function(modules) { // webpackBootstrap * array * @param {Array} array A multi dimensional array * @return {Array} The flattened array (1 dimensional) - * @private */ exports.flatten = function(array) { - var flat = array, - isArray = Array.isArray; - - while (isArray(flat[0])) { - var next = []; - for (var i = 0, ii = flat.length; i < ii; i++) { - next = next.concat.apply(next, flat[i]); - } - flat = next; + if (!Array.isArray(array)) { + //if not an array, return as is + return array; } + var flat = []; + + array.forEach(function callback(value) { + if (Array.isArray(value)) { + value.forEach(callback); //traverse through sub-arrays recursively + } + else { + flat.push(value); + } + }); return flat; }; - /** - * Convert function arguments to an array. - * @param {Arguments} args - * @returns {Array} array - */ - exports.argsToArray = function(args) { - var array = []; - for (var i = 0, len = args.length; i < len; i++) { - array[i] = args[i]; - } - return array; - }; - /** * Test whether an object is an array * @param {*} value * @return {Boolean} isArray */ - exports.isArray = isArray; + exports.isArray = Array.isArray; + /***/ }, -/* 173 */ +/* 38 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -22792,7 +7563,7 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 174 */ +/* 39 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -22832,12 +7603,98 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 175 */ +/* 40 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var NumberFormatter = __webpack_require__(352); + function factory (type, config, load, typed) { + /** + * Create a Matrix. The function creates a new `math.type.Matrix` object from + * an `Array`. A Matrix has utility functions to manipulate the data in the + * matrix, like getting the size and getting or setting values in the matrix. + * Supported storage formats are 'dense' and 'sparse'. + * + * Syntax: + * + * math.matrix() // creates an empty matrix using default storage format (dense). + * math.matrix(data) // creates a matrix with initial data using default storage format (dense). + * math.matrix('dense') // creates an empty matrix using the given storage format. + * math.matrix(data, 'dense') // creates a matrix with initial data using the given storage format. + * math.matrix(data, 'sparse') // creates a sparse matrix with initial data. + * math.matrix(data, 'sparse', 'number') // creates a sparse matrix with initial data, number data type. + * + * Examples: + * + * var m = math.matrix([[1, 2], [3, 4]]); + * m.size(); // Array [2, 2] + * m.resize([3, 2], 5); + * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] + * m.get([1, 0]) // number 3 + * + * See also: + * + * bignumber, boolean, complex, index, number, string, unit, sparse + * + * @param {Array | Matrix} [data] A multi dimensional array + * @param {string} [format] The Matrix storage format + * + * @return {Matrix} The created matrix + */ + return typed('matrix', { + '': function () { + return _create([]); + }, + + 'string': function (format) { + return _create([], format); + }, + + 'string, string': function (format, datatype) { + return _create([], format, datatype); + }, + + 'Array': function (data) { + return _create(data); + }, + + 'Matrix': function (data) { + return _create(data, data.storage()); + }, + + 'Array | Matrix, string': _create, + + 'Array | Matrix, string, string': _create + }); + + /** + * Create a new Matrix with given storage format + * @param {Array} data + * @param {string} [format] + * @param {string} [datatype] + * @returns {Matrix} Returns a new Matrix + * @private + */ + function _create(data, format, datatype) { + // get storage format constructor + var M = type.Matrix.storage(format || 'default'); + + // create instance + return new M(data, datatype); + } + } + + exports.name = 'matrix'; + exports.factory = factory; + + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var NumberFormatter = __webpack_require__(190); /** * Test whether value is a Number @@ -22845,7 +7702,7 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Boolean} isNumber */ exports.isNumber = function(value) { - return (value instanceof Number) || (typeof value == 'number'); + return typeof value === 'number'; }; /** @@ -23097,14 +7954,14 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 176 */ +/* 42 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var number = __webpack_require__(175); - var bignumber = __webpack_require__(214); - var BigNumber = __webpack_require__(351); + var number = __webpack_require__(41); + var bignumber = __webpack_require__(48); + var BigNumber = __webpack_require__(191); /** * Test whether value is a String @@ -23112,7 +7969,7 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Boolean} isString */ exports.isString = function(value) { - return (value instanceof String) || (typeof value == 'string'); + return typeof value === 'string'; }; /** @@ -23212,2997 +8069,502 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 177 */ +/* 43 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - /** - * Create a syntax error with the message: - * 'Wrong number of arguments in function ( provided, - expected)' - * @param {String} fn Function name - * @param {Number} count Actual argument count - * @param {Number} min Minimum required argument count - * @param {Number} [max] Maximum required argument count - * @extends Error - */ - function ArgumentsError(fn, count, min, max) { - if (!(this instanceof ArgumentsError)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.fn = fn; - this.count = count; - this.min = min; - this.max = max; - - this.message = 'Wrong number of arguments in function ' + fn + - ' (' + count + ' provided, ' + - min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; - - this.stack = (new Error()).stack; - } - - ArgumentsError.prototype = new Error(); - ArgumentsError.prototype.constructor = Error; - ArgumentsError.prototype.name = 'ArgumentsError'; - - module.exports = ArgumentsError; - - -/***/ }, -/* 178 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190), - string = __webpack_require__(176), - - isArray = Array.isArray, - isNode = Node.isNode; - - /** - * @constructor ArrayNode - * @extends {Node} - * Holds an 1-dimensional array with nodes - * @param {Node[]} [nodes] 1 dimensional array with nodes - */ - function ArrayNode(nodes) { - if (!(this instanceof ArrayNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - this.nodes = nodes || []; - - // validate input - if (!isArray(this.nodes) || !this.nodes.every(isNode)) { - throw new TypeError('Array containing Nodes expected'); - } - } - - ArrayNode.prototype = new Node(); - - ArrayNode.prototype.type = 'ArrayNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @private - */ - ArrayNode.prototype._compile = function (defs) { - var asMatrix = (defs.math.config().matrix !== 'array'); - - var nodes = this.nodes.map(function (node) { - return node._compile(defs); - }); - - return (asMatrix ? 'math.matrix([' : '[') + - nodes.join(',') + - (asMatrix ? '])' : ']'); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ArrayNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.nodes.length; i++) { - var node = this.nodes[i]; - callback(node, 'nodes[' + i + ']', this); - } - }; - - /** - * Create a new ArrayNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {ArrayNode} Returns a transformed copy of the node - */ - ArrayNode.prototype.map = function (callback) { - var nodes = []; - for (var i = 0; i < this.nodes.length; i++) { - nodes[i] = this._ifNode(callback(this.nodes[i], 'nodes[' + i + ']', this)); - } - return new ArrayNode(nodes); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ArrayNode} - */ - ArrayNode.prototype.clone = function() { - return new ArrayNode(this.nodes.slice(0)); - }; - - /** - * Get string representation - * @return {String} str - * @override - */ - ArrayNode.prototype.toString = function() { - return string.format(this.nodes); - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @param {String} type - * @return {String} str - */ - ArrayNode.prototype._toTex = function(callbacks) { - this.latexType = this.latexType || 'bmatrix'; - var s = '\\begin{' + this.latexType + '}'; - - this.nodes.forEach(function(node) { - if (node.nodes) { - s += node.nodes.map(function(childNode) { - return childNode.toTex(callbacks); - }).join('&'); - } - else { - s += node.toTex(callbacks); - } - - // new line - s += '\\\\'; - }); - s += '\\end{' + this.latexType + '}'; - return s; - }; - - module.exports = ArrayNode; - - -/***/ }, -/* 179 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190), - ArrayNode = __webpack_require__(178), - - keywords = __webpack_require__(353), - operators = __webpack_require__(354), - - latex = __webpack_require__(355), - isString = __webpack_require__(176).isString; - - /** - * @constructor AssignmentNode - * @extends {Node} - * Define a symbol, like "a = 3.2" - * - * @param {String} name Symbol name - * @param {Node} expr The expression defining the symbol - */ - function AssignmentNode(name, expr) { - if (!(this instanceof AssignmentNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (!isString(name)) throw new TypeError('String expected for parameter "name"'); - if (!(expr instanceof Node)) throw new TypeError('Node expected for parameter "expr"'); - if (name in keywords) throw new Error('Illegal symbol name, "' + name + '" is a reserved keyword'); - - this.name = name; - this.expr = expr; - } - - AssignmentNode.prototype = new Node(); - - AssignmentNode.prototype.type = 'AssignmentNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @private - */ - AssignmentNode.prototype._compile = function (defs) { - return 'scope["' + this.name + '"] = ' + this.expr._compile(defs) + ''; - }; - - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - AssignmentNode.prototype.forEach = function (callback) { - callback(this.expr, 'expr', this); - }; - - /** - * Create a new AssignmentNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {AssignmentNode} Returns a transformed copy of the node - */ - AssignmentNode.prototype.map = function (callback) { - return new AssignmentNode(this.name, this._ifNode(callback(this.expr, 'expr', this))); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {AssignmentNode} - */ - AssignmentNode.prototype.clone = function() { - return new AssignmentNode(this.name, this.expr); - }; - - /** - * Get string representation - * @return {String} - */ - AssignmentNode.prototype.toString = function() { - var precedence = operators.getPrecedence(this); - var exprPrecedence = operators.getPrecedence(this.expr); - var expr = this.expr.toString(); - if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { - expr = '(' + expr + ')'; - } - return this.name + ' = ' + expr; - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} - */ - AssignmentNode.prototype._toTex = function(callbacks) { - var precedence = operators.getPrecedence(this); - var exprPrecedence = operators.getPrecedence(this.expr); - - var expr = this.expr.toTex(callbacks); - if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { - expr = '\\left(' + expr + '\\right)'; - } - - return latex.toSymbol(this.name) + ':=' + expr; - }; - - module.exports = AssignmentNode; - - -/***/ }, -/* 180 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var ResultSet = __webpack_require__(9); - var isBoolean = __webpack_require__(209).isBoolean; - - /** - * @constructor BlockNode - * @extends {Node} - * Holds a set with blocks - * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks - * An array with blocks, where a block is constructed as an Object - * with properties block, which is a Node, and visible, which is - * a boolean. The property visible is optional and is true by default - */ - function BlockNode(blocks) { - if (!(this instanceof BlockNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input, copy blocks - if (!Array.isArray(blocks)) throw new Error('Array expected'); - this.blocks = blocks.map(function (block) { - var node = block && block.node; - var visible = block && block.visible !== undefined ? block.visible : true; - - if (!(node instanceof Node)) throw new TypeError('Property "node" must be a Node'); - if (!isBoolean(visible)) throw new TypeError('Property "visible" must be a boolean'); - - return { - node: node, - visible: visible - } - }); - } - - BlockNode.prototype = new Node(); - - BlockNode.prototype.type = 'BlockNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - BlockNode.prototype._compile = function (defs) { - defs.ResultSet = ResultSet; - var blocks = this.blocks.map(function (param) { - var js = param.node._compile(defs); - if (param.visible) { - return 'results.push(' + js + ');'; - } - else { - return js + ';'; - } - }); - - return '(function () {' + - 'var results = [];' + - blocks.join('') + - 'return new ResultSet(results);' + - '})()'; - }; - - /** - * Execute a callback for each of the child blocks of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - BlockNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.blocks.length; i++) { - callback(this.blocks[i].node, 'blocks[' + i + '].node', this); - } - }; - - /** - * Create a new BlockNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {BlockNode} Returns a transformed copy of the node - */ - BlockNode.prototype.map = function (callback) { - var blocks = []; - for (var i = 0; i < this.blocks.length; i++) { - var block = this.blocks[i]; - var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this)); - blocks[i] = { - node: node, - visible: block.visible - }; - } - return new BlockNode(blocks); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {BlockNode} - */ - BlockNode.prototype.clone = function() { - var blocks = this.blocks.map(function(block) { - return { - node: block.node, - visible: block.visible - }; - }); - - return new BlockNode(blocks); - }; - - /** - * Get string representation - * @return {String} str - * @override - */ - BlockNode.prototype.toString = function() { - return this.blocks.map(function (param) { - return param.node.toString() + (param.visible ? '' : ';'); - }).join('\n'); - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - BlockNode.prototype._toTex = function(callbacks) { - return this.blocks.map(function (param) { - return param.node.toTex(callbacks) + (param.visible ? '' : ';'); - }).join('\n'); - }; - - module.exports = BlockNode; - - -/***/ }, -/* 181 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var latex = __webpack_require__(355); - var BigNumber = __webpack_require__(351); - var Complex = __webpack_require__(3); - var Unit = __webpack_require__(7); - var util = __webpack_require__(171); - var operators = __webpack_require__(354); - var isString = util.string.isString; - var isNumber = util.number.isNumber; - var isBoolean = util['boolean'].isBoolean; - - /** - * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr' - * - * @param {Node} condition Condition, must result in a boolean - * @param {Node} trueExpr Expression evaluated when condition is true - * @param {Node} falseExpr Expression evaluated when condition is true - * - * @constructor ConditionalNode - * @extends {Node} - */ - function ConditionalNode (condition, trueExpr, falseExpr) { - if (!(this instanceof ConditionalNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - if (!(condition instanceof Node)) throw new TypeError('Parameter condition must be a Node'); - if (!(trueExpr instanceof Node)) throw new TypeError('Parameter trueExpr must be a Node'); - if (!(falseExpr instanceof Node)) throw new TypeError('Parameter falseExpr must be a Node'); - - this.condition = condition; - this.trueExpr = trueExpr; - this.falseExpr = falseExpr; - } - - ConditionalNode.prototype = new Node(); - - ConditionalNode.prototype.type = 'ConditionalNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - ConditionalNode.prototype._compile = function(defs) { - /** - * Test whether a condition is met - * @param {*} condition - * @returns {boolean} true if condition is true or non-zero, else false - */ - defs.testCondition = function (condition) { - if (isNumber(condition) || isBoolean(condition) || isString(condition)) { - return condition ? true : false; - } - - if (condition instanceof BigNumber) { - return condition.isZero() ? false : true; - } - - if (condition instanceof Complex) { - return (condition.re || condition.im) ? true : false; - } - - if (condition instanceof Unit) { - return condition.value ? true : false; - } - - if (condition === null || condition === undefined) { - return false; - } - - throw new TypeError('Unsupported type of condition "' + defs.math['typeof'](condition) + '"'); - }; - - return ( - 'testCondition(' + this.condition._compile(defs) + ') ? ' + - '( ' + this.trueExpr._compile(defs) + ') : ' + - '( ' + this.falseExpr._compile(defs) + ')' - ); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ConditionalNode.prototype.forEach = function (callback) { - callback(this.condition, 'condition', this); - callback(this.trueExpr, 'trueExpr', this); - callback(this.falseExpr, 'falseExpr', this); - }; - - /** - * Create a new ConditionalNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {ConditionalNode} Returns a transformed copy of the node - */ - ConditionalNode.prototype.map = function (callback) { - return new ConditionalNode( - this._ifNode(callback(this.condition, 'condition', this)), - this._ifNode(callback(this.trueExpr, 'trueExpr', this)), - this._ifNode(callback(this.falseExpr, 'falseExpr', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ConditionalNode} - */ - ConditionalNode.prototype.clone = function() { - return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr); - }; - - /** - * Get string representation - * @return {String} str - */ - ConditionalNode.prototype.toString = function() { - var precedence = operators.getPrecedence(this); - - //Enclose Arguments in parentheses if they are an OperatorNode - //or have lower or equal precedence - //NOTE: enclosing all OperatorNodes in parentheses is a decision - //purely based on aesthetics and readability - var condition = this.condition.toString(); - var conditionPrecedence = operators.getPrecedence(this.condition); - if ((this.condition.type === 'OperatorNode') - || ((conditionPrecedence !== null) && (conditionPrecedence <= precedence))) { - condition = '(' + condition + ')'; - } - - var trueExpr = this.trueExpr.toString(); - var truePrecedence = operators.getPrecedence(this.trueExpr); - if ((this.trueExpr.type === 'OperatorNode') - || ((truePrecedence !== null) && (truePrecedence <= precedence))) { - trueExpr = '(' + trueExpr + ')'; - } - - var falseExpr = this.falseExpr.toString(); - var falsePrecedence = operators.getPrecedence(this.falseExpr); - if ((this.falseExpr.type === 'OperatorNode') - || ((falsePrecedence !== null) && (falsePrecedence <= precedence))) { - falseExpr = '(' + falseExpr + ')'; - } - return condition + ' ? ' + trueExpr + ' : ' + falseExpr; - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - ConditionalNode.prototype._toTex = function(callbacks) { - return '\\left\\{\\begin{array}{l l}{' - + this.trueExpr.toTex(callbacks) + '}, &\\quad{\\text{if}\\;' - + this.condition.toTex(callbacks) - + '}\\\\{' + this.falseExpr.toTex(callbacks) - + '}, &\\quad{\\text{otherwise}}\\end{array}\\right.'; - }; - - module.exports = ConditionalNode; - - -/***/ }, -/* 182 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var BigNumber = __webpack_require__(351); - var type = __webpack_require__(216).type; - var isString = __webpack_require__(176).isString; - - /** - * A ConstantNode holds a constant value like a number or string. A ConstantNode - * stores a stringified version of the value and uses this to compile to - * JavaScript. - * - * In case of a stringified number as input, this may be compiled to a BigNumber - * when the math instance is configured for BigNumbers. - * - * Usage: - * - * // stringified values with type - * new ConstantNode('2.3', 'number'); - * new ConstantNode('true', 'boolean'); - * new ConstantNode('hello', 'string'); - * - * // non-stringified values, type will be automatically detected - * new ConstantNode(2.3); - * new ConstantNode('hello'); - * - * @param {String | Number | Boolean | null | undefined} value - * When valueType is provided, value must contain - * an uninterpreted string representing the value. - * When valueType is undefined, value can be a - * number, string, boolean, null, or undefined, and - * the type will be determined automatically. - * @param {String} [valueType] The type of value. Choose from 'number', 'string', - * 'boolean', 'undefined', 'null' - * @constructor ConstantNode - * @extends {Node} - */ - function ConstantNode(value, valueType) { - if (!(this instanceof ConstantNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (valueType) { - if (!isString(valueType)) { - throw new TypeError('String expected for parameter "valueType"'); - } - if (!isString(value)){ - throw new TypeError('String expected for parameter "value"'); - } - - this.value = value; - this.valueType = valueType; - } - else { - // stringify the value and determine the type - this.value = value + ''; - this.valueType = type(value); - } - - if (!SUPPORTED_TYPES[this.valueType]) { - throw new TypeError('Unsupported type of value "' + this.valueType + '"'); - } - } - - var SUPPORTED_TYPES = { - 'number': true, - 'string': true, - 'boolean': true, - 'undefined': true, - 'null': true - }; - - ConstantNode.prototype = new Node(); - - ConstantNode.prototype.type = 'ConstantNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - ConstantNode.prototype._compile = function (defs) { - switch (this.valueType) { - case 'number': - if (defs.math.config().number === 'bignumber') { - return 'math.bignumber("' + this.value + '")'; - } - else { - // remove leading zeros like '003.2' which are not allowed by JavaScript - return this.value.replace(/^(0*)[0-9]/, function (match, zeros) { - return match.substring(zeros.length); - }); - } - - case 'string': - return '"' + this.value + '"'; - - case 'boolean': - return this.value; - - case 'undefined': - return this.value; - - case 'null': - return this.value; - - default: - // TODO: move this error to the constructor? - throw new TypeError('Unsupported type of constant "' + this.valueType + '"'); - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - ConstantNode.prototype.forEach = function (callback) { - // nothing to do, we don't have childs - }; - - - /** - * Create a new ConstantNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node) : Node} callback - * @returns {ConstantNode} Returns a clone of the node - */ - ConstantNode.prototype.map = function (callback) { - return this.clone(); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {ConstantNode} - */ - ConstantNode.prototype.clone = function() { - return new ConstantNode(this.value, this.valueType); - }; - - /** - * Get string representation - * @return {String} str - */ - ConstantNode.prototype.toString = function() { - switch (this.valueType) { - case 'string': - return '"' + this.value + '"'; - - default: - return this.value; - } - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - ConstantNode.prototype._toTex = function(callbacks) { - var value = this.value, - index; - switch (this.valueType) { - case 'string': - return '\\text{' + value + '}'; - - case 'number': - index = value.toLowerCase().indexOf('e'); - if (index !== -1) { - return value.substring(0, index) + '\\cdot10^{' + - value.substring(index + 1) + '}'; - } - return value; - - default: - return value; - } - }; - - module.exports = ConstantNode; - - -/***/ }, -/* 183 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var keywords = __webpack_require__(353); - var latex = __webpack_require__(355); - var operators = __webpack_require__(354); - var isString = __webpack_require__(176).isString; - var isArray = Array.isArray; - - /** - * @constructor FunctionAssignmentNode - * @extends {Node} - * Function assignment - * - * @param {String} name Function name - * @param {String[]} params Function parameter names - * @param {Node} expr The function expression - */ - function FunctionAssignmentNode(name, params, expr) { - if (!(this instanceof FunctionAssignmentNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (!isString(name)) throw new TypeError('String expected for parameter "name"'); - if (!isArray(params) || !params.every(isString)) throw new TypeError('Array containing strings expected for parameter "params"'); - if (!(expr instanceof Node)) throw new TypeError('Node expected for parameter "expr"'); - if (name in keywords) throw new Error('Illegal function name, "' + name + '" is a reserved keyword'); - - this.name = name; - this.params = params; - this.expr = expr; - } - - FunctionAssignmentNode.prototype = new Node(); - - FunctionAssignmentNode.prototype.type = 'FunctionAssignmentNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - FunctionAssignmentNode.prototype._compile = function (defs) { - // add the function arguments to defs (used by SymbolNode and UpdateNode) - this.params.forEach(function (variable) { - defs.args[variable] = true; - }); - - return 'scope["' + this.name + '"] = ' + - ' (function () {' + - ' var fn = function ' + this.name + '(' + this.params.join(',') + ') {' + - ' if (arguments.length != ' + this.params.length + ') {' + - // TODO: use util.error.ArgumentsError here? - // TODO: test arguments error - ' throw new SyntaxError("Wrong number of arguments in function ' + this.name + ' (" + arguments.length + " provided, ' + this.params.length + ' expected)");' + - ' }' + - ' return ' + this.expr._compile(defs) + '' + - ' };' + - ' fn.syntax = "' + this.name + '(' + this.params.join(', ') + ')";' + - ' return fn;' + - ' })();'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - FunctionAssignmentNode.prototype.forEach = function (callback) { - callback(this.expr, 'expr', this); - }; - - /** - * Create a new FunctionAssignmentNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {FunctionAssignmentNode} Returns a transformed copy of the node - */ - FunctionAssignmentNode.prototype.map = function (callback) { - var expr = this._ifNode(callback(this.expr, 'expr', this)); - - return new FunctionAssignmentNode(this.name, this.params.slice(0), expr); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {FunctionAssignmentNode} - */ - FunctionAssignmentNode.prototype.clone = function() { - return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr); - }; - - /** - * get string representation - * @return {String} str - */ - FunctionAssignmentNode.prototype.toString = function() { - var precedence = operators.getPrecedence(this); - var exprPrecedence = operators.getPrecedence(this.expr); - - var expr = this.expr.toString(); - if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { - expr = '(' + expr + ')'; - } - return 'function ' + this.name + - '(' + this.params.join(', ') + ') = ' + expr; - }; - - /** - * get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - FunctionAssignmentNode.prototype._toTex = function(callbacks) { - var precedence = operators.getPrecedence(this); - var exprPrecedence = operators.getPrecedence(this.expr); - - var expr = this.expr.toTex(callbacks); - if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { - expr = '\\left(' + expr + '\\right)'; - } - - return latex.toSymbol(this.name) - + '\\left(' + this.params.map(latex.toSymbol).join(',') + '\\right):=' + expr; - }; - - module.exports = FunctionAssignmentNode; - - -/***/ }, -/* 184 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var RangeNode = __webpack_require__(187); - var SymbolNode = __webpack_require__(188); - - var BigNumber = __webpack_require__(351); - var Range = __webpack_require__(4); - - var isNode = Node.isNode; - var isArray = Array.isArray; - - /** - * @constructor IndexNode - * @extends Node - * - * get a subset of a matrix - * - * @param {Node} object - * @param {Node[]} ranges - */ - function IndexNode (object, ranges) { - if (!(this instanceof IndexNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (!(object instanceof Node)) throw new TypeError('Node expected for parameter "object"'); - if (!isArray(ranges) || !ranges.every(isNode)) { - throw new TypeError('Array containing Nodes expected for parameter "ranges"'); - } - - this.object = object; - this.ranges = ranges; - } - - IndexNode.prototype = new Node(); - - IndexNode.prototype.type = 'IndexNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - IndexNode.prototype._compile = function (defs) { - return this.compileSubset(defs); - }; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the - * compiled expression - * @param {String} [replacement] If provided, the function returns - * "math.subset(obj, math.index(...), replacement)" - * Else, the function returns - * "math.subset(obj, math.index(...))" - * @return {String} js - * @returns {string} - */ - IndexNode.prototype.compileSubset = function(defs, replacement) { - // check whether any of the ranges expressions uses the context symbol 'end' - function test(node) { - return (node instanceof SymbolNode) && (node.name == 'end'); - } - - var someUseEnd = false; - var rangesUseEnd = this.ranges.map(function (range) { - var useEnd = range.filter(test).length > 0; - someUseEnd = useEnd ? useEnd : someUseEnd; - return useEnd; - }); - - // create a Range from start, step and end - defs.range = function (start, end, step) { - return new Range( - start instanceof BigNumber ? start.toNumber() : start, - end instanceof BigNumber ? end.toNumber() : end, - step instanceof BigNumber ? step.toNumber() : step - ); - }; - - // TODO: implement support for bignumber (currently bignumbers are silently - // reduced to numbers when changing the value to zero-based) - - // TODO: Optimization: when the range values are ConstantNodes, - // we can beforehand resolve the zero-based value - - var ranges = this.ranges.map(function(range, i) { - var useEnd = rangesUseEnd[i]; - if (range instanceof RangeNode) { - if (useEnd) { - defs.args.end = true; - - // resolve end and create range - return '(function () {' + - ' var end = size[' + i + '];' + - ' return range(' + - ' ' + range.start._compile(defs) + ', ' + - ' ' + range.end._compile(defs) + ', ' + - ' ' + (range.step ? range.step._compile(defs) : '1') + - ' );' + - '})()'; - } - else { - // create range - return 'range(' + - range.start._compile(defs) + ', ' + - range.end._compile(defs) + ', ' + - (range.step ? range.step._compile(defs) : '1') + - ')'; - } - } - else { - if (useEnd) { - defs.args.end = true; - - // resolve the parameter 'end' - return '(function () {' + - ' var end = size[' + i + '];' + - ' return ' + range._compile(defs) + ';' + - '})()' - } - else { - // just evaluate the expression - return range._compile(defs); - } - } - }); - - // if some parameters use the 'end' parameter, we need to calculate the size - if (someUseEnd) { - return '(function () {' + - ' var obj = ' + this.object._compile(defs) + ';' + - ' var size = math.size(obj).valueOf();' + - ' return math.subset(' + - ' obj, ' + - ' math.index(' + ranges.join(', ') + ')' + - ' ' + (replacement ? (', ' + replacement) : '') + - ' );' + - '})()'; - } - else { - return 'math.subset(' + - this.object._compile(defs) + ',' + - 'math.index(' + ranges.join(', ') + ')' + - (replacement ? (', ' + replacement) : '') + - ')'; - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - IndexNode.prototype.forEach = function (callback) { - // object - callback(this.object, 'object', this); - - // ranges - for (var i = 0; i < this.ranges.length; i++) { - callback(this.ranges[i], 'ranges[' + i + ']', this); - } - }; - - /** - * Create a new IndexNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {IndexNode} Returns a transformed copy of the node - */ - IndexNode.prototype.map = function (callback) { - var object = this._ifNode(callback(this.object, 'object', this)); - - var ranges = []; - for (var i = 0; i < this.ranges.length; i++) { - ranges[i] = this._ifNode(callback(this.ranges[i], 'ranges[' + i + ']', this)); - } - - return new IndexNode(object, ranges); - }; - - /** - * Get the name of the object linked to this IndexNode - * @return {string} name - */ - IndexNode.prototype.objectName = function() { - return this.object.name; - }; - - /** - * Create a clone of this node, a shallow copy - * @return {IndexNode} - */ - IndexNode.prototype.clone = function() { - return new IndexNode(this.object, this.ranges.slice(0)); - }; - - /** - * Get string representation - * @return {String} str - */ - IndexNode.prototype.toString = function() { - // format the parameters like "[1, 0:5]" - return this.object.toString() + '[' + this.ranges.join(', ') + ']'; - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - IndexNode.prototype._toTex = function(callbacks) { - var ranges = this.ranges.map(function (range) { - return range.toTex(callbacks); - }); - return this.object.toTex(callbacks) + '_{\\left[' + ranges.join(',') + '\\right]}'; - }; - - module.exports = IndexNode; - - -/***/ }, -/* 185 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190), - ConstantNode = __webpack_require__(182), - SymbolNode = __webpack_require__(188), - FunctionNode = __webpack_require__(186), - latex = __webpack_require__(355), - operators = __webpack_require__(354), - isArray = Array.isArray, - isNode = Node.isNode; - - /** - * @constructor OperatorNode - * @extends {Node} - * An operator with two arguments, like 2+3 - * - * @param {String} op Operator name, for example '+' - * @param {String} fn Function name, for example 'add' - * @param {Node[]} args Operator arguments - */ - function OperatorNode (op, fn, args) { - if (!(this instanceof OperatorNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - //validate input - if (typeof op !== 'string') { - throw new TypeError('string expected for parameter "op"'); - } - if (typeof fn !== 'string') { - throw new TypeError('string expected for parameter "fn"'); - } - if (!isArray(args) || !args.every(isNode)) { - throw new TypeError('Array containing Nodes expected for parameter "args"'); - } - - this.op = op; - this.fn = fn; - this.args = args || []; - } - - OperatorNode.prototype = new Node(); - - OperatorNode.prototype.type = 'OperatorNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - OperatorNode.prototype._compile = function (defs) { - if (!(this.fn in defs.math)) { - throw new Error('Function ' + this.fn + ' missing in provided namespace "math"'); - } - - var args = this.args.map(function (arg) { - return arg._compile(defs); - }); - return 'math.' + this.fn + '(' + args.join(', ') + ')'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - OperatorNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.args.length; i++) { - callback(this.args[i], 'args[' + i + ']', this); - } - }; - - /** - * Create a new OperatorNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {OperatorNode} Returns a transformed copy of the node - */ - OperatorNode.prototype.map = function (callback) { - var args = []; - for (var i = 0; i < this.args.length; i++) { - args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); - } - return new OperatorNode(this.op, this.fn, args); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {OperatorNode} - */ - OperatorNode.prototype.clone = function() { - return new OperatorNode(this.op, this.fn, this.args.slice(0)); - }; - - /** - * Calculate which parentheses are necessary. Gets an OperatorNode - * (which is the root of the tree) and an Array of Nodes - * (this.args) and returns an array where 'true' means that an argument - * has to be enclosed in parentheses whereas 'false' means the opposite. - * - * @param {OperatorNode} root - * @param {Node[]} arguments - * @param {bool} - * @return {bool[]} - * @private - */ - function calculateNecessaryParentheses (root, args, latex) { - //precedence of the root OperatorNode - var precedence = operators.getPrecedence(root); - var associativity = operators.getAssociativity(root); - - switch (args.length) { - case 1: //unary operators - //precedence of the operand - var operandPrecedence = operators.getPrecedence(args[0]); - - //handle special cases for LaTeX, where some of the parentheses aren't needed - if (latex && (operandPrecedence !== null)) { - var operandIdentifier = args[0].getIdentifier(); - var rootIdentifier = root.getIdentifier(); - if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { - return [false]; - } - - if (operators.properties[operandPrecedence][operandIdentifier].latexParens === false) { - return [false]; - } - } - - if (operandPrecedence === null) { - //if the operand has no defined precedence, no parens are needed - return [false]; - } - - if (operandPrecedence <= precedence) { - //if the operands precedence is lower, parens are needed - return [true]; - } - - //otherwise, no parens needed - return [false]; - - case 2: //binary operators - var lhsParens; //left hand side needs parenthesis? - //precedence of the left hand side - var lhsPrecedence = operators.getPrecedence(args[0]); - //is the root node associative with the left hand side - var assocWithLhs = operators.isAssociativeWith(root, args[0]); - - if (lhsPrecedence === null) { - //if the left hand side has no defined precedence, no parens are needed - //FunctionNode for example - lhsParens = false; - } - else if ((lhsPrecedence === precedence) && (associativity === 'right') && !assocWithLhs) { - //In case of equal precedence, if the root node is left associative - // parens are **never** necessary for the left hand side. - //If it is right associative however, parens are necessary - //if the root node isn't associative with the left hand side - lhsParens = true; - } - else if (lhsPrecedence < precedence) { - lhsParens = true; - } - else { - lhsParens = false; - } - - var rhsParens; //right hand side needs parenthesis? - //precedence of the right hand side - var rhsPrecedence = operators.getPrecedence(args[1]); - //is the root node associative with the right hand side? - var assocWithRhs = operators.isAssociativeWith(root, args[1]); - - if (rhsPrecedence === null) { - //if the right hand side has no defined precedence, no parens are needed - //FunctionNode for example - rhsParens = false; - } - else if ((rhsPrecedence === precedence) && (associativity === 'left') && !assocWithRhs) { - //In case of equal precedence, if the root node is right associative - // parens are **never** necessary for the right hand side. - //If it is left associative however, parens are necessary - //if the root node isn't associative with the right hand side - rhsParens = true; - } - else if (rhsPrecedence < precedence) { - rhsParens = true; - } - else { - rhsParens = false; - } - - //handle special cases for LaTeX, where some of the parentheses aren't needed - if (latex) { - var rootIdentifier = root.getIdentifier(); - var lhsIdentifier = root.args[0].getIdentifier(); - var rhsIdentifier = root.args[1].getIdentifier(); - - if (lhsPrecedence !== null) { - if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { - lhsParens = false; - } - - if (operators.properties[lhsPrecedence][lhsIdentifier].latexParens === false) { - lhsParens = false; - } - } - - if (rhsPrecedence !== null) { - if (operators.properties[precedence][rootIdentifier].latexRightParens === false) { - rhsParens = false; - } - - if (operators.properties[rhsPrecedence][rhsIdentifier].latexParens === false) { - rhsParens = false; - } - } - } - - return [lhsParens, rhsParens]; - default: - //behavior is undefined, fall back to putting everything in parens - var parens = []; - args.forEach(function () { - parens.push(true); - }); - return parens; - } - } - - /** - * Get string representation. - * @return {String} str - */ - OperatorNode.prototype.toString = function() { - var args = this.args; - var parens = calculateNecessaryParentheses(this, args, false); - - switch (args.length) { - case 1: //unary operators - var assoc = operators.getAssociativity(this); - - var operand = args[0].toString(); - if (parens[0]) { - operand = '(' + operand + ')'; - } - - if (assoc === 'right') { //prefix operator - return this.op + operand; - } - else if (assoc === 'left') { //postfix - return operand + this.op; - } - - //fall back to postfix - return operand + this.op; - - case 2: - var lhs = args[0].toString(); //left hand side - var rhs = args[1].toString(); //right hand side - if (parens[0]) { //left hand side in parenthesis? - lhs = '(' + lhs + ')'; - } - if (parens[1]) { //right hand side in parenthesis? - rhs = '(' + rhs + ')'; - } - - return lhs + ' ' + this.op + ' ' + rhs; - - default: - //fallback to formatting as a function call - return this.fn + '(' + this.args.join(', ') + ')'; - } - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - OperatorNode.prototype._toTex = function(callbacks) { - var args = this.args; - var parens = calculateNecessaryParentheses(this, args, true); - var op = latex.operators[this.fn]; - op = typeof op === 'undefined' ? this.op : op; //fall back to using this.op - - switch (args.length) { - case 1: //unary operators - var assoc = operators.getAssociativity(this); - - var operand = args[0].toTex(callbacks); - if (parens[0]) { - operand = '\\left(' + operand + '\\right)'; - } - - if (assoc === 'right') { //prefix operator - return op + operand; - } - else if (assoc === 'left') { //postfix operator - return operand + op; - } - - //fall back to postfix - return operand + op; - - case 2: //binary operators - var lhs = args[0]; //left hand side - var lhsTex = lhs.toTex(callbacks); - if (parens[0]) { - lhsTex = '\\left(' + lhsTex + '\\right)'; - } - - var rhs = args[1]; //right hand side - var rhsTex = rhs.toTex(callbacks); - if (parens[1]) { - rhsTex = '\\left(' + rhsTex + '\\right)'; - } - - //handle some exceptions (due to the way LaTeX works) - switch (this.getIdentifier()) { - case 'OperatorNode:divide': - //op contains '\\frac' at this point - return op + '{' + lhsTex + '}' + '{' + rhsTex + '}'; - case 'OperatorNode:pow': - lhsTex = '{' + lhsTex + '}'; - rhsTex = '{' + rhsTex + '}'; - switch (lhs.getIdentifier()) { - case 'ConditionalNode': // - case 'OperatorNode:divide': - lhsTex = '\\left(' + lhsTex + '\\right)'; - } - } - return lhsTex + op + rhsTex; - - default: - //fall back to formatting as a function call - //as this is a fallback, it doesn't use - //fancy function names - return '\\mathrm{' + this.fn + '}\\left(' - + args.map(function (arg) { - return arg.toTex(callbacks); - }).join(',') + '\\right)'; - } - }; - - /** - * Get identifier. - * @return {String} - */ - OperatorNode.prototype.getIdentifier = function () { - return this.type + ':' + this.fn; - }; - - module.exports = OperatorNode; - - -/***/ }, -/* 186 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var SymbolNode = __webpack_require__(188); - - var latex = __webpack_require__(355); - var isNode = Node.isNode; - var isArray = Array.isArray; - - /** - * @constructor FunctionNode - * @extends {Node} - * invoke a list with arguments on a node - * @param {string} name - * @param {Node[]} args - */ - function FunctionNode (name, args) { - if (!(this instanceof FunctionNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (typeof name !== 'string') throw new TypeError('string expected for parameter "name"'); - if (!isArray(args) || !args.every(isNode)) { - throw new TypeError('Array containing Nodes expected for parameter "args"'); - } - - this.name = name; - this.args = args || []; - } - - FunctionNode.prototype = new Node(); - - FunctionNode.prototype.type = 'FunctionNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - FunctionNode.prototype._compile = function (defs) { - var fn = defs.math[this.name]; - var isRaw = (typeof fn === 'function') && (fn.rawArgs == true); - - // compile the parameters - var args = this.args.map(function (arg) { - return arg._compile(defs); - }); - - if (isRaw) { - // pass unevaluated parameters (nodes) to the function - var paramsName; - do { - paramsName = 'p' + Math.round(Math.random() * 10000); - } - while (paramsName in defs); - defs[paramsName] = this.args; - - return '("' + this.name + '" in scope ? ' + - 'scope["' + this.name + '"](' + args.join(', ') + ') : ' + - 'math["' + this.name + '"]' + '(' + paramsName + ', math, scope))'; - } - else { - // "regular" evaluation - var symbol = new SymbolNode(this.name); - return symbol._compile(defs) + '(' + args.join(', ') + ')'; - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - FunctionNode.prototype.forEach = function (callback) { - for (var i = 0; i < this.args.length; i++) { - callback(this.args[i], 'args[' + i + ']', this); - } - }; - - /** - * Create a new FunctionNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {FunctionNode} Returns a transformed copy of the node - */ - FunctionNode.prototype.map = function (callback) { - var args = []; - for (var i = 0; i < this.args.length; i++) { - args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); - } - return new FunctionNode(this.name, args); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {FunctionNode} - */ - FunctionNode.prototype.clone = function() { - return new FunctionNode(this.name, this.args.slice(0)); - }; - - /** - * Get string representation - * @return {String} str - */ - FunctionNode.prototype.toString = function() { - // format the parameters like "add(2, 4.2)" - return this.name + '(' + this.args.join(', ') + ')'; - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - */ - FunctionNode.prototype._toTex = function(callbacks) { - return latex.toFunction(this, callbacks, this.name); - }; - - /** - * Get identifier. - * @return {String} - */ - FunctionNode.prototype.getIdentifier = function () { - return this.type + ':' + this.name; - }; - - module.exports = FunctionNode; - - -/***/ }, -/* 187 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190); - var operators = __webpack_require__(354); - - var isNode = Node.isNode; - - /** - * @constructor RangeNode - * @extends {Node} - * create a range - * @param {Node} start included lower-bound - * @param {Node} end included lower-bound - * @param {Node} [step] optional step - */ - function RangeNode (start, end, step) { - if (!(this instanceof RangeNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate inputs - if (!isNode(start)) throw new TypeError('Node expected'); - if (!isNode(end)) throw new TypeError('Node expected'); - if (step && !isNode(step)) throw new TypeError('Node expected'); - if (arguments.length > 3) throw new Error('Too many arguments'); - - this.start = start; // included lower-bound - this.end = end; // included upper-bound - this.step = step || null; // optional step - } - - RangeNode.prototype = new Node(); - - RangeNode.prototype.type = 'RangeNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - RangeNode.prototype._compile = function (defs) { - return 'math.range(' + - this.start._compile(defs) + ', ' + - this.end._compile(defs) + - (this.step ? (', ' + this.step._compile(defs)) : '') + - ')'; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - RangeNode.prototype.forEach = function (callback) { - callback(this.start, 'start', this); - callback(this.end, 'end', this); - if (this.step) { - callback(this.step, 'step', this); - } - }; - - /** - * Create a new RangeNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {RangeNode} Returns a transformed copy of the node - */ - RangeNode.prototype.map = function (callback) { - return new RangeNode( - this._ifNode(callback(this.start, 'start', this)), - this._ifNode(callback(this.end, 'end', this)), - this.step && this._ifNode(callback(this.step, 'step', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {RangeNode} - */ - RangeNode.prototype.clone = function() { - return new RangeNode(this.start, this.end, this.step && this.step); - }; - - /** - * Get string representation - * @return {String} str - */ - RangeNode.prototype.toString = function() { - var precedence = operators.getPrecedence(this); - - //format string as start:step:stop - var str; - - var start = this.start.toString(); - var startPrecedence = operators.getPrecedence(this.start); - if ((startPrecedence !== null) && (startPrecedence <= precedence)) { - start = '(' + start + ')'; - } - str = start; - - if (this.step) { - var step = this.step.toString(); - var stepPrecedence = operators.getPrecedence(this.step); - if ((stepPrecedence !== null) && (stepPrecedence <= precedence)) { - step = '(' + step + ')'; - } - str += ':' + step; - } - - var end = this.end.toString(); - var endPrecedence = operators.getPrecedence(this.end); - if ((endPrecedence !== null) && (endPrecedence <= precedence)) { - end = '(' + end + ')'; - } - str += ':' + end; - - return str; - }; - - /** - * Get LaTeX representation - * @params {Object|function} callback(s) - * @return {String} str - */ - RangeNode.prototype._toTex = function(callbacks) { - var str = this.start.toTex(callbacks); - if (this.step) { - str += ':' + this.step.toTex(callbacks); - } - str += ':' + this.end.toTex(callbacks); - - return str; - }; - - module.exports = RangeNode; - - -/***/ }, -/* 188 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190), - Unit = __webpack_require__(7), - - latex = __webpack_require__(355), - isString = __webpack_require__(176).isString; - - /** - * @constructor SymbolNode - * @extends {Node} - * A symbol node can hold and resolve a symbol - * @param {String} name - * @extends {Node} - */ - function SymbolNode(name) { - if (!(this instanceof SymbolNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - // validate input - if (!isString(name)) throw new TypeError('String expected for parameter "name"'); - - this.name = name; - } - - SymbolNode.prototype = new Node(); - - SymbolNode.prototype.type = 'SymbolNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - SymbolNode.prototype._compile = function (defs) { - // add a function to the definitions - defs['undef'] = undef; - defs['Unit'] = Unit; - - if (this.name in defs.args) { - // this is a FunctionAssignment argument - // (like an x when inside the expression of a function assignment `f(x) = ...`) - return this.name; - } - else if (this.name in defs.math) { - return '("' + this.name + '" in scope ? scope["' + this.name + '"] : math["' + this.name + '"])'; - } - else { - return '(' + - '"' + this.name + '" in scope ? scope["' + this.name + '"] : ' + - (Unit.isValuelessUnit(this.name) ? - 'new Unit(null, "' + this.name + '")' : - 'undef("' + this.name + '")') + - ')'; - } - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - SymbolNode.prototype.forEach = function (callback) { - // nothing to do, we don't have childs - }; - - /** - * Create a new SymbolNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node) : Node} callback - * @returns {SymbolNode} Returns a clone of the node - */ - SymbolNode.prototype.map = function (callback) { - return this.clone(); - }; - - /** - * Throws an error 'Undefined symbol {name}' - * @param {String} name - */ - function undef (name) { - throw new Error('Undefined symbol ' + name); - } - - /** - * Create a clone of this node, a shallow copy - * @return {SymbolNode} - */ - SymbolNode.prototype.clone = function() { - return new SymbolNode(this.name); - }; - - /** - * Get string representation - * @return {String} str - * @override - */ - SymbolNode.prototype.toString = function() { - return this.name; - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} str - * @override - */ - SymbolNode.prototype._toTex = function(callbacks) { - var symbol = latex.toSymbol(this.name); - if (symbol[0] === '\\') { - //no space needed if the symbol starts with '\' - return symbol; - } - //the space prevents symbols from breaking stuff like '\cdot' if it's written right before the symbol - return ' ' + symbol; - }; - - module.exports = SymbolNode; - - -/***/ }, -/* 189 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var Node = __webpack_require__(190), - IndexNode = __webpack_require__(184); - - /** - * @constructor UpdateNode - * @extends {Node} - * Update a matrix subset, like A[2,3] = 4.5 - * - * @param {IndexNode} index IndexNode containing symbol and ranges - * @param {Node} expr The expression defining the symbol - */ - function UpdateNode(index, expr) { - if (!(this instanceof UpdateNode)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - - if (!(index instanceof IndexNode)) { - throw new TypeError('Expected IndexNode for parameter "index"'); - } - if (!(expr instanceof Node)) { - throw new TypeError('Expected Node for parameter "expr"'); - } - - this.index = index; - this.expr = expr; - } - - UpdateNode.prototype = new Node(); - - UpdateNode.prototype.type = 'UpdateNode'; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * or constants globally available for the compiled - * expression - * @return {String} js - * @private - */ - UpdateNode.prototype._compile = function (defs) { - var lhs = (this.index.objectName() in defs.args) - ? this.name + ' = ' // this is a FunctionAssignment argument - : 'scope["' + this.index.objectName() + '\"]'; - - var rhs = this.index.compileSubset(defs, this.expr._compile(defs)); - - return lhs + ' = ' + rhs; - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - UpdateNode.prototype.forEach = function (callback) { - callback(this.index, 'index', this); - callback(this.expr, 'expr', this); - }; - - /** - * Create a new UpdateNode having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {UpdateNode} Returns a transformed copy of the node - */ - UpdateNode.prototype.map = function (callback) { - return new UpdateNode( - this._ifNode(callback(this.index, 'index', this)), - this._ifNode(callback(this.expr, 'expr', this)) - ); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {UpdateNode} - */ - UpdateNode.prototype.clone = function() { - return new UpdateNode(this.index, this.expr); - }; - - /** - * Get string representation - * @return {String} - */ - UpdateNode.prototype.toString = function() { - return this.index.toString() + ' = ' + this.expr.toString(); - }; - - /** - * Get LaTeX representation - * @param {Object|function} callback(s) - * @return {String} - */ - UpdateNode.prototype._toTex = function(callbacks) { - return this.index.toTex(callbacks) + ':=' + this.expr.toTex(callbacks); - }; - - module.exports = UpdateNode; - - -/***/ }, -/* 190 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var keywords = __webpack_require__(353); - - /** - * Node - */ - function Node() { - if (!(this instanceof Node)) { - throw new SyntaxError('Constructor must be called with the new operator'); - } - } - - /** - * Evaluate the node - * @return {*} result - */ - // TODO: cleanup deprecated code one day. Deprecated since version 0.19.0 - Node.prototype.eval = function () { - throw new Error('Node.eval is deprecated. ' + - 'Use Node.compile(math).eval([scope]) instead.'); - }; - - Node.prototype.type = 'Node'; - - /** - * Compile the node to javascript code - * @param {Object} math math.js instance - * @return {{eval: function}} expr Returns an object with a function 'eval', - * which can be invoked as expr.eval([scope]), - * where scope is an optional object with - * variables. - */ - Node.prototype.compile = function (math) { - if (!(math instanceof Object)) { - throw new TypeError('Object expected for parameter math'); - } - - // definitions globally available inside the closure of the compiled expressions - var defs = { - math: _transform(math), - args: {}, // can be filled with names of FunctionAssignment arguments - _validateScope: _validateScope - }; - - var code = this._compile(defs); - - var defsCode = Object.keys(defs).map(function (name) { - return ' var ' + name + ' = defs["' + name + '"];'; - }); - - var factoryCode = - defsCode.join(' ') + - 'return {' + - ' "eval": function (scope) {' + - ' if (scope) _validateScope(scope);' + - ' scope = scope || {};' + - ' return ' + code + ';' + - ' }' + - '};'; - - var factory = new Function ('defs', factoryCode); - return factory(defs); - }; - - /** - * Compile the node to javascript code - * @param {Object} defs Object which can be used to define functions - * and constants globally available inside the closure - * of the compiled expression - * @return {String} js - * @private - */ - Node.prototype._compile = function (defs) { - // must be implemented by each of the Node implementations - throw new Error('Cannot compile a Node interface'); - }; - - /** - * Execute a callback for each of the child nodes of this node - * @param {function(child: Node, path: string, parent: Node)} callback - */ - Node.prototype.forEach = function (callback) { - // must be implemented by each of the Node implementations - throw new Error('Cannot run forEach on a Node interface'); - }; - - /** - * Create a new Node having it's childs be the results of calling - * the provided callback function for each of the childs of the original node. - * @param {function(child: Node, path: string, parent: Node): Node} callback - * @returns {OperatorNode} Returns a transformed copy of the node - */ - Node.prototype.map = function (callback) { - // must be implemented by each of the Node implementations - throw new Error('Cannot run map on a Node interface'); - }; - - /** - * Validate whether an object is a Node, for use with map - * @param {Node} node - * @returns {Node} Returns the input if it's a node, else throws an Error - * @protected - */ - Node.prototype._ifNode = function (node) { - if (!(node instanceof Node)) { - throw new TypeError('Callback function must return a Node'); - } - - return node; - }; - - /** - * Recursively traverse all nodes in a node tree. Executes given callback for - * this node and each of its child nodes. - * @param {function(node: Node, path: string, parent: Node)} callback - * A callback called for every node in the node tree. - */ - Node.prototype.traverse = function (callback) { - // execute callback for itself - callback(this, null, null); - - // recursively traverse over all childs of a node - function _traverse (node, callback) { - node.forEach(function(child, path, parent) { - callback(child, path, parent); - _traverse(child, callback); - }); - } - _traverse(this, callback); - }; - - /** - * Recursively transform a node tree via a transform function. - * - * For example, to replace all nodes of type SymbolNode having name 'x' with a - * ConstantNode with value 2: - * - * var res = Node.transform(function (node, path, parent) { - * if (node instanceof SymbolNode) && (node.name == 'x')) { - * return new ConstantNode(2); - * } - * else { - * return node; - * } - * }); - * - * @param {function(node: Node, path: string, parent: Node) : Node} callback - * A mapping function accepting a node, and returning - * a replacement for the node or the original node. - * Signature: callback(node: Node, index: string, parent: Node) : Node - * @return {Node} Returns the original node or its replacement - */ - Node.prototype.transform = function (callback) { - // check itself - var replacement = callback(this, null, null); - if (replacement !== this) { - return replacement; - } - - // traverse over all childs - function _transform (node, callback) { - return node.map(function(child, path, parent) { - var replacement = callback(child, path, parent); - return (replacement !== child) ? replacement : _transform(child, callback); - }); - } - return _transform(this, callback); - }; - - /** - * Find any node in the node tree matching given filter function. For example, to - * find all nodes of type SymbolNode having name 'x': - * - * var results = Node.filter(function (node) { - * return (node instanceof SymbolNode) && (node.name == 'x'); - * }); - * - * @param {function(node: Node, path: string, parent: Node) : Node} callback - * A test function returning true when a node matches, and false - * otherwise. Function signature: - * callback(node: Node, index: string, parent: Node) : boolean - * @return {Node[]} nodes An array with nodes matching given filter criteria - */ - Node.prototype.filter = function (callback) { - var nodes = []; - - this.traverse(function (node, path, parent) { - if (callback(node, path, parent)) { - nodes.push(node); - } - }); - - return nodes; - }; - - // TODO: deprecated since version 1.1.0, remove this some day - Node.prototype.find = function () { - throw new Error('Function Node.find is deprecated. Use Node.filter instead.'); - }; - - // TODO: deprecated since version 1.1.0, remove this some day - Node.prototype.match = function () { - throw new Error('Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.'); - }; - - /** - * Create a clone of this node, a shallow copy - * @return {Node} - */ - Node.prototype.clone = function() { - // must be implemented by each of the Node implementations - throw new Error('Cannot clone a Node interface'); - }; - - /** - * Get string representation - * @return {String} - */ - Node.prototype.toString = function() { - return ''; - }; - - /** - * Get LaTeX representation. (wrapper function) - * This functions get's either an object containing callbacks or - * a single callback. It decides whether to call the callback and if - * not or if the callback returns nothing, it calls the default - * LaTeX implementation of the node (_toTex). - * - * @param {Object|function} callback(s) - * @return {String} - */ - Node.prototype.toTex = function(callback) { - var customTex; - if (this.type === 'ArrayNode') { - //FIXME this is only a workaround for a breaking change, - //remove this in version2 - delete this.latexType; - } - if (typeof callback === 'object') { - if ((this.type === 'FunctionNode') && callback.hasOwnProperty(this.name)) { - //if callback is a map of callback functions and this is a FunctionNode - customTex = callback[this.name](this, callback); - } - } - else if (typeof callback === 'function') { - //if callback is a function - customTex = callback(this, callback); - } - else if ((typeof callback === 'string') && (this.type === 'ArrayNode')) { - //FIXME this is only a workaround for a breaking change, - //remove this in version2 - this.latexType = callback; - } - else if (typeof callback !== 'undefined') { - throw new TypeError('Object or function expected as callback'); - } - - if (typeof customTex !== 'undefined') { - return customTex; - } - - return this._toTex(callback); - }; - - /** - * Internal function to generate the LaTeX output. - * This has to be implemented by every Node - * - * @param {Object}|function} - * @throws {Error} - */ - Node.prototype._toTex = function () { - if (this.type === 'Node') { - //FIXME remove this in v2 - return ''; - } - //must be implemented by each of the Node implementations - throw new Error('_toTex not implemented for this Node'); - }; - - /** - * Get identifier. - * @return {String} - */ - Node.prototype.getIdentifier = function () { - return this.type; - }; - - /** - * Test whether an object is a Node - * @param {*} object - * @returns {boolean} isNode - */ - Node.isNode = function(object) { - return object instanceof Node; - }; - - /** - * Validate the symbol names of a scope. - * Throws an error when the scope contains an illegal symbol. - * @param {Object} scope - */ - function _validateScope (scope) { - for (var symbol in scope) { - if (scope.hasOwnProperty(symbol)) { - if (symbol in keywords) { - throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword'); - } - } - } - } - - /** - * Replace all functions having a transform function attached at property transform - * with their transform. - * @param {Object} math - * @return {Object} transformed - * @private - */ - function _transform(math) { - var transformed = Object.create(math); - - if (math.expression && math.expression.transform) { - for (var name in math.expression.transform) { - if (math.expression.transform.hasOwnProperty(name)) { - transformed[name] = math.expression.transform[name]; - } - } - } - - return transformed; - } - - module.exports = Node; - - -/***/ }, -/* 191 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 192 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'false', - 'category': 'Constants', - 'syntax': [ - 'false' - ], - 'description': 'Boolean value false', - 'examples': [ - 'false' - ], - 'seealso': ['true'] - }; - - -/***/ }, -/* 193 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 194 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 195 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'LN2', - 'category': 'Constants', - 'syntax': [ - 'LN2' - ], - 'description': 'Returns the natural logarithm of 2, approximately equal to 0.693', - 'examples': [ - 'LN2', - 'log(2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 196 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'LN10', - 'category': 'Constants', - 'syntax': [ - 'LN10' - ], - 'description': 'Returns the natural logarithm of 10, approximately equal to 2.302', - 'examples': [ - 'LN10', - 'log(10)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 197 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 198 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 199 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'NaN', - 'category': 'Constants', - 'syntax': [ - 'NaN' - ], - 'description': 'Not a number', - 'examples': [ - 'NaN', - '0 / 0' - ], - 'seealso': [] - }; - - -/***/ }, -/* 200 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'null', - 'category': 'Constants', - 'syntax': [ - 'null' - ], - 'description': 'Value null', - 'examples': [ - 'null' - ], - 'seealso': ['true', 'false'] - }; - - -/***/ }, -/* 201 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 202 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'phi', - 'category': 'Constants', - 'syntax': [ - 'phi' - ], - 'description': 'Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...', - 'examples': [ - 'tau' - ], - 'seealso': [] - }; - - -/***/ }, -/* 203 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 204 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'SQRT2', - 'category': 'Constants', - 'syntax': [ - 'SQRT2' - ], - 'description': 'Returns the square root of 2, approximately equal to 1.414', - 'examples': [ - 'SQRT2', - 'sqrt(2)' - ], - 'seealso': [] - }; - - -/***/ }, -/* 205 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'tau', - 'category': 'Constants', - 'syntax': [ - 'tau' - ], - 'description': 'Tau is the ratio constant of a circle\'s circumference to radius, equal to 2 * pi, approximately 6.2832.', - 'examples': [ - 'tau', - '2 * pi' - ], - 'seealso': ['pi'] - }; - - -/***/ }, -/* 206 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'true', - 'category': 'Constants', - 'syntax': [ - 'true' - ], - 'description': 'Boolean value true', - 'examples': [ - 'true' - ], - 'seealso': ['false'] - }; - - -/***/ }, -/* 207 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'version', - 'category': 'Constants', - 'syntax': [ - 'version' - ], - 'description': 'A string with the version number of math.js', - 'examples': [ - 'version' - ], - 'seealso': [] - }; - - -/***/ }, -/* 208 */ -/***/ function(module, exports, __webpack_require__) { - - var DimensionError = __webpack_require__(174); - var IndexError = __webpack_require__(173); - - /** - * Transform zero-based indices to one-based indices in errors - * @param {Error} err - * @returns {Error} Returns the transformed error - */ - exports.transform = function (err) { - if (err instanceof IndexError) { - return new IndexError(err.index + 1, err.min + 1, err.max + 1); - } - - return err; - }; - - -/***/ }, -/* 209 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - /** - * Test whether value is a Boolean - * @param {*} value - * @return {Boolean} isBoolean - */ - exports.isBoolean = function(value) { - return (value instanceof Boolean) || (typeof value == 'boolean'); - }; - - -/***/ }, -/* 210 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory() { + function factory (type, config, load, typed, math) { + var Parser = load(__webpack_require__(52)); /** - * Copies a sparse vector into a dense one. Computes x = x + v * A(:,j) + * Create a parser. The function creates a new `math.expression.Parser` object. * - * @param {Matrix} a The source sparse matrix - * @param {Number} j The columns in the sparse matrix to copy the values from - * @param {Scalar} v The value to use in the calculation - * @param {Array} w Array with marks indicating the column j has been copied for a given row - * @param {Array} x The dense vector of values - * @param {Number} mark The value column j must have in w array - * @param {Matrix} c The target sparce matrix + * Syntax: * - * @return {Number} The nonzero elements in matrix c - * @private + * math.parser() + * + * Examples: + * + * var parser = new math.parser(); + * + * // evaluate expressions + * var a = parser.eval('sqrt(3^2 + 4^2)'); // 5 + * var b = parser.eval('sqrt(-4)'); // 2i + * var c = parser.eval('2 inch in cm'); // 5.08 cm + * var d = parser.eval('cos(45 deg)'); // 0.7071067811865476 + * + * // define variables and functions + * parser.eval('x = 7 / 2'); // 3.5 + * parser.eval('x + 3'); // 6.5 + * parser.eval('function f(x, y) = x^y'); // f(x, y) + * parser.eval('f(2, 3)'); // 8 + * + * // get and set variables and functions + * var x = parser.get('x'); // 7 + * var f = parser.get('f'); // function + * var g = f(3, 2); // 9 + * parser.set('h', 500); + * var i = parser.eval('h / 2'); // 250 + * parser.set('hello', function (name) { + * return 'hello, ' + name + '!'; + * }); + * parser.eval('hello("user")'); // "hello, user!" + * + * // clear defined functions and variables + * parser.clear(); + * + * See also: + * + * eval, compile, parse + * + * @return {Parser} Parser */ - var sparseScatter = function (a, j, v, w, x, mark, c, multiply, add) { - // a arrays - var avalues = a._values; - var aindex = a._index; - var aptr = a._ptr; - // c arrays - var cindex = c._index; - - // check we need to process values - if (x) { - // values in j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - var i = aindex[k]; - // check value exists in current j - if (w[i] !== mark) { - // i is new entry in j - w[i] = mark; - // add i to pattern of C - cindex.push(i); - // x(i) = A - x[i] = multiply(v, avalues[k]); - } - else { - // i exists in C already - x[i] = add(x[i], multiply(v, avalues[k])); - } - } + return typed('parser', { + '': function () { + return new Parser(math); } - else { - // values in j - for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { - // row - var i = aindex[k]; - // check value exists in current j - if (w[i] !== mark) { - // i is new entry in j - w[i] = mark; - // add i to pattern of C - cindex.push(i); - } - } - } - // number of nonzero elements in C - return cindex.length; - }; - - return sparseScatter; + }); } - exports.name = 'sparseScatter'; + exports.name = 'parser'; exports.factory = factory; + exports.math = true; // requires the math namespace as 5th argument /***/ }, -/* 211 */ +/* 44 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - function factory(type, config, load, typed) { + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); /** - * Add two scalar values, `x + y`. - * This function is meant for internal use: it is used by the public function - * `add` + * Test whether value x is smaller than y. * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. + * The function returns true when x is smaller than y and the relative + * difference between x and y is larger than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. * - * @param {Number | BigNumber | Boolean | Complex | Unit | null} x First value to add - * @param {Number | BigNumber | Boolean | Complex | null} y Second value to add - * @return {Number | BigNumber | Complex | Unit} Sum of `x` and `y` - * @private + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.smaller(x, y) + * + * Examples: + * + * math.smaller(2, 3); // returns true + * math.smaller(5, 2 * 2); // returns false + * + * var a = math.unit('5 cm'); + * var b = math.unit('2 inch'); + * math.smaller(a, b); // returns true + * + * See also: + * + * equal, unequal, smallerEq, larger, largerEq, compare + * + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false */ - var addScalar = typed('addScalar', { - - 'number, number': function (x, y) { - return x + y; + var smaller = typed('smaller', { + 'boolean, boolean': function (x, y) { + return x < y; }, - 'Complex, Complex': function (x, y) { - return new type.Complex( - x.re + y.re, - x.im + y.im - ); + 'number, number': function (x, y) { + return x < y && !nearlyEqual(x, y, config.epsilon); }, 'BigNumber, BigNumber': function (x, y) { - return x.plus(y); + return x.lt(y); + }, + + 'Complex, Complex': function (x, y) { + throw new TypeError('No ordering relation is defined for complex numbers'); }, 'Unit, Unit': function (x, y) { - if (x.value == null) throw new Error('Parameter x contains a unit with undefined value'); - if (y.value == null) throw new Error('Parameter y contains a unit with undefined value'); - if (!x.equalBase(y)) throw new Error('Units do not match'); - - var res = x.clone(); - res.value += y.value; - res.fixPrefix = false; - return res; + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return x.value < y.value && !nearlyEqual(x.value, y.value, config.epsilon); }, - + 'string, string': function (x, y) { - return x + y; + return x < y; + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, smaller); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, smaller); } }); - return addScalar; + return smaller; } - exports.name = 'addScalar'; + exports.name = 'smaller'; exports.factory = factory; /***/ }, -/* 212 */ +/* 45 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - function factory(type, config, load, typed) { - + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + /** - * Multiply two scalar values, `x * y`. - * This function is meant for internal use: it is used by the public function - * `multiply` + * Test whether value x is larger than y. * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. + * The function returns true when x is larger than y and the relative + * difference between x and y is larger than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. * - * @param {Number | BigNumber | Boolean | Complex | Unit | null} x First value to multiply - * @param {Number | BigNumber | Boolean | Complex | null} y Second value to multiply - * @return {Number | BigNumber | Complex | Unit} Multiplication of `x` and `y` - * @private + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.larger(x, y) + * + * Examples: + * + * math.larger(2, 3); // returns false + * math.larger(5, 2 + 2); // returns true + * + * var a = math.unit('5 cm'); + * var b = math.unit('2 inch'); + * math.larger(a, b); // returns false + * + * See also: + * + * equal, unequal, smaller, smallerEq, largerEq, compare + * + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the x is larger than y, else returns false */ - var multiplyScalar = typed('multiplyScalar', { + var larger = typed('larger', { + 'boolean, boolean': function (x, y) { + return x > y; + }, 'number, number': function (x, y) { - return x * y; + return x > y && !nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.gt(y); }, 'Complex, Complex': function (x, y) { - return new type.Complex( - x.re * y.re - x.im * y.im, - x.re * y.im + x.im * y.re - ); + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return x.value > y.value && !nearlyEqual(x.value, y.value, config.epsilon); + }, + + 'string, string': function (x, y) { + return x > y; + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, larger); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, larger); + } + }); + + return larger; + } + + exports.name = 'larger'; + exports.factory = factory; + + +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + /** + * Test whether two values are equal. + * + * The function tests whether the relative difference between x and y is + * smaller than the configured epsilon. The function cannot be used to + * compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * In case of complex numbers, x.re must equal y.re, and x.im must equal y.im. + * + * Values `null` and `undefined` are compared strictly, thus `null` is only + * equal to `null` and nothing else, and `undefined` is only equal to + * `undefined` and nothing else. + * + * Syntax: + * + * math.equal(x, y) + * + * Examples: + * + * math.equal(2 + 2, 3); // returns false + * math.equal(2 + 2, 4); // returns true + * + * var a = math.unit('50 cm'); + * var b = math.unit('5 m'); + * math.equal(a, b); // returns true + * + * var c = [2, 5, 1]; + * var d = [2, 7, 1]; + * + * math.equal(c, d); // returns [true, false, true] + * math.deepEqual(c, d); // returns false + * + * math.equal(0, null); // returns false + * + * See also: + * + * unequal, smaller, smallerEq, larger, largerEq, compare, deepEqual + * + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} x First value to compare + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the compared values are equal, else returns false + */ + var equal = typed('equal', { + 'any, any': function (x, y) { + // strict equality for null and undefined? + if (x === null) { return y === null; } + if (y === null) { return x === null; } + if (x === undefined) { return y === undefined; } + if (y === undefined) { return x === undefined; } + + return _equal(x, y); + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, _equal); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, _equal); + } + }); + + var _equal = typed('_equal', { + 'boolean, boolean': function (x, y) { + return x === y; + }, + + 'number, number': function (x, y) { + return x === y || nearlyEqual(x, y, config.epsilon); }, 'BigNumber, BigNumber': function (x, y) { - return x.times(y); + return x.eq(y); + }, + + 'Complex, Complex': function (x, y) { + return (x.re === y.re || nearlyEqual(x.re, y.re, config.epsilon)) && + (x.im === y.im || nearlyEqual(x.im, y.im, config.epsilon)); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return x.value === y.value || nearlyEqual(x.value, y.value, config.epsilon); + }, + + 'string, string': function (x, y) { + return x === y; + } + }); + + return equal; + } + + exports.name = 'equal'; + exports.factory = factory; + + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var addScalar = load(__webpack_require__(192)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Add two values, `x + y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.add(x, y) + * + * Examples: + * + * math.add(2, 3); // returns Number 5 + * + * var a = math.complex(2, 3); + * var b = math.complex(-4, 1); + * math.add(a, b); // returns Complex -2 + 4i + * + * math.add([1, 2, 3], 4); // returns Array [5, 6, 7] + * + * var c = math.unit('5 cm'); + * var d = math.unit('2.1 mm'); + * math.add(c, d); // returns Unit 52.1 mm + * + * See also: + * + * subtract + * + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null} x First value to add + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null} y Second value to add + * @return {Number | BigNumber | Complex | Unit | String | Array | Matrix} Sum of `x` and `y` + */ + var add = typed('add', { + + 'any, any': addScalar, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm4(x, y, addScalar); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm1(y, x, addScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm1(x, y, addScalar, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, addScalar); + break; + } + break; + } + return c; }, - 'number, Unit': function (x, y) { - var res = y.clone(); - res.value = (res.value === null) ? res._normalize(x) : (res.value * x); - return res; + 'Array, Array': function (x, y) { + // use matrix implementation + return add(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return add(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return add(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(x, y, addScalar, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, addScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, addScalar, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, addScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, addScalar, false).valueOf(); }, - 'Unit, number': function (x, y) { - var res = x.clone(); - res.value = (res.value === null) ? res._normalize(y) : (res.value * y); - return res; - }, + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, addScalar, true).valueOf(); + } }); - - return multiplyScalar; + + return add; } - exports.name = 'multiplyScalar'; + exports.name = 'add'; exports.factory = factory; /***/ }, -/* 213 */ +/* 48 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - function factory(type, config, load, typed) { - /** - * Divide two scalar values, `x / y`. - * This function is meant for internal use: it is used by the public functions - * `divide` and `inv`. - * - * This function does not support collections (Array or Matrix), and does - * not validate the number of of inputs. - * - * @param {Number | BigNumber | Boolean | Complex | Unit | null} x Numerator - * @param {Number | BigNumber | Boolean | Complex | null} y Denominator - * @return {Number | BigNumber | Complex | Unit} Quotient, `x / y` - * @private - */ - var divideScalar = typed('divideScalar', { - 'number, number': function (x, y) { - return x / y; - }, - - 'Complex, Complex': _divideComplex, - - 'BigNumber, BigNumber': function (x, y) { - return x.div(y); - }, - - 'Unit, number': function (x, y) { - var res = x.clone(); - res.value = ((res.value === null) ? res._normalize(1) : res.value) / y; - return res; - } - }); - - /** - * Divide two complex numbers. x / y or divide(x, y) - * @param {Complex} x - * @param {Complex} y - * @return {Complex} res - * @private - */ - function _divideComplex (x, y) { - var den = y.re * y.re + y.im * y.im; - if (den != 0) { - return new type.Complex( - (x.re * y.re + x.im * y.im) / den, - (x.im * y.re - x.re * y.im) / den - ); - } - else { - // both y.re and y.im are zero - return new type.Complex( - (x.re != 0) ? (x.re / 0) : 0, - (x.im != 0) ? (x.im / 0) : 0 - ); - } - } - - return divideScalar; - } - - exports.name = 'divideScalar'; - exports.factory = factory; - - -/***/ }, -/* 214 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - var BigNumber = __webpack_require__(351); - var isNumber = __webpack_require__(175).isNumber; - var digits = __webpack_require__(175).digits; - var memoize = __webpack_require__(350).memoize; + var BigNumber = __webpack_require__(191); + var isNumber = __webpack_require__(41).isNumber; + var digits = __webpack_require__(41).digits; + var memoize = __webpack_require__(188).memoize; /** * Test whether value is a BigNumber @@ -27624,225 +9986,15826 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 215 */ +/* 49 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = '2.0.0-SNAPSHOT'; + // Note: This file is automatically generated when building math.js. + // Changes made in this file will be overwritten. + + +/***/ }, +/* 50 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var ArgumentsError = __webpack_require__(177); + exports.ArgumentsError = __webpack_require__(194); + exports.DimensionError = __webpack_require__(39); + exports.IndexError = __webpack_require__(38); + + // TODO: implement an InvalidValueError? + + +/***/ }, +/* 51 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var ArgumentsError = __webpack_require__(194); - // TODO: rethink math.distribution - // TODO: rework to a typed function function factory (type, config, load, typed) { var collection = load(__webpack_require__(2)); - var matrix = load(__webpack_require__(75)); - var array = __webpack_require__(172); - var isCollection = collection.isCollection; + var ArrayNode = load(__webpack_require__(195)); + var AssignmentNode = load(__webpack_require__(196)); + var BlockNode = load(__webpack_require__(197)); + var ConditionalNode = load(__webpack_require__(198)); + var ConstantNode = load(__webpack_require__(199)); + var FunctionAssignmentNode = load(__webpack_require__(200)); + var IndexNode = load(__webpack_require__(201)); + var OperatorNode = load(__webpack_require__(202)); + var FunctionNode = load(__webpack_require__(203)); + var RangeNode = load(__webpack_require__(204)); + var SymbolNode = load(__webpack_require__(205)); + var UpdateNode = load(__webpack_require__(206)); + /** - * Create a distribution object with a set of random functions for given - * random distribution. + * Parse an expression. Returns a node tree, which can be evaluated by + * invoking node.eval(); * * Syntax: * - * math.distribution(name) + * parse(expr) + * parse(expr, options) + * parse([expr1, expr2, expr3, ...]) + * parse([expr1, expr2, expr3, ...], options) * - * Examples: + * Example: * - * var normalDist = math.distribution('normal'); // create a normal distribution - * normalDist.random(0, 10); // get a random value between 0 and 10 + * var node = parse('sqrt(3^2 + 4^2)'); + * node.compile(math).eval(); // 5 * - * See also: + * var scope = {a:3, b:4} + * var node = parse('a * b'); // 12 + * var code = node.compile(math); + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 * - * random, randomInt, pickRandom + * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); + * nodes[2].compile(math).eval(); // 12 * - * @param {String} name Name of a distribution. Choose from 'uniform', 'normal'. - * @return {Object} Returns a distribution object containing functions: - * `random([size] [, min] [, max])`, - * `randomInt([min] [, max])`, - * `pickRandom(array)` + * @param {String | String[] | Matrix} expr + * @param {{nodes: Object}} [options] Available options: + * - `nodes` a set of custom nodes + * @return {Node | Node[]} node + * @throws {Error} */ - function distribution(name) { - if (!distributions.hasOwnProperty(name)) - throw new Error('Unknown distribution ' + name); + function parse (expr, options) { + if (arguments.length != 1 && arguments.length != 2) { + throw new ArgumentsError('parse', arguments.length, 1, 2); + } - var args = Array.prototype.slice.call(arguments, 1), - distribution = distributions[name].apply(this, args); + // pass extra nodes + extra_nodes = (options && options.nodes) ? options.nodes : {}; - return (function(distribution) { + if (typeof expr === 'string') { + // parse a single expression + expression = expr; + return parseStart(); + } + else if (Array.isArray(expr) || expr instanceof type.Matrix) { + // parse an array or matrix with expressions + return collection.deepMap(expr, function (elem) { + if (typeof elem !== 'string') throw new TypeError('String expected'); - // This is the public API for all distributions - var randFunctions = { - - random: function(arg1, arg2, arg3) { - var size, min, max; - if (arguments.length > 3) { - throw new ArgumentsError('random', arguments.length, 0, 3); - - // `random(max)` or `random(size)` - } else if (arguments.length === 1) { - if (isCollection(arg1)) { - size = arg1; - } - else { - max = arg1; - } - // `random(min, max)` or `random(size, max)` - } else if (arguments.length === 2) { - if (isCollection(arg1)) { - size = arg1; - max = arg2; - } - else { - min = arg1; - max = arg2; - } - // `random(size, min, max)` - } else { - size = arg1; - min = arg2; - max = arg3; - } - - // TODO: validate type of min, max, and size - - if (max === undefined) max = 1; - if (min === undefined) min = 0; - if (size !== undefined) { - var res = _randomDataForMatrix(size.valueOf(), min, max, _random); - return (size instanceof type.Matrix) ? matrix(res) : res; - } - else return _random(min, max); - }, - - randomInt: function(arg1, arg2, arg3) { - var size, min, max; - if (arguments.length > 3 || arguments.length < 1) - throw new ArgumentsError('randomInt', arguments.length, 1, 3); - - // `random(max)` or `random(size)` - else if (arguments.length === 1) - if (isCollection(arg1)) { - size = arg1; - } - else { - max = arg1; - } - // `randomInt(min, max)` or `randomInt(size, max)` - else if (arguments.length === 2) { - if (isCollection(arg1)) { - size = arg1; - max = arg2; - } - else { - min = arg1; - max = arg2; - } - // `randomInt(size, min, max)` - } else { - size = arg1; - min = arg2; - max = arg3; - } - - // TODO: validate type of min, max, and size - - if (min === undefined) min = 0; - if (size !== undefined) { - var res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt); - return (size instanceof type.Matrix) ? matrix(res) : res; - } - else return _randomInt(min, max); - }, - - pickRandom: function(possibles) { - if (arguments.length !== 1) { - throw new ArgumentsError('pickRandom', arguments.length, 1); - } - if (possibles instanceof type.Matrix) { - possibles = possibles.valueOf(); // get Array - } - else if (!Array.isArray(possibles)) { - throw new TypeError('Unsupported type of value in function pickRandom'); - } - - if (array.size(possibles).length > 1) { - throw new Error('Only one dimensional vectors supported'); - } - - // TODO: add support for multi dimensional matrices - return possibles[Math.floor(Math.random() * possibles.length)]; - } - - }; - - var _random = function(min, max) { - return min + distribution() * (max - min); - }; - - var _randomInt = function(min, max) { - return Math.floor(min + distribution() * (max - min)); - }; - - // This is a function for generating a random matrix recursively. - var _randomDataForMatrix = function(size, min, max, randFunc) { - var data = [], length, i; - size = size.slice(0); - - if (size.length > 1) { - for (i = 0, length = size.shift(); i < length; i++) - data.push(_randomDataForMatrix(size, min, max, randFunc)); - } else { - for (i = 0, length = size.shift(); i < length; i++) - data.push(randFunc(min, max)); - } - - return data; - }; - - return randFunctions; - - })(distribution); + expression = elem; + return parseStart(); + }); + } + else { + // oops + throw new TypeError('String or matrix expected'); + } } - // Each distribution is a function that takes no argument and when called returns - // a number between 0 and 1. - var distributions = { - - uniform: function() { - return Math.random; - }, - - // Implementation of normal distribution using Box-Muller transform - // ref : http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform - // We take : mean = 0.5, standard deviation = 1/6 - // so that 99.7% values are in [0, 1]. - normal: function() { - return function() { - var u1, u2, - picked = -1; - // We reject values outside of the interval [0, 1] - // TODO: check if it is ok to do that? - while (picked < 0 || picked > 1) { - u1 = Math.random(); - u2 = Math.random(); - picked = 1/6 * Math.pow(-2 * Math.log(u1), 0.5) * Math.cos(2 * Math.PI * u2) + 0.5; - } - return picked; - } - } + // token types enumeration + var TOKENTYPE = { + NULL : 0, + DELIMITER : 1, + NUMBER : 2, + SYMBOL : 3, + UNKNOWN : 4 }; - return distribution; - } + // map with all delimiters + var DELIMITERS = { + ',': true, + '(': true, + ')': true, + '[': true, + ']': true, + '\"': true, + ';': true, - exports.name = 'distribution'; + '+': true, + '-': true, + '*': true, + '.*': true, + '/': true, + './': true, + '%': true, + '^': true, + '.^': true, + '~': true, + '!': true, + '&': true, + '|': true, + '^|': true, + '\'': true, + '=': true, + ':': true, + '?': true, + + '==': true, + '!=': true, + '<': true, + '>': true, + '<=': true, + '>=': true, + + '<<': true, + '>>': true, + '>>>': true + }; + + // map with all named delimiters + var NAMED_DELIMITERS = { + 'mod': true, + 'to': true, + 'in': true, + 'and': true, + 'xor': true, + 'or': true, + 'not': true + }; + + var extra_nodes = {}; // current extra nodes + var expression = ''; // current expression + var index = 0; // current index in expr + var c = ''; // current token character in expr + var token = ''; // current token + var token_type = TOKENTYPE.NULL; // type of the token + var nesting_level = 0; // level of nesting inside parameters, used to ignore newline characters + var conditional_level = null; // when a conditional is being parsed, the level of the conditional is stored here + + /** + * Get the first character from the expression. + * The character is stored into the char c. If the end of the expression is + * reached, the function puts an empty string in c. + * @private + */ + function first() { + index = 0; + c = expression.charAt(0); + nesting_level = 0; + conditional_level = null; + } + + /** + * Get the next character from the expression. + * The character is stored into the char c. If the end of the expression is + * reached, the function puts an empty string in c. + * @private + */ + function next() { + index++; + c = expression.charAt(index); + } + + /** + * Preview the next character from the expression. + * @return {String} cNext + * @private + */ + function nextPreview() { + return expression.charAt(index + 1); + } + + /** + * Preview the second next character from the expression. + * @return {String} cNext + * @private + */ + function nextNextPreview() { + return expression.charAt(index + 2); + } + + /** + * Get next token in the current string expr. + * The token and token type are available as token and token_type + * @private + */ + function getToken() { + token_type = TOKENTYPE.NULL; + token = ''; + + // skip over whitespaces + // space, tab, and newline when inside parameters + while (c == ' ' || c == '\t' || (c == '\n' && nesting_level)) { + // TODO: also take '\r' carriage return as newline? Or does that give problems on mac? + next(); + } + + // skip comment + if (c == '#') { + while (c != '\n' && c != '') { + next(); + } + } + + // check for end of expression + if (c == '') { + // token is still empty + token_type = TOKENTYPE.DELIMITER; + return; + } + + // check for new line character + if (c == '\n' && !nesting_level) { + token_type = TOKENTYPE.DELIMITER; + token = c; + next(); + return; + } + + // check for delimiters consisting of 3 characters + var c2 = c + nextPreview(); + var c3 = c2 + nextNextPreview(); + if (c3.length == 3 && DELIMITERS[c3]) { + token_type = TOKENTYPE.DELIMITER; + token = c3; + next(); + next(); + next(); + return; + } + + // check for delimiters consisting of 2 characters + if (c2.length == 2 && DELIMITERS[c2]) { + token_type = TOKENTYPE.DELIMITER; + token = c2; + next(); + next(); + return; + } + + // check for delimiters consisting of 1 character + if (DELIMITERS[c]) { + token_type = TOKENTYPE.DELIMITER; + token = c; + next(); + return; + } + + // check for a number + if (isDigitDot(c)) { + token_type = TOKENTYPE.NUMBER; + + // get number, can have a single dot + if (c == '.') { + token += c; + next(); + + if (!isDigit(c)) { + // this is no legal number, it is just a dot + token_type = TOKENTYPE.UNKNOWN; + } + } + else { + while (isDigit(c)) { + token += c; + next(); + } + if (c == '.') { + token += c; + next(); + } + } + while (isDigit(c)) { + token += c; + next(); + } + + // check for exponential notation like "2.3e-4", "1.23e50" or "2e+4" + c2 = nextPreview(); + if ((c == 'E' || c == 'e') && (isDigit(c2) || c2 == '-' || c2 == '+')) { + token += c; + next(); + + if (c == '+' || c == '-') { + token += c; + next(); + } + + // Scientific notation MUST be followed by an exponent + if (!isDigit(c)) { + // this is no legal number, exponent is missing. + token_type = TOKENTYPE.UNKNOWN; + } + + while (isDigit(c)) { + token += c; + next(); + } + } + + return; + } + + // check for variables, functions, named operators + if (isAlpha(c)) { + while (isAlpha(c) || isDigit(c)) { + token += c; + next(); + } + + if (NAMED_DELIMITERS[token]) { + token_type = TOKENTYPE.DELIMITER; + } + else { + token_type = TOKENTYPE.SYMBOL; + } + + return; + } + + // something unknown is found, wrong characters -> a syntax error + token_type = TOKENTYPE.UNKNOWN; + while (c != '') { + token += c; + next(); + } + throw createSyntaxError('Syntax error in part "' + token + '"'); + } + + /** + * Get next token and skip newline tokens + */ + function getTokenSkipNewline () { + do { + getToken(); + } + while (token == '\n'); + } + + /** + * Open parameters. + * New line characters will be ignored until closeParams() is called + */ + function openParams() { + nesting_level++; + } + + /** + * Close parameters. + * New line characters will no longer be ignored + */ + function closeParams() { + nesting_level--; + } + + /** + * checks if the given char c is a letter (upper or lower case) + * or underscore + * @param {String} c a string with one character + * @return {Boolean} + * @private + */ + function isAlpha (c) { + return ((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + c == '_'); + } + + /** + * checks if the given char c is a digit or dot + * @param {String} c a string with one character + * @return {Boolean} + * @private + */ + function isDigitDot (c) { + return ((c >= '0' && c <= '9') || + c == '.'); + } + + /** + * checks if the given char c is a digit + * @param {String} c a string with one character + * @return {Boolean} + * @private + */ + function isDigit (c) { + return ((c >= '0' && c <= '9')); + } + + /** + * Start of the parse levels below, in order of precedence + * @return {Node} node + * @private + */ + function parseStart () { + // get the first character in expression + first(); + + getToken(); + + var node = parseBlock(); + + // check for garbage at the end of the expression + // an expression ends with a empty character '' and token_type DELIMITER + if (token != '') { + if (token_type == TOKENTYPE.DELIMITER) { + // user entered a not existing operator like "//" + + // TODO: give hints for aliases, for example with "<>" give as hint " did you mean != ?" + throw createError('Unexpected operator ' + token); + } + else { + throw createSyntaxError('Unexpected part "' + token + '"'); + } + } + + return node; + } + + /** + * Parse a block with expressions. Expressions can be separated by a newline + * character '\n', or by a semicolon ';'. In case of a semicolon, no output + * of the preceding line is returned. + * @return {Node} node + * @private + */ + function parseBlock () { + var node; + var blocks = []; + var visible; + + if (token == '') { + // empty expression + return new ConstantNode('undefined', 'undefined'); + } + + if (token != '\n' && token != ';') { + node = parseFunctionAssignment(); + } + + // TODO: simplify this loop + while (token == '\n' || token == ';') { + if (blocks.length == 0 && node) { + visible = (token != ';'); + blocks.push({ + node: node, + visible: visible + }); + } + + getToken(); + if (token != '\n' && token != ';' && token != '') { + node = parseFunctionAssignment(); + + visible = (token != ';'); + blocks.push({ + node: node, + visible: visible + }); + } + } + + if (blocks.length > 0) { + return new BlockNode(blocks); + } + else { + return node; + } + } + + /** + * Parse a function assignment like "function f(a,b) = a*b" + * @return {Node} node + * @private + */ + function parseFunctionAssignment () { + // TODO: function assignment using keyword 'function' is deprecated since version 0.18.0, cleanup some day + if (token_type == TOKENTYPE.SYMBOL && token == 'function') { + throw createSyntaxError('Deprecated keyword "function". ' + + 'Functions can now be assigned without it, like "f(x) = x^2".'); + } + + return parseAssignment(); + } + + /** + * Assignment of a variable, can be a variable like "a=2.3" or a updating an + * existing variable like "matrix(2,3:5)=[6,7,8]" + * @return {Node} node + * @private + */ + function parseAssignment () { + var name, args, expr, valid; + + var node = parseConditional(); + + if (token == '=') { + if (node && node.isSymbolNode) { + // parse a variable assignment like 'a = 2/3' + name = node.name; + getTokenSkipNewline(); + expr = parseAssignment(); + return new AssignmentNode(name, expr); + } + else if (node && node.isIndexNode) { + // parse a matrix subset assignment like 'A[1,2] = 4' + getTokenSkipNewline(); + expr = parseAssignment(); + return new UpdateNode(node, expr); + } + else if (node && node.isFunctionNode) { + // parse function assignment like 'f(x) = x^2' + valid = true; + args = []; + + name = node.name; + node.args.forEach(function (arg, index) { + if (arg && arg.isSymbolNode) { + args[index] = arg.name; + } + else { + valid = false; + } + }); + + if (valid) { + getTokenSkipNewline(); + expr = parseAssignment(); + return new FunctionAssignmentNode(name, args, expr); + } + } + + throw createSyntaxError('Invalid left hand side of assignment operator ='); + } + + return node; + } + + /** + * conditional operation + * + * condition ? truePart : falsePart + * + * Note: conditional operator is right-associative + * + * @return {Node} node + * @private + */ + function parseConditional () { + var node = parseLogicalOr(); + + while (token == '?') { + // set a conditional level, the range operator will be ignored as long + // as conditional_level == nesting_level. + var prev = conditional_level; + conditional_level = nesting_level; + getTokenSkipNewline(); + + var condition = node; + var trueExpr = parseLogicalOr(); + + if (token != ':') throw createSyntaxError('False part of conditional expression expected'); + + conditional_level = null; + getTokenSkipNewline(); + + var falseExpr = parseConditional(); // Note: check for conditional operator again, right associativity + + node = new ConditionalNode(condition, trueExpr, falseExpr); + + // restore the previous conditional level + conditional_level = prev; + } + + return node; + } + + /** + * logical or, 'x or y' + * @return {Node} node + * @private + */ + function parseLogicalOr() { + var node = parseLogicalXor(); + + while (token == 'or') { + getTokenSkipNewline(); + node = new OperatorNode('or', 'or', [node, parseLogicalXor()]); + } + + return node; + } + + /** + * logical exclusive or, 'x xor y' + * @return {Node} node + * @private + */ + function parseLogicalXor() { + var node = parseLogicalAnd(); + + while (token == 'xor') { + getTokenSkipNewline(); + node = new OperatorNode('xor', 'xor', [node, parseLogicalAnd()]); + } + + return node; + } + + /** + * logical and, 'x and y' + * @return {Node} node + * @private + */ + function parseLogicalAnd() { + var node = parseBitwiseOr(); + + while (token == 'and') { + getTokenSkipNewline(); + node = new OperatorNode('and', 'and', [node, parseBitwiseOr()]); + } + + return node; + } + + /** + * bitwise or, 'x | y' + * @return {Node} node + * @private + */ + function parseBitwiseOr() { + var node = parseBitwiseXor(); + + while (token == '|') { + getTokenSkipNewline(); + node = new OperatorNode('|', 'bitOr', [node, parseBitwiseXor()]); + } + + return node; + } + + /** + * bitwise exclusive or (xor), 'x ^| y' + * @return {Node} node + * @private + */ + function parseBitwiseXor() { + var node = parseBitwiseAnd(); + + while (token == '^|') { + getTokenSkipNewline(); + node = new OperatorNode('^|', 'bitXor', [node, parseBitwiseAnd()]); + } + + return node; + } + + /** + * bitwise and, 'x & y' + * @return {Node} node + * @private + */ + function parseBitwiseAnd () { + var node = parseRelational(); + + while (token == '&') { + getTokenSkipNewline(); + node = new OperatorNode('&', 'bitAnd', [node, parseRelational()]); + } + + return node; + } + + /** + * relational operators + * @return {Node} node + * @private + */ + function parseRelational () { + var node, operators, name, fn, params; + + node = parseShift(); + + operators = { + '==': 'equal', + '!=': 'unequal', + '<': 'smaller', + '>': 'larger', + '<=': 'smallerEq', + '>=': 'largerEq' + }; + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseShift()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * Bitwise left shift, bitwise right arithmetic shift, bitwise right logical shift + * @return {Node} node + * @private + */ + function parseShift () { + var node, operators, name, fn, params; + + node = parseConversion(); + + operators = { + '<<' : 'leftShift', + '>>' : 'rightArithShift', + '>>>' : 'rightLogShift' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseConversion()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * conversion operators 'to' and 'in' + * @return {Node} node + * @private + */ + function parseConversion () { + var node, operators, name, fn, params; + + node = parseRange(); + + operators = { + 'to' : 'to', + 'in' : 'to' // alias of 'to' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseRange()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * parse range, "start:end", "start:step:end", ":", "start:", ":end", etc + * @return {Node} node + * @private + */ + function parseRange () { + var node, params = []; + + if (token == ':') { + // implicit start=1 (one-based) + node = new ConstantNode('1', 'number'); + } + else { + // explicit start + node = parseAddSubtract(); + } + + if (token == ':' && (conditional_level !== nesting_level)) { + // we ignore the range operator when a conditional operator is being processed on the same level + params.push(node); + + // parse step and end + while (token == ':' && params.length < 3) { + getTokenSkipNewline(); + + if (token == ')' || token == ']' || token == ',' || token == '') { + // implicit end + params.push(new SymbolNode('end')); + } + else { + // explicit end + params.push(parseAddSubtract()); + } + } + + if (params.length == 3) { + // params = [start, step, end] + node = new RangeNode(params[0], params[2], params[1]); // start, end, step + } + else { // length == 2 + // params = [start, end] + node = new RangeNode(params[0], params[1]); // start, end + } + } + + return node; + } + + /** + * add or subtract + * @return {Node} node + * @private + */ + function parseAddSubtract () { + var node, operators, name, fn, params; + + node = parseMultiplyDivide(); + + operators = { + '+': 'add', + '-': 'subtract' + }; + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseMultiplyDivide()]; + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * multiply, divide, modulus + * @return {Node} node + * @private + */ + function parseMultiplyDivide () { + var node, operators, name, fn, params; + + node = parseUnary(); + + operators = { + '*': 'multiply', + '.*': 'dotMultiply', + '/': 'divide', + './': 'dotDivide', + '%': 'mod', + 'mod': 'mod' + }; + + if (token in operators) { + while (token in operators) { + name = token; + fn = operators[name]; + + getTokenSkipNewline(); + params = [node, parseUnary()]; + node = new OperatorNode(name, fn, params); + } + } + + // parse implicit multiplication + if ((token_type == TOKENTYPE.SYMBOL) || + (token == 'in' && (node && node.isConstantNode)) || + (token_type == TOKENTYPE.NUMBER && !(node && node.isConstantNode)) || + (token == '(' || token == '[')) { + // symbol: implicit multiplication like '2a', '(2+3)a', 'a b' + // number: implicit multiplication like '(2+3)2' + // Note: we don't allow implicit multiplication between numbers, + // like '2 3'. I'm not sure whether that is a good idea. + // parenthesis: implicit multiplication like '2(3+4)', '(3+4)(1+2)', '2[1,2,3]' + node = new OperatorNode('*', 'multiply', [node, parseMultiplyDivide()]); + } + + return node; + } + + /** + * Unary plus and minus, and logical and bitwise not + * @return {Node} node + * @private + */ + function parseUnary () { + var name, params; + var fn = { + '-': 'unaryMinus', + '+': 'unaryPlus', + '~': 'bitNot', + 'not': 'not' + }[token]; + + if (fn) { + name = token; + + getTokenSkipNewline(); + params = [parseUnary()]; + + return new OperatorNode(name, fn, params); + } + + return parsePow(); + } + + /** + * power + * Note: power operator is right associative + * @return {Node} node + * @private + */ + function parsePow () { + var node, name, fn, params; + + node = parseLeftHandOperators(); + + if (token == '^' || token == '.^') { + name = token; + fn = (name == '^') ? 'pow' : 'dotPow'; + + getTokenSkipNewline(); + params = [node, parseUnary()]; // Go back to unary, we can have '2^-3' + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * Left hand operators: factorial x!, transpose x' + * @return {Node} node + * @private + */ + function parseLeftHandOperators () { + var node, operators, name, fn, params; + + node = parseCustomNodes(); + + operators = { + '!': 'factorial', + '\'': 'transpose' + }; + + while (token in operators) { + name = token; + fn = operators[name]; + + getToken(); + params = [node]; + + node = new OperatorNode(name, fn, params); + } + + return node; + } + + /** + * Parse a custom node handler. A node handler can be used to process + * nodes in a custom way, for example for handling a plot. + * + * A handler must be passed as second argument of the parse function. + * - must extend math.expression.node.Node + * - must contain a function _compile(defs: Object) : String + * - must contain a function find(filter: Object) : Node[] + * - must contain a function toString() : String + * - the constructor is called with a single argument containing all parameters + * + * For example: + * + * nodes = { + * 'plot': PlotHandler + * }; + * + * The constructor of the handler is called as: + * + * node = new PlotHandler(params); + * + * The handler will be invoked when evaluating an expression like: + * + * node = math.parse('plot(sin(x), x)', nodes); + * + * @return {Node} node + * @private + */ + function parseCustomNodes () { + var params = [], handler; + + if (token_type == TOKENTYPE.SYMBOL && extra_nodes[token]) { + handler = extra_nodes[token]; + + getToken(); + + // parse parameters + if (token == '(') { + params = []; + + openParams(); + getToken(); + + if (token != ')') { + params.push(parseConditional()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseConditional()); + } + } + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + } + + // create a new node handler + //noinspection JSValidateTypes + return new handler(params); + } + + return parseSymbol(); + } + + /** + * parse symbols: functions, variables, constants, units + * @return {Node} node + * @private + */ + function parseSymbol () { + var node, name; + + if (token_type == TOKENTYPE.SYMBOL || + (token_type == TOKENTYPE.DELIMITER && token in NAMED_DELIMITERS)) { + name = token; + + getToken(); + + // parse function parameters and matrix index + node = parseFunctions(name); + node = parseIndex(node); + return node; + } + + return parseString(); + } + + /** + * parse a function call like fn(a, b, c) + * @param {string} name Function name + * @return {FunctionNode | SymbolNode} node + * @private + */ + function parseFunctions (name) { + var params; + + if (token == '(') { + params = []; + + openParams(); + getToken(); + + if (token != ')') { + params.push(parseConditional()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseConditional()); + } + } + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + + return new FunctionNode(name, params); + } + + return new SymbolNode(name); + } + + /** + * parse index parameters, enclosed in square brackets [...], for example A[2,3] + * @param {Node} node Node on which to apply the parameters. If there + * are no parameters in the expression, the node + * itself is returned + * @return {Node} node + * @private + */ + function parseIndex (node) { + var params; + + while (token == '[') { + params = []; + + openParams(); + getToken(); + + if (token != ']') { + params.push(parseConditional()); + + // parse a list with parameters + while (token == ',') { + getToken(); + params.push(parseConditional()); + } + } + + if (token != ']') { + throw createSyntaxError('Parenthesis ] expected'); + } + closeParams(); + getToken(); + + node = new IndexNode(node, params); + } + + return node; + } + + /** + * parse a string. + * A string is enclosed by double quotes + * @return {Node} node + * @private + */ + function parseString () { + var node, str, tPrev; + + if (token == '"') { + // string "..." + str = ''; + tPrev = ''; + while (c != '' && (c != '\"' || tPrev == '\\')) { // also handle escape character + str += c; + tPrev = c; + next(); + } + + getToken(); + if (token != '"') { + throw createSyntaxError('End of string " expected'); + } + getToken(); + + // create constant + node = new ConstantNode(str, 'string'); + + // parse index parameters + node = parseIndex(node); + + return node; + } + + return parseMatrix(); + } + + /** + * parse the matrix + * @return {Node} node + * @private + */ + function parseMatrix () { + var array, params, rows, cols; + + if (token == '[') { + // matrix [...] + openParams(); + getToken(); + + if (token != ']') { + // this is a non-empty matrix + var row = parseRow(); + + if (token == ';') { + // 2 dimensional array + rows = 1; + params = [row]; + + // the rows of the matrix are separated by dot-comma's + while (token == ';') { + getToken(); + + params[rows] = parseRow(); + rows++; + } + + if (token != ']') { + throw createSyntaxError('End of matrix ] expected'); + } + closeParams(); + getToken(); + + // check if the number of columns matches in all rows + cols = params[0].nodes.length; + for (var r = 1; r < rows; r++) { + if (params[r].nodes.length != cols) { + throw createError('Column dimensions mismatch ' + + '(' + params[r].nodes.length + ' != ' + cols + ')'); + } + } + + array = new ArrayNode(params); + } + else { + // 1 dimensional vector + if (token != ']') { + throw createSyntaxError('End of matrix ] expected'); + } + closeParams(); + getToken(); + + array = row; + } + } + else { + // this is an empty matrix "[ ]" + closeParams(); + getToken(); + array = new ArrayNode([]); + } + + return array; + } + + return parseNumber(); + } + + /** + * Parse a single comma-separated row from a matrix, like 'a, b, c' + * @return {ArrayNode} node + */ + function parseRow () { + var params = [parseAssignment()]; + var len = 1; + + while (token == ',') { + getToken(); + + // parse expression + params[len] = parseAssignment(); + len++; + } + + return new ArrayNode(params); + } + + /** + * parse a number + * @return {Node} node + * @private + */ + function parseNumber () { + var number; + + if (token_type == TOKENTYPE.NUMBER) { + // this is a number + number = token; + getToken(); + + return new ConstantNode(number, 'number'); + } + + return parseParentheses(); + } + + /** + * parentheses + * @return {Node} node + * @private + */ + function parseParentheses () { + var node; + + // check if it is a parenthesized expression + if (token == '(') { + // parentheses (...) + openParams(); + getToken(); + + node = parseAssignment(); // start again + + if (token != ')') { + throw createSyntaxError('Parenthesis ) expected'); + } + closeParams(); + getToken(); + + return node; + } + + return parseEnd(); + } + + /** + * Evaluated when the expression is not yet ended but expected to end + * @return {Node} res + * @private + */ + function parseEnd () { + if (token == '') { + // syntax error or unexpected end of expression + throw createSyntaxError('Unexpected end of expression'); + } else { + throw createSyntaxError('Value expected'); + } + } + + /** + * Shortcut for getting the current row value (one based) + * Returns the line of the currently handled expression + * @private + */ + /* TODO: implement keeping track on the row number + function row () { + return null; + } + */ + + /** + * Shortcut for getting the current col value (one based) + * Returns the column (position) where the last token starts + * @private + */ + function col () { + return index - token.length + 1; + } + + /** + * Create an error + * @param {String} message + * @return {SyntaxError} instantiated error + * @private + */ + function createSyntaxError (message) { + var c = col(); + var error = new SyntaxError(message + ' (char ' + c + ')'); + error['char'] = c; + + return error; + } + + /** + * Create an error + * @param {String} message + * @return {Error} instantiated error + * @private + */ + function createError (message) { + var c = col(); + var error = new Error(message + ' (char ' + c + ')'); + error['char'] = c; + + return error; + } + + return parse; + }; + + exports.name = 'parse'; + exports.path = 'expression'; exports.factory = factory; /***/ }, -/* 216 */ +/* 52 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var _parse = load(__webpack_require__(51)); + + /** + * @constructor Parser + * Parser contains methods to evaluate or parse expressions, and has a number + * of convenience methods to get, set, and remove variables from memory. Parser + * keeps a scope containing variables in memory, which is used for all + * evaluations. + * + * Methods: + * var result = parser.eval(expr); // evaluate an expression + * var value = parser.get(name); // retrieve a variable from the parser + * parser.set(name, value); // set a variable in the parser + * parser.remove(name); // clear a variable from the + * // parsers scope + * parser.clear(); // clear the parsers scope + * + * Example usage: + * var parser = new Parser(); + * // Note: there is a convenience method which can be used instead: + * // var parser = new math.parser(); + * + * // evaluate expressions + * parser.eval('sqrt(3^2 + 4^2)'); // 5 + * parser.eval('sqrt(-4)'); // 2i + * parser.eval('2 inch in cm'); // 5.08 cm + * parser.eval('cos(45 deg)'); // 0.7071067811865476 + * + * // define variables and functions + * parser.eval('x = 7 / 2'); // 3.5 + * parser.eval('x + 3'); // 6.5 + * parser.eval('function f(x, y) = x^y'); // f(x, y) + * parser.eval('f(2, 3)'); // 8 + * + * // get and set variables and functions + * var x = parser.get('x'); // 7 + * var f = parser.get('f'); // function + * var g = f(3, 2); // 9 + * parser.set('h', 500); + * var i = parser.eval('h / 2'); // 250 + * parser.set('hello', function (name) { + * return 'hello, ' + name + '!'; + * }); + * parser.eval('hello("user")'); // "hello, user!" + * + * // clear defined functions and variables + * parser.clear(); + * + */ + function Parser() { + if (!(this instanceof Parser)) { + throw new SyntaxError( + 'Constructor must be called with the new operator'); + } + this.scope = {}; + } + + /** + * Parse an expression and return the parsed function node. + * The node tree can be compiled via `code = node.compile(math)`, + * and the compiled code can be executed as `code.eval([scope])` + * @param {String} expr + * @return {Node} node + * @throws {Error} + */ + Parser.prototype.parse = function (expr) { + throw new Error('Parser.parse is deprecated. Use math.parse instead.'); + }; + + /** + * Parse and compile an expression, return the compiled javascript code. + * The node can be evaluated via code.eval([scope]) + * @param {String} expr + * @return {{eval: function}} code + * @throws {Error} + */ + Parser.prototype.compile = function (expr) { + throw new Error('Parser.compile is deprecated. Use math.compile instead.'); + }; + + /** + * Parse and evaluate the given expression + * @param {String} expr A string containing an expression, for example "2+3" + * @return {*} result The result, or undefined when the expression was empty + * @throws {Error} + */ + Parser.prototype.eval = function (expr) { + // TODO: validate arguments + return _parse(expr) + .compile(math) + .eval(this.scope); + }; + + /** + * Get a variable (a function or variable) by name from the parsers scope. + * Returns undefined when not found + * @param {String} name + * @return {* | undefined} value + */ + Parser.prototype.get = function (name) { + // TODO: validate arguments + return this.scope[name]; + }; + + /** + * Set a symbol (a function or variable) by name from the parsers scope. + * @param {String} name + * @param {* | undefined} value + */ + Parser.prototype.set = function (name, value) { + // TODO: validate arguments + return this.scope[name] = value; + }; + + /** + * Remove a variable from the parsers scope + * @param {String} name + */ + Parser.prototype.remove = function (name) { + // TODO: validate arguments + delete this.scope[name]; + }; + + /** + * Clear the scope with variables and functions + */ + Parser.prototype.clear = function () { + for (var name in this.scope) { + if (this.scope.hasOwnProperty(name)) { + delete this.scope[name]; + } + } + }; + + return Parser; + } + + exports.name = 'Parser'; + exports.path = 'expression'; + exports.factory = factory; + exports.math = true; // requires the math namespace as 5th argument + + +/***/ }, +/* 53 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Instantiate mathjs data types from their JSON representation + * @param {string} key + * @param {*} value + * @returns {*} Returns the revived object + */ + return function reviver(key, value) { + var constructor = type[value && value.mathjs]; + if (constructor && typeof constructor.fromJSON === 'function') { + return constructor.fromJSON(value); + } + + return value; + } + } + + exports.name = 'reviver'; + exports.path = 'json'; + exports.factory = factory; + + +/***/ }, +/* 54 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + + var object = util.object; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var abs = load(__webpack_require__(56)); + var add = load(__webpack_require__(47)); + var divideScalar = load(__webpack_require__(207)); + var multiply = load(__webpack_require__(71)); + var subtract = load(__webpack_require__(79)); + var larger = load(__webpack_require__(45)); + var equal = load(__webpack_require__(46)); + var unaryMinus = load(__webpack_require__(80)); + + var SparseMatrix = type.SparseMatrix; + var DenseMatrix = type.DenseMatrix; + var Spa = type.Spa; + + /** + * Calculate the Matrix LU decomposition with pivoting. Matrix A is decomposed in three matrices (L, U, P) where + * A * P = L * U + * + * @param {Matrix | Array} A two dimensional matrix or array for which to get the LUP decomposition. + * + * @return {Array} The lower triangular matrix, the upper triangular matrix and the permutation matrix. + */ + var lup = typed('lup', { + 'Matrix': function (m) { + // process matrix storage format + switch (m.storage()) { + case 'dense': + return _denseLUP(m); + case 'sparse': + return _sparseLUP(m); + } + }, + 'Array': function (a) { + // create dense matrix from array + var m = matrix(a); + // lup, use matrix implementation + var r = lup(m); + // result + return { + L: r.L.valueOf(), + U: r.U.valueOf(), + P: r.P.valueOf() + }; + } + }); + + var _denseLUP = function (m) { + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // minimum rows and columns + var n = Math.min(rows, columns); + // matrix array, clone original data + var data = object.clone(m._data); + // l matrix arrays + var ldata = []; + var lsize = [rows, n]; + // u matrix arrays + var udata = []; + var usize = [n, columns]; + // p (eye [n, n]) + var p = DenseMatrix.diagonal([rows, rows], 1, 0); + // vars + var i, j, k; + // loop columns + for (j = 0; j < columns; j++) { + // skip first column in upper triangular matrix + if (j > 0) { + // loop rows + for (i = 0; i < rows; i++) { + // min i,j + var min = Math.min(i, j); + // v[i, j] + var s = 0; + // loop up to min + for (k = 0; k < min; k++) { + // s = l[i, k] - data[k, j] + s = add(s, multiply(data[i][k], data[k][j])); + } + data[i][j] = subtract(data[i][j], s); + } + } + // row with larger value in cvector, row >= j + var pi = j; + var pabsv = 0; + var vjj = 0; + // loop rows + for (i = j; i < rows; i++) { + // data @ i, j + var v = data[i][j]; + // absolute value + var absv = abs(v); + // value is greater than pivote value + if (larger(absv, pabsv)) { + // store row + pi = i; + // update max value + pabsv = absv; + // value @ [j, j] + vjj = v; + } + } + // swap rows (j <-> pi) + if (j !== pi) { + // swap values j <-> pi in P + DenseMatrix._swapRows(j, pi, p._data); + // swap j <-> pi in data + DenseMatrix._swapRows(j, pi, data); + } + // check column is in lower triangular matrix + if (j < rows) { + // loop rows (lower triangular matrix) + for (i = j + 1; i < rows; i++) { + // value @ i, j + var vij = data[i][j]; + if (!equal(vij, 0)) { + // update data + data[i][j] = divideScalar(data[i][j], vjj); + } + } + } + } + // loop columns + for (j = 0; j < columns; j++) { + // loop rows + for (i = 0; i < rows; i++) { + // initialize row in arrays + if (j === 0) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i] = []; + } + // L + ldata[i] = []; + } + // check we are in the upper triangular matrix + if (i < j) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = data[i][j]; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = 0; + } + continue; + } + // diagonal value + if (i === j) { + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = data[i][j]; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = 1; + } + continue; + } + // check row exists in upper triangular matrix + if (i < columns) { + // U + udata[i][j] = 0; + } + // check column exists in lower triangular matrix + if (j < rows) { + // L + ldata[i][j] = data[i][j]; + } + } + } + // l matrix + var l = new DenseMatrix({ + data: ldata, + size: lsize + }); + // u matrix + var u = new DenseMatrix({ + data: udata, + size: usize + }); + // return matrices + return { + L: l, + U: u, + P: p, + toString: function () { + return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.P.toString(); + } + }; + }; + + var _sparseLUP = function (m) { + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // minimum rows and columns + var n = Math.min(rows, columns); + // matrix arrays (will not be modified, thanks to permutation vector) + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // l matrix arrays + var lvalues = []; + var lindex = []; + var lptr = []; + var lsize = [rows, n]; + // u matrix arrays + var uvalues = []; + var uindex = []; + var uptr = []; + var usize = [n, columns]; + // p matrix arrays + var pvalues = []; + var pindex = []; + var pptr = []; + var psize = [rows, rows]; + // vars + var i, j, k; + // permutation vectors, (current index -> original index) and (original index -> current index) + var pv_co = new Array(rows); + var pv_oc = new Array(rows); + for (i = 0; i < rows; i++) { + pv_co[i] = i; + pv_oc[i] = i; + } + // swap indices in permutation vectors (condition x < y)! + var swapIndeces = function (x, y) { + // find pv indeces getting data from x and y + var kx = pv_oc[x]; + var ky = pv_oc[y]; + // update permutation vector current -> original + pv_co[kx] = y; + pv_co[ky] = x; + // update permutation vector original -> current + pv_oc[x] = ky; + pv_oc[y] = kx; + }; + // loop columns + for (j = 0; j < columns; j++) { + // sparse accumulator + var spa = new Spa(rows); + // check lower triangular matrix has a value @ column j + if (j < rows) { + // update ptr + lptr.push(lvalues.length); + // first value in j column for lower triangular matrix + lvalues.push(1); + lindex.push(j); + } + // update ptr + uptr.push(uvalues.length); + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // copy column j into sparse accumulator + for (k = k0; k < k1; k++) { + // row + i = index[k]; + // copy column values into sparse accumulator (use permutation vector) + spa.set(pv_co[i], values[k]); + } + // skip first column in upper triangular matrix + if (j > 0) { + // loop rows in column j (above diagonal) + spa.forEach(0, j - 1, function (k, vkj) { + // loop rows in column k (L) + SparseMatrix._forEachRow(k, lvalues, lindex, lptr, function (i, vik) { + // check row is below k + if (i > k) { + // update spa value + spa.accumulate(i, unaryMinus(multiply(vik, vkj))); + } + }); + }); + } + // row with larger value in spa, row >= j + var pi = j; + var vjj = spa.get(j); + var pabsv = abs(vjj); + // loop values in spa (order by row, below diagonal) + spa.forEach(j + 1, rows - 1, function (x, v) { + // absolute value + var absv = abs(v); + // value is greater than pivote value + if (larger(absv, pabsv)) { + // store row + pi = x; + // update max value + pabsv = absv; + // value @ [j, j] + vjj = v; + } + }); + // swap rows (j <-> pi) + if (j !== pi) { + // swap values j <-> pi in L + SparseMatrix._swapRows(j, pi, lsize[1], lvalues, lindex, lptr); + // swap values j <-> pi in U + SparseMatrix._swapRows(j, pi, usize[1], uvalues, uindex, uptr); + // swap values in spa + spa.swap(j, pi); + // update permutation vector (swap values @ j, pi) + swapIndeces(j, pi); + } + // loop values in spa (order by row) + spa.forEach(0, rows - 1, function (x, v) { + // check we are above diagonal + if (x <= j) { + // update upper triangular matrix + uvalues.push(v); + uindex.push(x); + } + else { + // update value + v = divideScalar(v, vjj); + // check value is non zero + if (!equal(v, 0)) { + // update lower triangular matrix + lvalues.push(v); + lindex.push(x); + } + } + }); + } + // update ptrs + lptr.push(lvalues.length); + uptr.push(uvalues.length); + // generate P matrix + for (i = 0; i < rows; i++) { + // ptr + pptr.push(pvalues.length); + // value + pvalues.push(1); + // row + pindex.push(pv_co[i]); + } + // close ptr + pptr.push(pvalues.length); + // return matrices + return { + L: new SparseMatrix({ + values: lvalues, + index: lindex, + ptr: lptr, + size: lsize + }), + U: new SparseMatrix({ + values: uvalues, + index: uindex, + ptr: uptr, + size: usize + }), + P: new SparseMatrix({ + values: pvalues, + index: pindex, + ptr: pptr, + size: psize + }), + toString: function () { + return 'L: ' + this.L.toString() + '\nU: ' + this.U.toString() + '\nP: ' + this.P.toString(); + } + }; + }; + + return lup; + } + + exports.name = 'lup'; + exports.factory = factory; + + +/***/ }, +/* 55 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isArray = Array.isArray; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var lup = load(__webpack_require__(54)); + var multiply = load(__webpack_require__(71)); + + var backwardSubstitution = load(__webpack_require__(208)); + var forwardSubstitution = load(__webpack_require__(209)); + + /** + * Solves the linear system A * x = b where A is an [n x n] matrix and b is a [n] column vector. + * + * Syntax: + * + * var x = math.lusolve(matrix, b) // returns column vector with the solution to the linear system A * x = b + * + * var x = math.lusolve(lup, b) // returns column vector with the solution to the linear system A * x = b, lup = math.lup(A) + * + * Examples: + * + * var m = [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]; + * + * var x = math.lusolve(m, [-1, -1, -1, -1]); // x = [-1, -0.5, -1/3, -0.25] + * + * var f = math.lup(m); + * var x1 = math.lusolve(f, [-1, -1, -1, -1]); // x1 = [-1, -0.5, -1/3, -0.25] + * var x2 = math.lusolve(f, [1, 2, 1, -1]); // x2 = [1, 1, 1/3, -0.25] + * + * See also: + * + * lup + * + * @param {Matrix | Array | Object} a Invertible Matrix or the Matrix LUP decomposition + * @param {Matrix | Array} b Column Vector + * + * @return {Matrix | Array} Column vector with the solution to the linear system A * x = b + */ + var lusolve = typed('lusolve', { + 'Array, Array | Matrix': function (a, b) { + // convert a to matrix + a = matrix(a); + // matrix lup decomposition + var d = lup(a); + // solve + var x = _lusolve(d.L, d.U, d.P, b); + // convert result to array + return x.valueOf(); + }, + 'Matrix, Array | Matrix': function (a, b) { + // matrix lup decomposition + var d = lup(a); + // solve + return _lusolve(d.L, d.U, d.P, b); + }, + 'Object, Array | Matrix': function (d, b) { + // solve + return _lusolve(d.L, d.U, d.P, b); + } + }); + + var _toMatrix = function (a) { + // check it is a matrix + if (a instanceof type.Matrix) + return a; + // check array + if (isArray(a)) + return matrix(a); + // throw + throw new TypeError('Invalid Matrix LUP decomposition'); + }; + + var _lusolve = function (l, u, p, b) { + // verify L, U, P + l = _toMatrix(l); + u = _toMatrix(u); + p = _toMatrix(p); + // modify column vector applying permutations + b = multiply(p, b); + // use forward substitution to resolve L * y = b + var y = forwardSubstitution(l, b); + // use backward substitution to resolve U * x = y + return backwardSubstitution(u, y); + }; + + return lusolve; + } + + exports.name = 'lusolve'; + exports.factory = factory; + + +/***/ }, +/* 56 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the absolute value of a number. For matrices, the function is + * evaluated element wise. + * + * Syntax: + * + * math.abs(x) + * + * Examples: + * + * math.abs(3.5); // returns Number 3.5 + * math.abs(-4.2); // returns Number 4.2 + * + * math.abs([3, -5, -1, 0, 2]); // returns Array [3, 5, 1, 0, 2] + * + * See also: + * + * sign + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * A number or matrix for which to get the absolute value + * @return {Number | BigNumber | Complex | Array | Matrix} + * Absolute value of `x` + */ + var abs = typed('abs', { + 'number': Math.abs, + + 'Complex': function (x) { + var re = Math.abs(x.re); + var im = Math.abs(x.im); + if (re < 1000 && im < 1000) { + return Math.sqrt(re * re + im * im); + } + else { + // prevent overflow for large numbers + if (re >= im) { + var i = im / re; + return re * Math.sqrt(1 + i * i); + } + else { + var j = re / im; + return im * Math.sqrt(1 + j * j); + } + } + }, + + 'BigNumber': function (x) { + return x.abs(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since abs(0) = 0 + return collection.deepMap(x, abs, true); + } + }); + + return abs; + } + + exports.name = 'abs'; + exports.factory = factory; + + +/***/ }, +/* 57 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Round a value towards plus infinity + * If `x` is complex, both real and imaginary part are rounded towards plus infinity. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.ceil(x) + * + * Examples: + * + * math.ceil(3.2); // returns Number 4 + * math.ceil(3.8); // returns Number 4 + * math.ceil(-4.2); // returns Number -4 + * math.ceil(-4.7); // returns Number -4 + * + * var c = math.complex(3.2, -2.7); + * math.ceil(c); // returns Complex 4 - 2i + * + * math.ceil([3.2, 3.8, -4.7]); // returns Array [4, 4, -4] + * + * See also: + * + * floor, fix, round + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded + * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value + */ + var ceil = typed('ceil', { + 'number': Math.ceil, + + 'Complex': function (x) { + return new x.constructor( + Math.ceil(x.re), + Math.ceil(x.im) + ); + }, + + 'BigNumber': function (x) { + return x.ceil(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since ceil(0) = 0 + return collection.deepMap(x, ceil, true); + } + }); + + return ceil; + } + + exports.name = 'ceil'; + exports.factory = factory; + + +/***/ }, +/* 58 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var collection = load(__webpack_require__(2)); + var complexMultiply = load(__webpack_require__(210)).signatures['Complex,Complex']; + + /** + * Compute the cube of a value, `x * x * x`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cube(x) + * + * Examples: + * + * math.cube(2); // returns Number 8 + * math.pow(2, 3); // returns Number 8 + * math.cube(4); // returns Number 64 + * 4 * 4 * 4; // returns Number 64 + * + * math.cube([1, 2, 3, 4]); // returns Array [1, 8, 27, 64] + * + * See also: + * + * multiply, square, pow + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number for which to calculate the cube + * @return {Number | BigNumber | Complex | Array | Matrix} Cube of x + */ + var cube = typed('cube', { + 'number': function (x) { + return x * x * x; + }, + + 'Complex': function (x) { + return complexMultiply(complexMultiply(x, x), x); + }, + + 'BigNumber': function (x) { + return x.times(x).times(x); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since cube(0) = 0 + return collection.deepMap(x, cube, true); + } + }); + + return cube; + } + + exports.name = 'cube'; + exports.factory = factory; + + +/***/ }, +/* 59 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var divideScalar = load(__webpack_require__(207)); + var multiply = load(__webpack_require__(71)); + var inv = load(__webpack_require__(109)); + + /** + * Divide two values, `x / y`. + * To divide matrices, `x` is multiplied with the inverse of `y`: `x * inv(y)`. + * + * Syntax: + * + * math.divide(x, y) + * + * Examples: + * + * math.divide(2, 3); // returns Number 0.6666666666666666 + * + * var a = math.complex(5, 14); + * var b = math.complex(4, 1); + * math.divide(a, b); // returns Complex 2 + 3i + * + * var c = [[7, -6], [13, -4]]; + * var d = [[1, 2], [4, 3]]; + * math.divide(c, d); // returns Array [[-9, 4], [-11, 6]] + * + * var e = math.unit('18 km'); + * math.divide(e, 4.5); // returns Unit 4 km + * + * See also: + * + * multiply + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Numerator + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} y Denominator + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Quotient, `x / y` + */ + return typed('divide', { + 'any, any': divideScalar, + + 'Array | Matrix, Array | Matrix': function (x, y) { + // TODO: implement matrix right division using pseudo inverse + // http://www.mathworks.nl/help/matlab/ref/mrdivide.html + // http://www.gnu.org/software/octave/doc/interpreter/Arithmetic-Ops.html + // http://stackoverflow.com/questions/12263932/how-does-gnu-octave-matrix-division-work-getting-unexpected-behaviour + return multiply(x, inv(y)); + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, divideScalar); + }, + + 'any, Array | Matrix': function (x, y) { + return multiply(x, inv(y)); + } + }); + } + + exports.name = 'divide'; + exports.factory = factory; + + +/***/ }, +/* 60 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var divideScalar = load(__webpack_require__(207)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Divide two matrices element wise. The function accepts both matrices and + * scalar values. + * + * Syntax: + * + * math.dotDivide(x, y) + * + * Examples: + * + * math.dotDivide(2, 4); // returns 0.5 + * + * a = [[9, 5], [6, 1]]; + * b = [[3, 2], [5, 2]]; + * + * math.dotDivide(a, b); // returns [[3, 2.5], [1.2, 0.5]] + * math.divide(a, b); // returns [[1.75, 0.75], [-1.75, 2.25]] + * + * See also: + * + * divide, multiply, dotMultiply + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Numerator + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Denominator + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Quotient, `x ./ y` + */ + var dotDivide = typed('dotDivide', { + + 'any, any': divideScalar, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse ./ sparse + c = elementWiseOperations.algorithm7(x, y, divideScalar, false); + break; + default: + // sparse ./ dense + c = elementWiseOperations.algorithm2(y, x, divideScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense ./ sparse + c = elementWiseOperations.algorithm3(x, y, divideScalar, false); + break; + default: + // dense ./ dense + c = elementWiseOperations.algorithm12(x, y, divideScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotDivide(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotDivide(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotDivide(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, divideScalar, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, divideScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, divideScalar, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, divideScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, divideScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, divideScalar, true).valueOf(); + } + }); + + return dotDivide; + } + + exports.name = 'dotDivide'; + exports.factory = factory; + + +/***/ }, +/* 61 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var multiplyScalar = load(__webpack_require__(210)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Multiply two matrices element wise. The function accepts both matrices and + * scalar values. + * + * Syntax: + * + * math.dotMultiply(x, y) + * + * Examples: + * + * math.dotMultiply(2, 4); // returns 8 + * + * a = [[9, 5], [6, 1]]; + * b = [[3, 2], [5, 2]]; + * + * math.dotMultiply(a, b); // returns [[27, 10], [30, 2]] + * math.multiply(a, b); // returns [[52, 28], [23, 14]] + * + * See also: + * + * multiply, divide, dotDivide + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Left hand value + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Right hand value + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` + */ + var dotMultiply = typed('dotMultiply', { + + 'any, any': multiplyScalar, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse .* sparse + c = elementWiseOperations.algorithm6(x, y, multiplyScalar, false); + break; + default: + // sparse .* dense + c = elementWiseOperations.algorithm2(y, x, multiplyScalar, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense .* sparse + c = elementWiseOperations.algorithm2(x, y, multiplyScalar, false); + break; + default: + // dense .* dense + c = elementWiseOperations.algorithm12(x, y, multiplyScalar); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotMultiply(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotMultiply(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotMultiply(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, multiplyScalar, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, multiplyScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(y, x, multiplyScalar, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, multiplyScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, multiplyScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, multiplyScalar, true).valueOf(); + } + }); + + return dotMultiply; + } + + exports.name = 'dotMultiply'; + exports.factory = factory; + + +/***/ }, +/* 62 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var pow = load(__webpack_require__(74)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Calculates the power of x to y element wise. + * + * Syntax: + * + * math.dotPow(x, y) + * + * Examples: + * + * math.dotPow(2, 3); // returns Number 8 + * + * var a = [[1, 2], [4, 3]]; + * math.dotPow(a, 2); // returns Array [[1, 4], [16, 9]] + * math.pow(a, 2); // returns Array [[9, 8], [16, 17]] + * + * See also: + * + * pow, sqrt, multiply + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x The base + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y The exponent + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} The value of `x` to the power `y` + */ + var dotPow = typed('dotPow', { + + 'any, any': pow, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse .^ sparse + c = elementWiseOperations.algorithm7(x, y, pow, false); + break; + default: + // sparse .^ dense + c = elementWiseOperations.algorithm3(y, x, pow, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense .^ sparse + c = elementWiseOperations.algorithm3(x, y, pow, false); + break; + default: + // dense .^ dense + c = elementWiseOperations.algorithm12(x, y, pow); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return dotPow(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return dotPow(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return dotPow(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, dotPow, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, dotPow, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, dotPow, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, dotPow, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, dotPow, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, dotPow, true).valueOf(); + } + }); + + return dotPow; + } + + exports.name = 'dotPow'; + exports.factory = factory; + + +/***/ }, +/* 63 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the exponent of a value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.exp(x) + * + * Examples: + * + * math.exp(2); // returns Number 7.3890560989306495 + * math.pow(math.e, 2); // returns Number 7.3890560989306495 + * math.log(math.exp(2)); // returns Number 2 + * + * math.exp([1, 2, 3]); + * // returns Array [ + * // 2.718281828459045, + * // 7.3890560989306495, + * // 20.085536923187668 + * // ] + * + * See also: + * + * log, pow + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x A number or matrix to exponentiate + * @return {Number | BigNumber | Complex | Array | Matrix} Exponent of `x` + */ + var exp = typed('exp', { + 'number': Math.exp, + + 'Complex': function (x) { + var r = Math.exp(x.re); + return new type.Complex( + r * Math.cos(x.im), + r * Math.sin(x.im) + ); + }, + + 'BigNumber': function (x) { + return x.exp(); + }, + + 'Array | Matrix': function (x) { + // TODO: exp(sparse) should return a dense matrix since exp(0)==1 + return collection.deepMap(x, exp); + } + }); + + return exp; + } + + exports.name = 'exp'; + exports.factory = factory; + + +/***/ }, +/* 64 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Round a value towards zero. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.fix(x) + * + * Examples: + * + * math.fix(3.2); // returns Number 3 + * math.fix(3.8); // returns Number 3 + * math.fix(-4.2); // returns Number -4 + * math.fix(-4.7); // returns Number -4 + * + * var c = math.complex(3.2, -2.7); + * math.fix(c); // returns Complex 3 - 2i + * + * math.fix([3.2, 3.8, -4.7]); // returns Array [3, 3, -4] + * + * See also: + * + * ceil, floor, round + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded + * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value + */ + var fix = typed('fix', { + 'number': function (x) { + return (x > 0) ? Math.floor(x) : Math.ceil(x); + }, + + 'Complex': function (x) { + return new x.constructor( + (x.re > 0) ? Math.floor(x.re) : Math.ceil(x.re), + (x.im > 0) ? Math.floor(x.im) : Math.ceil(x.im) + ); + }, + + 'BigNumber': function (x) { + return x.isNegative() ? x.ceil() : x.floor(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since fix(0) = 0 + return collection.deepMap(x, fix, true); + } + }); + + return fix; + } + + exports.name = 'fix'; + exports.factory = factory; + +/***/ }, +/* 65 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Round a value towards minus infinity. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.floor(x) + * + * Examples: + * + * math.floor(3.2); // returns Number 3 + * math.floor(3.8); // returns Number 3 + * math.floor(-4.2); // returns Number -5 + * math.floor(-4.7); // returns Number -5 + * + * var c = math.complex(3.2, -2.7); + * math.floor(c); // returns Complex 3 - 3i + * + * math.floor([3.2, 3.8, -4.7]); // returns Array [3, 3, -5] + * + * See also: + * + * ceil, fix, round + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded + * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value + */ + var floor = typed('floor', { + 'number': Math.floor, + + 'Complex': function (x) { + return new x.constructor( + Math.floor(x.re), + Math.floor(x.im) + ); + }, + + 'BigNumber': function (x) { + return x.floor(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since floor(0) = 0 + return collection.deepMap(x, floor, true); + } + }); + + return floor; + } + + exports.name = 'floor'; + exports.factory = factory; + +/***/ }, +/* 66 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + + /** + * Calculate the greatest common divisor for two or more values or arrays. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.gcd(a, b) + * math.gcd(a, b, c, ...) + * + * Examples: + * + * math.gcd(8, 12); // returns 4 + * math.gcd(-4, 6); // returns 2 + * math.gcd(25, 15, -10); // returns 5 + * + * math.gcd([8, -4], [12, 6]); // returns [4, 2] + * + * See also: + * + * lcm, xgcd + * + * @param {... Number | BigNumber | Boolean | Array | Matrix | null} args Two or more integer numbers + * @return {Number | BigNumber | Array | Matrix} The greatest common divisor + */ + var gcd = typed('gcd', { + + 'number, number': _gcd, + + 'BigNumber, BigNumber': _gcdBigNumber, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm4(x, y, gcd); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm1(y, x, gcd, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm1(x, y, gcd, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, gcd); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return gcd(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return gcd(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return gcd(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(x, y, gcd, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, gcd, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, gcd, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, gcd, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, gcd, false).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, gcd, true).valueOf(); + }, + + // TODO: need a smarter notation here + 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { + var res = gcd(a, b); + for (var i = 0; i < args.length; i++) { + res = gcd(res, args[i]); + } + return res; + } + }); + + return gcd; + + /** + * Calculate gcd for BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @returns {BigNumber} Returns greatest common denominator of a and b + * @private + */ + function _gcdBigNumber(a, b) { + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function gcd must be integer numbers'); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + var zero = new type.BigNumber(0); + while (!b.isZero()) { + var r = a.mod(b); + a = b; + b = r; + } + return a.lt(zero) ? a.neg() : a; + } + } + + /** + * Calculate gcd for numbers + * @param {number} a + * @param {number} b + * @returns {number} Returns the greatest common denominator of a and b + * @private + */ + function _gcd(a, b) { + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function gcd must be integer numbers'); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + var r; + while (b != 0) { + r = a % b; + a = b; + b = r; + } + return (a < 0) ? -a : a; + } + + exports.name = 'gcd'; + exports.factory = factory; + +/***/ }, +/* 67 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Calculate the least common multiple for two or more values or arrays. + * + * lcm is defined as: + * + * lcm(a, b) = abs(a * b) / gcd(a, b) + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.lcm(a, b) + * math.lcm(a, b, c, ...) + * + * Examples: + * + * math.lcm(4, 6); // returns 12 + * math.lcm(6, 21); // returns 42 + * math.lcm(6, 21, 5); // returns 210 + * + * math.lcm([4, 6], [6, 21]); // returns [12, 42] + * + * See also: + * + * gcd, xgcd + * + * @param {... Number | BigNumber | Boolean | Array | Matrix | null} args Two or more integer numbers + * @return {Number | BigNumber | Array | Matrix} The least common multiple + */ + var lcm = typed('lcm', { + 'number, number': _lcm, + + 'BigNumber, BigNumber': _lcmBigNumber, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm6(x, y, lcm); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm2(y, x, lcm, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm2(x, y, lcm, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, lcm); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return lcm(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return lcm(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return lcm(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, lcm, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, lcm, false); + break; + } + return c; + }, + + 'number | BigNumber, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(y, x, lcm, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, lcm, true); + break; + } + return c; + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, lcm, false).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, lcm, true).valueOf(); + }, + + // TODO: need a smarter notation here + 'Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber': function (a, b, args) { + var res = lcm(a, b); + for (var i = 0; i < args.length; i++) { + res = lcm(res, args[i]); + } + return res; + } + }); + + return lcm; + + /** + * Calculate lcm for two BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @returns {BigNumber} Returns the least common multiple of a and b + * @private + */ + function _lcmBigNumber(a, b) { + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function lcm must be integer numbers'); + } + + if (a.isZero() || b.isZero()) { + return new type.BigNumber(0); + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + // evaluate lcm here inline to reduce overhead + var prod = a.times(b); + while (!b.isZero()) { + var t = b; + b = a.mod(t); + a = t; + } + return prod.div(a).abs(); + } + } + + /** + * Calculate lcm for two numbers + * @param {number} a + * @param {number} b + * @returns {number} Returns the least common multiple of a and b + * @private + */ + function _lcm (a, b) { + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function lcm must be integer numbers'); + } + + if (a == 0 || b == 0) { + return 0; + } + + // http://en.wikipedia.org/wiki/Euclidean_algorithm + // evaluate lcm here inline to reduce overhead + var t; + var prod = a * b; + while (b != 0) { + t = b; + b = a % t; + a = t; + } + return Math.abs(prod / a); + } + + exports.name = 'lcm'; + exports.factory = factory; + +/***/ }, +/* 68 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var divideScalar = load(__webpack_require__(207)); + + /** + * Calculate the logarithm of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.log(x) + * math.log(x, base) + * + * Examples: + * + * math.log(3.5); // returns 1.252762968495368 + * math.exp(math.log(2.4)); // returns 2.4 + * + * math.pow(10, 4); // returns 10000 + * math.log(10000, 10); // returns 4 + * math.log(10000) / math.log(10); // returns 4 + * + * math.log(1024, 2); // returns 10 + * math.pow(2, 10); // returns 1024 + * + * See also: + * + * exp, log10 + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * Value for which to calculate the logarithm. + * @param {Number | BigNumber | Boolean | Complex | null} [base=e] + * Optional base for the logarithm. If not provided, the natural + * logarithm of `x` is calculated. + * @return {Number | BigNumber | Complex | Array | Matrix} + * Returns the logarithm of `x` + */ + var log = typed('log', { + 'number': _logNumber, + + 'Complex': function (x) { + return new type.Complex ( + Math.log(Math.sqrt(x.re * x.re + x.im * x.im)), + Math.atan2(x.im, x.re) + ); + }, + + 'BigNumber': function (x) { + return x.ln(); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, log); + }, + + 'any, any': function (x, base) { + // calculate logarithm for a specified base, log(x, base) + return divideScalar(log(x), log(base)); + } + }); + + /** + * Calculate the natural logarithm of a number + * @param {number} x + * @returns {number | Complex} + * @private + */ + function _logNumber(x) { + if (x >= 0) { + return Math.log(x); + } + else { + // negative value -> complex value computation + return log(new type.Complex(x, 0)); + } + } + + return log; + } + + exports.name = 'log'; + exports.factory = factory; + + +/***/ }, +/* 69 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the 10-base of a value. This is the same as calculating `log(x, 10)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.log10(x) + * + * Examples: + * + * math.log10(0.00001); // returns -5 + * math.log10(10000); // returns 4 + * math.log(10000) / math.log(10); // returns 4 + * math.pow(10, 4); // returns 10000 + * + * See also: + * + * exp, log + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * Value for which to calculate the logarithm. + * @return {Number | BigNumber | Complex | Array | Matrix} + * Returns the 10-base logarithm of `x` + */ + var log10 = typed('log10', { + 'number': function (x) { + if (x >= 0) { + return Math.log(x) / Math.LN10; + } + else { + // negative value -> complex value computation + return log10(new type.Complex(x, 0)); + } + }, + + 'Complex': _log10Complex, + + 'BigNumber': function (x) { + if (x.isNegative()) { + // downgrade to number, return Complex valued result + return _log10Complex(new type.Complex(x.toNumber(), 0)); + } + else { + return x.log(); + } + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, log10); + } + }); + + return log10; + + /** + * Calculate log10 for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _log10Complex(x) { + return new type.Complex ( + Math.log(Math.sqrt(x.re * x.re + x.im * x.im)) / Math.LN10, + Math.atan2(x.im, x.re) / Math.LN10 + ); + } + } + + exports.name = 'log10'; + exports.factory = factory; + + + +/***/ }, +/* 70 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Calculates the modulus, the remainder of an integer division. + * + * For matrices, the function is evaluated element wise. + * + * The modulus is defined as: + * + * x - y * floor(x / y) + * + * See http://en.wikipedia.org/wiki/Modulo_operation. + * + * Syntax: + * + * math.mod(x, y) + * + * Examples: + * + * math.mod(8, 3); // returns 2 + * math.mod(11, 2); // returns 1 + * + * function isOdd(x) { + * return math.mod(x, 2) != 0; + * } + * + * isOdd(2); // returns false + * isOdd(3); // returns true + * + * See also: + * + * divide + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Dividend + * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Divisor + * @return {Number | BigNumber | Array | Matrix} Returns the remainder of `x` divided by `y`. + */ + var mod = typed('mod', { + + 'number, number': _mod, + + 'BigNumber, BigNumber': function (x, y) { + return y.isZero() ? x : x.mod(y); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // mod(sparse, sparse) + c = elementWiseOperations.algorithm5(x, y, mod, false); + break; + default: + // mod(sparse, dense) + c = elementWiseOperations.algorithm2(y, x, mod, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // mod(dense, sparse) + c = elementWiseOperations.algorithm3(x, y, mod, false); + break; + default: + // mod(dense, dense) + c = elementWiseOperations.algorithm12(x, y, mod); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return mod(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return mod(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return mod(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, mod, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, mod, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, mod, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, mod, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, mod, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, mod, true).valueOf(); + } + }); + + return mod; + + /** + * Calculate the modulus of two numbers + * @param {Number} x + * @param {Number} y + * @returns {number} res + * @private + */ + function _mod(x, y) { + if (y > 0) { + // We don't use JavaScript's % operator here as this doesn't work + // correctly for x < 0 and x == 0 + // see http://en.wikipedia.org/wiki/Modulo_operation + return x - y * Math.floor(x / y); + } + else if (y === 0) { + return x; + } + else { // y < 0 + // TODO: implement mod for a negative divisor + throw new Error('Cannot calculate mod for a negative divisor'); + } + } + } + + exports.name = 'mod'; + exports.factory = factory; + + +/***/ }, +/* 71 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + + var array = util.array; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var addScalar = load(__webpack_require__(192)); + var multiplyScalar = load(__webpack_require__(210)); + var equal = load(__webpack_require__(46)); + var elementWiseOperations = load(__webpack_require__(193)); + + var DenseMatrix = type.DenseMatrix; + var SparseMatrix = type.SparseMatrix; + + /** + * Multiply two values, `x * y`. The result is squeezed. + * For matrices, the matrix product is calculated. + * + * Syntax: + * + * math.multiply(x, y) + * + * Examples: + * + * math.multiply(4, 5.2); // returns Number 20.8 + * + * var a = math.complex(2, 3); + * var b = math.complex(4, 1); + * math.multiply(a, b); // returns Complex 5 + 14i + * + * var c = [[1, 2], [4, 3]]; + * var d = [[1, 2, 3], [3, -4, 7]]; + * math.multiply(c, d); // returns Array [[7, -6, 17], [13, -4, 33]] + * + * var e = math.unit('2.1 km'); + * math.multiply(3, e); // returns Unit 6.3 km + * + * See also: + * + * divide + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to multiply + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to multiply + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Multiplication of `x` and `y` + */ + var multiply = typed('multiply', { + + 'any, any': multiplyScalar, + + 'Array, Array': function (x, y) { + // check dimensions + _validateMatrixDimensions(array.size(x), array.size(y)); + + // use dense matrix implementation + var m = multiply(matrix(x), matrix(y)); + // return array or scalar + return m instanceof type.Matrix ? m.valueOf() : m; + }, + + 'Matrix, Matrix': function (x, y) { + // dimensions + var xsize = x.size(); + var ysize = y.size(); + + // check dimensions + _validateMatrixDimensions(xsize, ysize); + + // process dimensions + if (xsize.length === 1) { + // process y dimensions + if (ysize.length === 1) { + // Vector * Vector + return _multiplyVectorVector(x, y, xsize[0]); + } + // Vector * Matrix + return _multiplyVectorMatrix(x, y); + } + // process y dimensions + if (ysize.length === 1) { + // Matrix * Vector + return _multiplyMatrixVector(x, y); + } + // Matrix * Matrix + return _multiplyMatrixMatrix(x, y); + }, + + 'Matrix, Array': function (x, y) { + // use Matrix * Matrix implementation + return multiply(x, matrix(y)); + }, + + 'Array, Matrix': function (x, y) { + // use Matrix * Matrix implementation + return multiply(matrix(x, y.storage()), y); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + + // process storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, multiplyScalar, false); + break; + case 'dense': + c = elementWiseOperations.algorithm13(x, y, multiplyScalar, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(y, x, multiplyScalar, true); + break; + case 'dense': + c = elementWiseOperations.algorithm13(y, x, multiplyScalar, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, multiplyScalar, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, multiplyScalar, true).valueOf(); + } + }); + + var _validateMatrixDimensions = function (size1, size2) { + // check left operand dimensions + switch (size1.length) { + case 1: + // check size2 + switch (size2.length) { + case 1: + // Vector x Vector + if (size1[0] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Vectors must have the same length'); + } + break; + case 2: + // Vector x Matrix + if (size1[0] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Vector length (' + size1[0] + ') must match Matrix rows (' + size2[0] + ')'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); + } + break; + case 2: + // check size2 + switch (size2.length) { + case 1: + // Matrix x Vector + if (size1[1] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Matrix columns (' + size1[1] + ') must match Vector length (' + size2[0] + ')'); + } + break; + case 2: + // Matrix x Matrix + if (size1[1] !== size2[0]) { + // throw error + throw new RangeError('Dimension mismatch in multiplication. Matrix A columns (' + size1[1] + ') must match Matrix B rows (' + size2[0] + ')'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)'); + } + break; + default: + throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix A has ' + size1.length + ' dimensions)'); + } + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (N) + * @param {Matrix} b Dense Vector (N) + * + * @return {Number} Scalar value + */ + var _multiplyVectorVector = function (a, b, n) { + // check empty vector + if (n === 0) + throw new Error('Cannot multiply two empty vectors'); + + // a dense + var adata = a._data; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bdt = b._datatype; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // result (do not initialize it with zero) + var c = mf(adata[0], bdata[0]); + // loop data + for (var i = 1; i < n; i++) { + // multiply and accumulate + c = af(c, mf(adata[i], bdata[i])); + } + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (M) + * @param {Matrix} b Matrix (MxN) + * + * @return {Matrix} Dense Vector (N) + */ + var _multiplyVectorMatrix = function (a, b) { + // process storage + switch (b.storage()) { + case 'dense': + return _multiplyVectorDenseMatrix(a, b); + } + throw new Error('Not implemented'); + }; + + /** + * C = A * B + * + * @param {Matrix} a Dense Vector (M) + * @param {Matrix} b Dense Matrix (MxN) + * + * @return {Matrix} Dense Vector (N) + */ + var _multiplyVectorDenseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + // rows & columns + var alength = asize[0]; + var bcolumns = bsize[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // result + var c = new Array(bcolumns); + + // loop matrix columns + for (var j = 0; j < bcolumns; j++) { + // sum (do not initialize it with zero) + var sum = mf(adata[0], bdata[0][j]); + // loop vector + for (var i = 1; i < alength; i++) { + // multiply & accumulate + sum = af(sum, mf(adata[i], bdata[i][j])); + } + c[j] = sum; + } + + // check we need to squeeze the result into a scalar + if (bcolumns === 1) + return c[0]; + + // return matrix + return new DenseMatrix({ + data: c, + size: [bcolumns], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a Matrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} Dense Vector (M) + */ + var _multiplyMatrixVector = function (a, b) { + // process storage + switch (a.storage()) { + case 'dense': + return _multiplyDenseMatrixVector(a, b); + case 'sparse': + return _multiplySparseMatrixVector(a, b); + } + }; + + /** + * C = A * B + * + * @param {Matrix} a Matrix (MxN) + * @param {Matrix} b Matrix (NxC) + * + * @return {Matrix} Matrix (MxC) + */ + var _multiplyMatrixMatrix = function (a, b) { + // process storage + switch (a.storage()) { + case 'dense': + // process storage + switch (b.storage()) { + case 'dense': + return _multiplyDenseMatrixDenseMatrix(a, b); + case 'sparse': + return _multiplyDenseMatrixSparseMatrix(a, b); + } + break; + case 'sparse': + // process storage + switch (b.storage()) { + case 'dense': + return _multiplySparseMatrixDenseMatrix(a, b); + case 'sparse': + return _multiplySparseMatrixSparseMatrix(a, b); + } + break; + } + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} Dense Vector (M) + */ + var _multiplyDenseMatrixVector = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = asize[0]; + var acolumns = asize[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // result + var c = new Array(arows); + + // loop matrix a rows + for (var i = 0; i < arows; i++) { + // current row + var row = adata[i]; + // sum (do not initialize it with zero) + var sum = mf(row[0], bdata[0]); + // loop matrix a columns + for (var j = 1; j < acolumns; j++) { + // multiply & accumulate + sum = af(sum, mf(row[j], bdata[j])); + } + c[i] = sum; + } + // check we need to squeeze the result into a scalar + if (arows === 1) + return c[0]; + + // return matrix + return new DenseMatrix({ + data: c, + size: [arows], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b DenseMatrix (NxC) + * + * @return {Matrix} DenseMatrix (MxC) + */ + var _multiplyDenseMatrixDenseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b dense + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + // rows & columns + var arows = asize[0]; + var acolumns = asize[1]; + var bcolumns = bsize[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // result + var c = new Array(arows); + + // loop matrix a rows + for (var i = 0; i < arows; i++) { + // current row + var row = adata[i]; + // initialize row array + c[i] = new Array(bcolumns); + // loop matrix b columns + for (var j = 0; j < bcolumns; j++) { + // sum (avoid initializing sum to zero) + var sum = mf(row[0], bdata[0][j]); + // loop matrix a columns + for (var x = 1; x < acolumns; x++) { + // multiply & accumulate + sum = af(sum, mf(row[x], bdata[x][j])); + } + c[i][j] = sum; + } + } + // check we need to squeeze the result into a scalar + if (arows === 1 && bcolumns === 1) + return c[0][0]; + + // return matrix + return new DenseMatrix({ + data: c, + size: [arows, bcolumns], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a DenseMatrix (MxN) + * @param {Matrix} b SparseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplyDenseMatrixSparseMatrix = function (a, b) { + // a dense + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b sparse + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + // validate b matrix + if (!bvalues) + throw new Error('Cannot multiply Dense Matrix times Pattern only Matrix'); + // rows & columns + var arows = asize[0]; + var bcolumns = bsize[1]; + // result + var cvalues = []; + var cindex = []; + var cptr = new Array(bcolumns + 1); + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // indeces in column jb + var kb0 = bptr[jb]; + var kb1 = bptr[jb + 1]; + // do not process column jb if no data exists + if (kb1 > kb0) { + // last row mark processed + var last = 0; + // loop a rows + for (var i = 0; i < arows; i++) { + // column mark + var mark = i + 1; + // C[i, jb] + var cij; + // values in b column j + for (var kb = kb0; kb < kb1; kb++) { + // row + var ib = bindex[kb]; + // check value has been initialized + if (last !== mark) { + // first value in column jb + cij = mf(adata[i][ib], bvalues[kb]); + // update mark + last = mark; + } + else { + // accumulate value + cij = af(cij, mf(adata[i][ib], bvalues[kb])); + } + } + // check column has been processed and value != 0 + if (last === mark && !equal(cij, 0)) { + // push row & value + cindex.push(i); + cvalues.push(cij); + } + } + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // check we need to squeeze the result into a scalar + if (arows === 1 && bcolumns === 1) + return cvalues.length === 1 ? cvalues[0] : 0; + + // return sparse matrix + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b Dense Vector (N) + * + * @return {Matrix} SparseMatrix (M, 1) + */ + var _multiplySparseMatrixVector = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // validate a matrix + if (!avalues) + throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = a._size[0]; + var brows = b._size[0]; + // result + var cvalues = []; + var cindex = []; + var cptr = new Array(2); + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // workspace + var x = new Array(arows); + // vector with marks indicating a value x[i] exists in a given column + var w = new Array(arows); + + // update ptr + cptr[0] = 0; + // rows in b + for (var ib = 0; ib < brows; ib++) { + // b[ib] + var vbi = bdata[ib]; + // check b[ib] != 0, avoid loops + if (!equal(vbi, 0)) { + // A values & index in ib column + for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // a row + var ia = aindex[ka]; + // check value exists in current j + if (!w[ia]) { + // ia is new entry in j + w[ia] = true; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(vbi, avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(vbi, avalues[ka])); + } + } + } + } + // copy values from x to column jb of c + for (var p1 = cindex.length, p = 0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + // update ptr + cptr[1] = cindex.length; + + // check we need to squeeze the result into a scalar + if (arows === 1) + return cvalues.length === 1 ? cvalues[0] : 0; + + // return sparse matrix + return new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, 1], + datatype: dt + }); + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b DenseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplySparseMatrixDenseMatrix = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // validate a matrix + if (!avalues) + throw new Error('Cannot multiply Pattern only Matrix times Dense Matrix'); + // b dense + var bdata = b._data; + var bdt = b._datatype; + // rows & columns + var arows = a._size[0]; + var brows = b._size[0]; + var bcolumns = b._size[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + + // result + var cvalues = []; + var cindex = []; + var cptr = new Array(bcolumns + 1); + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + // workspace + var x = new Array(arows); + // vector with marks indicating a value x[i] exists in a given column + var w = new Array(arows); + + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // mark in workspace for current column + var mark = jb + 1; + // rows in jb + for (var ib = 0; ib < brows; ib++) { + // b[ib, jb] + var vbij = bdata[ib][jb]; + // check b[ib, jb] != 0, avoid loops + if (!equal(vbij, 0)) { + // A values & index in ib column + for (var ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // a row + var ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(vbij, avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(vbij, avalues[ka])); + } + } + } + } + // copy values from x to column jb of c + for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // check we need to squeeze the result into a scalar + if (arows === 1 && bcolumns === 1) + return cvalues.length === 1 ? cvalues[0] : 0; + + // return sparse matrix + return c; + }; + + /** + * C = A * B + * + * @param {Matrix} a SparseMatrix (MxN) + * @param {Matrix} b SparseMatrix (NxC) + * + * @return {Matrix} SparseMatrix (MxC) + */ + var _multiplySparseMatrixSparseMatrix = function (a, b) { + // a sparse + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var adt = a._datatype; + // b sparse + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bdt = b._datatype; + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // multiply & add scalar implementations + var mf = dt ? multiplyScalar.signatures[dt + ',' + dt] || multiplyScalar : multiplyScalar; + var af = dt ? addScalar.signatures[dt + ',' + dt] || addScalar : addScalar; + // rows & columns + var arows = a._size[0]; + var bcolumns = b._size[1]; + // flag indicating both matrices (a & b) contain data + var values = avalues && bvalues; + // result + var cvalues = values ? [] : undefined; + var cindex = []; + var cptr = new Array(bcolumns + 1); + // c matrix + var c = new SparseMatrix({ + values : cvalues, + index: cindex, + ptr: cptr, + size: [arows, bcolumns], + datatype: dt + }); + // workspace + var x = values ? new Array(arows) : undefined; + // vector with marks indicating a value x[i] exists in a given column + var w = new Array(arows); + // variables + var ka, ka0, ka1, kb, kb0, kb1, ia, ib; + // loop b columns + for (var jb = 0; jb < bcolumns; jb++) { + // update ptr + cptr[jb] = cindex.length; + // mark in workspace for current column + var mark = jb + 1; + // B values & index in j + for (kb0 = bptr[jb], kb1 = bptr[jb + 1], kb = kb0; kb < kb1; kb++) { + // b row + ib = bindex[kb]; + // check we need to process values + if (values) { + // loop values in a[:,ib] + for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // row + ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + // x(ia) = A + x[ia] = mf(bvalues[kb], avalues[ka]); + } + else { + // i exists in C already + x[ia] = af(x[ia], mf(bvalues[kb], avalues[ka])); + } + } + } + else { + // loop values in a[:,ib] + for (ka0 = aptr[ib], ka1 = aptr[ib + 1], ka = ka0; ka < ka1; ka++) { + // row + ia = aindex[ka]; + // check value exists in current j + if (w[ia] !== mark) { + // ia is new entry in j + w[ia] = mark; + // add i to pattern of C + cindex.push(ia); + } + } + } + } + // check we need to process matrix values (pattern matrix) + if (values) { + // copy values from x to column jb of c + for (var p0 = cptr[jb], p1 = cindex.length, p = p0; p < p1; p++) { + // row + var ic = cindex[p]; + // copy value + cvalues[p] = x[ic]; + } + } + } + // update ptr + cptr[bcolumns] = cindex.length; + + // check we need to squeeze the result into a scalar + if (arows === 1 && bcolumns === 1 && values) + return cvalues.length === 1 ? cvalues[0] : 0; + + // return sparse matrix + return c; + }; + + return multiply; + } + + exports.name = 'multiply'; + exports.factory = factory; + + +/***/ }, +/* 72 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var abs = load(__webpack_require__(56)); + var add = load(__webpack_require__(47)); + var pow = load(__webpack_require__(74)); + var sqrt = load(__webpack_require__(77)); + var multiply = load(__webpack_require__(71)); + var equal = load(__webpack_require__(46)); + var larger = load(__webpack_require__(45)); + var smaller = load(__webpack_require__(44)); + var matrix = load(__webpack_require__(40)); + var trace = load(__webpack_require__(116)); + var transpose = load(__webpack_require__(117)); + + var complexAbs = abs.signatures['Complex']; + + /** + * Calculate the norm of a number, vector or matrix. + * + * The second parameter p is optional. If not provided, it defaults to 2. + * + * Syntax: + * + * math.norm(x) + * math.norm(x, p) + * + * Examples: + * + * math.abs(-3.5); // returns 3.5 + * math.norm(-3.5); // returns 3.5 + * + * math.norm(math.complex(3, -4)); // returns 5 + * + * math.norm([1, 2, -3], Infinity); // returns 3 + * math.norm([1, 2, -3], -Infinity); // returns 1 + * + * math.norm([3, 4], 2); // returns 5 + * + * math.norm([[1, 2], [3, 4]], 1) // returns 6 + * math.norm([[1, 2], [3, 4]], 'inf'); // returns 7 + * math.norm([[1, 2], [3, 4]], 'fro'); // returns 5.477225575051661 + * + * See also: + * + * abs + * + * @param {Number | BigNumber | Complex | Boolean | Array | Matrix | null} x + * Value for which to calculate the norm + * @param {Number | BigNumber | String} [p=2] + * Vector space. + * Supported numbers include Infinity and -Infinity. + * Supported strings are: 'inf', '-inf', and 'fro' (The Frobenius norm) + * @return {Number | BigNumber} the p-norm + */ + var norm = typed('norm', { + 'number': Math.abs, + + 'Complex': complexAbs, + + 'BigNumber': function (x) { + // norm(x) = abs(x) + return x.abs(); + }, + + 'boolean | null' : function (x) { + // norm(x) = abs(x) + return Math.abs(x); + }, + + 'Array': function (x) { + return _norm(matrix(x), 2); + }, + + 'Matrix': function (x) { + return _norm(x, 2); + }, + + 'number | Complex | BigNumber | boolean | null, number | BigNumber | string': function (x) { + // ignore second parameter, TODO: remove the option of second parameter for these types + return norm(x); + }, + + 'Array, number | BigNumber | string': function (x, p) { + return _norm(matrix(x), p); + }, + + 'Matrix, number | BigNumber | string': function (x, p) { + return _norm(x, p); + } + }); + + /** + * Calculate the norm for an array + * @param {Array} x + * @param {number | string} p + * @returns {number} Returns the norm + * @private + */ + function _norm (x, p) { + // size + var sizeX = x.size(); + + // check if it is a vector + if (sizeX.length == 1) { + // check p + if (p === Number.POSITIVE_INFINITY || p === 'inf') { + // norm(x, Infinity) = max(abs(x)) + var pinf = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + var v = abs(value); + if (larger(v, pinf)) + pinf = v; + }, + true); + return pinf; + } + if (p === Number.NEGATIVE_INFINITY || p === '-inf') { + // norm(x, -Infinity) = min(abs(x)) + var ninf; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + var v = abs(value); + if (!ninf || smaller(v, ninf)) + ninf = v; + }, + true); + return ninf || 0; + } + if (p === 'fro') { + return _norm(x, 2); + } + if (typeof p === 'number' && !isNaN(p)) { + // check p != 0 + if (!equal(p, 0)) { + // norm(x, p) = sum(abs(xi) ^ p) ^ 1/p + var n = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value) { + n = add(pow(abs(value), p), n); + }, + true); + return pow(n, 1 / p); + } + return Number.POSITIVE_INFINITY; + } + // invalid parameter value + throw new Error('Unsupported parameter value'); + } + // MxN matrix + if (sizeX.length == 2) { + // check p + if (p === 1) { + // norm(x) = the largest column sum + var c = []; + // result + var maxc = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value, index) { + var j = index[1]; + var cj = add(c[j] || 0, abs(value)); + if (larger(cj, maxc)) + maxc = cj; + c[j] = cj; + }, + true); + return maxc; + } + if (p === Number.POSITIVE_INFINITY || p === 'inf') { + // norm(x) = the largest row sum + var r = []; + // result + var maxr = 0; + // skip zeros since abs(0) == 0 + x.forEach( + function (value, index) { + var i = index[0]; + var ri = add(r[i] || 0, abs(value)); + if (larger(ri, maxr)) + maxr = ri; + r[i] = ri; + }, + true); + return maxr; + } + if (p === 'fro') { + // norm(x) = sqrt(sum(diag(x'x))) + return sqrt(trace(multiply(transpose(x), x))); + } + if (p === 2) { + // not implemented + throw new Error('Unsupported parameter value, missing implementation of matrix singular value decomposition'); + } + // invalid parameter value + throw new Error('Unsupported parameter value'); + } + } + + return norm; + } + + exports.name = 'norm'; + exports.factory = factory; + + +/***/ }, +/* 73 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the nth root of a value. + * The principal nth root of a positive real number A, is the positive real + * solution of the equation + * + * x^root = A + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.nthRoot(a) + * math.nthRoot(a, root) + * + * Examples: + * + * math.nthRoot(9, 2); // returns 3, as 3^2 == 9 + * math.sqrt(9); // returns 3, as 3^2 == 9 + * math.nthRoot(64, 3); // returns 4, as 4^3 == 64 + * + * See also: + * + * sqrt, pow + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} a + * Value for which to calculate the nth root + * @param {Number | BigNumber | Boolean | null} [root=2] The root. + * @return {Number | Complex | Array | Matrix} Returns the nth root of `a` + */ + var nthRoot = typed('nthRoot', { + 'number': function (x) { + return _nthRoot(x, 2); + }, + 'number, number': _nthRoot, + + 'BigNumber': function (x) { + return _bigNthRoot(x, new type.BigNumber(2)); + }, + 'BigNumber, BigNumber': _bigNthRoot, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, nthRoot); + }, + + 'Array | Matrix, any': function (x, root) { + return collection.deepMap2(x, root, nthRoot); + }, + + 'any, Array | Matrix': function (x, root) { + return collection.deepMap2(x, root, nthRoot); + } + }); + + return nthRoot; + + /** + * Calculate the nth root of a for BigNumbers, solve x^root == a + * http://rosettacode.org/wiki/Nth_root#JavaScript + * @param {BigNumber} a + * @param {BigNumber} root + * @private + */ + function _bigNthRoot(a, root) { + var zero = new type.BigNumber(0); + var one = new type.BigNumber(1); + var inv = root.isNegative(); + if (inv) root = root.negated(); + + if (root.isZero()) throw new Error('Root must be non-zero'); + if (a.isNegative() && !root.abs().mod(2).equals(1)) throw new Error('Root must be odd when a is negative.'); + + // edge cases zero and infinity + if (a.isZero()) return zero; + if (!a.isFinite()) + { + return inv ? zero : a; + } + + var x = one; // Initial guess + var i = 0; + var iMax = 100; + do { + var xPrev = x; + var delta = a.div(x.pow(root.minus(1))).minus(x).div(root); + x = x.plus(delta); + i++; + } + while (!x.equals(xPrev) && i < iMax); + + return inv ? one.div(x) : x; + } + } + + /** + * Calculate the nth root of a, solve x^root == a + * http://rosettacode.org/wiki/Nth_root#JavaScript + * @param {number} a + * @param {number} root + * @private + */ + function _nthRoot(a, root) { + var inv = root < 0; + if (inv) root = -root; + + if (root === 0) throw new Error('Root must be non-zero'); + if (a < 0 && (Math.abs(root) % 2 != 1)) throw new Error('Root must be odd when a is negative.'); + + // edge cases zero and infinity + if (a == 0) return 0; + if (!Number.isFinite(a)) { + return inv ? 0 : a; + } + + var epsilon = 1e-16; + var x = 1; // Initial guess + var i = 0; + var iMax = 100; + do { + var delta = (a / Math.pow(x, root - 1) - x) / root; + x = x + delta; + i++; + } + while (Math.abs(delta) > epsilon && i < iMax); + + return inv ? 1 / x : x; + } + + exports.name = 'nthRoot'; + exports.factory = factory; + + +/***/ }, +/* 74 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var exp = load(__webpack_require__(63)); + var eye = load(__webpack_require__(107)); + var log = load(__webpack_require__(68)); + var multiply = load(__webpack_require__(71)); + var matrix = load(__webpack_require__(40)); + + /** + * Calculates the power of x to y, `x ^ y`. + * Matrix exponentiation is supported for square matrices `x`, and positive + * integer exponents `y`. + * + * Syntax: + * + * math.pow(x, y) + * + * Examples: + * + * math.pow(2, 3); // returns Number 8 + * + * var a = math.complex(2, 3); + * math.pow(a, 2) // returns Complex -5 + 12i + * + * var b = [[1, 2], [4, 3]]; + * math.pow(b, 2); // returns Array [[9, 8], [16, 17]] + * + * See also: + * + * multiply, sqrt + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x The base + * @param {Number | BigNumber | Boolean | Complex | null} y The exponent + * @return {Number | BigNumber | Complex | Array | Matrix} The value of `x` to the power `y` + */ + var pow = typed('pow', { + 'number, number': function (x, y) { + if (isInteger(y) || x >= 0) { + return Math.pow(x, y); + } + else { + return _powComplex(new type.Complex(x, 0), new type.Complex(y, 0)); + } + }, + + 'BigNumber, BigNumber': function (x, y) { + if (isInteger(y) || x >= 0) { + return x.pow(y); + } + else { + return _powComplex(new type.Complex(x.toNumber(), 0), new type.Complex(y.toNumber(), 0)); + } + }, + + 'Complex, Complex': _powComplex, + + 'Array, number': _powArray, + + 'Array, BigNumber': function (x, y) { + return _powArray(x, y.toNumber()); + }, + + 'Matrix, number': _powMatrix, + + 'Matrix, BigNumber': function (x, y) { + return _powMatrix(x, y.toNumber()); + } + }); + + /** + * Calculates the power of x to y, x^y, for two complex numbers. + * @param {Complex} x + * @param {Complex} y + * @return {Complex} res + * @private + */ + function _powComplex (x, y) { + // complex computation + // x^y = exp(log(x)*y) = exp((abs(x)+i*arg(x))*y) + // TODO: we can optimize this as we know x and y are Complex + // expComplex = exp.signatures['Complex,Complex'] + // multiplyComplex = multiply.signatures['Complex,Complex'] + // logComplex = log.signatures['Complex,Complex'] + // return expComplex(multiplyComplex(logComplex(x), y)); + return exp(multiply(log(x), y)); + } + + /** + * Calculate the power of a 2d array + * @param {Array} x must be a 2 dimensional, square matrix + * @param {number} y a positive, integer value + * @returns {Array} + * @private + */ + function _powArray(x, y) { + if (!isInteger(y) || y < 0) { + throw new TypeError('For A^b, b must be a positive integer (value is ' + y + ')'); + } + // verify that A is a 2 dimensional square matrix + var s = size(x); + if (s.length != 2) { + throw new Error('For A^b, A must be 2 dimensional (A has ' + s.length + ' dimensions)'); + } + if (s[0] != s[1]) { + throw new Error('For A^b, A must be square (size is ' + s[0] + 'x' + s[1] + ')'); + } + + var res = eye(s[0]).valueOf(); + var px = x; + while (y >= 1) { + if ((y & 1) == 1) { + res = multiply(px, res); + } + y >>= 1; + px = multiply(px, px); + } + return res; + } + + /** + * Calculate the power of a 2d matrix + * @param {Matrix} x must be a 2 dimensional, square matrix + * @param {number} y a positive, integer value + * @returns {Matrix} + * @private + */ + function _powMatrix (x, y) { + return matrix(_powArray(x.valueOf(), y)); + } + + return pow; + } + + exports.name = 'pow'; + exports.factory = factory; + + +/***/ }, +/* 75 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var toFixed = __webpack_require__(41).toFixed; + + function factory (type, config, load, typed) { + + var collection = load(__webpack_require__(2)); + var matrix = load(__webpack_require__(40)); + var equal = load(__webpack_require__(46)); + var zeros = load(__webpack_require__(118)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Round a value towards the nearest integer. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.round(x) + * math.round(x, n) + * + * Examples: + * + * math.round(3.2); // returns Number 3 + * math.round(3.8); // returns Number 4 + * math.round(-4.2); // returns Number -4 + * math.round(-4.7); // returns Number -5 + * math.round(math.pi, 3); // returns Number 3.142 + * math.round(123.45678, 2); // returns Number 123.46 + * + * var c = math.complex(3.2, -2.7); + * math.round(c); // returns Complex 3 - 3i + * + * math.round([3.2, 3.8, -4.7]); // returns Array [3, 4, -5] + * + * See also: + * + * ceil, fix, floor + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Number to be rounded + * @param {Number | BigNumber | Boolean | Array | null} [n=0] Number of decimals + * @return {Number | BigNumber | Complex | Array | Matrix} Rounded value + */ + var round = typed('round', { + + 'number': Math.round, + + 'number, number': function (x, n) { + if (!isInteger(n)) {throw new TypeError('Number of decimals in function round must be an integer');} + if (n < 0 || n > 15) {throw new Error('Number of decimals in function round must be in te range of 0-15');} + + return _round(x, n); + }, + + 'Complex': function (x) { + return new type.Complex ( + Math.round(x.re), + Math.round(x.im) + ); + }, + + 'Complex, number': function (x, n) { + return new type.Complex ( + _round(x.re, n), + _round(x.im, n) + ); + }, + + 'Complex, BigNumber': function (x, n) { + var _n = n.toNumber(); + return new type.Complex ( + _round(x.re, _n), + _round(x.im, _n) + ); + }, + + 'BigNumber': function (x) { + return x.toDecimalPlaces(0); + }, + + 'BigNumber, BigNumber': function (x, n) { + if (!n.isInteger()) {throw new TypeError('Number of decimals in function round must be an integer');} + + return x.toDecimalPlaces(n.toNumber()); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since round(0) = 0 + return collection.deepMap(x, round, true); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, round, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, round, false); + break; + } + return c; + }, + + 'number | Complex | BigNumber, Matrix': function (x, y) { + // check scalar is zero + if (!equal(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, round, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, round, true); + break; + } + return c; + } + // do not execute algorithm, result will be a zero matrix + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, round, false).valueOf(); + }, + + 'number | Complex | BigNumber, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, round, true).valueOf(); + } + }); + + return round; + } + + /** + * round a number to the given number of decimals, or to zero if decimals is + * not provided + * @param {Number} value + * @param {Number} decimals number of decimals, between 0 and 15 (0 by default) + * @return {Number} roundedValue + * @private + */ + function _round (value, decimals) { + return parseFloat(toFixed(value, decimals)); + } + + exports.name = 'round'; + exports.factory = factory; + + +/***/ }, +/* 76 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var number = __webpack_require__(41); + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Compute the sign of a value. The sign of a value x is: + * + * - 1 when x > 1 + * - -1 when x < 0 + * - 0 when x == 0 + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sign(x) + * + * Examples: + * + * math.sign(3.5); // returns 1 + * math.sign(-4.2); // returns -1 + * math.sign(0); // returns 0 + * + * math.sign([3, 5, -2, 0, 2]); // returns [1, 1, -1, 0, 1] + * + * See also: + * + * abs + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * The number for which to determine the sign + * @return {Number | BigNumber | Complex | Array | Matrix}e + * The sign of `x` + */ + var sign = typed('sign', { + 'number': number.sign, + + 'Complex': function (x) { + var abs = Math.sqrt(x.re * x.re + x.im * x.im); + return new x.constructor(x.re / abs, x.im / abs); + }, + + 'BigNumber': function (x) { + return new x.constructor(x.cmp(0)); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sign(0) = 0 + return collection.deepMap(x, sign, true); + } + }); + + return sign; + } + + exports.name = 'sign'; + exports.factory = factory; + + + +/***/ }, +/* 77 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the square root of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sqrt(x) + * + * Examples: + * + * math.sqrt(25); // returns 5 + * math.square(5); // returns 25 + * math.sqrt(-4); // returns Complex -2i + * + * See also: + * + * square, multiply + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * Value for which to calculate the square root. + * @return {Number | BigNumber | Complex | Array | Matrix} + * Returns the square root of `x` + */ + var sqrt = typed('sqrt', { + 'number': _sqrtNumber, + + 'Complex': _sqrtComplex, + + 'BigNumber': function (x) { + if (x.isNegative()) { + // negative value -> downgrade to number to do complex value computation + return _sqrtNumber(x.toNumber()); + } + else { + return x.sqrt(); + } + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sqrt(0) = 0 + return collection.deepMap(x, sqrt, true); + } + }); + + /** + * Calculate sqrt for a number + * @param {Number} x + * @returns {Number | Complex} Returns the square root of x + * @private + */ + function _sqrtNumber(x) { + if (x >= 0) { + return Math.sqrt(x); + } + else { + return _sqrtComplex(new type.Complex(x, 0)); + } + } + + /** + * Calculate sqrt for a complex number + * @param {Complex} x + * @returns {Complex} Returns the square root of x + * @private + */ + function _sqrtComplex(x) { + var r = Math.sqrt(x.re * x.re + x.im * x.im); + + var re, im; + + if (x.re >= 0) { + re = 0.5 * Math.sqrt(2.0 * (r + x.re)); + } + else { + re = Math.abs(x.im) / Math.sqrt(2 * (r - x.re)); + } + + if (x.re <= 0) { + im = 0.5 * Math.sqrt(2.0 * (r - x.re)); + } + else { + im = Math.abs(x.im) / Math.sqrt(2 * (r + x.re)); + } + + if (x.im >= 0) { + return new type.Complex(re, im); + } + else { + return new type.Complex(re, -im); + } + } + + return sqrt; + } + + exports.name = 'sqrt'; + exports.factory = factory; + + +/***/ }, +/* 78 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Compute the square of a value, `x * x`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.square(x) + * + * Examples: + * + * math.square(2); // returns Number 4 + * math.square(3); // returns Number 9 + * math.pow(3, 2); // returns Number 9 + * math.multiply(3, 3); // returns Number 9 + * + * math.square([1, 2, 3, 4]); // returns Array [1, 4, 9, 16] + * + * See also: + * + * multiply, cube, sqrt, pow + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x + * Number for which to calculate the square + * @return {Number | BigNumber | Complex | Array | Matrix} + * Squared value + */ + var square = typed('square', { + 'number': function (x) { + return x * x; + }, + + 'Complex': function (x) { + return new x.constructor( + x.re * x.re - x.im * x.im, + x.re * x.im + x.im * x.re + ); + }, + + 'BigNumber': function (x) { + return x.times(x); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since square(0) = 0 + return collection.deepMap(x, square, true); + } + }); + + return square; + } + + exports.name = 'square'; + exports.factory = factory; + + +/***/ }, +/* 79 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(39); + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var addScalar = load(__webpack_require__(192)); + var unaryMinus = load(__webpack_require__(80)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Subtract two values, `x - y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.subtract(x, y) + * + * Examples: + * + * math.subtract(5.3, 2); // returns Number 3.3 + * + * var a = math.complex(2, 3); + * var b = math.complex(4, 1); + * math.subtract(a, b); // returns Complex -2 + 2i + * + * math.subtract([5, 7, 4], 4); // returns Array [1, 3, 0] + * + * var c = math.unit('2.1 km'); + * var d = math.unit('500m'); + * math.subtract(c, d); // returns Unit 1.6 km + * + * See also: + * + * add + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x + * Initial value + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y + * Value to subtract from `x` + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} + * Subtraction of `x` and `y` + */ + var subtract = typed('subtract', { + + 'number, number': function (x, y) { + return x - y; + }, + + 'Complex, Complex': function (x, y) { + return new type.Complex ( + x.re - y.re, + x.im - y.im + ); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.minus(y); + }, + + 'Unit, Unit': function (x, y) { + if (x.value == null) { + throw new Error('Parameter x contains a unit with undefined value'); + } + + if (y.value == null) { + throw new Error('Parameter y contains a unit with undefined value'); + } + + if (!x.equalBase(y)) { + throw new Error('Units do not match'); + } + + var res = x.clone(); + res.value -= y.value; + res.fixPrefix = false; + + return res; + }, + + 'Matrix, Matrix': function (x, y) { + // matrix sizes + var xsize = x.size(); + var ysize = y.size(); + + // check dimensions + if (xsize.length !== ysize.length) + throw new DimensionError(xsize.length, ysize.length); + + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse - sparse + c = elementWiseOperations.algorithm5(x, y, subtract); + break; + default: + // sparse - dense + c = elementWiseOperations.algorithm3(y, x, subtract, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense - sparse + c = elementWiseOperations.algorithm1(x, y, subtract, false); + break; + default: + // dense - dense + c = elementWiseOperations.algorithm12(x, y, subtract); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return subtract(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return subtract(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return subtract(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + // algorithm 7 is faster than 9 since it calls f() for nonzero items only! + c = elementWiseOperations.algorithm9(x, unaryMinus(y), addScalar); + break; + default: + c = elementWiseOperations.algorithm13(x, y, subtract); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, subtract, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, subtract, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, subtract, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, subtract, true).valueOf(); + } + }); + + return subtract; + } + + exports.name = 'subtract'; + exports.factory = factory; + + +/***/ }, +/* 80 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Inverse the sign of a value, apply a unary minus operation. + * + * For matrices, the function is evaluated element wise. Boolean values and + * strings will be converted to a number. For complex numbers, both real and + * complex value are inverted. + * + * Syntax: + * + * math.unaryMinus(x) + * + * Examples: + * + * math.unaryMinus(3.5); // returns -3.5 + * math.unaryMinus(-4.2); // returns 4.2 + * + * See also: + * + * add, subtract, unaryPlus + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Number to be inverted. + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} Returns the value with inverted sign. + */ + var unaryMinus = typed('unaryMinus', { + 'number': function (x) { + return -x; + }, + + 'Complex': function (x) { + return new x.constructor(-x.re, -x.im); + }, + + 'BigNumber': function (x) { + return x.neg(); + }, + + 'Unit': function (x) { + var res = x.clone(); + res.value = -x.value; + return res; + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since unaryMinus(0) = 0 + return collection.deepMap(x, unaryMinus, true); + } + + // TODO: add support for string + }); + + return unaryMinus; + } + + exports.name = 'unaryMinus'; + exports.factory = factory; + + +/***/ }, +/* 81 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Unary plus operation. + * Boolean values and strings will be converted to a number, numeric values will be returned as is. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.unaryPlus(x) + * + * Examples: + * + * math.unaryPlus(3.5); // returns 3.5 + * math.unaryPlus(1); // returns 1 + * + * See also: + * + * unaryMinus, add, subtract + * + * @param {Number | BigNumber | Boolean | String | Complex | Unit | Array | Matrix | null} x + * Input value + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} + * Returns the input value when numeric, converts to a number when input is non-numeric. + */ + var unaryPlus = typed('unaryPlus', { + 'number': function (x) { + return x; + }, + + 'Complex': function (x) { + return x.clone(); + }, + + 'BigNumber': function (x) { + return x; + }, + + 'Unit': function (x) { + return x.clone(); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since unaryPlus(0) = 0 + return collection.deepMap(x, unaryPlus, true); + }, + + 'boolean | string | null': function (x) { + // convert to a number or bignumber + return (config.number == 'bignumber') ? new type.BigNumber(+x): +x; + } + }); + + return unaryPlus; + } + + exports.name = 'unaryPlus'; + exports.factory = factory; + + +/***/ }, +/* 82 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var matrix = load(__webpack_require__(40)); + + /** + * Calculate the extended greatest common divisor for two values. + * See http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm. + * + * Syntax: + * + * math.xgcd(a, b) + * + * Examples: + * + * math.xgcd(8, 12); // returns [4, -1, 1] + * math.gcd(8, 12); // returns 4 + * math.xgcd(36163, 21199); // returns [1247, -7, 12] + * + * See also: + * + * gcd, lcm + * + * @param {Number | BigNumber | Boolean} a An integer number + * @param {Number | BigNumber | Boolean} b An integer number + * @return {Array} Returns an array containing 3 integers `[div, m, n]` + * where `div = gcd(a, b)` and `a*m + b*n = div` + */ + return typed('xgcd', { + 'number, number': _xgcd, + 'BigNumber, BigNumber': _xgcdBigNumber + }); + + /** + * Calculate xgcd for two numbers + * @param {Number} a + * @param {Number} b + * @return {Number} result + * @private + */ + function _xgcd (a, b) { + // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm + var t, // used to swap two variables + q, // quotient + r, // remainder + x = 0, lastx = 1, + y = 1, lasty = 0; + + if (!isInteger(a) || !isInteger(b)) { + throw new Error('Parameters in function xgcd must be integer numbers'); + } + + while (b) { + q = Math.floor(a / b); + r = a % b; + + t = x; + x = lastx - q * x; + lastx = t; + + t = y; + y = lasty - q * y; + lasty = t; + + a = b; + b = r; + } + + var res; + if (a < 0) { + res = [-a, -lastx, -lasty]; + } + else { + res = [a, a ? lastx : 0, lasty]; + } + return (config.matrix === 'array') ? res : matrix(res); + } + + /** + * Calculate xgcd for two BigNumbers + * @param {BigNumber} a + * @param {BigNumber} b + * @return {BigNumber[]} result + * @private + */ + function _xgcdBigNumber(a, b) { + // source: http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm + var t, // used to swap two variables + q, // quotient + r, // remainder + zero = new type.BigNumber(0), + x = new type.BigNumber(0), lastx = new type.BigNumber(1), + y = new type.BigNumber(1), lasty = new type.BigNumber(0); + + if (!a.isInt() || !b.isInt()) { + throw new Error('Parameters in function xgcd must be integer numbers'); + } + + while (!b.isZero()) { + q = a.div(b).floor(); + r = a.mod(b); + + t = x; + x = lastx.minus(q.times(x)); + lastx = t; + + t = y; + y = lasty.minus(q.times(y)); + lasty = t; + + a = b; + b = r; + } + + var res; + if (a.lt(zero)) { + res = [a.neg(), lastx.neg(), lasty.neg()]; + } + else { + res = [a, !a.isZero() ? lastx : 0, lasty]; + } + return (config.matrix === 'array') ? res : matrix(res); + } + } + + exports.name = 'xgcd'; + exports.factory = factory; + +/***/ }, +/* 83 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigBitAnd = __webpack_require__(48).and; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise AND two values, `x & y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.bitAnd(x, y) + * + * Examples: + * + * math.bitAnd(53, 131); // returns Number 1 + * + * math.bitAnd([1, 12, 31], 42); // returns Array [0, 8, 10] + * + * See also: + * + * bitNot, bitOr, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to and + * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to and + * @return {Number | BigNumber | Array | Matrix} AND of `x` and `y` + */ + var bitAnd = typed('bitAnd', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitAnd'); + } + + return x & y; + }, + + 'BigNumber, BigNumber': bigBitAnd, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = elementWiseOperations.algorithm6(x, y, bitAnd, false); + break; + default: + // sparse & dense + c = elementWiseOperations.algorithm2(y, x, bitAnd, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = elementWiseOperations.algorithm2(x, y, bitAnd, false); + break; + default: + // dense & dense + c = elementWiseOperations.algorithm12(x, y, bitAnd); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitAnd(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitAnd(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitAnd(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, bitAnd, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, bitAnd, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(y, x, bitAnd, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, bitAnd, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, bitAnd, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, bitAnd, true).valueOf(); + } + }); + + return bitAnd; + } + + exports.name = 'bitAnd'; + exports.factory = factory; + + +/***/ }, +/* 84 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigBitNot = __webpack_require__(48).not; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Bitwise NOT value, `~x`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.bitNot(x) + * + * Examples: + * + * math.bitNot(1); // returns Number -2 + * + * math.bitNot([2, -3, 4]); // returns Array [-3, 2, 5] + * + * See also: + * + * bitAnd, bitOr, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to not + * @return {Number | BigNumber | Array | Matrix} NOT of `x` + */ + var bitNot = typed('bitNot', { + 'number': function (x) { + if (!isInteger(x)) { + throw new Error('Integer expected in function bitNot'); + } + + return ~x; + }, + + 'BigNumber': bigBitNot, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, bitNot); + } + }); + + return bitNot; + } + + exports.name = 'bitNot'; + exports.factory = factory; + + +/***/ }, +/* 85 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigBitOr = __webpack_require__(48).or; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise OR two values, `x | y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the lowest print base. + * + * Syntax: + * + * math.bitOr(x, y) + * + * Examples: + * + * math.bitOr(1, 2); // returns Number 3 + * + * math.bitOr([1, 2, 3], 4); // returns Array [5, 6, 7] + * + * See also: + * + * bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to or + * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to or + * @return {Number | BigNumber | Array | Matrix} OR of `x` and `y` + */ + var bitOr = typed('bitOr', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitOr'); + } + + return x | y; + }, + + 'BigNumber, BigNumber': bigBitOr, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm4(x, y, bitOr); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm1(y, x, bitOr, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm1(x, y, bitOr, false); + break; + default: + c = elementWiseOperations.algorithm12(x, y, bitOr); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitOr(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitOr(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitOr(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(x, y, bitOr, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, bitOr, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, bitOr, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, bitOr, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, bitOr, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, bitOr, true).valueOf(); + } + }); + + return bitOr; + } + + exports.name = 'bitOr'; + exports.factory = factory; + + +/***/ }, +/* 86 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigBitXor = __webpack_require__(48).xor; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise XOR two values, `x ^ y`. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.bitXor(x, y) + * + * Examples: + * + * math.bitXor(1, 2); // returns Number 3 + * + * math.bitXor([2, 3, 4], 4); // returns Array [6, 7, 0] + * + * See also: + * + * bitAnd, bitNot, bitOr, leftShift, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x First value to xor + * @param {Number | BigNumber | Boolean | Array | Matrix | null} y Second value to xor + * @return {Number | BigNumber | Array | Matrix} XOR of `x` and `y` + */ + var bitXor = typed('bitXor', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function bitXor'); + } + + return x ^ y; + }, + + 'BigNumber, BigNumber': bigBitXor, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm7(x, y, bitXor); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm3(y, x, bitXor, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm3(x, y, bitXor, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, bitXor); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return bitXor(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return bitXor(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return bitXor(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(x, y, bitXor, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, bitXor, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, bitXor, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, bitXor, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, bitXor, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, bitXor, true).valueOf(); + } + }); + + return bitXor; + } + + exports.name = 'bitXor'; + exports.factory = factory; + + +/***/ }, +/* 87 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigLeftShift = __webpack_require__(48).leftShift; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var equal = load(__webpack_require__(46)); + var zeros = load(__webpack_require__(118)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise left logical shift of a value x by y number of bits, `x << y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.leftShift(x, y) + * + * Examples: + * + * math.leftShift(1, 2); // returns Number 4 + * + * math.leftShift([1, 2, 3], 4); // returns Array [16, 32, 64] + * + * See also: + * + * leftShift, bitNot, bitOr, bitXor, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to be shifted + * @param {Number | BigNumber | Boolean | null} y Amount of shifts + * @return {Number | BigNumber | Array | Matrix} `x` shifted left `y` times + */ + var leftShift = typed('leftShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function leftShift'); + } + + return x << y; + }, + + 'BigNumber, BigNumber': bigLeftShift, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = elementWiseOperations.algorithm8(x, y, leftShift, false); + break; + default: + // sparse & dense + c = elementWiseOperations.algorithm2(y, x, leftShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = elementWiseOperations.algorithm1(x, y, leftShift, false); + break; + default: + // dense & dense + c = elementWiseOperations.algorithm12(x, y, leftShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return leftShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equal(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, leftShift, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, leftShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equal(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, leftShift, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, leftShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return leftShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return leftShift(x, matrix(y)).valueOf(); + } + }); + + return leftShift; + } + + exports.name = 'leftShift'; + exports.factory = factory; + + +/***/ }, +/* 88 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var bigRightArithShift = __webpack_require__(48).rightArithShift; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var equal = load(__webpack_require__(46)); + var zeros = load(__webpack_require__(118)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise right arithmetic shift of a value x by y number of bits, `x >> y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.rightArithShift(x, y) + * + * Examples: + * + * math.rightArithShift(4, 2); // returns Number 1 + * + * math.rightArithShift([16, -32, 64], 4); // returns Array [1, -2, 3] + * + * See also: + * + * bitAnd, bitNot, bitOr, bitXor, rightArithShift, rightLogShift + * + * @param {Number | BigNumber | Boolean | Array | Matrix | null} x Value to be shifted + * @param {Number | BigNumber | Boolean | null} y Amount of shifts + * @return {Number | BigNumber | Array | Matrix} `x` sign-filled shifted right `y` times + */ + var rightArithShift = typed('rightArithShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function rightArithShift'); + } + + return x >> y; + }, + + 'BigNumber, BigNumber': bigRightArithShift, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = elementWiseOperations.algorithm8(x, y, rightArithShift, false); + break; + default: + // sparse & dense + c = elementWiseOperations.algorithm2(y, x, rightArithShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = elementWiseOperations.algorithm1(x, y, rightArithShift, false); + break; + default: + // dense & dense + c = elementWiseOperations.algorithm12(x, y, rightArithShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return rightArithShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equal(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, rightArithShift, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, rightArithShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equal(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, rightArithShift, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, rightArithShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return rightArithShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return rightArithShift(x, matrix(y)).valueOf(); + } + }); + + return rightArithShift; + } + + exports.name = 'rightArithShift'; + exports.factory = factory; + + +/***/ }, +/* 89 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var equal = load(__webpack_require__(46)); + var zeros = load(__webpack_require__(118)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Bitwise right logical shift of value x by y number of bits, `x >>> y`. + * For matrices, the function is evaluated element wise. + * For units, the function is evaluated on the best prefix base. + * + * Syntax: + * + * math.rightLogShift(x, y) + * + * Examples: + * + * math.rightLogShift(4, 2); // returns Number 1 + * + * math.rightLogShift([16, -32, 64], 4); // returns Array [1, 2, 3] + * + * See also: + * + * bitAnd, bitNot, bitOr, bitXor, leftShift, rightLogShift + * + * @param {Number | Boolean | Array | Matrix | null} x Value to be shifted + * @param {Number | Boolean | null} y Amount of shifts + * @return {Number | Array | Matrix} `x` zero-filled shifted right `y` times + */ + + var rightLogShift = typed('rightLogShift', { + + 'number, number': function (x, y) { + if (!isInteger(x) || !isInteger(y)) { + throw new Error('Integers expected in function rightLogShift'); + } + + return x >>> y; + }, + + // 'BigNumber, BigNumber': ..., // TODO: implement BigNumber support for rightLogShift + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = elementWiseOperations.algorithm8(x, y, rightLogShift, false); + break; + default: + // sparse & dense + c = elementWiseOperations.algorithm2(y, x, rightLogShift, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = elementWiseOperations.algorithm1(x, y, rightLogShift, false); + break; + default: + // dense & dense + c = elementWiseOperations.algorithm12(x, y, rightLogShift); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return rightLogShift(x, matrix(y)); + }, + + 'Matrix, number | BigNumber': function (x, y) { + // check scalar + if (!equal(y, 0)) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, rightLogShift, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, rightLogShift, false); + break; + } + return c; + } + return x.clone(); + }, + + 'number | BigNumber, Matrix': function (x, y) { + // check scalar + if (!equal(x, 0)) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm9(y, x, rightLogShift, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, rightLogShift, true); + break; + } + return c; + } + return zeros(y.size(), y.storage()); + }, + + 'Array, number | BigNumber': function (x, y) { + // use matrix implementation + return rightLogShift(matrix(x), y).valueOf(); + }, + + 'number | BigNumber, Array': function (x, y) { + // use matrix implementation + return rightLogShift(x, matrix(y)).valueOf(); + } + }); + + return rightLogShift; + } + + exports.name = 'rightLogShift'; + exports.factory = factory; + + +/***/ }, +/* 90 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Compute the argument of a complex value. + * For a complex number `a + bi`, the argument is computed as `atan2(b, a)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.arg(x) + * + * Examples: + * + * var a = math.complex(2, 2); + * math.arg(a) / math.pi; // returns Number 0.25 + * + * var b = math.complex('2 + 3i'); + * math.arg(b); // returns Number 0.982793723247329 + * math.atan2(3, 2); // returns Number 0.982793723247329 + * + * See also: + * + * re, im, conj, abs + * + * @param {Number | Complex | Array | Matrix | Boolean | null} x + * A complex number or array with complex numbers + * @return {Number | Array | Matrix} The argument of x + */ + var arg = typed('arg', { + 'number': function (x) { + return Math.atan2(0, x); + }, + + // FIXME: must arg(Complex return a complex or a number? + 'Complex': function (x) { + return Math.atan2(x.im, x.re); + }, + + // TODO: implement BigNumber support for function arg + + 'Array | Matrix': function (x) { + return collection.deepMap(x, arg); + } + }); + + return arg; + } + + exports.name = 'arg'; + exports.factory = factory; + + +/***/ }, +/* 91 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Compute the complex conjugate of a complex value. + * If `x = a+bi`, the complex conjugate of `x` is `a - bi`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.conj(x) + * + * Examples: + * + * math.conj(math.complex('2 + 3i')); // returns Complex 2 - 3i + * math.conj(math.complex('2 - 3i')); // returns Complex 2 + 3i + * math.conj(math.complex('-5.2i')); // returns Complex 5.2i + * + * See also: + * + * re, im, arg, abs + * + * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x + * A complex number or array with complex numbers + * @return {Number | BigNumber | Complex | Array | Matrix} + * The complex conjugate of x + */ + var conj = typed('conj', { + 'number': function (x) { + return x; + }, + + 'BigNumber': function (x) { + return x; + }, + + 'Complex': function (x) { + return new x.constructor(x.re, -x.im); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, conj); + } + }); + + return conj; + } + + exports.name = 'conj'; + exports.factory = factory; + + +/***/ }, +/* 92 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Get the imaginary part of a complex number. + * For a complex number `a + bi`, the function returns `b`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.im(x) + * + * Examples: + * + * var a = math.complex(2, 3); + * math.re(a); // returns Number 2 + * math.im(a); // returns Number 3 + * + * math.re(math.complex('-5.2i')); // returns Number -5.2 + * math.re(math.complex(2.4)); // returns Number 0 + * + * See also: + * + * re, conj, abs, arg + * + * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x + * A complex number or array with complex numbers + * @return {Number | BigNumber | Array | Matrix} The imaginary part of x + */ + var im = typed('im', { + 'number': function (x) { + return 0; + }, + + 'BigNumber': function (x) { + return new x.constructor(0); + }, + + 'Complex': function (x) { + return x.im; + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, im); + } + }); + + return im; + } + + exports.name = 'im'; + exports.factory = factory; + + +/***/ }, +/* 93 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Get the real part of a complex number. + * For a complex number `a + bi`, the function returns `a`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.re(x) + * + * Examples: + * + * var a = math.complex(2, 3); + * math.re(a); // returns Number 2 + * math.im(a); // returns Number 3 + * + * math.re(math.complex('-5.2i')); // returns Number 0 + * math.re(math.complex(2.4)); // returns Number 2.4 + * + * See also: + * + * im, conj, abs, arg + * + * @param {Number | BigNumber | Complex | Array | Matrix | Boolean | null} x + * A complex number or array with complex numbers + * @return {Number | BigNumber | Array | Matrix} The real part of x + */ + var re = typed('re', { + 'number': function (x) { + return x; + }, + + 'BigNumber': function (x) { + return x; + }, + + 'Complex': function (x) { + return x.re; + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, re); + } + }); + + return re; + } + + exports.name = 're'; + exports.factory = factory; + + +/***/ }, +/* 94 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var zeros = load(__webpack_require__(118)); + var not = load(__webpack_require__(95)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Logical `and`. Test whether two values are both defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.and(x, y) + * + * Examples: + * + * math.and(2, 4); // returns true + * + * a = [2, 0, 0]; + * b = [3, 7, 0]; + * c = 0; + * + * math.and(a, b); // returns [true, false, false] + * math.and(a, c); // returns [false, false, false] + * + * See also: + * + * not, or, xor + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check + * @return {Boolean | Array | Matrix} + * Returns true when both inputs are defined with a nonzero/nonempty value. + */ + var and = typed('and', { + + 'number, number': function (x, y) { + return !!(x && y); + }, + + 'Complex, Complex': function (x, y) { + return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0); + }, + + 'BigNumber, BigNumber': function (x, y) { + return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN(); + }, + + 'Unit, Unit': function (x, y) { + return (x.value !== 0 && x.value !== null) && (y.value !== 0 && y.value !== null); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse & sparse + c = elementWiseOperations.algorithm6(x, y, and, false); + break; + default: + // sparse & dense + c = elementWiseOperations.algorithm2(y, x, and, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense & sparse + c = elementWiseOperations.algorithm2(x, y, and, false); + break; + default: + // dense & dense + c = elementWiseOperations.algorithm12(x, y, and); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return and(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return and(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return and(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // check scalar + if (not(y)) { + // return zero matrix + return zeros(x.size(), x.storage()); + } + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(x, y, and, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, and, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // check scalar + if (not(x)) { + // return zero matrix + return zeros(x.size(), x.storage()); + } + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm10(y, x, and, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, and, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return and(matrix(x), y).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return and(x, matrix(y)).valueOf(); + } + }); + + return and; + } + + exports.name = 'and'; + exports.factory = factory; + + +/***/ }, +/* 95 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Logical `not`. Flips boolean value of a given parameter. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.not(x) + * + * Examples: + * + * math.not(2); // returns false + * math.not(0); // returns true + * math.not(true); // returns false + * + * a = [2, -7, 0]; + * math.not(a); // returns [false, false, true] + * + * See also: + * + * and, or, xor + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check + * @return {Boolean | Array | Matrix} + * Returns true when input is a zero or empty value. + */ + var not = typed('not', { + 'number': function (x) { + return !x; + }, + + 'Complex': function (x) { + return x.re === 0 && x.im === 0; + }, + + 'BigNumber': function (x) { + return x.isZero() || x.isNaN(); + }, + + 'Unit': function (x) { + return x.value === null || x.value == 0; + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, not); + } + }); + + return not; + } + + exports.name = 'not'; + exports.factory = factory; + + +/***/ }, +/* 96 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Logical `or`. Test if at least one value is defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.or(x, y) + * + * Examples: + * + * math.or(2, 4); // returns true + * + * a = [2, 5, 0]; + * b = [0, 22, 0]; + * c = 0; + * + * math.or(a, b); // returns [true, true, false] + * math.or(b, c); // returns [false, true, false] + * + * See also: + * + * and, not, xor + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check + * @return {Boolean | Array | Matrix} + * Returns true when one of the inputs is defined with a nonzero/nonempty value. + */ + var or = typed('or', { + + 'number, number': function (x, y) { + return !!(x || y); + }, + + 'Complex, Complex': function (x, y) { + return (x.re !== 0 || x.im !== 0) || (y.re !== 0 || y.im !== 0); + }, + + 'BigNumber, BigNumber': function (x, y) { + return (!x.isZero() && !x.isNaN()) || (!y.isZero() && !y.isNaN()); + }, + + 'Unit, Unit': function (x, y) { + return (x.value !== 0 && x.value !== null) || (y.value !== 0 && y.value !== null); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm5(x, y, or); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm3(y, x, or, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm3(x, y, or, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, or); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return or(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return or(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return or(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(x, y, or, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, or, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, or, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, or, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, or, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, or, true).valueOf(); + } + }); + + return or; + } + + exports.name = 'or'; + exports.factory = factory; + + +/***/ }, +/* 97 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var elementWiseOperations = load(__webpack_require__(193)); + + /** + * Logical `xor`. Test whether one and only one value is defined with a nonzero/nonempty value. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.xor(x, y) + * + * Examples: + * + * math.xor(2, 4); // returns false + * + * a = [2, 0, 0]; + * b = [2, 7, 0]; + * c = 0; + * + * math.xor(a, b); // returns [false, true, false] + * math.xor(a, c); // returns [true, false, false] + * + * See also: + * + * and, not, or + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First value to check + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second value to check + * @return {Boolean | Array | Matrix} + * Returns true when one and only one input is defined with a nonzero/nonempty value. + */ + var xor = typed('xor', { + + 'number, number': function (x, y) { + return !!(!!x ^ !!y); + }, + + 'Complex, Complex': function (x, y) { + return !!((x.re !== 0 || x.im !== 0) ^ (y.re !== 0 || y.im !== 0)); + }, + + 'BigNumber, BigNumber': function (x, y) { + return !!((!x.isZero() && !x.isNaN()) ^ (!y.isZero() && !y.isNaN())); + }, + + 'Unit, Unit': function (x, y) { + return !!((x.value !== 0 && x.value !== null) ^ (y.value !== 0 && y.value !== null)); + }, + + 'Matrix, Matrix': function (x, y) { + // result + var c; + + // process matrix storage + switch (x.storage()) { + case 'sparse': + switch (y.storage()) { + case 'sparse': + // sparse + sparse + c = elementWiseOperations.algorithm7(x, y, xor); + break; + default: + // sparse + dense + c = elementWiseOperations.algorithm3(y, x, xor, true); + break; + } + break; + default: + switch (y.storage()) { + case 'sparse': + // dense + sparse + c = elementWiseOperations.algorithm3(x, y, xor, false); + break; + default: + // dense + dense + c = elementWiseOperations.algorithm12(x, y, xor); + break; + } + break; + } + return c; + }, + + 'Array, Array': function (x, y) { + // use matrix implementation + return xor(matrix(x), matrix(y)).valueOf(); + }, + + 'Array, Matrix': function (x, y) { + // use matrix implementation + return xor(matrix(x), y); + }, + + 'Matrix, Array': function (x, y) { + // use matrix implementation + return xor(x, matrix(y)); + }, + + 'Matrix, any': function (x, y) { + // result + var c; + // check storage format + switch (x.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(x, y, xor, false); + break; + default: + c = elementWiseOperations.algorithm13(x, y, xor, false); + break; + } + return c; + }, + + 'any, Matrix': function (x, y) { + // result + var c; + // check storage format + switch (y.storage()) { + case 'sparse': + c = elementWiseOperations.algorithm11(y, x, xor, true); + break; + default: + c = elementWiseOperations.algorithm13(y, x, xor, true); + break; + } + return c; + }, + + 'Array, any': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(x), y, xor, false).valueOf(); + }, + + 'any, Array': function (x, y) { + // use matrix implementation + return elementWiseOperations.algorithm13(matrix(y), x, xor, true).valueOf(); + } + }); + + return xor; + } + + exports.name = 'xor'; + exports.factory = factory; + + +/***/ }, +/* 98 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var collection = load(__webpack_require__(2)); + var parse = load(__webpack_require__(51)); + + /** + * Parse and compile an expression. + * Returns a an object with a function `eval([scope])` to evaluate the + * compiled expression. + * + * Syntax: + * + * math.compile(expr) // returns one node + * math.compile([expr1, expr2, expr3, ...]) // returns an array with nodes + * + * Examples: + * + * var code = math.compile('sqrt(3^2 + 4^2)'); + * code.eval(); // 5 + * + * var scope = {a: 3, b: 4} + * var code = math.compile('a * b'); // 12 + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 + * + * var nodes = math.compile(['a = 3', 'b = 4', 'a * b']); + * nodes[2].eval(); // 12 + * + * See also: + * + * parse, eval + * + * @param {String | String[] | Array | Matrix} expr + * The expression to be compiled + * @return {{eval: Function} | Array.<{eval: Function}>} code + * An object with the compiled expression + * @throws {Error} + */ + return typed('compile', { + 'string': function (expr) { + return parse(expr).compile(math); + }, + + 'Array | Matrix': function (expr) { + return collection.deepMap(expr, function (entry) { + return parse(entry).compile(math); + }); + } + }); + } + + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.name = 'compile'; + exports.factory = factory; + + +/***/ }, +/* 99 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var collection = load(__webpack_require__(2)); + var parse = load(__webpack_require__(51)); + + /** + * Evaluate an expression. + * + * Syntax: + * + * math.eval(expr) + * math.eval(expr, scope) + * math.eval([expr1, expr2, expr3, ...]) + * math.eval([expr1, expr2, expr3, ...], scope) + * + * Example: + * + * math.eval('(2+3)/4'); // 1.25 + * math.eval('sqrt(3^2 + 4^2)'); // 5 + * math.eval('sqrt(-4)'); // 2i + * math.eval(['a=3', 'b=4', 'a*b']);, // [3, 4, 12] + * + * var scope = {a:3, b:4}; + * math.eval('a * b', scope); // 12 + * + * See also: + * + * parse, compile + * + * @param {String | String[] | Matrix} expr The expression to be evaluated + * @param {Object} [scope] Scope to read/write variables + * @return {*} The result of the expression + * @throws {Error} + */ + return typed('compile', { + 'string': function (expr) { + var scope = {}; + return parse(expr).compile(math).eval(scope); + }, + + 'string, Object': function (expr, scope) { + return parse(expr).compile(math).eval(scope); + }, + + 'Array | Matrix': function (expr) { + var scope = {}; + return collection.deepMap(expr, function (entry) { + return parse(entry).compile(math).eval(scope); + }); + }, + + 'Array | Matrix, Object': function (expr, scope) { + return collection.deepMap(expr, function (entry) { + return parse(entry).compile(math).eval(scope); + }); + } + }); + } + + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.name = 'eval'; + exports.factory = factory; + +/***/ }, +/* 100 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed, math) { + var docs = load(__webpack_require__(185)); + + /** + * Retrieve help on a function or data type. + * Help files are retrieved from the documentation in math.expression.docs. + * + * Syntax: + * + * math.help(search) + * + * Examples: + * + * console.log(math.help('sin').toString()); + * console.log(math.help(math.add).toString()); + * console.log(math.help(math.add).toJSON()); + * + * @param {function | string | Object} search A function or function name + * for which to get help + * @return {Help} A help object + */ + return typed('help', { + 'any': function (search) { + var prop; + var name = search; + + if (typeof search !== 'string') { + for (prop in math) { + // search in functions and constants + if (math.hasOwnProperty(prop) && (search === math[prop])) { + name = prop; + break; + } + } + + /* TODO: implement help for data types + if (!text) { + // search data type + for (prop in math.type) { + if (math.type.hasOwnProperty(prop)) { + if (search === math.type[prop]) { + text = prop; + break; + } + } + } + } + */ + } + + var doc = docs[name]; + if (!doc) { + throw new Error('No documentation found on "' + name + '"'); + } + return new type.Help(doc); + } + }); + } + + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.name = 'help'; + exports.factory = factory; + + +/***/ }, +/* 101 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var parse = load(__webpack_require__(51)); + + /** + * Parse an expression. Returns a node tree, which can be evaluated by + * invoking node.eval(); + * + * Syntax: + * + * parse(expr) + * parse(expr, options) + * parse([expr1, expr2, expr3, ...]) + * parse([expr1, expr2, expr3, ...], options) + * + * Example: + * + * var node = parse('sqrt(3^2 + 4^2)'); + * node.compile(math).eval(); // 5 + * + * var scope = {a:3, b:4} + * var node = parse('a * b'); // 12 + * var code = node.compile(math); + * code.eval(scope); // 12 + * scope.a = 5; + * code.eval(scope); // 20 + * + * var nodes = math.parse(['a = 3', 'b = 4', 'a * b']); + * nodes[2].compile(math).eval(); // 12 + * + * @param {String | String[] | Matrix} expr Expression to be parsed + * @param {{nodes: Object}} [options] Available options: + * - `nodes` a set of custom nodes + * @return {Node | Node[]} node + * @throws {Error} + */ + return typed('parse', { + 'string | Array | Matrix': parse, + 'string | Array | Matrix, Object': parse + }); + } + + exports.name = 'parse'; + exports.factory = factory; + + +/***/ }, +/* 102 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(33).clone; + var isInteger = __webpack_require__(41).isInteger; + var array = __webpack_require__(37); + var IndexError = __webpack_require__(38); + var DimensionError = __webpack_require__(39); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Concatenate two or more matrices. + * + * Syntax: + * + * math.concat(A, B, C, ...) + * math.concat(A, B, C, ..., dim) + * + * Where: + * + * - `dim: number` is a zero-based dimension over which to concatenate the matrices. + * By default the last dimension of the matrices. + * + * Examples: + * + * var A = [[1, 2], [5, 6]]; + * var B = [[3, 4], [7, 8]]; + * + * math.concat(A, B); // returns [[1, 2, 3, 4], [5, 6, 7, 8]] + * math.concat(A, B, 0); // returns [[1, 2], [5, 6], [3, 4], [7, 8]] + * + * See also: + * + * size, squeeze, subset, transpose + * + * @param {... Array | Matrix} args Two or more matrices + * @return {Array | Matrix} Concatenated matrix + */ + return typed('concat', { + // TODO: change signature to '...Array | Matrix, dim?' when supported + '...Array | Matrix | number | BigNumber': function (args) { + var i; + var len = args.length; + var dim = -1; // zero-based dimension + var prevDim; + var asMatrix = false; + var matrices = []; // contains multi dimensional arrays + + for (i = 0; i < len; i++) { + var arg = args[i]; + + // test whether we need to return a Matrix (if not we return an Array) + if (arg instanceof type.Matrix) { + asMatrix = true; + } + + if (typeof arg === 'number' || arg instanceof type.BigNumber) { + if (i !== len - 1) { + throw new Error('Dimension must be specified as last argument'); + } + + // last argument contains the dimension on which to concatenate + prevDim = dim; + dim = arg.valueOf(); // change BigNumber to number + + if (!isInteger(dim)) { + throw new TypeError('Integer number expected for dimension'); + } + + if (dim < 0) { + // TODO: would be more clear when throwing a DimensionError here + throw new IndexError(dim); + } + if (i > 0 && dim > prevDim) { + // TODO: would be more clear when throwing a DimensionError here + throw new IndexError(dim, prevDim + 1); + } + } + else { + // this is a matrix or array + var m = clone(arg).valueOf(); + var size = array.size(m); + matrices[i] = m; + prevDim = dim; + dim = size.length - 1; + + // verify whether each of the matrices has the same number of dimensions + if (i > 0 && dim != prevDim) { + throw new DimensionError(prevDim + 1, dim + 1); + } + } + } + + if (matrices.length == 0) { + throw new SyntaxError('At least one matrix expected'); + } + + var res = matrices.shift(); + while (matrices.length) { + res = _concat(res, matrices.shift(), dim, 0); + } + + return asMatrix ? matrix(res) : res; + } + }); + } + + /** + * Recursively concatenate two matrices. + * The contents of the matrices is not cloned. + * @param {Array} a Multi dimensional array + * @param {Array} b Multi dimensional array + * @param {Number} concatDim The dimension on which to concatenate (zero-based) + * @param {Number} dim The current dim (zero-based) + * @return {Array} c The concatenated matrix + * @private + */ + function _concat(a, b, concatDim, dim) { + if (dim < concatDim) { + // recurse into next dimension + if (a.length != b.length) { + throw new DimensionError(a.length, b.length); + } + + var c = []; + for (var i = 0; i < a.length; i++) { + c[i] = _concat(a[i], b[i], concatDim, dim + 1); + } + return c; + } + else { + // concatenate this dimension + return a.concat(b); + } + } + + exports.name = 'concat'; + exports.factory = factory; + + +/***/ }, +/* 103 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + var subtract = load(__webpack_require__(79)); + var multiply = load(__webpack_require__(71)); + + /** + * Calculate the cross product for two vectors in three dimensional space. + * The cross product of `A = [a1, a2, a3]` and `B =[b1, b2, b3]` is defined + * as: + * + * cross(A, B) = [ + * a2 * b3 - a3 * b2, + * a3 * b1 - a1 * b3, + * a1 * b2 - a2 * b1 + * ] + * + * Syntax: + * + * math.cross(x, y) + * + * Examples: + * + * math.cross([1, 1, 0], [0, 1, 1]); // Returns [1, -1, 1] + * math.cross([3, -3, 1], [4, 9, 2]); // Returns [-15, -2, 39] + * math.cross([2, 3, 4], [5, 6, 7]); // Returns [-3, 6, -3] + * + * See also: + * + * dot, multiply + * + * @param {Array | Matrix} x First vector + * @param {Array | Matrix} y Second vector + * @return {Array | Matrix} Returns the cross product of `x` and `y` + */ + return typed('cross', { + 'Matrix, Matrix': function (x, y) { + return matrix(_cross(x.toArray(), y.toArray())); + }, + + 'Matrix, Array': function (x, y) { + return matrix(_cross(x.toArray(), y)); + }, + + 'Array, Matrix': function (x, y) { + return matrix(_cross(x, y.toArray())); + }, + + 'Array, Array': _cross + }); + + /** + * Calculate the cross product for two arrays + * @param {Array} x First vector + * @param {Array} y Second vector + * @returns {Array} Returns the cross product of x and y + * @private + */ + function _cross(x, y) { + var xSize= size(x); + var ySize = size(y); + + if (xSize.length != 1 || ySize.length != 1 || xSize[0] != 3 || ySize[0] != 3) { + throw new RangeError('Vectors with length 3 expected ' + + '(Size A = [' + xSize.join(', ') + '], B = [' + ySize.join(', ') + '])'); + } + + return [ + subtract(multiply(x[1], y[2]), multiply(x[2], y[1])), + subtract(multiply(x[2], y[0]), multiply(x[0], y[2])), + subtract(multiply(x[0], y[1]), multiply(x[1], y[0])) + ]; + } + } + + exports.name = 'cross'; + exports.factory = factory; + + +/***/ }, +/* 104 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + var object = util.object; + var string = util.string; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var matrix = load(__webpack_require__(40)); + var add = load(__webpack_require__(47)); + var subtract = load(__webpack_require__(79)); + var multiply = load(__webpack_require__(71)); + var unaryMinus = load(__webpack_require__(80)); + + /** + * Calculate the determinant of a matrix. + * + * Syntax: + * + * math.det(x) + * + * Examples: + * + * math.det([[1, 2], [3, 4]]); // returns -2 + * + * var A = [ + * [-2, 2, 3], + * [-1, 1, 3], + * [2, 0, -1] + * ] + * math.det(A); // returns 6 + * + * See also: + * + * inv + * + * @param {Array | Matrix} x A matrix + * @return {Number} The determinant of `x` + */ + return typed('det', { + 'any': function (x) { + return object.clone(x); + }, + + 'Array | Matrix': function det (x) { + var size; + if (x instanceof type.Matrix) { + size = x.size(); + } + else if (x instanceof Array) { + x = matrix(x); + size = x.size(); + } + else { + // a scalar + size = []; + } + + switch (size.length) { + case 0: + // scalar + return object.clone(x); + + case 1: + // vector + if (size[0] == 1) { + return object.clone(x.valueOf()[0]); + } + else { + throw new RangeError('Matrix must be square ' + + '(size: ' + string.format(size) + ')'); + } + + case 2: + // two dimensional array + var rows = size[0]; + var cols = size[1]; + if (rows == cols) { + return _det(x.clone().valueOf(), rows, cols); + } + else { + throw new RangeError('Matrix must be square ' + + '(size: ' + string.format(size) + ')'); + } + + default: + // multi dimensional array + throw new RangeError('Matrix must be two dimensional ' + + '(size: ' + string.format(size) + ')'); + } + } + }); + + /** + * Calculate the determinant of a matrix + * @param {Array[]} matrix A square, two dimensional matrix + * @param {Number} rows Number of rows of the matrix (zero-based) + * @param {Number} cols Number of columns of the matrix (zero-based) + * @returns {Number} det + * @private + */ + function _det (matrix, rows, cols) { + if (rows == 1) { + // this is a 1 x 1 matrix + return object.clone(matrix[0][0]); + } + else if (rows == 2) { + // this is a 2 x 2 matrix + // the determinant of [a11,a12;a21,a22] is det = a11*a22-a21*a12 + return subtract( + multiply(matrix[0][0], matrix[1][1]), + multiply(matrix[1][0], matrix[0][1]) + ); + } + else { + // this is an n x n matrix + var compute_mu = function (matrix) { + var i, j; + + // Compute the matrix with zero lower triangle, same upper triangle, + // and diagonals given by the negated sum of the below diagonal + // elements. + var mu = new Array(matrix.length); + var sum = 0; + for (i = 1; i < matrix.length; i++) { + sum = add(sum, matrix[i][i]); + } + + for (i = 0; i < matrix.length; i++) { + mu[i] = new Array(matrix.length); + mu[i][i] = unaryMinus(sum); + + for (j = 0; j < i; j++) { + mu[i][j] = 0; // TODO: make bignumber 0 in case of bignumber computation + } + + for (j = i + 1; j < matrix.length; j++) { + mu[i][j] = matrix[i][j]; + } + + if (i+1 < matrix.length) { + sum = subtract(sum, matrix[i + 1][i + 1]); + } + } + + return mu; + }; + + var fa = matrix; + for (var i = 0; i < rows - 1; i++) { + fa = multiply(compute_mu(fa), matrix); + } + + if (rows % 2 == 0) { + return unaryMinus(fa[0][0]); + } else { + return fa[0][0]; + } + } + } + } + + exports.name = 'det'; + exports.factory = factory; + + + +/***/ }, +/* 105 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(37); + var clone = __webpack_require__(33).clone; + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + + /** + * Create a diagonal matrix or retrieve the diagonal of a matrix + * + * When `x` is a vector, a matrix with vector `x` on the diagonal will be returned. + * When `x` is a two dimensional matrix, the matrixes `k`th diagonal will be returned as vector. + * When k is positive, the values are placed on the super diagonal. + * When k is negative, the values are placed on the sub diagonal. + * + * Syntax: + * + * math.diag(X) + * math.diag(X, format) + * math.diag(X, k) + * math.diag(X, k, format) + * + * Examples: + * + * // create a diagonal matrix + * math.diag([1, 2, 3]); // returns [[1, 0, 0], [0, 2, 0], [0, 0, 3]] + * math.diag([1, 2, 3], 1); // returns [[0, 1, 0, 0], [0, 0, 2, 0], [0, 0, 0, 3]] + * math.diag([1, 2, 3], -1); // returns [[0, 0, 0], [1, 0, 0], [0, 2, 0], [0, 0, 3]] + * + * // retrieve the diagonal from a matrix + * var a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + * math.diag(a); // returns [1, 5, 9] + * + * See also: + * + * ones, zeros, eye + * + * @param {Matrix | Array} x A two dimensional matrix or a vector + * @param {Number | BigNumber} [k=0] The diagonal where the vector will be filled + * in or retrieved. + * @param {string} [format='dense'] The matrix storage format. + * + * @returns {Matrix | Array} Diagonal matrix from input vector, or diagonal from input matrix. + */ + return typed('diag', { + // FIXME: simplify this huge amount of signatures as soon as typed-function supports optional arguments + + 'Array': function (x) { + return _diag(x, 0, array.size(x), null); + }, + + 'Array, number': function (x, k) { + return _diag(x, k, array.size(x), null); + }, + + 'Array, BigNumber': function (x, k) { + return _diag(x, k.toNumber(), array.size(x), null); + }, + + 'Array, string': function (x, format) { + return _diag(x, 0, array.size(x), format); + }, + + 'Array, number, string': function (x, k, format) { + return _diag(x, k, array.size(x), format); + }, + + 'Array, BigNumber, string': function (x, k, format) { + return _diag(x, k.toNumber(), array.size(x), format); + }, + + 'Matrix': function (x) { + return _diag(x, 0, x.size(), x.storage()); + }, + + 'Matrix, number': function (x, k) { + return _diag(x, k, x.size(), x.storage()); + }, + + 'Matrix, BigNumber': function (x, k) { + return _diag(x, k.toNumber(), x.size(), x.storage()); + }, + + 'Matrix, string': function (x, format) { + return _diag(x, 0, x.size(), format); + }, + + 'Matrix, number, string': function (x, k, format) { + return _diag(x, k, x.size(), format); + }, + + 'Matrix, BigNumber, string': function (x, k, format) { + return _diag(x, k.toNumber(), x.size(), format); + } + }); + + /** + * Creeate diagonal matrix from a vector or vice versa + * @param {Array | Matrix} x + * @param {number} k + * @param {string} format Storage format for matrix. If null, + * an Array is returned + * @returns {Array | Matrix} + * @private + */ + function _diag (x, k, size, format) { + if (!isInteger(k)) { + throw new TypeError ('Second parameter in function diag must be an integer'); + } + + var kSuper = k > 0 ? k : 0; + var kSub = k < 0 ? -k : 0; + + // check dimensions + switch (size.length) { + case 1: + return _createDiagonalMatrix(x, k, format, size[0], kSub, kSuper); + case 2: + return _getDiagonal(x, k, format, size, kSub, kSuper); + } + throw new RangeError('Matrix for function diag must be 2 dimensional'); + } + + function _createDiagonalMatrix(x, k, format, l, kSub, kSuper) { + // matrix size + var ms = [l + kSub, l + kSuper]; + // get matrix constructor + var F = type.Matrix.storage(format || 'dense'); + // create diagonal matrix + var m = F.diagonal(ms, x, k); + // check we need to return a matrix + return format !== null ? m : m.valueOf(); + } + + function _getDiagonal(x, k, format, s, kSub, kSuper) { + // check x is a Matrix + if (x instanceof type.Matrix) { + // get diagonal matrix + var dm = x.diagonal(k); + // check we need to return a matrix + if (format !== null) { + // check we need to change matrix format + if (format !== dm.storage()) + return matrix(dm, format); + return dm; + } + return dm.valueOf(); + } + // vector size + var n = Math.min(s[0] - kSub, s[1] - kSuper); + // diagonal values + var vector = new Array(n); + // loop diagonal + for (var i = 0; i < n; i++) { + vector[i] = clone(x[i + kSub][i + kSuper]); + } + // check we need to return a matrix + return format !== null ? matrix(vector) : vector; + } + } + + exports.name = 'diag'; + exports.factory = factory; + + +/***/ }, +/* 106 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(47)); + var multiply = load(__webpack_require__(71)); + + /** + * Calculate the dot product of two vectors. The dot product of + * `A = [a1, a2, a3, ..., an]` and `B = [b1, b2, b3, ..., bn]` is defined as: + * + * dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn + * + * Syntax: + * + * math.dot(x, y) + * + * Examples: + * + * math.dot([2, 4, 1], [2, 2, 3]); // returns Number 15 + * math.multiply([2, 4, 1], [2, 2, 3]); // returns Number 15 + * + * See also: + * + * multiply, cross + * + * @param {Array | Matrix} x First vector + * @param {Array | Matrix} y Second vector + * @return {Number} Returns the dot product of `x` and `y` + */ + return typed('dot', { + 'Matrix, Matrix': function (x, y) { + return _dot(x.toArray(), y.toArray()); + }, + + 'Matrix, Array': function (x, y) { + return _dot(x.toArray(), y); + }, + + 'Array, Matrix': function (x, y) { + return _dot(x, y.toArray()); + }, + + 'Array, Array': _dot + }); + + /** + * Calculate the dot product for two arrays + * @param {Array} x First vector + * @param {Array} y Second vector + * @returns {Number} Returns the dot product of x and y + * @private + */ + // TODO: double code with math.multiply + function _dot(x, y) { + var xSize= size(x); + var ySize = size(y); + var len = xSize[0]; + + if (xSize.length !== 1 || ySize.length !== 1) throw new RangeError('Vector expected'); // TODO: better error message + if (xSize[0] != ySize[0]) throw new RangeError('Vectors must have equal length (' + xSize[0] + ' != ' + ySize[0] + ')'); + if (len == 0) throw new RangeError('Cannot calculate the dot product of empty vectors'); + + var prod = 0; + for (var i = 0; i < len; i++) { + prod = add(prod, multiply(x[i], y[i])); + } + + return prod; + } + } + + exports.name = 'dot'; + exports.factory = factory; + + +/***/ }, +/* 107 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(37); + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + + /** + * Create a 2-dimensional identity matrix with size m x n or n x n. + * The matrix has ones on the diagonal and zeros elsewhere. + * + * Syntax: + * + * math.eye(n) + * math.eye(n, format) + * math.eye(m, n) + * math.eye(m, n, format) + * math.eye([m, n]) + * math.eye([m, n], format) + * + * Examples: + * + * math.eye(3); // returns [[1, 0, 0], [0, 1, 0], [0, 0, 1]] + * math.eye(3, 2); // returns [[1, 0], [0, 1], [0, 0]] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.eye(math.size(b)); // returns [[1, 0, 0], [0, 1, 0]] + * + * See also: + * + * diag, ones, zeros, size, range + * + * @param {...Number | Matrix | Array} size The size for the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Matrix | Array | Number} A matrix with ones on the diagonal. + */ + return typed('eye', { + '': function () { + return (config.matrix === 'matrix') ? matrix([]) : []; + }, + + 'string': function (format) { + return matrix(format); + }, + + 'number | BigNumber': function (rows) { + return _eye(rows, rows, config.matrix === 'matrix' ? 'default' : undefined); + }, + + 'number | BigNumber, string': function (rows, format) { + return _eye(rows, rows, format); + }, + + 'number | BigNumber, number | BigNumber': function (rows, cols) { + return _eye(rows, cols, config.matrix === 'matrix' ? 'default' : undefined); + }, + + 'number | BigNumber, number | BigNumber, string': function (rows, cols, format) { + return _eye(rows, cols, format); + }, + + 'Array': function (size) { + return _eyeVector(size); + }, + + 'Array, string': function (size, format) { + return _eyeVector(size, format); + }, + + 'Matrix': function (size) { + return _eyeVector(size.valueOf(), size.storage()); + }, + + 'Matrix, string': function (size, format) { + return _eyeVector(size.valueOf(), format); + } + }); + + function _eyeVector (size, format) { + switch (size.length) { + case 0: return format ? matrix(format) : []; + case 1: return _eye(size[0], size[0], format); + case 2: return _eye(size[0], size[1], format); + default: throw new Error('Vector containing two values expected'); + } + } + + /** + * Create an identity matrix + * @param {number | BigNumber} rows + * @param {number | BigNumber} cols + * @param {string} [format] + * @returns {Matrix} + * @private + */ + function _eye (rows, cols, format) { + // BigNumber constructor with the right precision + var Big = rows instanceof type.BigNumber ? rows.constructor : + cols instanceof type.BigNumber ? cols.constructor : null; + + if (rows instanceof type.BigNumber) rows = rows.toNumber(); + if (cols instanceof type.BigNumber) cols = cols.toNumber(); + + if (!isInteger(rows) || rows < 1) { + throw new Error('Parameters in function eye must be positive integers'); + } + if (!isInteger(cols) || cols < 1) { + throw new Error('Parameters in function eye must be positive integers'); + } + + var one = Big ? new type.BigNumber(1) : 1; + var defaultValue = Big ? new Big(0) : 0; + var size = [rows, cols]; + + // check we need to return a matrix + if (format) { + // get matrix storage constructor + var F = type.Matrix.storage(format); + // create diagonal matrix (use optimized implementation for storage format) + return F.diagonal(size, one, 0, defaultValue); + } + + // create and resize array + var res = array.resize([], size, defaultValue); + // fill in ones on the diagonal + var minimum = rows < cols ? rows : cols; + // fill diagonal + for (var d = 0; d < minimum; d++) { + res[d][d] = one; + } + return res; + } + } + + exports.name = 'eye'; + exports.factory = factory; + + +/***/ }, +/* 108 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(33).clone; + var _flatten = __webpack_require__(37).flatten; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Flatten a multi dimensional matrix into a single dimensional matrix. + * + * Syntax: + * + * math.flatten(x) + * + * Examples: + * + * math.flatten([[1,2], [3,4]]); // returns [1, 2, 3, 4] + * + * See also: + * + * concat, resize, size, squeeze + * + * @param {Matrix | Array} x Matrix to be flattened + * @return {Matrix | Array} Returns the flattened matrix + */ + return typed('flatten', { + 'Array': function (x) { + return _flatten(clone(x)); + }, + + 'Matrix': function (x) { + var flat = _flatten(clone(x.toArray())); + // TODO: return the same matrix type as x + return matrix(flat); + } + }); + } + + exports.name = 'flatten'; + exports.factory = factory; + + +/***/ }, +/* 109 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var matrix = load(__webpack_require__(40)); + var divideScalar = load(__webpack_require__(207)); + var add = load(__webpack_require__(47)); + var multiply = load(__webpack_require__(71)); + var unaryMinus = load(__webpack_require__(80)); + var det = load(__webpack_require__(104)); + var eye = load(__webpack_require__(107)); + + /** + * Calculate the inverse of a square matrix. + * + * Syntax: + * + * math.inv(x) + * + * Examples: + * + * math.inv([[1, 2], [3, 4]]); // returns [[-2, 1], [1.5, -0.5]] + * math.inv(4); // returns 0.25 + * 1 / 4; // returns 0.25 + * + * See also: + * + * det, transpose + * + * @param {Number | Complex | Array | Matrix} x Matrix to be inversed + * @return {Number | Complex | Array | Matrix} The inverse of `x`. + */ + var inv = typed('inv', { + 'Array | Matrix': function (x) { + var size = x instanceof type.Matrix ? x.size() : util.array.size(x); + switch (size.length) { + case 1: + // vector + if (size[0] == 1) { + if (x instanceof type.Matrix) { + return matrix([ + divideScalar(1, x.valueOf()[0]) + ]); + } + else { + return [ + divideScalar(1, x[0]) + ]; + } + } + else { + throw new RangeError('Matrix must be square ' + + '(size: ' + util.string.format(size) + ')'); + } + + case 2: + // two dimensional array + var rows = size[0]; + var cols = size[1]; + if (rows == cols) { + if (x instanceof type.Matrix) { + return matrix( + _inv(x.valueOf(), rows, cols), + x.storage() + ); + } + else { + // return an Array + return _inv(x, rows, cols); + } + } + else { + throw new RangeError('Matrix must be square ' + + '(size: ' + util.string.format(size) + ')'); + } + + default: + // multi dimensional array + throw new RangeError('Matrix must be two dimensional ' + + '(size: ' + util.string.format(size) + ')'); + } + }, + + 'any': function (x) { + // scalar + return divideScalar(1, x); // FIXME: create a BigNumber one when configured for bignumbers + } + }); + + /** + * Calculate the inverse of a square matrix + * @param {Array[]} mat A square matrix + * @param {Number} rows Number of rows + * @param {Number} cols Number of columns, must equal rows + * @return {Array[]} inv Inverse matrix + * @private + */ + function _inv (mat, rows, cols){ + var r, s, f, value, temp; + + if (rows == 1) { + // this is a 1 x 1 matrix + value = mat[0][0]; + if (value == 0) { + throw Error('Cannot calculate inverse, determinant is zero'); + } + return [[ + divideScalar(1, value) + ]]; + } + else if (rows == 2) { + // this is a 2 x 2 matrix + var d = det(mat); + if (d == 0) { + throw Error('Cannot calculate inverse, determinant is zero'); + } + return [ + [ + divideScalar(mat[1][1], d), + divideScalar(unaryMinus(mat[0][1]), d) + ], + [ + divideScalar(unaryMinus(mat[1][0]), d), + divideScalar(mat[0][0], d) + ] + ]; + } + else { + // this is a matrix of 3 x 3 or larger + // calculate inverse using gauss-jordan elimination + // http://en.wikipedia.org/wiki/Gaussian_elimination + // http://mathworld.wolfram.com/MatrixInverse.html + // http://math.uww.edu/~mcfarlat/inverse.htm + + // make a copy of the matrix (only the arrays, not of the elements) + var A = mat.concat(); + for (r = 0; r < rows; r++) { + A[r] = A[r].concat(); + } + + // create an identity matrix which in the end will contain the + // matrix inverse + var B = eye(rows).valueOf(); + + // loop over all columns, and perform row reductions + for (var c = 0; c < cols; c++) { + // element Acc should be non zero. if not, swap content + // with one of the lower rows + r = c; + while (r < rows && A[r][c] == 0) { + r++; + } + if (r == rows || A[r][c] == 0) { + // TODO: in case of zero det, just return a matrix wih Infinity values? (like octave) + throw Error('Cannot calculate inverse, determinant is zero'); + } + if (r != c) { + temp = A[c]; A[c] = A[r]; A[r] = temp; + temp = B[c]; B[c] = B[r]; B[r] = temp; + } + + // eliminate non-zero values on the other rows at column c + var Ac = A[c], + Bc = B[c]; + for (r = 0; r < rows; r++) { + var Ar = A[r], + Br = B[r]; + if(r != c) { + // eliminate value at column c and row r + if (Ar[c] != 0) { + f = divideScalar(unaryMinus(Ar[c]), Ac[c]); + + // add (f * row c) to row r to eliminate the value + // at column c + for (s = c; s < cols; s++) { + Ar[s] = add(Ar[s], multiply(f, Ac[s])); + } + for (s = 0; s < cols; s++) { + Br[s] = add(Br[s], multiply(f, Bc[s])); + } + } + } + else { + // normalize value at Acc to 1, + // divide each value on row r with the value at Acc + f = Ac[c]; + for (s = c; s < cols; s++) { + Ar[s] = divideScalar(Ar[s], f); + } + for (s = 0; s < cols; s++) { + Br[s] = divideScalar(Br[s], f); + } + } + } + } + return B; + } + } + + return inv; + } + + exports.name = 'inv'; + exports.factory = factory; + + +/***/ }, +/* 110 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var resize = __webpack_require__(37).resize; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Create a matrix filled with ones. The created matrix can have one or + * multiple dimensions. + * + * Syntax: + * + * math.ones(m) + * math.ones(m, format) + * math.ones(m, n) + * math.ones(m, n, format) + * math.ones([m, n]) + * math.ones([m, n], format) + * math.ones([m, n, p, ...]) + * math.ones([m, n, p, ...], format) + * + * Examples: + * + * math.ones(3); // returns [1, 1, 1] + * math.ones(3, 2); // returns [[1, 1], [1, 1], [1, 1]] + * math.ones(3, 2, 'dense'); // returns Dense Matrix [[1, 1], [1, 1], [1, 1]] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.ones(math.size(A)); // returns [[1, 1, 1], [1, 1, 1]] + * + * See also: + * + * zeros, eye, size, range + * + * @param {...Number | Array} size The size of each dimension of the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Array | Matrix | Number} A matrix filled with ones + */ + return typed('ones', { + '': function () { + return (config.matrix === 'array') + ? _ones([]) + : _ones([], 'default'); + }, + + // math.ones(m, n, p, ..., format) + // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this + '...number | BigNumber | string': function (size) { + var last = size[size.length - 1]; + if (typeof last === 'string') { + var format = size.pop(); + return _ones(size, format); + } + else if (config.matrix === 'array') { + return _ones(size); + } + else { + return _ones(size, 'default'); + } + }, + + 'Array': _ones, + + 'Matrix': function (size) { + var format = size.storage(); + return _ones(size.valueOf(), format); + }, + + 'Array | Matrix, string': function (size, format) { + return _ones (size.valueOf(), format); + } + }); + + /** + * Create an Array or Matrix with ones + * @param {Array} size + * @param {string} [format='default'] + * @return {Array | Matrix} + * @private + */ + function _ones(size, format) { + var hasBigNumbers = _normalize(size); + var defaultValue = hasBigNumbers ? new type.BigNumber(1) : 1; + _validate(size); + + if (format) { + // return a matrix + var m = matrix(format); + if (size.length > 0) { + return m.resize(size, defaultValue); + } + return m; + } + else { + // return an Array + var arr = []; + if (size.length > 0) { + return resize(arr, size, defaultValue); + } + return arr; + } + } + + // replace BigNumbers with numbers, returns true if size contained BigNumbers + function _normalize(size) { + var hasBigNumbers = false; + size.forEach(function (value, index, arr) { + if (value instanceof type.BigNumber) { + hasBigNumbers = true; + arr[index] = value.toNumber(); + } + }); + return hasBigNumbers; + } + + // validate arguments + function _validate (size) { + size.forEach(function (value) { + if (typeof value !== 'number' || !isInteger(value) || value < 0) { + throw new Error('Parameters in function ones must be positive integers'); + } + }); + } + } + + exports.name = 'ones'; + exports.factory = factory; + + +/***/ }, +/* 111 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + var ZERO = new type.BigNumber(0); + var ONE = new type.BigNumber(1); + + /** + * Create an array from a range. + * By default, the range end is excluded. This can be customized by providing + * an extra parameter `includeEnd`. + * + * Syntax: + * + * math.range(str [, includeEnd]) // Create a range from a string, + * // where the string contains the + * // start, optional step, and end, + * // separated by a colon. + * math.range(start, end [, includeEnd]) // Create a range with start and + * // end and a step size of 1. + * math.range(start, end, step [, includeEnd]) // Create a range with start, step, + * // and end. + * + * Where: + * + * - `str: String` + * A string 'start:end' or 'start:step:end' + * - `start: {Number | BigNumber}` + * Start of the range + * - `end: Number | BigNumber` + * End of the range, excluded by default, included when parameter includeEnd=true + * - `step: Number | BigNumber` + * Step size. Default value is 1. + * - `includeEnd: boolean` + * Option to specify whether to include the end or not. False by default. + * + * Examples: + * + * math.range(2, 6); // [2, 3, 4, 5] + * math.range(2, -3, -1); // [2, 1, 0, -1, -2] + * math.range('2:1:6'); // [2, 3, 4, 5] + * math.range(2, 6, true); // [2, 3, 4, 5, 6] + * + * See also: + * + * ones, zeros, size, subset + * + * @param {*} args Parameters describing the ranges `start`, `end`, and optional `step`. + * @return {Array | Matrix} range + */ + return typed('range', { + // TODO: simplify signatures when typed-function supports default values and optional arguments + + // TODO: a number or boolean should not be converted to string here + 'string': _strRange, + 'string, boolean': _strRange, + + 'number, number': function (start, end) { + return _out(_rangeEx(start, end, 1)); + }, + 'number, number, number': function (start, end, step) { + return _out(_rangeEx(start, end, step)); + }, + 'number, number, boolean': function (start, end, includeEnd) { + return includeEnd + ? _out(_rangeInc(start, end, 1)) + : _out(_rangeEx(start, end, 1)); + }, + 'number, number, number, boolean': function (start, end, step, includeEnd) { + return includeEnd + ? _out(_rangeInc(start, end, step)) + : _out(_rangeEx(start, end, step)); + }, + + 'BigNumber, BigNumber': function (start, end) { + return _out(_bigRangeEx(start, end, ONE)); + }, + 'BigNumber, BigNumber, BigNumber': function (start, end, step) { + return _out(_bigRangeEx(start, end, step)); + }, + 'BigNumber, BigNumber, boolean': function (start, end, includeEnd) { + return includeEnd + ? _out(_bigRangeInc(start, end, ONE)) + : _out(_bigRangeEx(start, end, ONE)); + }, + 'BigNumber, BigNumber, BigNumber, boolean': function (start, end, step, includeEnd) { + return includeEnd + ? _out(_bigRangeInc(start, end, step)) + : _out(_bigRangeEx(start, end, step)); + } + + }); + + function _out(arr) { + return config.matrix === 'array' ? arr : matrix(arr); + } + + function _strRange (str, includeEnd) { + var r = _parse(str); + if (!r){ + throw new SyntaxError('String "' + str + '" is no valid range'); + } + + var fn; + if (config.number === 'bignumber') { + fn = includeEnd ? _bigRangeInc : _bigRangeEx; + return _out(fn( + new type.BigNumber(r.start), + new type.BigNumber(r.end), + new type.BigNumber(r.step))); + } + else { + fn = includeEnd ? _rangeInc : _rangeEx; + return _out(fn(r.start, r.end, r.step)); + } + } + + /** + * Create a range with numbers. End is excluded + * @param {Number} start + * @param {Number} end + * @param {Number} step + * @returns {Array} range + * @private + */ + function _rangeEx (start, end, step) { + var array = [], + x = start; + if (step > 0) { + while (x < end) { + array.push(x); + x += step; + } + } + else if (step < 0) { + while (x > end) { + array.push(x); + x += step; + } + } + + return array; + } + + /** + * Create a range with numbers. End is included + * @param {Number} start + * @param {Number} end + * @param {Number} step + * @returns {Array} range + * @private + */ + function _rangeInc (start, end, step) { + var array = [], + x = start; + if (step > 0) { + while (x <= end) { + array.push(x); + x += step; + } + } + else if (step < 0) { + while (x >= end) { + array.push(x); + x += step; + } + } + + return array; + } + + /** + * Create a range with big numbers. End is excluded + * @param {BigNumber} start + * @param {BigNumber} end + * @param {BigNumber} step + * @returns {Array} range + * @private + */ + function _bigRangeEx (start, end, step) { + var array = [], + x = start; + 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; + } + + /** + * Create a range with big numbers. End is included + * @param {BigNumber} start + * @param {BigNumber} end + * @param {BigNumber} step + * @returns {Array} range + * @private + */ + function _bigRangeInc (start, end, step) { + var array = [], + x = start; + if (step.gt(ZERO)) { + while (x.lte(end)) { + array.push(x); + x = x.plus(step); + } + } + else if (step.lt(ZERO)) { + while (x.gte(end)) { + array.push(x); + x = x.plus(step); + } + } + + return array; + } + + /** + * Parse a string into a range, + * The string contains the start, optional step, and end, separated by a colon. + * If the string does not contain a valid range, null is returned. + * For example str='0:2:11'. + * @param {String} str + * @return {{start: number, end: number, step: number} | null} range Object containing properties start, end, step + * @private + */ + function _parse (str) { + var args = str.split(':'); + + // number + var nums = args.map(function (arg) { + // use Number and not parseFloat as Number returns NaN on invalid garbage in the string + return Number(arg); + }); + + var invalid = nums.some(function (num) { + return isNaN(num); + }); + if(invalid) { + return null; + } + + switch (nums.length) { + case 2: + return { + start: nums[0], + end: nums[1], + step: 1 + }; + + case 3: + return { + start: nums[0], + end: nums[2], + step: nums[1] + }; + + default: + return null; + } + } + + } + + exports.name = 'range'; + exports.factory = factory; + + +/***/ }, +/* 112 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DimensionError = __webpack_require__(39); + var ArgumentsError = __webpack_require__(194); + + var isInteger = __webpack_require__(41).isInteger; + var format = __webpack_require__(42).format; + var clone = __webpack_require__(33).clone; + var array = __webpack_require__(37); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Resize a matrix + * + * Syntax: + * + * math.resize(x, size) + * math.resize(x, size, defaultValue) + * + * Examples: + * + * math.resize([1, 2, 3, 4, 5], [3]); // returns Array [1, 2, 3] + * math.resize([1, 2, 3], [5], 0); // returns Array [1, 2, 3, 0, 0] + * math.resize(2, [2, 3], 0); // returns Matrix [[2, 0, 0], [0, 0, 0]] + * math.resize("hello", [8], "!"); // returns String 'hello!!!' + * + * See also: + * + * size, squeeze, subset + * + * @param {Array | Matrix | *} x Matrix to be resized + * @param {Array | Matrix} size One dimensional array with numbers + * @param {Number | String} [defaultValue=0] Zero by default, except in + * case of a string, in that case + * defaultValue = ' ' + * @return {* | Array | Matrix} A resized clone of matrix `x` + */ + // TODO: rework resize to a typed-function + return function resize (x, size, defaultValue) { + if (arguments.length != 2 && arguments.length != 3) { + throw new ArgumentsError('resize', arguments.length, 2, 3); + } + + if (size instanceof type.Matrix) { + size = size.valueOf(); // get Array + } + + if (size.length && size[0] instanceof type.BigNumber) { + // convert bignumbers to numbers + size = size.map(function (value) { + return (value instanceof type.BigNumber) ? value.toNumber() : value; + }); + } + + // check x is a Matrix + if (x instanceof type.Matrix) { + // use optimized matrix implementation, return copy + return x.resize(size, defaultValue, true); + } + + if (typeof x === 'string') { + // resize string + return _resizeString(x, size, defaultValue); + } + + // check result should be a matrix + var asMatrix = Array.isArray(x) ? false : (config.matrix !== 'array'); + + if (size.length == 0) { + // output a scalar + while (Array.isArray(x)) { + x = x[0]; + } + + return clone(x); + } + else { + // output an array/matrix + if (!Array.isArray(x)) { + x = [x]; + } + x = clone(x); + + var res = array.resize(x, size, defaultValue); + return asMatrix ? matrix(res) : res; + } + }; + + /** + * Resize a string + * @param {String} str + * @param {Number[]} size + * @param {string} [defaultChar=' '] + * @private + */ + function _resizeString(str, size, defaultChar) { + if (defaultChar !== undefined) { + if (typeof defaultChar !== 'string' || defaultChar.length !== 1) { + throw new TypeError('Single character expected as defaultValue'); + } + } + else { + defaultChar = ' '; + } + + if (size.length !== 1) { + throw new DimensionError(size.length, 1); + } + var len = size[0]; + if (typeof len !== 'number' || !isInteger(len)) { + throw new TypeError('Invalid size, must contain positive integers ' + + '(size: ' + format(size) + ')'); + } + + if (str.length > len) { + return str.substring(0, len); + } + else if (str.length < len) { + var res = str; + for (var i = 0, ii = len - str.length; i < ii; i++) { + res += defaultChar; + } + return res; + } + else { + return str; + } + } + } + + exports.name = 'resize'; + exports.factory = factory; + + +/***/ }, +/* 113 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var array = __webpack_require__(37); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Calculate the size of a matrix or scalar. + * + * Syntax: + * + * math.size(x) + * + * Examples: + * + * math.size(2.3); // returns [] + * math.size('hello world'); // returns [11] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.size(A); // returns [2, 3] + * math.size(math.range(1,6)); // returns [5] + * + * See also: + * + * resize, squeeze, subset + * + * @param {Boolean | Number | Complex | Unit | String | Array | Matrix} x A matrix + * @return {Array | Matrix} A vector with size of `x`. + */ + return typed('size', { + 'Matrix': function (x) { + // TODO: return the same matrix type as the input + return matrix(x.size()); + }, + + 'Array': array.size, + + 'string': function (x) { + return (config.matrix === 'array') ? [x.length] : matrix([x.length]); + }, + + 'number | Complex | BigNumber | Unit | boolean | null': function (x) { + // scalar + return (config.matrix === 'array') ? [] : matrix([]); + } + }); + } + + exports.name = 'size'; + exports.factory = factory; + + +/***/ }, +/* 114 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(33); + var array = __webpack_require__(37); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Squeeze a matrix, remove inner and outer singleton dimensions from a matrix. + * + * Syntax: + * + * math.squeeze(x) + * + * Examples: + * + * math.squeeze([3]); // returns 3 + * math.squeeze([[3]]); // returns 3 + * + * var A = math.zeros(3, 1); // returns [[0], [0], [0]] (size 3x1) + * math.squeeze(A); // returns [0, 0, 0] (size 3) + * + * var B = math.zeros(1, 3); // returns [[0, 0, 0]] (size 1x3) + * math.squeeze(B); // returns [0, 0, 0] (size 3) + * + * // only inner and outer dimensions are removed + * var C = math.zeros(2, 1, 3); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) + * math.squeeze(C); // returns [[[0, 0, 0]], [[0, 0, 0]]] (size 2x1x3) + * + * See also: + * + * subset + * + * @param {Matrix | Array} x Matrix to be squeezed + * @return {Matrix | Array} Squeezed matrix + */ + return typed('squeeze', { + 'Array': function (x) { + return array.squeeze(object.clone(x)); + }, + + 'Matrix': function (x) { + var res = array.squeeze(x.toArray()); + // FIXME: return the same type of matrix as the input + return Array.isArray(res) ? matrix(res) : res; + }, + + 'any': function (x) { + // scalar + return object.clone(x); + } + }); + } + + exports.name = 'squeeze'; + exports.factory = factory; + + +/***/ }, +/* 115 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(33).clone; + var validateIndex = __webpack_require__(37).validateIndex; + var DimensionError = __webpack_require__(39); + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Get or set a subset of a matrix or string. + * + * Syntax: + * math.subset(value, index) // retrieve a subset + * math.subset(value, index, replacement [, defaultValue]) // replace a subset + * + * Examples: + * + * // get a subset + * var d = [[1, 2], [3, 4]]; + * math.subset(d, math.index(1, 0)); // returns 3 + * math.subset(d, math.index([0, 2], 1)); // returns [[2], [4]] + * + * // replace a subset + * var e = []; + * var f = math.subset(e, math.index(0, [0, 2]), [5, 6]); // f = [[5, 6]] + * var g = math.subset(f, math.index(1, 1), 7, 0); // g = [[5, 6], [0, 7]] + * + * See also: + * + * size, resize, squeeze, index + * + * @param {Array | Matrix | String} matrix An array, matrix, or string + * @param {Index} index An index containing ranges for each + * dimension + * @param {*} [replacement] An array, matrix, or scalar. + * If provided, the subset is replaced with replacement. + * If not provided, the subset is returned + * @param {*} [defaultValue=undefined] Default value, filled in on new entries when + * the matrix is resized. If not provided, + * math.matrix elements will be left undefined. + * @return {Array | Matrix | String} Either the retrieved subset or the updated matrix. + */ + return typed('subset', { + // get subset + 'Array, Index': function (value, index) { + var m = matrix(value); + var subset = m.subset(index); // returns a Matrix + return subset && subset.valueOf(); // return an Array (like the input) + }, + + 'Matrix, Index': function (value, index) { + return value.subset(index); + }, + + 'string, Index': _getSubstring, + + // set subset + 'Array, Index, any': function (value, index, replacement) { + return matrix(clone(value)) + .subset(index, replacement, undefined) + .valueOf(); + }, + + 'Array, Index, any, any': function (value, index, replacement, defaultValue) { + return matrix(clone(value)) + .subset(index, replacement, defaultValue) + .valueOf(); + }, + + 'Matrix, Index, any': function (value, index, replacement) { + return value.clone().subset(index, replacement); + }, + + 'Matrix, Index, any, any': function (value, index, replacement, defaultValue) { + return value.clone().subset(index, replacement, defaultValue); + }, + + 'string, Index, string': _setSubstring, + 'string, Index, string, string': _setSubstring + }); + + /** + * Retrieve a subset of a string + * @param {String} str String from which to get a substring + * @param {Index} index An index containing ranges for each dimension + * @returns {string} substring + * @private + */ + function _getSubstring(str, index) { + if (!(index instanceof type.Index)) { + // TODO: better error message + throw new TypeError('Index expected'); + } + if (index.size().length != 1) { + throw new DimensionError(index.size().length, 1); + } + + // validate whether the range is out of range + var strLen = str.length; + validateIndex(index.min()[0], strLen); + validateIndex(index.max()[0], strLen); + + var range = index.range(0); + + var substr = ''; + range.forEach(function (v) { + substr += str.charAt(v); + }); + + return substr; + } + + /** + * Replace a substring in a string + * @param {String} str String to be replaced + * @param {Index} index An index containing ranges for each dimension + * @param {String} replacement Replacement string + * @param {String} [defaultValue] Default value to be uses when resizing + * the string. is ' ' by default + * @returns {string} result + * @private + */ + function _setSubstring(str, index, replacement, defaultValue) { + if (!(index instanceof type.Index)) { + // TODO: better error message + throw new TypeError('Index expected'); + } + if (index.size().length != 1) { + throw new DimensionError(index.size().length, 1); + } + if (defaultValue !== undefined) { + if (typeof defaultValue !== 'string' || defaultValue.length !== 1) { + throw new TypeError('Single character expected as defaultValue'); + } + } + else { + defaultValue = ' '; + } + + var range = index.range(0); + var len = range.size()[0]; + + if (len != replacement.length) { + throw new DimensionError(range.size()[0], replacement.length); + } + + // validate whether the range is out of range + var strLen = str.length; + validateIndex(index.min()[0]); + validateIndex(index.max()[0]); + + // copy the string into an array with characters + var chars = []; + for (var i = 0; i < strLen; i++) { + chars[i] = str.charAt(i); + } + + range.forEach(function (v, i) { + chars[v] = replacement.charAt(i); + }); + + // initialize undefined characters with a space + if (chars.length > strLen) { + for (i = strLen - 1, len = chars.length; i < len; i++) { + if (!chars[i]) { + chars[i] = defaultValue; + } + } + } + + return chars.join(''); + } + } + + exports.name = 'subset'; + exports.factory = factory; + + +/***/ }, +/* 116 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(33).clone; + var format = __webpack_require__(42).format; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var add = load(__webpack_require__(47)); + + /** + * Calculate the trace of a matrix: the sum of the elements on the main + * diagonal of a square matrix. + * + * Syntax: + * + * math.trace(x) + * + * Examples: + * + * math.trace([[1, 2], [3, 4]]); // returns 5 + * + * var A = [ + * [1, 2, 3], + * [-1, 2, 3], + * [2, 0, 3] + * ] + * math.trace(A); // returns 6 + * + * See also: + * + * diag + * + * @param {Array | Matrix} x A matrix + * + * @return {Number} The trace of `x` + */ + var trace = typed('trace', { + + 'Array': function (x) { + // use dense matrix implementation + return trace(matrix(x)); + }, + + 'Matrix': function (x) { + // result + var c; + // process storage format + switch (x.storage()) { + case 'dense': + c = _denseTrace(x); + break; + case 'sparse': + c = _sparseTrace(x); + break; + } + return c; + }, + + 'any': clone + }); + + var _denseTrace = function (m) { + // matrix size & data + var size = m._size; + var data = m._data; + + // process dimensions + switch (size.length) { + case 1: + // vector + if (size[0] == 1) { + // return data[0] + return clone(data[0]); + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + case 2: + // two dimensional + var rows = size[0]; + var cols = size[1]; + if (rows === cols) { + // calulate sum + var sum = 0; + // loop diagonal + for (var i = 0; i < rows; i++) + sum = add(sum, data[i][i]); + // return trace + return sum; + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + default: + // multi dimensional + throw new RangeError('Matrix must be two dimensional (size: ' + format(size) + ')'); + } + }; + + var _sparseTrace = function (m) { + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + var size = m._size; + // check dimensions + var rows = size[0]; + var columns = size[1]; + // matrix must be square + if (rows === columns) { + // calulate sum + var sum = 0; + // check we have data (avoid looping columns) + if (values.length > 0) { + // loop columns + for (var j = 0; j < columns; j++) { + // k0 <= k < k1 where k0 = _ptr[j] && k1 = _ptr[j+1] + var k0 = ptr[j]; + var k1 = ptr[j + 1]; + // loop k within [k0, k1[ + for (var k = k0; k < k1; k++) { + // row index + var i = index[k]; + // check row + if (i === j) { + // accumulate value + sum = add(sum, values[k]); + // exit loop + break; + } + if (i > j) { + // exit loop, no value on the diagonal for column j + break; + } + } + } + } + // return trace + return sum; + } + throw new RangeError('Matrix must be square (size: ' + format(size) + ')'); + }; + + return trace; + } + + exports.name = 'trace'; + exports.factory = factory; + + +/***/ }, +/* 117 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var clone = __webpack_require__(33).clone; + var format = __webpack_require__(42).format; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + + var DenseMatrix = type.DenseMatrix, + SparseMatrix = type.SparseMatrix; + + /** + * Transpose a matrix. All values of the matrix are reflected over its + * main diagonal. Only two dimensional matrices are supported. + * + * Syntax: + * + * math.transpose(x) + * + * Examples: + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.transpose(A); // returns [[1, 4], [2, 5], [3, 6]] + * + * See also: + * + * diag, inv, subset, squeeze + * + * @param {Array | Matrix} x Matrix to be transposed + * @return {Array | Matrix} The transposed matrix + */ + var transpose = typed('transpose', { + + 'Array': function (x) { + // use dense matrix implementation + return transpose(matrix(x)).valueOf(); + }, + + 'Matrix': function (x) { + // matrix size + var size = x.size(); + + // result + var c; + + // process dimensions + switch (size.length) { + case 1: + // vector + c = x.clone(); + break; + + case 2: + // rows and columns + var rows = size[0]; + var columns = size[1]; + + // check columns + if (columns === 0) { + // throw exception + throw new RangeError('Cannot transpose a 2D matrix with no columns (size: ' + format(size) + ')'); + } + + // process storage format + switch (x.storage()) { + case 'dense': + c = _denseTranspose(x, rows, columns); + break; + case 'sparse': + c = _sparseTranspose(x, rows, columns); + break; + } + break; + + default: + // multi dimensional + throw new RangeError('Matrix must be a vector or two dimensional (size: ' + format(this._size) + ')'); + } + return c; + }, + + // scalars + 'any': function (x) { + return clone(x); + } + }); + + var _denseTranspose = function (m, rows, columns) { + // matrix array + var data = m._data; + // transposed matrix data + var transposed = []; + var transposedRow; + // loop columns + for (var j = 0; j < columns; j++) { + // initialize row + transposedRow = transposed[j] = []; + // loop rows + for (var i = 0; i < rows; i++) { + // set data + transposedRow[i] = clone(data[i][j]); + } + } + // return matrix + return new DenseMatrix({ + data: transposed, + size: [columns, rows], + datatype: m._datatype + }); + }; + + var _sparseTranspose = function (m, rows, columns) { + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // result matrices + var cvalues = []; + var cindex = []; + var cptr = []; + // row counts + var w = new Array(rows); + for (var x = 0; x < rows; x++) + w[x] = 0; + // vars + var p, l, j; + // loop values in matrix + for (p = 0, l = index.length; p < l; p++) { + // number of values in row + w[index[p]]++; + } + // cumulative sum + var sum = 0; + // initialize cptr with the cummulative sum of row counts + for (var i = 0; i < rows; i++) { + // update cptr + cptr.push(sum); + // update sum + sum += w[i]; + // update w + w[i] = cptr[i]; + } + // update cptr + cptr.push(sum); + // loop columns + for (j = 0; j < columns; j++) { + // values & index in column + for (var k0 = ptr[j], k1 = ptr[j + 1], k = k0; k < k1; k++) { + // C values & index + var q = w[index[k]]++; + // C[j, i] = A[i, j] + cindex[q] = j; + cvalues[q] = clone(values[k]); + } + } + // return matrix + return new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [columns, rows], + datatype: m._datatype + }); + }; + + return transpose; + } + + exports.name = 'transpose'; + exports.factory = factory; + + +/***/ }, +/* 118 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + var resize = __webpack_require__(37).resize; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Create a matrix filled with zeros. The created matrix can have one or + * multiple dimensions. + * + * Syntax: + * + * math.zeros(m) + * math.zeros(m, format) + * math.zeros(m, n) + * math.zeros(m, n, format) + * math.zeros([m, n]) + * math.zeros([m, n], format) + * + * Examples: + * + * math.zeros(3); // returns [0, 0, 0] + * math.zeros(3, 2); // returns [[0, 0], [0, 0], [0, 0]] + * math.zeros(3, 'dense'); // returns [0, 0, 0] + * + * var A = [[1, 2, 3], [4, 5, 6]]; + * math.zeros(math.size(A)); // returns [[0, 0, 0], [0, 0, 0]] + * + * See also: + * + * ones, eye, size, range + * + * @param {...Number | Array} size The size of each dimension of the matrix + * @param {string} [format] The Matrix storage format + * + * @return {Array | Matrix} A matrix filled with zeros + */ + return typed('zeros', { + '': function () { + return (config.matrix === 'array') + ? _zeros([]) + : _zeros([], 'default'); + }, + + // math.zeros(m, n, p, ..., format) + // TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this + '...number | BigNumber | string': function (size) { + var last = size[size.length - 1]; + if (typeof last === 'string') { + var format = size.pop(); + return _zeros(size, format); + } + else if (config.matrix === 'array') { + return _zeros(size); + } + else { + return _zeros(size, 'default'); + } + }, + + 'Array': _zeros, + + 'Matrix': function (size) { + var format = size.storage(); + return _zeros(size.valueOf(), format); + }, + + 'Array | Matrix, string': function (size, format) { + return _zeros (size.valueOf(), format); + } + }); + + /** + * Create an Array or Matrix with zeros + * @param {Array} size + * @param {string} [format='default'] + * @return {Array | Matrix} + * @private + */ + function _zeros(size, format) { + var hasBigNumbers = _normalize(size); + var defaultValue = hasBigNumbers ? new type.BigNumber(0) : 0; + _validate(size); + + if (format) { + // return a matrix + var m = matrix(format); + if (size.length > 0) { + return m.resize(size, defaultValue); + } + return m; + } + else { + // return an Array + var arr = []; + if (size.length > 0) { + return resize(arr, size, defaultValue); + } + return arr; + } + } + + // replace BigNumbers with numbers, returns true if size contained BigNumbers + function _normalize(size) { + var hasBigNumbers = false; + size.forEach(function (value, index, arr) { + if (value instanceof type.BigNumber) { + hasBigNumbers = true; + arr[index] = value.toNumber(); + } + }); + return hasBigNumbers; + } + + // validate arguments + function _validate (size) { + size.forEach(function (value) { + if (typeof value !== 'number' || !isInteger(value) || value < 0) { + throw new Error('Parameters in function zeros must be positive integers'); + } + }); + } + } + + // TODO: zeros contains almost the same code as ones. Reuse this? + + exports.name = 'zeros'; + exports.factory = factory; + + +/***/ }, +/* 119 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a BigNumber, which can store numbers with arbitrary precision. + * When a matrix is provided, all elements will be converted to BigNumber. + * + * Syntax: + * + * math.bignumber(x) + * + * Examples: + * + * 0.1 + 0.2; // returns Number 0.30000000000000004 + * math.bignumber(0.1) + math.bignumber(0.2); // returns BigNumber 0.3 + * + * + * 7.2e500; // returns Number Infinity + * math.bignumber('7.2e500'); // returns BigNumber 7.2e500 + * + * See also: + * + * boolean, complex, index, matrix, string, unit + * + * @param {Number | String | Array | Matrix | Boolean | null} [value] Value for the big number, + * 0 by default. + * @returns {BigNumber} The created bignumber + */ + var bignumber = typed('bignumber', { + '': function () { + return new type.BigNumber(0); + }, + + 'number': function (x) { + // convert to string to prevent errors in case of >15 digits + return new type.BigNumber(x + ''); + }, + + 'string': function (x) { + return new type.BigNumber(x); + }, + + 'BigNumber': function (x) { + // we assume a BigNumber is immutable + return x; + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, bignumber); + } + }); + + return bignumber; + } + + exports.name = 'bignumber'; + exports.factory = factory; + + +/***/ }, +/* 120 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a boolean or convert a string or number to a boolean. + * In case of a number, `true` is returned for non-zero numbers, and `false` in + * case of zero. + * Strings can be `'true'` or `'false'`, or can contain a number. + * When value is a matrix, all elements will be converted to boolean. + * + * Syntax: + * + * math.boolean(x) + * + * Examples: + * + * math.boolean(0); // returns false + * math.boolean(1); // returns true + * math.boolean(-3); // returns true + * math.boolean('true'); // returns true + * math.boolean('false'); // returns false + * math.boolean([1, 0, 1, 1]); // returns [true, false, true, true] + * + * See also: + * + * bignumber, complex, index, matrix, string, unit + * + * @param {String | Number | Boolean | Array | Matrix | null} value A value of any type + * @return {Boolean | Array | Matrix} The boolean value + */ + var bool = typed('bool', { + '': function () { + return false; + }, + + 'boolean': function (x) { + return x; + }, + + 'number': function (x) { + return !!x; + }, + + 'BigNumber': function (x) { + return !x.isZero(); + }, + + 'string': function (x) { + // try case insensitive + var lcase = x.toLowerCase(); + if (lcase === 'true') { + return true; + } + else if (lcase === 'false') { + return false; + } + + // test whether value is a valid number + var num = Number(x); + if (x != '' && !isNaN(num)) { + return !!num; + } + + throw new Error('Cannot convert "' + x + '" to a boolean'); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, bool); + } + }); + + return bool; + } + + exports.name = 'boolean'; + exports.factory = factory; + + +/***/ }, +/* 121 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Wrap any value in a chain, allowing to perform chained operations on + * the value. + * + * All methods available in the math.js library can be called upon the chain, + * and then will be evaluated with the value itself as first argument. + * The chain can be closed by executing `chain.done()`, which returns + * the final value. + * + * The chain has a number of special functions: + * + * - `done()` Finalize the chain and return the chain's value. + * - `valueOf()` The same as `done()` + * - `toString()` Executes `math.format()` onto the chain's value, returning + * a string representation of the value. + * + * Syntax: + * + * math.chain(value) + * + * Examples: + * + * math.chain(3) + * .add(4) + * .subtract(2) + * .done(); // 5 + * + * math.chain( [[1, 2], [3, 4]] ) + * .subset(math.index(0, 0), 8) + * .multiply(3) + * .done(); // [[24, 6], [9, 12]] + * + * @param {*} [value] A value of any type on which to start a chained operation. + * @return {math.type.Chain} The created chain + */ + return typed('chain', { + '': function() { + return new type.Chain(); + }, + + 'any': function(value) { + return new type.Chain(value); + } + }); + } + + exports.name = 'chain'; + exports.factory = factory; + + +/***/ }, +/* 122 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a complex value or convert a value to a complex value. + * + * Syntax: + * + * math.complex() // creates a complex value with zero + * // as real and imaginary part. + * math.complex(re : number, im : string) // creates a complex value with provided + * // values for real and imaginary part. + * math.complex(re : number) // creates a complex value with provided + * // real value and zero imaginary part. + * math.complex(complex : Complex) // clones the provided complex value. + * math.complex(arg : string) // parses a string into a complex value. + * math.complex(array : Array) // converts the elements of the array + * // or matrix element wise into a + * // complex value. + * math.complex({re: number, im: number}) // creates a complex value with provided + * // values for real an imaginary part. + * math.complex({r: number, phi: number}) // creates a complex value with provided + * // polar coordinates + * + * Examples: + * + * var a = math.complex(3, -4); // a = Complex 3 - 4i + * a.re = 5; // a = Complex 5 - 4i + * var i = a.im; // Number -4; + * var b = math.complex('2 + 6i'); // Complex 2 + 6i + * var c = math.complex(); // Complex 0 + 0i + * var d = math.add(a, b); // Complex 5 + 2i + * + * See also: + * + * bignumber, boolean, index, matrix, number, string, unit + * + * @param {* | Array | Matrix} [args] + * Arguments specifying the real and imaginary part of the complex number + * @return {Complex | Array | Matrix} Returns a complex value + */ + var complex = typed('complex', { + '': function () { + return new type.Complex(0, 0); + }, + + 'number': function (x) { + return new type.Complex(x, 0); + }, + + 'number, number': function (re, im) { + return new type.Complex(re, im); + }, + + // TODO: this signature should be redundant + 'BigNumber, BigNumber': function (re, im) { + return new type.Complex(re.toNumber(), im.toNumber()); + }, + + 'Complex': function (x) { + return x.clone(); + }, + + 'string': function (x) { + var c = type.Complex.parse(x); + if (c) { + return c; + } + + throw new SyntaxError('String "' + x + '" is no valid complex number'); + }, + + 'Object': function (x) { + if('re' in x && 'im' in x) { + return new type.Complex(x.re, x.im); + } + + if ('r' in x && 'phi' in x) { + return type.Complex.fromPolar(x.r, x.phi); + } + + throw new Error('Expected object with either properties re and im, or properties r and phi.'); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, complex); + } + }); + + return complex; + } + + exports.name = 'complex'; + exports.factory = factory; + + +/***/ }, +/* 123 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Create an index. An Index can store ranges having start, step, and end + * for multiple dimensions. + * Matrix.get, Matrix.set, and math.subset accept an Index as input. + * + * Syntax: + * + * math.index(range1, range2, ...) + * + * Where: + * + * Each range can be any of: + * + * - An array [start, end] + * - An array [start, end, step] + * - A number + * - An instance of `Range` + * + * The parameters start, end, and step must be integer numbers. Start and end + * are zero based. The start of a range is included, the end is excluded. + * + * Examples: + * + * var math = math.js + * + * var b = [1, 2, 3, 4, 5]; + * math.subset(b, math.index([1, 3])); // returns [2, 3] + * + * var a = math.matrix([[1, 2], [3, 4]]); + * a.subset(math.index(0, 1)); // returns 2 + * a.subset(math.index(1, null)); // returns [3, 4] + * + * See also: + * + * bignumber, boolean, complex, matrix, number, string, unit + * + * @param {...*} ranges Zero or more ranges or numbers. + * @return {Index} Returns the created index + */ + return typed('index', { + '...number | BigNumber | Range | Array': function (args) { + var ranges = args.map(function (arg) { + if (arg instanceof type.BigNumber) { + return arg.toNumber(); // convert BigNumber to Number + } + else if (Array.isArray(arg)) { + return arg.map(function (elem) { + // convert BigNumber to Number + return (elem instanceof type.BigNumber) ? elem.toNumber() : elem; + }); + } + else { + return arg; + } + }); + + var res = new type.Index(); + type.Index.apply(res, ranges); + return res; + } + }); + } + + exports.name = 'index'; + exports.factory = factory; + + +/***/ }, +/* 124 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a number or convert a string, boolean, or unit to a number. + * When value is a matrix, all elements will be converted to number. + * + * Syntax: + * + * math.number(value) + * math.number(unit, valuelessUnit) + * + * Examples: + * + * math.number(2); // returns number 2 + * math.number('7.2'); // returns number 7.2 + * math.number(true); // returns number 1 + * math.number([true, false, true, true]); // returns [1, 0, 1, 1] + * math.number(math.unit('52cm'), 'm'); // returns 0.52 + * + * See also: + * + * bignumber, boolean, complex, index, matrix, string, unit + * + * @param {String | Number | Boolean | Array | Matrix | Unit | null} [value] Value to be converted + * @param {Unit | string} [valuelessUnit] A valueless unit, used to convert a unit to a number + * @return {Number | Array | Matrix} The created number + */ + var number = typed('number', { + '': function () { + return 0; + }, + + 'number': function (x) { + return x; + }, + + 'string': function (x) { + var num = Number(x); + if (isNaN(num)) { + throw new SyntaxError('String "' + x + '" is no valid number'); + } + return num; + }, + + 'BigNumber': function (x) { + return x.toNumber(); + }, + + 'Unit': function (x) { + throw new Error('Second argument with valueless unit expected'); + }, + + 'Unit, string | Unit': function (unit, valuelessUnit) { + return unit.toNumber(valuelessUnit); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, number); + } + }); + + return number; + } + + exports.name = 'number'; + exports.factory = factory; + + +/***/ }, +/* 125 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var SparseMatrix = type.SparseMatrix; + + /** + * Create a Sparse Matrix. The function creates a new `math.type.Matrix` object from + * an `Array`. A Matrix has utility functions to manipulate the data in the + * matrix, like getting the size and getting or setting values in the matrix. + * + * Syntax: + * + * math.sparse() // creates an empty sparse matrix. + * math.sparse(data) // creates a sparse matrix with initial data. + * math.sparse(data, 'number') // creates a sparse matrix with initial data, number datatype. + * + * Examples: + * + * var m = math.sparse([[1, 2], [3, 4]]); + * m.size(); // Array [2, 2] + * m.resize([3, 2], 5); + * m.valueOf(); // Array [[1, 2], [3, 4], [5, 5]] + * m.get([1, 0]) // number 3 + * + * See also: + * + * bignumber, boolean, complex, index, number, string, unit, matrix + * + * @param {Array | Matrix} [data] A two dimensional array + * + * @return {Matrix} The created matrix + */ + return typed('sparse', { + '': function () { + return new SparseMatrix([]); + }, + + 'string': function (datatype) { + return new SparseMatrix([], datatype); + }, + + 'Array | Matrix': function (data) { + return new SparseMatrix(data); + }, + + 'Array | Matrix, string': function (data, datatype) { + return new SparseMatrix(data, datatype); + } + }); + } + + exports.name = 'sparse'; + exports.factory = factory; + + +/***/ }, +/* 126 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var number = __webpack_require__(41); + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a string or convert any object into a string. + * Elements of Arrays and Matrices are processed element wise. + * + * Syntax: + * + * math.string(value) + * + * Examples: + * + * math.string(4.2); // returns string '4.2' + * math.string(math.complex(3, 2); // returns string '3 + 2i' + * + * var u = math.unit(5, 'km'); + * math.string(u.to('m')); // returns string '5000 m' + * + * math.string([true, false]); // returns ['true', 'false'] + * + * See also: + * + * bignumber, boolean, complex, index, matrix, number, unit + * + * @param {* | Array | Matrix | null} [value] A value to convert to a string + * @return {String | Array | Matrix} The created string + */ + var string = typed('string', { + '': function () { + return ''; + }, + + 'number': number.format, + + 'null': function (x) { + return 'null'; + }, + + 'boolean': function (x) { + return x + ''; + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, string); + }, + + 'any': function (x) { + return String(x); + } + }); + + return string; + } + + exports.name = 'string'; + exports.factory = factory; + + +/***/ }, +/* 127 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Create a unit. Depending on the passed arguments, the function + * will create and return a new math.type.Unit object. + * When a matrix is provided, all elements will be converted to units. + * + * Syntax: + * + * math.unit(unit : string) + * math.unit(value : number, unit : string) + * + * Examples: + * + * var a = math.unit(5, 'cm'); // returns Unit 50 mm + * var b = math.unit('23 kg'); // returns Unit 23 kg + * a.to('m'); // returns Unit 0.05 m + * + * See also: + * + * bignumber, boolean, complex, index, matrix, number, string + * + * @param {* | Array | Matrix} args A number and unit. + * @return {Unit | Array | Matrix} The created unit + */ + + var unit = typed('unit', { + 'Unit': function (x) { + return x.clone(); + }, + + 'string': function (x) { + if (type.Unit.isValuelessUnit(x)) { + return new type.Unit(null, x); // a pure unit + } + + var u = type.Unit.parse(x); // a unit with value, like '5cm' + if (u) { + return u; + } + + throw new SyntaxError('String "' + x + '" is no valid unit'); + }, + + 'number, string': function (value, unit) { + return new type.Unit(value, unit); + }, + + 'BigNumber, string': function (value, unit) { + return new type.Unit(value.toNumber(), unit); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, unit); + } + }); + + return unit; + } + + exports.name = 'unit'; + exports.factory = factory; + + +/***/ }, +/* 128 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + /** + * Compute the number of ways of picking `k` unordered outcomes from `n` + * possibilities. + * + * Combinations only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * Syntax: + * + * math.combinations(n, k) + * + * Examples: + * + * math.combinations(7, 5); // returns 21 + * + * See also: + * + * permutations, factorial + * + * @param {Number | BigNumber} n Total number of objects in the set + * @param {Number | BigNumber} k Number of objects in the subset + * @return {Number | BigNumber} Number of possible combinations. + */ + return typed('combinations', { + 'number, number': function (n, k) { + var max, result, i; + + if (!isInteger(n) || n < 0) { + throw new TypeError('Positive integer value expected in function combinations'); + } + if (k > n) { + throw new TypeError('k must be less than or equal to n'); + } + + max = Math.max(k, n - k); + result = 1; + for (i = 1; i <= n - max; i++) { + result = result * (max + i) / i; + } + + return result; + }, + + 'BigNumber, BigNumber': function (n, k) { + var max, result, i, ii; + var one = new type.BigNumber(1); + + if (!isPositiveInteger(n) || !isPositiveInteger(k)) { + throw new TypeError('Positive integer value expected in function combinations'); + } + if (k.gt(n)) { + throw new TypeError('k must be less than n in function combinations'); + } + + max = n.minus(k); + if (k.lt(max)) max = k; + result = one; + for (i = one, ii = n.minus(max); i.lte(ii); i = i.plus(1)) { + result = result.times(max.plus(i)).dividedBy(i); + } + + return result; + } + + // TODO: implement support for collection in combinations + }); + } + + /** + * Test whether BigNumber n is a positive integer + * @param {BigNumber} n + * @returns {boolean} isPositiveInteger + */ + function isPositiveInteger(n) { + return n.isInteger() && n.gte(0); + } + + exports.name = 'combinations'; + exports.factory = factory; + + +/***/ }, +/* 129 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bignumber = __webpack_require__(48); + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var gamma = load(__webpack_require__(130)); + + /** + * Compute the factorial of a value + * + * Factorial only supports an integer value as argument. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.factorial(n) + * + * Examples: + * + * math.factorial(5); // returns 120 + * math.factorial(3); // returns 6 + * + * See also: + * + * combinations, gamma, permutations + * + * @param {Number | BigNumber | Array | Matrix | Boolean | null} n An integer number + * @return {Number | BigNumber | Array | Matrix} The factorial of `n` + */ + var factorial = typed('factorial', { + 'number': function (n) { + if (n === Number.POSITIVE_INFINITY) { + return Math.sqrt(2 * Math.PI); + } + + return gamma(n + 1); + }, + + 'BigNumber': function (n) { + if (!n.isFinite() && !n.isNegative()) { + return bignumber.tau(config.precision).sqrt(); + } + + return gamma(n.plus(1)); + }, + + 'Array | Matrix': function (n) { + return collection.deepMap(n, factorial); + } + }); + + return factorial; + } + + exports.name = 'factorial'; + exports.factory = factory; + + +/***/ }, +/* 130 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var multiply = load(__webpack_require__(71)); + var pow = load(__webpack_require__(74)); + + /** + * Compute the gamma function of a value using Lanczos approximation for + * small values, and an extended Stirling approximation for large values. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.gamma(n) + * + * Examples: + * + * math.gamma(5); // returns 24 + * math.gamma(-0.5); // returns -3.5449077018110335 + * math.gamma(math.i); // returns -0.15494982830180973 - 0.49801566811835596i + * + * See also: + * + * combinations, factorial, permutations + * + * @param {Number | Array | Matrix | Boolean | null} n A real or complex number + * @return {Number | Array | Matrix} The gamma of `n` + */ + var gamma = typed('gamma', { + 'number': function (n) { + var t, x; + + if (isInteger(n)) { + if (n <= 0) { + return isFinite(n) ? Infinity : NaN; + } + + if (n > 171) { + return Infinity; // Will overflow + } + + var value = n - 2; + var res = n - 1; + while (value > 1) { + res *= value; + value--; + } + + if (res == 0) { + res = 1; // 0! is per definition 1 + } + + return res; + } + + if (n < 0.5) { + return Math.PI / (Math.sin(Math.PI * n) * gamma(1-n)); + } + + if (n >= 171.35) { + return Infinity; // will overflow + } + + if (n > 85.0) { // Extended Stirling Approx + var twoN = n*n; + var threeN = twoN*n; + var fourN = threeN*n; + var fiveN = fourN*n; + return Math.sqrt(2*Math.PI/n) * Math.pow((n/Math.E), n) * + (1 + 1/(12*n) + 1/(288*twoN) - 139/(51840*threeN) - + 571/(2488320*fourN) + 163879/(209018880*fiveN) + + 5246819/(75246796800*fiveN*n)); + } + + --n; + x = p[0]; + for (var i = 1; i < p.length; ++i) { + x += p[i] / (n+i); + } + + t = n + g + 0.5; + return Math.sqrt(2*Math.PI) * Math.pow(t, n+0.5) * Math.exp(-t) * x; + }, + + 'Complex': function (n) { + var t, x; + + if (n.im == 0) { + return gamma(n.re); + } + + n = new type.Complex(n.re - 1, n.im); + x = new type.Complex(p[0], 0); + for (var i = 1; i < p.length; ++i) { + var real = n.re + i; // x += p[i]/(n+i) + var den = real*real + n.im*n.im; + if (den != 0) { + x.re += p[i] * real / den; + x.im += -(p[i] * n.im) / den; + } else { + x.re = p[i] < 0 + ? -Infinity + : Infinity; + } + } + + t = new type.Complex(n.re + g + 0.5, n.im); + var twoPiSqrt = Math.sqrt(2*Math.PI); + + n.re += 0.5; + var result = pow(t, n); + if (result.im == 0) { // sqrt(2*PI)*result + result.re *= twoPiSqrt; + } else if (result.re == 0) { + result.im *= twoPiSqrt; + } else { + result.re *= twoPiSqrt; + result.im *= twoPiSqrt; + } + + var r = Math.exp(-t.re); // exp(-t) + t.re = r * Math.cos(-t.im); + t.im = r * Math.sin(-t.im); + + return multiply(multiply(result, t), x); + }, + + 'BigNumber': function (n) { + if (n.isInteger()) { + return (n.isNegative() || n.isZero()) + ? new type.BigNumber(Infinity) + : bigFactorial(n.minus(1)); + } + + if (!n.isFinite()) { + return new type.BigNumber(n.isNegative() ? NaN : Infinity); + } + + throw new Error('Integer BigNumber expected'); + }, + + 'Array | Matrix': function (n) { + return collection.deepMap(n, gamma); + } + }); + + /** + * Calculate factorial for a BigNumber + * @param {BigNumber} n + * @returns {BigNumber} Returns the factorial of n + */ + function bigFactorial(n) { + var value, res, preciseFacs; + + var num = n.toNumber(); // should definitely be below Number.MAX_VALUE + if (num < smallBigFacs.length) { + return new type.BigNumber(smallBigFacs[num]).toSD(config.precision); + } + + // be wary of round-off errors + var precision = config.precision + (Math.log(num) | 0); + var Big = type.BigNumber.constructor({precision: precision}); + + // adjust n do align with the precision specific tables + num -= smallBigFacs.length; + if (preciseFacs = bigBigFacs[precision]) { + if (preciseFacs[num]) { + return new type.BigNumber(preciseFacs[num].toPrecision(config.precision)); + } + res = preciseFacs[preciseFacs.length-1]; + } else { + preciseFacs = bigBigFacs[precision] = []; + res = new Big(smallBigFacs[smallBigFacs.length-1]) + .toSD(precision); + } + + var one = new Big(1); + value = new Big(preciseFacs.length + smallBigFacs.length); + for (var i = preciseFacs.length; i < num; ++i) { + preciseFacs[i] = res = res.times(value); + value = value.plus(one); + } + + preciseFacs[num] = res.times(value); + return new type.BigNumber(preciseFacs[num].toPrecision(config.precision)); + } + + return gamma; + } + + // TODO: comment on the variables g and p + + var g = 4.7421875; + + var p = [ + 0.99999999999999709182, + 57.156235665862923517, + -59.597960355475491248, + 14.136097974741747174, + -0.49191381609762019978, + 0.33994649984811888699e-4, + 0.46523628927048575665e-4, + -0.98374475304879564677e-4, + 0.15808870322491248884e-3, + -0.21026444172410488319e-3, + 0.21743961811521264320e-3, + -0.16431810653676389022e-3, + 0.84418223983852743293e-4, + -0.26190838401581408670e-4, + 0.36899182659531622704e-5 + ]; + + // 21! >= values for each precision + var bigBigFacs = []; + + // 0-20! values + var smallBigFacs = [ + 1, + 1, + 2, + 6, + 24, + 120, + 720, + 5040, + 40320, + 362880, + 3628800, + 39916800, + 479001600, + 6227020800, + 87178291200, + 1307674368000, + 20922789888000, + 355687428096000, + 6402373705728000, + 121645100408832000, + 2432902008176640000 + ]; + + exports.name = 'gamma'; + exports.factory = factory; + + +/***/ }, +/* 131 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isInteger = __webpack_require__(41).isInteger; + + function factory (type, config, load, typed) { + var factorial = load(__webpack_require__(129)); + + /** + * Compute the number of ways of obtaining an ordered subset of `k` elements + * from a set of `n` elements. + * + * Permutations only takes integer arguments. + * The following condition must be enforced: k <= n. + * + * Syntax: + * + * math.permutations(n) + * math.permutations(n, k) + * + * Examples: + * + * math.permutations(5); // 120 + * math.permutations(5, 3); // 60 + * + * See also: + * + * combinations, factorial + * + * @param {Number | BigNumber} n The number of objects in total + * @param {Number | BigNumber} [k] The number of objects in the subset + * @return {Number | BigNumber} The number of permutations + */ + return typed('permutations', { + 'number | BigNumber': factorial, + + 'number, number': function (n, k) { + var result, i; + + if (!isInteger(n) || n < 0) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (!isInteger(k) || k < 0) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (k > n) { + throw new TypeError('second argument k must be less than or equal to first argument n'); + } + + // Permute n objects, k at a time + result = 1; + for (i = n - k + 1; i <= n; i++) { + result = result * i; + } + + return result; + }, + + 'BigNumber, BigNumber': function (n, k) { + var result, i; + + if (!isPositiveInteger(n) || !isPositiveInteger(k)) { + throw new TypeError('Positive integer value expected in function permutations'); + } + if (k.gt(n)) { + throw new TypeError('second argument k must be less than or equal to first argument n'); + } + + result = new type.BigNumber(1); + for (i = n.minus(k).plus(1); i.lte(n); i = i.plus(1)) { + result = result.times(i); + } + + return result; + } + + // TODO: implement support for collection in permutations + }); + } + + /** + * Test whether BigNumber n is a positive integer + * @param {BigNumber} n + * @returns {boolean} isPositiveInteger + */ + function isPositiveInteger(n) { + return n.isInteger() && n.gte(0); + } + + exports.name = 'permutations'; + exports.factory = factory; + + +/***/ }, +/* 132 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(211)); + + /** + * Random pick a value from a one dimensional array. + * Array element is picked using a random function with uniform distribution. + * + * Syntax: + * + * math.pickRandom(array) + * + * Examples: + * + * math.pickRandom([3, 6, 12, 2]); // returns one of the values in the array + * + * See also: + * + * random, randomInt + * + * @param {Array} array A one dimensional array + * @return {Number} One of the elements of the provided input array + */ + // TODO: rework pickRandom to a typed-function + return distribution('uniform').pickRandom; + } + + exports.name = 'pickRandom'; + exports.factory = factory; + + +/***/ }, +/* 133 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(211)); + + /** + * Return a random number larger or equal to `min` and smaller than `max` + * using a uniform distribution. + * + * Syntax: + * + * math.random() // generate a random number between 0 and 1 + * math.random(max) // generate a random number between 0 and max + * math.random(min, max) // generate a random number between min and max + * math.random(size) // generate a matrix with random numbers between 0 and 1 + * math.random(size, max) // generate a matrix with random numbers between 0 and max + * math.random(size, min, max) // generate a matrix with random numbers between min and max + * + * Examples: + * + * math.random(); // returns a random number between 0 and 1 + * math.random(100); // returns a random number between 0 and 100 + * math.random(30, 40); // returns a random number between 30 and 40 + * math.random([2, 3]); // returns a 2x3 matrix with random numbers between 0 and 1 + * + * See also: + * + * randomInt, pickRandom + * + * @param {Array | Matrix} [size] If provided, an array or matrix with given + * size and filled with random values is returned + * @param {Number} [min] Minimum boundary for the random value, included + * @param {Number} [max] Maximum boundary for the random value, excluded + * @return {Number | Array | Matrix} A random number + */ + // TODO: rework random to a typed-function + return distribution('uniform').random; + } + + exports.name = 'random'; + exports.factory = factory; + + +/***/ }, +/* 134 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var distribution = load(__webpack_require__(211)); + + /** + * Return a random integer number larger or equal to `min` and smaller than `max` + * using a uniform distribution. + * + * Syntax: + * + * math.randomInt() // generate a random integer between 0 and 1 + * math.randomInt(max) // generate a random integer between 0 and max + * math.randomInt(min, max) // generate a random integer between min and max + * math.randomInt(size) // generate a matrix with random integer between 0 and 1 + * math.randomInt(size, max) // generate a matrix with random integer between 0 and max + * math.randomInt(size, min, max) // generate a matrix with random integer between min and max + * + * Examples: + * + * math.randomInt(); // returns a random integer between 0 and 1 + * math.randomInt(100); // returns a random integer between 0 and 100 + * math.randomInt(30, 40); // returns a random integer between 30 and 40 + * math.randomInt([2, 3]); // returns a 2x3 matrix with random integers between 0 and 1 + * + * See also: + * + * random, pickRandom + * + * @param {Array | Matrix} [size] If provided, an array or matrix with given + * size and filled with random values is returned + * @param {Number} [min] Minimum boundary for the random value, included + * @param {Number} [max] Maximum boundary for the random value, excluded + * @return {Number | Array | Matrix} A random integer value + */ + // TODO: rework randomInt to a typed-function + return distribution('uniform').randomInt; + } + + exports.name = 'randomInt'; + exports.factory = factory; + + +/***/ }, +/* 135 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var larger = load(__webpack_require__(45)); + + /** + * Compute the maximum value of a matrix or a list with values. + * In case of a multi dimensional array, the maximum of the flattened array + * will be calculated. When `dim` is provided, the maximum over the selected + * dimension will be calculated. Parameter `dim` is zero-based. + * + * Syntax: + * + * math.max(a, b, c, ...) + * math.max(A) + * math.max(A, dim) + * + * Examples: + * + * math.max(2, 1, 4, 3); // returns 4 + * math.max([2, 1, 4, 3]); // returns 4 + * + * // maximum over a specified dimension (zero-based) + * math.max([[2, 5], [4, 3], [1, 7]], 0); // returns [4, 7] + * math.max([[2, 5], [4, 3]], [1, 7], 1); // returns [5, 4, 7] + * + * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 + * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 + * + * See also: + * + * mean, median, min, prod, std, sum, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The maximum value + */ + return typed('max', { + // max([a, b, c, d, ...]) + 'Array | Matrix': _max, + + // max([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + return collection.reduce(array, dim.valueOf(), _largest); + }, + + // max(a, b, c, d, ...) + '...': function () { + return _max(arguments); + } + }); + + /** + * Return the largest of two values + * @param {*} x + * @param {*} y + * @returns {*} Returns x when x is largest, or y when y is largest + * @private + */ + function _largest(x, y){ + return larger(x, y) ? x : y; + } + + /** + * Recursively calculate the maximum value in an n-dimensional array + * @param {Array} array + * @return {Number} max + * @private + */ + function _max(array) { + var max = undefined; + + collection.deepForEach(array, function (value) { + if (max === undefined || larger(value, max)) { + max = value; + } + }); + + if (max === undefined) { + throw new Error('Cannot calculate max of an empty array'); + } + + return max; + } + } + + exports.name = 'max'; + exports.factory = factory; + + +/***/ }, +/* 136 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var add = load(__webpack_require__(47)); + var divide = load(__webpack_require__(59)); + + /** + * Compute the mean value of matrix or a list with values. + * In case of a multi dimensional array, the mean of the flattened array + * will be calculated. When `dim` is provided, the maximum over the selected + * dimension will be calculated. Parameter `dim` is zero-based. + * + * Syntax: + * + * math.mean(a, b, c, ...) + * math.mean(A) + * math.mean(A, dim) + * + * Examples: + * + * math.mean(2, 1, 4, 3); // returns 2.5 + * math.mean([1, 2.7, 3.2, 4]); // returns 2.725 + * + * math.mean([[2, 5], [6, 3], [1, 7]], 0); // returns [3, 5] + * math.mean([[2, 5], [6, 3], [1, 7]], 1); // returns [3.5, 4.5, 4] + * + * See also: + * + * median, min, max, sum, prod, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The mean of all values + */ + return typed('mean', { + // mean([a, b, c, d, ...]) + 'Array | Matrix': _mean, + + // mean([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': _nmean, + + // mean(a, b, c, d, ...) + '...': function () { + return _mean(arguments); + } + }); + + /** + * Calculate the mean value in an n-dimensional array, returning a + * n-1 dimensional array + * @param {Array} array + * @param {Number} dim + * @return {Number} mean + * @private + */ + function _nmean(array, dim){ + var sum = collection.reduce(array, dim, add); + var s = Array.isArray(array) ? size(array) : array.size(); + return divide(sum, s[dim]); + } + + /** + * Recursively calculate the mean value in an n-dimensional array + * @param {Array} array + * @return {Number} mean + * @private + */ + function _mean(array) { + var sum = 0; + var num = 0; + + collection.deepForEach(array, function (value) { + sum = add(sum, value); + num++; + }); + + if (num === 0) { + throw new Error('Cannot calculate mean of an empty array'); + } + + return divide(sum, num); + } + } + + exports.name = 'mean'; + exports.factory = factory; + + +/***/ }, +/* 137 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var flatten = __webpack_require__(37).flatten; + + function factory (type, config, load, typed) { + var add = load(__webpack_require__(47)); + var divide = load(__webpack_require__(59)); + var compare = load(__webpack_require__(168)); + + /** + * Compute the median of a matrix or a list with values. The values are + * sorted and the middle value is returned. In case of an even number of + * values, the average of the two middle values is returned. + * Supported types of values are: Number, BigNumber, Unit + * + * In case of a (multi dimensional) array or matrix, the median of all + * elements will be calculated. + * + * Syntax: + * + * math.median(a, b, c, ...) + * math.median(A) + * + * Examples: + * + * math.median(5, 2, 7); // returns 5 + * math.median([3, -1, 5, 7]); // returns 4 + * + * See also: + * + * mean, min, max, sum, prod, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The median + */ + var median = typed('median', { + // median([a, b, c, d, ...]) + 'Array | Matrix': _median, + + // median([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + // TODO: implement median(A, dim) + throw new Error('median(A, dim) is not yet supported'); + //return collection.reduce(arguments[0], arguments[1], ...); + }, + + // median(a, b, c, d, ...) + '...': function () { + return _median(Array.prototype.slice.call(arguments)); + } + }); + + /** + * Recursively calculate the median of an n-dimensional array + * @param {Array | Matrix} array + * @return {Number} median + * @private + */ + function _median(array) { + var flat = flatten(array.valueOf()); + + flat.sort(compare); + + var num = flat.length; + + if (num == 0) { + throw new Error('Cannot calculate median of an empty array'); + } + + if (num % 2 == 0) { + // even: return the average of the two middle values + return middle2(flat[num / 2 - 1], flat[num / 2]); + } + else { + // odd: return the middle value + return middle(flat[(num - 1) / 2]); + } + } + + // helper function to type check the middle value of the array + var middle = typed('number | BigNumber | Unit', function (value) { + return value; + }); + + // helper function to type check the two middle value of the array + var middle2 = typed('number | BigNumber | Unit, number | BigNumber | Unit', function (left, right) { + return divide(add(left, right), 2); + }); + + return median; + } + + exports.name = 'median'; + exports.factory = factory; + + +/***/ }, +/* 138 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var smaller = load(__webpack_require__(44)); + + /** + * Compute the maximum value of a matrix or a list of values. + * In case of a multi dimensional array, the maximum of the flattened array + * will be calculated. When `dim` is provided, the maximum over the selected + * dimension will be calculated. Parameter `dim` is zero-based. + * + * Syntax: + * + * math.min(a, b, c, ...) + * math.min(A) + * math.min(A, dim) + * + * Examples: + * + * math.min(2, 1, 4, 3); // returns 1 + * math.min([2, 1, 4, 3]); // returns 1 + * + * // maximum over a specified dimension (zero-based) + * math.min([[2, 5], [4, 3], [1, 7]], 0); // returns [1, 3] + * math.min([[2, 5], [4, 3], [1, 7]], 1); // returns [2, 3, 1] + * + * math.max(2.7, 7.1, -4.5, 2.0, 4.1); // returns 7.1 + * math.min(2.7, 7.1, -4.5, 2.0, 4.1); // returns -4.5 + * + * See also: + * + * mean, median, max, prod, std, sum, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The minimum value + */ + return typed('min', { + // min([a, b, c, d, ...]) + 'Array | Matrix': _min, + + // min([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + return collection.reduce(array, dim.valueOf(), _smallest); + }, + + // min(a, b, c, d, ...) + '...': function () { + return _min(arguments); + } + }); + + /** + * Return the smallest of two values + * @param {*} x + * @param {*} y + * @returns {*} Returns x when x is smallest, or y when y is smallest + * @private + */ + function _smallest(x, y) { + return smaller(x, y) ? x : y; + } + + /** + * Recursively calculate the minimum value in an n-dimensional array + * @param {Array} array + * @return {Number} min + * @private + */ + function _min(array) { + var min = undefined; + + collection.deepForEach(array, function (value) { + if (min === undefined || smaller(value, min)) { + min = value; + } + }); + + if (min === undefined) { + throw new Error('Cannot calculate min of an empty array'); + } + + return min; + } + } + + exports.name = 'min'; + exports.factory = factory; + + +/***/ }, +/* 139 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var multiply = load(__webpack_require__(71)); + + /** + * Compute the product of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the sum of all + * elements will be calculated. + * + * Syntax: + * + * math.prod(a, b, c, ...) + * math.prod(A) + * + * Examples: + * + * math.multiply(2, 3); // returns 6 + * math.prod(2, 3); // returns 6 + * math.prod(2, 3, 4); // returns 24 + * math.prod([2, 3, 4]); // returns 24 + * math.prod([[2, 5], [4, 3]]); // returns 120 + * + * See also: + * + * mean, median, min, max, sum, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The product of all values + */ + return typed('prod', { + // prod([a, b, c, d, ...]) + 'Array | Matrix': _prod, + + // prod([a, b, c, d, ...], dim) + 'Array | Matrix, number | BigNumber': function (array, dim) { + // TODO: implement prod(A, dim) + throw new Error('prod(A, dim) is not yet supported'); + //return collection.reduce(arguments[0], arguments[1], math.prod); + }, + + // prod(a, b, c, d, ...) + '...': function () { + return _prod(arguments); + } + }); + + /** + * Recursively calculate the product of an n-dimensional array + * @param {Array} array + * @return {Number} prod + * @private + */ + function _prod(array) { + var prod = undefined; + + collection.deepForEach(array, function (value) { + prod = (prod === undefined) ? value : multiply(prod, value); + }); + + if (prod === undefined) { + throw new Error('Cannot calculate prod of an empty array'); + } + + return prod; + } + } + + exports.name = 'prod'; + exports.factory = factory; + + +/***/ }, +/* 140 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var sqrt = load(__webpack_require__(77)); + var variance = load(__webpack_require__(142)); + + /** + * Compute the standard deviation of a matrix or a list with values. + * The standard deviations is defined as the square root of the variance: + * `std(A) = sqrt(var(A))`. + * In case of a (multi dimensional) array or matrix, the standard deviation + * over all elements will be calculated. + * + * Optionally, the type of normalization can be specified as second + * parameter. The parameter `normalization` can be one of the following values: + * + * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + * + * Syntax: + * + * math.std(a, b, c, ...) + * math.std(A) + * math.std(A, normalization) + * + * Examples: + * + * math.std(2, 4, 6); // returns 2 + * math.std([2, 4, 6, 8]); // returns 2.581988897471611 + * math.std([2, 4, 6, 8], 'uncorrected'); // returns 2.23606797749979 + * math.std([2, 4, 6, 8], 'biased'); // returns 2 + * + * math.std([[1, 2, 3], [4, 5, 6]]); // returns 1.8708286933869707 + * + * See also: + * + * mean, median, max, min, prod, sum, var + * + * @param {Array | Matrix} array + * A single matrix or or multiple scalar values + * @param {String} [normalization='unbiased'] + * Determines how to normalize the variance. + * Choose 'unbiased' (default), 'uncorrected', or 'biased'. + * @return {*} The standard deviation + */ + return typed('std', { + // std([a, b, c, d, ...]) + 'Array | Matrix': _std, + + // std([a, b, c, d, ...], normalization) + 'Array | Matrix, string': _std, + + // std(a, b, c, d, ...) + '...': function () { + return _std(Array.prototype.slice.call(arguments)); + } + }); + + function _std(array, normalization) { + if (array.length == 0) { + throw new SyntaxError('Function std requires one or more parameters (0 provided)'); + } + + return sqrt(variance.apply(null, arguments)); + } + } + + exports.name = 'std'; + exports.factory = factory; + + +/***/ }, +/* 141 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var add = load(__webpack_require__(47)); + + /** + * Compute the sum of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the sum of all + * elements will be calculated. + * + * Syntax: + * + * math.sum(a, b, c, ...) + * math.sum(A) + * + * Examples: + * + * math.sum(2, 1, 4, 3); // returns 10 + * math.sum([2, 1, 4, 3]); // returns 10 + * math.sum([[2, 5], [4, 3], [1, 7]]); // returns 22 + * + * See also: + * + * mean, median, min, max, prod, std, var + * + * @param {... *} args A single matrix or or multiple scalar values + * @return {*} The sum of all values + */ + return typed('sum', { + 'Array | Matrix': function (args) { + // sum([a, b, c, d, ...]) + return _sum(args); + }, + + 'Array | Matrix, number | BigNumber': function () { + // sum([a, b, c, d, ...], dim) + // TODO: implement sum(A, dim) + throw new Error('sum(A, dim) is not yet supported'); + }, + + '...': function () { + // sum(a, b, c, d, ...) + return _sum(arguments); + } + }); + + /** + * Recursively calculate the sum of an n-dimensional array + * @param {Array} array + * @return {Number} sum + * @private + */ + function _sum(array) { + var sum = undefined; + + collection.deepForEach(array, function (value) { + sum = (sum === undefined) ? value : add(sum, value); + }); + + if (sum === undefined) { + throw new Error('Cannot calculate sum of an empty array'); + } + return sum; + } + } + + exports.name = 'sum'; + exports.factory = factory; + + +/***/ }, +/* 142 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var DEFAULT_NORMALIZATION = 'unbiased'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var add = load(__webpack_require__(47)); + var subtract = load(__webpack_require__(79)); + var multiply = load(__webpack_require__(71)); + var divide = load(__webpack_require__(59)); + + /** + * Compute the variance of a matrix or a list with values. + * In case of a (multi dimensional) array or matrix, the variance over all + * elements will be calculated. + * + * Optionally, the type of normalization can be specified as second + * parameter. The parameter `normalization` can be one of the following values: + * + * - 'unbiased' (default) The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + + * Note that older browser may not like the variable name `var`. In that + * case, the function can be called as `math['var'](...)` instead of + * `math.var(...)`. + * + * Syntax: + * + * math.var(a, b, c, ...) + * math.var(A) + * math.var(A, normalization) + * + * Examples: + * + * math.var(2, 4, 6); // returns 4 + * math.var([2, 4, 6, 8]); // returns 6.666666666666667 + * math.var([2, 4, 6, 8], 'uncorrected'); // returns 5 + * math.var([2, 4, 6, 8], 'biased'); // returns 4 + * + * math.var([[1, 2, 3], [4, 5, 6]]); // returns 3.5 + * + * See also: + * + * mean, median, max, min, prod, std, sum + * + * @param {Array | Matrix} array + * A single matrix or or multiple scalar values + * @param {String} [normalization='unbiased'] + * Determines how to normalize the variance. + * Choose 'unbiased' (default), 'uncorrected', or 'biased'. + * @return {*} The variance + */ + return typed('variance', { + // var([a, b, c, d, ...]) + 'Array | Matrix': function (array) { + return _var(array, DEFAULT_NORMALIZATION); + }, + + // var([a, b, c, d, ...], normalization) + 'Array | Matrix, string': _var, + + // var(a, b, c, d, ...) + '...': function () { + return _var(arguments, DEFAULT_NORMALIZATION); + } + }); + + /** + * Recursively calculate the variance of an n-dimensional array + * @param {Array} array + * @param {String} normalization + * Determines how to normalize the variance: + * - 'unbiased' The sum of squared errors is divided by (n - 1) + * - 'uncorrected' The sum of squared errors is divided by n + * - 'biased' The sum of squared errors is divided by (n + 1) + * @return {Number | BigNumber} variance + * @private + */ + function _var(array, normalization) { + var sum = 0; + var num = 0; + + if (array.length == 0) { + throw new SyntaxError('Function var requires one or more parameters (0 provided)'); + } + + // calculate the mean and number of elements + collection.deepForEach(array, function (value) { + sum = add(sum, value); + num++; + }); + if (num === 0) throw new Error('Cannot calculate var of an empty array'); + + var mean = divide(sum, num); + + // calculate the variance + sum = 0; + collection.deepForEach(array, function (value) { + var diff = subtract(value, mean); + sum = add(sum, multiply(diff, diff)); + }); + + switch (normalization) { + case 'uncorrected': + return divide(sum, num); + + case 'biased': + return divide(sum, num + 1); + + case 'unbiased': + var zero = (sum instanceof type.BigNumber) ? new type.BigNumber(0) : 0; + return (num == 1) ? zero : divide(sum, num - 1); + + default: + throw new Error('Unknown normalization "' + normalization + '". ' + + 'Choose "unbiased" (default), "uncorrected", or "biased".'); + } + } + } + + exports.name = 'var'; + exports.factory = factory; + + +/***/ }, +/* 143 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcCos = __webpack_require__(48).arccos_arcsec; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexSqrt = load(__webpack_require__(77)).signatures['Complex']; + var complexLog = load(__webpack_require__(68)).signatures['Complex']; + + /** + * Calculate the inverse cosine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acos(x) + * + * Examples: + * + * math.acos(0.5); // returns Number 1.0471975511965979 + * math.acos(math.cos(1.5)); // returns Number 1.5 + * + * math.acos(2); // returns Complex 0 + 1.3169578969248166 i + * + * See also: + * + * cos, atan, asin + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} The arc cosine of x + */ + var acos = typed('acos', { + 'number': function (x) { + if (x >= -1 && x <= 1) { + return Math.acos(x); + } + else { + return _complexAcos(new type.Complex(x, 0)); + } + }, + + 'Complex': _complexAcos, + + 'BigNumber': function (x) { + return bigArcCos(x, type.BigNumber, false); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acos); + } + }); + + /** + * Calculate acos for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAcos(x) { + // acos(z) = 0.5*pi + i*log(iz + sqrt(1-z^2)) + var temp1 = new type.Complex( + x.im * x.im - x.re * x.re + 1.0, + -2.0 * x.re * x.im + ); + var temp2 = complexSqrt(temp1); + var temp3 = new type.Complex( + temp2.re - x.im, + temp2.im + x.re + ); + var temp4 = complexLog(temp3); + + // 0.5*pi = 1.5707963267948966192313216916398 + return new type.Complex( + 1.57079632679489661923 - temp4.im, + temp4.re + ); + } + + return acos; + } + + exports.name = 'acos'; + exports.factory = factory; + + +/***/ }, +/* 144 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAcosh = __webpack_require__(48).acosh_asinh_asech_acsch; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexAcos = load(__webpack_require__(143)).signatures['Complex']; + + /** + * Calculate the hyperbolic arccos of a value, + * defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acosh(x) + * + * Examples: + * + * math.acosh(1.5); // returns 0.9624236501192069 + * + * See also: + * + * cosh, asinh, atanh + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arccosine of x + */ + var acosh = typed('acosh', { + 'number': function (x) { + if (x >= 1) { + return Math.log(Math.sqrt(x*x - 1) + x); + } + if (x <= -1) { + return new type.Complex(Math.log(Math.sqrt(x*x - 1) - x), Math.PI); + } + return _complexAcosh(new type.Complex(x, 0)); + }, + + 'Complex': _complexAcosh, + + 'BigNumber': function (x) { + return bigAcosh(x, type.BigNumber, false, false); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acosh); + } + }); + + /** + * Calculate acosh for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAcosh(x) { + // acosh(z) = (-acos(z).im, acos(z).re) for acos(z).im <= 0 + // ( acos(z).im, -acos(z).re) otherwise + var temp; + var res = complexAcos(x); + if (res.im <= 0) { + temp = res.re; + res.re = -res.im; + res.im = temp; + } else { + temp = res.im; + res.im = -res.re; + res.re = temp; + } + + return res; + } + + return acosh; + } + + exports.name = 'acosh'; + exports.factory = factory; + + +/***/ }, +/* 145 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcCot = __webpack_require__(48).arctan_arccot; + + var HALF_PI = 1.5707963267948966; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexAtan = load(__webpack_require__(153)).signatures['Complex']; + + /** + * Calculate the inverse cotangent of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acot(x) + * + * Examples: + * + * math.acot(0.5); // returns Number 0.4636476090008061 + * math.acot(math.cot(1.5)); // returns Number 1.5 + * + * math.acot(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * cot, atan + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} The arc cotangent of x + */ + var acot = typed('acot', { + 'number': function (x) { + return (x) ? Math.atan(1 / x) : HALF_PI; + }, + + 'Complex': function (x) { + if (x.im == 0) { + return new type.Complex(x.re ? Math.atan(1 / x.re) : HALF_PI, 0); + } + + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re = x.re / den, + x.im = -x.im / den) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0); + + return complexAtan(x); + }, + + 'BigNumber': function (x) { + return bigArcCot(x, type.BigNumber, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acot); + } + }); + + return acot; + } + + exports.name = 'acot'; + exports.factory = factory; + + +/***/ }, +/* 146 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAcoth = __webpack_require__(48).atanh_acoth; + + var HALF_PI = 1.5707963267948966; + + function factory (type, config, load, typed) { + var atanh = load(__webpack_require__(155)).signatures['Complex']; + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic arccotangent of a value, + * defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acoth(x) + * + * Examples: + * + * math.acoth(0.5); // returns 0.8047189562170503 + * + * See also: + * + * acsch, asech + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arccotangent of x + */ + var acoth = typed('acoth', { + 'number': function (x) { + if (x >= 1 || x <= -1) { + return isFinite(x) ? (Math.log((x+1)/x) + Math.log(x/(x-1))) / 2 : 0; + } + return x !== 0 ? _complexAcoth(new type.Complex(x, 0)) : new type.Complex(0, HALF_PI); + }, + + 'Complex': _complexAcoth, + + 'BigNumber': function (x) { + return bigAcoth(x, type.BigNumber, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acoth); + } + }); + + /** + * Calculate the hyperbolic arccotangent of a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAcoth (x) { + if (x.re == 0 && x.im == 0) { + return new type.Complex(0, HALF_PI); + } + + // acoth(z) = -i*atanh(1/z) + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re / den, + -x.im / den + ) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0 + ); + + return atanh(x); + } + + return acoth; + } + + exports.name = 'acoth'; + exports.factory = factory; + + +/***/ }, +/* 147 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcCsc = __webpack_require__(48).arcsin_arccsc; + + var HALF_PI = 1.5707963267948966; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexAsin = load(__webpack_require__(151)).signatures['Complex']; + + /** + * Calculate the inverse cosecant of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acsc(x) + * + * Examples: + * + * math.acsc(0.5); // returns Number 0.5235987755982989 + * math.acsc(math.csc(1.5)); // returns Number ~1.5 + * + * math.acsc(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * csc, asin, asec + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} The arc cosecant of x + */ + var acsc = typed('acsc', { + 'number': function (x) { + if (x <= -1 || x >= 1) { + return Math.asin(1 / x); + } + return _complexAcsc(new type.Complex(x, 0)); + }, + + 'Complex': _complexAcsc, + + 'BigNumber': function (x) { + return bigArcCsc(x, type.BigNumber, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acsc); + } + }); + + /** + * Calculate acsc for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAcsc (x) { + if (x.re == 0 && x.im == 0) { + return new type.Complex(HALF_PI, Infinity); + } + + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re = x.re / den, + x.im = -x.im / den) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0); + + return complexAsin(x); + } + + return acsc; + } + + exports.name = 'acsc'; + exports.factory = factory; + + +/***/ }, +/* 148 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAcsch = __webpack_require__(48).acosh_asinh_asech_acsch; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var asinh = load(__webpack_require__(152)).signatures['Complex']; + + /** + * Calculate the hyperbolic arccosecant of a value, + * defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.acsch(x) + * + * Examples: + * + * math.acsch(0.5); // returns 1.4436354751788103 + * + * See also: + * + * asech, acoth + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arccosecant of x + */ + var acsch = typed('acsch', { + 'number': function (x) { + x = 1 / x; + return Math.log(x + Math.sqrt(x*x + 1)); + }, + + 'Complex': function (x) { + if (x.im == 0) { + x = (x.re != 0) + ? Math.log(x.re + Math.sqrt(x.re*x.re + 1)) + : Infinity; + return new type.Complex(x, 0); + } + + // acsch(z) = -i*asinh(1/z) + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re / den, + -x.im / den + ) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0 + ); + + return asinh(x); + }, + + 'BigNumber': function (x) { + return bigAcsch(x, type.BigNumber, true, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, acsch); + } + }); + + return acsch; + } + + exports.name = 'acsch'; + exports.factory = factory; + + +/***/ }, +/* 149 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcSec = __webpack_require__(48).arccos_arcsec; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexAcos = load(__webpack_require__(143)).signatures['Complex']; + + /** + * Calculate the inverse secant of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asec(x) + * + * Examples: + * + * math.asec(0.5); // returns 1.0471975511965979 + * math.asec(math.sec(1.5)); // returns 1.5 + * + * math.asec(2); // returns 0 + 1.3169578969248166 i + * + * See also: + * + * acos, acot, acsc + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} The arc secant of x + */ + var asec = typed('asec', { + 'number': function (x) { + if (x <= -1 || x >= 1) { + return Math.acos(1 / x); + } + return _complexAsec(new type.Complex(x, 0)); + }, + + 'Complex': _complexAsec, + + 'BigNumber': function (x) { + return bigArcSec(x, type.BigNumber, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, asec); + } + }); + + /** + * Calculate asec for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAsec (x) { + if (x.re == 0 && x.im == 0) { + return new type.Complex(0, Infinity); + } + + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re = x.re / den, + x.im = -x.im / den) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0); + + return complexAcos(x); + } + + return asec; + } + + exports.name = 'asec'; + exports.factory = factory; + + +/***/ }, +/* 150 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAsech = __webpack_require__(48).acosh_asinh_asech_acsch; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var acosh = load(__webpack_require__(144)).signatures['Complex']; + + /** + * Calculate the hyperbolic arcsecant of a value, + * defined as `asech(x) = ln(sqrt(1/x^2 - 1) + 1/x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asech(x) + * + * Examples: + * + * math.asech(0.5); // returns 1.3169578969248166 + * + * See also: + * + * acsch, acoth + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arcsecant of x + */ + var asech = typed('asech', { + 'number': function (x) { + if (x <= 1 && x >= -1) { + x = 1 / x; + + var ret = Math.sqrt(x*x - 1); + if (x > 0) { + return Math.log(ret + x); + } + + return new type.Complex(Math.log(ret - x), Math.PI); + } + + return _complexAsech(new type.Complex(x, 0)); + }, + + 'Complex': _complexAsech, + + 'BigNumber': function (x) { + return bigAsech(x, type.BigNumber, false, true); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, asech); + } + }); + + /** + * Calculate the hyperbolic arcsecant of a number + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAsech (x) { + if (x.re == 0 && x.im == 0) { + return new type.Complex(Infinity, 0); + } + + // acsch(z) = -i*asinh(1/z) + var den = x.re*x.re + x.im*x.im; + x = (den != 0) + ? new type.Complex( + x.re / den, + -x.im / den + ) + : new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? -(x.im / 0) : 0 + ); + + return acosh(x); + } + + return asech; + } + + exports.name = 'asech'; + exports.factory = factory; + + +/***/ }, +/* 151 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcSin = __webpack_require__(48).arcsin_arccsc; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexSqrt = load(__webpack_require__(77)).signatures['Complex']; + var complexLog = load(__webpack_require__(68)).signatures['Complex']; + + /** + * Calculate the inverse sine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asin(x) + * + * Examples: + * + * math.asin(0.5); // returns Number 0.5235987755982989 + * math.asin(math.sin(1.5)); // returns Number ~1.5 + * + * math.asin(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * sin, atan, acos + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} The arc sine of x + */ + var asin = typed('asin', { + 'number': function (x) { + if (x >= -1 && x <= 1) { + return Math.asin(x); + } + else { + return _complexAsin(new type.Complex(x, 0)); + } + }, + + 'Complex': _complexAsin, + + 'BigNumber': function (x) { + return bigArcSin(x, type.BigNumber, false); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since asin(0) = 0 + return collection.deepMap(x, asin, true); + } + }); + + /** + * Calculate asin for a complex value + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAsin(x) { + // asin(z) = -i*log(iz + sqrt(1-z^2)) + var re = x.re; + var im = x.im; + var temp1 = new type.Complex( + im * im - re * re + 1.0, + -2.0 * re * im + ); + var temp2 = complexSqrt(temp1); + var temp3 = new type.Complex( + temp2.re - im, + temp2.im + re + ); + var temp4 = complexLog(temp3); + + return new type.Complex(temp4.im, -temp4.re); + } + + return asin; + } + + exports.name = 'asin'; + exports.factory = factory; + + +/***/ }, +/* 152 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAsinh = __webpack_require__(48).acosh_asinh_asech_acsch; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexAsin = load(__webpack_require__(151)).signatures['Complex']; + + /** + * Calculate the hyperbolic arcsine of a value, + * defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.asinh(x) + * + * Examples: + * + * math.asinh(0.5); // returns 0.48121182505960347 + * + * See also: + * + * acosh, atanh + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arcsine of x + */ + var asinh = typed('asinh', { + 'number': function (x) { + return Math.log(Math.sqrt(x*x + 1) + x); + }, + + 'Complex': function (x) { + // asinh(z) = (-asin((z.im, -z.re)).im, asin((z.im, -z.re)).re) + var temp = x.im; + x.im = -x.re; + x.re = temp; + + var res = complexAsin(x); + + // restore original values + x.re = -x.im; + x.im = temp; + + temp = res.re; + res.re = -res.im; + res.im = temp; + + return res; + }, + + 'BigNumber': function (x) { + return bigAsinh(x, type.BigNumber, true, false); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since asinh(0) = 0 + return collection.deepMap(x, asinh, true); + } + }); + + return asinh; + } + + exports.name = 'asinh'; + exports.factory = factory; + + +/***/ }, +/* 153 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigArcTan = __webpack_require__(48).arctan_arccot; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var complexLog = load(__webpack_require__(68)).signatures['Complex']; + + /** + * Calculate the inverse tangent of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atan(x) + * + * Examples: + * + * math.atan(0.5); // returns Number 0.4636476090008061 + * math.atan(math.tan(1.5)); // returns Number 1.5 + * + * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * tan, asin, acos + * + * @param {Number | BigNumber | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} The arc tangent of x + */ + var atan = typed('atan', { + 'number': function (x) { + return Math.atan(x); + }, + + 'Complex': function (x) { + if (x.re == 0) { + if (x.im == 1) { + return new type.Complex(0, Infinity); + } + if (x.im == -1) { + return new type.Complex(0, -Infinity); + } + } + + // atan(z) = 1/2 * i * (ln(1-iz) - ln(1+iz)) + var re = x.re; + var im = x.im; + var den = re * re + (1.0 - im) * (1.0 - im); + + var temp1 = new type.Complex( + (1.0 - im * im - re * re) / den, + (-2.0 * re) / den + ); + var temp2 = complexLog(temp1); + + return new type.Complex( + -0.5 * temp2.im, + 0.5 * temp2.re + ); + }, + + 'BigNumber': function (x) { + return bigArcTan(x, type.BigNumber, false); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since atan(0) = 0 + return collection.deepMap(x, atan, true); + } + }); + + return atan; + } + + exports.name = 'atan'; + exports.factory = factory; + + +/***/ }, +/* 154 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAtan2 = __webpack_require__(48).arctan2; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the inverse tangent function with two arguments, y/x. + * By providing two arguments, the right quadrant of the computed angle can be + * determined. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atan2(y, x) + * + * Examples: + * + * math.atan2(2, 2) / math.pi; // returns number 0.25 + * + * var angle = math.unit(60, 'deg'); // returns Unit 60 deg + * var x = math.cos(angle); + * var y = math.sin(angle); + * + * math.atan(2); // returns Complex 1.5707963267948966 -1.3169578969248166 i + * + * See also: + * + * tan, atan, sin, cos + * + * @param {Number | Boolean | Array | Matrix | null} y Second dimension + * @param {Number | Boolean | Array | Matrix | null} x First dimension + * @return {Number | Array | Matrix} Four-quadrant inverse tangent + */ + var atan2 = typed('atan2', { + 'number, number': Math.atan2, + + // TODO: implement atan2 for complex numbers + + 'BigNumber, BigNumber': function (y, x) { + return bigAtan2(y, x, type.BigNumber); + }, + + 'Array | Matrix, any': function (y, x) { + return collection.deepMap2(y, x, atan2); + }, + + 'any, Array | Matrix': function (y, x) { + return collection.deepMap2(y, x, atan2); + } + }); + + return atan2; + } + + exports.name = 'atan2'; + exports.factory = factory; + + +/***/ }, +/* 155 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigAtanh = __webpack_require__(48).atanh_acoth; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic arctangent of a value, + * defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.atanh(x) + * + * Examples: + * + * math.atanh(0.5); // returns 0.5493061443340549 + * + * See also: + * + * acosh, asinh + * + * @param {Number | Boolean | Complex | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic arctangent of x + */ + var atanh = typed('atanh', { + 'number': function (x) { + if (x <= 1 && x >= -1) { + return Math.log((1 + x)/(1 - x)) / 2; + } + return _complexAtanh(new type.Complex(x, 0)); + }, + + 'Complex': _complexAtanh, + + 'BigNumber': function (x) { + return bigAtanh(x, type.BigNumber, false); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since atanh(0) = 0 + return collection.deepMap(x, atanh, true); + } + }); + + /** + * Calculate the hyperbolic arctangent of a complex number + * @param {Complex} x + * @returns {Complex} + * @private + */ + function _complexAtanh (x) { + // x.im should equal -pi / 2 in this case + var noIM = x.re > 1 && x.im == 0; + + var oneMinus = 1 - x.re; + var onePlus = 1 + x.re; + var den = oneMinus*oneMinus + x.im*x.im; + x = (den != 0) + ? new type.Complex( + (onePlus*oneMinus - x.im*x.im) / den, + (x.im*oneMinus + onePlus*x.im) / den + ) + : new type.Complex( + (x.re != -1) ? (x.re / 0) : 0, + (x.im != 0) ? (x.im / 0) : 0 + ); + + var temp = x.re; + x.re = Math.log(Math.sqrt(x.re*x.re + x.im*x.im)) / 2; + x.im = Math.atan2(x.im, temp) / 2; + + if (noIM) { + x.im = -x.im; + } + return x; + } + + return atanh; + } + + exports.name = 'atanh'; + exports.factory = factory; + + +/***/ }, +/* 156 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCos = __webpack_require__(48).cos_sin_sec_csc; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var cosh = load(__webpack_require__(157)).signatures['number']; + var sinh = load(__webpack_require__(165)).signatures['number']; + + /** + * Calculate the cosine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cos(x) + * + * Examples: + * + * math.cos(2); // returns Number -0.4161468365471422 + * math.cos(math.pi / 4); // returns Number 0.7071067811865475 + * math.cos(math.unit(180, 'deg')); // returns Number -1 + * math.cos(math.unit(60, 'deg')); // returns Number 0.5 + * + * var angle = 0.2; + * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns Number ~1 + * + * See also: + * + * cos, tan + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Cosine of x + */ + var cos = typed('cos', { + 'number': Math.cos, + + 'Complex': function (x) { + // cos(z) = (exp(iz) + exp(-iz)) / 2 + return new type.Complex( + Math.cos(x.re) * cosh(-x.im), + Math.sin(x.re) * sinh(-x.im) + ); + }, + + 'BigNumber': function (x) { + return bigCos(x, type.BigNumber, 0, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cos is no angle'); + } + return Math.cos(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, cos); + } + }); + + return cos; + } + + exports.name = 'cos'; + exports.factory = factory; + + +/***/ }, +/* 157 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCosh = __webpack_require__(48).cosh_sinh_csch_sech; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic cosine of a value, + * defined as `cosh(x) = 1/2 * (exp(x) + exp(-x))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cosh(x) + * + * Examples: + * + * math.cosh(0.5); // returns Number 1.1276259652063807 + * + * See also: + * + * sinh, tanh + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic cosine of x + */ + var cosh = typed('cosh', { + 'number': _cosh, + + 'Complex': function (x) { + var ep = Math.exp(x.re); + var en = Math.exp(-x.re); + return new type.Complex(Math.cos(x.im) * (ep + en) / 2, Math.sin(x.im) * (ep - en) / 2); + }, + + 'BigNumber': function (x) { + return bigCosh(x, type.BigNumber, false, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cosh is no angle'); + } + return _cosh(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, cosh); + } + }); + + return cosh; + } + + /** + * Calculate the hyperbolic cosine of a number + * @param {number} x + * @returns {number} + * @private + */ + function _cosh(x) { + return (Math.exp(x) + Math.exp(-x)) / 2; + } + + exports.name = 'cosh'; + exports.factory = factory; + + +/***/ }, +/* 158 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCot = __webpack_require__(48).tan_cot; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the cotangent of a value. `cot(x)` is defined as `1 / tan(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.cot(x) + * + * Examples: + * + * math.cot(2); // returns Number -0.45765755436028577 + * 1 / math.tan(2); // returns Number -0.45765755436028577 + * + * See also: + * + * tan, sec, csc + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Cotangent of x + */ + var cot = typed('cot', { + 'number': function (x) { + return 1 / Math.tan(x); + }, + + 'Complex': function (x) { + var den = + Math.exp(-4 * x.im) - + 2 * Math.exp(-2 * x.im) * Math.cos(2 * x.re) + 1; + + return new type.Complex( + 2 * Math.exp(-2 * x.im) * Math.sin(2 * x.re) / den, + (Math.exp(-4 * x.im) - 1) / den + ); + }, + + 'BigNumber': function (x) { + return bigCot(x, type.BigNumber, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function cot is no angle'); + } + return 1 / Math.tan(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, cot); + } + }); + + return cot; + } + + exports.name = 'cot'; + exports.factory = factory; + + +/***/ }, +/* 159 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCoth = __webpack_require__(48).tanh_coth; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic cotangent of a value, + * defined as `coth(x) = 1 / tanh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.coth(x) + * + * Examples: + * + * // coth(x) = 1 / tanh(x) + * math.coth(2); // returns 1.0373147207275482 + * 1 / math.tanh(2); // returns 1.0373147207275482 + * + * See also: + * + * sinh, tanh, cosh + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic cotangent of x + */ + var coth = typed('coth', { + 'number': _coth, + + 'Complex': function (x) { + var r = Math.exp(2 * x.re); + var re = r * Math.cos(2 * x.im); + var im = r * Math.sin(2 * x.im); + var den = (re - 1) * (re - 1) + im * im; + return new type.Complex( + ((re + 1) * (re - 1) + im * im) / den, + -2 * im / den + ); + }, + + 'BigNumber': function (x) { + return bigCoth(x, type.BigNumber, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function coth is no angle'); + } + return _coth(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, coth); + } + }); + + return coth; + } + + /** + * Calculate the hyperbolic cosine of a number + * @param {number} x + * @returns {number} + * @private + */ + function _coth(x) { + var e = Math.exp(2 * x); + return (e + 1) / (e - 1); + } + + exports.name = 'coth'; + exports.factory = factory; + + +/***/ }, +/* 160 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCsc = __webpack_require__(48).cos_sin_sec_csc; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the cosecant of a value, defined as `csc(x) = 1/sin(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.csc(x) + * + * Examples: + * + * math.csc(2); // returns Number 1.099750170294617 + * 1 / math.sin(2); // returns Number 1.099750170294617 + * + * See also: + * + * sin, sec, cot + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Cosecant of x + */ + var csc = typed('csc', { + 'number': function (x) { + return 1 / Math.sin(x); + }, + + 'Complex': function (x) { + // csc(z) = 1/sin(z) = (2i) / (exp(iz) - exp(-iz)) + var den = + 0.25 * (Math.exp(-2 * x.im) + Math.exp(2 * x.im)) - + 0.5 * Math.cos(2 * x.re); + + return new type.Complex ( + 0.5 * Math.sin(x.re) * (Math.exp(-x.im) + Math.exp(x.im)) / den, + 0.5 * Math.cos(x.re) * (Math.exp(-x.im) - Math.exp(x.im)) / den + ); + }, + + 'BigNumber': function (x) { + return bigCsc(x, type.BigNumber, 1, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function csc is no angle'); + } + return 1 / Math.sin(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, csc); + } + }); + + return csc; + } + + exports.name = 'csc'; + exports.factory = factory; + + +/***/ }, +/* 161 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigCsch = __webpack_require__(48).cosh_sinh_csch_sech; + var sign = __webpack_require__(41).sign; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic cosecant of a value, + * defined as `csch(x) = 1 / sinh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.csch(x) + * + * Examples: + * + * // csch(x) = 1/ sinh(x) + * math.csch(0.5); // returns 1.9190347513349437 + * 1 / math.sinh(0.5); // returns 1.9190347513349437 + * + * See also: + * + * sinh, sech, coth + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic cosecant of x + */ + var csch = typed('csch', { + 'number': _csch, + + 'Complex': function (x) { + var ep = Math.exp(x.re); + var en = Math.exp(-x.re); + var re = Math.cos(x.im) * (ep - en); + var im = Math.sin(x.im) * (ep + en); + var den = re * re + im * im; + return new type.Complex(2 * re / den, -2 * im /den); + }, + + 'BigNumber': function (x) { + return bigCsch(x, type.BigNumber, true, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function csch is no angle'); + } + return _csch(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, csch); + } + }); + + return csch; + } + + /** + * Calculate the hyperbolic cosecant of a number + * @param {number} x + * @returns {number} + * @private + */ + function _csch(x) { + // consider values close to zero (+/-) + if (x == 0) { + return Number.POSITIVE_INFINITY; + } + else { + return Math.abs(2 / (Math.exp(x) - Math.exp(-x))) * sign(x); + } + } + + exports.name = 'csch'; + exports.factory = factory; + + +/***/ }, +/* 162 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigSec = __webpack_require__(48).cos_sin_sec_csc; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the secant of a value, defined as `sec(x) = 1/cos(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sec(x) + * + * Examples: + * + * math.sec(2); // returns Number -2.4029979617223822 + * 1 / math.cos(2); // returns Number -2.4029979617223822 + * + * See also: + * + * cos, csc, cot + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Secant of x + */ + var sec = typed('sec', { + 'number': function (x) { + return 1 / Math.cos(x); + }, + + 'Complex': function (x) { + // sec(z) = 1/cos(z) = 2 / (exp(iz) + exp(-iz)) + var den = + 0.25 * (Math.exp(-2 * x.im) + Math.exp(2 * x.im)) + + 0.5 * Math.cos(2 * x.re); + + return new type.Complex( + 0.5 * Math.cos(x.re) * (Math.exp(-x.im) + Math.exp( x.im)) / den, + 0.5 * Math.sin(x.re) * (Math.exp( x.im) - Math.exp(-x.im)) / den + ); + }, + + 'BigNumber': function (x) { + return bigSec(x, type.BigNumber, 0, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sec is no angle'); + } + return 1 / Math.cos(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, sec); + } + }); + + return sec; + } + + exports.name = 'sec'; + exports.factory = factory; + + +/***/ }, +/* 163 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigSech = __webpack_require__(48).cosh_sinh_csch_sech; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic secant of a value, + * defined as `sech(x) = 1 / cosh(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sech(x) + * + * Examples: + * + * // sech(x) = 1/ cosh(x) + * math.sech(0.5); // returns 0.886818883970074 + * 1 / math.cosh(0.5); // returns 0.886818883970074 + * + * See also: + * + * cosh, csch, coth + * + * @param {Number | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | Complex | Array | Matrix} Hyperbolic secant of x + */ + var sech = typed('sech', { + 'number': _sech, + + 'Complex': function (x) { + var ep = Math.exp(x.re); + var en = Math.exp(-x.re); + var re = Math.cos(x.im) * (ep + en); + var im = Math.sin(x.im) * (ep - en); + var den = re * re + im * im; + return new type.Complex(2 * re / den, -2 * im / den); + }, + + 'BigNumber': function (x) { + return bigSech(x, type.BigNumber, false, true); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sech is no angle'); + } + return _sech(x.value); + }, + + 'Array | Matrix': function (x) { + return collection.deepMap(x, sech); + } + }); + + return sech; + } + + /** + * Calculate the hyperbolic secant of a number + * @param {number} x + * @returns {number} + * @private + */ + function _sech(x) { + return 2 / (Math.exp(x) + Math.exp(-x)); + } + + exports.name = 'sech'; + exports.factory = factory; + + +/***/ }, +/* 164 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigSin = __webpack_require__(48).cos_sin_sec_csc; + + function factory (type, config, load, typed) { + var cosh = load(__webpack_require__(157)).signatures['number']; + var sinh = load(__webpack_require__(165)).signatures['number']; + var collection = load(__webpack_require__(2)); + + /** + * Calculate the sine of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sin(x) + * + * Examples: + * + * math.sin(2); // returns Number 0.9092974268256813 + * math.sin(math.pi / 4); // returns Number 0.7071067811865475 + * math.sin(math.unit(90, 'deg')); // returns Number 1 + * math.sin(math.unit(30, 'deg')); // returns Number 0.5 + * + * var angle = 0.2; + * math.pow(math.sin(angle), 2) + math.pow(math.cos(angle), 2); // returns Number ~1 + * + * See also: + * + * cos, tan + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Sine of x + */ + var sin = typed('sin', { + 'number': Math.sin, + + 'Complex': function (x) { + return new type.Complex( + Math.sin(x.re) * cosh(-x.im), + Math.cos(x.re) * sinh(x.im) + ); + }, + + 'BigNumber': function (x) { + return bigSin(x, type.BigNumber, 1, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sin is no angle'); + } + return Math.sin(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sin(0) = 0 + return collection.deepMap(x, sin, true); + } + }); + + return sin; + } + + exports.name = 'sin'; + exports.factory = factory; + + +/***/ }, +/* 165 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigSinh = __webpack_require__(48).cosh_sinh_csch_sech; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic sine of a value, + * defined as `sinh(x) = 1/2 * (exp(x) - exp(-x))`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.sinh(x) + * + * Examples: + * + * math.sinh(0.5); // returns Number 0.5210953054937474 + * + * See also: + * + * cosh, tanh + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic sine of x + */ + var sinh = typed('sinh', { + 'number': _sinh, + + 'Complex': function (x) { + var cim = Math.cos(x.im); + var sim = Math.sin(x.im); + var ep = Math.exp(x.re); + var en = Math.exp(-x.re); + return new type.Complex(cim * (ep - en) / 2, sim * (ep + en) / 2); + }, + + 'BigNumber': function (x) { + return bigSinh(x, type.BigNumber, true, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function sinh is no angle'); + } + return _sinh(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since sinh(0) = 0 + return collection.deepMap(x, sinh, true); + } + }); + + return sinh; + } + + /** + * Calculate the hyperbolic sine of a number + * @param {number} x + * @returns {number} + * @private + */ + function _sinh (x) { + if (Math.abs(x) < 1) { + return x + (x * x * x) / 6 + (x * x * x * x * x) / 120; + } else { + return (Math.exp(x) - Math.exp(-x)) / 2; + } + } + + exports.name = 'sinh'; + exports.factory = factory; + + +/***/ }, +/* 166 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigTan = __webpack_require__(48).tan_cot; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the tangent of a value. `tan(x)` is equal to `sin(x) / cos(x)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.tan(x) + * + * Examples: + * + * math.tan(0.5); // returns Number 0.5463024898437905 + * math.sin(0.5) / math.cos(0.5); // returns Number 0.5463024898437905 + * math.tan(math.pi / 4); // returns Number 1 + * math.tan(math.unit(45, 'deg')); // returns Number 1 + * + * See also: + * + * atan, sin, cos + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Tangent of x + */ + var tan = typed('tan', { + 'number': Math.tan, + + 'Complex': function (x) { + var den = + Math.exp(-4 * x.im) + + 2 * Math.exp(-2 * x.im) * Math.cos(2 * x.re) + + 1; + + return new type.Complex( + 2 * Math.exp(-2 * x.im) * Math.sin(2 * x.re) / den, + (1 - Math.exp(-4 * x.im)) / den + ); + }, + + 'BigNumber': function (x) { + return bigTan(x, type.BigNumber, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function tan is no angle'); + } + return Math.tan(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since tan(0) = 0 + return collection.deepMap(x, tan, true); + } + }); + + return tan; + } + + exports.name = 'tan'; + exports.factory = factory; + + +/***/ }, +/* 167 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var bigTanh = __webpack_require__(48).tanh_coth; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Calculate the hyperbolic tangent of a value, + * defined as `tanh(x) = (exp(2 * x) - 1) / (exp(2 * x) + 1)`. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.tanh(x) + * + * Examples: + * + * // tanh(x) = sinh(x) / cosh(x) = 1 / coth(x) + * math.tanh(0.5); // returns 0.46211715726000974 + * math.sinh(0.5) / math.cosh(0.5); // returns 0.46211715726000974 + * 1 / math.coth(0.5); // returns 0.46211715726000974 + * + * See also: + * + * sinh, cosh, coth + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x Function input + * @return {Number | BigNumber | Complex | Array | Matrix} Hyperbolic tangent of x + */ + var tanh = typed('tanh', { + 'number': _tanh, + + 'Complex': function (x) { + var r = Math.exp(2 * x.re); + var re = r * Math.cos(2 * x.im); + var im = r * Math.sin(2 * x.im); + var den = (re + 1) * (re + 1) + im * im; + return new type.Complex( + ((re - 1) * (re + 1) + im * im) / den, + im * 2 / den + ); + }, + + 'BigNumber': function (x) { + return bigTanh(x, type.BigNumber, false); + }, + + 'Unit': function (x) { + if (!x.hasBase(type.Unit.BASE_UNITS.ANGLE)) { + throw new TypeError ('Unit in function tanh is no angle'); + } + return _tanh(x.value); + }, + + 'Array | Matrix': function (x) { + // deep map collection, skip zeros since tanh(0) = 0 + return collection.deepMap(x, tanh, true); + } + }); + + return tanh; + } + + /** + * Calculate the hyperbolic tangent of a number + * @param {number} x + * @returns {number} + * @private + */ + function _tanh (x) { + var e = Math.exp(2 * x); + return (e - 1) / (e + 1); + } + + exports.name = 'tanh'; + exports.factory = factory; + + +/***/ }, +/* 168 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Compare two values. Returns 1 when x > y, -1 when x < y, and 0 when x == y. + * + * x and y are considered equal when the relative difference between x and y + * is smaller than the configured epsilon. The function cannot be used to + * compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.compare(x, y) + * + * Examples: + * + * math.compare(6, 1); // returns 1 + * math.compare(2, 3); // returns -1 + * math.compare(7, 7); // returns 0 + * + * var a = math.unit('5 cm'); + * var b = math.unit('40 mm'); + * math.compare(a, b); // returns 1 + * + * math.compare(2, [1, 2, 3]); // returns [1, 0, -1] + * + * See also: + * + * equal, unequal, smaller, smallerEq, larger, largerEq + * + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare + * @return {Number | BigNumber | Array | Matrix} Returns the result of the comparison: 1, 0 or -1. + */ + var compare = typed('compare', { + 'boolean, boolean': function (x, y) { + return x === y ? 0 : (x > y ? 1 : -1); + }, + + 'number, number': function (x, y) { + return (x === y || nearlyEqual(x, y, config.epsilon)) ? 0 : (x > y ? 1 : -1); + }, + + 'BigNumber, BigNumber': function (x, y) { + return new x.constructor(x.cmp(y)); + }, + + 'Complex, Complex': function (x, y) { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return (x.value === y.value || nearlyEqual(x.value, y.value, config.epsilon)) ? 0 : (x.value > y.value ? 1 : -1); + }, + + 'string, string': function (x, y) { + return x === y ? 0 : (x > y ? 1 : -1); + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, compare); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, compare); + } + }); + + return compare; + } + + exports.name = 'compare'; + exports.factory = factory; + + +/***/ }, +/* 169 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var equal = load(__webpack_require__(46)); + + /** + * Test element wise whether two matrices are equal. + * The function accepts both matrices and scalar values. + * + * Syntax: + * + * math.deepEqual(x, y) + * + * Examples: + * + * math.deepEqual(2, 4); // returns false + * + * a = [2, 5, 1]; + * b = [2, 7, 1]; + * + * math.deepEqual(a, b); // returns false + * math.equal(a, b); // returns [true, false, true] + * + * See also: + * + * equal, unequal + * + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} x First matrix to compare + * @param {Number | BigNumber | Boolean | Complex | Unit | Array | Matrix | null} y Second matrix to compare + * @return {Number | BigNumber | Complex | Unit | Array | Matrix} + * Returns true when the input matrices have the same size and each of their elements is equal. + */ + return typed('deepEqual', { + 'any, any': function (x, y) { + return _deepEqual(x.valueOf(), y.valueOf()); + } + }); + + /** + * Test whether two arrays have the same size and all elements are equal + * @param {Array | *} x + * @param {Array | *} y + * @return {boolean} Returns true if both arrays are deep equal + */ + function _deepEqual(x, y) { + if (Array.isArray(x)) { + if (Array.isArray(y)) { + var len = x.length; + if (len !== y.length) { + return false; + } + + for (var i = 0; i < len; i++) { + if (!_deepEqual(x[i], y[i])) { + return false; + } + } + + return true; + } + else { + return false; + } + } + else { + if (Array.isArray(y)) { + return false; + } + else { + return equal(x, y); + } + } + } + } + + exports.name = 'deepEqual'; + exports.factory = factory; + + +/***/ }, +/* 170 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Test whether value x is larger or equal to y. + * + * The function returns true when x is larger than y or the relative + * difference between x and y is smaller than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.largerEq(x, y) + * + * Examples: + * + * math.larger(2, 1 + 1); // returns false + * math.largerEq(2, 1 + 1); // returns true + * + * See also: + * + * equal, unequal, smaller, smallerEq, larger, compare + * + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the x is larger or equal to y, else returns false + */ + var largerEq = typed('largerEq', { + 'boolean, boolean': function (x, y) { + return x >= y; + }, + + 'number, number': function (x, y) { + return x >= y || nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.gte(y); + }, + + 'Complex, Complex': function (x, y) { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return x.value >= y.value || nearlyEqual(x.value, y.value, config.epsilon); + }, + + 'string, string': function (x, y) { + return x >= y; + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, largerEq); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, largerEq); + } + }); + + return largerEq; + } + + exports.name = 'largerEq'; + exports.factory = factory; + + +/***/ }, +/* 171 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Test whether value x is smaller or equal to y. + * + * The function returns true when x is smaller than y or the relative + * difference between x and y is smaller than the configured epsilon. The + * function cannot be used to compare values smaller than approximately 2.22e-16. + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.smallerEq(x, y) + * + * Examples: + * + * math.smaller(1 + 2, 3); // returns false + * math.smallerEq(1 + 2, 3); // returns true + * + * See also: + * + * equal, unequal, smaller, larger, largerEq, compare + * + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} x First value to compare + * @param {Number | BigNumber | Boolean | Unit | String | Array | Matrix | null} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the x is smaller than y, else returns false + */ + var smallerEq = typed('smallerEq', { + 'boolean, boolean': function (x, y) { + return x <= y; + }, + + 'number, number': function (x, y) { + return x <= y || nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.lte(y); + }, + + 'Complex, Complex': function (x, y) { + throw new TypeError('No ordering relation is defined for complex numbers'); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return x.value <= y.value || nearlyEqual(x.value, y.value, config.epsilon); + }, + + 'string, string': function (x, y) { + return x <= y; + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, smallerEq); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, smallerEq); + } + }); + + return smallerEq; + } + + exports.name = 'smallerEq'; + exports.factory = factory; + + +/***/ }, +/* 172 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var nearlyEqual = __webpack_require__(41).nearlyEqual; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Test whether two values are unequal. + * + * The function tests whether the relative difference between x and y is + * larger than the configured epsilon. The function cannot be used to compare + * values smaller than approximately 2.22e-16. + * + * For matrices, the function is evaluated element wise. + * In case of complex numbers, x.re must unequal y.re, or x.im must unequal y.im. + * + * Values `null` and `undefined` are compared strictly, thus `null` is unequal + * with everything except `null`, and `undefined` is unequal with everying + * except. `undefined`. + * + * Syntax: + * + * math.unequal(x, y) + * + * Examples: + * + * math.unequal(2 + 2, 3); // returns true + * math.unequal(2 + 2, 4); // returns false + * + * var a = math.unit('50 cm'); + * var b = math.unit('5 m'); + * math.unequal(a, b); // returns false + * + * var c = [2, 5, 1]; + * var d = [2, 7, 1]; + * + * math.unequal(c, d); // returns [false, true, false] + * math.deepEqual(c, d); // returns false + * + * math.unequal(0, null); // returns true + * See also: + * + * equal, deepEqual, smaller, smallerEq, larger, largerEq, compare + * + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} x First value to compare + * @param {Number | BigNumber | Boolean | Complex | Unit | String | Array | Matrix | null | undefined} y Second value to compare + * @return {Boolean | Array | Matrix} Returns true when the compared values are unequal, else returns false + */ + var unequal = typed('unequal', { + 'any, any': function (x, y) { + // strict equality for null and undefined? + if (x === null) { return y !== null; } + if (y === null) { return x !== null; } + if (x === undefined) { return y !== undefined; } + if (y === undefined) { return x !== undefined; } + + return _unequal(x, y); + }, + + 'Array | Matrix, any': function (x, y) { + return collection.deepMap2(x, y, _unequal); + }, + + 'any, Array | Matrix': function (x, y) { + return collection.deepMap2(x, y, _unequal); + } + }); + + var _unequal = typed('_unequal', { + 'boolean, boolean': function (x, y) { + return x !== y; + }, + + 'number, number': function (x, y) { + return !nearlyEqual(x, y, config.epsilon); + }, + + 'BigNumber, BigNumber': function (x, y) { + return !x.eq(y); + }, + + 'Complex, Complex': function (x, y) { + return !nearlyEqual(x.re, y.re, config.epsilon) || + !nearlyEqual(x.im, y.im, config.epsilon); + }, + + 'Unit, Unit': function (x, y) { + if (!x.equalBase(y)) { + throw new Error('Cannot compare units with different base'); + } + return !nearlyEqual(x.value, y.value, config.epsilon); + }, + + 'string, string': function (x, y) { + return x !== y; + } + }); + + return unequal; + } + + exports.name = 'unequal'; + exports.factory = factory; + + +/***/ }, +/* 173 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + + /** + * Change the unit of a value. + * + * For matrices, the function is evaluated element wise. + * + * Syntax: + * + * math.to(x, unit) + * + * Examples: + * + * math.to(math.unit('2 inch'), 'cm'); // returns Unit 5.08 cm + * math.to(math.unit('2 inch'), math.unit(null, 'cm')); // returns Unit 5.08 cm + * math.to(math.unit(16, 'bytes'), 'bits'); // returns Unit 128 bits + * + * See also: + * + * unit + * + * @param {Unit | Array | Matrix} x The unit to be converted. + * @param {Unit | Array | Matrix} unit New unit. Can be a string like "cm" + * or a unit without value. + * @return {Unit | Array | Matrix} value with changed, fixed unit. + */ + var to = typed('to', { + 'Unit, Unit | string': function (x, unit) { + return x.to(unit); + }, + + 'Array | Matrix, any': function (x, unit) { + return collection.deepMap2(x, unit, to); + }, + + 'any, Array | Matrix': function (x, unit) { + return collection.deepMap2(x, unit, to); + } + }); + + return to; + } + + exports.name = 'to'; + exports.factory = factory; + + +/***/ }, +/* 174 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object= __webpack_require__(33); + + function factory (type, config, load, typed) { + /** + * Clone an object. + * + * Syntax: + * + * math.clone(x) + * + * Examples: + * + * math.clone(3.5); // returns number 3.5 + * math.clone(math.complex('2 - 4i'); // returns Complex 2 - 4i + * math.clone(math.unit(45, 'deg')); // returns Unit 45 deg + * math.clone([[1, 2], [3, 4]]); // returns Array [[1, 2], [3, 4]] + * math.clone("hello world"); // returns string "hello world" + * + * @param {*} x Object to be cloned + * @return {*} A clone of object x + */ + return typed('clone', { + 'any': object.clone + }); + } + + exports.name = 'clone'; + exports.factory = factory; + + +/***/ }, +/* 175 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var object = __webpack_require__(33); + + function factory (type, config, load, typed, math) { + /** + * Set configuration options for math.js, and get current options + * @param {Object} [options] Available options: + * {String} matrix + * A string 'matrix' (default) or 'array'. + * {String} number + * A string 'number' (default) or 'bignumber' + * {Number} precision + * The number of significant digits for BigNumbers. + * Not applicable for Numbers. + * @return {Object} Returns the current configuration + */ + return function _config(options) { + if (options) { + // merge options + object.deepExtend(config, options); + + // TODO: BigNumber should do this by itself, should register on an onChange handler of config + if (options.precision && type.BigNumber) { + type.BigNumber.config({ + precision: options.precision + }); + } + + // reload the constants (they depend on option number and precision) + // this must be done after math.type.BigNumber.config is applied + // TODO: this is an ugly solution, refreshing the constants like this + __webpack_require__(15).factory(type, config, load, typed, math); + } + + // return a clone of the settings + return object.clone(config); + }; + } + + exports.name = 'config'; + exports.math = true; // request the math namespace as fifth argument + exports.factory = factory; + + +/***/ }, +/* 176 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + + /** + * Sort the items in a matrix. + * + * Syntax: + * + * math.filter(x, test) + * + * Examples: + * + * function isPositive (x) { + * return x > 0; + * } + * math.filter([6, -2, -1, 4, 3], isPositive); // returns [6, 4, 3] + * + * math.filter(["23", "foo", "100", "55", "bar"], /[0-9]+/); // returns ["23", "100", "55"] + * + * See also: + * + * forEach, map, sort + * + * @param {Matrix | Array} x A one dimensional matrix or array to filter + * @param {function | RegExp} test + * A function or regular expression to test items. + * When `test` is a function, it must return a boolean. + * All entries for which `test` returns true are returned. + * @return {Matrix | Array} Returns the filtered matrix. + */ + return typed('filter', { + 'Array, function': _filterCallback, + + 'Array, RegExp': _filterRegExp, + + 'Matrix, function': function (x, test) { + return matrix(_filterCallback(x.toArray(), test)); + }, + + 'Matrix, RegExp': function (x, test) { + return matrix(_filterRegExp(x.toArray(), test)); + } + }); + } + + /** + * Filter values in a callback given a callback function + * @param {Array} x + * @param {function} callback + * @return {Array} Returns the filtered array + * @private + */ + function _filterCallback (x, callback) { + if (size(x).length !== 1) { + throw new Error('Only one dimensional matrices supported'); + } + + return x.filter(function (entry) { + return callback(entry); + }); + } + + /** + * Filter values in a callback given a regular expression + * @param {Array} x + * @param {function} regexp + * @return {Array} Returns the filtered array + * @private + */ + function _filterRegExp (x, regexp) { + if (size(x).length !== 1) { + throw new Error('Only one dimensional matrices supported'); + } + + return x.filter(function (entry) { + return regexp.test(entry); + }); + } + + exports.name = 'filter'; + exports.factory = factory; + + +/***/ }, +/* 177 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var string = __webpack_require__(42); + + function factory (type, config, load, typed) { + /** + * Format a value of any type into a string. + * + * Syntax: + * + * math.format(value) + * math.format(value, options) + * math.format(value, precision) + * math.format(value, fn) + * + * Where: + * + * - `value: *` + * The value to be formatted + * - `options: Object` + * An object with formatting options. Available options: + * - `notation: String` + * Number notation. Choose from: + * - 'fixed' + * Always use regular number notation. + * For example '123.40' and '14000000' + * - '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 exponential notation elsewhere. + * Lower bound is included, upper bound is excluded. + * For example '123.4' and '1.4e7'. + * - `precision: Number` + * A number between 0 and 16 to round the digits of the number. In case + * of notations 'exponential' and 'auto', `precision` defines the total + * number of significant digits returned and is undefined by default. + * In case of notation 'fixed', `precision` defines the number of + * significant digits after the decimal point, and is 0 by default. + * - `exponential: Object` + * An object containing two parameters, {Number} lower and {Number} upper, + * used by notation 'auto' to determine when to return exponential + * notation. Default values are `lower=1e-3` and `upper=1e5`. Only + * applicable for notation `auto`. + * - `fn: Function` + * A custom formatting function. Can be used to override the built-in notations. + * Function `fn` is called with `value` as parameter and must return a string. + * Is useful for example to format all values inside a matrix in a particular way. + * + * Examples: + * + * math.format(6.4); // returns '6.4' + * math.format(1240000); // returns '1.24e6' + * math.format(1/3); // returns '0.3333333333333333' + * math.format(1/3, 3); // returns '0.333' + * math.format(21385, 2); // returns '21000' + * math.format(12.071, {notation: 'fixed'}); // returns '12' + * math.format(2.3, {notation: 'fixed', precision: 2}); // returns '2.30' + * math.format(52.8, {notation: 'exponential'}); // returns '5.28e+1' + * + * See also: + * + * print + * + * @param {*} value Value to be stringified + * @param {Object | Function | Number} [options] Formatting options + * @return {String} The formatted value + */ + return typed('format', { + 'any': string.format, + 'any, Object | function | number': string.format + }); + } + + exports.name = 'format'; + exports.factory = factory; + + +/***/ }, +/* 178 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Create a new matrix or array with the results of the callback function executed on + * each entry of the matrix/array. + * + * Syntax: + * + * math.map(x, callback) + * + * Examples: + * + * math.map([1, 2, 3], function(value) { + * return value * value; + * }); // returns [1, 4, 9] + * + * See also: + * + * filter, forEach, sort + * + * @param {Matrix | Array} x The matrix to iterate on. + * @param {Function} callback The callback method is invoked with three + * parameters: the value of the element, the index + * of the element, and the matrix being traversed. + * @return {Matrix | array} Transformed map of x + */ + return typed('map', { + 'Array, function': _map, + + 'Matrix, function': function (x, callback) { + return x.map(callback); + } + }); + } + + /** + * Map for a multi dimensional array + * @param {Array} array + * @param {function} callback + * @return {Array} + * @private + */ + function _map (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + return value.map(function (child, i) { + // we create a copy of the index array and append the new index value + return recurse(child, index.concat(i)); + }); + } + else { + return callback(value, index, array); + } + }; + + return recurse(array, []); + } + + exports.name = 'map'; + exports.factory = factory; + + +/***/ }, +/* 179 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var isString = __webpack_require__(42).isString; + var format = __webpack_require__(42).format; + + function factory (type, config, load, typed) { + /** + * Interpolate values into a string template. + * + * Syntax: + * + * math.print(template, values) + * math.print(template, values, precision) + * + * Example usage: + * + * // the following outputs: 'Lucy is 5 years old' + * math.print('Lucy is $age years old', {age: 5}); + * + * // the following outputs: 'The value of pi is 3.141592654' + * math.print('The value of pi is $pi', {pi: math.pi}, 10); + * + * // the following outputs: 'hello Mary! The date is 2013-03-23' + * math.print('Hello $user.name! The date is $date', { + * user: { + * name: 'Mary', + * }, + * date: new Date(2013, 2, 23).toISOString().substring(0, 10) + * }); + * + * See also: + * + * format + * + * @param {String} template A string containing variable placeholders. + * @param {Object} values An object containing variables which will + * be filled in in the template. + * @param {Number} [precision] Number of digits to format numbers. + * If not provided, the value will not be rounded. + * @return {String} Interpolated string + */ + return typed ('print', { + 'string, Object': _print, + 'string, Object, number': _print + }); + } + + /** + * Interpolate values into a string template. + * @param {string} template + * @param {Object} values + * @param {number} [precision] + * @returns {string} Interpolated string + * @private + */ + function _print(template, values, precision) { + return template.replace(/\$([\w\.]+)/g, function (original, key) { + var keys = key.split('.'); + var value = values[keys.shift()]; + while (keys.length && value !== undefined) { + var k = keys.shift(); + value = k ? value[k] : value + '.'; + } + + if (value !== undefined) { + if (!isString(value)) { + return format(value, precision); + } + else { + return value; + } + } + + return original; + } + ); + } + + exports.name = 'print'; + exports.factory = factory; + + +/***/ }, +/* 180 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var size = __webpack_require__(37).size; + + function factory (type, config, load, typed) { + var matrix = load(__webpack_require__(40)); + var asc = load(__webpack_require__(168)); + var desc = function (a, b) { + return -asc(a, b); + }; + + /** + * Sort the items in a matrix. + * + * Syntax: + * + * math.sort(x) + * math.sort(x, compare) + * + * Examples: + * + * math.sort([5, 10, 1]); // returns [1, 5, 10] + * math.sort(['C', 'B', 'A', 'D']); // returns ['A', 'B', 'C', 'D'] + * + * function sortByLength (a, b) { + * return a.length - b.length; + * } + * math.sort(['Langdon', 'Tom', 'Sara'], sortByLength); // returns ['Tom', 'Sara', 'Langdon'] + * + * See also: + * + * filter, forEach, map + * + * @param {Matrix | Array} x A one dimensional matrix or array to sort + * @param {Function | 'asc' | 'desc'} [compare='asc'] + * An optional _comparator function. The function is called as + * `compare(a, b)`, and must return 1 when a > b, -1 when a < b, + * and 0 when a == b. + * @return {Matrix | Array} Returns the sorted matrix. + */ + return typed('sort', { + 'Array': function (x) { + _arrayIsVector(x); + return x.sort(asc); + }, + + 'Matrix': function (x) { + _matrixIsVector(x); + return matrix(x.toArray().sort(asc), x.storage()); + }, + + 'Array, function': function (x, _comparator) { + _arrayIsVector(x); + return x.sort(_comparator); + }, + + 'Matrix, function': function (x, _comparator) { + _matrixIsVector(x); + return matrix(x.toArray().sort(_comparator), x.storage()); + }, + + 'Array, string': function (x, order) { + _arrayIsVector(x); + return x.sort(_comparator(order)); + }, + + 'Matrix, string': function (x, order) { + _matrixIsVector(x); + return matrix(x.toArray().sort(_comparator(order)), x.storage()); + } + }); + + /** + * Get the comparator for given order ('asc' or 'desc') + * @param {'asc' | 'desc'} order + * @return {function} Returns a _comparator function + */ + function _comparator (order) { + if (order === 'asc') { + return asc; + } + else if (order === 'desc') { + return desc; + } + else { + throw new Error('String "asc" or "desc" expected'); + } + } + + /** + * Validate whether an array is one dimensional + * Throws an error when this is not the case + * @param {Array} array + * @private + */ + function _arrayIsVector (array) { + if (size(array).length !== 1) { + throw new Error('One dimensional array expected'); + } + } + + /** + * Validate whether a matrix is one dimensional + * Throws an error when this is not the case + * @param {Matrix} matrix + * @private + */ + function _matrixIsVector (matrix) { + if (matrix.size().length !== 1) { + throw new Error('One dimensional matrix expected'); + } + } + } + + exports.name = 'sort'; + exports.factory = factory; + + +/***/ }, +/* 181 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var types = __webpack_require__(189); + + function factory (type, config, load, typed) { + /** + * Determine the type of a variable. + * + * Function `typeof` recognizes the following types of objects: + * + * Object | Returns | Example + * ---------------------- | ------------- | ------------------------------------------ + * Array | `'array'` | `math.typeof ([1, 2, 3])` + * boolean | `'boolean'` | `math.typeof (true)` + * Date | `'date'` | `math.typeof (new Date())` + * null | `'null'` | `math.typeof(null)` + * number | `'number'` | `math.typeof(3.5)` + * Object | `'object'` | `math.typeof ({a: 2, b: 3})` + * RegExp | `'regexp'` | `math.typeof (/a regexp/)` + * string | `'string'` | `math.typeof ('hello world')` + * undefined | `'undefined'` | `math.typeof(undefined)` + * math.type.BigNumber | `'bignumber'` | `math.typeof (math.bignumber('2.3e500'))` + * math.type.Chain | `'chain'` | `math.typeof (math.chain(2))` + * math.type.Complex | `'complex'` | `math.typeof (math.complex(2, 3))` + * math.type.Help | `'help'` | `math.typeof (math.help('sqrt'))` + * math.type.Index | `'index'` | `math.typeof (math.index(1, 3))` + * math.type.Matrix | `'matrix'` | `math.typeof (math.matrix([[1,2], [3, 4]]))` + * math.type.Range | `'range'` | `math.typeof (math.range(0, 10))` + * math.type.Unit | `'unit'` | `math.typeof (math.unit('45 deg'))` + * + * Syntax: + * + * math.typeof(x) + * + * Examples: + * + * math.typeof(3.5); // returns 'number' + * math.typeof(math.complex('2 - 4i')); // returns 'complex' + * math.typeof(math.unit('45 deg')); // returns 'unit' + * math.typeof('hello world'); // returns 'string' + * + * @param {*} x The variable for which to test the type. + * @return {String} Lower case type, for example 'number', 'string', 'array'. + */ + return typed('_typeof', { + 'any': function (x) { + // JavaScript types + var t = types.type(x); + + // math.js types + if (t === 'object') { + if (x instanceof type.Complex) return 'complex'; + if (x instanceof type.Matrix) return 'matrix'; + if (x instanceof type.Unit) return 'unit'; + if (x instanceof type.Index) return 'index'; + if (x instanceof type.Range) return 'range'; + if (x instanceof type.Help) return 'help'; + + // the following types are different instances per math.js instance + if (x instanceof type.BigNumber) return 'bignumber'; + if (x instanceof type.Chain) return 'chain'; + } + + return t; + } + }); + } + + exports.name = 'typeof'; + exports.factory = factory; + + +/***/ }, +/* 182 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + /** + * Iterate over all elements of a matrix/array, and executes the given callback function. + * + * Syntax: + * + * math.forEach(x, callback) + * + * Examples: + * + * math.forEach([1, 2, 3], function(value) { + * console.log(value); + * }); + * // outputs 1, 2, 3 + * + * See also: + * + * filter, map, sort + * + * @param {Matrix | Array} x The matrix to iterate on. + * @param {Function} callback The callback function is invoked with three + * parameters: the value of the element, the index + * of the element, and the Matrix/array being traversed. + */ + return typed('forEach', { + 'Array, function': _forEach, + + 'Matrix, function': function (x, callback) { + return x.forEach(callback); + } + }); + } + + /** + * forEach for a multi dimensional array + * @param {Array} array + * @param {function} callback + * @private + */ + function _forEach (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + value.forEach(function (child, i) { + // we create a copy of the index array and append the new index value + recurse(child, index.concat(i)); + }); + } + else { + callback(value, index, array); + } + }; + recurse(array, []); + } + + exports.name = 'forEach'; + exports.factory = factory; + + +/***/ }, +/* 183 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(195), + __webpack_require__(196), + __webpack_require__(197), + __webpack_require__(198), + __webpack_require__(199), + __webpack_require__(201), + __webpack_require__(200), + __webpack_require__(203), + __webpack_require__(212), + __webpack_require__(202), + __webpack_require__(204), + __webpack_require__(205), + __webpack_require__(206) + ]; + + +/***/ }, +/* 184 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = [ + __webpack_require__(213), + __webpack_require__(214), + __webpack_require__(215), + __webpack_require__(216), + __webpack_require__(217), + __webpack_require__(218), + __webpack_require__(219), + __webpack_require__(220), + __webpack_require__(221), + __webpack_require__(222) + ]; + + +/***/ }, +/* 185 */ +/***/ function(module, exports, __webpack_require__) { + + function factory (type, config, load, typed) { + var docs = {}; + + + // constants + docs.e = __webpack_require__(223); + docs.E = __webpack_require__(223); + docs['false'] = __webpack_require__(224); + docs.i = __webpack_require__(225); + docs['Infinity'] = __webpack_require__(226); + docs.LN2 = __webpack_require__(227); + docs.LN10 = __webpack_require__(228); + docs.LOG2E = __webpack_require__(229); + docs.LOG10E = __webpack_require__(230); + docs.NaN = __webpack_require__(231); + docs['null'] = __webpack_require__(232); + docs.pi = __webpack_require__(233); + docs.PI = __webpack_require__(233); + docs.phi = __webpack_require__(234); + docs.SQRT1_2 = __webpack_require__(235); + docs.SQRT2 = __webpack_require__(236); + docs.tau = __webpack_require__(237); + docs['true'] = __webpack_require__(238); + docs.version = __webpack_require__(239); + + // functions - arithmetic + docs.abs = __webpack_require__(240); + docs.add = __webpack_require__(241); + docs.ceil = __webpack_require__(242); + docs.cube = __webpack_require__(243); + docs.divide = __webpack_require__(244); + docs.dotDivide = __webpack_require__(245); + docs.dotMultiply = __webpack_require__(246); + docs.dotPow = __webpack_require__(247); + docs.exp = __webpack_require__(248); + docs.fix = __webpack_require__(249); + docs.floor = __webpack_require__(250); + docs.gcd = __webpack_require__(251); + docs.lcm = __webpack_require__(252); + docs.log = __webpack_require__(253); + docs.log10 = __webpack_require__(254); + docs.mod = __webpack_require__(255); + docs.multiply = __webpack_require__(256); + docs.norm = __webpack_require__(257); + docs.nthRoot = __webpack_require__(258); + docs.pow = __webpack_require__(259); + docs.round = __webpack_require__(260); + docs.sign = __webpack_require__(261); + docs.sqrt = __webpack_require__(262); + docs.square = __webpack_require__(263); + docs.subtract = __webpack_require__(264); + docs.unaryMinus = __webpack_require__(265); + docs.unaryPlus = __webpack_require__(266); + docs.xgcd = __webpack_require__(267); + + // functions - bitwise + docs.bitAnd = __webpack_require__(268); + docs.bitNot = __webpack_require__(269); + docs.bitOr = __webpack_require__(270); + docs.bitXor = __webpack_require__(271); + docs.leftShift = __webpack_require__(272); + docs.rightArithShift = __webpack_require__(273); + docs.rightLogShift = __webpack_require__(274); + + // functions - complex + docs.arg = __webpack_require__(275); + docs.conj = __webpack_require__(276); + docs.re = __webpack_require__(277); + docs.im = __webpack_require__(278); + + // functions - construction + docs.bignumber = __webpack_require__(279); + docs['boolean'] = __webpack_require__(280); + docs.complex = __webpack_require__(281); + docs.index = __webpack_require__(282); + docs.matrix = __webpack_require__(283); + docs.number = __webpack_require__(284); + docs.sparse = __webpack_require__(285); + docs.string = __webpack_require__(286); + docs.unit = __webpack_require__(287); + + // functions - expression + docs['eval'] = __webpack_require__(288); + docs.help = __webpack_require__(289); + + // functions - logical + docs['and'] = __webpack_require__(290); + docs['not'] = __webpack_require__(291); + docs['or'] = __webpack_require__(292); + docs['xor'] = __webpack_require__(293); + + // functions - matrix + docs['concat'] = __webpack_require__(294); + docs.cross = __webpack_require__(295); + docs.det = __webpack_require__(296); + docs.diag = __webpack_require__(297); + docs.dot = __webpack_require__(298); + docs.eye = __webpack_require__(299); + docs.flatten = __webpack_require__(300); + docs.inv = __webpack_require__(301); + docs.ones = __webpack_require__(302); + docs.range = __webpack_require__(303); + docs.resize = __webpack_require__(304); + docs.size = __webpack_require__(305); + docs.squeeze = __webpack_require__(306); + docs.subset = __webpack_require__(307); + docs.trace = __webpack_require__(308); + docs.transpose = __webpack_require__(309); + docs.zeros = __webpack_require__(310); + + // functions - probability + docs.combinations = __webpack_require__(311); + //docs.distribution = require('./function/probability/distribution'); + docs.factorial = __webpack_require__(312); + docs.gamma = __webpack_require__(313); + docs.permutations = __webpack_require__(314); + docs.pickRandom = __webpack_require__(315); + docs.random = __webpack_require__(316); + docs.randomInt = __webpack_require__(317); + + // functions - relational + docs.compare = __webpack_require__(318); + docs.deepEqual = __webpack_require__(319); + docs['equal'] = __webpack_require__(320); + docs.larger = __webpack_require__(321); + docs.largerEq = __webpack_require__(322); + docs.smaller = __webpack_require__(323); + docs.smallerEq = __webpack_require__(324); + docs.unequal = __webpack_require__(325); + + // functions - statistics + docs.max = __webpack_require__(326); + docs.mean = __webpack_require__(327); + docs.median = __webpack_require__(328); + docs.min = __webpack_require__(329); + docs.prod = __webpack_require__(330); + docs.std = __webpack_require__(331); + docs.sum = __webpack_require__(332); + docs['var'] = __webpack_require__(333); + + // functions - trigonometry + docs.acos = __webpack_require__(334); + docs.acosh = __webpack_require__(335); + docs.acot = __webpack_require__(336); + docs.acoth = __webpack_require__(337); + docs.acsc = __webpack_require__(338); + docs.acsch = __webpack_require__(339); + docs.asec = __webpack_require__(340); + docs.asech = __webpack_require__(341); + docs.asin = __webpack_require__(342); + docs.asinh = __webpack_require__(343); + docs.atan = __webpack_require__(344); + docs.atanh = __webpack_require__(345); + docs.atan2 = __webpack_require__(346); + docs.cos = __webpack_require__(347); + docs.cosh = __webpack_require__(348); + docs.cot = __webpack_require__(349); + docs.coth = __webpack_require__(350); + docs.csc = __webpack_require__(351); + docs.csch = __webpack_require__(352); + docs.sec = __webpack_require__(353); + docs.sech = __webpack_require__(354); + docs.sin = __webpack_require__(355); + docs.sinh = __webpack_require__(356); + docs.tan = __webpack_require__(357); + docs.tanh = __webpack_require__(358); + + // functions - units + docs.to = __webpack_require__(359); + + // functions - utils + docs.clone = __webpack_require__(360); + docs.map = __webpack_require__(361); + docs.filter = __webpack_require__(362); + docs.forEach = __webpack_require__(363); + docs.format = __webpack_require__(364); + // docs.print = require('./function/utils/print'); // TODO: add documentation for print as soon as the parser supports objects. + docs['import'] = __webpack_require__(365); + docs.sort = __webpack_require__(366); + docs['typeof'] = __webpack_require__(367); + + return docs; + } + + exports.name = 'docs'; + exports.path = 'expression'; + exports.factory = factory; + + +/***/ }, +/* 186 */ +/***/ function(module, exports, __webpack_require__) { + + var map = { + "./clone": 174, + "./clone.js": 174, + "./config": 175, + "./config.js": 175, + "./filter": 176, + "./filter.js": 176, + "./forEach": 182, + "./forEach.js": 182, + "./format": 177, + "./format.js": 177, + "./import": 35, + "./import.js": 35, + "./index": 32, + "./index.js": 32, + "./map": 178, + "./map.js": 178, + "./print": 179, + "./print.js": 179, + "./sort": 180, + "./sort.js": 180, + "./typeof": 181, + "./typeof.js": 181 + }; + function webpackContext(req) { + return __webpack_require__(webpackContextResolve(req)); + }; + function webpackContextResolve(req) { + return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }()); + }; + webpackContext.keys = function webpackContextKeys() { + return Object.keys(map); + }; + webpackContext.resolve = webpackContextResolve; + module.exports = webpackContext; + webpackContext.id = 186; + + +/***/ }, +/* 187 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Test whether value is a boolean + * @param {*} value + * @return {boolean} isBoolean + */ + exports.isBoolean = function(value) { + return typeof value == 'boolean'; + }; + + +/***/ }, +/* 188 */ +/***/ function(module, exports, __webpack_require__) { + + // function utils + + /* + * Memoize a given function by caching the computed result. + * The cache of a memoized function can be cleared by deleting the `cache` + * property of the function. + * + * @param {function} fn The function to be memoized. Must be a pure function. + * @return {function} Returns the memoized function + */ + exports.memoize = function(fn) { + return function memoize() { + if (typeof memoize.cache !== 'object') { + memoize.cache = {}; + } + + var hash = JSON.stringify(arguments); + if (!(hash in memoize.cache)) { + return memoize.cache[hash] = fn.apply(fn, arguments); + } + return memoize.cache[hash]; + }; + }; + + +/***/ }, +/* 189 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; @@ -27875,3587 +25838,220 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 217 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var divideScalar = load(__webpack_require__(213)); - var multiply = load(__webpack_require__(47)); - var subtract = load(__webpack_require__(55)); - var equal = load(__webpack_require__(115)); - - var substitutionValidation = load(__webpack_require__(356)); - - var SparseMatrix = type.SparseMatrix; - var DenseMatrix = type.DenseMatrix; - - /** - * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. - * - * M * x = b - * - * @param {Matrix, Array} A N x N matrix or array - * @param {Matrix, Array} A column vector with the b values - * - * @return {Matrix} A column vector with the linear system solution - */ - var backwardSubstitution = typed('backwardSubstitution', { - 'Matrix, Array | Matrix': function (m, b) { - // process matrix storage format - switch (m.storage()) { - case 'dense': - return _denseBackwardSubstitution(m, b); - case 'sparse': - return _sparseBackwardSubstitution(m, b); - } - }, - 'Array, Array | Matrix': function (a, b) { - // create dense matrix from array - var m = matrix(a); - // use matrix implementation - var r = backwardSubstitution(m, b); - // result - return r.valueOf(); - } - }); - - var _denseBackwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = substitutionValidation(m, b); - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // result - var x = new Array(rows); - // arrays - var data = m._data; - // backward solve m * x = b, loop columns (backwards) - for (var j = columns - 1; j >= 0 ; j--) { - // b[j] - var bj = b[j] || 0; - // x[j] - var xj; - // backward substitution (outer product) avoids inner looping when bj == 0 - if (!equal(bj, 0)) { - // value @ [j, j] - var vjj = data[j][j]; - // check vjj - if (equal(vjj, 0)) { - // system cannot be solved - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - xj = divideScalar(bj, vjj); - // loop rows - for (var i = j - 1; i >= 0; i--) { - // update copy of b - b[i] = subtract(b[i] || 0, multiply(xj, data[i][j])); - } - } - else { - // zero value @ j - xj = 0; - } - // update x - x[j] = [xj]; - } - // return column vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - var _sparseBackwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = substitutionValidation(m, b); - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // result arrays - var xvalues = []; - var xindex = []; - var xptr = []; - // vars - var i, k; - // init ptr - xptr.push(0); - // backward solve m * x = b, loop columns (backwards) - for (var j = columns - 1; j >= 0 ; j--) { - // b[j] - var bj = b[j] || 0; - // backward substitution (outer product) avoids inner looping when bj == 0 - if (!equal(bj, 0)) { - // value @ [j, j] - var vjj = 0; - // first & last indeces in column - var f = ptr[j]; - var l = ptr[j + 1]; - // values in column, find value @ [j, j], loop backwards - for (k = l - 1; k >= f; k--) { - // row - i = index[k]; - // check row - if (i === j) { - // update vjj - vjj = values[k]; - } - else if (i < j) { - // exit loop - break; - } - } - // at this point we must have a value @ [j, j] - if (equal(vjj, 0)) { - // system cannot be solved, there is no value @ [j, j] - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - var xj = divideScalar(bj, vjj); - // values in column, continue from last loop - for (; k >= f; k--) { - // row - i = index[k]; - // update copy of b - b[i] = subtract(b[i] || 0, multiply(xj, values[k])); - } - // check for non zero - if (!equal(xj, 0)) { - // push to values (at the beginning since we are looping backwards) - xvalues.unshift(xj); - // row - xindex.unshift(j); - } - } - } - // update ptr - xptr.push(xvalues.length); - // return column vector - return new SparseMatrix({ - values: xvalues, - index: xindex, - ptr: xptr, - size: [rows, 1] - }); - }; - - return backwardSubstitution; - } - - exports.name = 'backwardSubstitution'; - exports.factory = factory; - - -/***/ }, -/* 218 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - function factory (type, config, load, typed) { - - var matrix = load(__webpack_require__(75)); - var divideScalar = load(__webpack_require__(213)); - var multiply = load(__webpack_require__(47)); - var subtract = load(__webpack_require__(55)); - var equal = load(__webpack_require__(115)); - - var substitutionValidation = load(__webpack_require__(356)); - - var SparseMatrix = type.SparseMatrix; - var DenseMatrix = type.DenseMatrix; - - /** - * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. - * - * M * x = b - * - * @param {Matrix, Array} A N x N matrix or array - * @param {Matrix, Array} A column vector with the b values - * - * @return {Matrix} A column vector with the linear system solution - */ - var forwardSubstitution = typed('forwardSubstitution', { - 'Matrix, Array | Matrix': function (m, b) { - // process matrix storage format - switch (m.storage()) { - case 'dense': - return _denseForwardSubstitution(m, b); - case 'sparse': - return _sparseForwardSubstitution(m, b); - } - }, - 'Array, Array | Matrix': function (a, b) { - // create dense matrix from array - var m = matrix(a); - // use matrix implementation - var r = forwardSubstitution(m, b); - // result - return r.valueOf(); - } - }); - - var _denseForwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = substitutionValidation(m, b); - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // result - var x = new Array(rows); - // data - var data = m._data; - // forward solve m * x = b, loop columns - for (var j = 0; j < columns; j++) { - // b[j] - var bj = b[j] || 0; - // x[j] - var xj; - // forward substitution (outer product) avoids inner looping when bj == 0 - if (!equal(bj, 0)) { - // value @ [j, j] - var vjj = data[j][j]; - // check vjj - if (equal(vjj, 0)) { - // system cannot be solved - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - xj = divideScalar(bj, vjj); - // loop rows - for (var i = j + 1; i < rows; i++) { - // update copy of b - b[i] = subtract(b[i] || 0, multiply(xj, data[i][j])); - } - } - else { - // zero @ j - xj = 0; - } - // update x - x[j] = [xj]; - } - // return vector - return new DenseMatrix({ - data: x, - size: [rows, 1] - }); - }; - - var _sparseForwardSubstitution = function (m, b) { - // validate matrix and vector, return copy of column vector b - b = substitutionValidation(m, b); - // rows & columns - var rows = m._size[0]; - var columns = m._size[1]; - // matrix arrays - var values = m._values; - var index = m._index; - var ptr = m._ptr; - // result arrays - var xvalues = []; - var xindex = []; - var xptr = []; - // vars - var i, k; - // init ptr - xptr.push(0); - // forward solve m * x = b, loop columns - for (var j = 0; j < columns; j++) { - // b[j] - var bj = b[j] || 0; - // forward substitution (outer product) avoids inner looping when bj == 0 - if (!equal(bj, 0)) { - // value @ [j, j] - var vjj = 0; - // last index in column - var l = ptr[j + 1]; - // values in column, find value @ [j, j] - for (k = ptr[j]; k < l; k++) { - // row - i = index[k]; - // check row - if (i === j) { - // update vjj - vjj = values[k]; - } - else if (i > j) { - // exit loop - break; - } - } - // at this point we must have a value @ [j, j] - if (equal(vjj, 0)) { - // system cannot be solved, there is no value @ [j, j] - throw new Error('Linear system cannot be solved since matrix is singular'); - } - // calculate xj - var xj = divideScalar(bj, vjj); - // values in column, continue from last loop - for (; k < l; k++) { - // row - i = index[k]; - // update copy of b - b[i] = subtract(b[i] || 0, multiply(xj, values[k])); - } - // check for non zero - if (!equal(xj, 0)) { - // value @ row i - xvalues.push(xj); - // row - xindex.push(j); - } - } - } - // update ptr - xptr.push(xvalues.length); - // return column vector - return new SparseMatrix({ - values: xvalues, - index: xindex, - ptr: xptr, - size: [rows, 1] - }); - }; - - return forwardSubstitution; - } - - exports.name = 'forwardSubstitution'; - exports.factory = factory; - - -/***/ }, -/* 219 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'abs', - 'category': 'Arithmetic', - 'syntax': [ - 'abs(x)' - ], - 'description': 'Compute the absolute value.', - 'examples': [ - 'abs(3.5)', - 'abs(-4.2)' - ], - 'seealso': ['sign'] - }; - - -/***/ }, -/* 220 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'add', - 'category': 'Operators', - 'syntax': [ - 'x + y', - 'add(x, y)' - ], - 'description': 'Add two values.', - 'examples': [ - 'a = 2.1 + 3.6', - 'a - 3.6', - '3 + 2i', - '"hello" + " world"', - '3 cm + 2 inch' - ], - 'seealso': [ - 'subtract' - ] - }; - - -/***/ }, -/* 221 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 222 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 223 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'divide', - 'category': 'Operators', - 'syntax': [ - 'x / y', - 'divide(x, y)' - ], - 'description': 'Divide two values.', - 'examples': [ - 'a = 2 / 3', - 'a * 3', - '4.5 / 2', - '3 + 4 / 2', - '(3 + 4) / 2', - '18 km / 4.5' - ], - 'seealso': [ - 'multiply' - ] - }; - - -/***/ }, -/* 224 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'dotDivide', - 'category': 'Operators', - 'syntax': [ - 'x ./ y', - 'dotDivide(x, y)' - ], - 'description': 'Divide two values element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'b = [2, 1, 1; 3, 2, 5]', - 'a ./ b' - ], - 'seealso': [ - 'multiply', - 'dotMultiply', - 'divide' - ] - }; - - -/***/ }, -/* 225 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'dotMultiply', - 'category': 'Operators', - 'syntax': [ - 'x .* y', - 'dotMultiply(x, y)' - ], - 'description': 'Multiply two values element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'b = [2, 1, 1; 3, 2, 5]', - 'a .* b' - ], - 'seealso': [ - 'multiply', - 'divide', - 'dotDivide' - ] - }; - - -/***/ }, -/* 226 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'dotpow', - 'category': 'Operators', - 'syntax': [ - 'x .^ y', - 'dotpow(x, y)' - ], - 'description': - 'Calculates the power of x to y element wise.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'a .^ 2' - ], - 'seealso': [ - 'pow' - ] - }; - - -/***/ }, -/* 227 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [ - 'pow', - 'log' - ] - }; - - -/***/ }, -/* 228 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 229 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 230 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' ] - }; - - -/***/ }, -/* 231 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' ] - }; - - -/***/ }, -/* 232 */ -/***/ function(module, exports, __webpack_require__) { - - module.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 ^ 4', - 'log(10000, 10)', - 'log(10000) / log(10)', - 'b = log(1024, 2)', - '2 ^ b' - ], - 'seealso': [ - 'exp', - 'log10' - ] - }; - -/***/ }, -/* 233 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'log10', - 'category': 'Arithmetic', - 'syntax': [ - 'log10(x)' - ], - 'description': 'Compute the 10-base logarithm of a value.', - 'examples': [ - 'log10(0.00001)', - 'log10(10000)', - '10 ^ 4', - 'log(10000) / log(10)', - 'log(10000, 10)' - ], - 'seealso': [ - 'exp', - 'log' - ] - }; - - -/***/ }, -/* 234 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': ['divide'] - }; - - -/***/ }, -/* 235 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'multiply', - 'category': 'Operators', - 'syntax': [ - 'x * y', - 'multiply(x, y)' - ], - 'description': 'multiply two values.', - 'examples': [ - 'a = 2.1 * 3.4', - 'a / 3.4', - '2 * 3 + 4', - '2 * (3 + 4)', - '3 * 2.1 km' - ], - 'seealso': [ - 'divide' - ] - }; - - -/***/ }, -/* 236 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'norm', - 'category': 'Arithmetic', - 'syntax': [ - 'norm(x)', - 'norm(x, p)' - ], - 'description': 'Calculate the norm of a number, vector or matrix.', - 'examples': [ - 'abs(-3.5)', - 'norm(-3.5)', - 'norm(3 - 4i))', - 'norm([1, 2, -3], Infinity)', - 'norm([1, 2, -3], -Infinity)', - 'norm([3, 4], 2)', - 'norm([[1, 2], [3, 4]], 1)', - 'norm([[1, 2], [3, 4]], \'inf\')', - 'norm([[1, 2], [3, 4]], \'fro\')' - ] - }; - - -/***/ }, -/* 237 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'nthRoot', - 'category': 'Arithmetic', - 'syntax': [ - 'nthRoot(a)', - 'nthRoot(a, root)' - ], - 'description': 'Calculate the nth root of a value. ' + - 'The principal nth root of a positive real number A, ' + - 'is the positive real solution of the equation "x^root = A".', - 'examples': [ - '4 ^ 3', - 'nthRoot(64, 3)', - 'nthRoot(9, 2)', - 'sqrt(9)' - ], - 'seealso': [ - 'sqrt', - 'pow' - ] - }; - -/***/ }, -/* 238 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [ 'multiply' ] - }; - - -/***/ }, -/* 239 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 240 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 241 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 242 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 243 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'subtract', - 'category': 'Operators', - 'syntax': [ - 'x - y', - 'subtract(x, y)' - ], - 'description': 'subtract two values.', - 'examples': [ - 'a = 5.3 - 2', - 'a + 2', - '2/3 - 1/6', - '2 * 3 - 3', - '2.1 km - 500m' - ], - 'seealso': [ - 'add' - ] - }; - - -/***/ }, -/* 244 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'unaryMinus', - 'category': 'Operators', - 'syntax': [ - '-x', - 'unaryMinus(x)' - ], - 'description': - 'Inverse the sign of a value. Converts booleans and strings to numbers.', - 'examples': [ - '-4.5', - '-(-5.6)', - '-"22"' - ], - 'seealso': [ - 'add', 'subtract', 'unaryPlus' - ] - }; - - -/***/ }, -/* 245 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'unaryPlus', - 'category': 'Operators', - 'syntax': [ - '+x', - 'unaryPlus(x)' - ], - 'description': - 'Converts booleans and strings to numbers.', - 'examples': [ - '+true', - '+"2"' - ], - 'seealso': [ - 'add', 'subtract', 'unaryMinus' - ] - }; - - -/***/ }, -/* 246 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' ] - }; - - -/***/ }, -/* 247 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'bitAnd', - 'category': 'Bitwise', - 'syntax': [ - 'x & y', - 'bitAnd(x, y)' - ], - 'description': 'Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0', - 'examples': [ - '5 & 3', - 'bitAnd(53, 131)', - '[1, 12, 31] & 42' - ], - 'seealso': [ - 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 248 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'bitNot', - 'category': 'Bitwise', - 'syntax': [ - '~x', - 'bitNot(x)' - ], - 'description': 'Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.', - 'examples': [ - '~1', - '~2', - 'bitNot([2, -3, 4])' - ], - 'seealso': [ - 'bitAnd', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 249 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'bitOr', - 'category': 'Bitwise', - 'syntax': [ - 'x | y', - 'bitOr(x, y)' - ], - 'description': 'Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.', - 'examples': [ - '5 | 3', - 'bitOr([1, 2, 3], 4)' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 250 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'bitXor', - 'category': 'Bitwise', - 'syntax': [ - 'bitXor(x, y)' - ], - 'description': 'Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.', - 'examples': [ - 'bitOr(1, 2)', - 'bitXor([2, 3, 4], 4)' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'leftShift', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 251 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'leftShift', - 'category': 'Bitwise', - 'syntax': [ - 'x << y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise left logical shift of a value x by y number of bits.', - 'examples': [ - '4 << 1', - '8 >> 1' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'rightArithShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 252 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'rightArithShift', - 'category': 'Bitwise', - 'syntax': [ - 'x >> y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise right arithmetic shift of a value x by y number of bits.', - 'examples': [ - '8 >> 1', - '4 << 1', - '-12 >> 2' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightLogShift' - ] - }; - - -/***/ }, -/* 253 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'rightLogShift', - 'category': 'Bitwise', - 'syntax': [ - 'x >> y', - 'leftShift(x, y)' - ], - 'description': 'Bitwise right logical shift of a value x by y number of bits.', - 'examples': [ - '8 >>> 1', - '4 << 1', - '-12 >>> 2' - ], - 'seealso': [ - 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift' - ] - }; - - -/***/ }, -/* 254 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 255 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 256 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 257 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 258 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 259 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 260 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 261 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 262 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'matrix', - 'category': 'Type', - 'syntax': [ - '[]', - '[a1, b1, ...; a2, b2, ...]', - 'matrix()', - 'matrix("dense")', - 'matrix([...])' - ], - 'description': - 'Create a matrix.', - 'examples': [ - '[]', - '[1, 2, 3]', - '[1, 2, 3; 4, 5, 6]', - 'matrix()', - 'matrix([3, 4])', - 'matrix([3, 4; 5, 6], "sparse")', - 'matrix([3, 4; 5, 6], "sparse", "number")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'sparse' - ] - }; - - -/***/ }, -/* 263 */ -/***/ function(module, exports, __webpack_require__) { - - module.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])', - 'number("52cm", "m")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'string', 'unit' - ] - }; - - -/***/ }, -/* 264 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'sparse', - 'category': 'Type', - 'syntax': [ - 'sparse()', - 'sparse([a1, b1, ...; a1, b2, ...])', - 'sparse([a1, b1, ...; a1, b2, ...], "number")' - ], - 'description': - 'Create a sparse matrix.', - 'examples': [ - 'sparse()', - 'sparse([3, 4; 5, 6])', - 'sparse([3, 0; 5, 0], "number")' - ], - 'seealso': [ - 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'matrix' - ] - }; - - -/***/ }, -/* 265 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 266 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 267 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 268 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 269 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'and', - 'category': 'Logical', - 'syntax': [ - 'x and y', - 'and(x, y)' - ], - 'description': 'Logical and. Test whether two values are both defined with a nonzero/nonempty value.', - 'examples': [ - 'true and false', - 'true and true', - '2 and 4' - ], - 'seealso': [ - 'not', 'or', 'xor' - ] - }; - - -/***/ }, -/* 270 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'not', - 'category': 'Logical', - 'syntax': [ - '!x', - 'not x', - 'not(x)' - ], - 'description': 'Logical not. Flips the boolean value of given argument.', - 'examples': [ - '!true', - 'not false', - '!2', - '!0' - ], - 'seealso': [ - 'and', 'or', 'xor' - ] - }; - - -/***/ }, -/* 271 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'or', - 'category': 'Logical', - 'syntax': [ - 'x or y', - 'or(x, y)' - ], - 'description': 'Logical or. Test if at least one value is defined with a nonzero/nonempty value.', - 'examples': [ - 'true or false', - 'false or false', - '0 or 4' - ], - 'seealso': [ - 'not', 'and', 'xor' - ] - }; - - -/***/ }, -/* 272 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'xor', - 'category': 'Logical', - 'syntax': [ - 'x or y', - 'or(x, y)' - ], - 'description': 'Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.', - 'examples': [ - 'true xor false', - 'false xor false', - 'true xor true', - '0 or 4' - ], - 'seealso': [ - 'not', 'and', 'or' - ] - }; - - -/***/ }, -/* 273 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'concat', - 'category': 'Matrix', - 'syntax': [ - 'concat(A, B, C, ...)', - 'concat(A, B, C, ..., dim)' - ], - 'description': 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.', - 'examples': [ - 'A = [1, 2; 5, 6]', - 'B = [3, 4; 7, 8]', - 'concat(A, B)', - 'concat(A, B, 1)', - 'concat(A, B, 2)' - ], - 'seealso': [ - 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 274 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'cross', - 'category': 'Matrix', - 'syntax': [ - 'cross(A, B)' - ], - 'description': 'Calculate the cross product for two vectors in three dimensional space.', - 'examples': [ - 'cross([1, 1, 0], [0, 1, 1])', - 'cross([3, -3, 1], [4, 9, 2])', - 'cross([2, 3, 4], [5, 6, 7])' - ], - 'seealso': [ - 'multiply', - 'dot' - ] - }; - - -/***/ }, -/* 275 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'det', - 'category': 'Matrix', - 'syntax': [ - 'det(x)' - ], - 'description': 'Calculate the determinant of a matrix', - 'examples': [ - 'det([1, 2; 3, 4])', - 'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])' - ], - 'seealso': [ - 'concat', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 276 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'diag', - 'category': 'Matrix', - 'syntax': [ - 'diag(x)', - 'diag(x, k)' - ], - 'description': 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.', - 'examples': [ - 'diag(1:3)', - 'diag(1:3, 1)', - 'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]', - 'diag(a)' - ], - 'seealso': [ - 'concat', 'det', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 277 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'dot', - 'category': 'Matrix', - 'syntax': [ - 'dot(A, B)' - ], - 'description': 'Calculate the dot product of two vectors. ' + - 'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' + - 'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn', - 'examples': [ - 'dot([2, 4, 1], [2, 2, 3])', - '[2, 4, 1] * [2, 2, 3]' - ], - 'seealso': [ - 'multiply', - 'cross' - ] - }; - - -/***/ }, -/* 278 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'eye', - 'category': 'Matrix', - 'syntax': [ - 'eye(n)', - 'eye(m, n)', - 'eye([m, n])', - 'eye' - ], - 'description': 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.', - 'examples': [ - 'eye(3)', - 'eye(3, 5)', - 'a = [1, 2, 3; 4, 5, 6]', - 'eye(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 279 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'flatten', - 'category': 'Matrix', - 'syntax': [ - 'flatten(x)' - ], - 'description': 'Flatten a multi dimensional matrix into a single dimensional matrix.', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'size(a)', - 'b = flatten(a)', - 'size(b)' - ], - 'seealso': [ - 'concat', 'resize', 'size', 'squeeze' - ] - }; - - -/***/ }, -/* 280 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'inv', - 'category': 'Matrix', - 'syntax': [ - 'inv(x)' - ], - 'description': 'Calculate the inverse of a matrix', - 'examples': [ - 'inv([1, 2; 3, 4])', - 'inv(4)', - '1 / 4' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 281 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'ones', - 'category': 'Matrix', - 'syntax': [ - 'ones(m)', - 'ones(m, n)', - 'ones(m, n, p, ...)', - 'ones([m])', - 'ones([m, n])', - 'ones([m, n, p, ...])', - 'ones' - ], - 'description': 'Create a matrix containing ones.', - 'examples': [ - 'ones(3)', - 'ones(3, 5)', - 'ones([2,3]) * 4.5', - 'a = [1, 2, 3; 4, 5, 6]', - 'ones(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 282 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'range', - 'category': 'Type', - 'syntax': [ - 'start:end', - 'start:step:end', - 'range(start, end)', - 'range(start, end, step)', - 'range(string)' - ], - 'description': - 'Create a range. Lower bound of the range is included, upper bound is excluded.', - 'examples': [ - '1:5', - '3:-1:-3', - 'range(3, 7)', - 'range(0, 12, 2)', - 'range("4:10")', - 'a = [1, 2, 3, 4; 5, 6, 7, 8]', - 'a[1:2, 1:2]' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 283 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'resize', - 'category': 'Matrix', - 'syntax': [ - 'resize(x, size)', - 'resize(x, size, defaultValue)' - ], - 'description': 'Resize a matrix.', - 'examples': [ - 'resize([1,2,3,4,5], [3])', - 'resize([1,2,3], [5])', - 'resize([1,2,3], [5], -1)', - 'resize(2, [2, 3])', - 'resize("hello", [8], "!")' - ], - 'seealso': [ - 'size', 'subset', 'squeeze' - ] - }; - - -/***/ }, -/* 284 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'size', - 'category': 'Matrix', - 'syntax': [ - 'size(x)' - ], - 'description': 'Calculate the size of a matrix.', - 'examples': [ - 'size(2.3)', - 'size("hello world")', - 'a = [1, 2; 3, 4; 5, 6]', - 'size(a)', - 'size(1:6)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 285 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'squeeze', - 'category': 'Matrix', - 'syntax': [ - 'squeeze(x)' - ], - 'description': 'Remove inner and outer singleton dimensions from a matrix.', - 'examples': [ - 'a = zeros(3,2,1)', - 'size(squeeze(a))', - 'b = zeros(1,1,3)', - 'size(squeeze(b))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'subset', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 286 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'subset', - 'category': 'Matrix', - 'syntax': [ - 'value(index)', - 'value(index) = replacement', - 'subset(value, [index])', - 'subset(value, [index], replacement)' - ], - 'description': 'Get or set a subset of a matrix or string. ' + - 'Indexes are one-based. ' + - 'Both the ranges lower-bound and upper-bound are included.', - 'examples': [ - 'd = [1, 2; 3, 4]', - 'e = []', - 'e[1, 1:2] = [5, 6]', - 'e[2, :] = [7, 8]', - 'f = d * e', - 'f[2, 1]', - 'f[:, 1]' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'trace', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 287 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'trace', - 'category': 'Matrix', - 'syntax': [ - 'trace(A)' - ], - 'description': 'Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.', - 'examples': [ - 'A = [1, 2, 3; -1, 2, 3; 2, 0, 3]', - 'trace(A)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'transpose', 'zeros' - ] - }; - - -/***/ }, -/* 288 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'transpose', - 'category': 'Matrix', - 'syntax': [ - 'x\'', - 'transpose(x)' - ], - 'description': 'Transpose a matrix', - 'examples': [ - 'a = [1, 2, 3; 4, 5, 6]', - 'a\'', - 'transpose(a)' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros' - ] - }; - - -/***/ }, -/* 289 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'zeros', - 'category': 'Matrix', - 'syntax': [ - 'zeros(m)', - 'zeros(m, n)', - 'zeros(m, n, p, ...)', - 'zeros([m])', - 'zeros([m, n])', - 'zeros([m, n, p, ...])', - 'zeros' - ], - 'description': 'Create a matrix containing zeros.', - 'examples': [ - 'zeros(3)', - 'zeros(3, 5)', - 'a = [1, 2, 3; 4, 5, 6]', - 'zeros(size(a))' - ], - 'seealso': [ - 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose' - ] - }; - - -/***/ }, -/* 290 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'combinations', - 'category': 'Probability', - 'syntax': [ - 'combinations(n, k)' - ], - 'description': 'Compute the number of combinations of n items taken k at a time', - 'examples': [ - 'combinations(7, 5)' - ], - 'seealso': ['permutations', 'factorial'] - }; - - -/***/ }, -/* 291 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'factorial', - 'category': 'Probability', - 'syntax': [ - 'n!', - 'factorial(n)' - ], - 'description': 'Compute the factorial of a value', - 'examples': [ - '5!', - '5 * 4 * 3 * 2 * 1', - '3!' - ], - 'seealso': ['combinations', 'permutations', 'gamma'] - }; - - -/***/ }, -/* 292 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'gamma', - 'category': 'Probability', - 'syntax': [ - 'gamma(n)' - ], - 'description': 'Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.', - 'examples': [ - 'gamma(4)', - '3!', - 'gamma(1/2)', - 'sqrt(pi)' - ], - 'seealso': ['factorial'] - }; - - -/***/ }, -/* 293 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'permutations', - 'category': 'Probability', - 'syntax': [ - 'permutations(n)', - 'permutations(n, k)' - ], - 'description': 'Compute the number of permutations of n items taken k at a time', - 'examples': [ - 'permutations(5)', - 'permutations(5, 3)' - ], - 'seealso': ['combinations', 'factorial'] - }; - - -/***/ }, -/* 294 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': ['random', 'randomInt'] - }; - - -/***/ }, -/* 295 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'random', - 'category': 'Probability', - 'syntax': [ - 'random()', - 'random(max)', - 'random(min, max)', - 'random(size)', - 'random(size, max)', - 'random(size, min, max)' - ], - 'description': - 'Return a random number.', - 'examples': [ - 'random()', - 'random(10, 20)', - 'random([2, 3])' - ], - 'seealso': ['pickRandom', 'randomInt'] - }; - - -/***/ }, -/* 296 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': ['pickRandom', 'random'] - }; - -/***/ }, -/* 297 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'compare', - 'category': 'Relational', - 'syntax': [ - 'compare(x, y)' - ], - 'description': - 'Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.', - 'examples': [ - 'compare(2, 3)', - 'compare(3, 2)', - 'compare(2, 2)', - 'compare(5cm, 40mm)', - 'compare(2, [1, 2, 3])' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq' - ] - }; - - -/***/ }, -/* 298 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'deepEqual', - 'category': 'Relational', - 'syntax': [ - 'deepEqual(x, y)' - ], - 'description': - 'Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.', - 'examples': [ - '[1,3,4] == [1,3,4]', - '[1,3,4] == [1,3]' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 299 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'equal', - 'category': 'Relational', - 'syntax': [ - 'x == y', - 'equal(x, y)' - ], - 'description': - 'Check equality of two values. Returns true if the values are equal, and false if not.', - 'examples': [ - '2+2 == 3', - '2+2 == 4', - 'a = 3.2', - 'b = 6-2.8', - 'a == b', - '50cm == 0.5m' - ], - 'seealso': [ - 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' - ] - }; - - -/***/ }, -/* 300 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'larger', - 'category': 'Relational', - 'syntax': [ - 'x > y', - 'larger(x, y)' - ], - 'description': - 'Check if value x is larger than y. Returns true if x is larger than y, and false if not.', - 'examples': [ - '2 > 3', - '5 > 2*2', - 'a = 3.3', - 'b = 6-2.8', - '(a > b)', - '(b < a)', - '5 cm > 2 inch' - ], - 'seealso': [ - 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 301 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'largerEq', - 'category': 'Relational', - 'syntax': [ - 'x >= y', - 'largerEq(x, y)' - ], - 'description': - 'Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.', - 'examples': [ - '2 > 1+1', - '2 >= 1+1', - 'a = 3.2', - 'b = 6-2.8', - '(a > b)' - ], - 'seealso': [ - 'equal', 'unequal', 'smallerEq', 'smaller', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 302 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'smaller', - 'category': 'Relational', - 'syntax': [ - 'x < y', - 'smaller(x, y)' - ], - 'description': - 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.', - 'examples': [ - '2 < 3', - '5 < 2*2', - 'a = 3.3', - 'b = 6-2.8', - '(a < b)', - '5 cm < 2 inch' - ], - 'seealso': [ - 'equal', 'unequal', 'larger', 'smallerEq', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 303 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'smallerEq', - 'category': 'Relational', - 'syntax': [ - 'x <= y', - 'smallerEq(x, y)' - ], - 'description': - 'Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.', - 'examples': [ - '2 < 1+1', - '2 <= 1+1', - 'a = 3.2', - 'b = 6-2.8', - '(a < b)' - ], - 'seealso': [ - 'equal', 'unequal', 'larger', 'smaller', 'largerEq', 'compare' - ] - }; - - -/***/ }, -/* 304 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'unequal', - 'category': 'Relational', - 'syntax': [ - 'x != y', - 'unequal(x, y)' - ], - 'description': - 'Check unequality of two values. Returns true if the values are unequal, and false if they are equal.', - 'examples': [ - '2+2 != 3', - '2+2 != 4', - 'a = 3.2', - 'b = 6-2.8', - 'a != b', - '50cm != 0.5m', - '5 cm != 2 inch' - ], - 'seealso': [ - 'equal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' - ] - }; - - -/***/ }, -/* 305 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'max', - 'category': 'Statistics', - 'syntax': [ - 'max(a, b, c, ...)', - 'max(A)', - 'max(A, dim)' - ], - 'description': 'Compute the maximum value of a list of values.', - 'examples': [ - 'max(2, 3, 4, 1)', - 'max([2, 3, 4, 1])', - 'max([2, 5; 4, 3])', - 'max([2, 5; 4, 3], 1)', - 'max([2, 5; 4, 3], 2)', - 'max(2.7, 7.1, -4.5, 2.0, 4.1)', - 'min(2.7, 7.1, -4.5, 2.0, 4.1)' - ], - 'seealso': [ - 'mean', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 306 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'mean', - 'category': 'Statistics', - 'syntax': [ - 'mean(a, b, c, ...)', - 'mean(A)', - 'mean(A, dim)' - ], - 'description': 'Compute the arithmetic mean of a list of values.', - 'examples': [ - 'mean(2, 3, 4, 1)', - 'mean([2, 3, 4, 1])', - 'mean([2, 5; 4, 3])', - 'mean([2, 5; 4, 3], 1)', - 'mean([2, 5; 4, 3], 2)', - 'mean([1.0, 2.7, 3.2, 4.0])' - ], - 'seealso': [ - 'max', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 307 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'median', - 'category': 'Statistics', - 'syntax': [ - 'median(a, b, c, ...)', - 'median(A)' - ], - 'description': 'Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.', - 'examples': [ - 'median(5, 2, 7)', - 'median([3, -1, 5, 7])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 308 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'min', - 'category': 'Statistics', - 'syntax': [ - 'min(a, b, c, ...)', - 'min(A)', - 'min(A, dim)' - ], - 'description': 'Compute the minimum value of a list of values.', - 'examples': [ - 'min(2, 3, 4, 1)', - 'min([2, 3, 4, 1])', - 'min([2, 5; 4, 3])', - 'min([2, 5; 4, 3], 1)', - 'min([2, 5; 4, 3], 2)', - 'min(2.7, 7.1, -4.5, 2.0, 4.1)', - 'max(2.7, 7.1, -4.5, 2.0, 4.1)' - ], - 'seealso': [ - 'max', - 'mean', - 'median', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 309 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'prod', - 'category': 'Statistics', - 'syntax': [ - 'prod(a, b, c, ...)', - 'prod(A)' - ], - 'description': 'Compute the product of all values.', - 'examples': [ - 'prod(2, 3, 4)', - 'prod([2, 3, 4])', - 'prod([2, 5; 4, 3])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 310 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'std', - 'category': 'Statistics', - 'syntax': [ - 'std(a, b, c, ...)', - 'std(A)', - 'std(A, normalization)' - ], - 'description': 'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', - 'examples': [ - 'std(2, 4, 6)', - 'std([2, 4, 6, 8])', - 'std([2, 4, 6, 8], "uncorrected")', - 'std([2, 4, 6, 8], "biased")', - 'std([1, 2, 3; 4, 5, 6])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'prod', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 311 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'sum', - 'category': 'Statistics', - 'syntax': [ - 'sum(a, b, c, ...)', - 'sum(A)' - ], - 'description': 'Compute the sum of all values.', - 'examples': [ - 'sum(2, 3, 4, 1)', - 'sum([2, 3, 4, 1])', - 'sum([2, 5; 4, 3])' - ], - 'seealso': [ - 'max', - 'mean', - 'median', - 'min', - 'prod', - 'std', - 'sum', - 'var' - ] - }; - - -/***/ }, -/* 312 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'var', - 'category': 'Statistics', - 'syntax': [ - 'var(a, b, c, ...)', - 'var(A)', - 'var(A, normalization)' - ], - 'description': 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', - 'examples': [ - 'var(2, 4, 6)', - 'var([2, 4, 6, 8])', - 'var([2, 4, 6, 8], "uncorrected")', - 'var([2, 4, 6, 8], "biased")', - 'var([1, 2, 3; 4, 5, 6])' - ], - 'seealso': [ - 'max', - 'mean', - 'min', - 'median', - 'min', - 'prod', - 'std', - 'sum' - ] - }; - - -/***/ }, -/* 313 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acos', - 'category': 'Trigonometry', - 'syntax': [ - 'acos(x)' - ], - 'description': 'Compute the inverse cosine of a value in radians.', - 'examples': [ - 'acos(0.5)', - 'acos(cos(2.3))' - ], - 'seealso': [ - 'cos', - 'atan', - 'asin' - ] - }; - - -/***/ }, -/* 314 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acosh', - 'category': 'Trigonometry', - 'syntax': [ - 'acosh(x)' - ], - 'description': 'Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.', - 'examples': [ - 'acosh(1.5)' - ], - 'seealso': [ - 'cosh', - 'asinh', - 'atanh' - ] - }; - -/***/ }, -/* 315 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acot', - 'category': 'Trigonometry', - 'syntax': [ - 'acot(x)' - ], - 'description': 'Calculate the inverse cotangent of a value.', - 'examples': [ - 'acot(0.5)', - 'acot(cot(0.5))', - 'acot(2)' - ], - 'seealso': [ - 'cot', - 'atan' - ] - }; - - -/***/ }, -/* 316 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acoth', - 'category': 'Trigonometry', - 'syntax': [ - 'acoth(x)' - ], - 'description': 'Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.', - 'examples': [ - 'acoth(0.5)' - ], - 'seealso': [ - 'acsch', - 'asech' - ] - }; - -/***/ }, -/* 317 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acsc', - 'category': 'Trigonometry', - 'syntax': [ - 'acsc(x)' - ], - 'description': 'Calculate the inverse cotangent of a value.', - 'examples': [ - 'acsc(0.5)', - 'acsc(csc(0.5))', - 'acsc(2)' - ], - 'seealso': [ - 'csc', - 'asin', - 'asec' - ] - }; - - -/***/ }, -/* 318 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'acsch', - 'category': 'Trigonometry', - 'syntax': [ - 'acsch(x)' - ], - 'description': 'Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.', - 'examples': [ - 'acsch(0.5)' - ], - 'seealso': [ - 'asech', - 'acoth' - ] - }; - - -/***/ }, -/* 319 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'asec', - 'category': 'Trigonometry', - 'syntax': [ - 'asec(x)' - ], - 'description': 'Calculate the inverse secant of a value.', - 'examples': [ - 'asec(0.5)', - 'asec(sec(0.5))', - 'asec(2)' - ], - 'seealso': [ - 'acos', - 'acot', - 'acsc' - ] - }; - - -/***/ }, -/* 320 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'asech', - 'category': 'Trigonometry', - 'syntax': [ - 'asech(x)' - ], - 'description': 'Calculate the inverse secant of a value.', - 'examples': [ - 'asech(0.5)' - ], - 'seealso': [ - 'acsch', - 'acoth' - ] - }; - - -/***/ }, -/* 321 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'asin', - 'category': 'Trigonometry', - 'syntax': [ - 'asin(x)' - ], - 'description': 'Compute the inverse sine of a value in radians.', - 'examples': [ - 'asin(0.5)', - 'asin(sin(2.3))' - ], - 'seealso': [ - 'sin', - 'acos', - 'atan' - ] - }; - - -/***/ }, -/* 322 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'asinh', - 'category': 'Trigonometry', - 'syntax': [ - 'asinh(x)' - ], - 'description': 'Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.', - 'examples': [ - 'asinh(0.5)' - ], - 'seealso': [ - 'acosh', - 'atanh' - ] - }; - - -/***/ }, -/* 323 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 324 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'atanh', - 'category': 'Trigonometry', - 'syntax': [ - 'atanh(x)' - ], - 'description': 'Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.', - 'examples': [ - 'atanh(0.5)' - ], - 'seealso': [ - 'acosh', - 'asinh' - ] - }; - - -/***/ }, -/* 325 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 326 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 327 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'cosh', - 'category': 'Trigonometry', - 'syntax': [ - 'cosh(x)' - ], - 'description': 'Compute the hyperbolic cosine of x in radians.', - 'examples': [ - 'cosh(0.5)' - ], - 'seealso': [ - 'sinh', - 'tanh', - 'coth' - ] - }; - - -/***/ }, -/* 328 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 329 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'coth', - 'category': 'Trigonometry', - 'syntax': [ - 'coth(x)' - ], - 'description': 'Compute the hyperbolic cotangent of x in radians.', - 'examples': [ - 'coth(2)', - '1 / tanh(2)' - ], - 'seealso': [ - 'sech', - 'csch', - 'tanh' - ] - }; - - -/***/ }, -/* 330 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 331 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'csch', - 'category': 'Trigonometry', - 'syntax': [ - 'csch(x)' - ], - 'description': 'Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)', - 'examples': [ - 'csch(2)', - '1 / sinh(2)' - ], - 'seealso': [ - 'sech', - 'coth', - 'sinh' - ] - }; - - -/***/ }, -/* 332 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 333 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'sech', - 'category': 'Trigonometry', - 'syntax': [ - 'sech(x)' - ], - 'description': 'Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)', - 'examples': [ - 'sech(2)', - '1 / cosh(2)' - ], - 'seealso': [ - 'coth', - 'csch', - 'cosh' - ] - }; - - -/***/ }, -/* 334 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 335 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'sinh', - 'category': 'Trigonometry', - 'syntax': [ - 'sinh(x)' - ], - 'description': 'Compute the hyperbolic sine of x in radians.', - 'examples': [ - 'sinh(0.5)' - ], - 'seealso': [ - 'cosh', - 'tanh' - ] - }; - - -/***/ }, -/* 336 */ -/***/ function(module, exports, __webpack_require__) { - - module.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' - ] - }; - - -/***/ }, -/* 337 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'tanh', - 'category': 'Trigonometry', - 'syntax': [ - 'tanh(x)' - ], - 'description': 'Compute the hyperbolic tangent of x in radians.', - 'examples': [ - 'tanh(0.5)', - 'sinh(0.5) / cosh(0.5)' - ], - 'seealso': [ - 'sinh', - 'cosh' - ] - }; - - -/***/ }, -/* 338 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'to', - 'category': 'Units', - 'syntax': [ - 'x to unit', - 'to(x, unit)' - ], - 'description': 'Change the unit of a value.', - 'examples': [ - '5 inch to cm', - '3.2kg to g', - '16 bytes in bits' - ], - 'seealso': [] - }; - - -/***/ }, -/* 339 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 340 */ -/***/ function(module, exports, __webpack_require__) { - - module.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 value * value })' - ], - 'seealso': ['filter', 'forEach'] - }; - - -/***/ }, -/* 341 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'filter', - 'category': 'Utils', - 'syntax': [ - 'filter(x, test)' - ], - 'description': 'Filter items in a matrix.', - 'examples': [ - 'isPositive(x) = x > 0', - 'filter([6, -2, -1, 4, 3], isPositive)', - 'filter([6, -2, 0, 1, 0], x != 0)' - ], - 'seealso': ['sort', 'map', 'forEach'] - }; - - -/***/ }, -/* 342 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'forEach', - 'category': 'Utils', - 'syntax': [ - 'forEach(x, callback)' - ], - 'description': 'Iterates over all elements of a matrix/array, and executes the given callback function.', - 'examples': [ - 'forEach([1, 2, 3], function(val) { console.log(val) })' - ], - 'seealso': ['map', 'sort', 'filter'] - }; - - -/***/ }, -/* 343 */ -/***/ function(module, exports, __webpack_require__) { - - module.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'] - }; - - -/***/ }, -/* 344 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'import', - 'category': 'Utils', - 'syntax': [ - 'import(string)' - ], - 'description': 'Import functions from a file.', - 'examples': [ - 'import("numbers")', - 'import("./mylib.js")' - ], - 'seealso': [] - }; - - -/***/ }, -/* 345 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = { - 'name': 'sort', - 'category': 'Utils', - 'syntax': [ - 'sort(x)', - 'sort(x, compare)' - ], - 'description': 'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.', - 'examples': [ - 'sort([5, 10, 1])', - 'sort(["C", "B", "A", "D"])', - 'sortByLength(a, b) = size(a)[1] - size(b)[1]', - 'sort(["Langdon", "Tom", "Sara"], sortByLength)' - ], - 'seealso': ['map', 'filter', 'forEach'] - }; - - -/***/ }, -/* 346 */ -/***/ function(module, exports, __webpack_require__) { - - module.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': [] - }; - - -/***/ }, -/* 347 */ -/***/ function(module, exports, __webpack_require__) { - - var map = { - "./clone": 155, - "./clone.js": 155, - "./config": 156, - "./config.js": 156, - "./filter": 157, - "./filter.js": 157, - "./forEach": 163, - "./forEach.js": 163, - "./format": 158, - "./format.js": 158, - "./import": 168, - "./import.js": 168, - "./map": 159, - "./map.js": 159, - "./print": 160, - "./print.js": 160, - "./sort": 161, - "./sort.js": 161, - "./typeof": 162, - "./typeof.js": 162 - }; - function webpackContext(req) { - return __webpack_require__(webpackContextResolve(req)); - }; - function webpackContextResolve(req) { - return map[req] || (function() { throw new Error("Cannot find module '" + req + "'.") }()); - }; - webpackContext.keys = function webpackContextKeys() { - return Object.keys(map); - }; - webpackContext.resolve = webpackContextResolve; - module.exports = webpackContext; - webpackContext.id = 347; - - -/***/ }, -/* 348 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = '2.0.0-SNAPSHOT'; - // Note: This file is automatically generated when building math.js. - // Changes made in this file will be overwritten. - - -/***/ }, -/* 349 */ +/* 190 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; /** - * Create a TypeError with message: - * 'Function does not support a parameter of type '; - * @param {String} fn Function name - * @param {*...} [types] The types of the function arguments - * @extends TypeError + * Format a number using methods toPrecision, toFixed, toExponential. + * @param {number | string} value + * @constructor */ - function UnsupportedTypeError(fn, types) { - if (!(this instanceof UnsupportedTypeError)) { - throw new SyntaxError('Constructor must be called with the new operator'); + function NumberFormatter (value) { + // parse the input value + var match = String(value).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/); + if (!match) { + throw new SyntaxError('Invalid number'); } - this.fn = fn; - this.types = Array.prototype.splice.call(arguments, 1); + var sign = match[1]; + var coefficients = match[2]; + var exponent = parseFloat(match[4] || '0'); - if (!fn) { - this.message = 'Unsupported type of argument'; - } - else { - if (this.types.length == 0) { - this.message = 'Unsupported type of argument in function ' + fn; - } - else { - this.message = 'Function ' + fn + '(' + this.types.join(', ') + ') not supported'; - } + var dot = coefficients.indexOf('.'); + exponent += (dot !== -1) ? (dot - 1) : (coefficients.length - 1); + + this.sign = sign; + this.coefficients = coefficients + .replace('.', '') // remove the dot (must be removed before removing leading zeros) + .replace(/^0*/, function (zeros) { + // remove leading zeros, add their count to the exponent + exponent -= zeros.length; + return ''; + }) + .replace(/0*$/, '') // remove trailing zeros + .split('') + .map(function (d) { + return parseInt(d); + }); + + if (this.coefficients.length === 0) { + this.coefficients.push(0); + exponent++; } - this.stack = (new Error()).stack; + this.exponent = exponent; } - UnsupportedTypeError.prototype = new TypeError(); - UnsupportedTypeError.prototype.constructor = TypeError; - UnsupportedTypeError.prototype.name = 'UnsupportedTypeError'; - - module.exports = UnsupportedTypeError; - - -/***/ }, -/* 350 */ -/***/ function(module, exports, __webpack_require__) { - - // function utils - - /* - * Memoize a given function by caching the computed result. - * The cache of a memoized function can be cleared by deleting the `cache` - * property of the function. - * - * @param {function} fn The function to be memoized. Must be a pure function. - * @return {function} Returns the memoized function + /** + * Format a number with fixed notation. + * @param {Number} [precision=0] Optional number of decimals after the + * decimal point. Zero by default. */ - exports.memoize = function(fn) { - return function memoize() { - if (typeof memoize.cache !== 'object') { - memoize.cache = {}; + NumberFormatter.prototype.toFixed = function (precision) { + var rounded = this.roundDigits(this.exponent + 1 + (precision || 0)); + var c = rounded.coefficients; + var p = rounded.exponent + 1; // exponent may have changed + + // append zeros if needed + var pp = p + (precision || 0); + if (c.length < pp) { + c = c.concat(zeros(pp - c.length)); + } + + // prepend zeros if needed + if (p < 0) { + c = zeros(-p + 1).concat(c); + p = 1; + } + + // insert a dot if needed + if (precision) { + c.splice(p, 0, (p === 0) ? '0.' : '.'); + } + + return this.sign + c.join(''); + }; + + /** + * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' + * @param {Number} [precision] Number of digits in formatted output. + * If not provided, the maximum available digits + * is used. + */ + NumberFormatter.prototype.toExponential = function (precision) { + // round if needed, else create a clone + var rounded = precision ? this.roundDigits(precision) : this.clone(); + var c = rounded.coefficients; + var e = rounded.exponent; + + // append zeros if needed + if (c.length < precision) { + c = c.concat(zeros(precision - c.length)); + } + + // format as `C.CCCe+EEE` or `C.CCCe-EEE` + var first = c.shift(); + return this.sign + first + (c.length > 0 ? ('.' + c.join('')) : '') + + 'e' + (e >= 0 ? '+' : '') + e; + }; + + /** + * Format a number with a certain precision + * @param {Number} [precision=undefined] Optional number of digits. + * @param {{lower: number | undefined, upper: number | undefined}} [options] + * By default: + * lower = 1e-3 (excl) + * upper = 1e+5 (incl) + * @return {string} + */ + NumberFormatter.prototype.toPrecision = function(precision, options) { + // determine lower and upper bound for exponential notation. + var lower = (options && options.lower !== undefined) ? options.lower : 1e-3; + var upper = (options && options.upper !== undefined) ? options.upper : 1e+5; + + var abs = Math.abs(Math.pow(10, this.exponent)); + if (abs < lower || abs >= upper) { + // exponential notation + return this.toExponential(precision); + } + else { + var rounded = precision ? this.roundDigits(precision) : this.clone(); + var c = rounded.coefficients; + var e = rounded.exponent; + + // append trailing zeros + if (c.length < precision) { + c = c.concat(zeros(precision - c.length)); } - var hash = JSON.stringify(arguments); - if (!(hash in memoize.cache)) { - return memoize.cache[hash] = fn.apply(fn, arguments); + // append trailing zeros + // TODO: simplify the next statement + c = c.concat(zeros(e - c.length + 1 + + (c.length < precision ? precision - c.length : 0))); + + // prepend zeros + c = zeros(-e).concat(c); + + var dot = e > 0 ? e : 0; + if (dot < c.length - 1) { + c.splice(dot + 1, 0, '.'); } - return memoize.cache[hash]; - }; + + return this.sign + c.join(''); + } }; + + /** + * Crete a clone of the NumberFormatter + * @return {NumberFormatter} Returns a clone of the NumberFormatter + */ + NumberFormatter.prototype.clone = function () { + var clone = new NumberFormatter('0'); + clone.sign = this.sign; + clone.coefficients = this.coefficients.slice(0); + clone.exponent = this.exponent; + return clone; + }; + + /** + * Round the number of digits of a number * + * @param {number} precision A positive integer + * @return {NumberFormatter} Returns a new NumberFormatter with the rounded + * digits + */ + NumberFormatter.prototype.roundDigits = function (precision) { + var rounded = this.clone(); + var c = rounded.coefficients; + + // prepend zeros if needed + while (precision <= 0) { + c.unshift(0); + rounded.exponent++; + precision++; + } + + if (c.length > precision) { + var removed = c.splice(precision); + + if (removed[0] >= 5) { + var i = precision - 1; + c[i]++; + while (c[i] === 10) { + c.pop(); + if (i === 0) { + c.unshift(0); + rounded.exponent++; + i++; + } + i--; + c[i]++; + } + } + } + + return rounded; + }; + + /** + * Create an array filled with zeros. + * @param {number} length + * @return {Array} + */ + function zeros(length) { + var arr = []; + for (var i = 0; i < length; i++) { + arr.push(0); + } + return arr; + } + + module.exports = NumberFormatter; /***/ }, -/* 351 */ +/* 191 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v4.0.2 https://github.com/MikeMcl/decimal.js/LICENCE */ @@ -35521,227 +30117,8162 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }, -/* 352 */ +/* 192 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory(type, config, load, typed) { + + /** + * Add two scalar values, `x + y`. + * This function is meant for internal use: it is used by the public function + * `add` + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {Number | BigNumber | Boolean | Complex | Unit | null} x First value to add + * @param {Number | BigNumber | Boolean | Complex | null} y Second value to add + * @return {Number | BigNumber | Complex | Unit} Sum of `x` and `y` + * @private + */ + var addScalar = typed('addScalar', { + + 'number, number': function (x, y) { + return x + y; + }, + + 'Complex, Complex': function (x, y) { + return new type.Complex( + x.re + y.re, + x.im + y.im + ); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.plus(y); + }, + + 'Unit, Unit': function (x, y) { + if (x.value == null) throw new Error('Parameter x contains a unit with undefined value'); + if (y.value == null) throw new Error('Parameter y contains a unit with undefined value'); + if (!x.equalBase(y)) throw new Error('Units do not match'); + + var res = x.clone(); + res.value += y.value; + res.fixPrefix = false; + return res; + }, + + 'string, string': function (x, y) { + return x + y; + } + }); + + return addScalar; + } + + exports.name = 'addScalar'; + exports.factory = factory; + + +/***/ }, +/* 193 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + var DimensionError = __webpack_require__(39); + + var object = util.object; + + function factory (type, config, load) { + + var equal = load(__webpack_require__(46)); + + var DenseMatrix = type.DenseMatrix, + SparseMatrix = type.SparseMatrix; + + /** + * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). + * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ Dij ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (S) + * @param {function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm1 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + + // result (DenseMatrix) + var cdata = object.clone(adata); + + // loop columns in b + for (var j = 0; j < columns; j++) { + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + var i = bindex[k]; + // update C(i,j) + cdata[i][j] = inverse ? cf(bvalues[k], cdata[i][j]) : cf(cdata[i][j], bvalues[k]); + } + } + + // return dense matrix + return new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + }; + + /** + * Iterates over SparseMatrix nonzero items and invokes the callback function f(Dij, Sij). + * Callback function invoked NNZ times (number of nonzero items in SparseMatrix). + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (S) + * @param {function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm2 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + + // result (SparseMatrix) + var cvalues = []; + var cindex = []; + var cptr = new Array(columns + 1); + + // loop columns in b + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + var i = bindex[k]; + // update C(i,j) + var cij = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); + // check for nonzero + if (!equal(cij, 0)) { + // push i & v + cindex.push(i); + cvalues.push(cij); + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + }; + + /** + * Iterates over SparseMatrix items and invokes the callback function f(Dij, Sij). + * Callback function invoked M*N times. + * + * + * ┌ f(Dij, Sij) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ f(Dij, 0) ; otherwise + * + * + * @param {Matrix} denseMatrix The DenseMatrix instance (D) + * @param {Matrix} sparseMatrix The SparseMatrix instance (C) + * @param {function} callback The f(Dij,Sij) operation to invoke, where Dij = DenseMatrix(i,j) and Sij = SparseMatrix(i,j) + * @param {boolean} inverse A true value indicates callback should be invoked f(Sij,Dij) + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571 + */ + var algorithm3 = function (denseMatrix, sparseMatrix, callback, inverse) { + // dense matrix arrays + var adata = denseMatrix._data; + var asize = denseMatrix._size; + var adt = denseMatrix._datatype; + // sparse matrix arrays + var bvalues = sparseMatrix._values; + var bindex = sparseMatrix._index; + var bptr = sparseMatrix._ptr; + var bsize = sparseMatrix._size; + var bdt = sparseMatrix._datatype; + var bzero = sparseMatrix._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!bvalues) + throw new Error('Cannot perform operation on Dense Matrix and Pattern Sparse Matrix'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types (zero value is required!) + var dt = adt && bdt && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + + // sparse matrix zero value + var zero = dt ? bzero : 0; + + // result (DenseMatrix) + var cdata = new Array(rows); + + // initialize dense matrix + for (var z = 0; z < rows; z++) { + // initialize row + cdata[z] = new Array(columns); + } + + // workspace + var x = new Array(rows); + // marks indicating we have a value in x for a given column + var w = new Array(rows); + + // loop columns in b + for (var j = 0; j < columns; j++) { + // column mark + var mark = j + 1; + // values in column j + for (var k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + var i = bindex[k]; + // update workspace + x[i] = inverse ? cf(bvalues[k], adata[i][j]) : cf(adata[i][j], bvalues[k]); + w[i] = mark; + } + // process workspace + for (var y = 0; y < rows; y++) { + // check we have a calculated value for current row + if (w[y] === mark) { + // use calculated value + cdata[y][j] = x[y]; + } + else { + // calculate value + cdata[y][j] = inverse ? cf(zero, adata[y][j]) : cf(adata[y][j], zero); + } + } + } + + // return dense matrix + return new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + }; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 + * └ B(i,j) ; B(i,j) !== 0 + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm4 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var asize = a._size; + var adt = a._datatype; + var azero = a._zero; + // sparse matrix arrays + var bvalues = b._values; + var bsize = b._size; + var bdt = b._datatype; + var bzero = b._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types + var dt = adt && bdt && typeof(azero) !== 'undefined' && azero !== null && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + // equal + var ef = dt ? equal.signatures[dt + ',' + dt] || equal : equal; + + // sparse matrix zero value + var zero = dt ? azero : 0; + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = new Array(columns + 1); + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspace + var x = avalues && bvalues ? new Array(rows) : undefined; + // marks indicating we have a value in x for a given column + var w = new Array(rows); + // marks indicating value in a given row has been updated + var u = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + _scatter(a, j, w, x, u, mark, c, cf, false); + // scatter the values of B(:,j) into workspace + _scatter(b, j, w, x, u, mark, c, cf, false); + // check we need to process values (non pattern matrix) + if (x) { + // initialize first index in j + var k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + var i = cindex[k]; + // value @ i + var v = x[i]; + // check for zero value + if (!ef(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 || B(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm5 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var asize = a._size; + var adt = a._datatype; + var azero = a._zero; + // sparse matrix arrays + var bvalues = b._values; + var bsize = b._size; + var bdt = b._datatype; + var bzero = b._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types (zero value is required!) + var dt = adt && bdt && typeof(azero) !== 'undefined' && azero !== null && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + // equal + var ef = dt ? equal.signatures[dt + ',' + dt] || equal : equal; + + // sparse matrix zero value + var zero = dt ? azero : 0; + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = new Array(columns + 1); + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt, + zero: zero + }); + + // workspaces + var x = cvalues ? new Array(rows) : undefined; + // marks indicating we have a value in x for a given column + var w = new Array(rows); + // marks indicating value in a given row has been updated + var u = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + _scatter(a, j, w, x, u, mark, c); + // scatter the values of B(:,j) into workspace + _scatter(b, j, w, x, u, mark, c, cf, false, true, zero); + // check we need to process values (non pattern matrix) + if (x) { + // initialize first index in j + var k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + var i = cindex[k]; + // value @ i + var v = x[i]; + // check for zero value + if (!ef(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked (Anz U Bnz) times, where Anz and Bnz are the nonzero elements in both matrices. + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm6 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var asize = a._size; + var adt = a._datatype; + var azero = a._zero; + // sparse matrix arrays + var bvalues = b._values; + var bsize = b._size; + var bdt = b._datatype; + var bzero = b._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types (zero value is required!) + var dt = adt && bdt && typeof(azero) !== 'undefined' && azero !== null && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + // equal + var ef = dt ? equal.signatures[dt + ',' + dt] || equal : equal; + + // sparse matrix zero value + var zero = dt ? azero : 0; + + // result arrays + var cvalues = avalues && bvalues ? [] : undefined; + var cindex = []; + var cptr = new Array(columns + 1); + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt, + zero: zero + }); + + // workspaces + var x = cvalues ? new Array(rows) : undefined; + // marks indicating we have a value in x for a given column + var w = new Array(rows); + // marks indicating value in a given row has been updated + var u = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + _scatter(a, j, w, x, u, mark, c, cf); + // scatter the values of B(:,j) into workspace + _scatter(b, j, w, x, u, mark, c, cf); + // check we need to process values (non pattern matrix) + if (x) { + // initialize first index in j + var k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + var i = cindex[k]; + // check function was invoked on current row (Aij !=0 && Bij != 0) + if (u[i] === mark) { + // value @ i + var v = x[i]; + // check for zero value + if (!ef(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + else { + // initialize first index in j + var p = cptr[j]; + // loop index in j + while (p < cindex.length) { + // row + var r = cindex[p]; + // check function was invoked on current row (Aij !=0 && Bij != 0) + if (u[r] !== mark) { + // remove value @ i, do not increment pointer + cindex.splice(p, 1); + } + else { + // increment pointer + p++; + } + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix A and SparseMatrix B items (zero and nonzero) and invokes the callback function f(Aij, Bij). + * Callback function invoked MxN times. + * + * C(i,j) = f(Aij, Bij) + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} DenseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm7 = function (a, b, callback) { + // sparse matrix arrays + var asize = a._size; + var adt = a._datatype; + var azero = a._zero; + // sparse matrix arrays + var bsize = b._size; + var bdt = b._datatype; + var bzero = b._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types (zero value is required!) + var dt = adt && bdt && typeof(azero) !== 'undefined' && azero !== null && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + + // sparse matrix zero value + var zero = dt ? azero : 0; + + // result arrays + var cdata = new Array(rows); + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns], + datatype: dt + }); + + // workspaces + var xa = new Array(rows); + var xb = new Array(rows); + // marks indicating we have a value in x for a given column + var wa = new Array(rows); + var wb = new Array(rows); + // marks indicating value in a given row has been updated (not used in this algorithm) + var u = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // scatter the values of A(:,j) into workspace + _scatter(a, j, wa, xa, u, mark, undefined, cf); + // scatter the values of B(:,j) into workspace + _scatter(b, j, wb, xb, u, mark, undefined, cf); + // loop rows + for (var i = 0; i < rows; i++) { + // check this is the first column + if (j === 0) { + // initialize row + cdata[i] = new Array(columns); + } + // matrix values @ i,j + var va = wa[i] === mark ? xa[i] : zero; + var vb = wb[i] === mark ? xb[i] : zero; + // invoke callback + cdata[i][j] = callback(va, vb); + } + } + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix A and SparseMatrix B nonzero items and invokes the callback function f(Aij, Bij). + * Callback function invoked MAX(NNZA, NNZB) times + * + * + * ┌ f(Aij, Bij) ; A(i,j) !== 0 && B(i,j) !== 0 + * C(i,j) = ┤ A(i,j) ; A(i,j) !== 0 + * └ 0 ; otherwise + * + * + * @param {Matrix} a The SparseMatrix instance (A) + * @param {Matrix} b The SparseMatrix instance (B) + * @param {function} callback The f(Aij,Bij) operation to invoke + * + * @return {Matrix} SparseMatrix (C) + * + * see https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294 + */ + var algorithm8 = function (a, b, callback) { + // sparse matrix arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + var asize = a._size; + var adt = a._datatype; + var azero = a._zero; + // sparse matrix arrays + var bvalues = b._values; + var bindex = b._index; + var bptr = b._ptr; + var bsize = b._size; + var bdt = b._datatype; + var bzero = b._zero; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // check rows & columns + if (asize[0] !== bsize[0] || asize[1] !== bsize[1]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + + // sparse matrix cannot be a Pattern matrix + if (!avalues || !bvalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrices'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // process data types (zero value is required!) + var dt = adt && bdt && typeof(azero) !== 'undefined' && azero !== null && typeof(bzero) !== 'undefined' && bzero !== null && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + // equal + var ef = dt ? equal.signatures[dt + ',' + dt] || equal : equal; + + // sparse matrix zero value + var zero = dt ? azero : 0; + + // result arrays + var cvalues = []; + var cindex = []; + var cptr = new Array(columns + 1); + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns], + datatype: dt + }); + + // workspace + var x = new Array(rows); + // marks indicating we have a value in x for a given column + var w = new Array(rows); + + // vars + var k, k0, k1, i; + + // loop columns + for (var j = 0; j < columns; j++) { + // update cptr + cptr[j] = cindex.length; + // columns mark + var mark = j + 1; + // loop values in a + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // mark workspace + w[i] = mark; + // set value + x[i] = avalues[k]; + // add index + cindex.push(i); + } + // loop values in b + for (k0 = bptr[j], k1 = bptr[j + 1], k = k0; k < k1; k++) { + // row + i = bindex[k]; + // check value exists in workspace + if (w[i] === mark) { + // evaluate callback + x[i] = cf(x[i], bvalues[k]); + } + } + // initialize first index in j + k = cptr[j]; + // loop index in j + while (k < cindex.length) { + // row + i = cindex[k]; + // value @ i + var v = x[i]; + // check for zero value + if (!ef(v, zero)) { + // push value + cvalues.push(v); + // increment pointer + k++; + } + else { + // remove value @ i, do not increment pointer + cindex.splice(k, 1); + } + } + } + // update cptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked NZ times (number of nonzero items in S). + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ b ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm9 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // result arrays + var cdata = new Array(rows); + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns] + }); + + // workspaces + var x = new Array(rows); + // marks indicating we have a value in x for a given column + var w = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var r = aindex[k]; + // update workspace + x[r] = avalues[k]; + w[r] = mark; + } + // loop rows + for (var i = 0; i < rows; i++) { + // initialize C on first column + if (j === 0) { + // create row array + cdata[i] = new Array(columns); + } + // check sparse matrix has a value @ i,j + if (w[i] === mark) { + // invoke callback, update C + cdata[i][j] = inverse ? callback(b, x[i]) : callback(x[i], b); + } + else { + // dense matrix value @ i, j + cdata[i][j] = b; + } + } + } + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked NZ times (number of nonzero items in S). + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ 0 ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} SparseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm10 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // result arrays + var cvalues = []; + var cindex = []; + var cptr = new Array(columns + 1); + // matrix + var c = new SparseMatrix({ + values: cvalues, + index: cindex, + ptr: cptr, + size: [rows, columns] + }); + + // loop columns + for (var j = 0; j < columns; j++) { + // initialize ptr + cptr[j] = cindex.length; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var i = aindex[k]; + // invoke callback + var v = inverse ? callback(b, avalues[k]) : callback(avalues[k], b); + // check value is zero + if (!equal(v, 0)) { + // push index & value + cindex.push(i); + cvalues.push(v); + } + } + } + // update ptr + cptr[columns] = cindex.length; + + // return sparse matrix + return c; + }; + + /** + * Iterates over SparseMatrix S nonzero items and invokes the callback function f(Sij, b). + * Callback function invoked MxN times. + * + * + * ┌ f(Sij, b) ; S(i,j) !== 0 + * C(i,j) = ┤ + * └ f(0, b) ; otherwise + * + * + * @param {Matrix} s The SparseMatrix instance (S) + * @param {Scalar} b The Scalar value + * @param {function} callback The f(Aij,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Sij) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813 + */ + var algorithm11 = function (s, b, callback, inverse) { + // sparse matrix arrays + var avalues = s._values; + var aindex = s._index; + var aptr = s._ptr; + var asize = s._size; + + // sparse matrix cannot be a Pattern matrix + if (!avalues) + throw new Error('Cannot perform operation on Pattern Sparse Matrix and Scalar value'); + + // rows & columns + var rows = asize[0]; + var columns = asize[1]; + + // result arrays + var cdata = new Array(rows); + // matrix + var c = new DenseMatrix({ + data: cdata, + size: [rows, columns] + }); + + // workspaces + var x = new Array(rows); + // marks indicating we have a value in x for a given column + var w = new Array(rows); + + // loop columns + for (var j = 0; j < columns; j++) { + // columns mark + var mark = j + 1; + // values in j + for (var k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + var r = aindex[k]; + // update workspace + x[r] = avalues[k]; + w[r] = mark; + } + // loop rows + for (var i = 0; i < rows; i++) { + // initialize C on first column + if (j === 0) { + // create row array + cdata[i] = new Array(columns); + } + // check sparse matrix has a value @ i,j + if (w[i] === mark) { + // invoke callback, update C + cdata[i][j] = inverse ? callback(b, x[i]) : callback(x[i], b); + } + else { + // dense matrix value @ i, j + cdata[i][j] = inverse ? callback(b, 0) : callback(0, b); + } + } + } + + // return sparse matrix + return c; + }; + + /** + * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, Bij..z). + * Callback function invoked MxN times. + * + * C(i,j,...z) = f(Aij..z, Bij..z) + * + * @param {Matrix} a The DenseMatrix instance (A) + * @param {Matrix} b The DenseMatrix instance (B) + * @param {function} callback The f(Aij..z,Bij..z) operation to invoke + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97658658 + */ + var algorithm12 = function (a, b, callback) { + // a arrays + var adata = a._data; + var asize = a._size; + var adt = a._datatype; + // b arrays + var bdata = b._data; + var bsize = b._size; + var bdt = b._datatype; + + // validate dimensions + if (asize.length !== bsize.length) + throw new DimensionError(asize.length, bsize.length); + + // validate each one of the dimension sizes + for (var s = 0; s < asize.length; s++) { + // must match + if (asize[s] !== bsize[s]) + throw new RangeError('Dimension mismatch. Matrix A (' + asize + ') must match Matrix B (' + bsize + ')'); + } + + // process data types + var dt = adt && bdt && adt === bdt ? adt : undefined; + // callback implementation + var cf = dt && callback.signatures ? callback.signatures[dt + ',' + dt] || callback : callback; + + // c arrays + var cdata = new Array(asize[0]); + // c matrix + var c = new DenseMatrix({ + data: cdata, + size: object.clone(asize), + datatype: dt + }); + + // recursive function + var iterate = function (level, n, av, bv, cv) { + // check we reach the last level + if (level === asize.length - 1) { + // loop arrays in last level + for (var i = 0; i < n; i++) { + // invoke callback and store value + cv[i] = cf(av[i], bv[i]); + } + } + else { + // iterate current level + for (var j = 0; j < n; j++) { + // initialize cv for this level + var cvl = new Array(n); + // iterate next level + iterate(level + 1, asize[level + 1], av[j], bv[j], cvl); + // store array + cv[j] = cvl; + } + } + }; + + // populate cdata, iterate through dimensions + iterate(0, cdata.length, adata, bdata, cdata); + + // return matrix + return c; + }; + + /** + * Iterates over DenseMatrix items and invokes the callback function f(Aij..z, b). + * Callback function invoked MxN times. + * + * C(i,j,...z) = f(Aij..z, b) + * + * @param {Matrix} a The DenseMatrix instance (A) + * @param {Scalar} b The Scalar value + * @param {function} callback The f(Aij..z,b) operation to invoke + * @param {boolean} inverse A true value indicates callback should be invoked f(b,Aij..z) + * + * @return {Matrix} DenseMatrix (C) + * + * https://github.com/josdejong/mathjs/pull/346#issuecomment-97659042 + */ + var algorithm13 = function (a, b, callback, inverse) { + // a arrays + var adata = a._data; + var asize = a._size; + + // c arrays + var cdata = new Array(asize[0]); + // c matrix + var c = new DenseMatrix({ + data: cdata, + size: object.clone(asize) + }); + + // recursive function + var iterate = function (level, n, av, cv) { + // check we reach the last level + if (level === asize.length - 1) { + // loop arrays in last level + for (var i = 0; i < n; i++) { + // invoke callback and store value + cv[i] = inverse ? callback(b, av[i]) : callback(av[i], b); + } + } + else { + // iterate current level + for (var j = 0; j < n; j++) { + // initialize cv for this level + var cvl = new Array(n); + // iterate next level + iterate(level + 1, asize[level + 1], av[j], cvl); + // store array + cv[j] = cvl; + } + } + }; + + // populate cdata, iterate through dimensions + iterate(0, cdata.length, adata, cdata); + + // return matrix + return c; + }; + + var _scatter = function (a, j, w, x, u, mark, c, f, inverse, update, value) { + // a arrays + var avalues = a._values; + var aindex = a._index; + var aptr = a._ptr; + // c arrays + var cindex = c ? c._index : undefined; + + // vars + var k, k0, k1, i; + + // check we need to process values (pattern matrix) + if (x) { + // values in j + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // check value exists in current j + if (w[i] !== mark) { + // i is new entry in j + w[i] = mark; + // add i to pattern of C (if C was provided) + if (cindex) + cindex.push(i); + // x(i) = A, check we need to call function this time + if (update) { + // copy value to workspace calling callback function + x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]); + // function was called on current row + u[i] = mark; + } + else { + // copy value to workspace + x[i] = avalues[k]; + } + } + else { + // i exists in C already + x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]); + // function was called on current row + u[i] = mark; + } + } + } + else { + // values in j + for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) { + // row + i = aindex[k]; + // check value exists in current j + if (w[i] !== mark) { + // i is new entry in j + w[i] = mark; + // add i to pattern of C (if C was provided) + if (cindex) + cindex.push(i); + } + else { + // indicate function was called on current row + u[i] = mark; + } + } + } + }; + + // return algorithms + return { + // dense, sparse (https://github.com/josdejong/mathjs/pull/346#issuecomment-97477571) + algorithm1: algorithm1, + algorithm2: algorithm2, + algorithm3: algorithm3, + // sparse, sparse (https://github.com/josdejong/mathjs/pull/346#issuecomment-97620294) + algorithm4: algorithm4, + algorithm5: algorithm5, + algorithm6: algorithm6, + algorithm7: algorithm7, + algorithm8: algorithm8, + // sparse, scalar (https://github.com/josdejong/mathjs/pull/346#issuecomment-97626813) + algorithm9: algorithm9, + algorithm10: algorithm10, + algorithm11: algorithm11, + // dense, dense (https://github.com/josdejong/mathjs/pull/346#issuecomment-97658658) + algorithm12: algorithm12, + // dense, scalar (https://github.com/josdejong/mathjs/pull/346#issuecomment-97659042) + algorithm13: algorithm13 + }; + } + + exports.name = 'elementWiseOperations'; + exports.factory = factory; + + +/***/ }, +/* 194 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; /** - * Format a number using methods toPrecision, toFixed, toExponential. - * @param {number | string} value - * @constructor + * Create a syntax error with the message: + * 'Wrong number of arguments in function ( provided, - expected)' + * @param {String} fn Function name + * @param {Number} count Actual argument count + * @param {Number} min Minimum required argument count + * @param {Number} [max] Maximum required argument count + * @extends Error */ - function NumberFormatter (value) { - // parse the input value - var match = String(value).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/); - if (!match) { - throw new SyntaxError('Invalid number'); + function ArgumentsError(fn, count, min, max) { + if (!(this instanceof ArgumentsError)) { + throw new SyntaxError('Constructor must be called with the new operator'); } - var sign = match[1]; - var coefficients = match[2]; - var exponent = parseFloat(match[4] || '0'); + this.fn = fn; + this.count = count; + this.min = min; + this.max = max; - var dot = coefficients.indexOf('.'); - exponent += (dot !== -1) ? (dot - 1) : (coefficients.length - 1); + this.message = 'Wrong number of arguments in function ' + fn + + ' (' + count + ' provided, ' + + min + ((max != undefined) ? ('-' + max) : '') + ' expected)'; - this.sign = sign; - this.coefficients = coefficients - .replace('.', '') // remove the dot (must be removed before removing leading zeros) - .replace(/^0*/, function (zeros) { - // remove leading zeros, add their count to the exponent - exponent -= zeros.length; - return ''; - }) - .replace(/0*$/, '') // remove trailing zeros - .split('') - .map(function (d) { - return parseInt(d); - }); - - if (this.coefficients.length === 0) { - this.coefficients.push(0); - exponent++; - } - - this.exponent = exponent; + this.stack = (new Error()).stack; } - /** - * Format a number with fixed notation. - * @param {Number} [precision=0] Optional number of decimals after the - * decimal point. Zero by default. - */ - NumberFormatter.prototype.toFixed = function (precision) { - var rounded = this.roundDigits(this.exponent + 1 + (precision || 0)); - var c = rounded.coefficients; - var p = rounded.exponent + 1; // exponent may have changed + ArgumentsError.prototype = new Error(); + ArgumentsError.prototype.constructor = Error; + ArgumentsError.prototype.name = 'ArgumentsError'; - // append zeros if needed - var pp = p + (precision || 0); - if (c.length < pp) { - c = c.concat(zeros(pp - c.length)); - } + module.exports = ArgumentsError; + + +/***/ }, +/* 195 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; - // prepend zeros if needed - if (p < 0) { - c = zeros(-p + 1).concat(c); - p = 1; - } + var string = __webpack_require__(42); - // insert a dot if needed - if (precision) { - c.splice(p, 0, (p === 0) ? '0.' : '.'); - } + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); - return this.sign + c.join(''); - }; - - /** - * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3' - * @param {Number} [precision] Number of digits in formatted output. - * If not provided, the maximum available digits - * is used. - */ - NumberFormatter.prototype.toExponential = function (precision) { - // round if needed, else create a clone - var rounded = precision ? this.roundDigits(precision) : this.clone(); - var c = rounded.coefficients; - var e = rounded.exponent; - - // append zeros if needed - if (c.length < precision) { - c = c.concat(zeros(precision - c.length)); - } - - // format as `C.CCCe+EEE` or `C.CCCe-EEE` - var first = c.shift(); - return this.sign + first + (c.length > 0 ? ('.' + c.join('')) : '') + - 'e' + (e >= 0 ? '+' : '') + e; - }; - - /** - * Format a number with a certain precision - * @param {Number} [precision=undefined] Optional number of digits. - * @param {{lower: number | undefined, upper: number | undefined}} [options] - * By default: - * lower = 1e-3 (excl) - * upper = 1e+5 (incl) - * @return {string} - */ - NumberFormatter.prototype.toPrecision = function(precision, options) { - // determine lower and upper bound for exponential notation. - var lower = (options && options.lower !== undefined) ? options.lower : 1e-3; - var upper = (options && options.upper !== undefined) ? options.upper : 1e+5; - - var abs = Math.abs(Math.pow(10, this.exponent)); - if (abs < lower || abs >= upper) { - // exponential notation - return this.toExponential(precision); - } - else { - var rounded = precision ? this.roundDigits(precision) : this.clone(); - var c = rounded.coefficients; - var e = rounded.exponent; - - // append trailing zeros - if (c.length < precision) { - c = c.concat(zeros(precision - c.length)); + /** + * @constructor ArrayNode + * @extends {Node} + * Holds an 1-dimensional array with nodes + * @param {Node[]} [nodes] 1 dimensional array with nodes + */ + function ArrayNode(nodes) { + if (!(this instanceof ArrayNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); } - // append trailing zeros - // TODO: simplify the next statement - c = c.concat(zeros(e - c.length + 1 + - (c.length < precision ? precision - c.length : 0))); + this.nodes = nodes || []; - // prepend zeros - c = zeros(-e).concat(c); + // validate input + if (!Array.isArray(this.nodes) + || !this.nodes.every(function (node) {return node && node.isNode;})) { + throw new TypeError('Array containing Nodes expected'); + } + } - var dot = e > 0 ? e : 0; - if (dot < c.length - 1) { - c.splice(dot + 1, 0, '.'); + ArrayNode.prototype = new Node(); + + ArrayNode.prototype.type = 'ArrayNode'; + + ArrayNode.prototype.isArrayNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @private + */ + ArrayNode.prototype._compile = function (defs) { + var asMatrix = (defs.math.config().matrix !== 'array'); + + var nodes = this.nodes.map(function (node) { + return node._compile(defs); + }); + + return (asMatrix ? 'math.matrix([' : '[') + + nodes.join(',') + + (asMatrix ? '])' : ']'); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ArrayNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.nodes.length; i++) { + var node = this.nodes[i]; + callback(node, 'nodes[' + i + ']', this); + } + }; + + /** + * Create a new ArrayNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {ArrayNode} Returns a transformed copy of the node + */ + ArrayNode.prototype.map = function (callback) { + var nodes = []; + for (var i = 0; i < this.nodes.length; i++) { + nodes[i] = this._ifNode(callback(this.nodes[i], 'nodes[' + i + ']', this)); + } + return new ArrayNode(nodes); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ArrayNode} + */ + ArrayNode.prototype.clone = function() { + return new ArrayNode(this.nodes.slice(0)); + }; + + /** + * Get string representation + * @return {String} str + * @override + */ + ArrayNode.prototype._toString = function() { + return string.format(this.nodes); + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @param {String} type + * @return {String} str + */ + ArrayNode.prototype._toTex = function(callbacks) { + var s = '\\begin{bmatrix}'; + + this.nodes.forEach(function(node) { + if (node.nodes) { + s += node.nodes.map(function(childNode) { + return childNode.toTex(callbacks); + }).join('&'); + } + else { + s += node.toTex(callbacks); + } + + // new line + s += '\\\\'; + }); + s += '\\end{bmatrix}'; + return s; + }; + + return ArrayNode; + } + + exports.name = 'ArrayNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 196 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(369); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + var ArrayNode = load(__webpack_require__(195)); + + var keywords = __webpack_require__(370); + var operators = __webpack_require__(371); + + /** + * @constructor AssignmentNode + * @extends {Node} + * Define a symbol, like "a = 3.2" + * + * @param {String} name Symbol name + * @param {Node} expr The expression defining the symbol + */ + function AssignmentNode(name, expr) { + if (!(this instanceof AssignmentNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); } - return this.sign + c.join(''); - } - }; + // validate input + if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); + if (!(expr && expr.isNode)) throw new TypeError('Node expected for parameter "expr"'); + if (name in keywords) throw new Error('Illegal symbol name, "' + name + '" is a reserved keyword'); - /** - * Crete a clone of the NumberFormatter - * @return {NumberFormatter} Returns a clone of the NumberFormatter - */ - NumberFormatter.prototype.clone = function () { - var clone = new NumberFormatter('0'); - clone.sign = this.sign; - clone.coefficients = this.coefficients.slice(0); - clone.exponent = this.exponent; - return clone; - }; - - /** - * Round the number of digits of a number * - * @param {number} precision A positive integer - * @return {NumberFormatter} Returns a new NumberFormatter with the rounded - * digits - */ - NumberFormatter.prototype.roundDigits = function (precision) { - var rounded = this.clone(); - var c = rounded.coefficients; - - // prepend zeros if needed - while (precision <= 0) { - c.unshift(0); - rounded.exponent++; - precision++; + this.name = name; + this.expr = expr; } - if (c.length > precision) { - var removed = c.splice(precision); + AssignmentNode.prototype = new Node(); - if (removed[0] >= 5) { - var i = precision - 1; - c[i]++; - while (c[i] === 10) { - c.pop(); - if (i === 0) { - c.unshift(0); - rounded.exponent++; - i++; + AssignmentNode.prototype.type = 'AssignmentNode'; + + AssignmentNode.prototype.isAssignmentNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @private + */ + AssignmentNode.prototype._compile = function (defs) { + return 'scope["' + this.name + '"] = ' + this.expr._compile(defs) + ''; + }; + + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + AssignmentNode.prototype.forEach = function (callback) { + callback(this.expr, 'expr', this); + }; + + /** + * Create a new AssignmentNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {AssignmentNode} Returns a transformed copy of the node + */ + AssignmentNode.prototype.map = function (callback) { + return new AssignmentNode(this.name, this._ifNode(callback(this.expr, 'expr', this))); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {AssignmentNode} + */ + AssignmentNode.prototype.clone = function() { + return new AssignmentNode(this.name, this.expr); + }; + + /** + * Get string representation + * @return {String} + */ + AssignmentNode.prototype._toString = function() { + var precedence = operators.getPrecedence(this); + var exprPrecedence = operators.getPrecedence(this.expr); + var expr = this.expr._toString(); + if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { + expr = '(' + expr + ')'; + } + return this.name + ' = ' + expr; + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} + */ + AssignmentNode.prototype._toTex = function(callbacks) { + var precedence = operators.getPrecedence(this); + var exprPrecedence = operators.getPrecedence(this.expr); + + var expr = this.expr.toTex(callbacks); + if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { + expr = '\\left(' + expr + '\\right)'; + } + + return latex.toSymbol(this.name) + ':=' + expr; + }; + + return AssignmentNode; + } + + exports.name = 'AssignmentNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 197 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + var ResultSet = load(__webpack_require__(9)); + + /** + * @constructor BlockNode + * @extends {Node} + * Holds a set with blocks + * @param {Array.<{node: Node} | {node: Node, visible: boolean}>} blocks + * An array with blocks, where a block is constructed as an Object + * with properties block, which is a Node, and visible, which is + * a boolean. The property visible is optional and is true by default + */ + function BlockNode(blocks) { + if (!(this instanceof BlockNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input, copy blocks + if (!Array.isArray(blocks)) throw new Error('Array expected'); + this.blocks = blocks.map(function (block) { + var node = block && block.node; + var visible = block && block.visible !== undefined ? block.visible : true; + + if (!(node && node.isNode)) throw new TypeError('Property "node" must be a Node'); + if (typeof visible !== 'boolean') throw new TypeError('Property "visible" must be a boolean'); + + return { + node: node, + visible: visible + } + }); + } + + BlockNode.prototype = new Node(); + + BlockNode.prototype.type = 'BlockNode'; + + BlockNode.prototype.isBlockNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + BlockNode.prototype._compile = function (defs) { + defs.ResultSet = ResultSet; + var blocks = this.blocks.map(function (param) { + var js = param.node._compile(defs); + if (param.visible) { + return 'results.push(' + js + ');'; + } + else { + return js + ';'; + } + }); + + return '(function () {' + + 'var results = [];' + + blocks.join('') + + 'return new ResultSet(results);' + + '})()'; + }; + + /** + * Execute a callback for each of the child blocks of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + BlockNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.blocks.length; i++) { + callback(this.blocks[i].node, 'blocks[' + i + '].node', this); + } + }; + + /** + * Create a new BlockNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {BlockNode} Returns a transformed copy of the node + */ + BlockNode.prototype.map = function (callback) { + var blocks = []; + for (var i = 0; i < this.blocks.length; i++) { + var block = this.blocks[i]; + var node = this._ifNode(callback(block.node, 'blocks[' + i + '].node', this)); + blocks[i] = { + node: node, + visible: block.visible + }; + } + return new BlockNode(blocks); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {BlockNode} + */ + BlockNode.prototype.clone = function () { + var blocks = this.blocks.map(function (block) { + return { + node: block.node, + visible: block.visible + }; + }); + + return new BlockNode(blocks); + }; + + /** + * Get string representation + * @return {String} str + * @override + */ + BlockNode.prototype._toString = function () { + return this.blocks.map(function (param) { + return param.node._toString() + (param.visible ? '' : ';'); + }).join('\n'); + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + BlockNode.prototype._toTex = function (callbacks) { + return this.blocks.map(function (param) { + return param.node.toTex(callbacks) + (param.visible ? '' : ';'); + }).join('\n'); + }; + + return BlockNode; + } + + exports.name = 'BlockNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 198 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(369); + var operators = __webpack_require__(371); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + + var BigNumber = load(__webpack_require__(10)); + var Complex = load(__webpack_require__(3)); + var Unit = load(__webpack_require__(7)); + + /** + * A lazy evaluating conditional operator: 'condition ? trueExpr : falseExpr' + * + * @param {Node} condition Condition, must result in a boolean + * @param {Node} trueExpr Expression evaluated when condition is true + * @param {Node} falseExpr Expression evaluated when condition is true + * + * @constructor ConditionalNode + * @extends {Node} + */ + function ConditionalNode(condition, trueExpr, falseExpr) { + if (!(this instanceof ConditionalNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + if (!(condition && condition.isNode)) throw new TypeError('Parameter condition must be a Node'); + if (!(trueExpr && trueExpr.isNode)) throw new TypeError('Parameter trueExpr must be a Node'); + if (!(falseExpr && falseExpr.isNode)) throw new TypeError('Parameter falseExpr must be a Node'); + + this.condition = condition; + this.trueExpr = trueExpr; + this.falseExpr = falseExpr; + } + + ConditionalNode.prototype = new Node(); + + ConditionalNode.prototype.type = 'ConditionalNode'; + + ConditionalNode.prototype.isConditionalNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + ConditionalNode.prototype._compile = function (defs) { + /** + * Test whether a condition is met + * @param {*} condition + * @returns {boolean} true if condition is true or non-zero, else false + */ + defs.testCondition = function (condition) { + if (typeof condition === 'number' + || typeof condition === 'boolean' + || typeof condition === 'string') { + return condition ? true : false; + } + + if (condition instanceof BigNumber) { + return condition.isZero() ? false : true; + } + + if (condition instanceof Complex) { + return (condition.re || condition.im) ? true : false; + } + + if (condition instanceof Unit) { + return condition.value ? true : false; + } + + if (condition === null || condition === undefined) { + return false; + } + + throw new TypeError('Unsupported type of condition "' + defs.math['typeof'](condition) + '"'); + }; + + return ( + 'testCondition(' + this.condition._compile(defs) + ') ? ' + + '( ' + this.trueExpr._compile(defs) + ') : ' + + '( ' + this.falseExpr._compile(defs) + ')' + ); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ConditionalNode.prototype.forEach = function (callback) { + callback(this.condition, 'condition', this); + callback(this.trueExpr, 'trueExpr', this); + callback(this.falseExpr, 'falseExpr', this); + }; + + /** + * Create a new ConditionalNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {ConditionalNode} Returns a transformed copy of the node + */ + ConditionalNode.prototype.map = function (callback) { + return new ConditionalNode( + this._ifNode(callback(this.condition, 'condition', this)), + this._ifNode(callback(this.trueExpr, 'trueExpr', this)), + this._ifNode(callback(this.falseExpr, 'falseExpr', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ConditionalNode} + */ + ConditionalNode.prototype.clone = function () { + return new ConditionalNode(this.condition, this.trueExpr, this.falseExpr); + }; + + /** + * Get string representation + * @return {String} str + */ + ConditionalNode.prototype._toString = function () { + var precedence = operators.getPrecedence(this); + + //Enclose Arguments in parentheses if they are an OperatorNode + //or have lower or equal precedence + //NOTE: enclosing all OperatorNodes in parentheses is a decision + //purely based on aesthetics and readability + var condition = this.condition._toString(); + var conditionPrecedence = operators.getPrecedence(this.condition); + if ((this.condition.type === 'OperatorNode') + || ((conditionPrecedence !== null) && (conditionPrecedence <= precedence))) { + condition = '(' + condition + ')'; + } + + var trueExpr = this.trueExpr._toString(); + var truePrecedence = operators.getPrecedence(this.trueExpr); + if ((this.trueExpr.type === 'OperatorNode') + || ((truePrecedence !== null) && (truePrecedence <= precedence))) { + trueExpr = '(' + trueExpr + ')'; + } + + var falseExpr = this.falseExpr._toString(); + var falsePrecedence = operators.getPrecedence(this.falseExpr); + if ((this.falseExpr.type === 'OperatorNode') + || ((falsePrecedence !== null) && (falsePrecedence <= precedence))) { + falseExpr = '(' + falseExpr + ')'; + } + return condition + ' ? ' + trueExpr + ' : ' + falseExpr; + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + ConditionalNode.prototype._toTex = function (callbacks) { + return '\\left\\{\\begin{array}{l l}{' + + this.trueExpr.toTex(callbacks) + '}, &\\quad{\\text{if}\\;' + + this.condition.toTex(callbacks) + + '}\\\\{' + this.falseExpr.toTex(callbacks) + + '}, &\\quad{\\text{otherwise}}\\end{array}\\right.'; + }; + + return ConditionalNode; + } + + exports.name = 'ConditionalNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 199 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var getType = __webpack_require__(189).type; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + + /** + * A ConstantNode holds a constant value like a number or string. A ConstantNode + * stores a stringified version of the value and uses this to compile to + * JavaScript. + * + * In case of a stringified number as input, this may be compiled to a BigNumber + * when the math instance is configured for BigNumbers. + * + * Usage: + * + * // stringified values with type + * new ConstantNode('2.3', 'number'); + * new ConstantNode('true', 'boolean'); + * new ConstantNode('hello', 'string'); + * + * // non-stringified values, type will be automatically detected + * new ConstantNode(2.3); + * new ConstantNode('hello'); + * + * @param {String | Number | Boolean | null | undefined} value + * When valueType is provided, value must contain + * an uninterpreted string representing the value. + * When valueType is undefined, value can be a + * number, string, boolean, null, or undefined, and + * the type will be determined automatically. + * @param {String} [valueType] The type of value. Choose from 'number', 'string', + * 'boolean', 'undefined', 'null' + * @constructor ConstantNode + * @extends {Node} + */ + function ConstantNode(value, valueType) { + if (!(this instanceof ConstantNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (valueType) { + if (typeof valueType !== 'string') { + throw new TypeError('String expected for parameter "valueType"'); + } + if (typeof value !== 'string') { + throw new TypeError('String expected for parameter "value"'); + } + + this.value = value; + this.valueType = valueType; + } + else { + // stringify the value and determine the type + this.value = value + ''; + this.valueType = getType(value); + } + + if (!SUPPORTED_TYPES[this.valueType]) { + throw new TypeError('Unsupported type of value "' + this.valueType + '"'); + } + } + + var SUPPORTED_TYPES = { + 'number': true, + 'string': true, + 'boolean': true, + 'undefined': true, + 'null': true + }; + + ConstantNode.prototype = new Node(); + + ConstantNode.prototype.type = 'ConstantNode'; + + ConstantNode.prototype.isConstantNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + ConstantNode.prototype._compile = function (defs) { + switch (this.valueType) { + case 'number': + if (defs.math.config().number === 'bignumber') { + return 'math.bignumber("' + this.value + '")'; + } + else { + // remove leading zeros like '003.2' which are not allowed by JavaScript + return this.value.replace(/^(0*)[0-9]/, function (match, zeros) { + return match.substring(zeros.length); + }); + } + + case 'string': + return '"' + this.value + '"'; + + case 'boolean': + return this.value; + + case 'undefined': + return this.value; + + case 'null': + return this.value; + + default: + // TODO: move this error to the constructor? + throw new TypeError('Unsupported type of constant "' + this.valueType + '"'); + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + ConstantNode.prototype.forEach = function (callback) { + // nothing to do, we don't have childs + }; + + + /** + * Create a new ConstantNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node) : Node} callback + * @returns {ConstantNode} Returns a clone of the node + */ + ConstantNode.prototype.map = function (callback) { + return this.clone(); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {ConstantNode} + */ + ConstantNode.prototype.clone = function () { + return new ConstantNode(this.value, this.valueType); + }; + + /** + * Get string representation + * @return {String} str + */ + ConstantNode.prototype._toString = function () { + switch (this.valueType) { + case 'string': + return '"' + this.value + '"'; + + default: + return this.value; + } + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + ConstantNode.prototype._toTex = function (callbacks) { + var value = this.value, + index; + switch (this.valueType) { + case 'string': + return '\\mathtt{"' + value + '"}'; + + case 'number': + index = value.toLowerCase().indexOf('e'); + if (index !== -1) { + return value.substring(0, index) + '\\cdot10^{' + + value.substring(index + 1) + '}'; + } + return value; + + default: + return value; + } + }; + + return ConstantNode; + } + + exports.name = 'ConstantNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 200 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var keywords = __webpack_require__(370); + var latex = __webpack_require__(369); + var operators = __webpack_require__(371); + + function isString (x) { + return typeof x === 'string'; + } + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + + /** + * @constructor FunctionAssignmentNode + * @extends {Node} + * Function assignment + * + * @param {String} name Function name + * @param {String[]} params Function parameter names + * @param {Node} expr The function expression + */ + function FunctionAssignmentNode(name, params, expr) { + if (!(this instanceof FunctionAssignmentNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); + if (!Array.isArray(params) || !params.every(isString)) throw new TypeError('Array containing strings expected for parameter "params"'); + if (!(expr && expr.isNode)) throw new TypeError('Node expected for parameter "expr"'); + if (name in keywords) throw new Error('Illegal function name, "' + name + '" is a reserved keyword'); + + this.name = name; + this.params = params; + this.expr = expr; + } + + FunctionAssignmentNode.prototype = new Node(); + + FunctionAssignmentNode.prototype.type = 'FunctionAssignmentNode'; + + FunctionAssignmentNode.prototype.isFunctionAssignmentNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + FunctionAssignmentNode.prototype._compile = function (defs) { + // add the function arguments to defs (used by SymbolNode and UpdateNode) + this.params.forEach(function (variable) { + defs.args[variable] = true; + }); + + return 'scope["' + this.name + '"] = ' + + ' (function () {' + + ' var fn = function ' + this.name + '(' + this.params.join(',') + ') {' + + ' if (arguments.length != ' + this.params.length + ') {' + + // TODO: use util.error.ArgumentsError here? + // TODO: test arguments error + ' throw new SyntaxError("Wrong number of arguments in function ' + this.name + ' (" + arguments.length + " provided, ' + this.params.length + ' expected)");' + + ' }' + + ' return ' + this.expr._compile(defs) + '' + + ' };' + + ' fn.syntax = "' + this.name + '(' + this.params.join(', ') + ')";' + + ' return fn;' + + ' })();'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + FunctionAssignmentNode.prototype.forEach = function (callback) { + callback(this.expr, 'expr', this); + }; + + /** + * Create a new FunctionAssignmentNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {FunctionAssignmentNode} Returns a transformed copy of the node + */ + FunctionAssignmentNode.prototype.map = function (callback) { + var expr = this._ifNode(callback(this.expr, 'expr', this)); + + return new FunctionAssignmentNode(this.name, this.params.slice(0), expr); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {FunctionAssignmentNode} + */ + FunctionAssignmentNode.prototype.clone = function () { + return new FunctionAssignmentNode(this.name, this.params.slice(0), this.expr); + }; + + /** + * get string representation + * @return {String} str + */ + FunctionAssignmentNode.prototype._toString = function () { + var precedence = operators.getPrecedence(this); + var exprPrecedence = operators.getPrecedence(this.expr); + + var expr = this.expr._toString(); + if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { + expr = '(' + expr + ')'; + } + return 'function ' + this.name + + '(' + this.params.join(', ') + ') = ' + expr; + }; + + /** + * get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + FunctionAssignmentNode.prototype._toTex = function (callbacks) { + var precedence = operators.getPrecedence(this); + var exprPrecedence = operators.getPrecedence(this.expr); + + var expr = this.expr.toTex(callbacks); + if ((exprPrecedence !== null) && (exprPrecedence <= precedence)) { + expr = '\\left(' + expr + '\\right)'; + } + + return '\\mathrm{' + this.name + + '}\\left(' + this.params.map(latex.toSymbol).join(',') + '\\right):=' + expr; + }; + + return FunctionAssignmentNode; + } + exports.name = 'FunctionAssignmentNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 201 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + var RangeNode = load(__webpack_require__(204)); + var SymbolNode = load(__webpack_require__(205)); + + var BigNumber = load(__webpack_require__(10)); + var Range = load(__webpack_require__(4)); + + var isArray = Array.isArray; + + /** + * @constructor IndexNode + * @extends Node + * + * get a subset of a matrix + * + * @param {Node} object + * @param {Node[]} ranges + */ + function IndexNode(object, ranges) { + if (!(this instanceof IndexNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (!(object && object.isNode)) throw new TypeError('Node expected for parameter "object"'); + if (!isArray(ranges) + || !ranges.every(function (range) {return range && range.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "ranges"'); + } + + this.object = object; + this.ranges = ranges; + } + + IndexNode.prototype = new Node(); + + IndexNode.prototype.type = 'IndexNode'; + + IndexNode.prototype.isIndexNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + IndexNode.prototype._compile = function (defs) { + return this.compileSubset(defs); + }; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the + * compiled expression + * @param {String} [replacement] If provided, the function returns + * "math.subset(obj, math.index(...), replacement)" + * Else, the function returns + * "math.subset(obj, math.index(...))" + * @return {String} js + * @returns {string} + */ + IndexNode.prototype.compileSubset = function (defs, replacement) { + // check whether any of the ranges expressions uses the context symbol 'end' + function test(node) { + return (node && node.isSymbolNode) && (node.name == 'end'); + } + + var someUseEnd = false; + var rangesUseEnd = this.ranges.map(function (range) { + var useEnd = range.filter(test).length > 0; + someUseEnd = useEnd ? useEnd : someUseEnd; + return useEnd; + }); + + // create a Range from start, step and end + defs.range = function (start, end, step) { + return new Range( + start instanceof BigNumber ? start.toNumber() : start, + end instanceof BigNumber ? end.toNumber() : end, + step instanceof BigNumber ? step.toNumber() : step + ); + }; + + // TODO: implement support for bignumber (currently bignumbers are silently + // reduced to numbers when changing the value to zero-based) + + // TODO: Optimization: when the range values are ConstantNodes, + // we can beforehand resolve the zero-based value + + var ranges = this.ranges.map(function (range, i) { + var useEnd = rangesUseEnd[i]; + if (range && range.isRangeNode) { + if (useEnd) { + defs.args.end = true; + + // resolve end and create range + return '(function () {' + + ' var end = size[' + i + '];' + + ' return range(' + + ' ' + range.start._compile(defs) + ', ' + + ' ' + range.end._compile(defs) + ', ' + + ' ' + (range.step ? range.step._compile(defs) : '1') + + ' );' + + '})()'; + } + else { + // create range + return 'range(' + + range.start._compile(defs) + ', ' + + range.end._compile(defs) + ', ' + + (range.step ? range.step._compile(defs) : '1') + + ')'; + } + } + else { + if (useEnd) { + defs.args.end = true; + + // resolve the parameter 'end' + return '(function () {' + + ' var end = size[' + i + '];' + + ' return ' + range._compile(defs) + ';' + + '})()' + } + else { + // just evaluate the expression + return range._compile(defs); + } + } + }); + + // if some parameters use the 'end' parameter, we need to calculate the size + if (someUseEnd) { + return '(function () {' + + ' var obj = ' + this.object._compile(defs) + ';' + + ' var size = math.size(obj).valueOf();' + + ' return math.subset(' + + ' obj, ' + + ' math.index(' + ranges.join(', ') + ')' + + ' ' + (replacement ? (', ' + replacement) : '') + + ' );' + + '})()'; + } + else { + return 'math.subset(' + + this.object._compile(defs) + ',' + + 'math.index(' + ranges.join(', ') + ')' + + (replacement ? (', ' + replacement) : '') + + ')'; + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + IndexNode.prototype.forEach = function (callback) { + // object + callback(this.object, 'object', this); + + // ranges + for (var i = 0; i < this.ranges.length; i++) { + callback(this.ranges[i], 'ranges[' + i + ']', this); + } + }; + + /** + * Create a new IndexNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {IndexNode} Returns a transformed copy of the node + */ + IndexNode.prototype.map = function (callback) { + var object = this._ifNode(callback(this.object, 'object', this)); + + var ranges = []; + for (var i = 0; i < this.ranges.length; i++) { + ranges[i] = this._ifNode(callback(this.ranges[i], 'ranges[' + i + ']', this)); + } + + return new IndexNode(object, ranges); + }; + + /** + * Get the name of the object linked to this IndexNode + * @return {string} name + */ + IndexNode.prototype.objectName = function () { + return this.object.name; + }; + + /** + * Create a clone of this node, a shallow copy + * @return {IndexNode} + */ + IndexNode.prototype.clone = function () { + return new IndexNode(this.object, this.ranges.slice(0)); + }; + + /** + * Get string representation + * @return {String} str + */ + IndexNode.prototype._toString = function () { + // format the parameters like "[1, 0:5]" + return this.object._toString() + '[' + this.ranges.join(', ') + ']'; + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + IndexNode.prototype._toTex = function (callbacks) { + var ranges = this.ranges.map(function (range) { + return range.toTex(callbacks); + }); + return this.object.toTex(callbacks) + '_{\\left[' + ranges.join(',') + '\\right]}'; + }; + + return IndexNode; + } + + exports.name = 'IndexNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 202 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(369); + var operators = __webpack_require__(371); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(212)); + var ConstantNode = load(__webpack_require__(199)); + var SymbolNode = load(__webpack_require__(205)); + var FunctionNode = load(__webpack_require__(203)); + + /** + * @constructor OperatorNode + * @extends {Node} + * An operator with two arguments, like 2+3 + * + * @param {String} op Operator name, for example '+' + * @param {String} fn Function name, for example 'add' + * @param {Node[]} args Operator arguments + */ + function OperatorNode(op, fn, args) { + if (!(this instanceof OperatorNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + //validate input + if (typeof op !== 'string') { + throw new TypeError('string expected for parameter "op"'); + } + if (typeof fn !== 'string') { + throw new TypeError('string expected for parameter "fn"'); + } + if (!Array.isArray(args) + || !args.every(function (node) {return node && node.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "args"'); + } + + this.op = op; + this.fn = fn; + this.args = args || []; + } + + OperatorNode.prototype = new Node(); + + OperatorNode.prototype.type = 'OperatorNode'; + + OperatorNode.prototype.isOperatorNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + OperatorNode.prototype._compile = function (defs) { + if (!(this.fn in defs.math)) { + throw new Error('Function ' + this.fn + ' missing in provided namespace "math"'); + } + + var args = this.args.map(function (arg) { + return arg._compile(defs); + }); + return 'math.' + this.fn + '(' + args.join(', ') + ')'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + OperatorNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.args.length; i++) { + callback(this.args[i], 'args[' + i + ']', this); + } + }; + + /** + * Create a new OperatorNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {OperatorNode} Returns a transformed copy of the node + */ + OperatorNode.prototype.map = function (callback) { + var args = []; + for (var i = 0; i < this.args.length; i++) { + args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); + } + return new OperatorNode(this.op, this.fn, args); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {OperatorNode} + */ + OperatorNode.prototype.clone = function () { + return new OperatorNode(this.op, this.fn, this.args.slice(0)); + }; + + /** + * Calculate which parentheses are necessary. Gets an OperatorNode + * (which is the root of the tree) and an Array of Nodes + * (this.args) and returns an array where 'true' means that an argument + * has to be enclosed in parentheses whereas 'false' means the opposite. + * + * @param {OperatorNode} root + * @param {Node[]} arguments + * @param {bool} + * @return {bool[]} + * @private + */ + function calculateNecessaryParentheses(root, args, latex) { + //precedence of the root OperatorNode + var precedence = operators.getPrecedence(root); + var associativity = operators.getAssociativity(root); + + switch (args.length) { + case 1: //unary operators + //precedence of the operand + var operandPrecedence = operators.getPrecedence(args[0]); + + //handle special cases for LaTeX, where some of the parentheses aren't needed + if (latex && (operandPrecedence !== null)) { + var operandIdentifier = args[0].getIdentifier(); + var rootIdentifier = root.getIdentifier(); + if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { + return [false]; + } + + if (operators.properties[operandPrecedence][operandIdentifier].latexParens === false) { + return [false]; + } + } + + if (operandPrecedence === null) { + //if the operand has no defined precedence, no parens are needed + return [false]; + } + + if (operandPrecedence <= precedence) { + //if the operands precedence is lower, parens are needed + return [true]; + } + + //otherwise, no parens needed + return [false]; + + case 2: //binary operators + var lhsParens; //left hand side needs parenthesis? + //precedence of the left hand side + var lhsPrecedence = operators.getPrecedence(args[0]); + //is the root node associative with the left hand side + var assocWithLhs = operators.isAssociativeWith(root, args[0]); + + if (lhsPrecedence === null) { + //if the left hand side has no defined precedence, no parens are needed + //FunctionNode for example + lhsParens = false; + } + else if ((lhsPrecedence === precedence) && (associativity === 'right') && !assocWithLhs) { + //In case of equal precedence, if the root node is left associative + // parens are **never** necessary for the left hand side. + //If it is right associative however, parens are necessary + //if the root node isn't associative with the left hand side + lhsParens = true; + } + else if (lhsPrecedence < precedence) { + lhsParens = true; + } + else { + lhsParens = false; + } + + var rhsParens; //right hand side needs parenthesis? + //precedence of the right hand side + var rhsPrecedence = operators.getPrecedence(args[1]); + //is the root node associative with the right hand side? + var assocWithRhs = operators.isAssociativeWith(root, args[1]); + + if (rhsPrecedence === null) { + //if the right hand side has no defined precedence, no parens are needed + //FunctionNode for example + rhsParens = false; + } + else if ((rhsPrecedence === precedence) && (associativity === 'left') && !assocWithRhs) { + //In case of equal precedence, if the root node is right associative + // parens are **never** necessary for the right hand side. + //If it is left associative however, parens are necessary + //if the root node isn't associative with the right hand side + rhsParens = true; + } + else if (rhsPrecedence < precedence) { + rhsParens = true; + } + else { + rhsParens = false; + } + + //handle special cases for LaTeX, where some of the parentheses aren't needed + if (latex) { + var rootIdentifier = root.getIdentifier(); + var lhsIdentifier = root.args[0].getIdentifier(); + var rhsIdentifier = root.args[1].getIdentifier(); + + if (lhsPrecedence !== null) { + if (operators.properties[precedence][rootIdentifier].latexLeftParens === false) { + lhsParens = false; + } + + if (operators.properties[lhsPrecedence][lhsIdentifier].latexParens === false) { + lhsParens = false; + } + } + + if (rhsPrecedence !== null) { + if (operators.properties[precedence][rootIdentifier].latexRightParens === false) { + rhsParens = false; + } + + if (operators.properties[rhsPrecedence][rhsIdentifier].latexParens === false) { + rhsParens = false; + } + } + } + + return [lhsParens, rhsParens]; + default: + //behavior is undefined, fall back to putting everything in parens + var parens = []; + args.forEach(function () { + parens.push(true); + }); + return parens; + } + } + + /** + * Get string representation. + * @return {String} str + */ + OperatorNode.prototype._toString = function () { + var args = this.args; + var parens = calculateNecessaryParentheses(this, args, false); + + switch (args.length) { + case 1: //unary operators + var assoc = operators.getAssociativity(this); + + var operand = args[0]._toString(); + if (parens[0]) { + operand = '(' + operand + ')'; + } + + if (assoc === 'right') { //prefix operator + return this.op + operand; + } + else if (assoc === 'left') { //postfix + return operand + this.op; + } + + //fall back to postfix + return operand + this.op; + + case 2: + var lhs = args[0]._toString(); //left hand side + var rhs = args[1]._toString(); //right hand side + if (parens[0]) { //left hand side in parenthesis? + lhs = '(' + lhs + ')'; + } + if (parens[1]) { //right hand side in parenthesis? + rhs = '(' + rhs + ')'; + } + + return lhs + ' ' + this.op + ' ' + rhs; + + default: + //fallback to formatting as a function call + return this.fn + '(' + this.args.join(', ') + ')'; + } + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + OperatorNode.prototype._toTex = function (callbacks) { + var args = this.args; + var parens = calculateNecessaryParentheses(this, args, true); + var op = latex.operators[this.fn]; + op = typeof op === 'undefined' ? this.op : op; //fall back to using this.op + + switch (args.length) { + case 1: //unary operators + var assoc = operators.getAssociativity(this); + + var operand = args[0].toTex(callbacks); + if (parens[0]) { + operand = '\\left(' + operand + '\\right)'; + } + + if (assoc === 'right') { //prefix operator + return op + operand; + } + else if (assoc === 'left') { //postfix operator + return operand + op; + } + + //fall back to postfix + return operand + op; + + case 2: //binary operators + var lhs = args[0]; //left hand side + var lhsTex = lhs.toTex(callbacks); + if (parens[0]) { + lhsTex = '\\left(' + lhsTex + '\\right)'; + } + + var rhs = args[1]; //right hand side + var rhsTex = rhs.toTex(callbacks); + if (parens[1]) { + rhsTex = '\\left(' + rhsTex + '\\right)'; + } + + //handle some exceptions (due to the way LaTeX works) + switch (this.getIdentifier()) { + case 'OperatorNode:divide': + //op contains '\\frac' at this point + return op + '{' + lhsTex + '}' + '{' + rhsTex + '}'; + case 'OperatorNode:pow': + lhsTex = '{' + lhsTex + '}'; + rhsTex = '{' + rhsTex + '}'; + switch (lhs.getIdentifier()) { + case 'ConditionalNode': // + case 'OperatorNode:divide': + lhsTex = '\\left(' + lhsTex + '\\right)'; + } + } + return lhsTex + op + rhsTex; + + default: + //fall back to formatting as a function call + //as this is a fallback, it doesn't use + //fancy function names + return '\\mathrm{' + this.fn + '}\\left(' + + args.map(function (arg) { + return arg.toTex(callbacks); + }).join(',') + '\\right)'; + } + }; + + /** + * Get identifier. + * @return {String} + */ + OperatorNode.prototype.getIdentifier = function () { + return this.type + ':' + this.fn; + }; + + return OperatorNode; + } + + exports.name = 'OperatorNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 203 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(369); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(212)); + var SymbolNode = load(__webpack_require__(205)); + + /** + * @constructor FunctionNode + * @extends {Node} + * invoke a list with arguments on a node + * @param {string} name + * @param {Node[]} args + */ + function FunctionNode(name, args) { + if (!(this instanceof FunctionNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (typeof name !== 'string') throw new TypeError('string expected for parameter "name"'); + if (!Array.isArray(args) + || !args.every(function (arg) {return arg && arg.isNode;})) { + throw new TypeError('Array containing Nodes expected for parameter "args"'); + } + + this.name = name; + this.args = args || []; + } + + FunctionNode.prototype = new Node(); + + FunctionNode.prototype.type = 'FunctionNode'; + + FunctionNode.prototype.isFunctionNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + FunctionNode.prototype._compile = function (defs) { + var fn = defs.math[this.name]; + var isRaw = (typeof fn === 'function') && (fn.rawArgs == true); + + // compile the parameters + var args = this.args.map(function (arg) { + return arg._compile(defs); + }); + + if (isRaw) { + // pass unevaluated parameters (nodes) to the function + var paramsName; + do { + paramsName = 'p' + Math.round(Math.random() * 10000); + } + while (paramsName in defs); + defs[paramsName] = this.args; + + return '("' + this.name + '" in scope ? ' + + 'scope["' + this.name + '"](' + args.join(', ') + ') : ' + + 'math["' + this.name + '"]' + '(' + paramsName + ', math, scope))'; + } + else { + // "regular" evaluation + var symbol = new SymbolNode(this.name); + return symbol._compile(defs) + '(' + args.join(', ') + ')'; + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + FunctionNode.prototype.forEach = function (callback) { + for (var i = 0; i < this.args.length; i++) { + callback(this.args[i], 'args[' + i + ']', this); + } + }; + + /** + * Create a new FunctionNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {FunctionNode} Returns a transformed copy of the node + */ + FunctionNode.prototype.map = function (callback) { + var args = []; + for (var i = 0; i < this.args.length; i++) { + args[i] = this._ifNode(callback(this.args[i], 'args[' + i + ']', this)); + } + return new FunctionNode(this.name, args); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {FunctionNode} + */ + FunctionNode.prototype.clone = function () { + return new FunctionNode(this.name, this.args.slice(0)); + }; + + /** + * Get string representation + * @return {String} str + */ + FunctionNode.prototype._toString = function () { + // format the parameters like "add(2, 4.2)" + return this.name + '(' + this.args.join(', ') + ')'; + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + */ + FunctionNode.prototype._toTex = function (callbacks) { + return latex.toFunction(this, callbacks, this.name); + }; + + /** + * Get identifier. + * @return {String} + */ + FunctionNode.prototype.getIdentifier = function () { + return this.type + ':' + this.name; + }; + + return FunctionNode; + } + + exports.name = 'FunctionNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 204 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var operators = __webpack_require__(371); + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + + /** + * @constructor RangeNode + * @extends {Node} + * create a range + * @param {Node} start included lower-bound + * @param {Node} end included lower-bound + * @param {Node} [step] optional step + */ + function RangeNode(start, end, step) { + if (!(this instanceof RangeNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate inputs + if (!(start && start.isNode)) throw new TypeError('Node expected'); + if (!(end && end.isNode)) throw new TypeError('Node expected'); + if (step && !(step && step.isNode)) throw new TypeError('Node expected'); + if (arguments.length > 3) throw new Error('Too many arguments'); + + this.start = start; // included lower-bound + this.end = end; // included upper-bound + this.step = step || null; // optional step + } + + RangeNode.prototype = new Node(); + + RangeNode.prototype.type = 'RangeNode'; + + RangeNode.prototype.isRangeNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + RangeNode.prototype._compile = function (defs) { + return 'math.range(' + + this.start._compile(defs) + ', ' + + this.end._compile(defs) + + (this.step ? (', ' + this.step._compile(defs)) : '') + + ')'; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + RangeNode.prototype.forEach = function (callback) { + callback(this.start, 'start', this); + callback(this.end, 'end', this); + if (this.step) { + callback(this.step, 'step', this); + } + }; + + /** + * Create a new RangeNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {RangeNode} Returns a transformed copy of the node + */ + RangeNode.prototype.map = function (callback) { + return new RangeNode( + this._ifNode(callback(this.start, 'start', this)), + this._ifNode(callback(this.end, 'end', this)), + this.step && this._ifNode(callback(this.step, 'step', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {RangeNode} + */ + RangeNode.prototype.clone = function () { + return new RangeNode(this.start, this.end, this.step && this.step); + }; + + /** + * Get string representation + * @return {String} str + */ + RangeNode.prototype._toString = function () { + var precedence = operators.getPrecedence(this); + + //format string as start:step:stop + var str; + + var start = this.start._toString(); + var startPrecedence = operators.getPrecedence(this.start); + if ((startPrecedence !== null) && (startPrecedence <= precedence)) { + start = '(' + start + ')'; + } + str = start; + + if (this.step) { + var step = this.step._toString(); + var stepPrecedence = operators.getPrecedence(this.step); + if ((stepPrecedence !== null) && (stepPrecedence <= precedence)) { + step = '(' + step + ')'; + } + str += ':' + step; + } + + var end = this.end._toString(); + var endPrecedence = operators.getPrecedence(this.end); + if ((endPrecedence !== null) && (endPrecedence <= precedence)) { + end = '(' + end + ')'; + } + str += ':' + end; + + return str; + }; + + /** + * Get LaTeX representation + * @params {Object|function} callback(s) + * @return {String} str + */ + RangeNode.prototype._toTex = function (callbacks) { + var str = this.start.toTex(callbacks); + if (this.step) { + str += ':' + this.step.toTex(callbacks); + } + str += ':' + this.end.toTex(callbacks); + + return str; + }; + + return RangeNode; + } + + exports.name = 'RangeNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 205 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var latex = __webpack_require__(369); + + function factory (type, config, load, typed, math) { + var Node = load(__webpack_require__(212)); + + var Unit = load(__webpack_require__(7)); + + /** + * @constructor SymbolNode + * @extends {Node} + * A symbol node can hold and resolve a symbol + * @param {String} name + * @extends {Node} + */ + function SymbolNode(name) { + if (!(this instanceof SymbolNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + // validate input + if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"'); + + this.name = name; + } + + SymbolNode.prototype = new Node(); + + SymbolNode.prototype.type = 'SymbolNode'; + + SymbolNode.prototype.isSymbolNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + SymbolNode.prototype._compile = function (defs) { + // add a function to the definitions + defs['undef'] = undef; + defs['Unit'] = Unit; + + if (this.name in defs.args) { + // this is a FunctionAssignment argument + // (like an x when inside the expression of a function assignment `f(x) = ...`) + return this.name; + } + else if (this.name in defs.math) { + return '("' + this.name + '" in scope ? scope["' + this.name + '"] : math["' + this.name + '"])'; + } + else { + return '(' + + '"' + this.name + '" in scope ? scope["' + this.name + '"] : ' + + (Unit.isValuelessUnit(this.name) ? + 'new Unit(null, "' + this.name + '")' : + 'undef("' + this.name + '")') + + ')'; + } + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + SymbolNode.prototype.forEach = function (callback) { + // nothing to do, we don't have childs + }; + + /** + * Create a new SymbolNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node) : Node} callback + * @returns {SymbolNode} Returns a clone of the node + */ + SymbolNode.prototype.map = function (callback) { + return this.clone(); + }; + + /** + * Throws an error 'Undefined symbol {name}' + * @param {String} name + */ + function undef (name) { + throw new Error('Undefined symbol ' + name); + } + + /** + * Create a clone of this node, a shallow copy + * @return {SymbolNode} + */ + SymbolNode.prototype.clone = function() { + return new SymbolNode(this.name); + }; + + /** + * Get string representation + * @return {String} str + * @override + */ + SymbolNode.prototype._toString = function() { + return this.name; + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} str + * @override + */ + SymbolNode.prototype._toTex = function(callbacks) { + var isUnit = false; + if ((typeof math[this.name] === 'undefined') && Unit.isValuelessUnit(this.name)) { + isUnit = true; + } + var symbol = latex.toSymbol(this.name, isUnit); + if (symbol[0] === '\\') { + //no space needed if the symbol starts with '\' + return symbol; + } + //the space prevents symbols from breaking stuff like '\cdot' if it's written right before the symbol + return ' ' + symbol; + }; + + return SymbolNode; + } + + exports.name = 'SymbolNode'; + exports.path = 'expression.node'; + exports.math = true; // request access to the math namespace as 5th argument of the factory function + exports.factory = factory; + + +/***/ }, +/* 206 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + var Node = load(__webpack_require__(212)); + var IndexNode = load(__webpack_require__(201)); + + /** + * @constructor UpdateNode + * @extends {Node} + * Update a matrix subset, like A[2,3] = 4.5 + * + * @param {IndexNode} index IndexNode containing symbol and ranges + * @param {Node} expr The expression defining the symbol + */ + function UpdateNode(index, expr) { + if (!(this instanceof UpdateNode)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + + if (!(index && index.isIndexNode)) { + throw new TypeError('Expected IndexNode for parameter "index"'); + } + if (!(expr && expr.isNode)) { + throw new TypeError('Expected Node for parameter "expr"'); + } + + this.index = index; + this.expr = expr; + } + + UpdateNode.prototype = new Node(); + + UpdateNode.prototype.type = 'UpdateNode'; + + UpdateNode.prototype.isUpdateNode = true; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * or constants globally available for the compiled + * expression + * @return {String} js + * @private + */ + UpdateNode.prototype._compile = function (defs) { + var lhs = (this.index.objectName() in defs.args) + ? this.name + ' = ' // this is a FunctionAssignment argument + : 'scope["' + this.index.objectName() + '\"]'; + + var rhs = this.index.compileSubset(defs, this.expr._compile(defs)); + + return lhs + ' = ' + rhs; + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + UpdateNode.prototype.forEach = function (callback) { + callback(this.index, 'index', this); + callback(this.expr, 'expr', this); + }; + + /** + * Create a new UpdateNode having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {UpdateNode} Returns a transformed copy of the node + */ + UpdateNode.prototype.map = function (callback) { + return new UpdateNode( + this._ifNode(callback(this.index, 'index', this)), + this._ifNode(callback(this.expr, 'expr', this)) + ); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {UpdateNode} + */ + UpdateNode.prototype.clone = function () { + return new UpdateNode(this.index, this.expr); + }; + + /** + * Get string representation + * @return {String} + */ + UpdateNode.prototype._toString = function () { + return this.index._toString() + ' = ' + this.expr._toString(); + }; + + /** + * Get LaTeX representation + * @param {Object|function} callback(s) + * @return {String} + */ + UpdateNode.prototype._toTex = function (callbacks) { + return this.index.toTex(callbacks) + ':=' + this.expr.toTex(callbacks); + }; + + return UpdateNode; + } + + exports.name = 'UpdateNode'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 207 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory(type, config, load, typed) { + /** + * Divide two scalar values, `x / y`. + * This function is meant for internal use: it is used by the public functions + * `divide` and `inv`. + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {Number | BigNumber | Boolean | Complex | Unit | null} x Numerator + * @param {Number | BigNumber | Boolean | Complex | null} y Denominator + * @return {Number | BigNumber | Complex | Unit} Quotient, `x / y` + * @private + */ + var divideScalar = typed('divideScalar', { + 'number, number': function (x, y) { + return x / y; + }, + + 'Complex, Complex': _divideComplex, + + 'BigNumber, BigNumber': function (x, y) { + return x.div(y); + }, + + 'Unit, number': function (x, y) { + var res = x.clone(); + res.value = ((res.value === null) ? res._normalize(1) : res.value) / y; + return res; + } + }); + + /** + * Divide two complex numbers. x / y or divide(x, y) + * @param {Complex} x + * @param {Complex} y + * @return {Complex} res + * @private + */ + function _divideComplex (x, y) { + var den = y.re * y.re + y.im * y.im; + if (den != 0) { + return new type.Complex( + (x.re * y.re + x.im * y.im) / den, + (x.im * y.re - x.re * y.im) / den + ); + } + else { + // both y.re and y.im are zero + return new type.Complex( + (x.re != 0) ? (x.re / 0) : 0, + (x.im != 0) ? (x.im / 0) : 0 + ); + } + } + + return divideScalar; + } + + exports.name = 'divideScalar'; + exports.factory = factory; + + +/***/ }, +/* 208 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var divideScalar = load(__webpack_require__(207)); + var multiply = load(__webpack_require__(71)); + var subtract = load(__webpack_require__(79)); + var equal = load(__webpack_require__(46)); + + var substitutionValidation = load(__webpack_require__(372)); + + var SparseMatrix = type.SparseMatrix; + var DenseMatrix = type.DenseMatrix; + + /** + * Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix. + * + * M * x = b + * + * @param {Matrix, Array} A N x N matrix or array + * @param {Matrix, Array} A column vector with the b values + * + * @return {Matrix} A column vector with the linear system solution + */ + var backwardSubstitution = typed('backwardSubstitution', { + 'Matrix, Array | Matrix': function (m, b) { + // process matrix storage format + switch (m.storage()) { + case 'dense': + return _denseBackwardSubstitution(m, b); + case 'sparse': + return _sparseBackwardSubstitution(m, b); + } + }, + 'Array, Array | Matrix': function (a, b) { + // create dense matrix from array + var m = matrix(a); + // use matrix implementation + var r = backwardSubstitution(m, b); + // result + return r.valueOf(); + } + }); + + var _denseBackwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = substitutionValidation(m, b); + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // result + var x = new Array(rows); + // arrays + var data = m._data; + // backward solve m * x = b, loop columns (backwards) + for (var j = columns - 1; j >= 0 ; j--) { + // b[j] + var bj = b[j] || 0; + // x[j] + var xj; + // backward substitution (outer product) avoids inner looping when bj == 0 + if (!equal(bj, 0)) { + // value @ [j, j] + var vjj = data[j][j]; + // check vjj + if (equal(vjj, 0)) { + // system cannot be solved + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + xj = divideScalar(bj, vjj); + // loop rows + for (var i = j - 1; i >= 0; i--) { + // update copy of b + b[i] = subtract(b[i] || 0, multiply(xj, data[i][j])); + } + } + else { + // zero value @ j + xj = 0; + } + // update x + x[j] = [xj]; + } + // return column vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + var _sparseBackwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = substitutionValidation(m, b); + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // result arrays + var xvalues = []; + var xindex = []; + var xptr = []; + // vars + var i, k; + // init ptr + xptr.push(0); + // backward solve m * x = b, loop columns (backwards) + for (var j = columns - 1; j >= 0 ; j--) { + // b[j] + var bj = b[j] || 0; + // backward substitution (outer product) avoids inner looping when bj == 0 + if (!equal(bj, 0)) { + // value @ [j, j] + var vjj = 0; + // first & last indeces in column + var f = ptr[j]; + var l = ptr[j + 1]; + // values in column, find value @ [j, j], loop backwards + for (k = l - 1; k >= f; k--) { + // row + i = index[k]; + // check row + if (i === j) { + // update vjj + vjj = values[k]; + } + else if (i < j) { + // exit loop + break; + } + } + // at this point we must have a value @ [j, j] + if (equal(vjj, 0)) { + // system cannot be solved, there is no value @ [j, j] + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + var xj = divideScalar(bj, vjj); + // values in column, continue from last loop + for (; k >= f; k--) { + // row + i = index[k]; + // update copy of b + b[i] = subtract(b[i] || 0, multiply(xj, values[k])); + } + // check for non zero + if (!equal(xj, 0)) { + // push to values (at the beginning since we are looping backwards) + xvalues.unshift(xj); + // row + xindex.unshift(j); + } + } + } + // update ptr + xptr.push(xvalues.length); + // return column vector + return new SparseMatrix({ + values: xvalues, + index: xindex, + ptr: xptr, + size: [rows, 1] + }); + }; + + return backwardSubstitution; + } + + exports.name = 'backwardSubstitution'; + exports.factory = factory; + + +/***/ }, +/* 209 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory (type, config, load, typed) { + + var matrix = load(__webpack_require__(40)); + var divideScalar = load(__webpack_require__(207)); + var multiply = load(__webpack_require__(71)); + var subtract = load(__webpack_require__(79)); + var equal = load(__webpack_require__(46)); + + var substitutionValidation = load(__webpack_require__(372)); + + var SparseMatrix = type.SparseMatrix; + var DenseMatrix = type.DenseMatrix; + + /** + * Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix. + * + * M * x = b + * + * @param {Matrix, Array} A N x N matrix or array + * @param {Matrix, Array} A column vector with the b values + * + * @return {Matrix} A column vector with the linear system solution + */ + var forwardSubstitution = typed('forwardSubstitution', { + 'Matrix, Array | Matrix': function (m, b) { + // process matrix storage format + switch (m.storage()) { + case 'dense': + return _denseForwardSubstitution(m, b); + case 'sparse': + return _sparseForwardSubstitution(m, b); + } + }, + 'Array, Array | Matrix': function (a, b) { + // create dense matrix from array + var m = matrix(a); + // use matrix implementation + var r = forwardSubstitution(m, b); + // result + return r.valueOf(); + } + }); + + var _denseForwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = substitutionValidation(m, b); + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // result + var x = new Array(rows); + // data + var data = m._data; + // forward solve m * x = b, loop columns + for (var j = 0; j < columns; j++) { + // b[j] + var bj = b[j] || 0; + // x[j] + var xj; + // forward substitution (outer product) avoids inner looping when bj == 0 + if (!equal(bj, 0)) { + // value @ [j, j] + var vjj = data[j][j]; + // check vjj + if (equal(vjj, 0)) { + // system cannot be solved + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + xj = divideScalar(bj, vjj); + // loop rows + for (var i = j + 1; i < rows; i++) { + // update copy of b + b[i] = subtract(b[i] || 0, multiply(xj, data[i][j])); + } + } + else { + // zero @ j + xj = 0; + } + // update x + x[j] = [xj]; + } + // return vector + return new DenseMatrix({ + data: x, + size: [rows, 1] + }); + }; + + var _sparseForwardSubstitution = function (m, b) { + // validate matrix and vector, return copy of column vector b + b = substitutionValidation(m, b); + // rows & columns + var rows = m._size[0]; + var columns = m._size[1]; + // matrix arrays + var values = m._values; + var index = m._index; + var ptr = m._ptr; + // result arrays + var xvalues = []; + var xindex = []; + var xptr = []; + // vars + var i, k; + // init ptr + xptr.push(0); + // forward solve m * x = b, loop columns + for (var j = 0; j < columns; j++) { + // b[j] + var bj = b[j] || 0; + // forward substitution (outer product) avoids inner looping when bj == 0 + if (!equal(bj, 0)) { + // value @ [j, j] + var vjj = 0; + // last index in column + var l = ptr[j + 1]; + // values in column, find value @ [j, j] + for (k = ptr[j]; k < l; k++) { + // row + i = index[k]; + // check row + if (i === j) { + // update vjj + vjj = values[k]; + } + else if (i > j) { + // exit loop + break; + } + } + // at this point we must have a value @ [j, j] + if (equal(vjj, 0)) { + // system cannot be solved, there is no value @ [j, j] + throw new Error('Linear system cannot be solved since matrix is singular'); + } + // calculate xj + var xj = divideScalar(bj, vjj); + // values in column, continue from last loop + for (; k < l; k++) { + // row + i = index[k]; + // update copy of b + b[i] = subtract(b[i] || 0, multiply(xj, values[k])); + } + // check for non zero + if (!equal(xj, 0)) { + // value @ row i + xvalues.push(xj); + // row + xindex.push(j); + } + } + } + // update ptr + xptr.push(xvalues.length); + // return column vector + return new SparseMatrix({ + values: xvalues, + index: xindex, + ptr: xptr, + size: [rows, 1] + }); + }; + + return forwardSubstitution; + } + + exports.name = 'forwardSubstitution'; + exports.factory = factory; + + +/***/ }, +/* 210 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + function factory(type, config, load, typed) { + + /** + * Multiply two scalar values, `x * y`. + * This function is meant for internal use: it is used by the public function + * `multiply` + * + * This function does not support collections (Array or Matrix), and does + * not validate the number of of inputs. + * + * @param {Number | BigNumber | Boolean | Complex | Unit | null} x First value to multiply + * @param {Number | BigNumber | Boolean | Complex | null} y Second value to multiply + * @return {Number | BigNumber | Complex | Unit} Multiplication of `x` and `y` + * @private + */ + var multiplyScalar = typed('multiplyScalar', { + + 'number, number': function (x, y) { + return x * y; + }, + + 'Complex, Complex': function (x, y) { + return new type.Complex( + x.re * y.re - x.im * y.im, + x.re * y.im + x.im * y.re + ); + }, + + 'BigNumber, BigNumber': function (x, y) { + return x.times(y); + }, + + 'number, Unit': function (x, y) { + var res = y.clone(); + res.value = (res.value === null) ? res._normalize(x) : (res.value * x); + return res; + }, + + 'Unit, number': function (x, y) { + var res = x.clone(); + res.value = (res.value === null) ? res._normalize(y) : (res.value * y); + return res; + }, + }); + + return multiplyScalar; + } + + exports.name = 'multiplyScalar'; + exports.factory = factory; + + +/***/ }, +/* 211 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var ArgumentsError = __webpack_require__(194); + + // TODO: rethink math.distribution + // TODO: rework to a typed function + function factory (type, config, load, typed) { + var collection = load(__webpack_require__(2)); + var matrix = load(__webpack_require__(40)); + var array = __webpack_require__(37); + + var isCollection = collection.isCollection; + + /** + * Create a distribution object with a set of random functions for given + * random distribution. + * + * Syntax: + * + * math.distribution(name) + * + * Examples: + * + * var normalDist = math.distribution('normal'); // create a normal distribution + * normalDist.random(0, 10); // get a random value between 0 and 10 + * + * See also: + * + * random, randomInt, pickRandom + * + * @param {String} name Name of a distribution. Choose from 'uniform', 'normal'. + * @return {Object} Returns a distribution object containing functions: + * `random([size] [, min] [, max])`, + * `randomInt([min] [, max])`, + * `pickRandom(array)` + */ + function distribution(name) { + if (!distributions.hasOwnProperty(name)) + throw new Error('Unknown distribution ' + name); + + var args = Array.prototype.slice.call(arguments, 1), + distribution = distributions[name].apply(this, args); + + return (function(distribution) { + + // This is the public API for all distributions + var randFunctions = { + + random: function(arg1, arg2, arg3) { + var size, min, max; + if (arguments.length > 3) { + throw new ArgumentsError('random', arguments.length, 0, 3); + + // `random(max)` or `random(size)` + } else if (arguments.length === 1) { + if (isCollection(arg1)) { + size = arg1; + } + else { + max = arg1; + } + // `random(min, max)` or `random(size, max)` + } else if (arguments.length === 2) { + if (isCollection(arg1)) { + size = arg1; + max = arg2; + } + else { + min = arg1; + max = arg2; + } + // `random(size, min, max)` + } else { + size = arg1; + min = arg2; + max = arg3; + } + + // TODO: validate type of min, max, and size + + if (max === undefined) max = 1; + if (min === undefined) min = 0; + if (size !== undefined) { + var res = _randomDataForMatrix(size.valueOf(), min, max, _random); + return (size instanceof type.Matrix) ? matrix(res) : res; + } + else return _random(min, max); + }, + + randomInt: function(arg1, arg2, arg3) { + var size, min, max; + if (arguments.length > 3 || arguments.length < 1) + throw new ArgumentsError('randomInt', arguments.length, 1, 3); + + // `random(max)` or `random(size)` + else if (arguments.length === 1) + if (isCollection(arg1)) { + size = arg1; + } + else { + max = arg1; + } + // `randomInt(min, max)` or `randomInt(size, max)` + else if (arguments.length === 2) { + if (isCollection(arg1)) { + size = arg1; + max = arg2; + } + else { + min = arg1; + max = arg2; + } + // `randomInt(size, min, max)` + } else { + size = arg1; + min = arg2; + max = arg3; + } + + // TODO: validate type of min, max, and size + + if (min === undefined) min = 0; + if (size !== undefined) { + var res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt); + return (size instanceof type.Matrix) ? matrix(res) : res; + } + else return _randomInt(min, max); + }, + + pickRandom: function(possibles) { + if (arguments.length !== 1) { + throw new ArgumentsError('pickRandom', arguments.length, 1); + } + if (possibles instanceof type.Matrix) { + possibles = possibles.valueOf(); // get Array + } + else if (!Array.isArray(possibles)) { + throw new TypeError('Unsupported type of value in function pickRandom'); + } + + if (array.size(possibles).length > 1) { + throw new Error('Only one dimensional vectors supported'); + } + + // TODO: add support for multi dimensional matrices + return possibles[Math.floor(Math.random() * possibles.length)]; + } + + }; + + var _random = function(min, max) { + return min + distribution() * (max - min); + }; + + var _randomInt = function(min, max) { + return Math.floor(min + distribution() * (max - min)); + }; + + // This is a function for generating a random matrix recursively. + var _randomDataForMatrix = function(size, min, max, randFunc) { + var data = [], length, i; + size = size.slice(0); + + if (size.length > 1) { + for (i = 0, length = size.shift(); i < length; i++) + data.push(_randomDataForMatrix(size, min, max, randFunc)); + } else { + for (i = 0, length = size.shift(); i < length; i++) + data.push(randFunc(min, max)); + } + + return data; + }; + + return randFunctions; + + })(distribution); + } + + // Each distribution is a function that takes no argument and when called returns + // a number between 0 and 1. + var distributions = { + + uniform: function() { + return Math.random; + }, + + // Implementation of normal distribution using Box-Muller transform + // ref : http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform + // We take : mean = 0.5, standard deviation = 1/6 + // so that 99.7% values are in [0, 1]. + normal: function() { + return function() { + var u1, u2, + picked = -1; + // We reject values outside of the interval [0, 1] + // TODO: check if it is ok to do that? + while (picked < 0 || picked > 1) { + u1 = Math.random(); + u2 = Math.random(); + picked = 1/6 * Math.pow(-2 * Math.log(u1), 0.5) * Math.cos(2 * Math.PI * u2) + 0.5; + } + return picked; + } + } + }; + + return distribution; + } + + exports.name = 'distribution'; + exports.factory = factory; + + +/***/ }, +/* 212 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var keywords = __webpack_require__(370); + + function factory (type, config, load, typed) { + /** + * Node + */ + function Node() { + if (!(this instanceof Node)) { + throw new SyntaxError('Constructor must be called with the new operator'); + } + } + + /** + * Evaluate the node + * @return {*} result + */ + // TODO: cleanup deprecated code one day. Deprecated since version 0.19.0 + Node.prototype.eval = function () { + throw new Error('Node.eval is deprecated. ' + + 'Use Node.compile(math).eval([scope]) instead.'); + }; + + Node.prototype.type = 'Node'; + + Node.prototype.isNode = true; + + /** + * Compile the node to javascript code + * @param {Object} math math.js instance + * @return {{eval: function}} expr Returns an object with a function 'eval', + * which can be invoked as expr.eval([scope]), + * where scope is an optional object with + * variables. + */ + Node.prototype.compile = function (math) { + if (!(math instanceof Object)) { + throw new TypeError('Object expected for parameter math'); + } + + // definitions globally available inside the closure of the compiled expressions + var defs = { + math: _transform(math), + args: {}, // can be filled with names of FunctionAssignment arguments + _validateScope: _validateScope + }; + + var code = this._compile(defs); + + var defsCode = Object.keys(defs).map(function (name) { + return ' var ' + name + ' = defs["' + name + '"];'; + }); + + var factoryCode = + defsCode.join(' ') + + 'return {' + + ' "eval": function (scope) {' + + ' if (scope) _validateScope(scope);' + + ' scope = scope || {};' + + ' return ' + code + ';' + + ' }' + + '};'; + + var factory = new Function('defs', factoryCode); + return factory(defs); + }; + + /** + * Compile the node to javascript code + * @param {Object} defs Object which can be used to define functions + * and constants globally available inside the closure + * of the compiled expression + * @return {String} js + * @private + */ + Node.prototype._compile = function (defs) { + // must be implemented by each of the Node implementations + throw new Error('Cannot compile a Node interface'); + }; + + /** + * Execute a callback for each of the child nodes of this node + * @param {function(child: Node, path: string, parent: Node)} callback + */ + Node.prototype.forEach = function (callback) { + // must be implemented by each of the Node implementations + throw new Error('Cannot run forEach on a Node interface'); + }; + + /** + * Create a new Node having it's childs be the results of calling + * the provided callback function for each of the childs of the original node. + * @param {function(child: Node, path: string, parent: Node): Node} callback + * @returns {OperatorNode} Returns a transformed copy of the node + */ + Node.prototype.map = function (callback) { + // must be implemented by each of the Node implementations + throw new Error('Cannot run map on a Node interface'); + }; + + /** + * Validate whether an object is a Node, for use with map + * @param {Node} node + * @returns {Node} Returns the input if it's a node, else throws an Error + * @protected + */ + Node.prototype._ifNode = function (node) { + if (!(node && node.isNode)) { + throw new TypeError('Callback function must return a Node'); + } + + return node; + }; + + /** + * Recursively traverse all nodes in a node tree. Executes given callback for + * this node and each of its child nodes. + * @param {function(node: Node, path: string, parent: Node)} callback + * A callback called for every node in the node tree. + */ + Node.prototype.traverse = function (callback) { + // execute callback for itself + callback(this, null, null); + + // recursively traverse over all childs of a node + function _traverse(node, callback) { + node.forEach(function (child, path, parent) { + callback(child, path, parent); + _traverse(child, callback); + }); + } + + _traverse(this, callback); + }; + + /** + * Recursively transform a node tree via a transform function. + * + * For example, to replace all nodes of type SymbolNode having name 'x' with a + * ConstantNode with value 2: + * + * var res = Node.transform(function (node, path, parent) { + * if (node && node.isSymbolNode) && (node.name == 'x')) { + * return new ConstantNode(2); + * } + * else { + * return node; + * } + * }); + * + * @param {function(node: Node, path: string, parent: Node) : Node} callback + * A mapping function accepting a node, and returning + * a replacement for the node or the original node. + * Signature: callback(node: Node, index: string, parent: Node) : Node + * @return {Node} Returns the original node or its replacement + */ + Node.prototype.transform = function (callback) { + // check itself + var replacement = callback(this, null, null); + if (replacement !== this) { + return replacement; + } + + // traverse over all childs + function _transform(node, callback) { + return node.map(function (child, path, parent) { + var replacement = callback(child, path, parent); + return (replacement !== child) ? replacement : _transform(child, callback); + }); + } + + return _transform(this, callback); + }; + + /** + * Find any node in the node tree matching given filter function. For example, to + * find all nodes of type SymbolNode having name 'x': + * + * var results = Node.filter(function (node) { + * return (node && node.isSymbolNode) && (node.name == 'x'); + * }); + * + * @param {function(node: Node, path: string, parent: Node) : Node} callback + * A test function returning true when a node matches, and false + * otherwise. Function signature: + * callback(node: Node, index: string, parent: Node) : boolean + * @return {Node[]} nodes An array with nodes matching given filter criteria + */ + Node.prototype.filter = function (callback) { + var nodes = []; + + this.traverse(function (node, path, parent) { + if (callback(node, path, parent)) { + nodes.push(node); + } + }); + + return nodes; + }; + + // TODO: deprecated since version 1.1.0, remove this some day + Node.prototype.find = function () { + throw new Error('Function Node.find is deprecated. Use Node.filter instead.'); + }; + + // TODO: deprecated since version 1.1.0, remove this some day + Node.prototype.match = function () { + throw new Error('Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.'); + }; + + /** + * Create a clone of this node, a shallow copy + * @return {Node} + */ + Node.prototype.clone = function () { + // must be implemented by each of the Node implementations + throw new Error('Cannot clone a Node interface'); + }; + + /** + * Get string representation + * @return {String} + */ + Node.prototype.toString = function () { + return this._toString(); + }; + + /** + * Internal function to generate the string output. + * This has to be implemented by every Node + * + * @param {Object}|function} + * @throws {Error} + */ + Node.prototype._toString = function () { + if (this.type === 'Node') { + //FIXME remove this in v2??? + return ''; + } + //must be implemented by each of the Node implementations + throw new Error('_toString not implemented for ' + this.type); + }; + + /** + * Get LaTeX representation. (wrapper function) + * This functions get's either an object containing callbacks or + * a single callback. It decides whether to call the callback and if + * not or if the callback returns nothing, it calls the default + * LaTeX implementation of the node (_toTex). + * + * @param {Object|function} callback(s) + * @return {String} + */ + Node.prototype.toTex = function (callback) { + var customTex; + if (typeof callback === 'object') { + if ((this.type === 'FunctionNode') && callback.hasOwnProperty(this.name)) { + //if callback is a map of callback functions and this is a FunctionNode + customTex = callback[this.name](this, callback); + } + } + else if (typeof callback === 'function') { + //if callback is a function + customTex = callback(this, callback); + } + else if (typeof callback !== 'undefined') { + throw new TypeError('Object or function expected as callback'); + } + + if (typeof customTex !== 'undefined') { + return customTex; + } + + return this._toTex(callback); + }; + + /** + * Internal function to generate the LaTeX output. + * This has to be implemented by every Node + * + * @param {Object}|function} + * @throws {Error} + */ + Node.prototype._toTex = function () { + if (this.type === 'Node') { + //FIXME remove this in v2??? + return ''; + } + //must be implemented by each of the Node implementations + throw new Error('_toTex not implemented for ' + this.type); + }; + + /** + * Get identifier. + * @return {String} + */ + Node.prototype.getIdentifier = function () { + return this.type; + }; + + /** + * Validate the symbol names of a scope. + * Throws an error when the scope contains an illegal symbol. + * @param {Object} scope + */ + function _validateScope(scope) { + for (var symbol in scope) { + if (scope.hasOwnProperty(symbol)) { + if (symbol in keywords) { + throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword'); } - i--; - c[i]++; } } } - return rounded; - }; + /** + * Replace all functions having a transform function attached at property transform + * with their transform. + * @param {Object} math + * @return {Object} transformed + * @private + */ + function _transform(math) { + var transformed = Object.create(math); - /** - * Create an array filled with zeros. - * @param {number} length - * @return {Array} - */ - function zeros(length) { - var arr = []; - for (var i = 0; i < length; i++) { - arr.push(0); + // TODO: bind function or function transform at compile time in FunctionNode instead, use defs there + for (var name in math) { + if (math.hasOwnProperty(name)) { + var value = math[name]; + if (value && typeof value.transform === 'function') { + transformed[name] = value.transform; + } + } + } + + return transformed; } - return arr; + + return Node; } - module.exports = NumberFormatter; + exports.name = 'Node'; + exports.path = 'expression.node'; + exports.factory = factory; + + +/***/ }, +/* 213 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(373).transform; + + /** + * Attach a transform function to math.range + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function concat + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var concat = load(__webpack_require__(102)); + + // @see: comment of concat itself + concat.transform = typed('concat', { + '...any': function (args) { + // change last argument from one-based to zero-based + var lastIndex = args.length - 1; + var last = args[lastIndex]; + if (typeof last === 'number') { + args[lastIndex] = last - 1; + } + else if (last instanceof type.BigNumber) { + args[lastIndex] = last.minus(1); + } + + try { + return concat.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + + return concat.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 214 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.filter + * Adds a property transform containing the transform function. + * + * This transform adds support for equations as test function for math.filter, + * so you can do something like 'filter([3, -2, 5], x > 0)'. + */ + function factory (type, config, load, typed) { + var filter = load(__webpack_require__(176)); + var SymbolNode = load(__webpack_require__(205)); + + filter.transform = function (args, math, scope) { + var x, test; + + if (args[0]) { + x = args[0].compile(math).eval(scope); + } + + if (args[1]) { + if (args[1] && args[1].isSymbolNode) { + // a function pointer, like filter([3, -2, 5], myTestFunction); + test = args[1].compile(math).eval(scope); + } + else { + // an equation like filter([3, -2, 5], x > 0) + + // find an undefined symbol + var _scope = scope || {}; + var symbol = args[1] + .filter(function (node) { + return (node && node.isSymbolNode) && + !(node.name in math) && + !(node.name in _scope); + })[0]; + + // create a test function for this equation + var sub = Object.create(_scope); + var eq = args[1].compile(math); + if (symbol) { + var name = symbol.name; + test = function (x) { + sub[name] = x; + return eq.eval(sub); + } + } + else { + throw new Error('No undefined variable found in filter equation'); + } + } + } + + return filter(x, test); + }; + + filter.transform.rawArgs = true; + + return filter.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 215 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.forEach + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load, typed) { + var forEach = load(__webpack_require__(182)); + + forEach.transform = typed('forEach', { + 'Array | Matrix, function': function (array, callback) { + var recurse = function (value, index) { + if (Array.isArray(value)) { + value.forEach(function (child, i) { + // we create a copy of the index array and append the new index value + recurse(child, index.concat(i + 1)); // one based index, hence i+1 + }); + } + else { + callback(value, index, array); + } + }; + recurse(array.valueOf(), []); // pass Array + } + }); + + return forEach.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 216 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.index + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load, typed) { + var indexFactory = load(__webpack_require__(123)); + + indexFactory.transform = function () { + var args = []; + for (var i = 0, ii = arguments.length; i < ii; i++) { + var arg = arguments[i]; + + // change from one-based to zero based, and convert BigNumber to number + if (arg instanceof type.Range) { + arg.start--; + arg.end -= (arg.step > 0 ? 0 : 2); + } + else if (typeof arg === 'number') { + arg--; + } + else if (arg instanceof type.BigNumber) { + arg = arg.toNumber() - 1; + } + else { + throw new TypeError('Ranges must be a Number or Range'); + } + + args[i] = arg; + } + + var res = new type.Index(); + type.Index.apply(res, args); + return res; + }; + + return indexFactory.transform; + } + + exports.factory = factory; + + + +/***/ }, +/* 217 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.map + * Adds a property transform containing the transform function. + * + * This transform creates a one-based index instead of a zero-based index + */ + function factory (type, config, load, typed) { + var map = load(__webpack_require__(178)); + var matrix = load(__webpack_require__(40)); + + map.transform = typed('max', { + 'Array, function': function (x, callback) { + return _map(x, callback, x); + }, + + 'Matrix, function': function (x, callback) { + return matrix(_map(x.valueOf(), callback, x)); + } + }); + + return map.transform; + } + + /** + * Map for a multi dimensional array. One-based indexes + * @param {Array} array + * @param {function} callback + * @param {Array} orig + * @return {Array} + * @private + */ + function _map (array, callback, orig) { + function recurse(value, index) { + if (Array.isArray(value)) { + return value.map(function (child, i) { + // we create a copy of the index array and append the new index value + return recurse(child, index.concat(i + 1)); // one based index, hence i + 1 + }); + } + else { + return callback(value, index, orig); + } + } + + return recurse(array, []); + } + + exports.factory = factory; + + +/***/ }, +/* 218 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(373).transform; + + /** + * Attach a transform function to math.max + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function max + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var max = load(__webpack_require__(135)); + var isCollection = load(__webpack_require__(2)).isCollection; + + max.transform = typed('max', { + '...any': function (args) { + // change last argument dim from one-based to zero-based + if (args.length == 2 && isCollection(args[0])) { + var dim = args[1]; + if (typeof dim === 'number') { + args[1] = dim - 1; + } + else if (dim instanceof type.BigNumber) { + args[1] = dim.minus(1); + } + } + + try { + return max.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + + return max.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 219 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(373).transform; + + /** + * Attach a transform function to math.mean + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function mean + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var mean = load(__webpack_require__(136)); + var isCollection = load(__webpack_require__(2)).isCollection; + + mean.transform = typed('mean', { + '...any': function (args) { + // change last argument dim from one-based to zero-based + if (args.length == 2 && isCollection(args[0])) { + var dim = args[1]; + if (typeof dim === 'number') { + args[1] = dim - 1; + } + else if (dim instanceof type.BigNumber) { + args[1] = dim.minus(1); + } + } + + try { + return mean.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + + return mean.transform; + } + + exports.factory = factory; + + + +/***/ }, +/* 220 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(373).transform; + + /** + * Attach a transform function to math.min + * Adds a property transform containing the transform function. + * + * This transform changed the last `dim` parameter of function min + * from one-based to zero based + */ + function factory (type, config, load, typed) { + var min = load(__webpack_require__(138)); + var isCollection = load(__webpack_require__(2)).isCollection; + + min.transform = typed('min', { + '...any': function (args) { + // change last argument dim from one-based to zero-based + if (args.length == 2 && isCollection(args[0])) { + var dim = args[1]; + if (typeof dim === 'number') { + args[1] = dim - 1; + } + else if (dim instanceof type.BigNumber) { + args[1] = dim.minus(1); + } + } + + try { + return min.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + + return min.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 221 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + /** + * Attach a transform function to math.range + * Adds a property transform containing the transform function. + * + * This transform creates a range which includes the end value + */ + function factory (type, config, load, typed) { + var range = load(__webpack_require__(111)); + + range.transform = typed('range', { + '...any': function (args) { + var lastIndex = args.length - 1; + var last = args[lastIndex]; + if (typeof last !== 'boolean') { + // append a parameter includeEnd=true + args.push(true); + } + + return range.apply(null, args); + } + }); + + return range.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 222 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var errorTransform = __webpack_require__(373).transform; + + /** + * Attach a transform function to math.subset + * Adds a property transform containing the transform function. + * + * This transform creates a range which includes the end value + */ + function factory (type, config, load, typed) { + var subset = load(__webpack_require__(115)); + + subset.transform = typed('subset', { + '...any': function (args) { + try { + return subset.apply(null, args); + } + catch (err) { + throw errorTransform(err); + } + } + }); + + return subset.transform; + } + + exports.factory = factory; + + +/***/ }, +/* 223 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 224 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'false', + 'category': 'Constants', + 'syntax': [ + 'false' + ], + 'description': 'Boolean value false', + 'examples': [ + 'false' + ], + 'seealso': ['true'] + }; + + +/***/ }, +/* 225 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 226 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 227 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'LN2', + 'category': 'Constants', + 'syntax': [ + 'LN2' + ], + 'description': 'Returns the natural logarithm of 2, approximately equal to 0.693', + 'examples': [ + 'LN2', + 'log(2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 228 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'LN10', + 'category': 'Constants', + 'syntax': [ + 'LN10' + ], + 'description': 'Returns the natural logarithm of 10, approximately equal to 2.302', + 'examples': [ + 'LN10', + 'log(10)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 229 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 230 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 231 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'NaN', + 'category': 'Constants', + 'syntax': [ + 'NaN' + ], + 'description': 'Not a number', + 'examples': [ + 'NaN', + '0 / 0' + ], + 'seealso': [] + }; + + +/***/ }, +/* 232 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'null', + 'category': 'Constants', + 'syntax': [ + 'null' + ], + 'description': 'Value null', + 'examples': [ + 'null' + ], + 'seealso': ['true', 'false'] + }; + + +/***/ }, +/* 233 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 234 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'phi', + 'category': 'Constants', + 'syntax': [ + 'phi' + ], + 'description': 'Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...', + 'examples': [ + 'tau' + ], + 'seealso': [] + }; + + +/***/ }, +/* 235 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 236 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'SQRT2', + 'category': 'Constants', + 'syntax': [ + 'SQRT2' + ], + 'description': 'Returns the square root of 2, approximately equal to 1.414', + 'examples': [ + 'SQRT2', + 'sqrt(2)' + ], + 'seealso': [] + }; + + +/***/ }, +/* 237 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'tau', + 'category': 'Constants', + 'syntax': [ + 'tau' + ], + 'description': 'Tau is the ratio constant of a circle\'s circumference to radius, equal to 2 * pi, approximately 6.2832.', + 'examples': [ + 'tau', + '2 * pi' + ], + 'seealso': ['pi'] + }; + + +/***/ }, +/* 238 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'true', + 'category': 'Constants', + 'syntax': [ + 'true' + ], + 'description': 'Boolean value true', + 'examples': [ + 'true' + ], + 'seealso': ['false'] + }; + + +/***/ }, +/* 239 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'version', + 'category': 'Constants', + 'syntax': [ + 'version' + ], + 'description': 'A string with the version number of math.js', + 'examples': [ + 'version' + ], + 'seealso': [] + }; + + +/***/ }, +/* 240 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'abs', + 'category': 'Arithmetic', + 'syntax': [ + 'abs(x)' + ], + 'description': 'Compute the absolute value.', + 'examples': [ + 'abs(3.5)', + 'abs(-4.2)' + ], + 'seealso': ['sign'] + }; + + +/***/ }, +/* 241 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'add', + 'category': 'Operators', + 'syntax': [ + 'x + y', + 'add(x, y)' + ], + 'description': 'Add two values.', + 'examples': [ + 'a = 2.1 + 3.6', + 'a - 3.6', + '3 + 2i', + '"hello" + " world"', + '3 cm + 2 inch' + ], + 'seealso': [ + 'subtract' + ] + }; + + +/***/ }, +/* 242 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 243 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 244 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'divide', + 'category': 'Operators', + 'syntax': [ + 'x / y', + 'divide(x, y)' + ], + 'description': 'Divide two values.', + 'examples': [ + 'a = 2 / 3', + 'a * 3', + '4.5 / 2', + '3 + 4 / 2', + '(3 + 4) / 2', + '18 km / 4.5' + ], + 'seealso': [ + 'multiply' + ] + }; + + +/***/ }, +/* 245 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'dotDivide', + 'category': 'Operators', + 'syntax': [ + 'x ./ y', + 'dotDivide(x, y)' + ], + 'description': 'Divide two values element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'b = [2, 1, 1; 3, 2, 5]', + 'a ./ b' + ], + 'seealso': [ + 'multiply', + 'dotMultiply', + 'divide' + ] + }; + + +/***/ }, +/* 246 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'dotMultiply', + 'category': 'Operators', + 'syntax': [ + 'x .* y', + 'dotMultiply(x, y)' + ], + 'description': 'Multiply two values element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'b = [2, 1, 1; 3, 2, 5]', + 'a .* b' + ], + 'seealso': [ + 'multiply', + 'divide', + 'dotDivide' + ] + }; + + +/***/ }, +/* 247 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'dotpow', + 'category': 'Operators', + 'syntax': [ + 'x .^ y', + 'dotpow(x, y)' + ], + 'description': + 'Calculates the power of x to y element wise.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'a .^ 2' + ], + 'seealso': [ + 'pow' + ] + }; + + +/***/ }, +/* 248 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [ + 'pow', + 'log' + ] + }; + + +/***/ }, +/* 249 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 250 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 251 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' ] + }; + + +/***/ }, +/* 252 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' ] + }; + + +/***/ }, +/* 253 */ +/***/ function(module, exports, __webpack_require__) { + + module.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 ^ 4', + 'log(10000, 10)', + 'log(10000) / log(10)', + 'b = log(1024, 2)', + '2 ^ b' + ], + 'seealso': [ + 'exp', + 'log10' + ] + }; + +/***/ }, +/* 254 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'log10', + 'category': 'Arithmetic', + 'syntax': [ + 'log10(x)' + ], + 'description': 'Compute the 10-base logarithm of a value.', + 'examples': [ + 'log10(0.00001)', + 'log10(10000)', + '10 ^ 4', + 'log(10000) / log(10)', + 'log(10000, 10)' + ], + 'seealso': [ + 'exp', + 'log' + ] + }; + + +/***/ }, +/* 255 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': ['divide'] + }; + + +/***/ }, +/* 256 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'multiply', + 'category': 'Operators', + 'syntax': [ + 'x * y', + 'multiply(x, y)' + ], + 'description': 'multiply two values.', + 'examples': [ + 'a = 2.1 * 3.4', + 'a / 3.4', + '2 * 3 + 4', + '2 * (3 + 4)', + '3 * 2.1 km' + ], + 'seealso': [ + 'divide' + ] + }; + + +/***/ }, +/* 257 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'norm', + 'category': 'Arithmetic', + 'syntax': [ + 'norm(x)', + 'norm(x, p)' + ], + 'description': 'Calculate the norm of a number, vector or matrix.', + 'examples': [ + 'abs(-3.5)', + 'norm(-3.5)', + 'norm(3 - 4i))', + 'norm([1, 2, -3], Infinity)', + 'norm([1, 2, -3], -Infinity)', + 'norm([3, 4], 2)', + 'norm([[1, 2], [3, 4]], 1)', + 'norm([[1, 2], [3, 4]], \'inf\')', + 'norm([[1, 2], [3, 4]], \'fro\')' + ] + }; + + +/***/ }, +/* 258 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'nthRoot', + 'category': 'Arithmetic', + 'syntax': [ + 'nthRoot(a)', + 'nthRoot(a, root)' + ], + 'description': 'Calculate the nth root of a value. ' + + 'The principal nth root of a positive real number A, ' + + 'is the positive real solution of the equation "x^root = A".', + 'examples': [ + '4 ^ 3', + 'nthRoot(64, 3)', + 'nthRoot(9, 2)', + 'sqrt(9)' + ], + 'seealso': [ + 'sqrt', + 'pow' + ] + }; + +/***/ }, +/* 259 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [ 'multiply' ] + }; + + +/***/ }, +/* 260 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 261 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 262 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 263 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 264 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'subtract', + 'category': 'Operators', + 'syntax': [ + 'x - y', + 'subtract(x, y)' + ], + 'description': 'subtract two values.', + 'examples': [ + 'a = 5.3 - 2', + 'a + 2', + '2/3 - 1/6', + '2 * 3 - 3', + '2.1 km - 500m' + ], + 'seealso': [ + 'add' + ] + }; + + +/***/ }, +/* 265 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'unaryMinus', + 'category': 'Operators', + 'syntax': [ + '-x', + 'unaryMinus(x)' + ], + 'description': + 'Inverse the sign of a value. Converts booleans and strings to numbers.', + 'examples': [ + '-4.5', + '-(-5.6)', + '-"22"' + ], + 'seealso': [ + 'add', 'subtract', 'unaryPlus' + ] + }; + + +/***/ }, +/* 266 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'unaryPlus', + 'category': 'Operators', + 'syntax': [ + '+x', + 'unaryPlus(x)' + ], + 'description': + 'Converts booleans and strings to numbers.', + 'examples': [ + '+true', + '+"2"' + ], + 'seealso': [ + 'add', 'subtract', 'unaryMinus' + ] + }; + + +/***/ }, +/* 267 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' ] + }; + + +/***/ }, +/* 268 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'bitAnd', + 'category': 'Bitwise', + 'syntax': [ + 'x & y', + 'bitAnd(x, y)' + ], + 'description': 'Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0', + 'examples': [ + '5 & 3', + 'bitAnd(53, 131)', + '[1, 12, 31] & 42' + ], + 'seealso': [ + 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 269 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'bitNot', + 'category': 'Bitwise', + 'syntax': [ + '~x', + 'bitNot(x)' + ], + 'description': 'Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.', + 'examples': [ + '~1', + '~2', + 'bitNot([2, -3, 4])' + ], + 'seealso': [ + 'bitAnd', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 270 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'bitOr', + 'category': 'Bitwise', + 'syntax': [ + 'x | y', + 'bitOr(x, y)' + ], + 'description': 'Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.', + 'examples': [ + '5 | 3', + 'bitOr([1, 2, 3], 4)' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitXor', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 271 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'bitXor', + 'category': 'Bitwise', + 'syntax': [ + 'bitXor(x, y)' + ], + 'description': 'Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.', + 'examples': [ + 'bitOr(1, 2)', + 'bitXor([2, 3, 4], 4)' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'leftShift', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 272 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'leftShift', + 'category': 'Bitwise', + 'syntax': [ + 'x << y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise left logical shift of a value x by y number of bits.', + 'examples': [ + '4 << 1', + '8 >> 1' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'rightArithShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 273 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'rightArithShift', + 'category': 'Bitwise', + 'syntax': [ + 'x >> y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise right arithmetic shift of a value x by y number of bits.', + 'examples': [ + '8 >> 1', + '4 << 1', + '-12 >> 2' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightLogShift' + ] + }; + + +/***/ }, +/* 274 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'rightLogShift', + 'category': 'Bitwise', + 'syntax': [ + 'x >> y', + 'leftShift(x, y)' + ], + 'description': 'Bitwise right logical shift of a value x by y number of bits.', + 'examples': [ + '8 >>> 1', + '4 << 1', + '-12 >>> 2' + ], + 'seealso': [ + 'bitAnd', 'bitNot', 'bitOr', 'bitXor', 'leftShift', 'rightArithShift' + ] + }; + + +/***/ }, +/* 275 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 276 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 277 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 278 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 279 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 280 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 281 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 282 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 283 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'matrix', + 'category': 'Type', + 'syntax': [ + '[]', + '[a1, b1, ...; a2, b2, ...]', + 'matrix()', + 'matrix("dense")', + 'matrix([...])' + ], + 'description': + 'Create a matrix.', + 'examples': [ + '[]', + '[1, 2, 3]', + '[1, 2, 3; 4, 5, 6]', + 'matrix()', + 'matrix([3, 4])', + 'matrix([3, 4; 5, 6], "sparse")', + 'matrix([3, 4; 5, 6], "sparse", "number")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'sparse' + ] + }; + + +/***/ }, +/* 284 */ +/***/ function(module, exports, __webpack_require__) { + + module.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])', + 'number("52cm", "m")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'matrix', 'string', 'unit' + ] + }; + + +/***/ }, +/* 285 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'sparse', + 'category': 'Type', + 'syntax': [ + 'sparse()', + 'sparse([a1, b1, ...; a1, b2, ...])', + 'sparse([a1, b1, ...; a1, b2, ...], "number")' + ], + 'description': + 'Create a sparse matrix.', + 'examples': [ + 'sparse()', + 'sparse([3, 4; 5, 6])', + 'sparse([3, 0; 5, 0], "number")' + ], + 'seealso': [ + 'bignumber', 'boolean', 'complex', 'index', 'number', 'string', 'unit', 'matrix' + ] + }; + + +/***/ }, +/* 286 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 287 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 288 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 289 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 290 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'and', + 'category': 'Logical', + 'syntax': [ + 'x and y', + 'and(x, y)' + ], + 'description': 'Logical and. Test whether two values are both defined with a nonzero/nonempty value.', + 'examples': [ + 'true and false', + 'true and true', + '2 and 4' + ], + 'seealso': [ + 'not', 'or', 'xor' + ] + }; + + +/***/ }, +/* 291 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'not', + 'category': 'Logical', + 'syntax': [ + '!x', + 'not x', + 'not(x)' + ], + 'description': 'Logical not. Flips the boolean value of given argument.', + 'examples': [ + '!true', + 'not false', + '!2', + '!0' + ], + 'seealso': [ + 'and', 'or', 'xor' + ] + }; + + +/***/ }, +/* 292 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'or', + 'category': 'Logical', + 'syntax': [ + 'x or y', + 'or(x, y)' + ], + 'description': 'Logical or. Test if at least one value is defined with a nonzero/nonempty value.', + 'examples': [ + 'true or false', + 'false or false', + '0 or 4' + ], + 'seealso': [ + 'not', 'and', 'xor' + ] + }; + + +/***/ }, +/* 293 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'xor', + 'category': 'Logical', + 'syntax': [ + 'x or y', + 'or(x, y)' + ], + 'description': 'Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.', + 'examples': [ + 'true xor false', + 'false xor false', + 'true xor true', + '0 or 4' + ], + 'seealso': [ + 'not', 'and', 'or' + ] + }; + + +/***/ }, +/* 294 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'concat', + 'category': 'Matrix', + 'syntax': [ + 'concat(A, B, C, ...)', + 'concat(A, B, C, ..., dim)' + ], + 'description': 'Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.', + 'examples': [ + 'A = [1, 2; 5, 6]', + 'B = [3, 4; 7, 8]', + 'concat(A, B)', + 'concat(A, B, 1)', + 'concat(A, B, 2)' + ], + 'seealso': [ + 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 295 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'cross', + 'category': 'Matrix', + 'syntax': [ + 'cross(A, B)' + ], + 'description': 'Calculate the cross product for two vectors in three dimensional space.', + 'examples': [ + 'cross([1, 1, 0], [0, 1, 1])', + 'cross([3, -3, 1], [4, 9, 2])', + 'cross([2, 3, 4], [5, 6, 7])' + ], + 'seealso': [ + 'multiply', + 'dot' + ] + }; + + +/***/ }, +/* 296 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'det', + 'category': 'Matrix', + 'syntax': [ + 'det(x)' + ], + 'description': 'Calculate the determinant of a matrix', + 'examples': [ + 'det([1, 2; 3, 4])', + 'det([-2, 2, 3; -1, 1, 3; 2, 0, -1])' + ], + 'seealso': [ + 'concat', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 297 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'diag', + 'category': 'Matrix', + 'syntax': [ + 'diag(x)', + 'diag(x, k)' + ], + 'description': 'Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.', + 'examples': [ + 'diag(1:3)', + 'diag(1:3, 1)', + 'a = [1, 2, 3; 4, 5, 6; 7, 8, 9]', + 'diag(a)' + ], + 'seealso': [ + 'concat', 'det', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 298 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'dot', + 'category': 'Matrix', + 'syntax': [ + 'dot(A, B)' + ], + 'description': 'Calculate the dot product of two vectors. ' + + 'The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] ' + + 'is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn', + 'examples': [ + 'dot([2, 4, 1], [2, 2, 3])', + '[2, 4, 1] * [2, 2, 3]' + ], + 'seealso': [ + 'multiply', + 'cross' + ] + }; + + +/***/ }, +/* 299 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'eye', + 'category': 'Matrix', + 'syntax': [ + 'eye(n)', + 'eye(m, n)', + 'eye([m, n])', + 'eye' + ], + 'description': 'Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.', + 'examples': [ + 'eye(3)', + 'eye(3, 5)', + 'a = [1, 2, 3; 4, 5, 6]', + 'eye(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 300 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'flatten', + 'category': 'Matrix', + 'syntax': [ + 'flatten(x)' + ], + 'description': 'Flatten a multi dimensional matrix into a single dimensional matrix.', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'size(a)', + 'b = flatten(a)', + 'size(b)' + ], + 'seealso': [ + 'concat', 'resize', 'size', 'squeeze' + ] + }; + + +/***/ }, +/* 301 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'inv', + 'category': 'Matrix', + 'syntax': [ + 'inv(x)' + ], + 'description': 'Calculate the inverse of a matrix', + 'examples': [ + 'inv([1, 2; 3, 4])', + 'inv(4)', + '1 / 4' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 302 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'ones', + 'category': 'Matrix', + 'syntax': [ + 'ones(m)', + 'ones(m, n)', + 'ones(m, n, p, ...)', + 'ones([m])', + 'ones([m, n])', + 'ones([m, n, p, ...])', + 'ones' + ], + 'description': 'Create a matrix containing ones.', + 'examples': [ + 'ones(3)', + 'ones(3, 5)', + 'ones([2,3]) * 4.5', + 'a = [1, 2, 3; 4, 5, 6]', + 'ones(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 303 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'range', + 'category': 'Type', + 'syntax': [ + 'start:end', + 'start:step:end', + 'range(start, end)', + 'range(start, end, step)', + 'range(string)' + ], + 'description': + 'Create a range. Lower bound of the range is included, upper bound is excluded.', + 'examples': [ + '1:5', + '3:-1:-3', + 'range(3, 7)', + 'range(0, 12, 2)', + 'range("4:10")', + 'a = [1, 2, 3, 4; 5, 6, 7, 8]', + 'a[1:2, 1:2]' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'size', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 304 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'resize', + 'category': 'Matrix', + 'syntax': [ + 'resize(x, size)', + 'resize(x, size, defaultValue)' + ], + 'description': 'Resize a matrix.', + 'examples': [ + 'resize([1,2,3,4,5], [3])', + 'resize([1,2,3], [5])', + 'resize([1,2,3], [5], -1)', + 'resize(2, [2, 3])', + 'resize("hello", [8], "!")' + ], + 'seealso': [ + 'size', 'subset', 'squeeze' + ] + }; + + +/***/ }, +/* 305 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'size', + 'category': 'Matrix', + 'syntax': [ + 'size(x)' + ], + 'description': 'Calculate the size of a matrix.', + 'examples': [ + 'size(2.3)', + 'size("hello world")', + 'a = [1, 2; 3, 4; 5, 6]', + 'size(a)', + 'size(1:6)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'squeeze', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 306 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'squeeze', + 'category': 'Matrix', + 'syntax': [ + 'squeeze(x)' + ], + 'description': 'Remove inner and outer singleton dimensions from a matrix.', + 'examples': [ + 'a = zeros(3,2,1)', + 'size(squeeze(a))', + 'b = zeros(1,1,3)', + 'size(squeeze(b))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'subset', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 307 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'subset', + 'category': 'Matrix', + 'syntax': [ + 'value(index)', + 'value(index) = replacement', + 'subset(value, [index])', + 'subset(value, [index], replacement)' + ], + 'description': 'Get or set a subset of a matrix or string. ' + + 'Indexes are one-based. ' + + 'Both the ranges lower-bound and upper-bound are included.', + 'examples': [ + 'd = [1, 2; 3, 4]', + 'e = []', + 'e[1, 1:2] = [5, 6]', + 'e[2, :] = [7, 8]', + 'f = d * e', + 'f[2, 1]', + 'f[:, 1]' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'trace', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 308 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'trace', + 'category': 'Matrix', + 'syntax': [ + 'trace(A)' + ], + 'description': 'Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.', + 'examples': [ + 'A = [1, 2, 3; -1, 2, 3; 2, 0, 3]', + 'trace(A)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'transpose', 'zeros' + ] + }; + + +/***/ }, +/* 309 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'transpose', + 'category': 'Matrix', + 'syntax': [ + 'x\'', + 'transpose(x)' + ], + 'description': 'Transpose a matrix', + 'examples': [ + 'a = [1, 2, 3; 4, 5, 6]', + 'a\'', + 'transpose(a)' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'zeros' + ] + }; + + +/***/ }, +/* 310 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'zeros', + 'category': 'Matrix', + 'syntax': [ + 'zeros(m)', + 'zeros(m, n)', + 'zeros(m, n, p, ...)', + 'zeros([m])', + 'zeros([m, n])', + 'zeros([m, n, p, ...])', + 'zeros' + ], + 'description': 'Create a matrix containing zeros.', + 'examples': [ + 'zeros(3)', + 'zeros(3, 5)', + 'a = [1, 2, 3; 4, 5, 6]', + 'zeros(size(a))' + ], + 'seealso': [ + 'concat', 'det', 'diag', 'eye', 'inv', 'ones', 'range', 'size', 'squeeze', 'subset', 'trace', 'transpose' + ] + }; + + +/***/ }, +/* 311 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'combinations', + 'category': 'Probability', + 'syntax': [ + 'combinations(n, k)' + ], + 'description': 'Compute the number of combinations of n items taken k at a time', + 'examples': [ + 'combinations(7, 5)' + ], + 'seealso': ['permutations', 'factorial'] + }; + + +/***/ }, +/* 312 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'factorial', + 'category': 'Probability', + 'syntax': [ + 'n!', + 'factorial(n)' + ], + 'description': 'Compute the factorial of a value', + 'examples': [ + '5!', + '5 * 4 * 3 * 2 * 1', + '3!' + ], + 'seealso': ['combinations', 'permutations', 'gamma'] + }; + + +/***/ }, +/* 313 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'gamma', + 'category': 'Probability', + 'syntax': [ + 'gamma(n)' + ], + 'description': 'Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.', + 'examples': [ + 'gamma(4)', + '3!', + 'gamma(1/2)', + 'sqrt(pi)' + ], + 'seealso': ['factorial'] + }; + + +/***/ }, +/* 314 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'permutations', + 'category': 'Probability', + 'syntax': [ + 'permutations(n)', + 'permutations(n, k)' + ], + 'description': 'Compute the number of permutations of n items taken k at a time', + 'examples': [ + 'permutations(5)', + 'permutations(5, 3)' + ], + 'seealso': ['combinations', 'factorial'] + }; + + +/***/ }, +/* 315 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': ['random', 'randomInt'] + }; + + +/***/ }, +/* 316 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'random', + 'category': 'Probability', + 'syntax': [ + 'random()', + 'random(max)', + 'random(min, max)', + 'random(size)', + 'random(size, max)', + 'random(size, min, max)' + ], + 'description': + 'Return a random number.', + 'examples': [ + 'random()', + 'random(10, 20)', + 'random([2, 3])' + ], + 'seealso': ['pickRandom', 'randomInt'] + }; + + +/***/ }, +/* 317 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': ['pickRandom', 'random'] + }; + +/***/ }, +/* 318 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'compare', + 'category': 'Relational', + 'syntax': [ + 'compare(x, y)' + ], + 'description': + 'Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.', + 'examples': [ + 'compare(2, 3)', + 'compare(3, 2)', + 'compare(2, 2)', + 'compare(5cm, 40mm)', + 'compare(2, [1, 2, 3])' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq' + ] + }; + + +/***/ }, +/* 319 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'deepEqual', + 'category': 'Relational', + 'syntax': [ + 'deepEqual(x, y)' + ], + 'description': + 'Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.', + 'examples': [ + '[1,3,4] == [1,3,4]', + '[1,3,4] == [1,3]' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 320 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'equal', + 'category': 'Relational', + 'syntax': [ + 'x == y', + 'equal(x, y)' + ], + 'description': + 'Check equality of two values. Returns true if the values are equal, and false if not.', + 'examples': [ + '2+2 == 3', + '2+2 == 4', + 'a = 3.2', + 'b = 6-2.8', + 'a == b', + '50cm == 0.5m' + ], + 'seealso': [ + 'unequal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' + ] + }; + + +/***/ }, +/* 321 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'larger', + 'category': 'Relational', + 'syntax': [ + 'x > y', + 'larger(x, y)' + ], + 'description': + 'Check if value x is larger than y. Returns true if x is larger than y, and false if not.', + 'examples': [ + '2 > 3', + '5 > 2*2', + 'a = 3.3', + 'b = 6-2.8', + '(a > b)', + '(b < a)', + '5 cm > 2 inch' + ], + 'seealso': [ + 'equal', 'unequal', 'smaller', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 322 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'largerEq', + 'category': 'Relational', + 'syntax': [ + 'x >= y', + 'largerEq(x, y)' + ], + 'description': + 'Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.', + 'examples': [ + '2 > 1+1', + '2 >= 1+1', + 'a = 3.2', + 'b = 6-2.8', + '(a > b)' + ], + 'seealso': [ + 'equal', 'unequal', 'smallerEq', 'smaller', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 323 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'smaller', + 'category': 'Relational', + 'syntax': [ + 'x < y', + 'smaller(x, y)' + ], + 'description': + 'Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.', + 'examples': [ + '2 < 3', + '5 < 2*2', + 'a = 3.3', + 'b = 6-2.8', + '(a < b)', + '5 cm < 2 inch' + ], + 'seealso': [ + 'equal', 'unequal', 'larger', 'smallerEq', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 324 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'smallerEq', + 'category': 'Relational', + 'syntax': [ + 'x <= y', + 'smallerEq(x, y)' + ], + 'description': + 'Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.', + 'examples': [ + '2 < 1+1', + '2 <= 1+1', + 'a = 3.2', + 'b = 6-2.8', + '(a < b)' + ], + 'seealso': [ + 'equal', 'unequal', 'larger', 'smaller', 'largerEq', 'compare' + ] + }; + + +/***/ }, +/* 325 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'unequal', + 'category': 'Relational', + 'syntax': [ + 'x != y', + 'unequal(x, y)' + ], + 'description': + 'Check unequality of two values. Returns true if the values are unequal, and false if they are equal.', + 'examples': [ + '2+2 != 3', + '2+2 != 4', + 'a = 3.2', + 'b = 6-2.8', + 'a != b', + '50cm != 0.5m', + '5 cm != 2 inch' + ], + 'seealso': [ + 'equal', 'smaller', 'larger', 'smallerEq', 'largerEq', 'compare', 'deepEqual' + ] + }; + + +/***/ }, +/* 326 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'max', + 'category': 'Statistics', + 'syntax': [ + 'max(a, b, c, ...)', + 'max(A)', + 'max(A, dim)' + ], + 'description': 'Compute the maximum value of a list of values.', + 'examples': [ + 'max(2, 3, 4, 1)', + 'max([2, 3, 4, 1])', + 'max([2, 5; 4, 3])', + 'max([2, 5; 4, 3], 1)', + 'max([2, 5; 4, 3], 2)', + 'max(2.7, 7.1, -4.5, 2.0, 4.1)', + 'min(2.7, 7.1, -4.5, 2.0, 4.1)' + ], + 'seealso': [ + 'mean', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 327 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'mean', + 'category': 'Statistics', + 'syntax': [ + 'mean(a, b, c, ...)', + 'mean(A)', + 'mean(A, dim)' + ], + 'description': 'Compute the arithmetic mean of a list of values.', + 'examples': [ + 'mean(2, 3, 4, 1)', + 'mean([2, 3, 4, 1])', + 'mean([2, 5; 4, 3])', + 'mean([2, 5; 4, 3], 1)', + 'mean([2, 5; 4, 3], 2)', + 'mean([1.0, 2.7, 3.2, 4.0])' + ], + 'seealso': [ + 'max', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 328 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'median', + 'category': 'Statistics', + 'syntax': [ + 'median(a, b, c, ...)', + 'median(A)' + ], + 'description': 'Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.', + 'examples': [ + 'median(5, 2, 7)', + 'median([3, -1, 5, 7])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 329 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'min', + 'category': 'Statistics', + 'syntax': [ + 'min(a, b, c, ...)', + 'min(A)', + 'min(A, dim)' + ], + 'description': 'Compute the minimum value of a list of values.', + 'examples': [ + 'min(2, 3, 4, 1)', + 'min([2, 3, 4, 1])', + 'min([2, 5; 4, 3])', + 'min([2, 5; 4, 3], 1)', + 'min([2, 5; 4, 3], 2)', + 'min(2.7, 7.1, -4.5, 2.0, 4.1)', + 'max(2.7, 7.1, -4.5, 2.0, 4.1)' + ], + 'seealso': [ + 'max', + 'mean', + 'median', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 330 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'prod', + 'category': 'Statistics', + 'syntax': [ + 'prod(a, b, c, ...)', + 'prod(A)' + ], + 'description': 'Compute the product of all values.', + 'examples': [ + 'prod(2, 3, 4)', + 'prod([2, 3, 4])', + 'prod([2, 5; 4, 3])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 331 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'std', + 'category': 'Statistics', + 'syntax': [ + 'std(a, b, c, ...)', + 'std(A)', + 'std(A, normalization)' + ], + 'description': 'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', + 'examples': [ + 'std(2, 4, 6)', + 'std([2, 4, 6, 8])', + 'std([2, 4, 6, 8], "uncorrected")', + 'std([2, 4, 6, 8], "biased")', + 'std([1, 2, 3; 4, 5, 6])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'prod', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 332 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'sum', + 'category': 'Statistics', + 'syntax': [ + 'sum(a, b, c, ...)', + 'sum(A)' + ], + 'description': 'Compute the sum of all values.', + 'examples': [ + 'sum(2, 3, 4, 1)', + 'sum([2, 3, 4, 1])', + 'sum([2, 5; 4, 3])' + ], + 'seealso': [ + 'max', + 'mean', + 'median', + 'min', + 'prod', + 'std', + 'sum', + 'var' + ] + }; + + +/***/ }, +/* 333 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'var', + 'category': 'Statistics', + 'syntax': [ + 'var(a, b, c, ...)', + 'var(A)', + 'var(A, normalization)' + ], + 'description': 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".', + 'examples': [ + 'var(2, 4, 6)', + 'var([2, 4, 6, 8])', + 'var([2, 4, 6, 8], "uncorrected")', + 'var([2, 4, 6, 8], "biased")', + 'var([1, 2, 3; 4, 5, 6])' + ], + 'seealso': [ + 'max', + 'mean', + 'min', + 'median', + 'min', + 'prod', + 'std', + 'sum' + ] + }; + + +/***/ }, +/* 334 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acos', + 'category': 'Trigonometry', + 'syntax': [ + 'acos(x)' + ], + 'description': 'Compute the inverse cosine of a value in radians.', + 'examples': [ + 'acos(0.5)', + 'acos(cos(2.3))' + ], + 'seealso': [ + 'cos', + 'atan', + 'asin' + ] + }; + + +/***/ }, +/* 335 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acosh', + 'category': 'Trigonometry', + 'syntax': [ + 'acosh(x)' + ], + 'description': 'Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.', + 'examples': [ + 'acosh(1.5)' + ], + 'seealso': [ + 'cosh', + 'asinh', + 'atanh' + ] + }; + +/***/ }, +/* 336 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acot', + 'category': 'Trigonometry', + 'syntax': [ + 'acot(x)' + ], + 'description': 'Calculate the inverse cotangent of a value.', + 'examples': [ + 'acot(0.5)', + 'acot(cot(0.5))', + 'acot(2)' + ], + 'seealso': [ + 'cot', + 'atan' + ] + }; + + +/***/ }, +/* 337 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acoth', + 'category': 'Trigonometry', + 'syntax': [ + 'acoth(x)' + ], + 'description': 'Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.', + 'examples': [ + 'acoth(0.5)' + ], + 'seealso': [ + 'acsch', + 'asech' + ] + }; + +/***/ }, +/* 338 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acsc', + 'category': 'Trigonometry', + 'syntax': [ + 'acsc(x)' + ], + 'description': 'Calculate the inverse cotangent of a value.', + 'examples': [ + 'acsc(0.5)', + 'acsc(csc(0.5))', + 'acsc(2)' + ], + 'seealso': [ + 'csc', + 'asin', + 'asec' + ] + }; + + +/***/ }, +/* 339 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'acsch', + 'category': 'Trigonometry', + 'syntax': [ + 'acsch(x)' + ], + 'description': 'Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.', + 'examples': [ + 'acsch(0.5)' + ], + 'seealso': [ + 'asech', + 'acoth' + ] + }; + + +/***/ }, +/* 340 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'asec', + 'category': 'Trigonometry', + 'syntax': [ + 'asec(x)' + ], + 'description': 'Calculate the inverse secant of a value.', + 'examples': [ + 'asec(0.5)', + 'asec(sec(0.5))', + 'asec(2)' + ], + 'seealso': [ + 'acos', + 'acot', + 'acsc' + ] + }; + + +/***/ }, +/* 341 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'asech', + 'category': 'Trigonometry', + 'syntax': [ + 'asech(x)' + ], + 'description': 'Calculate the inverse secant of a value.', + 'examples': [ + 'asech(0.5)' + ], + 'seealso': [ + 'acsch', + 'acoth' + ] + }; + + +/***/ }, +/* 342 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'asin', + 'category': 'Trigonometry', + 'syntax': [ + 'asin(x)' + ], + 'description': 'Compute the inverse sine of a value in radians.', + 'examples': [ + 'asin(0.5)', + 'asin(sin(2.3))' + ], + 'seealso': [ + 'sin', + 'acos', + 'atan' + ] + }; + + +/***/ }, +/* 343 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'asinh', + 'category': 'Trigonometry', + 'syntax': [ + 'asinh(x)' + ], + 'description': 'Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.', + 'examples': [ + 'asinh(0.5)' + ], + 'seealso': [ + 'acosh', + 'atanh' + ] + }; + + +/***/ }, +/* 344 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 345 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'atanh', + 'category': 'Trigonometry', + 'syntax': [ + 'atanh(x)' + ], + 'description': 'Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.', + 'examples': [ + 'atanh(0.5)' + ], + 'seealso': [ + 'acosh', + 'asinh' + ] + }; + + +/***/ }, +/* 346 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 347 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 348 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'cosh', + 'category': 'Trigonometry', + 'syntax': [ + 'cosh(x)' + ], + 'description': 'Compute the hyperbolic cosine of x in radians.', + 'examples': [ + 'cosh(0.5)' + ], + 'seealso': [ + 'sinh', + 'tanh', + 'coth' + ] + }; + + +/***/ }, +/* 349 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 350 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'coth', + 'category': 'Trigonometry', + 'syntax': [ + 'coth(x)' + ], + 'description': 'Compute the hyperbolic cotangent of x in radians.', + 'examples': [ + 'coth(2)', + '1 / tanh(2)' + ], + 'seealso': [ + 'sech', + 'csch', + 'tanh' + ] + }; + + +/***/ }, +/* 351 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 352 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'csch', + 'category': 'Trigonometry', + 'syntax': [ + 'csch(x)' + ], + 'description': 'Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)', + 'examples': [ + 'csch(2)', + '1 / sinh(2)' + ], + 'seealso': [ + 'sech', + 'coth', + 'sinh' + ] + }; /***/ }, /* 353 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - // Reserved keywords not allowed to use in the parser module.exports = { - end: true + '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' + ] }; @@ -35749,770 +38280,304 @@ return /******/ (function(modules) { // webpackBootstrap /* 354 */ /***/ function(module, exports, __webpack_require__) { - 'use strict' - - //list of identifiers of nodes in order of their precedence - //also contains information about left/right associativity - //and which other operator the operator is associative with - //Example: - // addition is associative with addition and subtraction, because: - // (a+b)+c=a+(b+c) - // (a+b)-c=a+(b-c) - // - // postfix operators are left associative, prefix operators - // are right associative - // - //It's also possible to set the following properties: - // latexParens: if set to false, this node doesn't need to be enclosed - // in parentheses when using LaTeX - // latexLeftParens: if set to false, this !OperatorNode's! - // left argument doesn't need to be enclosed - // in parentheses - // latexRightParens: the same for the right argument - var properties = [ - { //assignment - 'AssignmentNode': {}, - 'FunctionAssignmentNode': {} - }, - { //conditional expression - 'ConditionalNode': { - latexLeftParens: false, - latexRightParens: false, - latexParens: false - //conditionals don't need parentheses in LaTeX because - //they are 2 dimensional - } - }, - { //logical or - 'OperatorNode:or': { - associativity: 'left', - associativeWith: [] - } - - }, - { //logical xor - 'OperatorNode:xor': { - associativity: 'left', - associativeWith: [] - } - }, - { //logical and - 'OperatorNode:and': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise or - 'OperatorNode:bitOr': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise xor - 'OperatorNode:bitXor': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitwise and - 'OperatorNode:bitAnd': { - associativity: 'left', - associativeWith: [] - } - }, - { //relational operators - 'OperatorNode:equal': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:unequal': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:smaller': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:larger': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:smallerEq': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:largerEq': { - associativity: 'left', - associativeWith: [] - } - }, - { //bitshift operators - 'OperatorNode:leftShift': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:rightArithShift': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:rightLogShift': { - associativity: 'left', - associativeWith: [] - } - }, - { //unit conversion - 'OperatorNode:to': { - associativity: 'left', - associativeWith: [] - } - }, - { //range - 'RangeNode': {} - }, - { //addition, subtraction - 'OperatorNode:add': { - associativity: 'left', - associativeWith: ['OperatorNode:add', 'OperatorNode:subtract'] - }, - 'OperatorNode:subtract': { - associativity: 'left', - associativeWith: [] - } - }, - { //multiply, divide, modulus - 'OperatorNode:multiply': { - associativity: 'left', - associativeWith: [ - 'OperatorNode:multiply', - 'OperatorNode:divide', - 'Operator:dotMultiply', - 'Operator:dotDivide' - ] - }, - 'OperatorNode:divide': { - associativity: 'left', - associativeWith: [], - latexLeftParens: false, - latexRightParens: false, - latexParens: false - //fractions don't require parentheses because - //they're 2 dimensional, so parens aren't needed - //in LaTeX - }, - 'OperatorNode:dotMultiply': { - associativity: 'left', - associativeWith: [ - 'OperatorNode:multiply', - 'OperatorNode:divide', - 'OperatorNode:dotMultiply', - 'OperatorNode:doDivide' - ] - }, - 'OperatorNode:dotDivide': { - associativity: 'left', - associativeWith: [] - }, - 'OperatorNode:mod': { - associativity: 'left', - associativeWith: [] - } - }, - { //unary prefix operators - 'OperatorNode:unaryPlus': { - associativity: 'right' - }, - 'OperatorNode:unaryMinus': { - associativity: 'right' - }, - 'OperatorNode:bitNot': { - associativity: 'right' - }, - 'OperatorNode:not': { - associativity: 'right' - } - }, - { //exponentiation - 'OperatorNode:pow': { - associativity: 'right', - associativeWith: [], - latexRightParens: false, - //the exponent doesn't need parentheses in - //LaTeX because it's 2 dimensional - //(it's on top) - }, - 'OperatorNode:dotPow': { - associativity: 'right', - associativeWith: [] - } - }, - { //factorial - 'OperatorNode:factorial': { - associativity: 'left' - } - }, - { //matrix transpose - 'OperatorNode:transpose': { - associativity: 'left' - } - } - ]; - - /** - * Get the precedence of a Node. - * Higher number for higher precedence, starting with 0. - * Returns null if the precedence is undefined. - * - * @param {Node} - * @return {Number|null} - */ - function getPrecedence (node) { - var identifier = node.getIdentifier(); - for (var i = 0; i < properties.length; i++) { - if (identifier in properties[i]) { - return i; - } - } - return null; - } - - /** - * Get the associativity of an operator (left or right). - * Returns a string containing 'left' or 'right' or null if - * the associativity is not defined. - * - * @param {Node} - * @return {String|null} - * @throws {Error} - */ - function getAssociativity (node) { - var identifier = node.getIdentifier(); - var index = getPrecedence(node); - if (index === null) { - //node isn't in the list - return null; - } - var property = properties[index][identifier]; - - if (property.hasOwnProperty('associativity')) { - if (property.associativity === 'left') { - return 'left'; - } - if (property.associativity === 'right') { - return 'right'; - } - //associativity is invalid - throw Error('\'' + identifier + '\' has the invalid associativity \'' - + property.associativity + '\'.'); - } - - //associativity is undefined - return null; - } - - /** - * Check if an operator is associative with another operator. - * Returns either true or false or null if not defined. - * - * @param {Node} nodeA - * @param {Node} nodeB - * @return {bool|null} - */ - function isAssociativeWith (nodeA, nodeB) { - var identifierA = nodeA.getIdentifier(); - var identifierB = nodeB.getIdentifier(); - var index = getPrecedence(nodeA); - if (index === null) { - //node isn't in the list - return null; - } - var property = properties[index][identifierA]; - - if (property.hasOwnProperty('associativeWith') - && (property.associativeWith instanceof Array)) { - for (var i = 0; i < property.associativeWith.length; i++) { - if (property.associativeWith[i] === identifierB) { - return true; - } - } - return false; - } - - //associativeWith is not defined - return null; - } - - module.exports.properties = properties; - module.exports.getPrecedence = getPrecedence; - module.exports.getAssociativity = getAssociativity; - module.exports.isAssociativeWith = isAssociativeWith; + module.exports = { + 'name': 'sech', + 'category': 'Trigonometry', + 'syntax': [ + 'sech(x)' + ], + 'description': 'Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)', + 'examples': [ + 'sech(2)', + '1 / cosh(2)' + ], + 'seealso': [ + 'coth', + 'csch', + 'cosh' + ] + }; /***/ }, /* 355 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - exports.symbols = { - // GREEK LETTERS - Alpha: 'A', alpha: '\\alpha', - Beta: 'B', beta: '\\beta', - Gamma: '\\Gamma', gamma: '\\gamma', - Delta: '\\Delta', delta: '\\delta', - Epsilon: 'E', epsilon: '\\epsilon', varepsilon: '\\varepsilon', - Zeta: 'Z', zeta: '\\zeta', - Eta: 'H', eta: '\\eta', - Theta: '\\Theta', theta: '\\theta', vartheta: '\\vartheta', - Iota: 'I', iota: '\\iota', - Kappa: 'K', kappa: '\\kappa', varkappa: '\\varkappa', - Lambda: '\\Lambda', lambda: '\\lambda', - Mu: 'M', mu: '\\mu', - Nu: 'N', nu: '\\nu', - Xi: '\\Xi', xi: '\\xi', - Omicron: 'O', omicron: 'o', - Pi: '\\Pi', pi: '\\pi', varpi: '\\varpi', - Rho: 'P', rho: '\\rho', varrho: '\\varrho', - Sigma: '\\Sigma', sigma: '\\sigma', varsigma: '\\varsigma', - Tau: 'T', tau: '\\tau', - Upsilon: '\\Upsilon', upsilon: '\\upsilon', - Phi: '\\Phi', phi: '\\phi', varphi: '\\varphi', - Chi: 'X', chi: '\\chi', - Psi: '\\Psi', psi: '\\psi', - Omega: '\\Omega', omega: '\\omega', - //logic - 'true': '\\mathrm{True}', - 'false': '\\mathrm{False}', - //other - i: 'i', //TODO use \i ?? - inf: '\\infty', - Inf: '\\infty', - infinity: '\\infty', - Infinity: '\\infty', - oo: '\\infty', - lim: '\\lim', - 'undefined': '\\mathbf{?}' + module.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' + ] }; - - exports.operators = { - 'transpose': '^\\top', - 'factorial': '!', - 'pow': '^', - 'dotPow': '.^\\wedge', //TODO find ideal solution - 'unaryPlus': '+', - 'unaryMinus': '-', - 'bitNot': '~', //TODO find ideal solution - 'not': '\\neg', - 'multiply': '\\cdot', - 'divide': '\\frac', //TODO how to handle that properly? - 'dotMultiply': '.\\cdot', //TODO find ideal solution - 'dotDivide': '.:', //TODO find ideal solution - 'mod': '\\mod', - 'add': '+', - 'subtract': '-', - 'to': '\\rightarrow', - 'leftShift': '<<', - 'rightArithShift': '>>', - 'rightLogShift': '>>>', - 'equal': '=', - 'unequal': '\\neq', - 'smaller': '<', - 'larger': '>', - 'smallerEq': '\\leq', - 'largerEq': '\\geq', - 'bitAnd': '\\&', - 'bitXor': '\\underline{|}', - 'bitOr': '|', - 'and': '\\wedge', - 'xor': '\\veebar', - 'or': '\\vee' - }; - - - //create a comma separated list of function arguments - function functionArgs(args, callbacks) { - return args.map( function (arg) { - return arg.toTex(callbacks); - }).join(','); - } - - var defaultTemplate = '\\mathrm{%name%}\\left(%*%\\right)'; - - /* - * expand a template - * - * @param {String} template - * @param {String} name of the function - * @param {Array} arguments of the function ( Strings ) - **/ - function expandTemplate(template, name, args) { - //replace %name% with the variable 'name' - template = template.replace(/%name%/g, name); - - //replace %0%, %1% .... with the arguments in args - args.forEach(function (arg, index) { - template = template.replace(RegExp('%' + index + '%', 'g'), arg); - }); - - //replace %*% with a comma separated list of all arguments - template = template.replace('%*%', args.map(function (arg) { - return arg; - }).join(',')); - - //replace %% with %, this comes in handy when you need a % in your LaTeX string - template = template.replace('%%', '%'); - - return template; - } - - //this is a map containing all the latex converters for all the functions - var functions = { - //arithmetic - 'abs': '\\left|%0%\\right|', - 'add': '\\left(%0%+%1%\\right)', - 'ceil': '\\left\\lceil%0%\\right\\rceil', - 'cube': '\\left(%0%\\right)^3', - 'divide': '\\frac{%0%}{%1%}', - 'dotDivide': '\\left(%0%' + exports.operators['dotDivide'] + '%1%\\right)', - 'dotMultiply': '\\left(%0%' + exports.operators['dotMultiply'] + '%1%\\right)', - 'dotPow': '\\left(%0%' + exports.operators['dotPow'] + '%1%\\right)', - 'exp': '\\exp\\left(%0%\\right)', - 'fix': defaultTemplate, - 'floor': '\\left\\lfloor%0%\\right\\rfloor', - 'gcd': '\\gcd\\left(%*%\\right)', - 'lcm': defaultTemplate, - 'log10': '\\log_{10}\\left(%0%\\right)', - 'log': { - 1: '\\ln\\left(%0%\\right)', - 2: '\\log_{%1%}\\left(%0%\\right)' - }, - 'mod': '\\left(%0%' + exports.operators['mod'] + '%1%\\right)', - 'multiply': '\\left(%0%' + exports.operators['multiply'] + '%1%\\right)', - 'norm': { - 1: '\\left\\|%0%\\right\\|', - 2: defaultTemplate - }, - 'nthRoot': '\\sqrt[%1%]{%0%}', - 'pow': '\\left(%0%\\right)' + exports.operators['pow'] + '{%1%}', - 'round': { - 1: '\\left\\lfloor%0%\\right\\rceil', - 2: defaultTemplate - }, - 'sign': defaultTemplate, - 'sqrt': '\\sqrt{%0%}', - 'square': '\\left(%0%\\right)^2', - 'subtract': '\\left(%0%' + exports.operators['subtract'] + '%1%\\right)', - 'unaryMinus': exports.operators['unaryMinus'] + '\\left(%0%\\right)', - 'unaryPlus': exports.operators['unaryPlus'] + '\\left(%0%\\right)', - 'xgcd': defaultTemplate, - - //bitwise - 'bitAnd': '\\left(%0%' + exports.operators['bitAnd'] + '%1%\\right)', - 'bitOr': '\\left(%0%' + exports.operators['bitOr'] + '%1%\\right)', - 'bitXor': '\\left(%0%' + exports.operators['bitXor'] + '%1%\\right)', - 'bitNot': exports.operators['bitNot'] + '\\left(%0%\\right)', - 'leftShift': '\\left(%0%' + exports.operators['leftShift'] + '%1%\\right)', - 'rightArithShift': '\\left(%0%' + exports.operators['rightArithShift'] + '%1%\\right)', - 'rightLogShift': '\\left(%0%' + exports.operators['rightLogShift'] + '%1%\\right)', - - //complex - 'arg': '\\arg\\left(%0%\\right)', - 'conj': '\\left(%0%\\right)^*', - 'im': '\\Im\\left\\lbrace%0%\\right\\rbrace', - 're': '\\Re\\left\\lbrace%0%\\right\\rbrace', - - //construction - 'bignumber': { - 0: '0', - 1: '\\left(%0%\\right)' - }, - 'boolean': defaultTemplate, - 'chain': defaultTemplate, - 'complex': { - 0: '0', - 1: '\\left(%0%\\right)', - 2: '\\left(\\left(%0%\\right)+' - + exports.symbols['i'] + '\\cdot\\left(%1%\\right)\\right)', - }, - 'index': defaultTemplate, - 'matrix': { - 0: '\\begin{bmatrix}\\end{bmatrix}', - 1: '\\left(%0%\\right)', - 2: '\\left(%0%\\right)' - }, - 'number': { - 0: '0', - 1: '\\left(%0%\\right)', - 2: '\\left(\\left(%0%\\right)%1%\\right)' - }, - 'parser': defaultTemplate, - 'sparse': { - 0: '\\begin{bsparse}\\end{bsparse}', - 1: '\\left(%0%\\right)' - }, - 'string': { - 0: '""', - 1: function (node) { - return '"' + node.args[0].toString() + '"'; - } - }, - 'unit': { - 1: '\\left(%0%\\right)', - 2: '\\left(\\left(%0%\\right)%1%\\right)' - }, - - //expression TODO does the default even work in this case? (.toTex on the args) - 'compile': defaultTemplate, - 'eval': defaultTemplate, - 'help': defaultTemplate, - 'parse': defaultTemplate, - - //logical - 'and': '\\left(%0%' + exports.operators['and'] + '%1%\\right)', - 'not': exports.operators['not'] + '\\left(%0%\\right)', - 'or': '\\left(%0%' + exports.operators['or'] + '%1%\\right)', - 'xor': '\\left(%0%' + exports.operators['xor'] + '%1%\\right)', - - //matrix - 'concat': defaultTemplate, - 'cross': '\\left(%0%\\right)\\times\\left(%1%\\right)', - 'det': '\\det\\left(%0%\\right)', - 'diag': defaultTemplate, - 'dot': '\\left(%0%\\cdot%1%\\right)', - 'eye': defaultTemplate, - 'flatten': defaultTemplate, - 'inv': '\\left(%0%\\right)^{-1}', - 'ones': defaultTemplate, - 'range': defaultTemplate, - 'resize': defaultTemplate, - 'size': defaultTemplate, - 'squeeze': defaultTemplate, - 'subset': defaultTemplate, - 'trace': '\\mathrm{tr}\\left(%0%\\right)', - 'transpose': '\\left(%0%\\right)' + exports.operators['transpose'], - 'zeros': defaultTemplate, - - //probability - 'combinations': '\\binom{%0%}{%1%}', - 'distribution': defaultTemplate, - 'factorial': '\\left(%0%\\right)' + exports.operators['factorial'], - 'gamma': '\\Gamma\\left(%0%\\right)', - 'permutations': defaultTemplate, - 'pickRandom': defaultTemplate, - 'randomInt': defaultTemplate, - 'random': defaultTemplate, - - //relational - 'compare': defaultTemplate, - 'deepEqual': defaultTemplate, - 'equal': '\\left(%0%' + exports.operators['equal'] + '%1%\\right)', - 'largerEq': '\\left(%0%' + exports.operators['largerEq'] + '%1%\\right)', - 'larger': '\\left(%0%' + exports.operators['larger'] + '%1%\\right)', - 'smallerEq': '\\left(%0%' + exports.operators['smallerEq'] + '%1%\\right)', - 'smaller': '\\left(%0%' + exports.operators['smaller'] + '%1%\\right)', - 'unequal': '\\left(%0%' + exports.operators['unequal'] + '%1%\\right)', - - //statistics - 'max': '\\max\\left(%*%\\right)', - 'mean': defaultTemplate, - 'median': defaultTemplate, - 'min': '\\min\\left(%*%\\right)', - 'prod': defaultTemplate, - 'std': defaultTemplate, - 'sum': defaultTemplate, - 'var': '\\mathrm{Var}\\left(%*%\\right)', - - //trigonometry - 'acosh': '\\cosh^{-1}\\left(%0%\\right)', - 'acos': '\\cos^{-1}\\left(%0%\\right)', - 'acoth': '\\coth^{-1}\\left(%0%\\right)', - 'acot': '\\cot^{-1}\\left(%0%\\right)', - 'acsch': '\\mathrm{csch}^{-1}\\left(%0%\\right)', - 'acsc': '\\csc^{-1}\\left(%0%\\right)', - 'asech': '\\mathrm{sech}^{-1}\\left(%0%\\right)', - 'asec': '\\sec^{-1}\\left(%0%\\right)', - 'asinh': '\\sinh^{-1}\\left(%0%\\right)', - 'asin': '\\sin^{-1}\\left(%0%\\right)', - 'atan2': '\\mathrm{atan2}\\left(%*%\\right)', - 'atanh': '\\tanh^{-1}\\left(%0%\\right)', - 'atan': '\\tan^{-1}\\left(%0%\\right)', - 'cosh': '\\cosh\\left(%0%\\right)', - 'cos': '\\cos\\left(%0%\\right)', - 'coth': '\\coth\\left(%0%\\right)', - 'cot': '\\cot\\left(%0%\\right)', - 'csch': '\\mathrm{csch}\\left(%0%\\right)', - 'csc': '\\csc\\left(%0%\\right)', - 'sech': '\\mathrm{sech}\\left(%0%\\right)', - 'sec': '\\sec\\left(%0%\\right)', - 'sinh': '\\sinh\\left(%0%\\right)', - 'sin': '\\sin\\left(%0%\\right)', - 'tanh': '\\tanh\\left(%0%\\right)', - 'tan': '\\tan\\left(%0%\\right)', - - //units - 'to': '\\left(%0%' + exports.operators['to'] + '%1%\\right)', - - //utils - 'clone': defaultTemplate, - 'filter': defaultTemplate, - 'forEach': defaultTemplate, - 'format': defaultTemplate, - 'import': defaultTemplate, - 'map': defaultTemplate, - 'print': defaultTemplate, - 'sort': defaultTemplate, - 'typeof': defaultTemplate - }; - - var units = { - deg: '^\\circ' - }; - - //FIXME find a good solution so that single characters still - //get rendered in regular italic whereas single character units - //are rendered with \mathrm - exports.toSymbol = function (name) { - if (units.hasOwnProperty(name)) { - return units[name]; - } - - if (exports.symbols.hasOwnProperty(name)) { - return exports.symbols[name]; - } - else if (name.indexOf('_') !== -1) { - //symbol with index (eg. alpha_1) - var index = name.indexOf('_'); - return exports.toSymbol(name.substring(0, index)) + '_{' - + exports.toSymbol(name.substring(index + 1)) + '}'; - } - return '\\mathrm{' + name + '}'; - }; - - //returns the latex output for a given function - exports.toFunction = function (node, callbacks, name) { - var latexConverter = functions[name]; - var args = node.args.map(function (arg) { //get LaTeX of the arguments - return arg.toTex(callbacks); - }); - - switch (typeof latexConverter) { - case 'function': //a callback function - return latexConverter(node, callbacks); - case 'string': //a template string - return expandTemplate(latexConverter, name, args); - case 'object': //an object with different "converters" for different numbers of arguments - switch (typeof latexConverter[args.length]) { - case 'function': - return latexConverter[args.length](node, callbacks); - case 'string': - return expandTemplate(latexConverter[args.length], name, args); - } - //no break here! That's intentionally - default: - return expandTemplate(defaultTemplate, name, args); - } - } /***/ }, /* 356 */ /***/ function(module, exports, __webpack_require__) { - 'use strict'; - - var util = __webpack_require__(171); - - var string = util.string; - var array = util.array; - var object = util.object; - - var isArray = Array.isArray; - - function factory (type, config, load, typed) { - - var Matrix = type.Matrix; - - /** - * Validates matrix and column vector b for backward/forward substitution algorithms. - * - * @param {Matrix} m An N x N matrix - * @param {Array | Matrix} b A column vector - * - * @return {Array} Dense copy of column vector b - */ - var substitutionValidation = function (m, b) { - // matrix size - var size = m.size(); - // validate matrix dimensions - if (size.length !== 2) - throw new RangeError('Matrix must be two dimensional (size: ' + string.format(size) + ')'); - // rows & columns - var rows = size[0]; - var columns = size[1]; - // validate rows & columns - if (rows !== columns) - throw new RangeError('Matrix must be square (size: ' + string.format(size) + ')'); - // check b is matrix - if (b instanceof Matrix) { - // matrix size - var msize = b.size(); - // check matrix dimensions, vector - if (msize.length === 1) { - // check vector length - if (msize[0] !== rows) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - else if (msize.length === 2) { - // array must be a column vector - if (msize[0] !== rows || msize[1] !== 1) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - else { - // throw error - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - // dense copy of column vector - var x = new Array(rows); - // copy values (skip zeros) - b.forEach(function (v, index) { - x[index[0]] = object.clone(v); - }, true); - // return vector - return x; - } - // check b is array - if (isArray(b)) { - // size - var asize = array.size(b); - // check matrix dimensions, vector - if (asize.length === 1) { - // check vector length - if (asize[0] !== rows) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // return copy of b - return object.clone(b); - } - if (asize.length === 2) { - // array must be a column vector - if (asize[0] !== rows || asize[1] !== 1) - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - // loop rows in array, return copy of column vector - return b.map(function (v) { - return object.clone(v[0]); - }); - } - // throw error - throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); - } - }; - - return substitutionValidation; - } - - exports.name = 'substitutionValidation'; - exports.factory = factory; + module.exports = { + 'name': 'sinh', + 'category': 'Trigonometry', + 'syntax': [ + 'sinh(x)' + ], + 'description': 'Compute the hyperbolic sine of x in radians.', + 'examples': [ + 'sinh(0.5)' + ], + 'seealso': [ + 'cosh', + 'tanh' + ] + }; + /***/ }, /* 357 */ +/***/ function(module, exports, __webpack_require__) { + + module.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' + ] + }; + + +/***/ }, +/* 358 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'tanh', + 'category': 'Trigonometry', + 'syntax': [ + 'tanh(x)' + ], + 'description': 'Compute the hyperbolic tangent of x in radians.', + 'examples': [ + 'tanh(0.5)', + 'sinh(0.5) / cosh(0.5)' + ], + 'seealso': [ + 'sinh', + 'cosh' + ] + }; + + +/***/ }, +/* 359 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'to', + 'category': 'Units', + 'syntax': [ + 'x to unit', + 'to(x, unit)' + ], + 'description': 'Change the unit of a value.', + 'examples': [ + '5 inch to cm', + '3.2kg to g', + '16 bytes in bits' + ], + 'seealso': [] + }; + + +/***/ }, +/* 360 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 361 */ +/***/ function(module, exports, __webpack_require__) { + + module.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 value * value })' + ], + 'seealso': ['filter', 'forEach'] + }; + + +/***/ }, +/* 362 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'filter', + 'category': 'Utils', + 'syntax': [ + 'filter(x, test)' + ], + 'description': 'Filter items in a matrix.', + 'examples': [ + 'isPositive(x) = x > 0', + 'filter([6, -2, -1, 4, 3], isPositive)', + 'filter([6, -2, 0, 1, 0], x != 0)' + ], + 'seealso': ['sort', 'map', 'forEach'] + }; + + +/***/ }, +/* 363 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'forEach', + 'category': 'Utils', + 'syntax': [ + 'forEach(x, callback)' + ], + 'description': 'Iterates over all elements of a matrix/array, and executes the given callback function.', + 'examples': [ + 'forEach([1, 2, 3], function(val) { console.log(val) })' + ], + 'seealso': ['map', 'sort', 'filter'] + }; + + +/***/ }, +/* 364 */ +/***/ function(module, exports, __webpack_require__) { + + module.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'] + }; + + +/***/ }, +/* 365 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'import', + 'category': 'Utils', + 'syntax': [ + 'import(string)' + ], + 'description': 'Import functions from a file.', + 'examples': [ + 'import("numbers")', + 'import("./mylib.js")' + ], + 'seealso': [] + }; + + +/***/ }, +/* 366 */ +/***/ function(module, exports, __webpack_require__) { + + module.exports = { + 'name': 'sort', + 'category': 'Utils', + 'syntax': [ + 'sort(x)', + 'sort(x, compare)' + ], + 'description': 'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.', + 'examples': [ + 'sort([5, 10, 1])', + 'sort(["C", "B", "A", "D"])', + 'sortByLength(a, b) = size(a)[1] - size(b)[1]', + 'sort(["Langdon", "Tom", "Sara"], sortByLength)' + ], + 'seealso': ['map', 'filter', 'forEach'] + }; + + +/***/ }, +/* 367 */ +/***/ function(module, exports, __webpack_require__) { + + module.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': [] + }; + + +/***/ }, +/* 368 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/** @@ -37619,6 +39684,805 @@ return /******/ (function(modules) { // webpackBootstrap })); +/***/ }, +/* 369 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.symbols = { + // GREEK LETTERS + Alpha: 'A', alpha: '\\alpha', + Beta: 'B', beta: '\\beta', + Gamma: '\\Gamma', gamma: '\\gamma', + Delta: '\\Delta', delta: '\\delta', + Epsilon: 'E', epsilon: '\\epsilon', varepsilon: '\\varepsilon', + Zeta: 'Z', zeta: '\\zeta', + Eta: 'H', eta: '\\eta', + Theta: '\\Theta', theta: '\\theta', vartheta: '\\vartheta', + Iota: 'I', iota: '\\iota', + Kappa: 'K', kappa: '\\kappa', varkappa: '\\varkappa', + Lambda: '\\Lambda', lambda: '\\lambda', + Mu: 'M', mu: '\\mu', + Nu: 'N', nu: '\\nu', + Xi: '\\Xi', xi: '\\xi', + Omicron: 'O', omicron: 'o', + Pi: '\\Pi', pi: '\\pi', varpi: '\\varpi', + Rho: 'P', rho: '\\rho', varrho: '\\varrho', + Sigma: '\\Sigma', sigma: '\\sigma', varsigma: '\\varsigma', + Tau: 'T', tau: '\\tau', + Upsilon: '\\Upsilon', upsilon: '\\upsilon', + Phi: '\\Phi', phi: '\\phi', varphi: '\\varphi', + Chi: 'X', chi: '\\chi', + Psi: '\\Psi', psi: '\\psi', + Omega: '\\Omega', omega: '\\omega', + //logic + 'true': '\\mathrm{True}', + 'false': '\\mathrm{False}', + //other + i: 'i', //TODO use \i ?? + inf: '\\infty', + Inf: '\\infty', + infinity: '\\infty', + Infinity: '\\infty', + oo: '\\infty', + lim: '\\lim', + 'undefined': '\\mathbf{?}' + }; + + exports.operators = { + 'transpose': '^\\top', + 'factorial': '!', + 'pow': '^', + 'dotPow': '.^\\wedge', //TODO find ideal solution + 'unaryPlus': '+', + 'unaryMinus': '-', + 'bitNot': '~', //TODO find ideal solution + 'not': '\\neg', + 'multiply': '\\cdot', + 'divide': '\\frac', //TODO how to handle that properly? + 'dotMultiply': '.\\cdot', //TODO find ideal solution + 'dotDivide': '.:', //TODO find ideal solution + 'mod': '\\mod', + 'add': '+', + 'subtract': '-', + 'to': '\\rightarrow', + 'leftShift': '<<', + 'rightArithShift': '>>', + 'rightLogShift': '>>>', + 'equal': '=', + 'unequal': '\\neq', + 'smaller': '<', + 'larger': '>', + 'smallerEq': '\\leq', + 'largerEq': '\\geq', + 'bitAnd': '\\&', + 'bitXor': '\\underline{|}', + 'bitOr': '|', + 'and': '\\wedge', + 'xor': '\\veebar', + 'or': '\\vee' + }; + + + //create a comma separated list of function arguments + function functionArgs(args, callbacks) { + return args.map( function (arg) { + return arg.toTex(callbacks); + }).join(','); + } + + var defaultTemplate = '\\mathrm{%name%}\\left(%*%\\right)'; + + /* + * expand a template + * + * @param {String} template + * @param {String} name of the function + * @param {Array} arguments of the function ( Strings ) + **/ + function expandTemplate(template, name, args) { + //replace %name% with the variable 'name' + template = template.replace(/%name%/g, name); + + //replace %0%, %1% .... with the arguments in args + args.forEach(function (arg, index) { + template = template.replace(RegExp('%' + index + '%', 'g'), arg); + }); + + //replace %*% with a comma separated list of all arguments + template = template.replace('%*%', args.map(function (arg) { + return arg; + }).join(',')); + + //replace %% with %, this comes in handy when you need a % in your LaTeX string + template = template.replace('%%', '%'); + + return template; + } + + //this is a map containing all the latex converters for all the functions + var functions = { + //arithmetic + 'abs': '\\left|%0%\\right|', + 'add': '\\left(%0%+%1%\\right)', + 'ceil': '\\left\\lceil%0%\\right\\rceil', + 'cube': '\\left(%0%\\right)^3', + 'divide': '\\frac{%0%}{%1%}', + 'dotDivide': '\\left(%0%' + exports.operators['dotDivide'] + '%1%\\right)', + 'dotMultiply': '\\left(%0%' + exports.operators['dotMultiply'] + '%1%\\right)', + 'dotPow': '\\left(%0%' + exports.operators['dotPow'] + '%1%\\right)', + 'exp': '\\exp\\left(%0%\\right)', + 'fix': defaultTemplate, + 'floor': '\\left\\lfloor%0%\\right\\rfloor', + 'gcd': '\\gcd\\left(%*%\\right)', + 'lcm': defaultTemplate, + 'log10': '\\log_{10}\\left(%0%\\right)', + 'log': { + 1: '\\ln\\left(%0%\\right)', + 2: '\\log_{%1%}\\left(%0%\\right)' + }, + 'mod': '\\left(%0%' + exports.operators['mod'] + '%1%\\right)', + 'multiply': '\\left(%0%' + exports.operators['multiply'] + '%1%\\right)', + 'norm': { + 1: '\\left\\|%0%\\right\\|', + 2: defaultTemplate + }, + 'nthRoot': '\\sqrt[%1%]{%0%}', + 'pow': '\\left(%0%\\right)' + exports.operators['pow'] + '{%1%}', + 'round': { + 1: '\\left\\lfloor%0%\\right\\rceil', + 2: defaultTemplate + }, + 'sign': defaultTemplate, + 'sqrt': '\\sqrt{%0%}', + 'square': '\\left(%0%\\right)^2', + 'subtract': '\\left(%0%' + exports.operators['subtract'] + '%1%\\right)', + 'unaryMinus': exports.operators['unaryMinus'] + '\\left(%0%\\right)', + 'unaryPlus': exports.operators['unaryPlus'] + '\\left(%0%\\right)', + 'xgcd': defaultTemplate, + + //bitwise + 'bitAnd': '\\left(%0%' + exports.operators['bitAnd'] + '%1%\\right)', + 'bitOr': '\\left(%0%' + exports.operators['bitOr'] + '%1%\\right)', + 'bitXor': '\\left(%0%' + exports.operators['bitXor'] + '%1%\\right)', + 'bitNot': exports.operators['bitNot'] + '\\left(%0%\\right)', + 'leftShift': '\\left(%0%' + exports.operators['leftShift'] + '%1%\\right)', + 'rightArithShift': '\\left(%0%' + exports.operators['rightArithShift'] + '%1%\\right)', + 'rightLogShift': '\\left(%0%' + exports.operators['rightLogShift'] + '%1%\\right)', + + //complex + 'arg': '\\arg\\left(%0%\\right)', + 'conj': '\\left(%0%\\right)^*', + 'im': '\\Im\\left\\lbrace%0%\\right\\rbrace', + 're': '\\Re\\left\\lbrace%0%\\right\\rbrace', + + //construction + 'bignumber': { + 0: '0', + 1: '\\left(%0%\\right)' + }, + 'boolean': defaultTemplate, + 'chain': defaultTemplate, + 'complex': { + 0: '0', + 1: '\\left(%0%\\right)', + 2: '\\left(\\left(%0%\\right)+' + + exports.symbols['i'] + '\\cdot\\left(%1%\\right)\\right)', + }, + 'index': defaultTemplate, + 'matrix': { + 0: '\\begin{bmatrix}\\end{bmatrix}', + 1: '\\left(%0%\\right)', + 2: '\\left(%0%\\right)' + }, + 'number': { + 0: '0', + 1: '\\left(%0%\\right)', + 2: '\\left(\\left(%0%\\right)%1%\\right)' + }, + 'parser': defaultTemplate, + 'sparse': { + 0: '\\begin{bsparse}\\end{bsparse}', + 1: '\\left(%0%\\right)' + }, + 'string': { + 0: '\\mathtt{""}', + 1: '\\mathrm{string}\\left(%0%\\right)' + }, + 'unit': { + 1: '\\left(%0%\\right)', + 2: '\\left(\\left(%0%\\right)%1%\\right)' + }, + + //expression TODO does the default even work in this case? (.toTex on the args) + 'compile': defaultTemplate, + 'eval': defaultTemplate, + 'help': defaultTemplate, + 'parse': defaultTemplate, + + //logical + 'and': '\\left(%0%' + exports.operators['and'] + '%1%\\right)', + 'not': exports.operators['not'] + '\\left(%0%\\right)', + 'or': '\\left(%0%' + exports.operators['or'] + '%1%\\right)', + 'xor': '\\left(%0%' + exports.operators['xor'] + '%1%\\right)', + + //matrix + 'concat': defaultTemplate, + 'cross': '\\left(%0%\\right)\\times\\left(%1%\\right)', + 'det': '\\det\\left(%0%\\right)', + 'diag': defaultTemplate, + 'dot': '\\left(%0%\\cdot%1%\\right)', + 'eye': defaultTemplate, + 'flatten': defaultTemplate, + 'inv': '\\left(%0%\\right)^{-1}', + 'ones': defaultTemplate, + 'range': defaultTemplate, + 'resize': defaultTemplate, + 'size': defaultTemplate, + 'squeeze': defaultTemplate, + 'subset': defaultTemplate, + 'trace': '\\mathrm{tr}\\left(%0%\\right)', + 'transpose': '\\left(%0%\\right)' + exports.operators['transpose'], + 'zeros': defaultTemplate, + + //probability + 'combinations': '\\binom{%0%}{%1%}', + 'distribution': defaultTemplate, + 'factorial': '\\left(%0%\\right)' + exports.operators['factorial'], + 'gamma': '\\Gamma\\left(%0%\\right)', + 'permutations': defaultTemplate, + 'pickRandom': defaultTemplate, + 'randomInt': defaultTemplate, + 'random': defaultTemplate, + + //relational + 'compare': defaultTemplate, + 'deepEqual': defaultTemplate, + 'equal': '\\left(%0%' + exports.operators['equal'] + '%1%\\right)', + 'largerEq': '\\left(%0%' + exports.operators['largerEq'] + '%1%\\right)', + 'larger': '\\left(%0%' + exports.operators['larger'] + '%1%\\right)', + 'smallerEq': '\\left(%0%' + exports.operators['smallerEq'] + '%1%\\right)', + 'smaller': '\\left(%0%' + exports.operators['smaller'] + '%1%\\right)', + 'unequal': '\\left(%0%' + exports.operators['unequal'] + '%1%\\right)', + + //statistics + 'max': '\\max\\left(%*%\\right)', + 'mean': defaultTemplate, + 'median': defaultTemplate, + 'min': '\\min\\left(%*%\\right)', + 'prod': defaultTemplate, + 'std': defaultTemplate, + 'sum': defaultTemplate, + 'var': '\\mathrm{Var}\\left(%*%\\right)', + + //trigonometry + 'acosh': '\\cosh^{-1}\\left(%0%\\right)', + 'acos': '\\cos^{-1}\\left(%0%\\right)', + 'acoth': '\\coth^{-1}\\left(%0%\\right)', + 'acot': '\\cot^{-1}\\left(%0%\\right)', + 'acsch': '\\mathrm{csch}^{-1}\\left(%0%\\right)', + 'acsc': '\\csc^{-1}\\left(%0%\\right)', + 'asech': '\\mathrm{sech}^{-1}\\left(%0%\\right)', + 'asec': '\\sec^{-1}\\left(%0%\\right)', + 'asinh': '\\sinh^{-1}\\left(%0%\\right)', + 'asin': '\\sin^{-1}\\left(%0%\\right)', + 'atan2': '\\mathrm{atan2}\\left(%*%\\right)', + 'atanh': '\\tanh^{-1}\\left(%0%\\right)', + 'atan': '\\tan^{-1}\\left(%0%\\right)', + 'cosh': '\\cosh\\left(%0%\\right)', + 'cos': '\\cos\\left(%0%\\right)', + 'coth': '\\coth\\left(%0%\\right)', + 'cot': '\\cot\\left(%0%\\right)', + 'csch': '\\mathrm{csch}\\left(%0%\\right)', + 'csc': '\\csc\\left(%0%\\right)', + 'sech': '\\mathrm{sech}\\left(%0%\\right)', + 'sec': '\\sec\\left(%0%\\right)', + 'sinh': '\\sinh\\left(%0%\\right)', + 'sin': '\\sin\\left(%0%\\right)', + 'tanh': '\\tanh\\left(%0%\\right)', + 'tan': '\\tan\\left(%0%\\right)', + + //units + 'to': '\\left(%0%' + exports.operators['to'] + '%1%\\right)', + + //utils + 'clone': defaultTemplate, + 'filter': defaultTemplate, + 'forEach': defaultTemplate, + 'format': defaultTemplate, + 'import': defaultTemplate, + 'map': defaultTemplate, + 'print': defaultTemplate, + 'sort': defaultTemplate, + 'typeof': defaultTemplate + }; + + var units = { + deg: '^\\circ' + }; + + //@param {string} name + //@param {boolean} isUnit + exports.toSymbol = function (name, isUnit) { + isUnit = typeof isUnit === 'undefined' ? false : isUnit; + if (isUnit) { + if (units.hasOwnProperty(name)) { + return units[name]; + } + return '\\mathrm{' + name + '}'; + } + + if (exports.symbols.hasOwnProperty(name)) { + return exports.symbols[name]; + } + else if (name.indexOf('_') !== -1) { + //symbol with index (eg. alpha_1) + var index = name.indexOf('_'); + return exports.toSymbol(name.substring(0, index)) + '_{' + + exports.toSymbol(name.substring(index + 1)) + '}'; + } + return name; + }; + + //returns the latex output for a given function + exports.toFunction = function (node, callbacks, name) { + var latexConverter = functions[name]; + var args = node.args.map(function (arg) { //get LaTeX of the arguments + return arg.toTex(callbacks); + }); + + switch (typeof latexConverter) { + case 'function': //a callback function + return latexConverter(node, callbacks); + case 'string': //a template string + return expandTemplate(latexConverter, name, args); + case 'object': //an object with different "converters" for different numbers of arguments + switch (typeof latexConverter[args.length]) { + case 'function': + return latexConverter[args.length](node, callbacks); + case 'string': + return expandTemplate(latexConverter[args.length], name, args); + } + //no break here! That's intentionally + default: + return expandTemplate(defaultTemplate, name, args); + } + } + + +/***/ }, +/* 370 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + // Reserved keywords not allowed to use in the parser + module.exports = { + end: true + }; + + +/***/ }, +/* 371 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict' + + //list of identifiers of nodes in order of their precedence + //also contains information about left/right associativity + //and which other operator the operator is associative with + //Example: + // addition is associative with addition and subtraction, because: + // (a+b)+c=a+(b+c) + // (a+b)-c=a+(b-c) + // + // postfix operators are left associative, prefix operators + // are right associative + // + //It's also possible to set the following properties: + // latexParens: if set to false, this node doesn't need to be enclosed + // in parentheses when using LaTeX + // latexLeftParens: if set to false, this !OperatorNode's! + // left argument doesn't need to be enclosed + // in parentheses + // latexRightParens: the same for the right argument + var properties = [ + { //assignment + 'AssignmentNode': {}, + 'FunctionAssignmentNode': {} + }, + { //conditional expression + 'ConditionalNode': { + latexLeftParens: false, + latexRightParens: false, + latexParens: false + //conditionals don't need parentheses in LaTeX because + //they are 2 dimensional + } + }, + { //logical or + 'OperatorNode:or': { + associativity: 'left', + associativeWith: [] + } + + }, + { //logical xor + 'OperatorNode:xor': { + associativity: 'left', + associativeWith: [] + } + }, + { //logical and + 'OperatorNode:and': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise or + 'OperatorNode:bitOr': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise xor + 'OperatorNode:bitXor': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitwise and + 'OperatorNode:bitAnd': { + associativity: 'left', + associativeWith: [] + } + }, + { //relational operators + 'OperatorNode:equal': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:unequal': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:smaller': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:larger': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:smallerEq': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:largerEq': { + associativity: 'left', + associativeWith: [] + } + }, + { //bitshift operators + 'OperatorNode:leftShift': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:rightArithShift': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:rightLogShift': { + associativity: 'left', + associativeWith: [] + } + }, + { //unit conversion + 'OperatorNode:to': { + associativity: 'left', + associativeWith: [] + } + }, + { //range + 'RangeNode': {} + }, + { //addition, subtraction + 'OperatorNode:add': { + associativity: 'left', + associativeWith: ['OperatorNode:add', 'OperatorNode:subtract'] + }, + 'OperatorNode:subtract': { + associativity: 'left', + associativeWith: [] + } + }, + { //multiply, divide, modulus + 'OperatorNode:multiply': { + associativity: 'left', + associativeWith: [ + 'OperatorNode:multiply', + 'OperatorNode:divide', + 'Operator:dotMultiply', + 'Operator:dotDivide' + ] + }, + 'OperatorNode:divide': { + associativity: 'left', + associativeWith: [], + latexLeftParens: false, + latexRightParens: false, + latexParens: false + //fractions don't require parentheses because + //they're 2 dimensional, so parens aren't needed + //in LaTeX + }, + 'OperatorNode:dotMultiply': { + associativity: 'left', + associativeWith: [ + 'OperatorNode:multiply', + 'OperatorNode:divide', + 'OperatorNode:dotMultiply', + 'OperatorNode:doDivide' + ] + }, + 'OperatorNode:dotDivide': { + associativity: 'left', + associativeWith: [] + }, + 'OperatorNode:mod': { + associativity: 'left', + associativeWith: [] + } + }, + { //unary prefix operators + 'OperatorNode:unaryPlus': { + associativity: 'right' + }, + 'OperatorNode:unaryMinus': { + associativity: 'right' + }, + 'OperatorNode:bitNot': { + associativity: 'right' + }, + 'OperatorNode:not': { + associativity: 'right' + } + }, + { //exponentiation + 'OperatorNode:pow': { + associativity: 'right', + associativeWith: [], + latexRightParens: false, + //the exponent doesn't need parentheses in + //LaTeX because it's 2 dimensional + //(it's on top) + }, + 'OperatorNode:dotPow': { + associativity: 'right', + associativeWith: [] + } + }, + { //factorial + 'OperatorNode:factorial': { + associativity: 'left' + } + }, + { //matrix transpose + 'OperatorNode:transpose': { + associativity: 'left' + } + } + ]; + + /** + * Get the precedence of a Node. + * Higher number for higher precedence, starting with 0. + * Returns null if the precedence is undefined. + * + * @param {Node} + * @return {Number|null} + */ + function getPrecedence (node) { + var identifier = node.getIdentifier(); + for (var i = 0; i < properties.length; i++) { + if (identifier in properties[i]) { + return i; + } + } + return null; + } + + /** + * Get the associativity of an operator (left or right). + * Returns a string containing 'left' or 'right' or null if + * the associativity is not defined. + * + * @param {Node} + * @return {String|null} + * @throws {Error} + */ + function getAssociativity (node) { + var identifier = node.getIdentifier(); + var index = getPrecedence(node); + if (index === null) { + //node isn't in the list + return null; + } + var property = properties[index][identifier]; + + if (property.hasOwnProperty('associativity')) { + if (property.associativity === 'left') { + return 'left'; + } + if (property.associativity === 'right') { + return 'right'; + } + //associativity is invalid + throw Error('\'' + identifier + '\' has the invalid associativity \'' + + property.associativity + '\'.'); + } + + //associativity is undefined + return null; + } + + /** + * Check if an operator is associative with another operator. + * Returns either true or false or null if not defined. + * + * @param {Node} nodeA + * @param {Node} nodeB + * @return {bool|null} + */ + function isAssociativeWith (nodeA, nodeB) { + var identifierA = nodeA.getIdentifier(); + var identifierB = nodeB.getIdentifier(); + var index = getPrecedence(nodeA); + if (index === null) { + //node isn't in the list + return null; + } + var property = properties[index][identifierA]; + + if (property.hasOwnProperty('associativeWith') + && (property.associativeWith instanceof Array)) { + for (var i = 0; i < property.associativeWith.length; i++) { + if (property.associativeWith[i] === identifierB) { + return true; + } + } + return false; + } + + //associativeWith is not defined + return null; + } + + module.exports.properties = properties; + module.exports.getPrecedence = getPrecedence; + module.exports.getAssociativity = getAssociativity; + module.exports.isAssociativeWith = isAssociativeWith; + + +/***/ }, +/* 372 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var util = __webpack_require__(36); + + var string = util.string; + var array = util.array; + var object = util.object; + + var isArray = Array.isArray; + + function factory (type, config, load, typed) { + + var Matrix = type.Matrix; + + /** + * Validates matrix and column vector b for backward/forward substitution algorithms. + * + * @param {Matrix} m An N x N matrix + * @param {Array | Matrix} b A column vector + * + * @return {Array} Dense copy of column vector b + */ + var substitutionValidation = function (m, b) { + // matrix size + var size = m.size(); + // validate matrix dimensions + if (size.length !== 2) + throw new RangeError('Matrix must be two dimensional (size: ' + string.format(size) + ')'); + // rows & columns + var rows = size[0]; + var columns = size[1]; + // validate rows & columns + if (rows !== columns) + throw new RangeError('Matrix must be square (size: ' + string.format(size) + ')'); + // check b is matrix + if (b instanceof Matrix) { + // matrix size + var msize = b.size(); + // check matrix dimensions, vector + if (msize.length === 1) { + // check vector length + if (msize[0] !== rows) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + else if (msize.length === 2) { + // array must be a column vector + if (msize[0] !== rows || msize[1] !== 1) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + else { + // throw error + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + // dense copy of column vector + var x = new Array(rows); + // copy values (skip zeros) + b.forEach(function (v, index) { + x[index[0]] = object.clone(v); + }, true); + // return vector + return x; + } + // check b is array + if (isArray(b)) { + // size + var asize = array.size(b); + // check matrix dimensions, vector + if (asize.length === 1) { + // check vector length + if (asize[0] !== rows) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // return copy of b + return object.clone(b); + } + if (asize.length === 2) { + // array must be a column vector + if (asize[0] !== rows || asize[1] !== 1) + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + // loop rows in array, return copy of column vector + return b.map(function (v) { + return object.clone(v[0]); + }); + } + // throw error + throw new RangeError('Dimension mismatch. Matrix columns must match vector length.'); + } + }; + + return substitutionValidation; + } + + exports.name = 'substitutionValidation'; + exports.factory = factory; + +/***/ }, +/* 373 */ +/***/ function(module, exports, __webpack_require__) { + + var IndexError = __webpack_require__(38); + + /** + * Transform zero-based indices to one-based indices in errors + * @param {Error} err + * @returns {Error} Returns the transformed error + */ + exports.transform = function (err) { + if (err instanceof IndexError) { + return new IndexError(err.index + 1, err.min + 1, err.max + 1); + } + + return err; + }; + + /***/ } /******/ ]) }); diff --git a/dist/math.map b/dist/math.map index b0b5ccf08..e9904106a 100644 --- a/dist/math.map +++ b/dist/math.map @@ -1 +1 @@ -{"version":3,"file":"math.map","sources":["math.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","create","config","math","loader","_config","expression","node","docs","type","Complex","Range","Index","Unit","Help","ResultSet","transform","concat","filter","forEach","index","map","max","mean","min","range","subset","Chain","createProxy","isFactory","load","Error","instance","factories","indexOf","typed","push","instances","Object","matrix","number","precision","epsilon","error","_reduce","mat","dim","callback","i","ret","val","tran","Array","isArray","_switch","length","j","I","J","tmp","collection","argsToArray","args","array","Matrix","valueOf","util","isCollection","x","deepMap","skipZeros","deepMap2","array1","array2","res","len","DimensionError","reduce","size","arraySize","IndexError","deepForEach","ii","value","name","re","im","SyntaxError","arguments","arg","construct","fromPolar","r","phi","isNumber","TypeError","skipWhitespace","next","isDigitDot","isDigit","text","charAt","revert","oldIndex","parseNumber","parseComplex","cnext","isUnit","isString","string","isComplex","parse","str","first","Number","separator","second","substring","hasBase","BASE_UNITS","ANGLE","toNumber","Math","cos","sin","prototype","toPolar","sqrt","atan2","clone","equals","other","format","options","strRe","strIm","pow","abs","toString","toJSON","mathjs","fromJSON","json","start","end","step","parseFloat","split","nums","invalid","some","num","isNaN","isRange","object","diff","sign","ceil","undefined","obj","toArray","ranges","_ranges","_isScalar","_createRange","primitive","isInteger","isIndex","apply","values","isScalar","row","strings","join","isMatrix","storage","constructor","_storage","datatype","replacement","defaultValue","get","set","resize","path","_findUnit","unit","prefix","UNIT_NONE","PREFIX_NONE","_normalize","fixPrefix","parseUnit","unitName","UNITS","hasOwnProperty","endsWith","prefixLen","prefixName","prefixes","err","offset","_denormalize","prefixValue","isValuelessUnit","base","equalBase","to","valuelessUnit","bestPrefix","_bestPrefix","absValue","bestDiff","log","LN10","scientific","PREFIXES","NONE","SHORT","da","h","k","M","G","T","P","E","Z","Y","d","u","n","f","a","z","y","LONG","deca","hecto","kilo","mega","giga","tera","peta","exa","zetta","yotta","deci","centi","milli","micro","nano","pico","femto","atto","zepto","yocto","SQUARED","CUBIC","BINARY_SHORT","Ki","Mi","Gi","Ti","Pi","Ei","Zi","Yi","BINARY_LONG","kibi","mebi","gibi","tebi","pebi","exi","zebi","yobi","LENGTH","MASS","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","FORCE","SURFACE","VOLUME","BIT","BASE_UNIT_NONE","meter","inch","foot","yard","mile","link","rod","chain","angstrom","in","ft","yd","mi","li","rd","ch","mil","m2","sqin","sqft","sqyd","sqmi","sqrd","sqch","sqmil","m3","L","l","litre","cuin","cuft","cuyd","teaspoon","tablespoon","drop","gtt","minim","fluiddram","fluidounce","gill","cc","cup","pint","quart","gallon","beerbarrel","oilbarrel","hogshead","fldr","floz","gi","cp","pt","qt","gal","bbl","obl","g","gram","ton","tonne","grain","dram","ounce","poundmass","hundredweight","stick","stone","gr","dr","oz","lbm","cwt","s","sec","minute","hour","day","rad","deg","grad","cycle","A","ampere","K","degC","degF","degR","kelvin","celsius","fahrenheit","rankine","mol","mole","cd","candela","N","newton","lbf","poundforce","b","bits","B","bytes","PLURALS","meters","inches","feet","yards","miles","links","rods","chains","angstroms","litres","teaspoons","tablespoons","minims","fluiddrams","fluidounces","gills","cups","pints","quarts","gallons","beerbarrels","oilbarrels","hogsheads","gtts","grams","tons","tonnes","grains","drams","ounces","poundmasses","hundredweights","sticks","seconds","minutes","hours","days","radians","degrees","gradients","cycles","amperes","moles","plural","lt","liter","liters","lb","lbs","doc","isHelp","toText","desc","category","description","syntax","examples","parser","expr","eval","e","seealso","prop","entries","BigNumber","Decimal","convert","digits","FibonacciHeap","_minimum","_size","smaller","larger","oneOverLogPhi","insert","key","degree","minimum","left","right","clear","isEmpty","extractMinimum","numberOfChildren","child","tempRight","parent","_findMinimumNode","remove","_decreaseKey","_cut","_cascadingCut","mark","_linkNodes","floor","numRoots","temp","slice","done","arg0","arg1","ArgumentsError","extra_nodes","nodes","parseStart","elem","nesting_level","conditional_level","nextPreview","nextNextPreview","getToken","token_type","TOKENTYPE","NULL","token","DELIMITER","c2","c3","DELIMITERS","isAlpha","NAMED_DELIMITERS","SYMBOL","UNKNOWN","createSyntaxError","NUMBER","getTokenSkipNewline","openParams","closeParams","parseBlock","createError","visible","blocks","ConstantNode","parseFunctionAssignment","BlockNode","parseAssignment","valid","parseConditional","SymbolNode","AssignmentNode","IndexNode","UpdateNode","FunctionNode","FunctionAssignmentNode","parseLogicalOr","prev","condition","trueExpr","falseExpr","ConditionalNode","parseLogicalXor","OperatorNode","parseLogicalAnd","parseBitwiseOr","parseBitwiseXor","parseBitwiseAnd","parseRelational","operators","fn","params","parseShift","==","!=","<",">","<=",">=","parseConversion","<<",">>",">>>","parseRange","parseAddSubtract","RangeNode","parseMultiplyDivide","+","-","parseUnary","*",".*","/","./","%","mod","~","not","parsePow","parseLeftHandOperators","parseCustomNodes","!","'","handler","parseSymbol","parseFunctions","parseIndex","parseString","tPrev","parseMatrix","rows","cols","parseRow","ArrayNode","parseParentheses","parseEnd","col","message",",","(",")","[","]","\"",";","^",".^","&","|","^|","=",":","?","and","xor","or","Parser","scope","_parse","compile","Node","LN2","LOG2E","LOG10E","NaN","pi","PI","SQRT1_2","SQRT2","tau","version","add","cube","divide","dotDivide","dotMultiply","dotPow","exp","fix","gcd","lcm","log10","multiply","norm","nthRoot","round","square","subtract","unaryMinus","unaryPlus","xgcd","bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift","conj","bignumber","complex","sparse","help","cross","det","diag","dot","eye","flatten","inv","ones","squeeze","trace","transpose","zeros","combinations","factorial","gamma","permutations","pickRandom","random","randomInt","compare","deepEqual","largerEq","smallerEq","unequal","median","prod","std","sum","acos","acosh","acot","acoth","acsc","acsch","asec","asech","asin","asinh","atan","atanh","cosh","cot","coth","csc","csch","sech","sinh","tan","tanh","sort","SparseMatrix","data","_createFromMatrix","ptr","_values","_index","_ptr","_datatype","_createFromArray","types","equal","source","columns","v","_getsubset","_setsubset","validateIndex","_map","submatrix","sSize","iSize","outer","unsqueeze","x0","y0","_getValueIndex","_resize","_remove","_insert","top","bottom","splice","copy","ins","k0","k1","me","invoke","minRow","maxRow","minColumn","maxColumn","_toArray","density","diagonal","kSuper","kSub","_value","ms","swapRows","_swapRows","_forEachRow","kx","ky","vx","vy","DenseMatrix","_data","preprocess","_get","_getSubmatrix","dims","last","_set","_fit","_setSubmatrix","dataIndex","subIndex","newSize","changed","index_i","recurse","vi","dense","Spa","_heap","accumulate","from","heap","swap","nodei","nodej","errorTransform","lastIndex","minus","isBoolean","_filter","test","_scope","symbol","sub","eq","rawArgs","_forEachArray","arrayOrig","UnsupportedTypeError","_mapArray","arrayIn","Array | Matrix","sparseScatter","addScalar","multiplyScalar","any, any","Matrix, Matrix","xsize","ysize","_addSparseMatrixSparseMatrix","_addSparseMatrixMatrix","_addMatrixSparseMatrix","_addMatrixMatrix","Array, Array","Array, Matrix","Matrix, Array","Matrix, any","_addSparseMatrixScalar","any, Matrix","Array, any","any, Array","asize","avalues","aindex","aptr","cvalues","cindex","cptr","bsize","RangeError","adt","bvalues","bdt","dt","mf","signatures","af","w","p0","p1","bindex","bptr","cdata","complexMultiply","times","divideScalar","Array | Matrix, Array | Matrix","Array | Matrix, any","any, Array | Matrix","isNegative","_gcdBigNumber","isInt","zero","isZero","neg","number, number","_gcd","BigNumber, BigNumber","Array | Matrix, Array | Matrix | number | BigNumber","number | BigNumber, Array | Matrix","Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber","_lcmBigNumber","t","div","_lcm","_logNumber","ln","_log10Complex","_mod","_validateMatrixDimensions","_multiplyVectorVector","_multiplyVectorMatrix","_multiplyMatrixVector","_multiplyMatrixMatrix","size1","size2","adata","bdata","_multiplyVectorDenseMatrix","alength","bcolumns","_multiplyDenseMatrixVector","_multiplySparseMatrixVector","_multiplyDenseMatrixDenseMatrix","_multiplyDenseMatrixSparseMatrix","_multiplySparseMatrixDenseMatrix","_multiplySparseMatrixSparseMatrix","arows","acolumns","jb","kb0","kb1","cij","kb","ib","brows","vbi","ka0","ka1","ka","ia","ic","vbij","_norm","sizeX","POSITIVE_INFINITY","pinf","NEGATIVE_INFINITY","ninf","maxc","cj","maxr","ri","complexAbs","boolean | null","number | Complex | BigNumber | boolean | null, number | BigNumber | string","Array, number | BigNumber | string","Matrix, number | BigNumber | string","_bigNthRoot","one","negated","isFinite","iMax","xPrev","delta","plus","_nthRoot","_powComplex","_powArray","px","_powMatrix","Complex, Complex","Array, number","Array, BigNumber","Matrix, number","Matrix, BigNumber","_round","Complex, number","Complex, BigNumber","_n","toDecimalPlaces","Array | Matrix, number | BigNumber","number | Complex | BigNumber, Array | Matrix","decimals","toFixed","cmp","_sqrtNumber","_sqrtComplex","Unit, Unit","_subtractSparseMatrixSparseMatrix","_subtractSparseMatrixMatrix","_subtractMatrixSparseMatrix","_subtractMatrixMatrix","_subtractSparseMatrixScalar","_subtractScalarSparseMatrix","boolean | string | null","_xgcd","q","lastx","lasty","_xgcdBigNumber","bigBitAnd","bigBitNot","bigBitOr","bigBitXor","bigLeftShift","bigRightArithShift","bool","boolean","lcase","toLowerCase","any","...number | BigNumber | Range | Array","_create","string, string","Array | Matrix, string","Array | Matrix, string, string","Unit, string | Unit","null","String","number, string","BigNumber, string","entry","string, Object","Array | Matrix, Object","search","string | Array | Matrix","string | Array | Matrix, Object","...Array | Matrix | number | BigNumber","prevDim","asMatrix","matrices","shift","_concat","concatDim","_cross","xSize","ySize","_det","compute_mu","mu","fa","_diag","_createDiagonalMatrix","_getDiagonal","F","dm","vector","Array, string","Array, number, string","Array, BigNumber, string","Matrix, string","Matrix, number, string","Matrix, BigNumber, string","_dot","_eyeVector","_eye","Big","number | BigNumber","number | BigNumber, string","number | BigNumber, number | BigNumber","number | BigNumber, number | BigNumber, string","_flatten","flat","_inv","Ac","Bc","Ar","Br","asBigNumber","_range","_rangeInc","_bigRange","gt","_bigRangeInc","lte","gte","includeEnd","pop","_resizeString","defaultChar","number | Complex | BigNumber | Unit | boolean | null","_getSubset","_getSubstring","strLen","substr","_setSubset","_setSubstring","chars","_denseTrace","_sparseTrace","_denseTranspose","_sparseTranspose","transposedRow","transposed","result","isPositiveInteger","dividedBy","bigFactorial","preciseFacs","smallBigFacs","toSD","bigBigFacs","toPrecision","Infinity","twoN","threeN","fourN","fiveN","real","den","twoPiSqrt","distribution","boolean, boolean","nearlyEqual","_deepEqual","_equal","_unequal","_largest","_max","...","_nmean","_mean","_median","middle2","middle","_smallest","_min","_prod","_std","normalization","variance","_sum","_var","DEFAULT_NORMALIZATION","_complexAcos","temp1","temp2","complexSqrt","temp3","temp4","complexLog","bigArcCos","arccos_arcsec","_complexAcosh","complexAcos","bigAcosh","acosh_asinh_asech_acsch","complexAtan","HALF_PI","bigArcCot","arctan_arccot","_complexAcoth","bigAcoth","atanh_acoth","_complexAcsc","complexAsin","bigArcCsc","arcsin_arccsc","bigAcsch","_complexAsec","bigArcSec","_complexAsech","bigAsech","_complexAsin","bigArcSin","bigAsinh","bigArcTan","bigAtan2","arctan2","_complexAtanh","noIM","oneMinus","onePlus","bigAtanh","bigCos","cos_sin_sec_csc","_cosh","ep","en","bigCosh","cosh_sinh_csch_sech","bigCot","tan_cot","_coth","bigCoth","tanh_coth","bigCsc","_csch","bigCsch","bigSec","_sech","bigSech","bigSin","_sinh","cim","sim","bigSinh","bigTan","_tanh","bigTanh","Unit, Unit | string","deepExtend","Array, function","_filterCallback","Array, RegExp","_filterRegExp","Matrix, function","Matrix, RegExp","regexp","any, Object | function | number","_print","string, Object, number","template","replace","original","keys","_comparator","order","asc","_arrayIsVector","_matrixIsVector","_forEach","lup","_denseLUP","_sparseLUP","U","ldata","lsize","udata","usize","pabsv","vjj","absv","vij","lvalues","lindex","lptr","uvalues","uindex","uptr","pvalues","pindex","pptr","psize","pv_co","pv_oc","swapIndeces","spa","vkj","vik","backwardSubstitution","forwardSubstitution","lusolve","Array, Array | Matrix","_lusolve","Matrix, Array | Matrix","Object, Array | Matrix","_toMatrix","Boolean","Date","RegExp","extend","canDefineProperty","defineProperty","lazy","_uninitialized","configurable","traverse","names","conversions","math_import","opts","override","wrap","_module","_importFactory","imported","isSupportedType","_import","namespace","UNINITIALIZED","_validate","dimNext","oldLen","newLen","minLen","_squeeze","_unsqueeze","validate","_defaultValue","unshift","stack","actual","expected","relation","NumberFormatter","notation","toExponential","exponential","DBL_EPSILON","EPSILON","formatArray","count","every","isNode","_compile","defs","_ifNode","_toTex","callbacks","latexType","childNode","toTex","keywords","latex","precedence","getPrecedence","exprPrecedence","toSymbol","block","param","js","testCondition","conditionPrecedence","truePrecedence","falsePrecedence","valueType","SUPPORTED_TYPES","match","variable","compileSubset","someUseEnd","rangesUseEnd","useEnd","objectName","op","calculateNecessaryParentheses","associativity","getAssociativity","operandPrecedence","operandIdentifier","getIdentifier","rootIdentifier","properties","latexLeftParens","latexParens","lhsParens","lhsPrecedence","assocWithLhs","isAssociativeWith","rhsParens","rhsPrecedence","assocWithRhs","lhsIdentifier","rhsIdentifier","latexRightParens","parens","assoc","operand","lhs","rhs","lhsTex","rhsTex","isRaw","paramsName","toFunction","startPrecedence","stepPrecedence","endPrecedence","undef","_validateScope","_transform","transformed","code","defsCode","factoryCode","Function","_traverse","find","customTex","number, Unit","Unit, number","_divideComplex","bitwise","func","xBits","yBits","xSign","ySign","decCoefficientToBinaryString","minBits","maxBits","minSign","shortLen","longLen","expFuncVal","outVal","twoPower","ONE","two","prevPrec","xe","strL","arr","arrL","reverse","arcsin_newton","oldPrecision","tolerance","maxp","localPrecision","maxIter","curr","tmp0","tmp1","sinToCos","tmp2","toDP","arcsin_taylor","yPrev","x2","polyNum","constNum","constDen","bigK","arctan_taylor","cos_sin_taylor","mode","reduceToPeriod","dp","sinVal","memoize","isBigNumber","toBigNumber","pi4th","negOne","reciprocal","absX","halfPi","wasReduced","x2PlusOrMinus","isNeg","precPlusGuardDigits","five","sixteen","twenty","ret2","ret3","ret5","div_factor","loops","eight","ret4","posExp","negExp","lower","upper","toExpNeg","toExpPos","toSignificantDigits","distributions","randFunctions","arg2","arg3","_randomDataForMatrix","_random","_randomInt","possibles","randFunc","uniform","normal","u1","u2","picked","substitutionValidation","_denseBackwardSubstitution","_sparseBackwardSubstitution","xj","bj","xvalues","xindex","xptr","_denseForwardSubstitution","_sparseForwardSubstitution","webpackContext","req","webpackContextResolve","./clone","./clone.js","./config","./config.js","./filter","./filter.js","./forEach","./forEach.js","./format","./format.js","./import","./import.js","./map","./map.js","./print","./print.js","./sort","./sort.js","./typeof","./typeof.js","resolve","cache","hash","JSON","stringify","__WEBPACK_AMD_DEFINE_RESULT__","global","coefficientToString","LOGBASE","charCodeAt","checkRoundingDigits","rm","repeating","ci","mathpow","checkRM","method","outOfRange","parseInt","ifExceptionsThrow","checkArg","MAX_DIGITS","pr","denom","guard","sd","rep","external","rnd","getCoeffLength","more","intPow","c0","x1","xc","xci","out","mathfloor","BASE","convertBase","decimal","crypto","NUMERALS","EXP_LIMIT","INT_POW_LIMIT","yc","base10","inf","sd10","xLTy","half","pos","groupSeparator","g1","g2","intPart","fractionPart","intDigits","maxD","d0","d2","frac","n0","n1","d1","yN","toBaseOut","baseIn","baseOut","multiplyInteger","carry","aL","bL","logbase","prodL","qc","rem","remL","rem0","xi","xL","yc0","yL","yz","maxOrMin","ltgt","rand","Uint32Array","decimalFactory","parseDecimal","decimalSeparator","groupSize","secondaryGroupSize","fractionGroupSeparator","fractionGroupSize","isValid","trim","isNum","orig","coefficients","exponent","rounded","roundDigits","pp","removed","identifier","property","nodeA","nodeB","identifierA","identifierB","associativeWith","OperatorNode:or","OperatorNode:xor","OperatorNode:and","OperatorNode:bitOr","OperatorNode:bitXor","OperatorNode:bitAnd","OperatorNode:equal","OperatorNode:unequal","OperatorNode:smaller","OperatorNode:larger","OperatorNode:smallerEq","OperatorNode:largerEq","OperatorNode:leftShift","OperatorNode:rightArithShift","OperatorNode:rightLogShift","OperatorNode:to","OperatorNode:add","OperatorNode:subtract","OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:dotDivide","OperatorNode:mod","OperatorNode:unaryPlus","OperatorNode:unaryMinus","OperatorNode:bitNot","OperatorNode:not","OperatorNode:pow","OperatorNode:dotPow","OperatorNode:factorial","OperatorNode:transpose","expandTemplate","symbols","Alpha","alpha","Beta","beta","Gamma","Delta","Epsilon","varepsilon","Zeta","zeta","Eta","eta","Theta","theta","vartheta","Iota","iota","Kappa","kappa","varkappa","Lambda","lambda","Mu","Nu","nu","Xi","Omicron","omicron","varpi","Rho","rho","varrho","Sigma","sigma","varsigma","Tau","Upsilon","upsilon","Phi","varphi","Chi","chi","Psi","psi","Omega","omega","true","false","Inf","infinity","oo","lim","defaultTemplate","functions",1,2,"var","import","print","typeof","units","latexConverter","msize","__WEBPACK_AMD_DEFINE_FACTORY__","__WEBPACK_AMD_DEFINE_ARRAY__","getTypeTest","hint","argCount","actualType","getTypeOf","_expected","anyType","contains","Refs","categories","Param","varArgs","_types","_varArgs","Signature","_params","signature","childs","parseSignatures","rawSignatures","expanded","expand","signature_i","existing","mapSignatures","normalized","parseTree","nodeSignature","filtered","overlapping","getArgs","_typed","refs","_signatures","_name","_args","maxParams","toCode","body","cat","hasConversions","ac","bc","toConversion","conversion","newParam","ref","comment","getTests","tests","bind","allTypes","exactTypes","conversion_i","_innerCode","nextAnyType","exceptions","_exceptions","function","string, function","string, string, function","...function","fns"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,IACQ,kBAAXG,SAAyBA,OAAOC,IAC9CD,OAAOH,GACmB,gBAAZC,SACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,KACd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aACZE,QACE,UAEFD,YAAe,qCACfE,UACE,WACA,UACA,gBACA,UACA,uDAEFK,SACE,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,UAEFD,YACI,sGACJE,UACE,WACA,WACA,YACA,aAEFK,SAAY,OAAQ,QAAS,WAM1B,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,QACR2W,SAAY,aACZE,QACE,YAEFD,YACI,yHACJE,UACE,aACA,aACA,eAEFK,SAAY,OAAQ,MAAO,WAMxB,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,YACA,qBAEFD,YAAe,uCACfE,UACE,aACA,aACA,oBAEFK,SAAa,MAAO,UAMjB,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,aAEFD,YAAe,qCACfE,UACE,YACA,aACA,iBAEFK,SAAa,SAMV,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,SACA,gBAEFD,YAAe,8NACfE,UACE,WACA,eACA,SACA,SACA,iBACA,uBACA,mBACA,SAEFK,SACE,MACA,WAMC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,QACR2W,SAAY,aACZE,QACE,YAEFD,YAAe,4CACfE,UACE,iBACA,eACA,SACA,uBACA,kBAEFK,SACE,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,YACZE,QACE,QACA,UACA,aAEFD,YACI,gEACJE,UACE,QACA,SACA,WACA,4BACA,WACA,YAEFK,SAAY,YAMT,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,WACR2W,SAAY,YACZE,QACE,QACA;AAEFD,YAAe,uBACfE,UACE,gBACA,UACA,YACA,cACA,cAEFK,SACE,YAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,aACZE,QACE,UACA,cAEFD,YAAe,oDACfE,UACE,YACA,aACA,gBACA,6BACA,8BACA,kBACA,4BACA,gCACA,mCAOC,SAAS/c,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,UACR2W,SAAY,aACZE,QACE,aACA,oBAEFD,YAAe,qJAGfE,UACE,QACA,iBACA,gBACA,WAEFK,SACE,OACA,SAMC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,YACZE,QACE,QACA,aAEFD,YACI,uCACJE,UACE,UACA,QACA,oBAEFK,SAAa,cAMV,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,QACR2W,SAAY,aACZE,QACE,WACA,eAEFD,YACI,4LACJE,UACE,aACA,aACA,cACA,cACA,eACA,uBAEFK,SAAY,OAAQ,QAAS,SAM1B,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,aACZE,QACE,WAEFD,YACI,iGACJE,UACE,YACA,aACA,WAEFK,SACE,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,aACZE,QACE,WAEFD,YACI,+EACJE,UACE,WACA,QACA,YAEFK,SACE,SACA,cAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,SACR2W,SAAY,aACZE,QACE,aAEFD,YACI,2DACJE,UACE,YACA,UACA,MACA,SAEFK,SACE,WACA,MACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,WACR2W,SAAY,YACZE,QACE,QACA,kBAEFD,YAAe,uBACfE,UACE,cACA,QACA,YACA,YACA,iBAEFK,SACE,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,aACR2W,SAAY,Y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AQ,kBACR2W,SAAY,UACZE,QACE,SACA,mBAEFD,YAAe,mEACfE,UACE,SACA,SACA,YAEFK,SACE,SAAU,SAAU,QAAS,SAAU,YAAa,mBAOnD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,gBACR2W,SAAY,UACZE,QACE,SACA,mBAEFD,YAAe,gEACfE,UACE,UACA,SACA,aAEFK,SACE,SAAU,SAAU,QAAS,SAAU,YAAa,qBAOnD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,UACZE,QACE,UAEFD,YACI,iGACJE,UACE,cACA,cACA,eAEFK,SACE,KACA,KACA,OACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,UACZE,QACE,WAEFD,YACI,gGACJE,UACE,eACA,eACA,eAEFK,SACE,KACA,KACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,KACR2W,SAAY,UACZE,QACE,SAEFD,YAAe,yCACfE,UACE,aACA,aACA,YACA,WAEFK,SACE,KACA,OACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,KACR2W,SAAY,UACZE,QACE,SAEFD,YAAe,8CACfE,UACE,aACA,aACA,YACA,WAEFK,SACE,KACA,OACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,YACR2W,SAAY,OACZE,QACE,gBAEFD,YACI,+CACJE,UACE,YACA,kCACA,mBACA,uBACA,8BAEFK,SACE,UAAW,UAAW,QAAS,SAAU,SAAU,UAOlD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,UACR2W,SAAY,OACZE,QACE,IACA,cAEFD,YACI,6CACJE,UACE,aACA,aACA,aACA,kBACA,mBACA,yBAEFK,SACE,YAAa,UAAW,QAAS,SAAU,SAAU,SAAU,UAO9D,SAASpd,E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,aACZE,QACE,SACA,kBAEFD,YACI,yGACJE,UACE,UACA,WACA,UACA,YACA,WAEFK,SACE,QAAS,UAAW,YAAa,UAAW,WAAY,aAOvD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,UACR2W,SAAY,aACZE,QACE,QACA,iBAEFD,YACI,mGACJE,UACE,QACA,UACA,UACA,YACA,UACA,iBAEFK,SACE,QAAS,UAAW,SAAU,YAAa,WAAY,aAOtD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,YACR2W,SAAY,aACZE,QACE,SACA,mBAEFD,YACI,0GACJE,UACE,UACA,WACA,UACA,YACA,WAEFK,SACE,QAAS,UAAW,SAAU,UAAW,WAAY,aAOpD,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,UACR2W,SAAY,aACZE,QACE,SACA,iBAEFD,YACI,uGACJE,UACE,WACA,WACA,UACA,YACA,SACA,eACA,kBAEFK,SACE,QAAS,UAAW,SAAU,YAAa,WAAY,UAAW,eAOjE,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,oBACA,SACA,eAEFD,YAAe,iDACfE,UACE,kBACA,oBACA,oBACA,uBACA,uBACA,gCACA,iCAEFK,SACE,OACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,aACZE,QACE,qBACA,UACA,gBAEFD,YAAe,mDACfE,UACE,mBACA,qBACA,qBACA,wBACA,wBACA,8BAEFK,SACE,MACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,SACR2W,SAAY,aACZE,QACE,uBACA,aAEFD,YAAe,mLACfE,UACE,kBACA,yBAEFK,SACE,MACA,OACA,MACA,OACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,oBACA,SACA,eAEFD,YAAe,iDACfE,UACE,kBACA,oBACA,oBACA,uBACA,uBACA,gCACA,iCAEFK,SACE,MACA,OACA,SACA,OACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,aACZE,QACE,qBACA,WAEFD,YAAe,qCACfE,UACE,gBACA,kBACA,sBAEFK,SACE,MACA,OACA,MACA,SACA,MACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,oBACA,SACA,yBAEFD,YAAe,4KACfE,UACE,eACA,oBACA,mCACA,8BACA,2BAEFK,SACE,MACA,OACA,MACA,SACA,MACA,OACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,oBACA,UAEFD,YAAe,iCACfE,UACE,kBACA,oBACA,qBAEFK,SACE,MACA,OACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,aACZE,QACE,oBACA,SACA,yBAEFD,YAAe,gIACfE,UACE,eACA,oBACA,mCACA,8BACA,2BAEFK,SACE,MACA,OACA,MACA,SACA,MACA,OACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,oDACfE,UACE,YACA,kBAEFK,SACE,MACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,QACR2W,SAAY,eACZE,QACE,YAEFD,YAAe,6FACfE,UACE,cAEFK,SACE,OACA,QACA,WAMC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,8CACf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D,SACLkG,KAAQ,QACR2W,SAAY,eACZE,QACE,eAEFD,YACI,qEACJE,UACE,mBACA,wBACA,iBACA,iBACA,eAEFK,SACE,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,eACZE,QACE,UAEFD,YAAe,sCACfE,UACE,SACA,kBACA,eACA,cACA,2BAEFK,SACE,OACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,iDACfE,UACE,aAEFK,SACE,OACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,eACZE,QACE,UAEFD,YAAe,6DACfE,UACE,SACA,cAEFK,SACE,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,oDACfE,UACE,UACA,eAEFK,SACE,OACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,eACZE,QACE,UAEFD,YAAe,4DACfE,UACE,SACA,cAEFK,SACE,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,wEACfE,UACE,UACA,eAEFK,SACE,OACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,MACR2W,SAAY,eACZE,QACE,UAEFD,YAAe,0DACfE,UACE,SACA,cAEFK,SACE,MACA,MACA,SAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,KAAQ,OACR2W,SAAY,eACZE,QACE,WAEFD,YAAe,sEACfE,UACE,UACA,eAEFK,SACE,OACA,OACA,UAOC,SAASpd,EAAQD,EAASM,GAE/BL,EAAOD,SACLkG,K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EAAGuS,WAAW5oB,eAAeu+C,GAAY,CAC3C,GAAI31B,EAAW5oB,eAAeu+C,GAG5B,KAFAl+C,GAAM,GAAIzK,OAAM,cAAgB2oD,EAAY,sBAC5Cl+C,EAAIogB,MAAQ89B,UAAWA,GACjBl+C,CAGNuoB,GAAW21B,GAAaloC,EAAGuS,WAAW21B,GAM5C,GAAe,IAAXloC,EAAGpd,KACL,GAAY,IAARA,EACFA,EAAOod,EAAGpd,SAEP,IAAIA,GAAQod,EAAGpd,KAMlB,KALAoH,GAAM,GAAIzK,OAAM,0CAA4CqD,EAAO,aAAeod,EAAGpd,KAAO,KAC5FoH,EAAIogB,MACFqiB,OAAQzsB,EAAGpd,KACX8pC,SAAU9pC,GAENoH,EAKZ,MAAOi/C,GAAOrmD,EAAM2vB,MAKxB5yB,EAAMjC,OAASA,EACfiC,EAAMirB,MAAQA,EACdjrB,EAAMurC,YAAcA,EAEbvrC"} \ No newline at end of file +{"version":3,"file":"math.map","sources":["math.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","id","loaded","call","m","c","p","create","config","math","loader","type","Chain","createProxy","isFactory","load","Error","instance","index","factories","indexOf","_config","typed","push","instances","Object","matrix","number","precision","epsilon","error","_reduce","mat","dim","callback","i","ret","val","tran","Array","isArray","_switch","length","j","I","J","tmp","collection","isCollection","x","Matrix","deepMap","array","skipZeros","map","deepMap2","array1","array2","res","len","DimensionError","valueOf","reduce","size","arraySize","IndexError","deepForEach","ii","value","name","Complex","re","im","SyntaxError","arguments","arg","construct","fromPolar","r","phi","isNumber","TypeError","skipWhitespace","next","isDigitDot","isDigit","text","charAt","revert","oldIndex","parseNumber","parseComplex","cnext","Unit","isUnit","isComplex","parse","str","isString","first","Number","separator","second","substring","args","hasBase","BASE_UNITS","ANGLE","toNumber","Math","cos","sin","prototype","toPolar","sqrt","atan2","clone","equals","other","format","options","strRe","strIm","pow","abs","toString","toJSON","mathjs","fromJSON","json","util","string","path","Range","start","end","step","parseFloat","split","nums","invalid","some","num","isNaN","isRange","object","diff","sign","ceil","min","undefined","max","forEach","obj","toArray","Index","ranges","_ranges","_isScalar","_createRange","primitive","isInteger","isIndex","apply","range","values","isScalar","row","strings","join","isMatrix","storage","constructor","_storage","datatype","subset","replacement","defaultValue","get","set","resize","_findUnit","unit","prefix","UNIT_NONE","PREFIX_NONE","_normalize","fixPrefix","parseUnit","unitName","UNITS","hasOwnProperty","endsWith","prefixLen","prefixName","prefixes","err","offset","_denormalize","prefixValue","isValuelessUnit","base","equalBase","to","valuelessUnit","bestPrefix","_bestPrefix","absValue","bestDiff","log","LN10","scientific","PREFIXES","NONE","SHORT","da","h","k","M","G","T","P","E","Z","Y","d","u","n","f","a","z","y","LONG","deca","hecto","kilo","mega","giga","tera","peta","exa","zetta","yotta","deci","centi","milli","micro","nano","pico","femto","atto","zepto","yocto","SQUARED","CUBIC","BINARY_SHORT","Ki","Mi","Gi","Ti","Pi","Ei","Zi","Yi","BINARY_LONG","kibi","mebi","gibi","tebi","pebi","exi","zebi","yobi","LENGTH","MASS","TIME","CURRENT","TEMPERATURE","LUMINOUS_INTENSITY","AMOUNT_OF_SUBSTANCE","FORCE","SURFACE","VOLUME","BIT","BASE_UNIT_NONE","meter","inch","foot","yard","mile","link","rod","chain","angstrom","in","ft","yd","mi","li","rd","ch","mil","m2","sqin","sqft","sqyd","sqmi","sqrd","sqch","sqmil","m3","L","l","litre","cuin","cuft","cuyd","teaspoon","tablespoon","drop","gtt","minim","fluiddram","fluidounce","gill","cc","cup","pint","quart","gallon","beerbarrel","oilbarrel","hogshead","fldr","floz","gi","cp","pt","qt","gal","bbl","obl","g","gram","ton","tonne","grain","dram","ounce","poundmass","hundredweight","stick","stone","gr","dr","oz","lbm","cwt","s","sec","minute","hour","day","rad","deg","grad","cycle","A","ampere","K","degC","degF","degR","kelvin","celsius","fahrenheit","rankine","mol","mole","cd","candela","N","newton","lbf","poundforce","b","bits","B","bytes","PLURALS","meters","inches","feet","yards","miles","links","rods","chains","angstroms","litres","teaspoons","tablespoons","minims","fluiddrams","fluidounces","gills","cups","pints","quarts","gallons","beerbarrels","oilbarrels","hogsheads","gtts","grams","tons","tonnes","grains","drams","ounces","poundmasses","hundredweights","sticks","seconds","minutes","hours","days","radians","degrees","gradients","cycles","amperes","moles","plural","lt","liter","liters","lb","lbs","Help","doc","parser","isHelp","desc","category","description","syntax","examples","expr","eval","e","seealso","prop","ResultSet","entries","BigNumber","Decimal","convert","digits","FibonacciHeap","_minimum","_size","smaller","larger","oneOverLogPhi","insert","key","node","degree","minimum","left","right","clear","isEmpty","extractMinimum","numberOfChildren","child","tempRight","parent","_findMinimumNode","remove","_decreaseKey","_cut","_cascadingCut","mark","_linkNodes","floor","numRoots","temp","SparseMatrix","data","_createFromMatrix","ptr","_values","_index","_ptr","_datatype","_createFromArray","types","equal","source","rows","columns","v","_getsubset","_setsubset","validateIndex","_map","submatrix","sSize","iSize","outer","unsqueeze","deepEqual","x0","y0","_getValueIndex","_resize","_remove","_insert","top","bottom","splice","copy","ins","k0","k1","me","invoke","minRow","maxRow","minColumn","maxColumn","_toArray","density","diagonal","kSuper","kSub","_value","ms","swapRows","_swapRows","_forEachRow","kx","ky","vx","vy","sparse","DenseMatrix","_data","preprocess","_get","_getSubmatrix","dims","last","_set","_fit","_setSubmatrix","dataIndex","subIndex","newSize","changed","elem","index_i","recurse","concat","vi","dense","Spa","_heap","add","accumulate","from","heap","nodes","swap","nodei","nodej","UNINITIALIZED","Infinity","NaN","lazy","bignumber","pi","tau","ln","div","PI","LN2","LOG2E","LOG10E","SQRT1_2","SQRT2","version","slice","done","arg0","arg1","String","Boolean","Date","RegExp","extend","deepExtend","canDefineProperty","defineProperty","fn","_uninitialized","configurable","traverse","names","conversions","math_import","ArgumentsError","opts","override","wrap","_module","_importFactory","entry","imported","isSupportedType","_import","transform","namespace","_validate","dimNext","oldLen","newLen","minLen","_squeeze","_unsqueeze","validate","_defaultValue","squeeze","shift","unshift","flatten","flat","message","stack","RangeError","actual","expected","relation","_create","string, string","Array | Matrix, string","Array | Matrix, string, string","NumberFormatter","round","notation","toFixed","toExponential","toPrecision","exponential","replace","DBL_EPSILON","EPSILON","nearlyEqual","isFinite","formatArray","search","Parser","boolean, boolean","number, number","BigNumber, BigNumber","Complex, Complex","Unit, Unit","Array | Matrix, any","any, Array | Matrix","gt","any, any","_equal","eq","addScalar","elementWiseOperations","Matrix, Matrix","algorithm4","algorithm1","algorithm12","Array, Array","Array, Matrix","Matrix, Array","Matrix, any","algorithm9","algorithm13","any, Matrix","Array, any","any, Array","bitwise","func","xBits","yBits","xSign","ySign","decCoefficientToBinaryString","not","minBits","maxBits","minSign","shortLen","longLen","expFuncVal","outVal","twoPower","ONE","two","prevPrec","plus","times","xe","strL","arr","arrL","reverse","arcsin_newton","Big","oldPrecision","tolerance","maxp","localPrecision","maxIter","curr","asin","tmp0","cos_sin_sec_csc","tmp1","sinToCos","isZero","tmp2","minus","toDP","arcsin_taylor","one","yPrev","x2","polyNum","constNum","constDen","bigK","arctan_taylor","cos_sin_taylor","mode","den","reduceToPeriod","lte","dp","mod","sinVal","memoize","isBigNumber","toBigNumber","exp","pi4th","and","isNegative","leftShift","or","negOne","rightArithShift","xor","arccos_arcsec","reciprocal","acos","arctan_arccot","arcsin_arccsc","absX","halfPi","wasReduced","gte","arctan2","acosh_asinh_asech_acsch","x2PlusOrMinus","atanh_acoth","isNeg","precPlusGuardDigits","five","sixteen","twenty","ret2","ret3","ret5","div_factor","loops","eight","ret4","tan_cot","tan","cosh_sinh_csch_sech","tanh_coth","posExp","negExp","lower","upper","toExpNeg","toExpPos","toSignificantDigits","extra_nodes","expression","parseStart","nesting_level","conditional_level","nextPreview","nextNextPreview","getToken","token_type","TOKENTYPE","NULL","token","DELIMITER","c2","c3","DELIMITERS","isAlpha","NAMED_DELIMITERS","SYMBOL","UNKNOWN","createSyntaxError","NUMBER","getTokenSkipNewline","openParams","closeParams","parseBlock","createError","visible","blocks","ConstantNode","parseFunctionAssignment","BlockNode","parseAssignment","valid","parseConditional","isSymbolNode","AssignmentNode","isIndexNode","UpdateNode","isFunctionNode","FunctionAssignmentNode","parseLogicalOr","prev","condition","trueExpr","falseExpr","ConditionalNode","parseLogicalXor","OperatorNode","parseLogicalAnd","parseBitwiseOr","parseBitwiseXor","parseBitwiseAnd","parseRelational","operators","params","parseShift","==","!=","<",">","<=",">=","parseConversion","<<",">>",">>>","parseRange","parseAddSubtract","SymbolNode","RangeNode","parseMultiplyDivide","+","-","parseUnary","*",".*","/","./","%","isConstantNode","~","parsePow","parseLeftHandOperators","parseCustomNodes","!","'","handler","parseSymbol","parseFunctions","parseIndex","parseString","FunctionNode","IndexNode","tPrev","parseMatrix","cols","parseRow","ArrayNode","parseParentheses","parseEnd","col",",","(",")","[","]","\"",";","^",".^","&","|","^|","=",":","?","scope","_parse","compile","divideScalar","multiply","subtract","unaryMinus","lup","_denseLUP","_sparseLUP","U","ldata","lsize","udata","usize","pabsv","vjj","absv","vij","lvalues","lindex","lptr","uvalues","uindex","uptr","pvalues","pindex","pptr","psize","pv_co","pv_oc","swapIndeces","spa","vkj","vik","backwardSubstitution","forwardSubstitution","lusolve","Array, Array | Matrix","_lusolve","Matrix, Array | Matrix","Object, Array | Matrix","_toMatrix","Array | Matrix","complexMultiply","signatures","cube","inv","Array | Matrix, Array | Matrix","dotDivide","algorithm7","algorithm2","algorithm3","algorithm10","algorithm11","multiplyScalar","dotMultiply","algorithm6","dotPow","fix","_gcdBigNumber","isInt","zero","neg","gcd","_gcd","Matrix, number | BigNumber","number | BigNumber, Matrix","Array, number | BigNumber","number | BigNumber, Array","Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber","_lcmBigNumber","prod","t","lcm","_lcm","_logNumber","_log10Complex","log10","_mod","algorithm5","_validateMatrixDimensions","xsize","ysize","_multiplyVectorVector","_multiplyVectorMatrix","_multiplyMatrixVector","_multiplyMatrixMatrix","size1","size2","adata","adt","bdata","bdt","dt","mf","af","_multiplyVectorDenseMatrix","asize","bsize","alength","bcolumns","sum","_multiplyDenseMatrixVector","_multiplySparseMatrixVector","_multiplyDenseMatrixDenseMatrix","_multiplyDenseMatrixSparseMatrix","_multiplySparseMatrixDenseMatrix","_multiplySparseMatrixSparseMatrix","arows","acolumns","bvalues","bindex","bptr","cvalues","cindex","cptr","jb","kb0","kb1","cij","kb","ib","avalues","aindex","aptr","brows","w","vbi","ka0","ka1","ka","ia","p1","ic","vbij","p0","_norm","sizeX","POSITIVE_INFINITY","pinf","NEGATIVE_INFINITY","ninf","maxc","cj","maxr","ri","trace","transpose","complexAbs","norm","boolean | null","number | Complex | BigNumber | boolean | null, number | BigNumber | string","Array, number | BigNumber | string","Matrix, number | BigNumber | string","_bigNthRoot","negated","iMax","xPrev","delta","nthRoot","_nthRoot","_powComplex","_powArray","eye","px","_powMatrix","Array, number","Array, BigNumber","Matrix, number","Matrix, BigNumber","zeros","_round","Complex, number","Complex, BigNumber","_n","toDecimalPlaces","number | Complex | BigNumber, Matrix","number | Complex | BigNumber, Array","decimals","cmp","_sqrtNumber","_sqrtComplex","square","unaryPlus","boolean | string | null","_xgcd","q","lastx","lasty","_xgcdBigNumber","bitAnd","bigBitAnd","bitNot","bigBitNot","bitOr","bigBitOr","bitXor","bigBitXor","bigLeftShift","algorithm8","bigRightArithShift","rightLogShift","conj","string, Object","Array | Matrix, Object","docs","any","string | Array | Matrix","string | Array | Matrix, Object","...Array | Matrix | number | BigNumber","prevDim","asMatrix","matrices","_concat","concatDim","_cross","xSize","ySize","_det","compute_mu","mu","fa","_diag","_createDiagonalMatrix","_getDiagonal","F","dm","vector","Array, string","Array, number, string","Array, BigNumber, string","Matrix, string","Matrix, number, string","Matrix, BigNumber, string","_dot","_eyeVector","_eye","number | BigNumber","number | BigNumber, string","number | BigNumber, number | BigNumber","number | BigNumber, number | BigNumber, string","_flatten","_inv","det","Ac","Bc","Ar","Br","_ones","hasBigNumbers","...number | BigNumber | string","pop","_out","_strRange","includeEnd","_bigRangeInc","_bigRangeEx","_rangeInc","_rangeEx","ZERO","string, boolean","number, number, number","number, number, boolean","number, number, number, boolean","BigNumber, BigNumber, BigNumber","BigNumber, BigNumber, boolean","BigNumber, BigNumber, BigNumber, boolean","_resizeString","defaultChar","number | Complex | BigNumber | Unit | boolean | null","_getSubstring","strLen","substr","_setSubstring","chars","Array, Index","Matrix, Index","string, Index","Array, Index, any","Array, Index, any, any","Matrix, Index, any","Matrix, Index, any, any","string, Index, string","string, Index, string, string","_denseTrace","_sparseTrace","_denseTranspose","_sparseTranspose","transposedRow","transposed","_zeros","bool","boolean","lcase","toLowerCase","complex","...number | BigNumber | Range | Array","Unit, string | Unit","null","number, string","BigNumber, string","result","isPositiveInteger","dividedBy","gamma","factorial","bigFactorial","preciseFacs","smallBigFacs","toSD","bigBigFacs","twoN","threeN","fourN","fiveN","real","twoPiSqrt","distribution","pickRandom","random","randomInt","_largest","_max","Array | Matrix, number | BigNumber","...","_nmean","divide","_mean","_median","sort","compare","middle2","middle","median","_smallest","_min","_prod","_std","normalization","variance","_sum","_var","mean","DEFAULT_NORMALIZATION","_complexAcos","temp1","temp2","complexSqrt","temp3","temp4","complexLog","bigArcCos","_complexAcosh","complexAcos","acosh","bigAcosh","complexAtan","acot","atan","HALF_PI","bigArcCot","_complexAcoth","atanh","acoth","bigAcoth","_complexAcsc","complexAsin","acsc","bigArcCsc","asinh","acsch","bigAcsch","_complexAsec","asec","bigArcSec","_complexAsech","asech","bigAsech","_complexAsin","bigArcSin","bigAsinh","bigArcTan","bigAtan2","_complexAtanh","noIM","oneMinus","onePlus","bigAtanh","cosh","sinh","bigCos","_cosh","ep","en","bigCosh","cot","bigCot","coth","_coth","bigCoth","csc","bigCsc","csch","_csch","bigCsch","bigSec","sech","_sech","bigSech","bigSin","_sinh","cim","sim","bigSinh","bigTan","tanh","_tanh","bigTanh","_deepEqual","largerEq","smallerEq","unequal","_unequal","Unit, Unit | string","Array, function","_filterCallback","Array, RegExp","_filterRegExp","Matrix, function","test","Matrix, RegExp","filter","regexp","any, Object | function | number","_print","string, Object, number","template","original","keys","_comparator","order","asc","_arrayIsVector","_matrixIsVector","_forEach","xgcd","help","cross","diag","dot","ones","combinations","permutations","std","webpackContext","req","webpackContextResolve","./clone","./clone.js","./config","./config.js","./filter","./filter.js","./forEach","./forEach.js","./format","./format.js","./import","./import.js","./index","./index.js","./map","./map.js","./print","./print.js","./sort","./sort.js","./typeof","./typeof.js","resolve","isBoolean","cache","hash","JSON","stringify","Function","match","coefficients","exponent","parseInt","rounded","roundDigits","pp","removed","__WEBPACK_AMD_DEFINE_RESULT__","global","coefficientToString","LOGBASE","charCodeAt","checkRoundingDigits","rm","repeating","ci","mathpow","checkRM","method","outOfRange","ifExceptionsThrow","checkArg","MAX_DIGITS","pr","denom","guard","sd","rep","external","rnd","getCoeffLength","more","intPow","c0","x1","xc","xci","out","mathfloor","BASE","convertBase","decimal","crypto","NUMERALS","EXP_LIMIT","INT_POW_LIMIT","yc","base10","inf","sd10","xLTy","half","pos","groupSeparator","g1","g2","intPart","fractionPart","intDigits","maxD","d0","d2","frac","n0","n1","d1","yN","toBaseOut","baseIn","baseOut","multiplyInteger","carry","aL","bL","logbase","prodL","qc","rem","remL","rem0","xi","xL","yc0","yL","yz","maxOrMin","ltgt","rand","Uint32Array","decimalFactory","parseDecimal","decimalSeparator","groupSize","secondaryGroupSize","fractionGroupSeparator","fractionGroupSize","isValid","trim","isNum","orig","denseMatrix","sparseMatrix","inverse","cf","cdata","bzero","_zero","azero","ef","_scatter","xa","xb","wa","wb","va","vb","iterate","level","av","bv","cv","cvl","update","count","every","isNode","Node","isArrayNode","_compile","defs","_ifNode","_toString","_toTex","callbacks","childNode","toTex","keywords","isAssignmentNode","precedence","getPrecedence","exprPrecedence","latex","toSymbol","block","isBlockNode","param","js","isConditionalNode","testCondition","conditionPrecedence","truePrecedence","falsePrecedence","valueType","getType","SUPPORTED_TYPES","isFunctionAssignmentNode","variable","compileSubset","someUseEnd","rangesUseEnd","useEnd","isRangeNode","objectName","op","calculateNecessaryParentheses","associativity","getAssociativity","operandPrecedence","operandIdentifier","getIdentifier","rootIdentifier","properties","latexLeftParens","latexParens","lhsParens","lhsPrecedence","assocWithLhs","isAssociativeWith","rhsParens","rhsPrecedence","assocWithRhs","lhsIdentifier","rhsIdentifier","latexRightParens","parens","isOperatorNode","assoc","operand","lhs","rhs","lhsTex","rhsTex","isRaw","rawArgs","paramsName","symbol","toFunction","startPrecedence","stepPrecedence","endPrecedence","undef","isUpdateNode","_divideComplex","Unit, number","substitutionValidation","_denseBackwardSubstitution","_sparseBackwardSubstitution","xj","bj","xvalues","xindex","xptr","_denseForwardSubstitution","_sparseForwardSubstitution","number, Unit","distributions","randFunctions","arg2","arg3","_randomDataForMatrix","_random","_randomInt","possibles","randFunc","uniform","normal","u1","u2","picked","_validateScope","_transform","transformed","code","defsCode","factoryCode","_traverse","find","customTex","...any","lastIndex","errorTransform","_scope","sub","Array | Matrix, function","indexFactory","__WEBPACK_AMD_DEFINE_FACTORY__","__WEBPACK_AMD_DEFINE_ARRAY__","getTypeTest","hint","argCount","actualType","getTypeOf","_expected","anyType","contains","Refs","categories","Param","varArgs","_types","_varArgs","Signature","_params","signature","childs","parseSignatures","rawSignatures","expanded","expand","signature_i","existing","mapSignatures","normalized","parseTree","nodeSignature","filtered","overlapping","getArgs","_typed","refs","_signatures","_name","_args","maxParams","toCode","body","cat","hasConversions","ac","bc","toConversion","conversion","newParam","ref","comment","getTests","tests","bind","allTypes","exactTypes","conversion_i","_innerCode","nextAnyType","exceptions","_exceptions","function","string, function","string, string, function","...function","fns","expandTemplate","symbols","Alpha","alpha","Beta","beta","Gamma","Delta","Epsilon","varepsilon","Zeta","zeta","Eta","eta","Theta","theta","vartheta","Iota","iota","Kappa","kappa","varkappa","Lambda","lambda","Mu","Nu","nu","Xi","Omicron","omicron","varpi","Rho","rho","varrho","Sigma","sigma","varsigma","Tau","Upsilon","upsilon","Phi","varphi","Chi","chi","Psi","psi","Omega","omega","true","false","Inf","infinity","oo","lim","defaultTemplate","functions",1,2,"var","import","print","typeof","units","latexConverter","identifier","property","nodeA","nodeB","identifierA","identifierB","associativeWith","OperatorNode:or","OperatorNode:xor","OperatorNode:and","OperatorNode:bitOr","OperatorNode:bitXor","OperatorNode:bitAnd","OperatorNode:equal","OperatorNode:unequal","OperatorNode:smaller","OperatorNode:larger","OperatorNode:smallerEq","OperatorNode:largerEq","OperatorNode:leftShift","OperatorNode:rightArithShift","OperatorNode:rightLogShift","OperatorNode:to","OperatorNode:add","OperatorNode:subtract","OperatorNode:multiply","OperatorNode:divide","OperatorNode:dotMultiply","OperatorNode:dotDivide","OperatorNode:mod","OperatorNode:unaryPlus","OperatorNode:unaryMinus","OperatorNode:bitNot","OperatorNode:not","OperatorNode:pow","OperatorNode:dotPow","OperatorNode:factorial","OperatorNode:transpose","msize"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;CA2BA,SAA2CA,EAAMC,GAC1B,gBAAZC,UAA0C,gBAAXC,QACxCA,OAAOD,QAAUD,IACQ,kBAAXG,SAAyBA,OAAOC,IAC9CD,OAAOH,GACmB,gBAAZC,SACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,KACdK,KAAM,WACT,MAAgB,UAAUC,GAKhB,QAASC,GAAoBC,GAG5B,GAAGC,EAAiBD,GACnB,MAAOC,GAAiBD,GAAUP,OAGnC,IAAIC,GAASO,EAAiBD,IAC7BP,WACAS,GAAIF,EACJG,QAAQ,EAUT,OANAL,GAAQE,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOS,QAAS,EAGTT,EAAOD,QAvBf,GAAIQ,KAqCJ,OATAF,GAAoBM,EAAIP,EAGxBC,EAAoBO,EAAIL,EAGxBF,EAAoBQ,EAAI,GAGjBR,EAAoB,KAK/B,SAASL,EAAQD,EAASM,GAgB/B,QAASS,GAAQC,GAGf,GAAIC,GAAOC,EAAOH,QAuDlB,OAtDAE,GAAKF,OAASA,EAG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A,UACA,UACA,YACA,UACA,iBAEFI,SACE,QAAS,UAAW,SAAU,YAAa,WAAY,aAOtD,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,YACRuX,SAAY,aACZE,QACE,SACA,mBAEFD,YACI,0GACJE,UACE,UACA,WACA,UACA,YACA,WAEFI,SACE,QAAS,UAAW,SAAU,UAAW,WAAY,aAOpD,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,UACRuX,SAAY,aACZE,QACE,SACA,iBAEFD,YACI,uGACJE,UACE,WACA,WACA,UACA,YACA,SACA,eACA,kBAEFI,SACE,QAAS,UAAW,SAAU,YAAa,WAAY,UAAW,eAOjE,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,MACRuX,SAAY,aACZE,QACE,oBACA,SACA,eAEFD,YAAe,iDACfE,UACE,kBACA,oBACA,oBACA,uBACA,uBACA,gCACA,iCAEFI,SACE,OACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,OACRuX,SAAY,aACZE,QACE,qBACA,UACA,gBAEFD,YAAe,mDACfE,UACE,mBACA,qBACA,qBACA,wBACA,wBACA,8BAEFI,SACE,MACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,SACRuX,SAAY,aACZE,QACE,uBACA,aAEFD,YAAe,mLACfE,UACE,kBACA,yBAEFI,SACE,MACA,OACA,MACA,OACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,MACRuX,SAAY,aACZE,QACE,oBACA,SACA,eAEFD,YAAe,iDACfE,UACE,kBACA,oBACA,oBACA,uBACA,uBACA,gCACA,iCAEFI,SACE,MACA,OACA,SACA,OACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,OACRuX,SAAY,aACZE,QACE,qBACA,WAEFD,YAAe,qCACfE,UACE,gBACA,kBACA,sBAEFI,SACE,MACA,OACA,MACA,SACA,MACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,MACRuX,SAAY,aACZE,QACE,oBACA,SACA,yBAEFD,YAAe,4KACfE,UACE,eACA,oBACA,mCACA,8BACA,2BAEFI,SACE,MACA,OACA,MACA,SACA,MACA,OACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,MACRuX,SAAY,aACZE,QACE,oBACA,UAEFD,YAAe,iCACfE,UACE,kBACA,oBACA,qBAEFI,SACE,MACA,OACA,SACA,MACA,OACA,MACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,MACRuX,SAAY,aACZE,QACE,oBACA,SACA,yBAEFD,YAAe,gIACfE,UACE,eACA,oBACA,mCACA,8BACA,2BAEFI,SACE,MACA,OACA,MACA,SACA,MACA,OACA,MACA,SAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,OACRuX,SAAY,eACZE,QACE,WAEFD,YAAe,oDACfE,UACE,YACA,kBAEFI,SACE,MACA,OACA,UAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,QACRuX,SAAY,eACZE,QACE,YAEFD,YAAe,6FACfE,UACE,cAEFI,SACE,OACA,QACA,WAMC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,OACRuX,SAAY,eACZE,QACE,WAEFD,YAAe,8CACfE,UACE,YACA,iBACA,WAEFI,SACE,MACA,UAOC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,SACL6E,KAAQ,QACRuX,SAAY,eACZE,QACE,YAEFD,YAAe,6GACfE,UACE,cAEFI,SACE,QACA,WAMC,SAAS1c,EAAQD,EAASM,GAE/BL,EAAOD,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EAAM,IAAM+H,EAAO7B,MAAMmY,KAC1B,GAEItc,EAGT,GAAIT,EAAQyV,GAAI,CAEd,GAAIonB,GAAQj8B,EAAMW,KAAKkU,EAEvB,IAAqB,IAAjBonB,EAAM38B,OAAc,CAEtB,GAAI28B,EAAM,KAAOhgB,EACf,KAAM,IAAI4I,YAAW,+DAEvB,OAAOhf,GAAO7B,MAAM6Q,GAEtB,GAAqB,IAAjBonB,EAAM38B,OAAc,CAEtB,GAAI28B,EAAM,KAAOhgB,GAAqB,IAAbggB,EAAM,GAC7B,KAAM,IAAIpX,YAAW,+DAEvB,OAAOhQ,GAAE3U,IAAI,SAAUic,GACrB,MAAOtW,GAAO7B,MAAMmY,EAAE,MAI1B,KAAM,IAAI0I,YAAW,iEAIzB,OAAOs8B,GAtFT,GAAIr8C,GAAOpI,EAAoB,IAE3BqI,EAASD,EAAKC,OACd/E,EAAQ8E,EAAK9E,MACb6F,EAASf,EAAKe,OAEdzG,EAAUD,MAAMC,OAmFpBhD,GAAQ6E,KAAO,yBACf7E,EAAQD,QAAUA,GAIb,SAASE,EAAQD,EAASM,GAE/B,GAAImE,GAAanE,EAAoB,GAOrCN,GAAQunB,UAAY,SAAU3a,GAC5B,MAAIA,aAAenI,GACV,GAAIA,GAAWmI,EAAIlL,MAAQ,EAAGkL,EAAI/C,IAAM,EAAG+C,EAAI7C,IAAM,GAGvD6C"} \ No newline at end of file diff --git a/dist/math.min.js b/dist/math.min.js index 5e4e7a56b..5ac555cd1 100644 --- a/dist/math.min.js +++ b/dist/math.min.js @@ -7,7 +7,7 @@ * mathematical functions, and a flexible expression parser. * * @version 2.0.0-SNAPSHOT - * @date 2015-04-28 + * @date 2015-05-02 * * @license * Copyright (C) 2013-2015 Jos de Jong @@ -24,15 +24,20 @@ * License for the specific language governing permissions and limitations under * the License. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):"object"==typeof exports?exports.math=t():e.math=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){function n(e){var t=i.create();t.create=n;var o=t._config;return t["import"](r(2)),t.expression={},t.expression.node=r(15),t["import"](r(13)),t["import"](r(14)),t.expression.docs=r(16),t.type.Complex=r(3),t.type.Range=r(4),t.type.Index=r(5),t["import"](r(6)),t.type.Unit=r(7),t.type.Help=r(8),t.type.ResultSet=r(9),t["import"](r(10)),t["import"](r(11)),t["import"](r(17)),t["import"](r(18)),t["import"](r(19)),t["import"](r(20)),t["import"](r(164)),t["import"](r(165)),t["import"](r(31)),t["import"](r(32)),t["import"](r(33)),t["import"](r(34)),t["import"](r(35)),t["import"](r(36)),t["import"](r(37)),t["import"](r(38)),t["import"](r(39)),t["import"](r(40)),t["import"](r(41)),t["import"](r(42)),t["import"](r(43)),t["import"](r(44)),t["import"](r(45)),t["import"](r(46)),t["import"](r(47)),t["import"](r(48)),t["import"](r(49)),t["import"](r(50)),t["import"](r(51)),t["import"](r(52)),t["import"](r(53)),t["import"](r(54)),t["import"](r(55)),t["import"](r(56)),t["import"](r(57)),t["import"](r(58)),t["import"](r(59)),t["import"](r(60)),t["import"](r(61)),t["import"](r(62)),t["import"](r(63)),t["import"](r(64)),t["import"](r(65)),t["import"](r(66)),t["import"](r(67)),t["import"](r(68)),t["import"](r(69)),t["import"](r(70)),t["import"](r(71)),t["import"](r(72)),t["import"](r(73)),t["import"](r(74)),t["import"](r(75)),t["import"](r(76)),t["import"](r(77)),t["import"](r(78)),t["import"](r(79)),t["import"](r(80)),t["import"](r(81)),t["import"](r(82)),t["import"](r(83)),t["import"](r(84)),t["import"](r(85)),t["import"](r(86)),t["import"](r(87)),t["import"](r(88)),t["import"](r(89)),t["import"](r(90)),t["import"](r(91)),t["import"](r(92)),t["import"](r(93)),t["import"](r(94)),t["import"](r(95)),t["import"](r(96)),r(97)(t,o),r(98)(t,o),r(99)(t,o),t["import"](r(100)),t["import"](r(101)),r(102)(t,o),t["import"](r(103)),t["import"](r(104)),r(105)(t,o),t["import"](r(106)),t["import"](r(107)),t["import"](r(108)),t["import"](r(109)),t["import"](r(110)),t["import"](r(111)),t["import"](r(112)),t["import"](r(113)),t["import"](r(114)),t["import"](r(115)),t["import"](r(116)),t["import"](r(117)),t["import"](r(118)),t["import"](r(119)),t["import"](r(120)),t["import"](r(121)),t["import"](r(122)),t["import"](r(123)),t["import"](r(124)),t["import"](r(125)),t["import"](r(126)),t["import"](r(127)),t["import"](r(128)),t["import"](r(129)),t["import"](r(130)),t["import"](r(131)),t["import"](r(132)),t["import"](r(133)),t["import"](r(134)),t["import"](r(135)),t["import"](r(136)),t["import"](r(137)),t["import"](r(138)),t["import"](r(139)),t["import"](r(140)),t["import"](r(141)),t["import"](r(142)),t["import"](r(143)),t["import"](r(144)),t["import"](r(145)),t["import"](r(146)),t["import"](r(147)),t["import"](r(148)),t["import"](r(149)),t["import"](r(150)),t["import"](r(151)),t["import"](r(152)),t["import"](r(153)),t["import"](r(154)),t["import"](r(155)),t["import"](r(156)),t["import"](r(157)),t["import"](r(158)),t["import"](r(159)),t["import"](r(160)),t["import"](r(161)),t["import"](r(162)),t["import"](r(163)),t.expression.transform={concat:r(21)(t,o),filter:r(22)(t,o),forEach:r(23)(t,o),index:r(24)(t,o),map:r(25)(t,o),max:r(26)(t,o),mean:r(27)(t,o),min:r(28)(t,o),range:r(29)(t,o),subset:r(30)(t,o)},t.type.Chain=r(12)(),t.type.Chain.createProxy(t),t.config(e),t}var i=r(1);e.exports=n()},function(e,t,r){var n=r(166).isFactory;t.create=function(){function e(r){if(!n(r))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var u,c=t.indexOf(r);return-1===c?(u=r.math?r.factory(o.type,s,e,a,o):r.factory(o.type,s,e,a),t.push(r),i.push(u)):u=i[c],u}if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var t=[],i=[],o={type:{}},a=r(167).create(o),s={matrix:"matrix",number:"number",precision:64,epsilon:1e-14};return o["import"]=e(r(168)),r(169)(o,s),o._config=s,o.error=r(170),o}},function(e,t,r){"use strict";function n(e,t,n,u){function c(e,t,r){var n,i,o,a;if(0>=t){if(Array.isArray(e[0])){for(a=f(e),i=[],n=0;nr;r++){var a=[];for(t=0;n>t;t++)a.push(e[t][r]);o.push(a)}return o}var l=n(r(75)),p={};return p.argsToArray=function(t){if(0===t.length)return[];if(1==t.length){var r=t[0];return r instanceof e.Matrix&&(r=r.valueOf()),Array.isArray(r)||(r=[r]),r}return i.array.argsToArray(t)},p.isCollection=function(t){return Array.isArray(t)||t instanceof e.Matrix},p.deepMap=function m(e,t,r){return e&&"function"==typeof e.map?e.map(function(e){return m(e,t,r)}):t(e)},p.deepMap2=function h(t,r,n){var i,o,a;if(Array.isArray(t))if(Array.isArray(r)){if(t.length!=r.length)throw new s(t.length,r.length);for(i=[],o=t.length,a=0;o>a;a++)i[a]=h(t[a],r[a],n)}else{if(r instanceof e.Matrix)return i=h(t,r.valueOf(),n),l(i);for(i=[],o=t.length,a=0;o>a;a++)i[a]=h(t[a],r,n)}else{if(t instanceof e.Matrix)return r instanceof e.Matrix?(i=h(t.valueOf(),r.valueOf(),n),l(i)):(i=h(t.valueOf(),r,n),l(i));if(Array.isArray(r))for(i=[],o=r.length,a=0;o>a;a++)i[a]=h(t,r[a],n);else{if(r instanceof e.Matrix)return i=h(t,r.valueOf(),n),l(i);i=n(t,r)}}return i},p.reduce=function(t,r,n){var i=Array.isArray(t)?o(t):t.size();if(0>r)throw new a(r);if(r>=i.length)throw new a(r,i.length);return t instanceof e.Matrix?l(c(t.valueOf(),r,n)):c(t,r,n)},p.deepForEach=function g(t,r){t instanceof e.Matrix&&(t=t.valueOf());for(var n=0,i=t.length;i>n;n++){var o=t[n];Array.isArray(o)?g(o,r):r(o)}},p}var i=r(171),o=r(172).size,a=r(173),s=r(174);t.name="collection",t.factory=n},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");switch(arguments.length){case 0:this.re=0,this.im=0;break;case 1:var r=arguments[0];if("object"==typeof r){if("re"in r&&"im"in r){var i=new n(r.re,r.im);this.re=i.re,this.im=i.im;break}if("r"in r&&"phi"in r){var i=n.fromPolar(r.r,r.phi);this.re=i.re,this.im=i.im;break}}throw new SyntaxError("Object with the re and im or r and phi properties expected.");case 2:if(!h(e)||!h(t))throw new TypeError("Two numbers expected in Complex constructor");this.re=e,this.im=t;break;default:throw new SyntaxError("One, two or three arguments expected in Complex constructor")}}function i(){for(;" "==x||" "==x;)s()}function o(e){return e>="0"&&"9">=e||"."==e}function a(e){return e>="0"&&"9">=e}function s(){y++,x=d.charAt(y)}function u(e){y=e,x=d.charAt(y)}function c(){var e,t="";if(e=y,"+"==x?s():"-"==x&&(t+=x,s()),!o(x))return u(e),null;if("."==x){if(t+=x,s(),!a(x))return u(e),null}else{for(;a(x);)t+=x,s();"."==x&&(t+=x,s())}for(;a(x);)t+=x,s();if("E"==x||"e"==x){if(t+=x,s(),("+"==x||"-"==x)&&(t+=x,s()),!a(x))return u(e),null;for(;a(x);)t+=x,s()}return t}function f(){var e=d.charAt(y+1);if("I"==x||"i"==x)return s(),"1";if(!("+"!=x&&"-"!=x||"I"!=e&&"i"!=e)){var t="+"==x?"1":"-1";return s(),s(),t}return null}var l=r(171),p=r(7),m=l.number,h=l.number.isNumber,g=p.isUnit,v=l.string.isString;n.isComplex=function(e){return e instanceof n};var d,y,x;n.parse=function(e){if(d=e,y=-1,x="",!v(d))return null;s(),i();var t=c();if(t){if("I"==x||"i"==x)return s(),i(),x?null:new n(0,Number(t));i();var r=x;if("+"!=r&&"-"!=r)return i(),x?null:new n(Number(t),0);s(),i();var o=c();if(o){if("I"!=x&&"i"!=x)return null;s()}else if(o=f(),!o)return null;return"-"==r&&(o="-"==o[0]?"+"+o.substring(1):"-"+o),s(),i(),x?null:new n(Number(t),Number(o))}return(t=f())?(i(),x?null:new n(0,Number(t))):null},n.fromPolar=function(e){switch(arguments.length){case 1:var t=arguments[0];if("object"==typeof t)return n.fromPolar(t.r,t.phi);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var r=arguments[0],i=arguments[1];if(h(r)){if(g(i)&&i.hasBase(p.BASE_UNITS.ANGLE)&&(i=i.toNumber("rad")),h(i))return new n(r*Math.cos(i),r*Math.sin(i));throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},n.prototype.toPolar=function(){return{r:Math.sqrt(this.re*this.re+this.im*this.im),phi:Math.atan2(this.im,this.re)}},n.prototype.clone=function(){return new n(this.re,this.im)},n.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},n.prototype.format=function(e){var t="",r=this.im,n=this.re,i=m.format(this.re,e),o=m.format(this.im,e),a=h(e)?e:e?e.precision:null;if(null!==a){var s=Math.pow(10,-a);Math.abs(n/r)0?1==r?i+" + i":i+" + "+o+"i":-1==r?i+" - i":i+" - "+o.substring(1)+"i"},n.prototype.toString=function(){return this.format()},n.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},n.fromJSON=function(e){return new n(e)},n.prototype.valueOf=n.prototype.toString,e.exports=n},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("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!=r&&!o.isNumber(r))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!=r?parseFloat(r):1}{var i=r(171),o=i.number,a=i.string;i.array}n.parse=function(e){if(!a.isString(e))return null;var t=e.split(":"),r=t.map(function(e){return parseFloat(e)}),i=r.some(function(e){return isNaN(e)});if(i)return null;switch(r.length){case 2:return new n(r[0],r[1]);case 3:return new n(r[0],r[2],r[1]);default:return null}},n.prototype.clone=function(){return new n(this.start,this.end,this.step)},n.isRange=function(e){return e instanceof n},n.prototype.size=function(){var e=0,t=this.start,r=this.step,n=this.end,i=n-t;return o.sign(r)==o.sign(i)?e=Math.ceil(i/r):0==i&&(e=0),isNaN(e)&&(e=0),[e]},n.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},n.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},n.prototype.forEach=function(e){var t=this.start,r=this.step,n=this.end,i=0;if(r>0)for(;n>t;)e(t,i,this),t+=r,i++;else if(0>r)for(;t>n;)e(t,i,this),t+=r,i++},n.prototype.map=function(e){var t=[];return this.forEach(function(r,n,i){t[n]=e(r,n,i)}),t},n.prototype.toArray=function(){var e=[];return this.forEach(function(t,r){e[r]=t}),e},n.prototype.valueOf=function(){return this.toArray()},n.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)},n.prototype.toString=function(){return this.format()},n.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},n.fromJSON=function(e){return new n(e.start,e.end,e.step)},e.exports=n},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this._ranges=[],this._isScalar=!0;for(var t=0,r=arguments.length;r>t;t++){var o=arguments[t];if(o instanceof a)this._ranges.push(o),this._isScalar=!1;else if(f(o))this._ranges.push(i(o)),this._isScalar=!1;else if(u(o))this._ranges.push(i([o,o+1]));else{var s=o.valueOf();if(!f(s))throw new TypeError("Ranges must be an Array, Number, or Range");this._ranges.push(i(s)),this._isScalar=!1}}}function i(e){for(var t=e.length,r=0;t>r;r++)if(!u(e[r])||!c(e[r]))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=r(171),a=r(4),s=o.number,u=s.isNumber,c=s.isInteger,f=Array.isArray;n.prototype.clone=function(){var e=new n;return e._ranges=o.object.clone(this._ranges),e._isScalar=this._isScalar,e},n.isIndex=function(e){return e instanceof n},n.create=function(e){var t=new n;return n.apply(t,e),t},n.prototype.size=function(){for(var e=[],t=0,r=this._ranges.length;r>t;t++){var n=this._ranges[t];e[t]=n.size()[0]}return e},n.prototype.max=function(){for(var e=[],t=0,r=this._ranges.length;r>t;t++){var n=this._ranges[t];e[t]=n.max()}return e},n.prototype.min=function(){for(var e=[],t=0,r=this._ranges.length;r>t;t++){var n=this._ranges[t];e[t]=n.min()}return e},n.prototype.forEach=function(e){for(var t=0,r=this._ranges.length;r>t;t++)e(this._ranges[t],t,this)},n.prototype.range=function(e){return this._ranges[e]||null},n.prototype.isScalar=function(){return this._isScalar},n.prototype.toArray=function(){for(var e=[],t=0,r=this._ranges.length;r>t;t++){var n=this._ranges[t],i=[],o=n.start,a=n.end,s=n.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},n.prototype.valueOf=n.prototype.toArray,n.prototype.toString=function(){for(var e=[],t=0,r=this._ranges.length;r>t;t++){var n=this._ranges[t],i=s.format(n.start);1!=n.step&&(i+=":"+s.format(n.step)),i+=":"+s.format(n.end),e.push(i)}return"["+e.join(", ")+"]"},n.prototype.toJSON=function(){return{mathjs:"Index",ranges:this._ranges}},n.fromJSON=function(e){return n.create(e.ranges)},e.exports=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.isMatrix=function(e){return e instanceof i},i.storage=function(e){if(!a(e))throw new TypeError("format must be a string value");var t=i._storage[e];if(!t)throw new SyntaxError("Unsupported matrix storage format: "+e);return t},i._storage={},i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.subset=function(e,t,r){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(e,t,r){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(e,t){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(e,t){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i}var i=r(171),o=i.string,a=o.isString;t.name="Matrix",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new Error("Constructor must be called with the new operator");if(void 0!=e&&!y(e))throw new TypeError("First parameter in Unit constructor must be a number");if(void 0!=t&&(!x(t)||""==t))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!=t){var r=l(t);if(!r)throw new SyntaxError('Unknown unit "'+t+'"');this.unit=r.unit,this.prefix=r.prefix}else this.unit=M,this.prefix=b;this.value=void 0!=e?this._normalize(e):null,this.fixPrefix=!1}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(){m++,h=p.charAt(m)}function u(e){m=e,h=p.charAt(m)}function c(){var e,t="";if(e=m,"+"==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 in A)if(A.hasOwnProperty(t)&&d.endsWith(e,t)){var r=A[t],n=e.length-t.length,i=e.substring(0,n),o=r.prefixes[i];if(void 0!==o)return{unit:r,prefix:o}}return null}var p,m,h,g=r(171),v=g.number,d=g.string,y=g.number.isNumber,x=g.string.isString;n.parse=function(e){if(p=e,m=-1,h="",!x(p))return null;s(),i();var t,r=c();if(r){if(t=f(),s(),i(),h)return null;if(r&&t)try{return new n(Number(r),t)}catch(o){}}else{if(t=f(),s(),i(),h)return null;if(t)try{return new n(null,t)}catch(o){}}return null},n.isUnit=function(e){return e instanceof n},n.prototype.clone=function(){var e=new n;for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},n.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},n.prototype._denormalize=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},n.isValuelessUnit=function(e){return null!=l(e)},n.prototype.hasBase=function(e){return this.unit.base===e},n.prototype.equalBase=function(e){return this.unit.base===e.unit.base},n.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},n.prototype.to=function(e){var t,r=null==this.value?this._normalize(1):this.value;if(x(e)){if(t=new n(null,e),!this.equalBase(t))throw new Error("Units do not match");return t.value=r,t.fixPrefix=!0,t}if(e instanceof n){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");return t=e.clone(),t.value=r,t.fixPrefix=!0,t}throw new Error("String or Unit expected as parameter")},n.prototype.toNumber=function(e){var t=this.to(e);return t._denormalize(t.value,t.prefix.value)},n.prototype.toString=function(){return this.format()},n.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.prefix.name+this.unit.name,fixPrefix:this.fixPrefix}},n.fromJSON=function(e){var t=new n(e.value,e.unit);return t.fixPrefix=e.fixPrefix||!1,t},n.prototype.valueOf=n.prototype.toString,n.prototype.format=function(e){var t,r;if(null===this.value||this.fixPrefix)t=this._denormalize(this.value),r=null!==this.value?v.format(t,e)+" ":"",r+=this.prefix.name+this.unit.name;else{var n=this._bestPrefix();t=this._denormalize(this.value,n.value),r=v.format(t,e)+" ",r+=n.name+this.unit.name}return r},n.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),t=b,r=Math.abs(Math.log(e/t.value)/Math.LN10-1.2),n=this.unit.prefixes;for(var i in n)if(n.hasOwnProperty(i)){var o=n[i];if(o.scientific){var a=Math.abs(Math.log(e/o.value)/Math.LN10-1.2);r>a&&(t=o,r=a)}}return t};var w={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}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-42,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},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},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: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},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}}},b={name:"",value:1,scientific:!0},N={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}},E={},M={name:"",base:E,value:1,offset:0},A={meter:{name:"meter",base:N.LENGTH,prefixes:w.LONG,value:1,offset:0},inch:{name:"inch",base:N.LENGTH,prefixes:w.NONE,value:.0254,offset:0},foot:{name:"foot",base:N.LENGTH,prefixes:w.NONE,value:.3048,offset:0},yard:{name:"yard",base:N.LENGTH,prefixes:w.NONE,value:.9144,offset:0},mile:{name:"mile",base:N.LENGTH,prefixes:w.NONE,value:1609.344,offset:0},link:{name:"link",base:N.LENGTH,prefixes:w.NONE,value:.201168,offset:0},rod:{name:"rod",base:N.LENGTH,prefixes:w.NONE,value:5.02921,offset:0},chain:{name:"chain",base:N.LENGTH,prefixes:w.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:N.LENGTH,prefixes:w.NONE,value:1e-10,offset:0},m:{name:"m",base:N.LENGTH,prefixes:w.SHORT,value:1,offset:0},"in":{name:"in",base:N.LENGTH,prefixes:w.NONE,value:.0254,offset:0},ft:{name:"ft",base:N.LENGTH,prefixes:w.NONE,value:.3048,offset:0},yd:{name:"yd",base:N.LENGTH,prefixes:w.NONE,value:.9144,offset:0},mi:{name:"mi",base:N.LENGTH,prefixes:w.NONE,value:1609.344,offset:0},li:{name:"li",base:N.LENGTH,prefixes:w.NONE,value:.201168,offset:0},rd:{name:"rd",base:N.LENGTH,prefixes:w.NONE,value:5.02921,offset:0},ch:{name:"ch",base:N.LENGTH,prefixes:w.NONE,value:20.1168,offset:0},mil:{name:"mil",base:N.LENGTH,prefixes:w.NONE,value:254e-7,offset:0},m2:{name:"m2",base:N.SURFACE,prefixes:w.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:N.SURFACE,prefixes:w.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:N.SURFACE,prefixes:w.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:N.SURFACE,prefixes:w.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:N.SURFACE,prefixes:w.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:N.SURFACE,prefixes:w.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:N.SURFACE,prefixes:w.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:N.SURFACE,prefixes:w.NONE,value:6.4516e-10,offset:0},m3:{name:"m3",base:N.VOLUME,prefixes:w.CUBIC,value:1,offset:0},L:{name:"L",base:N.VOLUME,prefixes:w.SHORT,value:.001,offset:0},l:{name:"l",base:N.VOLUME,prefixes:w.SHORT,value:.001,offset:0},litre:{name:"litre",base:N.VOLUME,prefixes:w.LONG,value:.001,offset:0},cuin:{name:"cuin",base:N.VOLUME,prefixes:w.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:N.VOLUME,prefixes:w.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:N.VOLUME,prefixes:w.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:N.VOLUME,prefixes:w.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:N.VOLUME,prefixes:w.NONE,value:15e-6,offset:0},drop:{name:"drop",base:N.VOLUME,prefixes:w.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:N.VOLUME,prefixes:w.NONE,value:5e-8,offset:0},minim:{name:"minim",base:N.VOLUME,prefixes:w.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:N.VOLUME,prefixes:w.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:N.VOLUME,prefixes:w.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:N.VOLUME,prefixes:w.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:N.VOLUME,prefixes:w.NONE,value:1e-6,offset:0},cup:{name:"cup",base:N.VOLUME,prefixes:w.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:N.VOLUME,prefixes:w.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:N.VOLUME,prefixes:w.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:N.VOLUME,prefixes:w.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:N.VOLUME,prefixes:w.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:N.VOLUME,prefixes:w.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:N.VOLUME,prefixes:w.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:N.VOLUME,prefixes:w.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:N.VOLUME,prefixes:w.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:N.VOLUME,prefixes:w.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:N.VOLUME,prefixes:w.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:N.VOLUME,prefixes:w.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:N.VOLUME,prefixes:w.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:N.VOLUME,prefixes:w.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:N.VOLUME,prefixes:w.NONE,value:.1173478,offset:0},obl:{name:"obl",base:N.VOLUME,prefixes:w.NONE,value:.1589873,offset:0},g:{name:"g",base:N.MASS,prefixes:w.SHORT,value:.001,offset:0},gram:{name:"gram",base:N.MASS,prefixes:w.LONG,value:.001,offset:0},ton:{name:"ton",base:N.MASS,prefixes:w.SHORT,value:907.18474,offset:0},tonne:{name:"tonne",base:N.MASS,prefixes:w.SHORT,value:1e3,offset:0},grain:{name:"grain",base:N.MASS,prefixes:w.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:N.MASS,prefixes:w.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:N.MASS,prefixes:w.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:N.MASS,prefixes:w.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:N.MASS,prefixes:w.NONE,value:45.359237,offset:0},stick:{name:"stick",base:N.MASS,prefixes:w.NONE,value:.115,offset:0},stone:{name:"stone",base:N.MASS,prefixes:w.NONE,value:6350,offset:0},gr:{name:"gr",base:N.MASS,prefixes:w.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:N.MASS,prefixes:w.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:N.MASS,prefixes:w.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:N.MASS,prefixes:w.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:N.MASS,prefixes:w.NONE,value:45.359237,offset:0},s:{name:"s",base:N.TIME,prefixes:w.SHORT,value:1,offset:0},min:{name:"min",base:N.TIME,prefixes:w.NONE,value:60,offset:0},h:{name:"h",base:N.TIME,prefixes:w.NONE,value:3600,offset:0},second:{name:"second",base:N.TIME,prefixes:w.LONG,value:1,offset:0},sec:{name:"sec",base:N.TIME,prefixes:w.LONG,value:1,offset:0},minute:{name:"minute",base:N.TIME,prefixes:w.NONE,value:60,offset:0},hour:{name:"hour",base:N.TIME,prefixes:w.NONE,value:3600,offset:0},day:{name:"day",base:N.TIME,prefixes:w.NONE,value:86400,offset:0},rad:{name:"rad",base:N.ANGLE,prefixes:w.NONE,value:1,offset:0},deg:{name:"deg",base:N.ANGLE,prefixes:w.NONE,value:.017453292519943295,offset:0},grad:{name:"grad",base:N.ANGLE,prefixes:w.NONE,value:.015707963267948967,offset:0},cycle:{name:"cycle",base:N.ANGLE,prefixes:w.NONE,value:6.283185307179586,offset:0},A:{name:"A",base:N.CURRENT,prefixes:w.SHORT,value:1,offset:0},ampere:{name:"ampere",base:N.CURRENT,prefixes:w.LONG,value:1,offset:0},K:{name:"K",base:N.TEMPERATURE,prefixes:w.NONE,value:1,offset:0},degC:{name:"degC",base:N.TEMPERATURE,prefixes:w.NONE,value:1,offset:273.15},degF:{name:"degF",base:N.TEMPERATURE,prefixes:w.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:N.TEMPERATURE,prefixes:w.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:N.TEMPERATURE,prefixes:w.NONE,value:1,offset:0},celsius:{name:"celsius",base:N.TEMPERATURE,prefixes:w.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:N.TEMPERATURE,prefixes:w.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:N.TEMPERATURE,prefixes:w.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:N.AMOUNT_OF_SUBSTANCE,prefixes:w.NONE,value:1,offset:0},mole:{name:"mole",base:N.AMOUNT_OF_SUBSTANCE,prefixes:w.NONE,value:1,offset:0},cd:{name:"cd",base:N.LUMINOUS_INTENSITY,prefixes:w.NONE,value:1,offset:0},candela:{name:"candela",base:N.LUMINOUS_INTENSITY,prefixes:w.NONE,value:1,offset:0},N:{name:"N",base:N.FORCE,prefixes:w.SHORT,value:1,offset:0 -},newton:{name:"newton",base:N.FORCE,prefixes:w.LONG,value:1,offset:0},lbf:{name:"lbf",base:N.FORCE,prefixes:w.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:N.FORCE,prefixes:w.NONE,value:4.4482216152605,offset:0},b:{name:"b",base:N.BIT,prefixes:w.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:N.BIT,prefixes:w.BINARY_LONG,value:1,offset:0},B:{name:"B",base:N.BIT,prefixes:w.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:N.BIT,prefixes:w.BINARY_LONG,value:8,offset:0}},_={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",litres:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",seconds:"second",minutes:"minute",hours:"hour",days:"day",radians:"rad",degrees:"deg",gradients:"grad",cycles:"cycle",amperes:"ampere",moles:"mole"};for(var O in _)if(_.hasOwnProperty(O)){var C=A[_[O]],S=Object.create(C);S.name=O,A[O]=S}A.lt=A.l,A.liter=A.litre,A.liters=A.litres,A.lb=A.lbm,A.lbs=A.lbm,n.PREFIXES=w,n.BASE_UNITS=N,n.UNITS=A,e.exports=n},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}var i=r(171),o=i.object,a=i.string;n.isHelp=function(e){return e instanceof n},n.prototype.toText=function(e){var t=this.doc||{},r="\n";if(t.name&&(r+="Name: "+t.name+"\n\n"),t.category&&(r+="Category: "+t.category+"\n\n"),t.description&&(r+="Description:\n "+t.description+"\n\n"),t.syntax&&(r+="Syntax:\n "+t.syntax.join("\n ")+"\n\n"),t.examples){var i=e&&e.parser();r+="Examples:\n";for(var o=0;o15?e:new a(e)},a}var i=r(351),o=r(175).digits;t.name="BigNumber",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}var a=n(r(118)),s=n(r(116)),u=1/Math.log((1+Math.sqrt(5))/2);o.prototype.insert=function(e,t){var r={key:e,value:t,degree:0};if(this._minimum){var n=this._minimum;r.left=n,r.right=n.right,n.right=r,r.right.left=r,a(e,n.key)&&(this._minimum=r)}else r.left=r,r.right=r,this._minimum=r;return this._size++,r},o.prototype.size=function(){return this._size},o.prototype.clear=function(){this._minimum=null,this._size=0},o.prototype.isEmpty=function(){return!!this._minimum},o.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var t=this._minimum,r=e.degree,n=e.child;r>0;){var i=n.right;n.left.right=n.right,n.right.left=n.left,n.left=t,n.right=t.right,t.right=n,n.right.left=n,n.parent=null,n=i,r--}return e.left.right=e.right,e.right.left=e.left,e==e.right?t=null:(t=e.right,t=m(t,this._size)),this._size--,this._minimum=t,e},o.prototype.remove=function(e){this._minimum=c(this._minimum,e,null),this.extractMinimum()};var c=function(e,t,r){t.key=r;var n=t.parent;return n&&a(t.key,n.key)&&(f(e,t,n),l(e,n)),a(t.key,e.key)&&(e=t),e},f=function(e,t,r){t.left.right=t.right,t.right.left=t.left,r.degree--,r.child==t&&(r.child=t.right),0===r.degree&&(r.child=null),t.left=e,t.right=e.right,e.right=t,t.right.left=t,t.parent=null,t.mark=!1},l=function(e,t){var r=t.parent;r&&(t.mark?(f(e,t,r),l(r)):t.mark=!0)},p=function(e,t){e.left.right=e.right,e.right.left=e.left,e.parent=t,t.child?(e.left=t.child,e.right=t.child.right,t.child.right=e,e.right.left=e):(t.child=e,e.right=e,e.left=e),t.degree++,e.mark=!1},m=function(e,t){var r=Math.floor(Math.log(t)*u)+1,n=new Array(r),i=0,o=e;if(o)for(i++,o=o.right;o!==e;)i++,o=o.right;for(var c;i>0;){for(var f=o.degree,l=o.right;;){if(c=n[f],!c)break;if(s(o.key,c.key)){var m=c;c=o,o=m}p(c,o),n[f]=null,f++}n[f]=o,o=l,i--}e=null;for(var h=0;r>h;h++)c=n[h],c&&(e?(c.left.right=c.right,c.right.left=c.left,c.left=e,c.right=e.right,e.right=c,c.right.left=c,a(c.key,e.key)&&(e=c)):e=c);return e};return o}t.name="FibonacciHeap",t.path="type",t.factory=n},function(e,t,r){"use strict";e.exports=function(){function e(t){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");t instanceof e?this.value=t.value:this.value=t}function t(t,r){var n=Array.prototype.slice;"function"==typeof r?e.prototype[t]=function(){var t=[this.value].concat(n.call(arguments,0));return new e(r.apply(this,t))}:e.prototype[t]=new e(r)}var n=r(176);return e.prototype.done=function(){return this.value},e.prototype.valueOf=function(){return this.value},e.prototype.toString=function(){return n.format(this.value)},e.createProxy=function(e,r){if("string"==typeof e)t(e,r);else for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])},e}},function(e,t,r){"use strict";function n(e,t,n,i){function x(t,r){if(1!=arguments.length&&2!=arguments.length)throw new o("parse",arguments.length,1,2);if(he=r&&r.nodes?r.nodes:{},a(t))return ge=t,T();if(Array.isArray(t)||t instanceof e.Matrix)return fe.deepMap(t,function(e){if(!a(e))throw new TypeError("String expected");return ge=e,T()});throw new TypeError("String or matrix expected")}function w(){ve=0,de=ge.charAt(0),we=0,be=null}function b(){ve++,de=ge.charAt(ve)}function N(){return ge.charAt(ve+1)}function E(){return ge.charAt(ve+2)}function M(){for(xe=le.NULL,ye="";" "==de||" "==de||"\n"==de&&we;)b();if("#"==de)for(;"\n"!=de&&""!=de;)b();if(""==de)return void(xe=le.DELIMITER);if("\n"==de&&!we)return xe=le.DELIMITER,ye=de,void b();var e=de+N(),t=e+E();if(3==t.length&&pe[t])return xe=le.DELIMITER,ye=t,b(),b(),void b();if(2==e.length&&pe[e])return xe=le.DELIMITER,ye=e,b(),void b();if(pe[de])return xe=le.DELIMITER,ye=de,void b();if(!S(de)){if(C(de)){for(;C(de)||z(de);)ye+=de,b();return void(xe=me[ye]?le.DELIMITER:le.SYMBOL)}for(xe=le.UNKNOWN;""!=de;)ye+=de,b();throw ue('Syntax error in part "'+ye+'"')}if(xe=le.NUMBER,"."==de)ye+=de,b(),z(de)||(xe=le.UNKNOWN);else{for(;z(de);)ye+=de,b();"."==de&&(ye+=de,b())}for(;z(de);)ye+=de,b();if(e=N(),("E"==de||"e"==de)&&(z(e)||"-"==e||"+"==e))for(ye+=de,b(),("+"==de||"-"==de)&&(ye+=de,b()),z(de)||(xe=le.UNKNOWN);z(de);)ye+=de,b()}function A(){do M();while("\n"==ye)}function _(){we++}function O(){we--}function C(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function S(e){return e>="0"&&"9">=e||"."==e}function z(e){return e>="0"&&"9">=e}function T(){w(),M();var e=B();if(""!=ye)throw xe==le.DELIMITER?ce("Unexpected operator "+ye):ue('Unexpected part "'+ye+'"');return e}function B(){var e,t,r=[];if(""==ye)return new l("undefined","undefined");for("\n"!=ye&&";"!=ye&&(e=I());"\n"==ye||";"==ye;)0==r.length&&e&&(t=";"!=ye,r.push({node:e,visible:t})),M(),"\n"!=ye&&";"!=ye&&""!=ye&&(e=I(),t=";"!=ye,r.push({node:e,visible:t}));return r.length>0?new c(r):e}function I(){if(xe==le.SYMBOL&&"function"==ye)throw ue('Deprecated keyword "function". Functions can now be assigned without it, like "f(x) = x^2".');return q()}function q(){var e,t,r,n,i=P();if("="==ye){if(i instanceof d)return e=i.name,A(),r=q(),new u(e,r);if(i instanceof m)return A(),r=q(),new y(i,r);if(i instanceof g&&(n=!0,t=[],e=i.name,i.args.forEach(function(e,r){e instanceof d?t[r]=e.name:n=!1}),n))return A(),r=q(),new p(e,t,r);throw ue("Invalid left hand side of assignment operator =")}return i}function P(){for(var e=U();"?"==ye;){var t=be;be=we,A();var r=e,n=U();if(":"!=ye)throw ue("False part of conditional expression expected");be=null,A();var i=P();e=new f(r,n,i),be=t}return e}function U(){for(var e=R();"or"==ye;)A(),e=new h("or","or",[e,R()]);return e}function R(){for(var e=L();"xor"==ye;)A(),e=new h("xor","xor",[e,L()]);return e}function L(){for(var e=k();"and"==ye;)A(),e=new h("and","and",[e,k()]);return e}function k(){for(var e=j();"|"==ye;)A(),e=new h("|","bitOr",[e,j()]);return e}function j(){for(var e=F();"^|"==ye;)A(),e=new h("^|","bitXor",[e,F()]);return e}function F(){for(var e=D();"&"==ye;)A(),e=new h("&","bitAnd",[e,D()]);return e}function D(){var e,t,r,n,i;for(e=G(),t={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};ye in t;)r=ye,n=t[r],A(),i=[e,G()],e=new h(r,n,i);return e}function G(){var e,t,r,n,i;for(e=V(),t={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};ye in t;)r=ye,n=t[r],A(),i=[e,V()],e=new h(r,n,i);return e}function V(){var e,t,r,n,i;for(e=Z(),t={to:"to","in":"to"};ye in t;)r=ye,n=t[r],A(),i=[e,Z()],e=new h(r,n,i);return e}function Z(){var e,t=[];if(e=":"==ye?new l("1","number"):W(),":"==ye&&be!==we){for(t.push(e);":"==ye&&t.length<3;)A(),t.push(")"==ye||"]"==ye||","==ye||""==ye?new d("end"):W());e=3==t.length?new v(t[0],t[2],t[1]):new v(t[0],t[1])}return e}function W(){var e,t,r,n,i;for(e=H(),t={"+":"add","-":"subtract"};ye in t;)r=ye,n=t[r],A(),i=[e,H()],e=new h(r,n,i);return e}function H(){var e,t,r,n,i;if(e=Y(),t={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"},ye in t)for(;ye in t;)r=ye,n=t[r],A(),i=[e,Y()],e=new h(r,n,i);return(xe==le.SYMBOL||"in"==ye&&e instanceof l||xe==le.NUMBER&&!(e instanceof l)||"("==ye||"["==ye)&&(e=new h("*","multiply",[e,H()])),e}function Y(){var e,t,r={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"}[ye];return r?(e=ye,A(),t=[Y()],new h(e,r,t)):X()}function X(){var e,t,r,n;return e=J(),("^"==ye||".^"==ye)&&(t=ye,r="^"==t?"pow":"dotPow",A(),n=[e,Y()],e=new h(t,r,n)),e}function J(){var e,t,r,n,i;for(e=Q(),t={"!":"factorial","'":"transpose"};ye in t;)r=ye,n=t[r],M(),i=[e],e=new h(r,n,i);return e}function Q(){var e,t=[];if(xe==le.SYMBOL&&he[ye]){if(e=he[ye],M(),"("==ye){if(t=[],_(),M(),")"!=ye)for(t.push(P());","==ye;)M(),t.push(P());if(")"!=ye)throw ue("Parenthesis ) expected");O(),M()}return new e(t)}return $()}function $(){var e,t;return xe==le.SYMBOL||xe==le.DELIMITER&&ye in me?(t=ye,M(),e=K(t),e=ee(e)):te()}function K(e){var t;if("("==ye){if(t=[],_(),M(),")"!=ye)for(t.push(P());","==ye;)M(),t.push(P());if(")"!=ye)throw ue("Parenthesis ) expected");return O(),M(),new g(e,t)}return new d(e)}function ee(e){for(var t;"["==ye;){if(t=[],_(),M(),"]"!=ye)for(t.push(P());","==ye;)M(),t.push(P());if("]"!=ye)throw ue("Parenthesis ] expected");O(),M(),e=new m(e,t)}return e}function te(){var e,t,r;if('"'==ye){for(t="",r="";""!=de&&('"'!=de||"\\"==r);)t+=de,r=de,b();if(M(),'"'!=ye)throw ue('End of string " expected');return M(),e=new l(t,"string"),e=ee(e)}return re()}function re(){var e,t,r,n;if("["==ye){if(_(),M(),"]"!=ye){var i=ne();if(";"==ye){for(r=1,t=[i];";"==ye;)M(),t[r]=ne(),r++;if("]"!=ye)throw ue("End of matrix ] expected");O(),M(),n=t[0].nodes.length;for(var o=1;r>o;o++)if(t[o].nodes.length!=n)throw ce("Column dimensions mismatch ("+t[o].nodes.length+" != "+n+")");e=new s(t)}else{if("]"!=ye)throw ue("End of matrix ] expected");O(),M(),e=i}}else O(),M(),e=new s([]);return e}return ie()}function ne(){for(var e=[q()],t=1;","==ye;)M(),e[t]=q(),t++;return new s(e)}function ie(){var e;return xe==le.NUMBER?(e=ye,M(),new l(e,"number")):oe()}function oe(){var e;if("("==ye){if(_(),M(),e=q(),")"!=ye)throw ue("Parenthesis ) expected");return O(),M(),e}return ae()}function ae(){throw ue(""==ye?"Unexpected end of expression":"Value expected")}function se(){return ve-ye.length+1}function ue(e){var t=se(),r=new SyntaxError(e+" (char "+t+")");return r["char"]=t,r}function ce(e){var t=se(),r=new Error(e+" (char "+t+")");return r["char"]=t,r}var fe=n(r(2)),le={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},pe={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"'":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},me={mod:!0,to:!0,"in":!0,and:!0,xor:!0,or:!0,not:!0},he={},ge="",ve=0,de="",ye="",xe=le.NULL,we=0,be=null;return x}var i=r(171),o=r(177),a=i.string.isString,s=r(178),u=r(179),c=r(180),f=r(181),l=r(182),p=r(183),m=r(184),h=r(185),g=r(186),v=r(187),d=r(188),y=r(189);t.name="parse",t.path="expression",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,o){function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this.scope={}}var s=n(r(13));return a.prototype.parse=function(e){throw new Error("Parser.parse is deprecated. Use math.parse instead.")},a.prototype.compile=function(e){throw new Error("Parser.compile is deprecated. Use math.compile instead.")},a.prototype.eval=function(e){return s(e).compile(o).eval(this.scope)},a.prototype.get=function(e){return this.scope[e]},a.prototype.set=function(e,t){return this.scope[e]=t},a.prototype.remove=function(e){delete this.scope[e]},a.prototype.clear=function(){for(var e in this.scope)this.scope.hasOwnProperty(e)&&delete this.scope[e]},a}t.name="Parser",t.path="expression",t.factory=n,t.math=!0},function(e,t,r){"use strict";t.ArrayNode=r(178),t.AssignmentNode=r(179),t.BlockNode=r(180),t.ConditionalNode=r(181),t.ConstantNode=r(182),t.IndexNode=r(184),t.FunctionAssignmentNode=r(183),t.FunctionNode=r(186),t.Node=r(190),t.OperatorNode=r(185),t.RangeNode=r(187),t.SymbolNode=r(188),t.UpdateNode=r(189)},function(e,t,r){t.e=r(191),t.E=r(191),t["false"]=r(192),t.i=r(193),t.Infinity=r(194),t.LN2=r(195),t.LN10=r(196),t.LOG2E=r(197),t.LOG10E=r(198),t.NaN=r(199),t["null"]=r(200),t.pi=r(201),t.PI=r(201),t.phi=r(202),t.SQRT1_2=r(203),t.SQRT2=r(204),t.tau=r(205),t["true"]=r(206),t.version=r(207),t.abs=r(219),t.add=r(220),t.ceil=r(221),t.cube=r(222),t.divide=r(223),t.dotDivide=r(224),t.dotMultiply=r(225),t.dotPow=r(226),t.exp=r(227),t.fix=r(228),t.floor=r(229),t.gcd=r(230),t.lcm=r(231),t.log=r(232),t.log10=r(233),t.mod=r(234),t.multiply=r(235),t.norm=r(236),t.nthRoot=r(237),t.pow=r(238),t.round=r(239),t.sign=r(240),t.sqrt=r(241),t.square=r(242),t.subtract=r(243),t.unaryMinus=r(244),t.unaryPlus=r(245),t.xgcd=r(246),t.bitAnd=r(247),t.bitNot=r(248),t.bitOr=r(249),t.bitXor=r(250),t.leftShift=r(251),t.rightArithShift=r(252),t.rightLogShift=r(253),t.arg=r(254),t.conj=r(255),t.re=r(256),t.im=r(257),t.bignumber=r(258),t["boolean"]=r(259),t.complex=r(260),t.index=r(261),t.matrix=r(262),t.number=r(263),t.sparse=r(264),t.string=r(265),t.unit=r(266),t.eval=r(267),t.help=r(268),t.and=r(269),t.not=r(270),t.or=r(271),t.xor=r(272),t.concat=r(273),t.cross=r(274),t.det=r(275),t.diag=r(276),t.dot=r(277),t.eye=r(278),t.flatten=r(279),t.inv=r(280),t.ones=r(281),t.range=r(282),t.resize=r(283),t.size=r(284),t.squeeze=r(285),t.subset=r(286),t.trace=r(287),t.transpose=r(288),t.zeros=r(289),t.combinations=r(290),t.factorial=r(291),t.gamma=r(292),t.permutations=r(293),t.pickRandom=r(294),t.random=r(295),t.randomInt=r(296),t.compare=r(297),t.deepEqual=r(298),t.equal=r(299),t.larger=r(300),t.largerEq=r(301),t.smaller=r(302),t.smallerEq=r(303),t.unequal=r(304),t.max=r(305),t.mean=r(306),t.median=r(307),t.min=r(308),t.prod=r(309),t.std=r(310),t.sum=r(311),t["var"]=r(312),t.acos=r(313),t.acosh=r(314),t.acot=r(315),t.acoth=r(316),t.acsc=r(317),t.acsch=r(318),t.asec=r(319),t.asech=r(320),t.asin=r(321),t.asinh=r(322),t.atan=r(323),t.atanh=r(324),t.atan2=r(325),t.cos=r(326),t.cosh=r(327),t.cot=r(328),t.coth=r(329),t.csc=r(330),t.csch=r(331),t.sec=r(332),t.sech=r(333),t.sin=r(334),t.sinh=r(335),t.tan=r(336),t.tanh=r(337),t.to=r(338),t.clone=r(339),t.map=r(340),t.filter=r(341),t.forEach=r(342),t.format=r(343),t["import"]=r(344),t.sort=r(345),t["typeof"]=r(346)},function(e,t,r){"use strict";function n(e,t,n){function g(e,t){if(!(this instanceof g))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!m(t))throw new Error("Invalid datatype: "+t);if(e instanceof x)w(this,e,t);else if(e&&f(e.index)&&f(e.ptr)&&f(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=t||e.datatype;else if(f(e))b(this,e,t);else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0],this._datatype=t}}var v=n(r(115)),d=e.Index,y=e.BigNumber,x=e.Matrix,w=function(e,t,r){"SparseMatrix"===t.type?(e._values=t._values?s.clone(t._values):void 0,e._index=s.clone(t._index),e._ptr=s.clone(t._ptr),e._size=s.clone(t._size),e._datatype=r||t._datatype):b(e,t.valueOf(),r||t._datatype)},b=function(e,t,r){e._values=[],e._index=[],e._ptr=[],e._datatype=r;var n=t.length,i=0;if(n>0){var o=0;do{e._ptr.push(e._values.length);for(var a=0;n>a;a++){var s=t[a];if(f(s)){if(0===o&&ii&&(i=1),v(s,0)||(e._values.push(s),e._index.push(a))}o++}while(i>o)}e._ptr.push(e._values.length),e._size=[n,i]};g.prototype=new x,g.prototype.type="SparseMatrix",g.prototype.storage=function(){return"sparse"},g.prototype.datatype=function(){return this._datatype},g.prototype.subset=function(e,t,r){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return N(this,e);case 2:case 3:return E(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}};var N=function(e,t){if(!(t instanceof d))throw new TypeError("Invalid index");var r=t.isScalar();if(r)return e.get(t.min());var n=t.size();if(n.length!=e._size.length)throw new o(n.length,e._size.length);for(var i=t.min(),a=t.max(),s=0,u=e._size.length;u>s;s++)h(i[s],e._size[s]),h(a[s],e._size[s]);var c=function(e){return e};return C(e,i[0],a[0],i[1],a[1],c,!1)},E=function(e,t,r,n){if(!(t instanceof d))throw new TypeError("Invalid index");var i,u=t.size(),c=t.isScalar();if(r instanceof x?(i=r.size(),r=r.toArray()):i=a.size(r),c){if(0!==i.length)throw new TypeError("Scalar expected");e.set(t.min(),r,n)}else{if(1!==u.length&&2!==u.length)throw new o(u.length,e._size.length,"<");if(i.length");for(var p=t.min()[0],m=t.min()[1],h=i[0],g=i[1],v=0;h>v;v++)for(var y=0;g>y;y++){var w=r[v][y];e.set([v+p,y+m],w,n)}}return e};g.prototype.get=function(e){if(!f(e))throw new TypeError("Array expected");if(e.length!=this._size.length)throw new o(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var t=e[0],r=e[1];h(t,this._size[0]),h(r,this._size[1]);var n=M(t,this._ptr[r],this._ptr[r+1],this._index);return na-1||i>s-1)&&(O(this,Math.max(n+1,a),Math.max(i+1,s),r),a=this._size[0],s=this._size[1]),h(n,a),h(i,s);var u=M(n,this._ptr[i],this._ptr[i+1],this._index);return un[r-1])return r;for(;r>t;){var i=~~((t+r)/2),o=n[i];if(o>e)r=i;else{if(!(e>o))return i;t=i+1}}return t},A=function(e,t,r,n,i){r.splice(e,1),n.splice(e,1);for(var o=t+1;ot)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(e)+")")});var n=r?this.clone():this;return O(n,e[0],e[1],t)};var O=function(e,t,r,n){var i,o,a,s=n||0,u=!v(s,0),c=e._size[0],f=e._size[1];if(r>f){for(o=f;r>o;o++)if(e._ptr[o]=e._values.length,u)for(i=0;c>i;i++)e._values.push(s),e._index.push(i);e._ptr[r]=e._values.length}else f>r&&(e._ptr.splice(r+1,f-r),e._values.splice(e._ptr[r],e._values.length),e._index.splice(e._ptr[r],e._index.length));if(f=r,t>c){if(u){var l=0;for(o=0;f>o;o++){e._ptr[o]=e._ptr[o]+l,a=e._ptr[o+1]+l;var p=0;for(i=c;t>i;i++,p++)e._values.splice(a+p,0,s),e._index.splice(a+p,0,i),l++}e._ptr[f]=e._values.length}}else if(c>t){var m=0;for(o=0;f>o;o++){e._ptr[o]=e._ptr[o]-m;var h=e._ptr[o],g=e._ptr[o+1]-m;for(a=h;g>a;a++)i=e._index[a],i>t-1&&(e._values.splice(a,1),e._index.splice(a,1),m++)}e._ptr[o]=e._values.length}return e._size[0]=t,e._size[1]=r,e};g.prototype.clone=function(){var e=new g({values:this._values?s.clone(this._values):void 0,index:s.clone(this._index),ptr:s.clone(this._ptr),size:s.clone(this._size)});return e},g.prototype.size=function(){return s.clone(this._size)},g.prototype.map=function(e,t){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var r=this,n=this._size[0],i=this._size[1],o=function(t,n,i){return e(t,[n,i],r)};return C(this,0,n-1,0,i-1,o,t)};var C=function(e,t,r,n,i,o,a){for(var s=[],u=[],c=[],f=function(e,t,r){e=o(e,t,r),v(e,0)||(s.push(e),u.push(t))},l=n;i>=l;l++){c.push(s.length);for(var p=e._ptr[l],m=e._ptr[l+1],h=t,d=p;m>d;d++){var y=e._index[d];if(y>=t&&r>=y){if(!a)for(var x=h;y>x;x++)f(0,x-t,l-n);f(e._values[d],y-t,l-n)}h=y+1}if(!a)for(var w=h;r>=w;w++)f(0,w-t,l-n)}return c.push(s.length),new g({values:s,index:u,ptr:c,size:[r-t+1,i-n+1]})};g.prototype.forEach=function(e,t){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var r=this,n=this._size[0],i=this._size[1],o=0;i>o;o++){for(var a=this._ptr[o],s=this._ptr[o+1],u=0,c=a;s>c;c++){var f=this._index[c];if(!t)for(var l=u;f>l;l++)e(0,[l,o],r);e(this._values[c],[f,o],r),u=f+1}if(!t)for(var p=u;n>p;p++)e(0,[p,o],r)}},g.prototype.toArray=function(){return S(this._values,this._index,this._ptr,this._size,!0)},g.prototype.valueOf=function(){return S(this._values,this._index,this._ptr,this._size,!1)};var S=function(e,t,r,n,i){var o,a,u=n[0],c=n[1],f=new Array(u);for(o=0;u>o;o++)for(f[o]=new Array(c),a=0;c>a;a++)f[o][a]=0;for(a=0;c>a;a++)for(var l=r[a],p=r[a+1],m=l;p>m;m++)o=t[m],f[o][a]=e?i?s.clone(e[m]):e[m]:1;return f};return g.prototype.format=function(e){for(var t=this._size[0],r=this._size[1],n=0!==t&&0!==r?this._index.length/(t*r):0,i="Sparse Matrix ["+u.format(t,e)+" x "+u.format(r,e)+"] density: "+u.format(n,e)+"\n",o=0;r>o;o++)for(var a=this._ptr[o],s=this._ptr[o+1],c=a;s>c;c++){var f=this._index[c];i+="\n ("+u.format(f,e)+", "+u.format(o,e)+") ==> "+(this._values?u.format(this._values[c],e):"X")}return i},g.prototype.toString=function(){return u.format(this.toArray())},g.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(e){if(e){if(e instanceof y&&(e=e.toNumber()),!l(e)||!p(e))throw new TypeError("The parameter k must be an integer number")}else e=0;var t=e>0?e:0,r=0>e?-e:0,n=this._size[0],i=this._size[1],o=Math.min(n-r,i-t),a=[],u=[],c=[];c[0]=0;for(var f=t;i>f&&a.lengthv;v++){var d=this._index[v];if(d===f-t+r){a.push(s.clone(this._values[v])),u[a.length-1]=d-r;break}}return c.push(a.length),new g({values:a,index:u,ptr:c,size:[o,1]})},g.fromJSON=function(e){return new g(e)},g.diagonal=function(e,t,r){if(!f(e))throw new TypeError("Array expected, size parameter");if(2!==e.length)throw new Error("Only two dimensions matrix are supported");if(e=e.map(function(e){if(e instanceof y&&(e=e.toNumber()),!l(e)||!p(e)||1>e)throw new Error("Size values must be positive integers");return e}),r){if(r instanceof y&&(r=r.toNumber()),!l(r)||!p(r))throw new TypeError("The parameter k must be an integer number")}else r=0;var n,i=r>0?r:0,o=0>r?-r:0,a=e[0],s=e[1],u=Math.min(a-o,s-i);if(f(t)){if(t.length!==u)throw new Error("Invalid value array length");n=function(e){return t[e]}}else if(t instanceof x){var c=t.size();if(1!==c.length||c[0]!==u)throw new Error("Invalid matrix length");n=function(e){return t.get([e])}}else n=function(){return t};for(var m=[],h=[],d=[],w=0;s>w;w++){d.push(m.length);var b=w-i;if(b>=0&&u>b){var N=n(b);v(N,0)||(h.push(b+o),m.push(N))}}return d.push(m.length),new g({values:m,index:h,ptr:d,size:[a,s]})},g.prototype.swapRows=function(e,t){if(!(l(e)&&p(e)&&l(t)&&p(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return h(e,this._size[0]),h(t,this._size[0]),g._swapRows(e,t,this._size[1],this._values,this._index,this._ptr),this},g._forEachRow=function(e,t,r,n,i){for(var o=n[e],a=n[e+1],s=o;a>s;s++)i(r[s],t[s])},g._swapRows=function(e,t,r,n,i,o){for(var a=0;r>a;a++){var s=o[a],u=o[a+1],c=M(e,s,u,i),f=M(t,s,u,i);if(u>c&&u>f&&i[c]===e&&i[f]===t){if(n){var l=n[c];n[c]=n[f],n[f]=l}}else if(u>c&&i[c]===e&&(f>=u||i[f]!==t)){var p=n?n[c]:void 0;i.splice(f,0,t),n&&n.splice(f,0,p),i.splice(c>=f?c+1:c,1),n&&n.splice(c>=f?c+1:c,1)}else if(u>f&&i[f]===t&&(c>=u||i[c]!==e)){var m=n?n[f]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(f>=c?f+1:f,1),n&&n.splice(f>=c?f+1:f,1)}}},x._storage.sparse=g,g}var i=r(171),o=r(174),a=i.array,s=i.object,u=i.string,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,m=u.isString,h=a.validateIndex;t.name="SparseMatrix",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,r){function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!m(t))throw new Error("Invalid datatype: "+t);if(e instanceof N)"DenseMatrix"===e.type?(this._data=u.clone(e._data),this._size=u.clone(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&f(e.data)&&f(e.size))this._data=e.data,this._size=e.size,this._datatype=t||e.datatype;else if(f(e))this._data=x(e),this._size=s.size(this._data),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._data=[],this._size=[0],this._datatype=t}}function c(e,t){if(!(t instanceof w))throw new TypeError("Invalid index");var r=t.isScalar();if(r)return e.get(t.min());var i=t.size();if(i.length!=e._size.length)throw new o(i.length,e._size.length);for(var a=t.min(),s=t.max(),u=0,c=e._size.length;c>u;u++)h(a[u],e._size[u]),h(s[u],e._size[u]);return new n(g(e._data,t,i.length,0))}function g(e,t,r,n){var i=n==r-1,o=t.range(n);return o.map(i?function(t){return e[t]}:function(i){var o=e[i];return g(o,t,r,n+1)})}function v(e,t,r,n){if(!(t instanceof w))throw new TypeError("Invalid index");var i,a=t.size(),c=t.isScalar();if(r instanceof N?(i=r.size(),r=r.valueOf()):i=s.size(r),c){if(0!==i.length)throw new TypeError("Scalar expected");e.set(t.min(),r,n)}else{if(a.length");var p=t.max().map(function(e){return e+1});y(e,p,n);var m=a.length,h=0;d(e._data,t,r,m,h)}return e}function d(e,t,r,n,i){var o=i==n-1,a=t.range(i);a.forEach(o?function(t,n){h(t),e[t]=r[n]}:function(o,a){h(o),d(e[o],t,r[a],n,i+1)})}function y(e,t,r){for(var n=u.clone(e._size),i=!1;n.lengtho;o++)t[o]>n[o]&&(n[o]=t[o],i=!0);i&&E(e,n,r)}function x(e){for(var t=0,r=e.length;r>t;t++){var n=e[t];f(n)?e[t]=x(n):n instanceof N&&(e[t]=x(n.valueOf()))}return e}var w=e.Index,b=e.BigNumber,N=e.Matrix;n.prototype=new N,n.prototype.type="DenseMatrix",n.prototype.storage=function(){return"dense"},n.prototype.datatype=function(){return this._datatype},n.prototype.subset=function(e,t,r){switch(arguments.length){case 1:return c(this,e);case 2:case 3:return v(this,e,t,r);default:throw new SyntaxError("Wrong number of arguments")}},n.prototype.get=function(e){if(!f(e))throw new TypeError("Array expected");if(e.length!=this._size.length)throw new o(e.length,this._size.length);for(var t=0;tn;n++){var a=e[n];h(a,r.length),r=r[a]}return u.clone(r)},n.prototype.set=function(e,t,r){if(!f(e))throw new TypeError("Array expected");if(e.lengthn;n++)a=e[n],h(a,u.length),u=u[a];return a=e[e.length-1],h(a,u.length),u[a]=t,this},n.prototype.resize=function(e,t,r){if(!f(e))throw new TypeError("Array expected");var n=r?this.clone():this;return E(n,e,t)};var E=function(e,t,r){if(0===t.length){for(var n=e._data;f(n);)n=n[0];return u.clone(n)}return e._size=u.clone(t),e._data=s.resize(e._data,e._size,r),e};return n.prototype.clone=function(){var e=new n({data:u.clone(this._data),size:u.clone(this._size),datatype:this._datatype});return e},n.prototype.size=function(){return this._size},n.prototype.map=function(e){var t=this,r=function(n,i){return f(n)?n.map(function(e,t){return r(e,i.concat(t))}):e(n,i,t)};return new n({data:r(this._data,[]),size:u.clone(this._size)})},n.prototype.forEach=function(e){var t=this,r=function(n,i){f(n)?n.forEach(function(e,t){r(e,i.concat(t))}):e(n,i,t)};r(this._data,[])},n.prototype.toArray=function(){return u.clone(this._data)},n.prototype.valueOf=function(){return this._data},n.prototype.format=function(e){return a.format(this._data,e)},n.prototype.toString=function(){return a.format(this._data)},n.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},n.prototype.diagonal=function(e){if(e){if(e instanceof b&&(e=e.toNumber()),!l(e)||!p(e))throw new TypeError("The parameter k must be an integer number")}else e=0;for(var t=e>0?e:0,r=0>e?-e:0,i=this._size[0],o=this._size[1],a=Math.min(i-r,o-t),s=[],c=0;a>c;c++)s[c]=u.clone(this._data[c+r][c+t]);return new n({data:s,size:[a]})},n.diagonal=function(t,r,i,o){if(!f(t))throw new TypeError("Array expected, size parameter");if(2!==t.length)throw new Error("Only two dimensions matrix are supported");if(t=t.map(function(e){if(e instanceof b&&(e=e.toNumber()),!l(e)||!p(e)||1>e)throw new Error("Size values must be positive integers");return e}),i){if(i instanceof b&&(i=i.toNumber()),!l(i)||!p(i))throw new TypeError("The parameter k must be an integer number")}else i=0;var a,u=i>0?i:0,c=0>i?-i:0,m=t[0],h=t[1],g=Math.min(m-c,h-u);if(f(r)){if(r.length!==g)throw new Error("Invalid value array length"); +!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):"object"==typeof exports?exports.math=r():e.math=r()}(this,function(){return function(e){function r(n){if(t[n])return t[n].exports;var i=t[n]={exports:{},id:n,loaded:!1};return e[n].call(i.exports,i,i.exports,r),i.loaded=!0,i.exports}var t={};return r.m=e,r.c=t,r.p="",r(0)}([function(e,r,t){function n(e){var r=i.create();return r.create=n,r["import"](t(2)),r["import"](t(3)),r["import"](t(4)),r["import"](t(5)),r["import"](t(6)),r["import"](t(12)),r["import"](t(13)),r["import"](t(14)),r["import"](t(7)),r["import"](t(8)),r["import"](t(9)),r["import"](t(10)),r["import"](t(11)),r["import"](t(15)),r["import"](t(17)),r["import"](t(18)),r["import"](t(19)),r["import"](t(20)),r["import"](t(21)),r["import"](t(22)),r["import"](t(23)),r["import"](t(24)),r["import"](t(25)),r["import"](t(26)),r["import"](t(27)),r["import"](t(28)),r["import"](t(29)),r["import"](t(30)),r["import"](t(31)),r["import"](t(32)),r.type.Chain=t(16)(),r.type.Chain.createProxy(r),r.config(e),r}var i=t(1);e.exports=n()},function(e,r,t){var n=t(33).isFactory;r.create=function(){function e(t){if(!n(t))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var u,c=r.indexOf(t);return-1===c?(u=t.math?t.factory(a.type,s,e,o,a):t.factory(a.type,s,e,o),r.push(t),i.push(u)):u=i[c],u}if("function"!=typeof Object.create)throw new Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var r=[],i=[],a={type:{}},o=t(34).create(a),s={matrix:"matrix",number:"number",precision:64,epsilon:1e-14};return a["import"]=e(t(35)),a.error=t(50),a}},function(e,r,t){"use strict";function n(e,r,n,s){function u(e,r,t){var n,i,a,o;if(0>=r){if(Array.isArray(e[0])){for(o=c(e),i=[],n=0;nt;t++){var o=[];for(r=0;n>r;r++)o.push(e[r][t]);a.push(o)}return a}var f=n(t(40)),l={};return l.isCollection=function(r){return Array.isArray(r)||r instanceof e.Matrix},l.deepMap=function p(e,r,t){return e&&"function"==typeof e.map?e.map(function(e){return p(e,r,t)}):r(e)},l.deepMap2=function m(r,t,n){var i,a,s;if(Array.isArray(r))if(Array.isArray(t)){if(r.length!=t.length)throw new o(r.length,t.length);for(i=[],a=r.length,s=0;a>s;s++)i[s]=m(r[s],t[s],n)}else{if(t instanceof e.Matrix)return i=m(r,t.valueOf(),n),f(i);for(i=[],a=r.length,s=0;a>s;s++)i[s]=m(r[s],t,n)}else{if(r instanceof e.Matrix)return t instanceof e.Matrix?(i=m(r.valueOf(),t.valueOf(),n),f(i)):(i=m(r.valueOf(),t,n),f(i));if(Array.isArray(t))for(i=[],a=t.length,s=0;a>s;s++)i[s]=m(r,t[s],n);else{if(t instanceof e.Matrix)return i=m(r,t.valueOf(),n),f(i);i=n(r,t)}}return i},l.reduce=function(r,t,n){var o=Array.isArray(r)?i(r):r.size();if(0>t)throw new a(t);if(t>=o.length)throw new a(t,o.length);return r instanceof e.Matrix?f(u(r.valueOf(),t,n)):u(r,t,n)},l.deepForEach=function h(r,t){r instanceof e.Matrix&&(r=r.valueOf());for(var n=0,i=r.length;i>n;n++){var a=r[n];Array.isArray(a)?h(a,t):t(a)}},l}var i=(t(36),t(37).size),a=t(38),o=t(39);r.name="collection",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function u(e,r){if(!(this instanceof u))throw new SyntaxError("Constructor must be called with the new operator");switch(arguments.length){case 0:this.re=0,this.im=0;break;case 1:var t=arguments[0];if("object"==typeof t){if("re"in t&&"im"in t){var n=new u(t.re,t.im);this.re=n.re,this.im=n.im;break}if("r"in t&&"phi"in t){var n=u.fromPolar(t.r,t.phi);this.re=n.re,this.im=n.im;break}}throw new SyntaxError("Object with the re and im or r and phi properties expected.");case 2:if(!o(e)||!o(r))throw new TypeError("Two numbers expected in Complex constructor");this.re=e,this.im=r;break;default:throw new SyntaxError("One, two or three arguments expected in Complex constructor")}}function c(){for(;" "==w||" "==w;)p()}function f(e){return e>="0"&&"9">=e||"."==e}function l(e){return e>="0"&&"9">=e}function p(){x++,w=y.charAt(x)}function m(e){x=e,w=y.charAt(x)}function h(){var e,r="";if(e=x,"+"==w?p():"-"==w&&(r+=w,p()),!f(w))return m(e),null;if("."==w){if(r+=w,p(),!l(w))return m(e),null}else{for(;l(w);)r+=w,p();"."==w&&(r+=w,p())}for(;l(w);)r+=w,p();if("E"==w||"e"==w){if(r+=w,p(),("+"==w||"-"==w)&&(r+=w,p()),!l(w))return m(e),null;for(;l(w);)r+=w,p()}return r}function g(){var e=y.charAt(x+1);if("I"==w||"i"==w)return p(),"1";if(!("+"!=w&&"-"!=w||"I"!=e&&"i"!=e)){var r="+"==w?"1":"-1";return p(),p(),r}return null}var v=n(t(7)),d=v.isUnit;u.isComplex=function(e){return e instanceof u};var y,x,w;return u.parse=function(e){if(y=e,x=-1,w="",!s(y))return null;p(),c();var r=h();if(r){if("I"==w||"i"==w)return p(),c(),w?null:new u(0,Number(r));c();var t=w;if("+"!=t&&"-"!=t)return c(),w?null:new u(Number(r),0);p(),c();var n=h();if(n){if("I"!=w&&"i"!=w)return null;p()}else if(n=g(),!n)return null;return"-"==t&&(n="-"==n[0]?"+"+n.substring(1):"-"+n),p(),c(),w?null:new u(Number(r),Number(n))}return(r=g())?(c(),w?null:new u(0,Number(r))):null},u.fromPolar=function(e){switch(arguments.length){case 1:var r=arguments[0];if("object"==typeof r)return u.fromPolar(r.r,r.phi);throw new TypeError("Input has to be an object with r and phi keys.");case 2:var t=arguments[0],n=arguments[1];if(o(t)){if(d(n)&&n.hasBase(v.BASE_UNITS.ANGLE)&&(n=n.toNumber("rad")),o(n))return new u(t*Math.cos(n),t*Math.sin(n));throw new TypeError("Phi is not a number nor an angle unit.")}throw new TypeError("Radius r is not a number.");default:throw new SyntaxError("Wrong number of arguments in function fromPolar")}},u.prototype.toPolar=function(){return{r:Math.sqrt(this.re*this.re+this.im*this.im),phi:Math.atan2(this.im,this.re)}},u.prototype.clone=function(){return new u(this.re,this.im)},u.prototype.equals=function(e){return this.re===e.re&&this.im===e.im},u.prototype.format=function(e){var r="",t=this.im,n=this.re,i=a.format(this.re,e),s=a.format(this.im,e),u=o(e)?e:e?e.precision:null;if(null!==u){var c=Math.pow(10,-u);Math.abs(n/t)0?1==t?i+" + i":i+" + "+s+"i":-1==t?i+" - i":i+" - "+s.substring(1)+"i"},u.prototype.toString=function(){return this.format()},u.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},u.fromJSON=function(e){return new u(e)},u.prototype.valueOf=u.prototype.toString,u}var i=t(36),a=i.number,o=i.number.isNumber,s=i.string.isString;r.name="Complex",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function a(e,r,t){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(null!=e&&"number"!=typeof e)throw new TypeError("Parameter start must be a number");if(null!=r&&"number"!=typeof r)throw new TypeError("Parameter end must be a number");if(null!=t&&"number"!=typeof t)throw new TypeError("Parameter step must be a number");this.start=null!=e?parseFloat(e):0,this.end=null!=r?parseFloat(r):0,this.step=null!=t?parseFloat(t):1}return a.parse=function(e){if("string"!=typeof e)return null;var r=e.split(":"),t=r.map(function(e){return parseFloat(e)}),n=t.some(function(e){return isNaN(e)});if(n)return null;switch(t.length){case 2:return new a(t[0],t[1]);case 3:return new a(t[0],t[2],t[1]);default:return null}},a.prototype.clone=function(){return new a(this.start,this.end,this.step)},a.isRange=function(e){return e instanceof a},a.prototype.size=function(){var e=0,r=this.start,t=this.step,n=this.end,a=n-r;return i.sign(t)==i.sign(a)?e=Math.ceil(a/t):0==a&&(e=0),isNaN(e)&&(e=0),[e]},a.prototype.min=function(){var e=this.size()[0];return e>0?this.step>0?this.start:this.start+(e-1)*this.step:void 0},a.prototype.max=function(){var e=this.size()[0];return e>0?this.step>0?this.start+(e-1)*this.step:this.start:void 0},a.prototype.forEach=function(e){var r=this.start,t=this.step,n=this.end,i=0;if(t>0)for(;n>r;)e(r,i,this),r+=t,i++;else if(0>t)for(;r>n;)e(r,i,this),r+=t,i++},a.prototype.map=function(e){var r=[];return this.forEach(function(t,n,i){r[n]=e(t,n,i)}),r},a.prototype.toArray=function(){var e=[];return this.forEach(function(r,t){e[t]=r}),e},a.prototype.valueOf=function(){return this.toArray()},a.prototype.format=function(e){var r=i.format(this.start,e);return 1!=this.step&&(r+=":"+i.format(this.step,e)),r+=":"+i.format(this.end,e)},a.prototype.toString=function(){return this.format()},a.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},a.fromJSON=function(e){return new a(e.start,e.end,e.step)},a}var i=t(41);r.name="Range",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");this._ranges=[],this._isScalar=!0;for(var r=0,t=arguments.length;t>r;r++){var n=arguments[r];if(n instanceof c)this._ranges.push(n),this._isScalar=!1;else if(Array.isArray(n))this._ranges.push(u(n)),this._isScalar=!1;else if("number"==typeof n)this._ranges.push(u([n,n+1]));else{var i=n.valueOf();if(!Array.isArray(i))throw new TypeError("Ranges must be an Array, Number, or Range");this._ranges.push(u(i)),this._isScalar=!1}}}function u(e){for(var r=e.length,t=0;r>t;t++)if("number"!=typeof e[t]||!o(e[t]))throw new TypeError("Index parameters must be integer numbers");switch(e.length){case 2:return new c(e[0],e[1]);case 3:return new c(e[0],e[1],e[2]);default:throw new SyntaxError("Wrong number of arguments in Index (2 or 3 expected)")}}var c=e.Range;return s.prototype.clone=function(){var e=new s;return e._ranges=i(this._ranges),e._isScalar=this._isScalar,e},s.isIndex=function(e){return e instanceof s},s.create=function(e){var r=new s;return s.apply(r,e),r},s.prototype.size=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r];e[r]=n.size()[0]}return e},s.prototype.max=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r];e[r]=n.max()}return e},s.prototype.min=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r];e[r]=n.min()}return e},s.prototype.forEach=function(e){for(var r=0,t=this._ranges.length;t>r;r++)e(this._ranges[r],r,this)},s.prototype.range=function(e){return this._ranges[e]||null},s.prototype.isScalar=function(){return this._isScalar},s.prototype.toArray=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r],i=[],a=n.start,o=n.end,s=n.step;if(s>0)for(;o>a;)i.push(a),a+=s;else if(0>s)for(;a>o;)i.push(a),a+=s;e.push(i)}return e},s.prototype.valueOf=s.prototype.toArray,s.prototype.toString=function(){for(var e=[],r=0,t=this._ranges.length;t>r;r++){var n=this._ranges[r],i=a(n.start);1!=n.step&&(i+=":"+a(n.step)),i+=":"+a(n.end),e.push(i)}return"["+e.join(", ")+"]"},s.prototype.toJSON=function(){return{mathjs:"Index",ranges:this._ranges}},s.fromJSON=function(e){return s.create(e.ranges)},s}var i=t(33).clone,a=t(41).format,o=t(41).isInteger;r.name="Index",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function i(){if(!(this instanceof i))throw new SyntaxError("Constructor must be called with the new operator")}return i.isMatrix=function(e){return e instanceof i},i.storage=function(e){if(!o(e))throw new TypeError("format must be a string value");var r=i._storage[e];if(!r)throw new SyntaxError("Unsupported matrix storage format: "+e);return r},i._storage={},i.prototype.storage=function(){throw new Error("Cannot invoke storage on a Matrix interface")},i.prototype.datatype=function(){throw new Error("Cannot invoke datatype on a Matrix interface")},i.prototype.subset=function(e,r,t){throw new Error("Cannot invoke subset on a Matrix interface")},i.prototype.get=function(e){throw new Error("Cannot invoke get on a Matrix interface")},i.prototype.set=function(e,r,t){throw new Error("Cannot invoke set on a Matrix interface")},i.prototype.resize=function(e,r){throw new Error("Cannot invoke resize on a Matrix interface")},i.prototype.clone=function(){throw new Error("Cannot invoke clone on a Matrix interface")},i.prototype.size=function(){throw new Error("Cannot invoke size on a Matrix interface")},i.prototype.map=function(e,r){throw new Error("Cannot invoke map on a Matrix interface")},i.prototype.forEach=function(e){throw new Error("Cannot invoke forEach on a Matrix interface")},i.prototype.toArray=function(){throw new Error("Cannot invoke toArray on a Matrix interface")},i.prototype.valueOf=function(){throw new Error("Cannot invoke valueOf on a Matrix interface")},i.prototype.format=function(e){throw new Error("Cannot invoke format on a Matrix interface")},i.prototype.toString=function(){throw new Error("Cannot invoke toString on a Matrix interface")},i}var i=t(36),a=i.string,o=a.isString;r.name="Matrix",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function o(e,r){if(!(this instanceof o))throw new Error("Constructor must be called with the new operator");if(void 0!=e&&"number"!=typeof e)throw new TypeError("First parameter in Unit constructor must be a number");if(void 0!=r&&("string"!=typeof r||""==r))throw new TypeError("Second parameter in Unit constructor must be a string");if(void 0!=r){var t=h(r);if(!t)throw new SyntaxError('Unknown unit "'+r+'"');this.unit=t.unit,this.prefix=t.prefix}else this.unit=N,this.prefix=x;this.value=void 0!=e?this._normalize(e):null,this.fixPrefix=!1}function s(){for(;" "==d||" "==d;)f()}function u(e){return e>="0"&&"9">=e||"."==e}function c(e){return e>="0"&&"9">=e}function f(){v++,d=g.charAt(v)}function l(e){v=e,d=g.charAt(v)}function p(){var e,r="";if(e=v,"+"==d?f():"-"==d&&(r+=d,f()),!u(d))return l(e),null;if("."==d){if(r+=d,f(),!c(d))return l(e),null}else{for(;c(d);)r+=d,f();"."==d&&(r+=d,f())}for(;c(d);)r+=d,f();if("E"==d||"e"==d){if(r+=d,f(),("+"==d||"-"==d)&&(r+=d,f()),!c(d))return l(e),null;for(;c(d);)r+=d,f()}return r}function m(){var e="";for(s();d&&" "!=d&&" "!=d;)e+=d,f();return e||null}function h(e){for(var r in E)if(E.hasOwnProperty(r)&&a(e,r)){var t=E[r],n=e.length-r.length,i=e.substring(0,n),o=t.prefixes[i];if(void 0!==o)return{unit:t,prefix:o}}return null}var g,v,d;o.parse=function(e){if(g=e,v=-1,d="","string"!=typeof g)return null;f(),s();var r,t=p();if(t){if(r=m(),f(),s(),d)return null;if(t&&r)try{return new o(Number(t),r)}catch(n){}}else{if(r=m(),f(),s(),d)return null;if(r)try{return new o(null,r)}catch(n){}}return null},o.isUnit=function(e){return e instanceof o},o.prototype.clone=function(){var e=new o;for(var r in this)this.hasOwnProperty(r)&&(e[r]=this[r]);return e},o.prototype._normalize=function(e){return(e+this.unit.offset)*this.unit.value*this.prefix.value},o.prototype._denormalize=function(e,r){return void 0==r?e/this.unit.value/this.prefix.value-this.unit.offset:e/this.unit.value/r-this.unit.offset},o.isValuelessUnit=function(e){return null!=h(e)},o.prototype.hasBase=function(e){return this.unit.base===e},o.prototype.equalBase=function(e){return this.unit.base===e.unit.base},o.prototype.equals=function(e){return this.equalBase(e)&&this.value==e.value},o.prototype.to=function(e){var r,t=null==this.value?this._normalize(1):this.value;if("string"==typeof e){if(r=new o(null,e),!this.equalBase(r))throw new Error("Units do not match");return r.value=t,r.fixPrefix=!0,r}if(e instanceof o){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");return r=e.clone(),r.value=t,r.fixPrefix=!0,r}throw new Error("String or Unit expected as parameter")},o.prototype.toNumber=function(e){var r=this.to(e);return r._denormalize(r.value,r.prefix.value)},o.prototype.toString=function(){return this.format()},o.prototype.toJSON=function(){return{mathjs:"Unit",value:this._denormalize(this.value),unit:this.prefix.name+this.unit.name,fixPrefix:this.fixPrefix}},o.fromJSON=function(e){var r=new o(e.value,e.unit);return r.fixPrefix=e.fixPrefix||!1,r},o.prototype.valueOf=o.prototype.toString,o.prototype.format=function(e){var r,t;if(null===this.value||this.fixPrefix)r=this._denormalize(this.value),t=null!==this.value?i(r,e)+" ":"",t+=this.prefix.name+this.unit.name;else{var n=this._bestPrefix();r=this._denormalize(this.value,n.value),t=i(r,e)+" ",t+=n.name+this.unit.name}return t},o.prototype._bestPrefix=function(){var e=Math.abs(this.value/this.unit.value),r=x,t=Math.abs(Math.log(e/r.value)/Math.LN10-1.2),n=this.unit.prefixes;for(var i in n)if(n.hasOwnProperty(i)){var a=n[i];if(a.scientific){var o=Math.abs(Math.log(e/a.value)/Math.LN10-1.2);t>o&&(r=a,t=o)}}return r};var y={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}},SQUARED:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:100,scientific:!1},h:{name:"h",value:1e4,scientific:!1},k:{name:"k",value:1e6,scientific:!0},M:{name:"M",value:1e12,scientific:!0},G:{name:"G",value:1e18,scientific:!0},T:{name:"T",value:1e24,scientific:!0},P:{name:"P",value:1e30,scientific:!0},E:{name:"E",value:1e36,scientific:!0},Z:{name:"Z",value:1e42,scientific:!0},Y:{name:"Y",value:1e48,scientific:!0},d:{name:"d",value:.01,scientific:!1},c:{name:"c",value:1e-4,scientific:!1},m:{name:"m",value:1e-6,scientific:!0},u:{name:"u",value:1e-12,scientific:!0},n:{name:"n",value:1e-18,scientific:!0},p:{name:"p",value:1e-24,scientific:!0},f:{name:"f",value:1e-30,scientific:!0},a:{name:"a",value:1e-36,scientific:!0},z:{name:"z",value:1e-42,scientific:!0},y:{name:"y",value:1e-42,scientific:!0}},CUBIC:{"":{name:"",value:1,scientific:!0},da:{name:"da",value:1e3,scientific:!1},h:{name:"h",value:1e6,scientific:!1},k:{name:"k",value:1e9,scientific:!0},M:{name:"M",value:1e18,scientific:!0},G:{name:"G",value:1e27,scientific:!0},T:{name:"T",value:1e36,scientific:!0},P:{name:"P",value:1e45,scientific:!0},E:{name:"E",value:1e54,scientific:!0},Z:{name:"Z",value:1e63,scientific:!0},Y:{name:"Y",value:1e72,scientific:!0},d:{name:"d",value:.001,scientific:!1},c:{name:"c",value:1e-6,scientific:!1},m:{name:"m",value:1e-9,scientific:!0},u:{name:"u",value:1e-18,scientific:!0},n:{name:"n",value:1e-27,scientific:!0},p:{name:"p",value:1e-36,scientific:!0},f:{name:"f",value:1e-45,scientific:!0},a:{name:"a",value:1e-54,scientific:!0},z:{name:"z",value:1e-63,scientific:!0},y:{name:"y",value:1e-72,scientific:!0}},BINARY_SHORT:{"":{name:"",value:1,scientific:!0},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},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: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},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}}},x={name:"",value:1,scientific:!0},w={NONE:{},LENGTH:{},MASS:{},TIME:{},CURRENT:{},TEMPERATURE:{},LUMINOUS_INTENSITY:{},AMOUNT_OF_SUBSTANCE:{},FORCE:{},SURFACE:{},VOLUME:{},ANGLE:{},BIT:{}},b={},N={name:"",base:b,value:1,offset:0},E={meter:{name:"meter",base:w.LENGTH,prefixes:y.LONG,value:1,offset:0},inch:{name:"inch",base:w.LENGTH,prefixes:y.NONE,value:.0254,offset:0},foot:{name:"foot",base:w.LENGTH,prefixes:y.NONE,value:.3048,offset:0},yard:{name:"yard",base:w.LENGTH,prefixes:y.NONE,value:.9144,offset:0},mile:{name:"mile",base:w.LENGTH,prefixes:y.NONE,value:1609.344,offset:0},link:{name:"link",base:w.LENGTH,prefixes:y.NONE,value:.201168,offset:0},rod:{name:"rod",base:w.LENGTH,prefixes:y.NONE,value:5.02921,offset:0},chain:{name:"chain",base:w.LENGTH,prefixes:y.NONE,value:20.1168,offset:0},angstrom:{name:"angstrom",base:w.LENGTH,prefixes:y.NONE,value:1e-10,offset:0},m:{name:"m",base:w.LENGTH,prefixes:y.SHORT,value:1,offset:0},"in":{name:"in",base:w.LENGTH,prefixes:y.NONE,value:.0254,offset:0},ft:{name:"ft",base:w.LENGTH,prefixes:y.NONE,value:.3048,offset:0},yd:{name:"yd",base:w.LENGTH,prefixes:y.NONE,value:.9144,offset:0},mi:{name:"mi",base:w.LENGTH,prefixes:y.NONE,value:1609.344,offset:0},li:{name:"li",base:w.LENGTH,prefixes:y.NONE,value:.201168,offset:0},rd:{name:"rd",base:w.LENGTH,prefixes:y.NONE,value:5.02921,offset:0},ch:{name:"ch",base:w.LENGTH,prefixes:y.NONE,value:20.1168,offset:0},mil:{name:"mil",base:w.LENGTH,prefixes:y.NONE,value:254e-7,offset:0},m2:{name:"m2",base:w.SURFACE,prefixes:y.SQUARED,value:1,offset:0},sqin:{name:"sqin",base:w.SURFACE,prefixes:y.NONE,value:64516e-8,offset:0},sqft:{name:"sqft",base:w.SURFACE,prefixes:y.NONE,value:.09290304,offset:0},sqyd:{name:"sqyd",base:w.SURFACE,prefixes:y.NONE,value:.83612736,offset:0},sqmi:{name:"sqmi",base:w.SURFACE,prefixes:y.NONE,value:2589988.110336,offset:0},sqrd:{name:"sqrd",base:w.SURFACE,prefixes:y.NONE,value:25.29295,offset:0},sqch:{name:"sqch",base:w.SURFACE,prefixes:y.NONE,value:404.6873,offset:0},sqmil:{name:"sqmil",base:w.SURFACE,prefixes:y.NONE,value:6.4516e-10,offset:0},m3:{name:"m3",base:w.VOLUME,prefixes:y.CUBIC,value:1,offset:0},L:{name:"L",base:w.VOLUME,prefixes:y.SHORT,value:.001,offset:0},l:{name:"l",base:w.VOLUME,prefixes:y.SHORT,value:.001,offset:0},litre:{name:"litre",base:w.VOLUME,prefixes:y.LONG,value:.001,offset:0},cuin:{name:"cuin",base:w.VOLUME,prefixes:y.NONE,value:16387064e-12,offset:0},cuft:{name:"cuft",base:w.VOLUME,prefixes:y.NONE,value:.028316846592,offset:0},cuyd:{name:"cuyd",base:w.VOLUME,prefixes:y.NONE,value:.764554857984,offset:0},teaspoon:{name:"teaspoon",base:w.VOLUME,prefixes:y.NONE,value:5e-6,offset:0},tablespoon:{name:"tablespoon",base:w.VOLUME,prefixes:y.NONE,value:15e-6,offset:0},drop:{name:"drop",base:w.VOLUME,prefixes:y.NONE,value:5e-8,offset:0},gtt:{name:"gtt",base:w.VOLUME,prefixes:y.NONE,value:5e-8,offset:0},minim:{name:"minim",base:w.VOLUME,prefixes:y.NONE,value:6.161152e-8,offset:0},fluiddram:{name:"fluiddram",base:w.VOLUME,prefixes:y.NONE,value:36966911e-13,offset:0},fluidounce:{name:"fluidounce",base:w.VOLUME,prefixes:y.NONE,value:2957353e-11,offset:0},gill:{name:"gill",base:w.VOLUME,prefixes:y.NONE,value:.0001182941,offset:0},cc:{name:"cc",base:w.VOLUME,prefixes:y.NONE,value:1e-6,offset:0},cup:{name:"cup",base:w.VOLUME,prefixes:y.NONE,value:.0002365882,offset:0},pint:{name:"pint",base:w.VOLUME,prefixes:y.NONE,value:.0004731765,offset:0},quart:{name:"quart",base:w.VOLUME,prefixes:y.NONE,value:.0009463529,offset:0},gallon:{name:"gallon",base:w.VOLUME,prefixes:y.NONE,value:.003785412,offset:0},beerbarrel:{name:"beerbarrel",base:w.VOLUME,prefixes:y.NONE,value:.1173478,offset:0},oilbarrel:{name:"oilbarrel",base:w.VOLUME,prefixes:y.NONE,value:.1589873,offset:0},hogshead:{name:"hogshead",base:w.VOLUME,prefixes:y.NONE,value:.238481,offset:0},fldr:{name:"fldr",base:w.VOLUME,prefixes:y.NONE,value:36966911e-13,offset:0},floz:{name:"floz",base:w.VOLUME,prefixes:y.NONE,value:2957353e-11,offset:0},gi:{name:"gi",base:w.VOLUME,prefixes:y.NONE,value:.0001182941,offset:0},cp:{name:"cp",base:w.VOLUME,prefixes:y.NONE,value:.0002365882,offset:0},pt:{name:"pt",base:w.VOLUME,prefixes:y.NONE,value:.0004731765,offset:0},qt:{name:"qt",base:w.VOLUME,prefixes:y.NONE,value:.0009463529,offset:0},gal:{name:"gal",base:w.VOLUME,prefixes:y.NONE,value:.003785412,offset:0},bbl:{name:"bbl",base:w.VOLUME,prefixes:y.NONE,value:.1173478,offset:0},obl:{name:"obl",base:w.VOLUME,prefixes:y.NONE,value:.1589873,offset:0},g:{name:"g",base:w.MASS,prefixes:y.SHORT,value:.001,offset:0},gram:{name:"gram",base:w.MASS,prefixes:y.LONG,value:.001,offset:0},ton:{name:"ton",base:w.MASS,prefixes:y.SHORT,value:907.18474,offset:0},tonne:{name:"tonne",base:w.MASS,prefixes:y.SHORT,value:1e3,offset:0},grain:{name:"grain",base:w.MASS,prefixes:y.NONE,value:6479891e-11,offset:0},dram:{name:"dram",base:w.MASS,prefixes:y.NONE,value:.0017718451953125,offset:0},ounce:{name:"ounce",base:w.MASS,prefixes:y.NONE,value:.028349523125,offset:0},poundmass:{name:"poundmass",base:w.MASS,prefixes:y.NONE,value:.45359237,offset:0},hundredweight:{name:"hundredweight",base:w.MASS,prefixes:y.NONE,value:45.359237,offset:0},stick:{name:"stick",base:w.MASS,prefixes:y.NONE,value:.115,offset:0},stone:{name:"stone",base:w.MASS,prefixes:y.NONE,value:6350,offset:0},gr:{name:"gr",base:w.MASS,prefixes:y.NONE,value:6479891e-11,offset:0},dr:{name:"dr",base:w.MASS,prefixes:y.NONE,value:.0017718451953125,offset:0},oz:{name:"oz",base:w.MASS,prefixes:y.NONE,value:.028349523125,offset:0},lbm:{name:"lbm",base:w.MASS,prefixes:y.NONE,value:.45359237,offset:0},cwt:{name:"cwt",base:w.MASS,prefixes:y.NONE,value:45.359237,offset:0},s:{name:"s",base:w.TIME,prefixes:y.SHORT,value:1,offset:0},min:{name:"min",base:w.TIME,prefixes:y.NONE,value:60,offset:0},h:{name:"h",base:w.TIME,prefixes:y.NONE,value:3600,offset:0},second:{name:"second",base:w.TIME,prefixes:y.LONG,value:1,offset:0},sec:{name:"sec",base:w.TIME,prefixes:y.LONG,value:1,offset:0},minute:{name:"minute",base:w.TIME,prefixes:y.NONE,value:60,offset:0},hour:{name:"hour",base:w.TIME,prefixes:y.NONE,value:3600,offset:0},day:{name:"day",base:w.TIME,prefixes:y.NONE,value:86400,offset:0},rad:{name:"rad",base:w.ANGLE,prefixes:y.NONE,value:1,offset:0},deg:{name:"deg",base:w.ANGLE,prefixes:y.NONE,value:.017453292519943295,offset:0},grad:{name:"grad",base:w.ANGLE,prefixes:y.NONE,value:.015707963267948967,offset:0},cycle:{name:"cycle",base:w.ANGLE,prefixes:y.NONE,value:6.283185307179586,offset:0},A:{name:"A",base:w.CURRENT,prefixes:y.SHORT,value:1,offset:0},ampere:{name:"ampere",base:w.CURRENT,prefixes:y.LONG,value:1,offset:0},K:{name:"K",base:w.TEMPERATURE,prefixes:y.NONE,value:1,offset:0},degC:{name:"degC",base:w.TEMPERATURE,prefixes:y.NONE,value:1,offset:273.15},degF:{name:"degF",base:w.TEMPERATURE,prefixes:y.NONE,value:1/1.8,offset:459.67},degR:{name:"degR",base:w.TEMPERATURE,prefixes:y.NONE,value:1/1.8,offset:0},kelvin:{name:"kelvin",base:w.TEMPERATURE,prefixes:y.NONE,value:1,offset:0},celsius:{name:"celsius",base:w.TEMPERATURE,prefixes:y.NONE,value:1,offset:273.15},fahrenheit:{name:"fahrenheit",base:w.TEMPERATURE,prefixes:y.NONE,value:1/1.8,offset:459.67},rankine:{name:"rankine",base:w.TEMPERATURE,prefixes:y.NONE,value:1/1.8,offset:0},mol:{name:"mol",base:w.AMOUNT_OF_SUBSTANCE,prefixes:y.NONE,value:1,offset:0},mole:{name:"mole",base:w.AMOUNT_OF_SUBSTANCE,prefixes:y.NONE,value:1,offset:0},cd:{name:"cd",base:w.LUMINOUS_INTENSITY,prefixes:y.NONE,value:1,offset:0},candela:{name:"candela",base:w.LUMINOUS_INTENSITY,prefixes:y.NONE,value:1,offset:0},N:{name:"N",base:w.FORCE,prefixes:y.SHORT,value:1,offset:0},newton:{name:"newton",base:w.FORCE,prefixes:y.LONG,value:1,offset:0},lbf:{name:"lbf",base:w.FORCE,prefixes:y.NONE,value:4.4482216152605,offset:0},poundforce:{name:"poundforce",base:w.FORCE,prefixes:y.NONE,value:4.4482216152605,offset:0},b:{name:"b",base:w.BIT,prefixes:y.BINARY_SHORT,value:1,offset:0},bits:{name:"bits",base:w.BIT,prefixes:y.BINARY_LONG,value:1,offset:0},B:{name:"B",base:w.BIT,prefixes:y.BINARY_SHORT,value:8,offset:0},bytes:{name:"bytes",base:w.BIT,prefixes:y.BINARY_LONG,value:8,offset:0}},M={meters:"meter",inches:"inch",feet:"foot",yards:"yard",miles:"mile",links:"link",rods:"rod",chains:"chain",angstroms:"angstrom",litres:"litre",teaspoons:"teaspoon",tablespoons:"tablespoon",minims:"minim",fluiddrams:"fluiddram",fluidounces:"fluidounce",gills:"gill",cups:"cup",pints:"pint",quarts:"quart",gallons:"gallon",beerbarrels:"beerbarrel",oilbarrels:"oilbarrel",hogsheads:"hogshead",gtts:"gtt",grams:"gram",tons:"ton",tonnes:"tonne",grains:"grain",drams:"dram",ounces:"ounce",poundmasses:"poundmass",hundredweights:"hundredweight",sticks:"stick",seconds:"second",minutes:"minute",hours:"hour",days:"day",radians:"rad",degrees:"deg",gradients:"grad",cycles:"cycle",amperes:"ampere",moles:"mole"};for(var A in M)if(M.hasOwnProperty(A)){var _=E[M[A]],O=Object.create(_);O.name=A,E[A]=O}return E.lt=E.l,E.liter=E.litre,E.liters=E.litres,E.lb=E.lbm,E.lbs=E.lbm,o.PREFIXES=y,o.BASE_UNITS=w,o.UNITS=E,o}var i=t(41).format,a=t(42).endsWith;r.name="Unit",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if(!e)throw new Error('Argument "doc" missing');this.doc=e}var u=n(t(43))();return s.isHelp=function(e){return e instanceof s},s.prototype.toString=function(){var e=this.doc||{},r="\n";if(e.name&&(r+="Name: "+e.name+"\n\n"),e.category&&(r+="Category: "+e.category+"\n\n"),e.description&&(r+="Description:\n "+e.description+"\n\n"),e.syntax&&(r+="Syntax:\n "+e.syntax.join("\n ")+"\n\n"),e.examples){r+="Examples:\n";for(var t=0;t15?e:new o(e)},o}var i=t(191),a=t(41).digits;r.name="BigNumber",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._minimum=null,this._size=0}var o=n(t(44)),s=n(t(45)),u=1/Math.log((1+Math.sqrt(5))/2);a.prototype.insert=function(e,r){var t={key:e,value:r,degree:0};if(this._minimum){var n=this._minimum;t.left=n,t.right=n.right,n.right=t,t.right.left=t,o(e,n.key)&&(this._minimum=t)}else t.left=t,t.right=t,this._minimum=t;return this._size++,t},a.prototype.size=function(){return this._size},a.prototype.clear=function(){this._minimum=null,this._size=0},a.prototype.isEmpty=function(){return!!this._minimum},a.prototype.extractMinimum=function(){var e=this._minimum;if(null===e)return e;for(var r=this._minimum,t=e.degree,n=e.child;t>0;){var i=n.right;n.left.right=n.right,n.right.left=n.left,n.left=r,n.right=r.right,r.right=n,n.right.left=n,n.parent=null,n=i,t--}return e.left.right=e.right,e.right.left=e.left,e==e.right?r=null:(r=e.right,r=m(r,this._size)),this._size--,this._minimum=r,e},a.prototype.remove=function(e){this._minimum=c(this._minimum,e,null),this.extractMinimum()};var c=function(e,r,t){r.key=t;var n=r.parent;return n&&o(r.key,n.key)&&(f(e,r,n),l(e,n)),o(r.key,e.key)&&(e=r),e},f=function(e,r,t){r.left.right=r.right,r.right.left=r.left,t.degree--,t.child==r&&(t.child=r.right),0===t.degree&&(t.child=null),r.left=e,r.right=e.right,e.right=r,r.right.left=r,r.parent=null,r.mark=!1},l=function(e,r){var t=r.parent;t&&(r.mark?(f(e,r,t),l(t)):r.mark=!0)},p=function(e,r){e.left.right=e.right,e.right.left=e.left,e.parent=r,r.child?(e.left=r.child,e.right=r.child.right,r.child.right=e,e.right.left=e):(r.child=e,e.right=e,e.left=e),r.degree++,e.mark=!1},m=function(e,r){var t=Math.floor(Math.log(r)*u)+1,n=new Array(t),i=0,a=e;if(a)for(i++,a=a.right;a!==e;)i++,a=a.right;for(var c;i>0;){for(var f=a.degree,l=a.right;;){if(c=n[f],!c)break;if(s(a.key,c.key)){var m=c;c=a,a=m}p(c,a),n[f]=null,f++}n[f]=a,a=l,i--}e=null;for(var h=0;t>h;h++)c=n[h],c&&(e?(c.left.right=c.right,c.right.left=c.left,c.left=e,c.right=e.right,e.right=c,c.right.left=c,o(c.key,e.key)&&(e=c)):e=c);return e};return a}r.name="FibonacciHeap",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,n){function g(e,r){if(!(this instanceof g))throw new SyntaxError("Constructor must be called with the new operator");if(r&&!m(r))throw new Error("Invalid datatype: "+r);if(e instanceof d)y(this,e,r);else if(e&&f(e.index)&&f(e.ptr)&&f(e.size))this._values=e.values,this._index=e.index,this._ptr=e.ptr,this._size=e.size,this._datatype=r||e.datatype;else if(f(e))x(this,e,r);else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._values=[],this._index=[],this._ptr=[0],this._size=[0],this._datatype=r}}var v=n(t(46)),d=e.Matrix,y=function(e,r,t){"SparseMatrix"===r.type?(e._values=r._values?s.clone(r._values):void 0,e._index=s.clone(r._index),e._ptr=s.clone(r._ptr),e._size=s.clone(r._size),e._datatype=t||r._datatype):x(e,r.valueOf(),t||r._datatype)},x=function(e,r,t){e._values=[],e._index=[],e._ptr=[],e._datatype=t;var n=r.length,i=0;if(n>0){var a=0;do{e._ptr.push(e._values.length);for(var o=0;n>o;o++){var s=r[o];if(f(s)){if(0===a&&ii&&(i=1),v(s,0)||(e._values.push(s),e._index.push(o))}a++}while(i>a)}e._ptr.push(e._values.length),e._size=[n,i]};g.prototype=new e.Matrix,g.prototype.type="SparseMatrix",g.prototype.storage=function(){return"sparse"},g.prototype.datatype=function(){return this._datatype},g.prototype.subset=function(e,r,t){if(!this._values)throw new Error("Cannot invoke subset on a Pattern only matrix");switch(arguments.length){case 1:return w(this,e);case 2:case 3:return b(this,e,r,t);default:throw new SyntaxError("Wrong number of arguments")}};var w=function(r,t){if(!(t instanceof e.Index))throw new TypeError("Invalid index");var n=t.isScalar();if(n)return r.get(t.min());var i=t.size();if(i.length!=r._size.length)throw new a(i.length,r._size.length);for(var o=t.min(),s=t.max(),u=0,c=r._size.length;c>u;u++)h(o[u],r._size[u]),h(s[u],r._size[u]);var f=function(e){return e};return _(r,o[0],s[0],o[1],s[1],f,!1)},b=function(r,t,n,i){if(!(t instanceof e.Index))throw new TypeError("Invalid index");var u,c=t.size(),f=t.isScalar();if(n instanceof e.Matrix?(u=n.size(),n=n.toArray()):u=o.size(n),f){if(0!==u.length)throw new TypeError("Scalar expected");r.set(t.min(),n,i)}else{if(1!==c.length&&2!==c.length)throw new a(c.length,r._size.length,"<");if(u.length");for(var m=t.min()[0],h=t.min()[1],g=u[0],v=u[1],d=0;g>d;d++)for(var y=0;v>y;y++){var x=n[d][y];r.set([d+m,y+h],x,i)}}return r};g.prototype.get=function(e){if(!f(e))throw new TypeError("Array expected");if(e.length!=this._size.length)throw new a(e.length,this._size.length);if(!this._values)throw new Error("Cannot invoke get on a Pattern only matrix");var r=e[0],t=e[1];h(r,this._size[0]),h(t,this._size[1]);var n=N(r,this._ptr[t],this._ptr[t+1],this._index);return no-1||i>s-1)&&(A(this,Math.max(n+1,o),Math.max(i+1,s),t),o=this._size[0],s=this._size[1]),h(n,o),h(i,s);var u=N(n,this._ptr[i],this._ptr[i+1],this._index);return un[t-1])return t;for(;t>r;){var i=~~((r+t)/2),a=n[i];if(a>e)t=i;else{if(!(e>a))return i;r=i+1}}return r},E=function(e,r,t,n,i){t.splice(e,1),n.splice(e,1);for(var a=r+1;ar)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(e)+")")});var n=t?this.clone():this;return A(n,e[0],e[1],r)};var A=function(e,r,t,n){var i,a,o,s=n||0,u=!v(s,0),c=e._size[0],f=e._size[1];if(t>f){for(a=f;t>a;a++)if(e._ptr[a]=e._values.length,u)for(i=0;c>i;i++)e._values.push(s),e._index.push(i);e._ptr[t]=e._values.length}else f>t&&(e._ptr.splice(t+1,f-t),e._values.splice(e._ptr[t],e._values.length),e._index.splice(e._ptr[t],e._index.length));if(f=t,r>c){if(u){var l=0;for(a=0;f>a;a++){e._ptr[a]=e._ptr[a]+l,o=e._ptr[a+1]+l;var p=0;for(i=c;r>i;i++,p++)e._values.splice(o+p,0,s),e._index.splice(o+p,0,i),l++}e._ptr[f]=e._values.length}}else if(c>r){var m=0;for(a=0;f>a;a++){e._ptr[a]=e._ptr[a]-m;var h=e._ptr[a],g=e._ptr[a+1]-m;for(o=h;g>o;o++)i=e._index[o],i>r-1&&(e._values.splice(o,1),e._index.splice(o,1),m++)}e._ptr[a]=e._values.length}return e._size[0]=r,e._size[1]=t,e};g.prototype.clone=function(){var e=new g({values:this._values?s.clone(this._values):void 0,index:s.clone(this._index),ptr:s.clone(this._ptr),size:s.clone(this._size),datatype:this._datatype});return e},g.prototype.size=function(){return s.clone(this._size)},g.prototype.map=function(e,r){if(!this._values)throw new Error("Cannot invoke map on a Pattern only matrix");var t=this,n=this._size[0],i=this._size[1],a=function(r,n,i){return e(r,[n,i],t)};return _(this,0,n-1,0,i-1,a,r)};var _=function(e,r,t,n,i,a,o){for(var s=[],u=[],c=[],f=function(e,r,t){e=a(e,r,t),v(e,0)||(s.push(e),u.push(r))},l=n;i>=l;l++){c.push(s.length);for(var p=e._ptr[l],m=e._ptr[l+1],h=r,d=p;m>d;d++){var y=e._index[d];if(y>=r&&t>=y){if(!o)for(var x=h;y>x;x++)f(0,x-r,l-n);f(e._values[d],y-r,l-n)}h=y+1}if(!o)for(var w=h;t>=w;w++)f(0,w-r,l-n)}return c.push(s.length),new g({values:s,index:u,ptr:c,size:[t-r+1,i-n+1]})};g.prototype.forEach=function(e,r){if(!this._values)throw new Error("Cannot invoke forEach on a Pattern only matrix");for(var t=this,n=this._size[0],i=this._size[1],a=0;i>a;a++){for(var o=this._ptr[a],s=this._ptr[a+1],u=0,c=o;s>c;c++){var f=this._index[c];if(!r)for(var l=u;f>l;l++)e(0,[l,a],t);e(this._values[c],[f,a],t),u=f+1}if(!r)for(var p=u;n>p;p++)e(0,[p,a],t)}},g.prototype.toArray=function(){return O(this._values,this._index,this._ptr,this._size,!0)},g.prototype.valueOf=function(){return O(this._values,this._index,this._ptr,this._size,!1)};var O=function(e,r,t,n,i){var a,o,u=n[0],c=n[1],f=new Array(u);for(a=0;u>a;a++)for(f[a]=new Array(c),o=0;c>o;o++)f[a][o]=0;for(o=0;c>o;o++)for(var l=t[o],p=t[o+1],m=l;p>m;m++)a=r[m],f[a][o]=e?i?s.clone(e[m]):e[m]:1;return f};return g.prototype.format=function(e){for(var r=this._size[0],t=this._size[1],n=0!==r&&0!==t?this._index.length/(r*t):0,i="Sparse Matrix ["+u.format(r,e)+" x "+u.format(t,e)+"] density: "+u.format(n,e)+"\n",a=0;t>a;a++)for(var o=this._ptr[a],s=this._ptr[a+1],c=o;s>c;c++){var f=this._index[c];i+="\n ("+u.format(f,e)+", "+u.format(a,e)+") ==> "+(this._values?u.format(this._values[c],e):"X")}return i},g.prototype.toString=function(){return u.format(this.toArray())},g.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(r){if(r){if(r instanceof e.BigNumber&&(r=r.toNumber()),!l(r)||!p(r))throw new TypeError("The parameter k must be an integer number")}else r=0;var t=r>0?r:0,n=0>r?-r:0,i=this._size[0],a=this._size[1],o=Math.min(i-n,a-t),u=[],c=[],f=[];f[0]=0;for(var m=t;a>m&&u.lengthd;d++){var y=this._index[d];if(y===m-t+n){u.push(s.clone(this._values[d])),c[u.length-1]=y-n;break}}return f.push(u.length),new g({values:u,index:c,ptr:f,size:[o,1]})},g.fromJSON=function(e){return new g(e)},g.diagonal=function(r,t,n){if(!f(r))throw new TypeError("Array expected, size parameter");if(2!==r.length)throw new Error("Only two dimensions matrix are supported");if(r=r.map(function(r){if(r instanceof e.BigNumber&&(r=r.toNumber()),!l(r)||!p(r)||1>r)throw new Error("Size values must be positive integers");return r}),n){if(n instanceof e.BigNumber&&(n=n.toNumber()),!l(n)||!p(n))throw new TypeError("The parameter k must be an integer number")}else n=0;var i,a=n>0?n:0,o=0>n?-n:0,s=r[0],u=r[1],c=Math.min(s-o,u-a);if(f(t)){if(t.length!==c)throw new Error("Invalid value array length");i=function(e){return t[e]}}else if(t instanceof e.Matrix){var m=t.size();if(1!==m.length||m[0]!==c)throw new Error("Invalid matrix length");i=function(e){return t.get([e])}}else i=function(){return t};for(var h=[],d=[],y=[],x=0;u>x;x++){y.push(h.length);var w=x-a;if(w>=0&&c>w){var b=i(w);v(b,0)||(d.push(w+o),h.push(b))}}return y.push(h.length),new g({values:h,index:d,ptr:y,size:[s,u]})},g.prototype.swapRows=function(e,r){if(!(l(e)&&p(e)&&l(r)&&p(r)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return h(e,this._size[0]),h(r,this._size[0]),g._swapRows(e,r,this._size[1],this._values,this._index,this._ptr),this},g._forEachRow=function(e,r,t,n,i){for(var a=n[e],o=n[e+1],s=a;o>s;s++)i(t[s],r[s])},g._swapRows=function(e,r,t,n,i,a){for(var o=0;t>o;o++){var s=a[o],u=a[o+1],c=N(e,s,u,i),f=N(r,s,u,i);if(u>c&&u>f&&i[c]===e&&i[f]===r){if(n){var l=n[c];n[c]=n[f],n[f]=l}}else if(u>c&&i[c]===e&&(f>=u||i[f]!==r)){var p=n?n[c]:void 0;i.splice(f,0,r),n&&n.splice(f,0,p),i.splice(c>=f?c+1:c,1),n&&n.splice(c>=f?c+1:c,1)}else if(u>f&&i[f]===r&&(c>=u||i[c]!==e)){var m=n?n[f]:void 0;i.splice(c,0,e),n&&n.splice(c,0,m),i.splice(f>=c?f+1:f,1),n&&n.splice(f>=c?f+1:f,1)}}},e.Matrix._storage.sparse=g,g}var i=t(36),a=t(39),o=i.array,s=i.object,u=i.string,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,m=u.isString,h=o.validateIndex;r.name="SparseMatrix",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e){function r(e,t){if(!(this instanceof r))throw new SyntaxError("Constructor must be called with the new operator");if(t&&!m(t))throw new Error("Invalid datatype: "+t);if(e instanceof y)"DenseMatrix"===e.type?(this._data=u.clone(e._data),this._size=u.clone(e._size),this._datatype=t||e._datatype):(this._data=e.toArray(),this._size=e.size(),this._datatype=t||e._datatype);else if(e&&f(e.data)&&f(e.size))this._data=e.data,this._size=e.size,this._datatype=t||e.datatype;else if(f(e))this._data=d(e),this._size=s.size(this._data),this._datatype=t;else{if(e)throw new TypeError("Unsupported type of data ("+i.types.type(e)+")");this._data=[],this._size=[0],this._datatype=t}}function t(t,i){if(!(i instanceof e.Index))throw new TypeError("Invalid index");var o=i.isScalar();if(o)return t.get(i.min());var s=i.size();if(s.length!=t._size.length)throw new a(s.length,t._size.length);for(var u=i.min(),c=i.max(),f=0,l=t._size.length;l>f;f++)h(u[f],t._size[f]),h(c[f],t._size[f]);return new r(n(t._data,i,s.length,0))}function n(e,r,t,i){var a=i==t-1,o=r.range(i);return o.map(a?function(r){return e[r]}:function(a){var o=e[a];return n(o,r,t,i+1)})}function c(r,t,n,i){if(!(t instanceof e.Index))throw new TypeError("Invalid index");var o,c=t.size(),f=t.isScalar();if(n instanceof e.Matrix?(o=n.size(),n=n.valueOf()):o=s.size(n),f){if(0!==o.length)throw new TypeError("Scalar expected");r.set(t.min(),n,i)}else{if(c.length");var m=t.max().map(function(e){return e+1});v(r,m,i);var h=c.length,d=0;g(r._data,t,n,h,d)}return r}function g(e,r,t,n,i){var a=i==n-1,o=r.range(i);o.forEach(a?function(r,n){h(r),e[r]=t[n]}:function(a,o){h(a),g(e[a],r,t[o],n,i+1)})}function v(e,r,t){for(var n=u.clone(e._size),i=!1;n.lengtha;a++)r[a]>n[a]&&(n[a]=r[a],i=!0);i&&x(e,n,t)}function d(r){for(var t=0,n=r.length;n>t;t++){var i=r[t];f(i)?r[t]=d(i):i instanceof e.Matrix&&(r[t]=d(i.valueOf()))}return r}var y=e.Matrix;r.prototype=new y,r.prototype.type="DenseMatrix",r.prototype.storage=function(){return"dense"},r.prototype.datatype=function(){return this._datatype},r.prototype.subset=function(e,r,n){switch(arguments.length){case 1:return t(this,e);case 2:case 3:return c(this,e,r,n);default:throw new SyntaxError("Wrong number of arguments")}},r.prototype.get=function(e){if(!f(e))throw new TypeError("Array expected");if(e.length!=this._size.length)throw new a(e.length,this._size.length);for(var r=0;rn;n++){var o=e[n];h(o,t.length),t=t[o]}return u.clone(t)},r.prototype.set=function(e,r,t){if(!f(e))throw new TypeError("Array expected");if(e.lengthn;n++)o=e[n],h(o,u.length),u=u[o];return o=e[e.length-1],h(o,u.length),u[o]=r,this},r.prototype.resize=function(e,r,t){if(!f(e))throw new TypeError("Array expected");var n=t?this.clone():this;return x(n,e,r)};var x=function(e,r,t){if(0===r.length){for(var n=e._data;f(n);)n=n[0];return u.clone(n)}return e._size=u.clone(r),e._data=s.resize(e._data,e._size,t),e};return r.prototype.clone=function(){var e=new r({data:u.clone(this._data),size:u.clone(this._size),datatype:this._datatype});return e},r.prototype.size=function(){return this._size},r.prototype.map=function(e){var t=this,n=function(r,i){return f(r)?r.map(function(e,r){return n(e,i.concat(r))}):e(r,i,t)};return new r({data:n(this._data,[]),size:u.clone(this._size)})},r.prototype.forEach=function(e){var r=this,t=function(n,i){f(n)?n.forEach(function(e,r){t(e,i.concat(r))}):e(n,i,r)};t(this._data,[])},r.prototype.toArray=function(){return u.clone(this._data)},r.prototype.valueOf=function(){return this._data},r.prototype.format=function(e){return o.format(this._data,e)},r.prototype.toString=function(){return o.format(this._data)},r.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},r.prototype.diagonal=function(t){if(t){if(t instanceof e.BigNumber&&(t=t.toNumber()),!l(t)||!p(t))throw new TypeError("The parameter k must be an integer number")}else t=0;for(var n=t>0?t:0,i=0>t?-t:0,a=this._size[0],o=this._size[1],s=Math.min(a-i,o-n),c=[],f=0;s>f;f++)c[f]=u.clone(this._data[f+i][f+n]);return new r({data:c,size:[s]})},r.diagonal=function(t,n,i,a){if(!f(t))throw new TypeError("Array expected, size parameter");if(2!==t.length)throw new Error("Only two dimensions matrix are supported");if(t=t.map(function(r){if(r instanceof e.BigNumber&&(r=r.toNumber()),!l(r)||!p(r)||1>r)throw new Error("Size values must be positive integers");return r}),i){if(i instanceof e.BigNumber&&(i=i.toNumber()),!l(i)||!p(i))throw new TypeError("The parameter k must be an integer number")}else i=0;var o,u=i>0?i:0,c=0>i?-i:0,m=t[0],h=t[1],g=Math.min(m-c,h-u);if(f(n)){if(n.length!==g)throw new Error("Invalid value array length");o=function(e){return n[e]}}else if(n instanceof e.Matrix){var v=n.size();if(1!==v.length||v[0]!==g)throw new Error("Invalid matrix length");o=function(e){return n.get([e])}}else o=function(){return n};a||(a=o(0)instanceof e.BigNumber?new e.BigNumber(0):0);var d=[];if(t.length>0){d=s.resize(d,t,a);for(var y=0;g>y;y++)d[y+c][y+u]=o(y)}return new r({data:d,size:[m,h]})},r.fromJSON=function(e){return new r(e)},r.prototype.swapRows=function(e,t){if(!(l(e)&&p(e)&&l(t)&&p(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return h(e,this._size[0]),h(t,this._size[0]),r._swapRows(e,t,this._data),this},r._swapRows=function(e,r,t){var n=t[e];t[e]=t[r],t[r]=n},e.Matrix._storage.dense=r,e.Matrix._storage["default"]=r,r}var i=t(36),a=t(39),o=i.string,s=i.array,u=i.object,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,m=o.isString,h=s.validateIndex;r.name="DenseMatrix",r.path="type",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=new Array(r),this._heap=new e.FibonacciHeap}var o=n(t(47)),s=n(t(46));return a.prototype.set=function(e,r){if(this._values[e])this._values[e].value=r;else{var t=this._heap.insert(e,r);this._values[e]=t}},a.prototype.get=function(e){var r=this._values[e];return r?r.value:0},a.prototype.accumulate=function(e,r){var t=this._values[e];t?t.value=o(t.value,r):(t=this._heap.insert(e,r),this._values[e]=t)},a.prototype.forEach=function(e,r,t){var n=this._heap,i=this._values,a=[],o=n.extractMinimum();for(o&&a.push(o);o&&o.key<=r;)o.key>=e&&(s(o.value,0)||t(o.key,o.value,this)),o=n.extractMinimum(),o&&a.push(o);for(var u=0;ui;i++)if(!r.deepEqual(e[i],t[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(t)||!(t instanceof Object))return!1;for(n in e)if(!r.deepEqual(e[n],t[n]))return!1;for(n in t)if(!r.deepEqual(e[n],t[n]))return!1;return!0}return typeof e==typeof t&&e==t},r.canDefineProperty=function(){try{if(Object.defineProperty)return Object.defineProperty({},"x",{}),!0}catch(e){}return!1},r.lazy=function(e,t,n){if(r.canDefineProperty()){var i,a=!0;Object.defineProperty(e,t,{get:function(){return a&&(i=n(),a=!1),i},set:function(e){i=e,a=!1},configurable:!0})}else e[t]=n()},r.traverse=function(e,r){var t=e;if(r)for(var n=r.split("."),i=0;i15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+r+"). Use function bignumber(x) to convert to BigNumber.");return new e.type.BigNumber(r)}},{from:"number",to:"Complex",convert:function(r){return new e.type.Complex(r,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(r){return new e.type.Complex(r.toNumber(),0)}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(r){return new e.type.BigNumber(+r)}},{from:"boolean",to:"string",convert:function(e){return+e}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new e.type.BigNumber(0)}},{from:"Array",to:"Matrix",convert:function(r){return new e.type.Matrix(r)}}],n}},function(e,r,t){"use strict";function n(e,r,n,o,s){function u(e,r){var n=arguments.length;if(1!=n&&2!=n)throw new s.error.ArgumentsError("import",n,1,2);var a,o={override:r&&r.override||!1,wrap:r&&r.wrap||!1};if("string"==typeof e){var p=t(186)(e);return u(p,r)}if(i(e))return f(e);if(Array.isArray(e))return e.map(function(e){return u(e,r)});if("object"==typeof e){var m={};for(a in e)if(e.hasOwnProperty(a)){var h=e[a];l(h)?m[a]=c(a,h,o):i(e)?m[a]=f(e):m[a]=u(h,r)}return m}throw new TypeError("Object or module name expected")}function c(e,r,t){return t.override||void 0===s[e]?(t.wrap&&"function"==typeof r?(s[e]=function(){for(var e=[],t=0,n=arguments.length;n>t;t++){var i=arguments[t];e[t]=i&&i.valueOf()}return r.apply(s,e)},r&&r.transform&&(s[e].transform=r.transform)):s[e]=r,s.type.Chain.createProxy(e,r),r):void 0}function f(e){var r=n(e);if("string"==typeof e.name){var t=e.path?a(s,e.path):s;if(t[e.name])throw new Error('"'+e.name+'" already exists');t[e.name]=r}return r}function l(r){return"function"==typeof r||"number"==typeof r||"string"==typeof r||"boolean"==typeof r||null===r||r instanceof e.Unit||r instanceof e.Complex}return u}var i=t(33).isFactory,a=t(33).traverse;r.math=!0,r.name="import",r.factory=n},function(e,r,t){"use strict";r.array=t(37),r["boolean"]=t(187),r["function"]=t(188),r.number=t(41),r.bignumber=t(48),r.object=t(33),r.string=t(42),r.types=t(189)},function(e,r,t){"use strict";function n(e){for(var r=[];Array.isArray(e);)r.push(e.length),e=e[0];return r}function i(e,r,t){var n,a=e.length;if(a!=r[t])throw new l(a,r[t]);if(tn;n++){var s=e[n];if(!Array.isArray(s))throw new l(r.length-1,r.length,"<");i(e[n],r,o)}}else for(n=0;a>n;n++)if(Array.isArray(e[n]))throw new l(r.length+1,r.length,">")}function a(e,t,n,i){var o,s,u=e.length,c=t[n],l=Math.min(u,c);if(e.length=c,no;o++)s=e[o],Array.isArray(s)||(s=[s],e[o]=s),a(s,t,p,i);for(o=l;c>o;o++)s=[],e[o]=s,a(s,t,p,i)}else{for(o=0;l>o;o++)for(;Array.isArray(e[o]);)e[o]=e[o][0];if(i!==r.UNINITIALIZED)for(o=l;c>o;o++)e[o]=f.clone(i)}}function o(e,r,t){var n,i;if(r>t){var a=t+1;for(n=0,i=e.length;i>n;n++)e[n]=o(e[n],r,a)}else for(;Array.isArray(e);)e=e[0];return e}function s(e,r,t){var n,i;if(Array.isArray(e)){var a=t+1;for(n=0,i=e.length;i>n;n++)e[n]=s(e[n],r,a)}else for(var o=t;r>o;o++)e=[e];return e}var u=t(41),c=t(42),f=t(33),l=(t(189),t(39)),p=t(38);r.size=function(e){var t=n(e);return r.validate(e,t),t},r.validate=function(e,r){var t=0==r.length;if(t){if(Array.isArray(e))throw new l(e.length,0)}else i(e,r,0)},r.validateIndex=function(e,r){if(!u.isNumber(e)||!u.isInteger(e))throw new TypeError("Index must be an integer (value: "+e+")");if(0>e)throw new p(e);if(void 0!==r&&e>=r)throw new p(e,r)},r.UNINITIALIZED={},r.resize=function(e,r,t){if(!Array.isArray(e)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new Error("Resizing to scalar is not supported");r.forEach(function(e){if(!u.isNumber(e)||!u.isInteger(e)||0>e)throw new TypeError("Invalid size, must contain positive integers (size: "+c.format(r)+")")});var n=void 0!==t?t:0;return a(e,r,0,n),e},r.squeeze=function(e,t){for(var n=t||r.size(e);Array.isArray(e)&&1===e.length;)e=e[0],n.shift();for(var i=n.length;1===n[i-1];)i--;return io;o++)e=[e],a.unshift(1);for(e=s(e,t,0);a.length=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}n.prototype=new RangeError,n.prototype.constructor=RangeError,n.prototype.name="IndexError",e.exports=n},function(e,r,t){"use strict";function n(e,r,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=r,this.relation=t,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=(new Error).stack; -a=function(e){return r[e]}}else if(r instanceof N){var v=r.size();if(1!==v.length||v[0]!==g)throw new Error("Invalid matrix length");a=function(e){return r.get([e])}}else a=function(){return r};o||(o=a(0)instanceof e.BigNumber?new e.BigNumber(0):0);var d=[];if(t.length>0){d=s.resize(d,t,o);for(var y=0;g>y;y++)d[y+c][y+u]=a(y)}return new n({data:d,size:[m,h]})},n.fromJSON=function(e){return new n(e)},n.prototype.swapRows=function(e,t){if(!(l(e)&&p(e)&&l(t)&&p(t)))throw new Error("Row index must be positive integers");if(2!==this._size.length)throw new Error("Only two dimensional matrix is supported");return h(e,this._size[0]),h(t,this._size[0]),n._swapRows(e,t,this._data),this},n._swapRows=function(e,t,r){var n=r[e];r[e]=r[t],r[t]=n},N._storage.dense=n,N._storage["default"]=n,n}var i=r(171),o=r(174),a=i.string,s=i.array,u=i.object,c=i.number,f=Array.isArray,l=c.isNumber,p=c.isInteger,m=a.isString,h=s.validateIndex;t.name="DenseMatrix",t.path="type",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(t){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this._values=new Array(t),this._heap=new e.FibonacciHeap}var a=n(r(32)),s=n(r(115));return o.prototype.set=function(e,t){if(this._values[e])this._values[e].value=t;else{var r=this._heap.insert(e,t);this._values[e]=r}},o.prototype.get=function(e){var t=this._values[e];return t?t.value:0},o.prototype.accumulate=function(e,t){var r=this._values[e];r?r.value=a(r.value,t):(r=this._heap.insert(e,t),this._values[e]=r)},o.prototype.forEach=function(e,t,r){var n=this._heap,i=this._values,o=[],a=n.extractMinimum();for(a&&o.push(a);a&&a.key<=t;)a.key>=e&&(s(a.value,0)||r(a.key,a.value,this)),a=n.extractMinimum(),a&&o.push(a);for(var u=0;ut;t++){var s=arguments[t];if(s instanceof i)s.start--,s.end-=s.step>0?0:2;else if(a(s))s--;else{if(!(s instanceof n))throw new TypeError("Ranges must be a Number or Range");s=s.toNumber()-1}e[t]=s}var u=new o;return o.apply(u,e),u};return e.index.transform=t,t}},function(e,t,r){"use strict";e.exports=function(e){function t(e,t,r){var n=function(e,i){return Array.isArray(e)?e.map(function(e,t){return n(e,i.concat(t+1))}):t(e,i,r)};return n(e,[])}var r=e.type.Matrix,n=function(n,i){if(2!=arguments.length)throw new e.error.ArgumentsError("map",arguments.length,2);if(Array.isArray(n))return t(n,i,n);if(n instanceof r)return e.matrix(t(n.valueOf(),i,n));throw new e.error.UnsupportedTypeError("map",e["typeof"](n))};return e.map.transform=n,n}},function(e,t,r){"use strict";var n=r(351),i=r(208).transform,o=r(175).isNumber,a=r(172).argsToArray;e.exports=function(e){var t=e.collection.isCollection,r=function(){var r=a(arguments);if(2==r.length&&t(r[0])){var s=r[1];o(s)?r[1]=s-1:s instanceof n&&(r[1]=s.minus(1))}try{return e.max.apply(e,r)}catch(u){throw i(u)}};return e.max.transform=r,r}},function(e,t,r){"use strict";var n=r(351),i=r(208).transform,o=r(175).isNumber,a=r(172).argsToArray;e.exports=function(e){var t=e.collection.isCollection,r=function(){var r=a(arguments);if(2==r.length&&t(r[0])){var s=r[1];o(s)?r[1]=s-1:s instanceof n&&(r[1]=s.minus(1))}try{return e.mean.apply(e,r)}catch(u){throw i(u)}};return e.mean.transform=r,r}},function(e,t,r){"use strict";var n=r(351),i=r(208).transform,o=r(175).isNumber,a=r(172).argsToArray;e.exports=function(e){var t=e.collection.isCollection,r=function(){var r=a(arguments);if(2==r.length&&t(r[0])){var s=r[1];o(s)?r[1]=s-1:s instanceof n&&(r[1]=s.minus(1))}try{return e.min.apply(e,r)}catch(u){throw i(u)}};return e.min.transform=r,r}},function(e,t,r){"use strict";var n=r(209).isBoolean,i=r(172).argsToArray;e.exports=function(e){var t=function(){var t=i(arguments),r=t.length-1,o=t[r];return n(o)||t.push(!0),e.range.apply(e,t)};return e.range.transform=t,t}},function(e,t,r){"use strict";var n=r(208).transform,i=(r(209).isBoolean,r(172).argsToArray);e.exports=function(e){var t=function(){try{return e.subset.apply(e,i(arguments))}catch(t){throw n(t)}};return e.subset.transform=t,t}},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("abs",{number:Math.abs,Complex:function(e){var t=Math.abs(e.re),r=Math.abs(e.im);if(1e3>t&&1e3>r)return Math.sqrt(t*t+r*r);if(t>=r){var n=r/t;return t*Math.sqrt(1+n*n)}var i=t/r;return r*Math.sqrt(1+i*i)},BigNumber:function(e){return e.abs()},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="abs",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=n(r(75)),c=n(r(115)),f=n(r(210)),l=n(r(211)),p=n(r(212)),m=e.DenseMatrix,h=e.SparseMatrix,g=a("add",{"any, any":l,"Matrix, Matrix":function(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new o(r.length,n.length);var i;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":i=d(e,t,r,n);break;default:i=y(e,t.valueOf(),r,n)}break;default:switch(t.storage()){case"sparse":i=x(e.valueOf(),t,r,n);break;default:i=w(e.valueOf(),t.valueOf(),e.storage())}}return i},"Array, Array":function(e,t){return g(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return g(u(e),t)},"Matrix, Array":function(e,t){return g(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=v(e,t,e.size());break;default:r=s.deepMap2(e,t,g)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=v(t,e,t.size());break;default:r=s.deepMap2(e,t,g)}return r},"Array, any":function(e,t){return s.deepMap2(e,t,g)},"any, Array":function(e,t){return s.deepMap2(e,t,g)}}),v=function(e,t,r){var n=r[0],i=r[1],o=e._values,a=e._index,s=e._ptr;if(!c(t,0)){for(var u=[],f=[],p=new Array(i),m=new h({values:u,index:f,ptr:p,size:[n,i]}),g=0;i>g;g++){p[g]=f.length;for(var v=s[g],d=s[g+1],y=v;d>y;y++){var x=l(o[y],t);c(x,0)||(f.push(a[y]),u.push(x))}}return p[i]=f.length,m}return e.clone()},d=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i=r[0],o=r[1],a=e._values,s=e._datatype,u=t._values,c=t._datatype,m=s&&c&&s===c?s:void 0,g=m?p.signatures[m+","+m]:p,v=m?l.signatures[m+","+m]:l,d=a&&u,y=d?[]:void 0,x=[],w=new Array(o),b=new h({values:y,index:x,ptr:w,size:[i,o]}),N=d?new Array(i):void 0,E=new Array(i),M=0;o>M;M++)if(w[M]=x.length,f(e,M,1,E,N,M+1,b,g,v),f(t,M,1,E,N,M+1,b,g,v),d)for(var A=w[M],_=x.length,O=A;_>O;O++)y.push(N[x[O]]);return w[o]=x.length,b},y=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i=r[0],o=r[1],a=t,s=[],u=[],m=new Array(o),g=new h({values:s,index:u,ptr:m,size:[i,o]}),v=new Array(i),d=new Array(i),y=0;o>y;y++){m[y]=u.length;for(var x=0;i>x;x++){var w=a[x][y];c(w,0)||(v[x]=w,d[x]=y+1,u.push(x))}f(e,y,1,d,v,y+1,g,p,l);for(var b=m[y],N=u.length,E=b;N>E;E++)s.push(v[u[E]])}return m[o]=u.length,g},x=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var o=r[0],a=r[1],s=e,u=t._values,c=t._index,f=t._ptr,p=i(s),h=new m({data:p,size:[o,a]}),g=0;a>g;g++)for(var v=f[g],d=f[g+1],y=v;d>y;y++){var x=c[y];p[x][g]=l(p[x][g],u[y])}return h},w=function(e,t,r){return u(s.deepMap2(e,t,g),r)};return g}var i=r(166).clone,o=r(174);t.name="add",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("ceil",{number:Math.ceil,Complex:function(e){return new e.constructor(Math.ceil(e.re),Math.ceil(e.im))},BigNumber:function(e){return e.ceil()},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="ceil",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=n(r(212)).signatures["Complex,Complex"],s=i("cube",{number:function(e){return e*e*e},Complex:function(e){return a(a(e,e),e)},BigNumber:function(e){return e.times(e).times(e)},"Array | Matrix":function(e){return o.deepMap(e,s,!0)}});return s}t.name="cube",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=n(r(213)),s=n(r(47)),u=n(r(96));return i("divide",{"any, any":a,"Array | Matrix, Array | Matrix":function(e,t){return s(e,u(t))},"Array | Matrix, any":function(e,t){return o.deepMap2(e,t,a)},"any, Array | Matrix":function(e,t){return s(e,u(t))}})}t.name="divide",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=n(r(213));return i("dotDivide",{"any, any":function(e,t){return o.deepMap2(e,t,a)}})}t.name="dotDivide",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=n(r(47));return i("dotMultiply",{"any, any":function(e,t){return o.deepMap2(e,t,a)}})}r(172).size;t.name="dotMultiply",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=n(r(50));return i("dotMultiply",{"any, any":function(e,t){return o.deepMap2(e,t,a)}})}t.name="dotPow",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("exp",{number:Math.exp,Complex:function(t){var r=Math.exp(t.re);return new e.Complex(r*Math.cos(t.im),r*Math.sin(t.im))},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="exp",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("fix",{number:function(e){return e>0?Math.floor(e):Math.ceil(e)},Complex:function(e){return new e.constructor(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},BigNumber:function(e){return e.isNegative()?e.ceil():e.floor()},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="fix",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("floor",{number:Math.floor,Complex:function(e){return new e.constructor(Math.floor(e.re),Math.floor(e.im))},BigNumber:function(e){return e.floor()},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="floor",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t,r){if(!t.isInt()||!r.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new e.BigNumber(0);!r.isZero();){var i=t.mod(r);t=r,r=i}return t.lt(n)?t.neg():t}var s=n(r(2)),u=o("gcd",{"number, number":i,"BigNumber, BigNumber":a,"Array | Matrix, Array | Matrix | number | BigNumber":function(e,t){return s.deepMap2(e,t,u)},"number | BigNumber, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=u(e,t),i=0;ie?-e:e}var o=r(175).isInteger;t.name="gcd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t,r){if(!t.isInt()||!r.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(t.isZero()||r.isZero())return new e.BigNumber(0);for(var n=t.times(r);!r.isZero();){var i=r;r=t.mod(i),t=i}return n.div(t).abs()}var s=n(r(2)),u=o("lcm",{"number, number":i,"BigNumber, BigNumber":a,"Array | Matrix, Array | Matrix | number | BigNumber":function(e,t){return s.deepMap2(e,t,u)},"number | BigNumber, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,t,r){for(var n=u(e,t),i=0;i=0?Math.log(t):u(new e.Complex(t,0))}var a=n(r(2)),s=n(r(213)),u=i("log",{number:o,Complex:function(t){return new e.Complex(Math.log(Math.sqrt(t.re*t.re+t.im*t.im)),Math.atan2(t.im,t.re))},BigNumber:function(e){return e.ln()},"Array | Matrix":function(e){return a.deepMap(e,u)},"any, any":function(e,t){return s(u(e),u(t))}});return u}t.name="log",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(t){return new e.Complex(Math.log(Math.sqrt(t.re*t.re+t.im*t.im))/Math.LN10,Math.atan2(t.im,t.re)/Math.LN10)}var a=n(r(2)),s=i("log10",{number:function(t){return t>=0?Math.log(t)/Math.LN10:s(new e.Complex(t,0))},Complex:o,BigNumber:function(t){return t.isNegative()?o(new e.Complex(t.toNumber(),0)):t.log()},"Array | Matrix":function(e){return a.deepMap(e,s)}});return s}t.name="log10",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){if(t>0)return e-t*Math.floor(e/t);if(0===t)return e;throw new Error("Cannot calculate mod for a negative divisor")}var a=n(r(2)),s=i("mod",{"number, number":o,"BigNumber, BigNumber":function(e,t){return t.isZero()?e:e.mod(t)},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}t.name="mod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(75)),s=n(r(211)),u=n(r(212)),c=n(r(115)),f=n(r(2)),l=e.DenseMatrix,p=e.SparseMatrix,m=i("multiply",{"any, any":u,"Array, Array":function(t,r){h(o.size(t),o.size(r));var n=m(a(t),a(r));return n instanceof e.Matrix?n.valueOf():n},"Matrix, Matrix":function(e,t){var r=e.size(),n=t.size();return h(r,n),1===r.length?1===n.length?g(e,t,r[0]):v(e,t):1===n.length?y(e,t):x(e,t)},"Matrix, Array":function(e,t){return m(e,a(t))},"Array, Matrix":function(e,t){return m(a(e,t.storage()),t)},"Array, any":function(e,t){return f.deepMap2(e,t,m)},"Matrix, any":function(e,t){return e.map(function(e){return m(e,t)},!0)},"any, Array | Matrix":function(e,t){return t.map(function(t){return m(t,e)},!0)}}),h=function(e,t){switch(e.length){case 1:switch(t.length){case 1:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;case 2:switch(t.length){case 1:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+t[0]+")");break;case 2:if(e[1]!==t[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+t[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+t.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}},g=function(e,t,r){if(0===r)throw new Error("Cannot multiply two empty vectors");for(var n=e._data,i=e._datatype,o=t._data,a=t._datatype,c=i&&a&&i===a?i:void 0,f=c?u.signatures[c+","+c]||u:u,l=c?s.signatures[c+","+c]||s:s,p=f(n[0],o[0]),m=1;r>m;m++)p=l(p,f(n[m],o[m]));return p},v=function(e,t){switch(t.storage()){case"dense":return d(e,t)}throw new Error("Not implemented")},d=function(e,t){for(var r=e._data,n=e._size,i=e._datatype,o=t._data,a=t._size,c=t._datatype,f=n[0],p=a[1],m=i&&c&&i===c?i:void 0,h=m?u.signatures[m+","+m]||u:u,g=m?s.signatures[m+","+m]||s:s,v=new Array(p),d=0;p>d;d++){for(var y=h(r[0],o[0][d]),x=1;f>x;x++)y=g(y,h(r[x],o[x][d]));v[d]=y}return 1===p?v[0]:new l({data:v,size:[p],datatype:m})},y=function(e,t){switch(e.storage()){case"dense":return w(e,t);case"sparse":return E(e,t)}},x=function(e,t){switch(e.storage()){case"dense":switch(t.storage()){case"dense":return b(e,t);case"sparse":return N(e,t)}break;case"sparse":switch(t.storage()){case"dense":return M(e,t);case"sparse":return A(e,t)}}},w=function(e,t){for(var r=e._data,n=e._size,i=e._datatype,o=t._data,a=t._datatype,c=n[0],f=n[1],p=i&&a&&i===a?i:void 0,m=p?u.signatures[p+","+p]||u:u,h=p?s.signatures[p+","+p]||s:s,g=new Array(c),v=0;c>v;v++){for(var d=r[v],y=m(d[0],o[0]),x=1;f>x;x++)y=h(y,m(d[x],o[x]));g[v]=y}return 1===c?g[0]:new l({data:g,size:[c],datatype:p})},b=function(e,t){for(var r=e._data,n=e._size,i=e._datatype,o=t._data,a=t._size,c=t._datatype,f=n[0],p=n[1],m=a[1],h=i&&c&&i===c?i:void 0,g=h?u.signatures[h+","+h]||u:u,v=h?s.signatures[h+","+h]||s:s,d=new Array(f),y=0;f>y;y++){var x=r[y];d[y]=new Array(m);for(var w=0;m>w;w++){for(var b=g(x[0],o[0][w]),N=1;p>N;N++)b=v(b,g(x[N],o[N][w]));d[y][w]=b}}return 1===f&&1===m?d[0][0]:new l({data:d,size:[f,m],datatype:h})},N=function(e,t){var r=e._data,n=e._size,i=e._datatype,o=t._values,a=t._index,f=t._ptr,l=t._size,m=t._datatype;if(!o)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");for(var h=n[0],g=l[1],v=[],d=[],y=new Array(g+1),x=new p({values:v,index:d,ptr:y,size:[h,g],datatype:w}),w=i&&m&&i===m?i:void 0,b=w?u.signatures[w+","+w]||u:u,N=w?s.signatures[w+","+w]||s:s,E=0;g>E;E++){y[E]=d.length;var M=f[E],A=f[E+1];if(A>M)for(var _=0,O=0;h>O;O++){for(var C,S=O+1,z=M;A>z;z++){var T=a[z];_!==S?(C=b(r[O][T],o[z]),_=S):C=N(C,b(r[O][T],o[z]))}_!==S||c(C,0)||(d.push(O),v.push(C))}}return y[g]=d.length,1===h&&1===g?1===v.length?v[0]:0:x},E=function(e,t){var r=e._values,n=e._index,i=e._ptr,o=e._datatype;if(!r)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var a=t._data,f=t._datatype,l=e._size[0],m=t._size[0],h=[],g=[],v=new Array(2),d=o&&f&&o===f?o:void 0,y=d?u.signatures[d+","+d]||u:u,x=d?s.signatures[d+","+d]||s:s,w=new Array(l),b=new Array(l);v[0]=0;for(var N=0;m>N;N++){var E=a[N];if(!c(E,0))for(var M=i[N],A=i[N+1],_=M;A>_;_++){var O=n[_];b[O]?w[O]=x(w[O],y(E,r[_])):(b[O]=!0,g.push(O),w[O]=y(E,r[_]))}}for(var C=g.length,S=0;C>S;S++){var z=g[S];h[S]=w[z]}return v[1]=g.length,1===l?1===h.length?h[0]:0:new p({values:h,index:g,ptr:v,size:[l,1],datatype:d})},M=function(e,t){var r=e._values,n=e._index,i=e._ptr,o=e._datatype;if(!r)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");for(var a=t._data,f=t._datatype,l=e._size[0],m=t._size[0],h=t._size[1],g=o&&f&&o===f?o:void 0,v=g?u.signatures[g+","+g]||u:u,d=g?s.signatures[g+","+g]||s:s,y=[],x=[],w=new Array(h+1),b=new p({values:y,index:x,ptr:w,size:[l,h],datatype:g}),N=new Array(l),E=new Array(l),M=0;h>M;M++){w[M]=x.length;for(var A=M+1,_=0;m>_;_++){var O=a[_][M];if(!c(O,0))for(var C=i[_],S=i[_+1],z=C;S>z;z++){var T=n[z];E[T]!==A?(E[T]=A,x.push(T),N[T]=v(O,r[z])):N[T]=d(N[T],v(O,r[z]))}}for(var B=w[M],I=x.length,q=B;I>q;q++){var P=x[q];y[q]=N[P]}}return w[h]=x.length,1===l&&1===h?1===y.length?y[0]:0:b},A=function(e,t){for(var r,n,i,o,a,c,f,l,m=e._values,h=e._index,g=e._ptr,v=e._datatype,d=t._values,y=t._index,x=t._ptr,w=t._datatype,b=v&&w&&v===w?v:void 0,N=b?u.signatures[b+","+b]||u:u,E=b?s.signatures[b+","+b]||s:s,M=e._size[0],A=t._size[1],_=m&&d,O=_?[]:void 0,C=[],S=new Array(A+1),z=new p({values:O,index:C,ptr:S,size:[M,A],datatype:b}),T=_?new Array(M):void 0,B=new Array(M),I=0;A>I;I++){S[I]=C.length;var q=I+1;for(a=x[I],c=x[I+1],o=a;c>o;o++)if(l=y[o],_)for(n=g[l],i=g[l+1],r=n;i>r;r++)f=h[r],B[f]!==q?(B[f]=q,C.push(f),T[f]=N(d[o],m[r])):T[f]=E(T[f],N(d[o],m[r]));else for(n=g[l],i=g[l+1],r=n;i>r;r++)f=h[r],B[f]!==q&&(B[f]=q,C.push(f));if(_)for(var P=S[I],U=C.length,R=P;U>R;R++){var L=C[R];O[R]=T[L]}}return S[A]=C.length,1===M&&1===A&&_?1===O.length?O[0]:0:z};return m}var i=r(171),o=i.array;t.name="multiply",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){var r=e.size();if(1==r.length){if(t===Number.POSITIVE_INFINITY||"inf"===t){var n=0;return e.forEach(function(e){var t=a(e);p(t,n)&&(n=t)},!0),n}if(t===Number.NEGATIVE_INFINITY||"-inf"===t){var i;return e.forEach(function(e){var t=a(e);(!i||m(t,i))&&(i=t)},!0),i||0}if("fro"===t)return o(e,2);if("number"==typeof t&&!isNaN(t)){if(!l(t,0)){var h=0;return e.forEach(function(e){h=s(u(a(e),t),h)},!0),u(h,1/t)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}if(2==r.length){if(1===t){var d=[],y=0;return e.forEach(function(e,t){var r=t[1],n=s(d[r]||0,a(e));p(n,y)&&(y=n),d[r]=n},!0),y}if(t===Number.POSITIVE_INFINITY||"inf"===t){var x=[],w=0;return e.forEach(function(e,t){var r=t[0],n=s(x[r]||0,a(e));p(n,w)&&(w=n),x[r]=n},!0),w}if("fro"===t)return c(g(f(v(e),e)));if(2===t)throw new Error("Unsupported parameter value, missing implementation of matrix singular value decomposition");throw new Error("Unsupported parameter value")}}var a=n(r(31)),s=n(r(32)),u=n(r(50)),c=n(r(53)),f=n(r(47)),l=n(r(115)),p=n(r(116)),m=n(r(118)),h=n(r(75)),g=n(r(103)),v=n(r(104)),d=a.signatures.Complex,y=i("norm",{number:Math.abs,Complex:d,BigNumber:function(e){return e.abs()},"boolean | null":function(e){return Math.abs(e)},Array:function(e){return o(h(e),2)},Matrix:function(e){return o(e,2)},"number | Complex | BigNumber | boolean | null, number | BigNumber | string":function(e){return y(e)},"Array, number | BigNumber | string":function(e,t){return o(h(e),t)},"Matrix, number | BigNumber | string":function(e,t){return o(e,t)}});return y}t.name="norm",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t,r){var n=new e.BigNumber(0),i=new e.BigNumber(1),o=r.isNegative();if(o&&(r=r.negated()),r.isZero())throw new Error("Root must be non-zero");if(t.isNegative()&&!r.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(t.isZero())return n;if(!t.isFinite())return o?n:t;var a=i,s=0,u=100;do{var c=a,f=t.div(a.pow(r.minus(1))).minus(a).div(r);a=a.plus(f),s++}while(!a.equals(c)&&u>s);return o?i.div(a):a}var s=n(r(2)),u=o("nthRoot",{number:function(e){return i(e,2)},"number, number":i,BigNumber:function(t){return a(t,new e.BigNumber(2))},"BigNumber, BigNumber":a,"Array | Matrix":function(e){return s.deepMap(e,u)},"Array | Matrix, any":function(e,t){return s.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}function i(e,t){var r=0>t;if(r&&(t=-t),0===t)throw new Error("Root must be non-zero");if(0>e&&Math.abs(t)%2!=1)throw new Error("Root must be odd when a is negative.");if(0==e)return 0;if(!Number.isFinite(e))return r?0:e;var n=1e-16,i=1,o=0,a=100;do{var s=(e/Math.pow(i,t-1)-i)/t;i+=s,o++}while(Math.abs(s)>n&&a>o);return r?1/i:i}t.name="nthRoot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function s(e,t){return f(m(p(e),t))}function u(e,t){if(!i(t)||0>t)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var r=o(e);if(2!=r.length)throw new Error("For A^b, A must be 2 dimensional (A has "+r.length+" dimensions)");if(r[0]!=r[1])throw new Error("For A^b, A must be square (size is "+r[0]+"x"+r[1]+")");for(var n=l(r[0]).valueOf(),a=e;t>=1;)1==(1&t)&&(n=m(a,n)),t>>=1,a=m(a,a);return n}function c(e,t){return h(u(e.valueOf(),t))}var f=(n(r(2)),n(r(39))),l=n(r(94)),p=n(r(44)),m=n(r(47)),h=n(r(75)),g=a("pow",{"number, number":function(t,r){return i(r)||t>=0?Math.pow(t,r):s(new e.Complex(t,0),new e.Complex(r,0))},"BigNumber, BigNumber":function(t,r){return i(r)||t>=0?t.pow(r):s(new e.Complex(t.toNumber(),0),new e.Complex(r.toNumber(),0))},"Complex, Complex":s,"Array, number":u,"Array, BigNumber":function(e,t){return u(e,t.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(e,t){return c(e,t.toNumber())}});return g}var i=r(175).isInteger,o=r(172).size;t.name="pow",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("round",{number:Math.round,"number, number":function(e,t){if(!o(t))throw new TypeError("Number of decimals in function round must be an integer");if(0>t||t>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return i(e,t)},Complex:function(t){return new e.Complex(Math.round(t.re),Math.round(t.im))},"Complex, number":function(t,r){return new e.Complex(i(t.re,r),i(t.im,r))},"Complex, BigNumber":function(t,r){var n=r.toNumber();return new e.Complex(i(t.re,n),i(t.im,n))},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,t){if(!t.isInteger())throw new TypeError("Number of decimals in function round must be an integer");return e.toDecimalPlaces(t.toNumber())},"Array | Matrix":function(e){return s.deepMap(e,u,!0)},"Array | Matrix, number | BigNumber":function(e,t){return s.deepMap2(e,t,u)},"number | Complex | BigNumber, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}function i(e,t){return parseFloat(a(e,t))}var o=r(175).isInteger,a=r(175).toFixed;t.name="round",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("sign",{number:i.sign,Complex:function(e){var t=Math.sqrt(e.re*e.re+e.im*e.im);return new e.constructor(e.re/t,e.im/t)},BigNumber:function(e){return new e.constructor(e.cmp(0))},"Array | Matrix":function(e){return a.deepMap(e,s,!0)}});return s}var i=r(175);t.name="sign",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(t){return t>=0?Math.sqrt(t):a(new e.Complex(t,0))}function a(t){var r,n,i=Math.sqrt(t.re*t.re+t.im*t.im);return r=t.re>=0?.5*Math.sqrt(2*(i+t.re)):Math.abs(t.im)/Math.sqrt(2*(i-t.re)),n=t.re<=0?.5*Math.sqrt(2*(i-t.re)):Math.abs(t.im)/Math.sqrt(2*(i+t.re)),t.im>=0?new e.Complex(r,n):new e.Complex(r,-n)}var s=n(r(2)),u=i("sqrt",{number:o,Complex:a,BigNumber:function(e){return e.isNegative()?o(e.toNumber()):e.sqrt()},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}t.name="sqrt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("square",{number:function(e){return e*e},Complex:function(e){return new e.constructor(e.re*e.re-e.im*e.im,e.re*e.im+e.im*e.re)},BigNumber:function(e){return e.times(e)},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="square",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(56)),u=n(r(75)),c=n(r(115)),f=n(r(210)),l=n(r(211)),p=n(r(212)),m=n(r(2)),h=e.DenseMatrix,g=e.SparseMatrix,v=a("subtract",{"number, number":function(e,t){return e-t},"Complex, Complex":function(t,r){return new e.Complex(t.re-r.re,t.im-r.im)},"BigNumber, BigNumber":function(e,t){return e.minus(t)},"Unit, Unit":function(e,t){if(null==e.value)throw new Error("Parameter x contains a unit with undefined value");if(null==t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value-=t.value,r.fixPrefix=!1,r},"Matrix, Matrix":function(e,t){var r=e.size(),n=t.size();if(r.length!==n.length)throw new o(r.length,n.length);var i;switch(e.storage()){case"sparse":switch(t.storage()){case"sparse":i=x(e,t,r,n);break;default:i=w(e,t.valueOf(),r,n)}break;default:switch(t.storage()){case"sparse":i=b(e.valueOf(),t,r,n);break;default:i=N(e.valueOf(),t.valueOf(),e.storage())}}return i},"Array, Array":function(e,t){return v(u(e),u(t)).valueOf()},"Array, Matrix":function(e,t){return v(u(e),t)},"Matrix, Array":function(e,t){return v(e,u(t))},"Matrix, any":function(e,t){var r;switch(e.storage()){case"sparse":r=d(e,t,e.size());break;default:r=m.deepMap2(e,t,v)}return r},"any, Matrix":function(e,t){var r;switch(t.storage()){case"sparse":r=y(e,t,t.size());break;default:r=m.deepMap2(e,t,v)}return r},"Array, any":function(e,t){return m.deepMap2(e,t,v)},"any, Array":function(e,t){return m.deepMap2(e,t,v)}}),d=function(e,t,r){var n=r[0],i=r[1],o=e._values,a=e._index,s=e._ptr;if(!c(t,0)){for(var u=[],f=[],l=new Array(i),p=new g({values:u,index:f,ptr:l,size:[n,i]}),m=0;i>m;m++){l[m]=f.length;for(var h=s[m],d=s[m+1],y=h;d>y;y++){var x=v(o[y],t);c(x,0)||(f.push(a[y]),u.push(x))}}return l[i]=f.length,p}return e.clone()},y=function(e,t,r){var n=r[0],i=r[1],o=t._values,a=t._index,s=t._ptr;if(!c(e,0)){for(var u=[],f=[],l=new Array(i),p=new g({values:u,index:f,ptr:l,size:[n,i]}),m=0;i>m;m++){l[m]=f.length;for(var h=s[m],d=s[m+1],y=h;d>y;y++){var x=v(e,o[y]);c(x,0)||(f.push(a[y]),u.push(x))}}return l[i]=f.length,p}return t.clone()},x=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i=r[0],o=r[1],a=e._values,s=t._values,u=a&&s,c=u?[]:void 0,m=[],h=new Array(o),v=new g({values:c,index:m,ptr:h,size:[i,o]}),d=u?new Array(i):void 0,y=new Array(i),x=0;o>x;x++)if(h[x]=m.length,f(e,x,1,y,d,x+1,v,p,l),f(t,x,-1,y,d,x+1,v,p,l),u)for(var w=h[x],b=m.length,N=w;b>N;N++)c.push(d[m[N]]);return h[o]=m.length,v},w=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var i=r[0],o=r[1],a=t,u=[],m=[],h=new Array(o),v=new g({values:u,index:m,ptr:h,size:[i,o]}),d=new Array(i),y=new Array(i),x=0;o>x;x++){h[x]=m.length;for(var w=0;i>w;w++){var b=s(a[w][x]);c(b,0)||(d[w]=b,y[w]=x+1,m.push(w))}f(e,x,1,y,d,x+1,v,p,l);for(var N=h[x],E=m.length,M=N;E>M;M++)u.push(d[m[M]])}return h[o]=m.length,v},b=function(e,t,r,n){if(r[0]!==n[0]||r[1]!==n[1])throw new RangeError("Dimension mismatch in add. Matrix A ("+r+") must match Matrix B ("+n+")");for(var o=r[0],a=r[1],s=e,u=t._values,c=t._index,f=t._ptr,l=i(s),p=new h({data:l,size:[o,a]}),m=0;a>m;m++)for(var g=f[m],d=f[m+1],y=g;d>y;y++){var x=c[y];l[x][m]=v(l[x][m],u[y])}return p},N=function(e,t,r){return u(m.deepMap2(e,t,v),r)};return v}var i=r(166).clone,o=r(174);t.name="subtract",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("unaryMinus",{number:function(e){return-e},Complex:function(e){return new e.constructor(-e.re,-e.im)},BigNumber:function(e){return e.neg()},Unit:function(e){var t=e.clone();return t.value=-e.value,t},"Array | Matrix":function(e){return o.deepMap(e,a,!0)}});return a}t.name="unaryMinus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("unaryPlus",{number:function(e){return e},Complex:function(e){ -return e.clone()},BigNumber:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return o.deepMap(e,a,!0)},"boolean | string | null":function(r){return"bignumber"==t.number?new e.BigNumber(+r):+r}});return a}t.name="unaryPlus",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e,r){var n,o,a,s=0,c=1,f=1,l=0;if(!i(e)||!i(r))throw new Error("Parameters in function xgcd must be integer numbers");for(;r;)o=Math.floor(e/r),a=e%r,n=s,s=c-o*s,c=n,n=f,f=l-o*f,l=n,e=r,r=a;var p;return p=0>e?[-e,-c,-l]:[e,e?c:0,l],"array"===t.matrix?p:u(p)}function s(r,n){var i,o,a,s=new e.BigNumber(0),c=new e.BigNumber(0),f=new e.BigNumber(1),l=new e.BigNumber(1),p=new e.BigNumber(0);if(!r.isInt()||!n.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!n.isZero();)o=r.div(n).floor(),a=r.mod(n),i=c,c=f.minus(o.times(c)),f=i,i=l,l=p.minus(o.times(l)),p=i,r=n,n=a;var m;return m=r.lt(s)?[r.neg(),f.neg(),p.neg()]:[r,r.isZero()?0:f,p],"array"===t.matrix?m:u(m)}var u=(n(r(2)),n(r(75)));return o("xgcd",{"number, number":a,"BigNumber, BigNumber":s})}var i=r(175).isInteger;t.name="xgcd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("bitAnd",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitAnd");return e&t},"BigNumber, BigNumber":o,"Array | Matrix, any":function(e,t){return s.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}var i=r(175).isInteger,o=r(214).and;t.name="bitAnd",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("bitNot",{number:function(e){if(!i(e))throw new Error("Integer expected in function bitNot");return~e},BigNumber:o,"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}var i=r(175).isInteger,o=r(214).not;t.name="bitNot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("bitOr",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitOr");return e|t},"BigNumber, BigNumber":o,"Array | Matrix, any":function(e,t){return s.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}var i=r(175).isInteger,o=r(214).or;t.name="bitOr",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("bitXor",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function bitXor");return e^t},"BigNumber, BigNumber":o,"Array | Matrix, any":function(e,t){return s.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}var i=r(175).isInteger,o=r(214).xor;t.name="bitXor",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("leftShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function leftShift");return e<>t},"BigNumber, BigNumber":o,"Array | Matrix, any":function(e,t){return s.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return s.deepMap2(e,t,u)}});return u}var i=r(175).isInteger,o=r(214).rightArithShift;t.name="rightArithShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("rightLogShift",{"number, number":function(e,t){if(!i(e)||!i(t))throw new Error("Integers expected in function rightLogShift");return e>>>t},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).isInteger;t.name="rightLogShift",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("arg",{number:function(e){return Math.atan2(0,e)},Complex:function(e){return Math.atan2(e.im,e.re)},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="arg",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("conj",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return new e.constructor(e.re,-e.im)},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="conj",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("re",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="re",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("im",{number:function(e){return 0},BigNumber:function(e){return new e.constructor(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="im",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("bignumber",{"":function(){return new e.BigNumber(0)},number:function(t){return new e.BigNumber(t+"")},string:function(t){return new e.BigNumber(t)},BigNumber:function(e){return e},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="bignumber",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("bool",{"":function(){return!1},"boolean":function(e){return e},number:function(e){return!!e},BigNumber:function(e){return!e.isZero()},string:function(e){var t=e.toLowerCase();if("true"===t)return!0;if("false"===t)return!1;var r=Number(e);if(""!=e&&!isNaN(r))return!!r;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="boolean",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("chain",{"":function(){return new e.Chain},any:function(t){return new e.Chain(t)}})}t.name="chain",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("complex",{"":function(){return new e.Complex(0,0)},number:function(t){return new e.Complex(t,0)},"number, number":function(t,r){return new e.Complex(t,r)},"BigNumber, BigNumber":function(t,r){return new e.Complex(t.toNumber(),r.toNumber())},Complex:function(e){return e.clone()},string:function(t){var r=e.Complex.parse(t);if(r)return r;throw new SyntaxError('String "'+t+'" is no valid complex number')},Object:function(t){if("re"in t&&"im"in t)return new e.Complex(t.re,t.im);if("r"in t&&"phi"in t)return e.Complex.fromPolar(t.r,t.phi);throw new Error("Expected object with either properties re and im, or properties r and phi.")},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="complex",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("index",{"...number | BigNumber | Range | Array":function(t){var r=t.map(function(t){return t instanceof e.BigNumber?t.toNumber():Array.isArray(t)?t.map(function(t){return t instanceof e.BigNumber?t.toNumber():t}):t}),n=new e.Index;return e.Index.apply(n,r),n}})}t.name="index",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(t,r,n){var i=e.Matrix.storage(r||"default");return new i(t,n)}return n("matrix",{"":function(){return i([])},string:function(e){return i([],e)},"string, string":function(e,t){return i([],e,t)},Array:function(e){return i(e)},Matrix:function(e){return i(e,e.storage())},"Array | Matrix, string":i,"Array | Matrix, string, string":i})}t.name="matrix",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("number",{"":function(){return 0},number:function(e){return e},string:function(e){var t=Number(e);if(isNaN(t))throw new SyntaxError('String "'+e+'" is no valid number');return t},BigNumber:function(e){return e.toNumber()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},"Unit, string | Unit":function(e,t){return e.toNumber(t)},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="number",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,o){var a=n(r(14));return i("parser",{"":function(){return new a(o)}})}t.name="parser",t.factory=n,t.math=!0},function(e,t,r){"use strict";function n(e,t,r,n){var i=e.SparseMatrix;return n("sparse",{"":function(){return new i([])},string:function(e){return new i([],e)},"Array | Matrix":function(e){return new i(e)},"Array | Matrix, string":function(e,t){return new i(e,t)}})}t.name="sparse",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("string",{"":function(){return""},number:i.format,"null":function(e){return"null"},"boolean":function(e){return e+""},"Array | Matrix":function(e){return a.deepMap(e,s)},any:function(e){return String(e)}});return s}var i=r(175);t.name="string",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("unit",{Unit:function(e){return e.clone()},string:function(t){if(e.Unit.isValuelessUnit(t))return new e.Unit(null,t);var r=e.Unit.parse(t);if(r)return r;throw new SyntaxError('String "'+t+'" is no valid unit')},"number, string":function(t,r){return new e.Unit(t,r)},"BigNumber, string":function(t,r){return new e.Unit(t.toNumber(),r)},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="unit",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,o){var a=n(r(2)),s=n(r(13));return i("compile",{string:function(e){return s(e).compile(o)},"Array | Matrix":function(e){return a.deepMap(e,function(e){return s(e).compile(o)})}})}t.math=!0,t.name="compile",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i,o){var a=n(r(2)),s=n(r(13));return i("compile",{string:function(e){var t={};return s(e).compile(o).eval(t)},"string, Object":function(e,t){return s(e).compile(o).eval(t)},"Array | Matrix":function(e){var t={};return a.deepMap(e,function(e){return s(e).compile(o).eval(t)})},"Array | Matrix, Object":function(e,t){return a.deepMap(e,function(e){return s(e).compile(o).eval(t)})}})}t.math=!0,t.name="eval",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n,o){return n("help",{any:function(t){var r,n=t;if("string"!=typeof t)for(r in o)if(o.hasOwnProperty(r)&&t===o[r]){n=r;break}var a=i[n];if(!a)throw new Error('No documentation found on "'+n+'"');return new e.Help(a)}})}var i=r(16);t.math=!0,t.name="help",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(13));return i("parse",{"string | Array | Matrix":o,"string | Array | Matrix, Object":o})}t.name="parse",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("and",{"number, number":function(e,t){return!(!e||!t)},"Complex, Complex":function(e,t){return!(0===e.re&&0===e.im||0===t.re&&0===t.im)},"BigNumber, BigNumber":function(e,t){return!(e.isZero()||t.isZero()||e.isNaN()||t.isNaN())},"Unit, Unit":function(e,t){return 0!==e.value&&null!==e.value&&0!==t.value&&null!==t.value},"Array | Matrix, any":function(e,t){return o.deepMap2(e,t,a)},"any, Array | Matrix":function(e,t){return o.deepMap2(e,t,a)}});return a}t.name="and",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("not",{number:function(e){return!e},Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||0==e.value},"Array | Matrix":function(e){return o.deepMap(e,a)}});return a}t.name="not",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("or",{"number, number":function(e,t){return!(!e&&!t)},"Complex, Complex":function(e,t){return 0!==e.re||0!==e.im||0!==t.re||0!==t.im},"BigNumber, BigNumber":function(e,t){return!e.isZero()&&!e.isNaN()||!t.isZero()&&!t.isNaN()},"Unit, Unit":function(e,t){return 0!==e.value&&null!==e.value||0!==t.value&&null!==t.value},"Array | Matrix, any":function(e,t){return o.deepMap2(e,t,a)},"any, Array | Matrix":function(e,t){return o.deepMap2(e,t,a)}});return a}t.name="or",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("xor",{"number, number":function(e,t){return!!(!!e^!!t)},"Complex, Complex":function(e,t){return!!((0!==e.re||0!==e.im)^(0!==t.re||0!==t.im))},"BigNumber, BigNumber":function(e,t){return!!((!e.isZero()&&!e.isNaN())^(!t.isZero()&&!t.isNaN()))},"Unit, Unit":function(e,t){return!!((0!==e.value&&null!==e.value)^(0!==t.value&&null!==t.value))},"Array | Matrix, any":function(e,t){return o.deepMap2(e,t,a)},"any, Array | Matrix":function(e,t){return o.deepMap2(e,t,a)}});return a}t.name="xor",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,f){var l=n(r(75));return f("concat",{"...Array | Matrix | number | BigNumber":function(t){var r,n,f=t.length,p=-1,m=!1,h=[];for(r=0;f>r;r++){var g=t[r];if(g instanceof e.Matrix&&(m=!0),"number"==typeof g||g instanceof e.BigNumber){if(r!==f-1)throw new Error("Dimension must be specified as last argument");if(n=p,p=g.valueOf(),!a(p))throw new TypeError("Integer number expected for dimension");if(0>p)throw new u(p);if(r>0&&p>n)throw new u(p,n+1)}else{var v=o(g).valueOf(),d=s.size(v);if(h[r]=v,n=p,p=d.length-1,r>0&&p!=n)throw new c(n+1,p+1)}}if(0==h.length)throw new SyntaxError("At least one matrix expected");for(var y=h.shift();h.length;)y=i(y,h.shift(),p,0);return m?l(y):y}})}function i(e,t,r,n){if(r>n){if(e.length!=t.length)throw new c(e.length,t.length);for(var o=[],a=0;ar;r++)n[t][r]=0;for(r=t+1;ra;a++)i=l(n(i),e);return t%2==0?p(i[0][0]):i[0][0]}var u=(n(r(2)),n(r(75))),c=n(r(32)),f=n(r(55)),l=n(r(47)),p=n(r(56));return i("det",{any:function(e){return o.clone(e)},"Array | Matrix":function(t){var r;switch(t instanceof e.Matrix?r=t.size():t instanceof Array?(t=u(t),r=t.size()):r=[],r.length){case 0:return o.clone(t);case 1:if(1==r[0])return o.clone(t.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+a.format(r)+")");case 2:var n=r[0],i=r[1];if(n==i)return s(t.clone().valueOf(),n,i);throw new RangeError("Matrix must be square (size: "+a.format(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+a.format(r)+")")}}})}var i=r(171),o=i.object,a=i.string;t.name="det",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,s){function u(e,t,r,n){if(!a(t))throw new TypeError("Second parameter in function diag must be an integer");var i=t>0?t:0,o=0>t?-t:0;switch(r.length){case 1:return c(e,t,n,r[0],o,i);case 2:return f(e,t,n,r,o,i)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function c(t,r,n,i,o,a){var s=[i+o,i+a],u=e.Matrix.storage(n||"dense"),c=u.diagonal(s,t,r);return null!==n?c:c.valueOf()}function f(t,r,n,i,a,s){if(t instanceof e.Matrix){var u=t.diagonal(r);return null!==n?n!==u.storage()?l(u,n):u:u.valueOf()}for(var c=Math.min(i[0]-a,i[1]-s),f=new Array(c),p=0;c>p;p++)f[p]=o(t[p+a][p+s]);return null!==n?l(f):f}var l=n(r(75));return s("diag",{Array:function(e){return u(e,0,i.size(e),null)},"Array, number":function(e,t){return u(e,t,i.size(e),null)},"Array, BigNumber":function(e,t){return u(e,t.toNumber(),i.size(e),null)},"Array, string":function(e,t){return u(e,0,i.size(e),t)},"Array, number, string":function(e,t,r){return u(e,t,i.size(e),r)},"Array, BigNumber, string":function(e,t,r){return u(e,t.toNumber(),i.size(e),r)},Matrix:function(e){return u(e,0,e.size(),e.storage())},"Matrix, number":function(e,t){return u(e,t,e.size(),e.storage())},"Matrix, BigNumber":function(e,t){return u(e,t.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,t){return u(e,0,e.size(),t)},"Matrix, number, string":function(e,t,r){return u(e,t,e.size(),r)},"Matrix, BigNumber, string":function(e,t,r){return u(e,t.toNumber(),e.size(),r)}})}var i=r(172),o=r(166).clone,a=r(175).isInteger;t.name="diag",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e,t){var r=i(e),n=i(t),o=r[0];if(1!==r.length||1!==n.length)throw new RangeError("Vector expected");if(r[0]!=n[0])throw new RangeError("Vectors must have equal length ("+r[0]+" != "+n[0]+")");if(0==o)throw new RangeError("Cannot calculate the dot product of empty vectors");for(var a=0,c=0;o>c;c++)a=s(a,u(e[c],t[c]));return a}var s=n(r(32)),u=n(r(47));return o("dot",{"Matrix, Matrix":function(e,t){return a(e.toArray(),t.toArray())},"Matrix, Array":function(e,t){return a(e.toArray(),t)},"Array, Matrix":function(e,t){return a(e,t.toArray())},"Array, Array":a})}var i=r(172).size;t.name="dot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function s(e,t){switch(e.length){case 0:return t?c(t):[];case 1:return u(e[0],e[0],t);case 2:return u(e[0],e[1],t);default:throw new Error("Vector containing two values expected")}}function u(t,r,n){var a=t instanceof e.BigNumber?t.constructor:r instanceof e.BigNumber?r.constructor:null;if(t instanceof e.BigNumber&&(t=t.toNumber()),r instanceof e.BigNumber&&(r=r.toNumber()),!o(t)||1>t)throw new Error("Parameters in function eye must be positive integers");if(!o(r)||1>r)throw new Error("Parameters in function eye must be positive integers");var s=a?new e.BigNumber(1):1,u=a?new a(0):0,c=[t,r];if(n){var f=e.Matrix.storage(n);return f.diagonal(c,s,0,u)}for(var l=i.resize([],c,u),p=r>t?t:r,m=0;p>m;m++)l[m][m]=s;return l}var c=n(r(75));return a("eye",{"":function(){return"matrix"===t.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber":function(e){return u(e,e,"matrix"===t.matrix?"default":void 0)},"number | BigNumber, string":function(e,t){return u(e,e,t)},"number | BigNumber, number | BigNumber":function(e,r){return u(e,r,"matrix"===t.matrix?"default":void 0)},"number | BigNumber, number | BigNumber, string":function(e,t,r){return u(e,t,r)},Array:function(e){return s(e)},"Array, string":function(e,t){return s(e,t)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,t){return s(e.valueOf(),t)}})}var i=r(172),o=r(175).isInteger;t.name="eye",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(75));return a("flatten",{Array:function(e){return o(i(e))},Matrix:function(e){var t=o(i(e.toArray()));return s(t)}})}var i=r(166).clone,o=r(172).flatten;t.name="flatten",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e,t,r){var n,i,o,a,s;if(1==t){if(a=e[0][0],0==a)throw Error("Cannot calculate inverse, determinant is zero");return[[u(1,a)]]}if(2==t){var h=p(e);if(0==h)throw Error("Cannot calculate inverse, determinant is zero");return[[u(e[1][1],h),u(l(e[0][1]),h)],[u(l(e[1][0]),h),u(e[0][0],h)]]}var g=e.concat();for(n=0;t>n;n++)g[n]=g[n].concat();for(var v=m(t).valueOf(),d=0;r>d;d++){for(n=d;t>n&&0==g[n][d];)n++;if(n==t||0==g[n][d])throw Error("Cannot calculate inverse, determinant is zero");n!=d&&(s=g[d],g[d]=g[n],g[n]=s,s=v[d],v[d]=v[n],v[n]=s);var y=g[d],x=v[d];for(n=0;t>n;n++){var w=g[n],b=v[n];if(n!=d){if(0!=w[d]){for(o=u(l(w[d]),y[d]),i=d;r>i;i++)w[i]=c(w[i],f(o,y[i]));for(i=0;r>i;i++)b[i]=c(b[i],f(o,x[i]))}}else{for(o=y[d],i=d;r>i;i++)w[i]=u(w[i],o);for(i=0;r>i;i++)b[i]=u(b[i],o)}}}return v}var s=(n(r(2)),n(r(75))),u=n(r(213)),c=n(r(32)),f=n(r(47)),l=n(r(56)),p=n(r(91)),m=n(r(94)),h=o("inv",{"Array | Matrix":function(t){var r=t instanceof e.Matrix?t.size():i.array.size(t);switch(r.length){case 1:if(1==r[0])return t instanceof e.Matrix?s([u(1,t.valueOf()[0])]):[u(1,t[0])];throw new RangeError("Matrix must be square (size: "+i.string.format(r)+")");case 2:var n=r[0],o=r[1];if(n==o)return t instanceof e.Matrix?s(a(t.valueOf(),n,o),t.storage()):a(t,n,o);throw new RangeError("Matrix must be square (size: "+i.string.format(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+i.string.format(r)+")")}},any:function(e){return u(1,e)}});return h}var i=r(171);t.name="inv",t.factory=n},function(e,t,r){"use strict";e.exports=function(e,t){var n=r(171),i=e.type.BigNumber,o=e.type.Matrix,a=e.collection,s=n.array,u=n.number.isNumber,c=n.number.isInteger,f=n.string.isString,l=Array.isArray;e.ones=function(r,n){var p,m=a.argsToArray(arguments);m.length>0&&f(m[m.length-1])?(p=m[m.length-1],m=a.argsToArray(m.slice(0,m.length-1))):r instanceof o?p=r.storage():l(r)||"matrix"!==t.matrix||(p="default");var h=!1;m=m.map(function(e){if(e instanceof i&&(h=!0,e=e.toNumber()),!u(e)||!c(e)||0>e)throw new Error("Parameters in function eye must be positive integers");return e});var g=h?new i(1):1;if(p){var v=e.matrix(p);return m.length>0?v.resize(m,g):v}var d=[];return m.length>0?s.resize(d,m,g):d}}},function(e,t,r){"use strict";e.exports=function(e,t){function n(e,t,r){var n=[],i=e;if(r>0)for(;t>i;)n.push(i),i+=r;else if(0>r)for(;i>t;)n.push(i),i+=r;return n}function i(e,t,r){var n=[],i=e;if(r>0)for(;t>=i;)n.push(i),i+=r;else if(0>r)for(;i>=t;)n.push(i),i+=r;return n}function o(e,t,r){var n=[],i=e,o=new c(0);if(r.gt(o))for(;i.lt(t);)n.push(i),i=i.plus(r);else if(r.lt(o))for(;i.gt(t);)n.push(i),i=i.plus(r);return n}function a(e,t,r){var n=[],i=e,o=new c(0);if(r.gt(o))for(;i.lte(t);)n.push(i),i=i.plus(r);else if(r.lt(o))for(;i.gte(t);)n.push(i),i=i.plus(r);return n}function s(e){var r=e.split(":"),n=null;if("bignumber"===t.number)try{n=r.map(function(e){return new c(e)})}catch(i){return null}else{n=r.map(function(e){return Number(e)});var o=n.some(function(e){return isNaN(e)});if(o)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 u=r(171),c=e.type.BigNumber,f=(e.type.Matrix,e.collection,u["boolean"].isBoolean),l=u.string.isString,p=u.number.isNumber;e.range=function(r){var u,m,h,g=Array.prototype.slice.call(arguments),v=!1;switch(f(g[g.length-1])&&(v=g.pop()?!0:!1),g.length){case 1:if(!l(g[0]))throw new TypeError("Two or three numbers or a single string expected in function range");var d=s(g[0]);if(!d)throw new SyntaxError('String "'+g[0]+'" is no valid range');u=d.start,m=d.end,h=d.step;break;case 2:u=g[0],m=g[1],h=1;break;case 3:u=g[0],m=g[1],h=g[2];break;case 4:throw new TypeError("Parameter includeEnd must be a boolean");default:throw new e.error.ArgumentsError("range",arguments.length,2,4)}if(!(p(u)||u instanceof c))throw new TypeError("Parameter start must be a number");if(!(p(m)||m instanceof c))throw new TypeError("Parameter end must be a number");if(!(p(h)||h instanceof c))throw new TypeError("Parameter step must be a number");if(u instanceof c||m instanceof c||h instanceof c){var y=!0;u instanceof c||(u=c.convert(u)),m instanceof c||(m=c.convert(m)),h instanceof c||(h=c.convert(h)),u instanceof c&&m instanceof c&&h instanceof c||(y=!1,u instanceof c&&(u=u.toNumber()),m instanceof c&&(m=m.toNumber()),h instanceof c&&(h=h.toNumber()))}var x=y?v?a:o:v?i:n,w=x(u,m,h);return"array"===t.matrix?w:e.matrix(w)}}},function(e,t,r){"use strict";e.exports=function(e,t){function n(t,r,n){if(void 0!==n){if(!f(n)||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==r.length)throw new e.error.DimensionError(r.length,1);var i=r[0];if(!l(i)||!p(i))throw new TypeError("Invalid size, must contain positive integers (size: "+c.format(r)+")");if(t.length>i)return t.substring(0,i);if(t.lengtha;a++)o+=n;return o}return t}var i=r(171),o=e.type.BigNumber,a=e.type.Matrix,s=i.array,u=i.object.clone,c=i.string,f=i.string.isString,l=i.number.isNumber,p=i.number.isInteger,m=s.isArray;e.resize=function(r,i,c){if(2!=arguments.length&&3!=arguments.length)throw new e.error.ArgumentsError("resize",arguments.length,2,3);if(i instanceof a&&(i=i.valueOf()),i.length&&i[0]instanceof o&&(i=i.map(function(e){return e instanceof o?e.toNumber():e})),r instanceof a)return r.resize(i,c,!0);if(f(r))return n(r,i,c);var l=m(r)?!1:"array"!==t.matrix;if(0==i.length){for(;m(r);)r=r[0];return u(r)}m(r)||(r=[r]),r=u(r);var p=s.resize(r,i,c);return l?e.matrix(p):p}}},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(75));return o("size",{Matrix:function(e){return a(e.size())},Array:i.size,string:function(e){return"array"===t.matrix?[e.length]:a([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"array"===t.matrix?[]:a([])}})}var i=r(172);t.name="size",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(75));return a("squeeze",{Array:function(e){return o.squeeze(i.clone(e))},Matrix:function(e){var t=o.squeeze(e.toArray());return Array.isArray(t)?s(t):t},any:function(e){return i.clone(e)}})}var i=r(166),o=r(172);t.name="squeeze",t.factory=n},function(e,t,r){"use strict";e.exports=function(e,t){function n(t,r){var n,o;if(p(t))return n=e.matrix(t),o=n.subset(r),o&&o.valueOf();if(t instanceof u)return t.subset(r);if(l(t))return i(t,r);throw new e.error.UnsupportedTypeError("subset",e["typeof"](t))}function i(t,r){if(!(r instanceof c))throw new TypeError("Index expected");if(1!=r.size().length)throw new e.error.DimensionError(r.size().length,1);var n=t.length;f.validateIndex(r.min()[0],n),f.validateIndex(r.max()[0],n);var i=r.range(0),o="";return i.forEach(function(e){o+=t.charAt(e)}),o}function o(t,r,n,i){var o;if(p(t))return o=e.matrix(e.clone(t)),o.subset(r,n,i),o.valueOf();if(t instanceof u)return t.clone().subset(r,n,i);if(l(t))return a(t,r,n,i);throw new e.error.UnsupportedTypeError("subset",e["typeof"](t))}function a(t,r,n,i){if(!(r instanceof c))throw new TypeError("Index expected");if(1!=r.size().length)throw new e.error.DimensionError(r.size().length,1);if(void 0!==i){if(!l(i)||1!==i.length)throw new TypeError("Single character expected as defaultValue")}else i=" ";var o=r.range(0),a=o.size()[0];if(a!=n.length)throw new e.error.DimensionError(o.size()[0],n.length);var s=t.length;f.validateIndex(r.min()[0]),f.validateIndex(r.max()[0]);for(var u=[],p=0;s>p;p++)u[p]=t.charAt(p);if(o.forEach(function(e,t){u[e]=n.charAt(t)}),u.length>s)for(p=s-1,a=u.length;a>p;p++)u[p]||(u[p]=i);return u.join("")}var s=r(171),u=e.type.Matrix,c=r(5),f=s.array,l=s.string.isString,p=Array.isArray;e.subset=function(t,r,i,a){switch(arguments.length){case 2:return n(arguments[0],arguments[1]);case 3:case 4:return o(arguments[0],arguments[1],arguments[2],arguments[3]);default:throw new e.error.ArgumentsError("subset",arguments.length,2,4)}}}},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(75)),u=n(r(32)),c=a("trace",{Array:function(e){return c(s(e))},Matrix:function(e){var t;switch(e.storage()){case"dense":t=f(e);break;case"sparse":t=l(e)}return t},any:i}),f=function(e){var t=e._size,r=e._data;switch(t.length){case 1:if(1==t[0])return i(r[0]);throw new RangeError("Matrix must be square (size: "+o(t)+")");case 2:var n=t[0],a=t[1];if(n===a){for(var s=0,c=0;n>c;c++)s=u(s,r[c][c]);return s}throw new RangeError("Matrix must be square (size: "+o(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+o(t)+")")}},l=function(e){var t=e._values,r=e._index,n=e._ptr,i=e._size,a=i[0],s=i[1];if(a===s){var c=0;if(t.length>0)for(var f=0;s>f;f++)for(var l=n[f],p=n[f+1],m=l;p>m;m++){var h=r[m];if(h===f){c=u(c,t[m]);break}if(h>f)break}return c}throw new RangeError("Matrix must be square (size: "+o(i)+")")};return c}var i=r(166).clone,o=r(176).format;t.name="trace",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(75)),u=e.DenseMatrix,c=e.SparseMatrix,f=a("transpose",{Array:function(e){return f(s(e)).valueOf()},Matrix:function(e){var t,r=e.size();switch(r.length){case 1:t=e.clone();break;case 2:var n=r[0],i=r[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+o(r)+")");switch(e.storage()){case"dense":t=l(e,n,i);break;case"sparse":t=p(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+o(this._size)+")")}return t},any:function(e){return i(e)}}),l=function(e,t,r){for(var n,o=e._data,a=[],s=0;r>s;s++){n=a[s]=[];for(var c=0;t>c;c++)n[c]=i(o[c][s])}return new u({data:a,size:[r,t]})},p=function(e,t,r){for(var n=e._values,o=e._index,a=e._ptr,s=[],u=[],f=[],l=new Array(t),p=0;t>p;p++)l[p]=0;var m,h,g;for(m=0,h=o.length;h>m;m++)l[o[m]]++;for(var v=0,d=0;t>d;d++)f.push(v),v+=l[d],l[d]=f[d];for(f.push(v),g=0;r>g;g++)for(var y=a[g],x=a[g+1],w=y;x>w;w++){var b=l[o[w]]++;u[b]=g,s[b]=i(n[w])}return new c({values:s,index:u,ptr:f,size:[r,t]})};return f}var i=r(166).clone,o=r(176).format;t.name="transpose",t.factory=n},function(e,t,r){"use strict";e.exports=function(e,t){var n=r(171),i=e.type.BigNumber,o=e.type.Matrix,a=e.collection,s=n.array,u=n.number.isNumber,c=n.number.isInteger,f=n.string.isString,l=Array.isArray;e.zeros=function(r){var n,p=a.argsToArray(arguments);p.length>0&&f(p[p.length-1])?(n=p[p.length-1],p=a.argsToArray(p.slice(0,p.length-1))):r instanceof o?n=r.storage():l(r)||"matrix"!==t.matrix||(n="default");var m=!1;p=p.map(function(e){if(e instanceof i&&(m=!0,e=e.toNumber()),!u(e)||!c(e)||0>e)throw new Error("Parameters in function eye must be positive integers");return e});var h=m?new i(0):0;if(n){var g=e.matrix(n);return p.length>0?g.resize(p,h):g}var v=[];return p.length>0?s.resize(v,p,h):v}}},function(e,t,r){"use strict";function n(e,t,r,n){return n("combinations",{"number, number":function(e,t){var r,n,i;if(!o(e)||0>e)throw new TypeError("Positive integer value expected in function combinations");if(t>e)throw new TypeError("k must be less than or equal to n");for(r=Math.max(t,e-t),n=1,i=1;e-r>=i;i++)n=n*(r+i)/i;return n},"BigNumber, BigNumber":function(t,r){var n,o,a,s,u=new e.BigNumber(1);if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function combinations");if(r.gt(t))throw new TypeError("k must be less than n in function combinations");for(n=t.minus(r),r.lt(n)&&(n=r),o=u,a=u,s=t.minus(n);a.lte(s);a=a.plus(1))o=o.times(n.plus(a)).dividedBy(a);return o}})}function i(e){return e.isInteger()&&e.gte(0)}var o=r(175).isInteger;t.name="combinations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=n(r(108)),u=o("factorial",{number:function(e){return e===Number.POSITIVE_INFINITY?Math.sqrt(2*Math.PI):s(e+1)},BigNumber:function(e){return e.isFinite()||e.isNegative()?s(e.plus(1)):i.tau(t.precision).sqrt()},"Array | Matrix":function(e){return a.deepMap(e,u)}});return u}var i=r(214);t.name="factorial",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,c){function f(r){var n,i,o,a=r.toNumber();if(ap;++p)o[p]=i=i.times(n),n=n.plus(l);return o[a]=i.times(n),new e.BigNumber(o[a].toPrecision(t.precision))}var l=n(r(2)),p=n(r(47)),m=n(r(50)),h=c("gamma",{ -number:function(e){var t,r;if(i(e)){if(0>=e)return isFinite(e)?1/0:0/0;if(e>171)return 1/0;for(var n=e-2,s=e-1;n>1;)s*=n,n--;return 0==s&&(s=1),s}if(.5>e)return Math.PI/(Math.sin(Math.PI*e)*h(1-e));if(e>=171.35)return 1/0;if(e>85){var u=e*e,c=u*e,f=c*e,l=f*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*u)-139/(51840*c)-571/(2488320*f)+163879/(209018880*l)+5246819/(75246796800*l*e))}--e,r=a[0];for(var p=1;pe)throw new TypeError("Positive integer value expected in function permutations");if(!o(t)||0>t)throw new TypeError("Positive integer value expected in function permutations");if(t>e)throw new TypeError("second argument k must be less than or equal to first argument n");for(r=1,n=e-t+1;e>=n;n++)r*=n;return r},"BigNumber, BigNumber":function(t,r){var n,o;if(!i(t)||!i(r))throw new TypeError("Positive integer value expected in function permutations");if(r.gt(t))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=new e.BigNumber(1),o=t.minus(r).plus(1);o.lte(t);o=o.plus(1))n=n.times(o);return n}})}function i(e){return e.isInteger()&&e.gte(0)}var o=r(175).isInteger;t.name="permutations",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(215));return o("uniform").pickRandom}t.name="pickRandom",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(215));return o("uniform").random}t.name="random",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(215));return o("uniform").randomInt}t.name="randomInt",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("compare",{"boolean, boolean":function(e,t){return e===t?0:e>t?1:-1},"number, number":function(e,r){return e===r||i(e,r,t.epsilon)?0:e>r?1:-1},"BigNumber, BigNumber":function(e,t){return new e.constructor(e.cmp(t))},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.value===r.value||i(e.value,r.value,t.epsilon)?0:e.value>r.value?1:-1},"string, string":function(e,t){return e===t?0:e>t?1:-1},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).nearlyEqual;t.name="compare",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){if(Array.isArray(e)){if(Array.isArray(t)){var r=e.length;if(r!==t.length)return!1;for(var n=0;r>n;n++)if(!o(e[n],t[n]))return!1;return!0}return!1}return Array.isArray(t)?!1:a(e,t)}var a=(n(r(2)),n(r(115)));return i("deepEqual",{"any, any":function(e,t){return o(e.valueOf(),t.valueOf())}})}t.name="deepEqual",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("equal",{"any, any":function(e,t){return null===e?null===t:null===t?null===e:void 0===e?void 0===t:void 0===t?void 0===e:u(e,t)},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,u)}}),u=o("_equal",{"boolean, boolean":function(e,t){return e===t},"number, number":function(e,r){return e===r||i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return e.eq(t)},"Complex, Complex":function(e,r){return(e.re===r.re||i(e.re,r.re,t.epsilon))&&(e.im===r.im||i(e.im,r.im,t.epsilon))},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.value===r.value||i(e.value,r.value,t.epsilon)},"string, string":function(e,t){return e===t}});return s}var i=r(175).nearlyEqual;t.name="equal",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("larger",{"boolean, boolean":function(e,t){return e>t},"number, number":function(e,r){return e>r&&!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gt(t)},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.value>r.value&&!i(e.value,r.value,t.epsilon)},"string, string":function(e,t){return e>t},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).nearlyEqual;t.name="larger",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("largerEq",{"boolean, boolean":function(e,t){return e>=t},"number, number":function(e,r){return e>=r||i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return e.gte(t)},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.value>=r.value||i(e.value,r.value,t.epsilon)},"string, string":function(e,t){return e>=t},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).nearlyEqual;t.name="largerEq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("smaller",{"boolean, boolean":function(e,t){return t>e},"number, number":function(e,r){return r>e&&!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lt(t)},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.valuee},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).nearlyEqual;t.name="smaller",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("smallerEq",{"boolean, boolean":function(e,t){return t>=e},"number, number":function(e,r){return r>=e||i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return e.lte(t)},"Complex, Complex":function(e,t){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return e.value<=r.value||i(e.value,r.value,t.epsilon)},"string, string":function(e,t){return t>=e},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(175).nearlyEqual;t.name="smallerEq",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("unequal",{"any, any":function(e,t){return null===e?null!==t:null===t?null!==e:void 0===e?void 0!==t:void 0===t?void 0!==e:u(e,t)},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,u)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,u)}}),u=o("_unequal",{"boolean, boolean":function(e,t){return e!==t},"number, number":function(e,r){return!i(e,r,t.epsilon)},"BigNumber, BigNumber":function(e,t){return!e.eq(t)},"Complex, Complex":function(e,r){return!i(e.re,r.re,t.epsilon)||!i(e.im,r.im,t.epsilon)},"Unit, Unit":function(e,r){if(!e.equalBase(r))throw new Error("Cannot compare units with different base");return!i(e.value,r.value,t.epsilon)},"string, string":function(e,t){return e!==t}});return s}var i=r(175).nearlyEqual;t.name="unequal",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){return u(e,t)?e:t}function a(e){var t=void 0;if(s.deepForEach(e,function(e){(void 0===t||u(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate max of an empty array");return t}var s=n(r(2)),u=n(r(116));return i("max",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){return s.reduce(e,t.valueOf(),o)},"...":function(){return a(arguments)}})}t.name="max",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e,t){var r=u.reduce(e,t,c),n=Array.isArray(e)?i(e):e.size();return f(r,n[t])}function s(e){var t=0,r=0;if(u.deepForEach(e,function(e){t=c(t,e),r++}),0===r)throw new Error("Cannot calculate mean of an empty array");return f(t,r)}var u=n(r(2)),c=n(r(32)),f=n(r(35));return o("mean",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":a,"...":function(){return s(arguments)}})}var i=r(172).size;t.name="mean",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e){var t=i(e.valueOf());t.sort(c);var r=t.length;if(0==r)throw new Error("Cannot calculate median of an empty array");return r%2==0?p(t[r/2-1],t[r/2]):l(t[(r-1)/2])}var s=n(r(32)),u=n(r(35)),c=n(r(113)),f=o("median",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("median(A, dim) is not yet supported")},"...":function(){return a(Array.prototype.slice.call(arguments))}}),l=o("number | BigNumber | Unit",function(e){return e}),p=o("number | BigNumber | Unit, number | BigNumber | Unit",function(e,t){return u(s(e,t),2)});return f}var i=r(172).flatten;t.name="median",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){return u(e,t)?e:t}function a(e){var t=void 0;if(s.deepForEach(e,function(e){(void 0===t||u(e,t))&&(t=e)}),void 0===t)throw new Error("Cannot calculate min of an empty array");return t}var s=n(r(2)),u=n(r(118));return i("min",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,t){return s.reduce(e,t.valueOf(),o)},"...":function(){return a(arguments)}})}t.name="min",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e){var t=void 0;if(a.deepForEach(e,function(e){t=void 0===t?e:s(t,e)}),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}var a=n(r(2)),s=n(r(47));return i("prod",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(){return o(arguments)}})}t.name="prod",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e,t){if(0==e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return a(s.apply(null,arguments))}var a=(n(r(2)),n(r(53))),s=n(r(128));return i("std",{"Array | Matrix":o,"Array | Matrix, string":o,"...":function(){return o(Array.prototype.slice.call(arguments))}})}t.name="std",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){function o(e){var t=void 0;if(a.deepForEach(e,function(e){t=void 0===t?e:s(t,e)}),void 0===t)throw new Error("Cannot calculate sum of an empty array");return t}var a=n(r(2)),s=n(r(32));return i("sum",{"Array | Matrix":function(e){return o(e)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(){return o(arguments)}})}t.name="sum",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t,r){var n=0,i=0;if(0==t.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(s.deepForEach(t,function(e){n=u(n,e),i++}),0===i)throw new Error("Cannot calculate var of an empty array");var o=l(n,i);switch(n=0,s.deepForEach(t,function(e){var t=c(e,o);n=u(n,f(t,t))}),r){case"uncorrected":return l(n,i);case"biased":return l(n,i+1);case"unbiased":var a=n instanceof e.BigNumber?new e.BigNumber(0):0;return 1==i?a:l(n,i-1);default:throw new Error('Unknown normalization "'+r+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}var s=n(r(2)),u=n(r(32)),c=n(r(55)),f=n(r(47)),l=n(r(35));return o("variance",{"Array | Matrix":function(e){return a(e,i)},"Array | Matrix, string":a,"...":function(){return a(arguments,i)}})}var i="unbiased";t.name="var",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){var r=new e.Complex(t.im*t.im-t.re*t.re+1,-2*t.re*t.im),n=u(r),i=new e.Complex(n.re-t.im,n.im+t.re),o=c(i);return new e.Complex(1.5707963267948966-o.im,o.re)}var s=n(r(2)),u=n(r(53)).signatures.Complex,c=n(r(44)).signatures.Complex,f=o("acos",{number:function(t){return t>=-1&&1>=t?Math.acos(t):a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,f)}});return f}var i=r(214).arccos_arcsec;t.name="acos",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e){var t,r=u(e);return r.im<=0?(t=r.re,r.re=-r.im,r.im=t):(t=r.im,r.im=-r.re,r.re=t),r}var s=n(r(2)),u=n(r(129)).signatures.Complex,c=o("acosh",{number:function(t){return t>=1?Math.log(Math.sqrt(t*t-1)+t):-1>=t?new e.Complex(Math.log(Math.sqrt(t*t-1)-t),Math.PI):a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!1,!1)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=r(214).acosh_asinh_asech_acsch;t.name="acosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=n(r(139)).signatures.Complex,c=a("acot",{number:function(e){return e?Math.atan(1/e):o},Complex:function(t){if(0==t.im)return new e.Complex(t.re?Math.atan(1/t.re):o,0);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re=t.re/r,t.im=-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),u(t)},BigNumber:function(t){return i(t,e.BigNumber,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=r(214).arctan_arccot,o=1.5707963267948966;t.name="acot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function s(t){if(0==t.re&&0==t.im)return new e.Complex(0,o);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re/r,-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),u(t)}var u=n(r(141)).signatures.Complex,c=n(r(2)),f=a("acoth",{number:function(t){return t>=1||-1>=t?isFinite(t)?(Math.log((t+1)/t)+Math.log(t/(t-1)))/2:0:0!==t?s(new e.Complex(t,0)):new e.Complex(0,o)},Complex:s,BigNumber:function(t){return i(t,e.BigNumber,!0)},"Array | Matrix":function(e){return c.deepMap(e,f)}});return f}var i=r(214).atanh_acoth,o=1.5707963267948966;t.name="acoth",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){function s(t){if(0==t.re&&0==t.im)return new e.Complex(o,1/0);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re=t.re/r,t.im=-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),c(t)}var u=n(r(2)),c=n(r(137)).signatures.Complex,f=a("acsc",{number:function(t){return-1>=t||t>=1?Math.asin(1/t):s(new e.Complex(t,0))},Complex:s,BigNumber:function(t){return i(t,e.BigNumber,!0)},"Array | Matrix":function(e){return u.deepMap(e,f)}});return f}var i=r(214).arcsin_arccsc,o=1.5707963267948966;t.name="acsc",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=n(r(138)).signatures.Complex,u=o("acsch",{number:function(e){return e=1/e,Math.log(e+Math.sqrt(e*e+1))},Complex:function(t){if(0==t.im)return t=0!=t.re?Math.log(t.re+Math.sqrt(t.re*t.re+1)):1/0,new e.Complex(t,0);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re/r,-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),s(t)},BigNumber:function(t){return i(t,e.BigNumber,!0,!0)},"Array | Matrix":function(e){return a.deepMap(e,u)}});return u}var i=r(214).acosh_asinh_asech_acsch;t.name="acsch",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){if(0==t.re&&0==t.im)return new e.Complex(0,1/0);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re=t.re/r,t.im=-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),u(t)}var s=n(r(2)),u=n(r(129)).signatures.Complex,c=o("asec",{number:function(t){return-1>=t||t>=1?Math.acos(1/t):a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=r(214).arccos_arcsec;t.name="asec",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){if(0==t.re&&0==t.im)return new e.Complex(1/0,0);var r=t.re*t.re+t.im*t.im;return t=0!=r?new e.Complex(t.re/r,-t.im/r):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?-(t.im/0):0),u(t)}var s=n(r(2)),u=n(r(130)).signatures.Complex,c=o("asech",{number:function(t){if(1>=t&&t>=-1){t=1/t;var r=Math.sqrt(t*t-1);return t>0?Math.log(r+t):new e.Complex(Math.log(r-t),Math.PI)}return a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!1,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=r(214).acosh_asinh_asech_acsch;t.name="asech",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){var r=t.re,n=t.im,i=new e.Complex(n*n-r*r+1,-2*r*n),o=u(i),a=new e.Complex(o.re-n,o.im+r),s=c(a);return new e.Complex(s.im,-s.re)}var s=n(r(2)),u=n(r(53)).signatures.Complex,c=n(r(44)).signatures.Complex,f=o("asin",{number:function(t){return t>=-1&&1>=t?Math.asin(t):a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,f,!0)}});return f}var i=r(214).arcsin_arccsc;t.name="asin",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=n(r(137)).signatures.Complex,u=o("asinh",{number:function(e){return Math.log(Math.sqrt(e*e+1)+e)},Complex:function(e){var t=e.im;e.im=-e.re,e.re=t;var r=s(e);return e.re=-e.im,e.im=t,t=r.re,r.re=-r.im,r.im=t,r},BigNumber:function(t){return i(t,e.BigNumber,!0,!1)},"Array | Matrix":function(e){return a.deepMap(e,u,!0)}});return u}var i=r(214).acosh_asinh_asech_acsch;t.name="asinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=n(r(44)).signatures.Complex,u=o("atan",{number:function(e){return Math.atan(e)},Complex:function(t){if(0==t.re){if(1==t.im)return new e.Complex(0,1/0);if(-1==t.im)return new e.Complex(0,-(1/0))}var r=t.re,n=t.im,i=r*r+(1-n)*(1-n),o=new e.Complex((1-n*n-r*r)/i,-2*r/i),a=s(o);return new e.Complex(-.5*a.im,.5*a.re)},BigNumber:function(t){return i(t,e.BigNumber,!1)},"Array | Matrix":function(e){return a.deepMap(e,u,!0)}});return u}var i=r(214).arctan_arccot;t.name="atan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(t,r){return i(t,r,e.BigNumber)},"Array | Matrix, any":function(e,t){return a.deepMap2(e,t,s)},"any, Array | Matrix":function(e,t){return a.deepMap2(e,t,s)}});return s}var i=r(214).arctan2;t.name="atan2",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){var r=t.re>1&&0==t.im,n=1-t.re,i=1+t.re,o=n*n+t.im*t.im;t=0!=o?new e.Complex((i*n-t.im*t.im)/o,(t.im*n+i*t.im)/o):new e.Complex(-1!=t.re?t.re/0:0,0!=t.im?t.im/0:0);var a=t.re;return t.re=Math.log(Math.sqrt(t.re*t.re+t.im*t.im))/2,t.im=Math.atan2(t.im,a)/2,r&&(t.im=-t.im),t}var s=n(r(2)),u=o("atanh",{number:function(t){return 1>=t&&t>=-1?Math.log((1+t)/(1-t))/2:a(new e.Complex(t,0))},Complex:a,BigNumber:function(t){return i(t,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}var i=r(214).atanh_acoth;t.name="atanh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=n(r(143)).signatures.number,u=n(r(151)).signatures.number,c=o("cos",{number:Math.cos,Complex:function(t){return new e.Complex(Math.cos(t.re)*s(-t.im),Math.sin(t.re)*u(-t.im))},BigNumber:function(t){return i(t,e.BigNumber,0,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.cos(t.value)},"Array | Matrix":function(e){return a.deepMap(e,c)}});return c}var i=r(214).cos_sin_sec_csc;t.name="cos",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("cosh",{number:i,Complex:function(t){var r=Math.exp(t.re),n=Math.exp(-t.re);return new e.Complex(Math.cos(t.im)*(r+n)/2,Math.sin(t.im)*(r-n)/2)},BigNumber:function(t){return o(t,e.BigNumber,!1,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return(Math.exp(e)+Math.exp(-e))/2}var o=r(214).cosh_sinh_csch_sech;t.name="cosh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("cot",{number:function(e){return 1/Math.tan(e)},Complex:function(t){var r=Math.exp(-4*t.im)-2*Math.exp(-2*t.im)*Math.cos(2*t.re)+1;return new e.Complex(2*Math.exp(-2*t.im)*Math.sin(2*t.re)/r,(Math.exp(-4*t.im)-1)/r)},BigNumber:function(t){return i(t,e.BigNumber,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return 1/Math.tan(t.value)},"Array | Matrix":function(e){return a.deepMap(e,s)}});return s}var i=r(214).tan_cot;t.name="cot",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("coth",{number:i,Complex:function(t){var r=Math.exp(2*t.re),n=r*Math.cos(2*t.im),i=r*Math.sin(2*t.im),o=(n-1)*(n-1)+i*i;return new e.Complex(((n+1)*(n-1)+i*i)/o,-2*i/o)},BigNumber:function(t){return o(t,e.BigNumber,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){var t=Math.exp(2*e);return(t+1)/(t-1)}var o=r(214).tanh_coth;t.name="coth",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("csc",{number:function(e){return 1/Math.sin(e)},Complex:function(t){var r=.25*(Math.exp(-2*t.im)+Math.exp(2*t.im))-.5*Math.cos(2*t.re);return new e.Complex(.5*Math.sin(t.re)*(Math.exp(-t.im)+Math.exp(t.im))/r,.5*Math.cos(t.re)*(Math.exp(-t.im)-Math.exp(t.im))/r)},BigNumber:function(t){return i(t,e.BigNumber,1,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return 1/Math.sin(t.value)},"Array | Matrix":function(e){return a.deepMap(e,s)}});return s}var i=r(214).cos_sin_sec_csc;t.name="csc",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("csch",{number:i,Complex:function(t){var r=Math.exp(t.re),n=Math.exp(-t.re),i=Math.cos(t.im)*(r-n),o=Math.sin(t.im)*(r+n),a=i*i+o*o;return new e.Complex(2*i/a,-2*o/a)},BigNumber:function(t){return o(t,e.BigNumber,!0,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return 0==e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*a(e)}var o=r(214).cosh_sinh_csch_sech,a=r(175).sign;t.name="csch",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("sec",{number:function(e){return 1/Math.cos(e)},Complex:function(t){var r=.25*(Math.exp(-2*t.im)+Math.exp(2*t.im))+.5*Math.cos(2*t.re);return new e.Complex(.5*Math.cos(t.re)*(Math.exp(-t.im)+Math.exp(t.im))/r,.5*Math.sin(t.re)*(Math.exp(t.im)-Math.exp(-t.im))/r)},BigNumber:function(t){return i(t,e.BigNumber,0,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return 1/Math.cos(t.value)},"Array | Matrix":function(e){return a.deepMap(e,s)}});return s}var i=r(214).cos_sin_sec_csc;t.name="sec",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("sech",{number:i,Complex:function(t){var r=Math.exp(t.re),n=Math.exp(-t.re),i=Math.cos(t.im)*(r+n),o=Math.sin(t.im)*(r-n),a=i*i+o*o;return new e.Complex(2*i/a,-2*o/a)},BigNumber:function(t){return o(t,e.BigNumber,!1,!0)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return 2/(Math.exp(e)+Math.exp(-e))}var o=r(214).cosh_sinh_csch_sech;t.name="sech",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(143)).signatures.number,s=n(r(151)).signatures.number,u=n(r(2)),c=o("sin",{number:Math.sin,Complex:function(t){return new e.Complex(Math.sin(t.re)*a(-t.im),Math.cos(t.re)*s(t.im))},BigNumber:function(t){return i(t,e.BigNumber,1,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return Math.sin(t.value)},"Array | Matrix":function(e){return u.deepMap(e,c,!0)}});return c}var i=r(214).cos_sin_sec_csc;t.name="sin",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("sinh",{number:i,Complex:function(t){var r=Math.cos(t.im),n=Math.sin(t.im),i=Math.exp(t.re),o=Math.exp(-t.re);return new e.Complex(r*(i-o)/2,n*(i+o)/2)},BigNumber:function(t){return o(t,e.BigNumber,!0,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}function i(e){return Math.abs(e)<1?e+e*e*e/6+e*e*e*e*e/120:(Math.exp(e)-Math.exp(-e))/2}var o=r(214).cosh_sinh_csch_sech;t.name="sinh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(2)),s=o("tan",{number:Math.tan,Complex:function(t){var r=Math.exp(-4*t.im)+2*Math.exp(-2*t.im)*Math.cos(2*t.re)+1;return new e.Complex(2*Math.exp(-2*t.im)*Math.sin(2*t.re)/r,(1-Math.exp(-4*t.im))/r)},BigNumber:function(t){return i(t,e.BigNumber,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return Math.tan(t.value)},"Array | Matrix":function(e){return a.deepMap(e,s,!0)}});return s}var i=r(214).tan_cot;t.name="tan",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(2)),u=a("tanh",{number:i,Complex:function(t){var r=Math.exp(2*t.re),n=r*Math.cos(2*t.im),i=r*Math.sin(2*t.im),o=(n+1)*(n+1)+i*i;return new e.Complex(((n-1)*(n+1)+i*i)/o,2*i/o)},BigNumber:function(t){return o(t,e.BigNumber,!1)},Unit:function(t){if(!t.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return i(t.value)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}function i(e){var t=Math.exp(2*e);return(t-1)/(t+1)}var o=r(214).tanh_coth;t.name="tanh",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(2)),a=i("to",{"Unit, Unit | string":function(e,t){return e.to(t)},"Array | Matrix, any":function(e,t){return o.deepMap2(e,t,a)},"any, Array | Matrix":function(e,t){return o.deepMap2(e,t,a)}});return a}t.name="to",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("clone",{any:i.clone})}var i=r(166);t.name="clone",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o,a){return function(n){return n&&(i.deepExtend(t,n),n.precision&&e.BigNumber&&e.BigNumber.config({precision:n.precision}),r(169)(a,t)),i.clone(t)}}var i=r(166);t.name="config",t.math=!0,t.factory=n},function(e,t,r){"use strict";function n(e,t,n,a){var s=n(r(75));return a("filter",{"Array, function":i,"Array, RegExp":o,"Matrix, function":function(e,t){return s(i(e.toArray(),t))},"Matrix, RegExp":function(e,t){return s(o(e.toArray(),t))}})}function i(e,t){if(1!==a(e).length)throw new Error("Only one dimensional matrices supported");return e.filter(function(e){return t(e)})}function o(e,t){if(1!==a(e).length)throw new Error("Only one dimensional matrices supported");return e.filter(function(e){return t.test(e)})}var a=r(172).size;t.name="filter",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("format",{any:i.format,"any, Object | function | number":i.format})}var i=r(176);t.name="format",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("map",{"Array, function":i,"Matrix, function":function(e,t){return e.map(t)}})}function i(e,t){var r=function(n,i){return Array.isArray(n)?n.map(function(e,t){return r(e,i.concat(t))}):t(n,i,e)};return r(e,[])}t.name="map",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("print",{"string, Object":i,"string, Object, number":i})}function i(e,t,r){return e.replace(/\$([\w\.]+)/g,function(e,n){for(var i=n.split("."),s=t[i.shift()];i.length&&void 0!==s;){var u=i.shift();s=u?s[u]:s+"."}return void 0!==s?o(s)?s:a(s,r):e})}var o=r(176).isString,a=r(176).format;t.name="print",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){function a(e){if("asc"===e)return f;if("desc"===e)return l;throw new Error('String "asc" or "desc" expected')}function s(e){if(1!==i(e).length)throw new Error("One dimensional array expected")}function u(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}var c=n(r(75)),f=n(r(113)),l=function(e,t){return-f(e,t)};return o("sort",{Array:function(e){return s(e),e.sort(f)},Matrix:function(e){return u(e),c(e.toArray().sort(f),e.storage())},"Array, function":function(e,t){return s(e),e.sort(t)},"Matrix, function":function(e,t){return u(e),c(e.toArray().sort(t),e.storage())},"Array, string":function(e,t){return s(e),e.sort(a(t))},"Matrix, string":function(e,t){return u(e),c(e.toArray().sort(a(t)),e.storage())}})}var i=r(172).size;t.name="sort",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("_typeof",{any:function(t){var r=i.type(t);if("object"===r){if(t instanceof e.Complex)return"complex";if(t instanceof e.Matrix)return"matrix";if(t instanceof e.Unit)return"unit";if(t instanceof e.Index)return"index";if(t instanceof e.Range)return"range";if(t instanceof e.Help)return"help";if(t instanceof e.BigNumber)return"bignumber";if(t instanceof e.Chain)return"chain"}return r}})}var i=r(216);t.name="typeof",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){return n("forEach",{"Array, function":i,"Matrix, function":function(e,t){return e.forEach(t)}})}function i(e,t){var r=function(n,i){Array.isArray(n)?n.forEach(function(e,t){r(e,i.concat(t))}):t(n,i,e)};r(e,[])}t.name="forEach",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var a=n(r(75)),s=n(r(31)),u=n(r(32)),c=n(r(213)),f=n(r(47)),l=n(r(55)),p=n(r(116)),m=n(r(115)),h=n(r(56)),g=e.SparseMatrix,v=e.DenseMatrix,d=e.Spa,y=i("lup",{Matrix:function(e){switch(e.storage()){case"dense":return x(e);case"sparse":return w(e)}},Array:function(e){var t=a(e),r=y(t);return{L:r.L.valueOf(),U:r.U.valueOf(),P:r.P.valueOf()}}}),x=function(e){var t,r,n,i=e._size[0],a=e._size[1],h=Math.min(i,a),g=o.clone(e._data),d=[],y=[i,h],x=[],w=[h,a],b=v.diagonal([i,i],1,0);for(r=0;a>r;r++){if(r>0)for(t=0;i>t;t++){var N=Math.min(t,r),E=0;for(n=0;N>n;n++)E=u(E,f(g[t][n],g[n][r]));g[t][r]=l(g[t][r],E)}var M=r,A=0,_=0;for(t=r;i>t;t++){var O=g[t][r],C=s(O);p(C,A)&&(M=t,A=C,_=O)}if(r!==M&&(v._swapRows(r,M,b._data), -v._swapRows(r,M,g)),i>r)for(t=r+1;i>t;t++){var S=g[t][r];m(S,0)||(g[t][r]=c(g[t][r],_))}}for(r=0;a>r;r++)for(t=0;i>t;t++)0===r&&(a>t&&(x[t]=[]),d[t]=[]),r>t?(a>t&&(x[t][r]=g[t][r]),i>r&&(d[t][r]=0)):t!==r?(a>t&&(x[t][r]=0),i>r&&(d[t][r]=g[t][r])):(a>t&&(x[t][r]=g[t][r]),i>r&&(d[t][r]=1));var z=new v({data:d,size:y}),T=new v({data:x,size:w});return{L:z,U:T,P:b,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.P.toString()}}},w=function(e){var t,r,n,i=e._size[0],o=e._size[1],a=Math.min(i,o),u=e._values,l=e._index,v=e._ptr,y=[],x=[],w=[],b=[i,a],N=[],E=[],M=[],A=[a,o],_=[],O=[],C=[],S=[i,i],z=new Array(i),T=new Array(i);for(t=0;i>t;t++)z[t]=t,T[t]=t;var B=function(e,t){var r=T[e],n=T[t];z[r]=t,z[n]=e,T[e]=n,T[t]=r};for(r=0;o>r;r++){var I=new d(i);i>r&&(w.push(y.length),y.push(1),x.push(r)),M.push(N.length);var q=v[r],P=v[r+1];for(n=q;P>n;n++)t=l[n],I.set(z[t],u[n]);r>0&&I.forEach(0,r-1,function(e,t){g._forEachRow(e,y,x,w,function(r,n){r>e&&I.accumulate(r,h(f(n,t)))})});var U=r,R=I.get(r),L=s(R);I.forEach(r+1,i-1,function(e,t){var r=s(t);p(r,L)&&(U=e,L=r,R=t)}),r!==U&&(g._swapRows(r,U,b[1],y,x,w),g._swapRows(r,U,A[1],N,E,M),I.swap(r,U),B(r,U)),I.forEach(0,i-1,function(e,t){r>=e?(N.push(t),E.push(e)):(t=c(t,R),m(t,0)||(y.push(t),x.push(e)))})}for(w.push(y.length),M.push(N.length),t=0;i>t;t++)C.push(_.length),_.push(1),O.push(z[t]);return C.push(_.length),{L:new g({values:y,index:x,ptr:w,size:b}),U:new g({values:N,index:E,ptr:M,size:A}),P:new g({values:_,index:O,ptr:C,size:S}),toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.P.toString()}}};return y}var i=r(171),o=i.object;t.name="lup",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,o){var a=n(r(75)),s=n(r(164)),u=n(r(47)),c=n(r(217)),f=n(r(218)),l=o("lusolve",{"Array, Array | Matrix":function(e,t){e=a(e);var r=s(e),n=m(r.L,r.U,r.P,t);return n.valueOf()},"Matrix, Array | Matrix":function(e,t){var r=s(e);return m(r.L,r.U,r.P,t)},"Object, Array | Matrix":function(e,t){return m(e.L,e.U,e.P,t)}}),p=function(t){if(t instanceof e.Matrix)return t;if(i(t))return a(t);throw new TypeError("Invalid Matrix LUP decomposition")},m=function(e,t,r,n){e=p(e),t=p(t),r=p(r),n=u(r,n);var i=f(e,n);return c(t,i)};return l}var i=Array.isArray;t.name="lusolve",t.factory=n},function(e,t,r){"use strict";var n=r(351);t.clone=function i(e){var t=typeof e;if("number"===t||"string"===t||"boolean"===t||null===e||void 0===e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e))return e.map(function(e){return i(e)});if(e instanceof Number)return new Number(e.valueOf());if(e instanceof String)return new String(e.valueOf());if(e instanceof Boolean)return new Boolean(e.valueOf());if(e instanceof Date)return new Date(e.valueOf());if(e instanceof n)return e;if(e instanceof RegExp)throw new TypeError("Cannot clone "+e);var r={};for(var o in e)e.hasOwnProperty(o)&&(r[o]=i(e[o]));return r},t.extend=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},t.deepExtend=function o(e,t){if(Array.isArray(t))throw new TypeError("Arrays are not supported by deepExtend");for(var r in t)if(t.hasOwnProperty(r))if(t[r]&&t[r].constructor===Object)void 0===e[r]&&(e[r]={}),e[r].constructor===Object?o(e[r],t[r]):e[r]=t[r];else{if(Array.isArray(t[r]))throw new TypeError("Arrays are not supported by deepExtend");e[r]=t[r]}return e},t.deepEqual=function(e,r){var n,i,o;if(Array.isArray(e)){if(!Array.isArray(r))return!1;if(e.length!=r.length)return!1;for(i=0,o=e.length;o>i;i++)if(!t.deepEqual(e[i],r[i]))return!1;return!0}if(e instanceof Object){if(Array.isArray(r)||!(r instanceof Object))return!1;for(n in e)if(!t.deepEqual(e[n],r[n]))return!1;for(n in r)if(!t.deepEqual(e[n],r[n]))return!1;return!0}return typeof e==typeof r&&e==r},t.canDefineProperty=function(){try{if(Object.defineProperty)return Object.defineProperty({},"x",{}),!0}catch(e){}return!1},t.lazy=function(e,r,n){if(t.canDefineProperty()){var i,o=!0;Object.defineProperty(e,r,{get:function(){return o&&(i=n(),o=!1),i},set:function(e){i=e,o=!1},configurable:!0})}else e[r]=n()},t.traverse=function(e,t){var r=e;if(t)for(var n=t.split("."),i=0;i15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+t+"). Use function bignumber(x) to convert to BigNumber.");return new e.type.BigNumber(t)}},{from:"number",to:"Complex",convert:function(t){return new e.type.Complex(t,0)}},{from:"number",to:"string",convert:function(e){return e+""}},{from:"BigNumber",to:"Complex",convert:function(t){return new e.type.Complex(t.toNumber(),0)}},{from:"boolean",to:"number",convert:function(e){return+e}},{from:"boolean",to:"BigNumber",convert:function(t){return new e.type.BigNumber(+t)}},{from:"boolean",to:"string",convert:function(e){return+e}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new e.type.BigNumber(0)}},{from:"Array",to:"Matrix",convert:function(t){return new e.type.Matrix(t)}}],n}},function(e,t,r){"use strict";function n(e,t,n,a,s){function u(e,t){var n=arguments.length;if(1!=n&&2!=n)throw new s.error.ArgumentsError("import",n,1,2);var o,a={override:t&&t.override||!1,wrap:t&&t.wrap||!1};if("string"==typeof e){var p=r(347)(e);return u(p,t)}if(i(e))return f(e);if("object"==typeof e){var m={};for(o in e)if(e.hasOwnProperty(o)){var h=e[o];l(h)?m[o]=c(o,h,a):i(e)?m[o]=f(e):m[o]=u(h,t)}return m}throw new TypeError("Object or module name expected")}function c(e,t,r){return r.override||void 0===s[e]?(r.wrap&&"function"==typeof t?(s[e]=function(){for(var e=[],r=0,n=arguments.length;n>r;r++){var i=arguments[r];e[r]=i&&i.valueOf()}return t.apply(s,e)},t&&t.transform&&(s[e].transform=t.transform)):s[e]=t,t&&t.transform&&(s.expression.transform[e]=t.transform),s.type.Chain.createProxy(e,t),t):void 0}function f(e){var t=n(e),r=e.path?o(s,e.path):s;if(r[e.name])throw new Error('"'+e.name+'" already exists');return r[e.name]=t,t}function l(t){return"function"==typeof t||"number"==typeof t||"string"==typeof t||"boolean"==typeof t||null===t||t instanceof e.Unit||t instanceof e.Complex}return u}var i=r(166).isFactory,o=r(166).traverse;t.math=!0,t.name="import",t.factory=n},function(e,t,r){"use strict";e.exports=function(e,t){var n=r(166),i=r(214),o=r(3),a=e.type.BigNumber;e["true"]=!0,e["false"]=!1,e["null"]=null,e.uninitialized=r(172).UNINITIALIZED,"bignumber"===t.number?(e.Infinity=new a(1/0),e.NaN=new a(0/0),n.lazy(e,"pi",function(){return i.pi(t.precision)}),n.lazy(e,"tau",function(){return i.tau(t.precision)}),n.lazy(e,"e",function(){return i.e(t.precision)}),n.lazy(e,"phi",function(){return i.phi(t.precision)}),n.lazy(e,"E",function(){return e.e}),n.lazy(e,"LN2",function(){return new a(2).ln()}),n.lazy(e,"LN10",function(){return new a(10).ln()}),n.lazy(e,"LOG2E",function(){return new a(1).div(new a(2).ln())}),n.lazy(e,"LOG10E",function(){return new a(1).div(new a(10).ln())}),n.lazy(e,"PI",function(){return e.pi}),n.lazy(e,"SQRT1_2",function(){return new a("0.5").sqrt()}),n.lazy(e,"SQRT2",function(){return new a(2).sqrt()})):(e.Infinity=1/0,e.NaN=0/0,e.pi=Math.PI,e.tau=2*Math.PI,e.e=Math.E,e.phi=1.618033988749895,e.E=e.e,e.LN2=Math.LN2,e.LN10=Math.LN10,e.LOG2E=Math.LOG2E,e.LOG10E=Math.LOG10E,e.PI=e.pi,e.SQRT1_2=Math.SQRT1_2,e.SQRT2=Math.SQRT2),e.i=new o(0,1),e.version=r(348)}},function(e,t,r){"use strict";t.ArgumentsError=r(177),t.DimensionError=r(174),t.IndexError=r(173),t.UnsupportedTypeError=r(349)},function(e,t,r){"use strict";t.array=r(172),t["boolean"]=r(209),t["function"]=r(350),t.number=r(175),t.bignumber=r(214),t.object=r(166),t.string=r(176),t.types=r(216)},function(e,t,r){"use strict";function n(e){for(var t=[];m(e);)t.push(e.length),e=e[0];return t}function i(e,t,r){var n,o=e.length;if(o!=t[r])throw new l(o,t[r]);if(rn;n++){var s=e[n];if(!m(s))throw new l(t.length-1,t.length,"<");i(e[n],t,a)}}else for(n=0;o>n;n++)if(m(e[n]))throw new l(t.length+1,t.length,">")}function o(e,r,n,i){var a,s,u=e.length,c=r[n],l=Math.min(u,c);if(e.length=c,na;a++)s=e[a],m(s)||(s=[s],e[a]=s),o(s,r,p,i);for(a=l;c>a;a++)s=[],e[a]=s,o(s,r,p,i)}else{for(a=0;l>a;a++)for(;m(e[a]);)e[a]=e[a][0];if(i!==t.UNINITIALIZED)for(a=l;c>a;a++)e[a]=f.clone(i)}}function a(e,t,r){var n,i;if(t>r){var o=r+1;for(n=0,i=e.length;i>n;n++)e[n]=a(e[n],t,o)}else for(;m(e);)e=e[0];return e}function s(e,t,r){var n,i;if(m(e)){var o=r+1;for(n=0,i=e.length;i>n;n++)e[n]=s(e[n],t,o)}else for(var a=r;t>a;a++)e=[e];return e}var u=r(175),c=r(176),f=r(166),l=(r(216),r(174)),p=r(173),m=Array.isArray;t.size=function(e){var r=n(e);return t.validate(e,r),r},t.validate=function(e,t){var r=0==t.length;if(r){if(m(e))throw new l(e.length,0)}else i(e,t,0)},t.validateIndex=function(e,t){if(!u.isNumber(e)||!u.isInteger(e))throw new TypeError("Index must be an integer (value: "+e+")");if(0>e)throw new p(e);if(void 0!==t&&e>=t)throw new p(e,t)},t.UNINITIALIZED={},t.resize=function(e,t,r){if(!m(e)||!m(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");t.forEach(function(e){if(!u.isNumber(e)||!u.isInteger(e)||0>e)throw new TypeError("Invalid size, must contain positive integers (size: "+c.format(t)+")")});var n=void 0!==r?r:0;return o(e,t,0,n),e},t.squeeze=function(e,r){for(var n=r||t.size(e);m(e)&&1===e.length;)e=e[0],n.shift();for(var i=n.length;1===n[i-1];)i--;return ia;a++)e=[e],o.unshift(1);for(e=s(e,r,0);o.lengthi;i++)n=n.concat.apply(n,t[i]);t=n}return t},t.argsToArray=function(e){for(var t=[],r=0,n=e.length;n>r;r++)t[r]=e[r];return t},t.isArray=m},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.index=e,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=r),void 0!==this.min&&this.index=this.max?this.message="Index out of range ("+this.index+" > "+(this.max-1)+")":this.message="Index out of range ("+this.index+")",this.stack=(new Error).stack}n.prototype=new RangeError,n.prototype.constructor=RangeError,n.prototype.name="IndexError",e.exports=n},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.actual=e,this.expected=t,this.relation=r,this.message="Dimension mismatch ("+(Array.isArray(e)?"["+e.join(", ")+"]":e)+" "+(this.relation||"!=")+" "+(Array.isArray(t)?"["+t.join(", ")+"]":t)+")",this.stack=(new Error).stack}n.prototype=new RangeError,n.prototype.constructor=RangeError,n.prototype.name="DimensionError",e.exports=n},function(e,t,r){"use strict";var n=r(352);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,r){if("function"==typeof r)return r(e);if(e===1/0)return"Infinity";if(e===-(1/0))return"-Infinity";if(isNaN(e))return"NaN";var n="auto",i=void 0;switch(r&&(r.notation&&(n=r.notation),t.isNumber(r)?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"auto":return t.toPrecision(e,i,r&&r.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return new n(e).toExponential(t)},t.toFixed=function(e,t){return new n(e).toFixed(t)},t.toPrecision=function(e,t,r){return new n(e).toPrecision(t,r)},t.digits=function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},t.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,t.nearlyEqual=function(e,r,n){if(null==n)return e==r;if(e==r)return!0;if(isNaN(e)||isNaN(r))return!1;if(isFinite(e)&&isFinite(r)){var i=Math.abs(e-r);return ia;a++)0!=a&&(i+=", "),i+=n(e[a],r);return i+="]"}return t.format(e,r)}var i=r(175),o=r(214),a=r(351);t.isString=function(e){return e instanceof String||"string"==typeof e},t.endsWith=function(e,t){var r=e.length-t.length,n=e.length;return e.substring(r,n)===t},t.format=function(e,r){return i.isNumber(e)?i.format(e,r):e instanceof a?o.format(e,r):Array.isArray(e)?n(e,r):t.isString(e)?'"'+e+'"':"function"==typeof e?e.syntax?e.syntax+"":"function":e instanceof Object?"function"==typeof e.format?e.format(r):e.toString():String(e)}},function(e,t,r){"use strict";function n(e,t,r,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=t,this.min=r,this.max=i,this.message="Wrong number of arguments in function "+e+" ("+t+" provided, "+r+(void 0!=i?"-"+i:"")+" expected)",this.stack=(new Error).stack}n.prototype=new Error,n.prototype.constructor=Error,n.prototype.name="ArgumentsError",e.exports=n},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(this.nodes=e||[],!a(this.nodes)||!this.nodes.every(s))throw new TypeError("Array containing Nodes expected")}var i=r(190),o=r(176),a=Array.isArray,s=i.isNode;n.prototype=new i,n.prototype.type="ArrayNode",n.prototype._compile=function(e){var t="array"!==e.math.config().matrix,r=this.nodes.map(function(t){return t._compile(e)});return(t?"math.matrix([":"[")+r.join(",")+(t?"])":"]")},n.prototype.forEach=function(e){for(var t=0;t=t&&(r="("+r+")"),this.name+" = "+r},n.prototype._toTex=function(e){var t=a.getPrecedence(this),r=a.getPrecedence(this.expr),n=this.expr.toTex(e);return null!==r&&t>=r&&(n="\\left("+n+"\\right)"),s.toSymbol(this.name)+":="+n},e.exports=n},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var t=e&&e.node,r=e&&void 0!==e.visible?e.visible:!0;if(!(t instanceof i))throw new TypeError('Property "node" must be a Node');if(!a(r))throw new TypeError('Property "visible" must be a boolean');return{node:t,visible:r}})}var i=r(190),o=r(9),a=r(209).isBoolean;n.prototype=new i,n.prototype.type="BlockNode",n.prototype._compile=function(e){e.ResultSet=o;var t=this.blocks.map(function(t){var r=t.node._compile(e);return t.visible?"results.push("+r+");":r+";"});return"(function () {var results = [];"+t.join("")+"return new ResultSet(results);})()"},n.prototype.forEach=function(e){for(var t=0;t=r)&&(t="("+t+")");var n=this.trueExpr.toString(),i=c.getPrecedence(this.trueExpr);("OperatorNode"===this.trueExpr.type||null!==i&&e>=i)&&(n="("+n+")");var o=this.falseExpr.toString(),a=c.getPrecedence(this.falseExpr);return("OperatorNode"===this.falseExpr.type||null!==a&&e>=a)&&(o="("+o+")"),t+" ? "+n+" : "+o},n.prototype._toTex=function(e){return"\\left\\{\\begin{array}{l l}{"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if}\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{array}\\right."},e.exports=n},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(t){if(!a(t))throw new TypeError('String expected for parameter "valueType"');if(!a(e))throw new TypeError('String expected for parameter "value"');this.value=e,this.valueType=t}else this.value=e+"",this.valueType=o(e);if(!s[this.valueType])throw new TypeError('Unsupported type of value "'+this.valueType+'"')}var i=r(190),o=(r(351),r(216).type),a=r(176).isString,s={number:!0,string:!0,"boolean":!0,undefined:!0,"null":!0};n.prototype=new i,n.prototype.type="ConstantNode",n.prototype._compile=function(e){switch(this.valueType){case"number":return"bignumber"===e.math.config().number?'math.bignumber("'+this.value+'")':this.value.replace(/^(0*)[0-9]/,function(e,t){return e.substring(t.length)});case"string":return'"'+this.value+'"';case"boolean":return this.value;case"undefined":return this.value;case"null":return this.value;default:throw new TypeError('Unsupported type of constant "'+this.valueType+'"')}},n.prototype.forEach=function(e){},n.prototype.map=function(e){return this.clone()},n.prototype.clone=function(){return new n(this.value,this.valueType)},n.prototype.toString=function(){switch(this.valueType){case"string":return'"'+this.value+'"';default:return this.value}},n.prototype._toTex=function(e){var t,r=this.value;switch(this.valueType){case"string":return"\\text{"+r+"}";case"number":return t=r.toLowerCase().indexOf("e"),-1!==t?r.substring(0,t)+"\\cdot10^{"+r.substring(t+1)+"}":r;default:return r}},e.exports=n},function(e,t,r){"use strict";function n(e,t,r){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!u(e))throw new TypeError('String expected for parameter "name"');if(!c(t)||!t.every(u))throw new TypeError('Array containing strings expected for parameter "params"');if(!(r instanceof i))throw new TypeError('Node expected for parameter "expr"');if(e in o)throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=t,this.expr=r}var i=r(190),o=r(353),a=r(355),s=r(354),u=r(176).isString,c=Array.isArray;n.prototype=new i,n.prototype.type="FunctionAssignmentNode",n.prototype._compile=function(e){return this.params.forEach(function(t){e.args[t]=!0}),'scope["'+this.name+'"] = (function () { var fn = function '+this.name+"("+this.params.join(",")+") { if (arguments.length != "+this.params.length+') { throw new SyntaxError("Wrong number of arguments in function '+this.name+' (" + arguments.length + " provided, '+this.params.length+' expected)"); } return '+this.expr._compile(e)+' }; fn.syntax = "'+this.name+"("+this.params.join(", ")+')"; return fn; })();'},n.prototype.forEach=function(e){e(this.expr,"expr",this)},n.prototype.map=function(e){var t=this._ifNode(e(this.expr,"expr",this));return new n(this.name,this.params.slice(0),t)},n.prototype.clone=function(){return new n(this.name,this.params.slice(0),this.expr)},n.prototype.toString=function(){var e=s.getPrecedence(this),t=s.getPrecedence(this.expr),r=this.expr.toString();return null!==t&&e>=t&&(r="("+r+")"),"function "+this.name+"("+this.params.join(", ")+") = "+r},n.prototype._toTex=function(e){var t=s.getPrecedence(this),r=s.getPrecedence(this.expr),n=this.expr.toTex(e);return null!==r&&t>=r&&(n="\\left("+n+"\\right)"),a.toSymbol(this.name)+"\\left("+this.params.map(a.toSymbol).join(",")+"\\right):="+n},e.exports=n},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!(e instanceof i))throw new TypeError('Node expected for parameter "object"');if(!f(t)||!t.every(c))throw new TypeError('Array containing Nodes expected for parameter "ranges"');this.object=e,this.ranges=t}var i=r(190),o=r(187),a=r(188),s=r(351),u=r(4),c=i.isNode,f=Array.isArray;n.prototype=new i,n.prototype.type="IndexNode",n.prototype._compile=function(e){return this.compileSubset(e)},n.prototype.compileSubset=function(e,t){function r(e){return e instanceof a&&"end"==e.name}var n=!1,i=this.ranges.map(function(e){var t=e.filter(r).length>0;return n=t?t:n,t});e.range=function(e,t,r){return new u(e instanceof s?e.toNumber():e,t instanceof s?t.toNumber():t,r instanceof s?r.toNumber():r)};var c=this.ranges.map(function(t,r){var n=i[r];return t instanceof o?n?(e.args.end=!0,"(function () { var end = size["+r+"]; return range( "+t.start._compile(e)+", "+t.end._compile(e)+", "+(t.step?t.step._compile(e):"1")+" );})()"):"range("+t.start._compile(e)+", "+t.end._compile(e)+", "+(t.step?t.step._compile(e):"1")+")":n?(e.args.end=!0,"(function () { var end = size["+r+"]; return "+t._compile(e)+";})()"):t._compile(e)});return n?"(function () { var obj = "+this.object._compile(e)+"; var size = math.size(obj).valueOf(); return math.subset( obj, math.index("+c.join(", ")+") "+(t?", "+t:"")+" );})()":"math.subset("+this.object._compile(e)+",math.index("+c.join(", ")+")"+(t?", "+t:"")+")"},n.prototype.forEach=function(e){e(this.object,"object",this);for(var t=0;t=o?[!0]:[!1];case 2:var c,f=s.getPrecedence(t[0]),l=s.isAssociativeWith(e,t[0]);c=null===f?!1:f!==n||"right"!==i||l?n>f?!0:!1:!0;var p,m=s.getPrecedence(t[1]),h=s.isAssociativeWith(e,t[1]);if(p=null===m?!1:m!==n||"left"!==i||h?n>m?!0:!1:!0,r){var u=e.getIdentifier(),g=e.args[0].getIdentifier(),v=e.args[1].getIdentifier();null!==f&&(s.properties[n][u].latexLeftParens===!1&&(c=!1),s.properties[f][g].latexParens===!1&&(c=!1)),null!==m&&(s.properties[n][u].latexRightParens===!1&&(p=!1),s.properties[m][v].latexParens===!1&&(p=!1))}return[c,p];default:var d=[];return t.forEach(function(){d.push(!0)}),d}}var o=r(190),a=(r(182),r(188),r(186),r(355)),s=r(354),u=Array.isArray,c=o.isNode;n.prototype=new o,n.prototype.type="OperatorNode",n.prototype._compile=function(e){if(!(this.fn in e.math))throw new Error("Function "+this.fn+' missing in provided namespace "math"');var t=this.args.map(function(t){return t._compile(e)});return"math."+this.fn+"("+t.join(", ")+")"},n.prototype.forEach=function(e){for(var t=0;t3)throw new Error("Too many arguments");this.start=e,this.end=t,this.step=r||null}var i=r(190),o=r(354),a=i.isNode;n.prototype=new i,n.prototype.type="RangeNode",n.prototype._compile=function(e){return"math.range("+this.start._compile(e)+", "+this.end._compile(e)+(this.step?", "+this.step._compile(e):"")+")"},n.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},n.prototype.clone=function(){return new n(this.start,this.end,this.step&&this.step)},n.prototype.toString=function(){var e,t=o.getPrecedence(this),r=this.start.toString(),n=o.getPrecedence(this.start);if(null!==n&&t>=n&&(r="("+r+")"),e=r,this.step){var i=this.step.toString(),a=o.getPrecedence(this.step);null!==a&&t>=a&&(i="("+i+")"), -e+=":"+i}var s=this.end.toString(),u=o.getPrecedence(this.end);return null!==u&&t>=u&&(s="("+s+")"),e+=":"+s},n.prototype._toTex=function(e){var t=this.start.toTex(e);return this.step&&(t+=":"+this.step.toTex(e)),t+=":"+this.end.toTex(e)},e.exports=n},function(e,t,r){"use strict";function n(e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!u(e))throw new TypeError('String expected for parameter "name"');this.name=e}function i(e){throw new Error("Undefined symbol "+e)}var o=r(190),a=r(7),s=r(355),u=r(176).isString;n.prototype=new o,n.prototype.type="SymbolNode",n.prototype._compile=function(e){return e.undef=i,e.Unit=a,this.name in e.args?this.name:this.name in e.math?'("'+this.name+'" in scope ? scope["'+this.name+'"] : math["'+this.name+'"])':'("'+this.name+'" in scope ? scope["'+this.name+'"] : '+(a.isValuelessUnit(this.name)?'new Unit(null, "'+this.name+'")':'undef("'+this.name+'")')+")"},n.prototype.forEach=function(e){},n.prototype.map=function(e){return this.clone()},n.prototype.clone=function(){return new n(this.name)},n.prototype.toString=function(){return this.name},n.prototype._toTex=function(e){var t=s.toSymbol(this.name);return"\\"===t[0]?t:" "+t},e.exports=n},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");if(!(e instanceof o))throw new TypeError('Expected IndexNode for parameter "index"');if(!(t instanceof i))throw new TypeError('Expected Node for parameter "expr"');this.index=e,this.expr=t}var i=r(190),o=r(184);n.prototype=new i,n.prototype.type="UpdateNode",n.prototype._compile=function(e){var t=this.index.objectName()in e.args?this.name+" = ":'scope["'+this.index.objectName()+'"]',r=this.index.compileSubset(e,this.expr._compile(e));return t+" = "+r},n.prototype.forEach=function(e){e(this.index,"index",this),e(this.expr,"expr",this)},n.prototype.map=function(e){return new n(this._ifNode(e(this.index,"index",this)),this._ifNode(e(this.expr,"expr",this)))},n.prototype.clone=function(){return new n(this.index,this.expr)},n.prototype.toString=function(){return this.index.toString()+" = "+this.expr.toString()},n.prototype._toTex=function(e){return this.index.toTex(e)+":="+this.expr.toTex(e)},e.exports=n},function(e,t,r){"use strict";function n(){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator")}function i(e){for(var t in e)if(e.hasOwnProperty(t)&&t in a)throw new Error('Scope contains an illegal symbol, "'+t+'" is a reserved keyword')}function o(e){var t=Object.create(e);if(e.expression&&e.expression.transform)for(var r in e.expression.transform)e.expression.transform.hasOwnProperty(r)&&(t[r]=e.expression.transform[r]);return t}var a=r(353);n.prototype.eval=function(){throw new Error("Node.eval is deprecated. Use Node.compile(math).eval([scope]) instead.")},n.prototype.type="Node",n.prototype.compile=function(e){if(!(e instanceof Object))throw new TypeError("Object expected for parameter math");var t={math:o(e),args:{},_validateScope:i},r=this._compile(t),n=Object.keys(t).map(function(e){return" var "+e+' = defs["'+e+'"];'}),a=n.join(" ")+'return { "eval": function (scope) { if (scope) _validateScope(scope); scope = scope || {}; return '+r+"; }};",s=new Function("defs",a);return s(t)},n.prototype._compile=function(e){throw new Error("Cannot compile a Node interface")},n.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},n.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},n.prototype._ifNode=function(e){if(!(e instanceof n))throw new TypeError("Callback function must return a Node");return e},n.prototype.traverse=function(e){function t(e,r){e.forEach(function(e,n,i){r(e,n,i),t(e,r)})}e(this,null,null),t(this,e)},n.prototype.transform=function(e){function t(e,r){return e.map(function(e,n,i){var o=r(e,n,i);return o!==e?o:t(e,r)})}var r=e(this,null,null);return r!==this?r:t(this,e)},n.prototype.filter=function(e){var t=[];return this.traverse(function(r,n,i){e(r,n,i)&&t.push(r)}),t},n.prototype.find=function(){throw new Error("Function Node.find is deprecated. Use Node.filter instead.")},n.prototype.match=function(){throw new Error("Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.")},n.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},n.prototype.toString=function(){return""},n.prototype.toTex=function(e){var t;if("ArrayNode"===this.type&&delete this.latexType,"object"==typeof e)"FunctionNode"===this.type&&e.hasOwnProperty(this.name)&&(t=e[this.name](this,e));else if("function"==typeof e)t=e(this,e);else if("string"==typeof e&&"ArrayNode"===this.type)this.latexType=e;else if("undefined"!=typeof e)throw new TypeError("Object or function expected as callback");return"undefined"!=typeof t?t:this._toTex(e)},n.prototype._toTex=function(){if("Node"===this.type)return"";throw new Error("_toTex not implemented for this Node")},n.prototype.getIdentifier=function(){return this.type},n.isNode=function(e){return e instanceof n},e.exports=n},function(e,t,r){e.exports={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]}},function(e,t,r){e.exports={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]}},function(e,t,r){e.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:[]}},function(e,t,r){e.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:[]}},function(e,t,r){e.exports={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]}},function(e,t,r){e.exports={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]}},function(e,t,r){e.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:[]}},function(e,t,r){e.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:[]}},function(e,t,r){e.exports={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]}},function(e,t,r){e.exports={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]}},function(e,t,r){e.exports={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]}},function(e,t,r){e.exports={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["tau"],seealso:[]}},function(e,t,r){e.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:[]}},function(e,t,r){e.exports={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]}},function(e,t,r){e.exports={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]}},function(e,t,r){e.exports={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]}},function(e,t,r){e.exports={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]}},function(e,t,r){var n=(r(174),r(173));t.transform=function(e){return e instanceof n?new n(e.index+1,e.min+1,e.max+1):e}},function(e,t,r){"use strict";t.isBoolean=function(e){return e instanceof Boolean||"boolean"==typeof e}},function(e,t,r){"use strict";function n(){var e=function(e,t,r,n,i,o,a,s,u){var c=e._values,f=e._index,l=e._ptr,p=a._index;if(i)for(var m=l[t],h=l[t+1],g=m;h>g;g++){var v=f[g];n[v]!==o?(n[v]=o,p.push(v),i[v]=s(r,c[g])):i[v]=u(i[v],s(r,c[g]))}else for(var m=l[t],h=l[t+1],g=m;h>g;g++){var v=f[g];n[v]!==o&&(n[v]=o,p.push(v))}return p.length};return e}t.name="sparseScatter",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("addScalar",{"number, number":function(e,t){return e+t},"Complex, Complex":function(t,r){return new e.Complex(t.re+r.re,t.im+r.im)},"BigNumber, BigNumber":function(e,t){return e.plus(t)},"Unit, Unit":function(e,t){if(null==e.value)throw new Error("Parameter x contains a unit with undefined value");if(null==t.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(t))throw new Error("Units do not match");var r=e.clone();return r.value+=t.value,r.fixPrefix=!1,r},"string, string":function(e,t){return e+t}});return i}t.name="addScalar",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){var i=n("multiplyScalar",{"number, number":function(e,t){return e*t},"Complex, Complex":function(t,r){return new e.Complex(t.re*r.re-t.im*r.im,t.re*r.im+t.im*r.re)},"BigNumber, BigNumber":function(e,t){return e.times(t)},"number, Unit":function(e,t){var r=t.clone();return r.value=null===r.value?r._normalize(e):r.value*e,r},"Unit, number":function(e,t){var r=e.clone();return r.value=null===r.value?r._normalize(t):r.value*t,r}});return i}t.name="multiplyScalar",t.factory=n},function(e,t,r){"use strict";function n(e,t,r,n){function i(t,r){var n=r.re*r.re+r.im*r.im;return 0!=n?new e.Complex((t.re*r.re+t.im*r.im)/n,(t.im*r.re-t.re*r.im)/n):new e.Complex(0!=t.re?t.re/0:0,0!=t.im?t.im/0:0)}var o=n("divideScalar",{"number, number":function(e,t){return e/t},"Complex, Complex":i,"BigNumber, BigNumber":function(e,t){return e.div(t)},"Unit, number":function(e,t){var r=e.clone();return r.value=(null===r.value?r._normalize(1):r.value)/t,r}});return o}t.name="divideScalar",t.factory=n},function(e,t,r){"use strict";function n(e,r,n){var o,a,s=e.constructor,u=+(e.s<0),c=+(r.s<0);if(u){o=i(t.not(e));for(var f=0;f0;)n(l[--h],p[--g])==v&&(d=d.plus(y)),y=y.times(x);for(;g>0;)n(m,p[--g])==v&&(d=d.plus(y)),y=y.times(x);return s.config({precision:w}),0==v&&(d.s=-d.s),d}function i(e){for(var t=e.c,r=t[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;u+="0");else c>s&&(u=u.slice(0,s)+"."+u.slice(s));for(var f=[0],n=0;n1&&(null==f[a+1]&&(f[a+1]=0),f[a+1]+=f[a]>>1,f[a]&=1)}return f.reverse()}function o(e,r){var n=r.precision,i=-(n+4),o=n+8-e.e,a=25-e.e,s=Math.max(1.442695*Math.log(n+2)|5,5);r.config({precision:a});var u=0,c=new r(Math.asin(e.toNumber())+"");do{var l=t.cos_sin_sec_csc(c,r,1,!1),p=f(l);l.isZero()||(l.s=c.s);var m=l.minus(e).div(p);c=c.minus(m),a=Math.min(2*a,o),r.config({precision:a})}while(2*m.e>=i&&!m.isZero()&&++u<=s);if(u==s)throw new Error("asin() failed to converge to the requested accuracy.Try with a higher precision.");return r.config({precision:n}),c.toDP(n-1)}function a(e,t){var r=e.constructor;r.config({precision:t+Math.log(t)|4});for(var n=new r(1),i=e,o=0/0,a=e.times(e),s=e,u=new r(n),c=new r(n),f=new r(n),l=3;!i.equals(o);l+=2)s=s.times(a),u=u.times(f),c=c.times(f.plus(n)),o=i,f=new r(l),i=i.plus(s.times(u).div(f.times(c)));return r.config({precision:t}),i.toDP(t-1)}function s(e){for(var t=e,r=0/0,n=e.times(e),i=e,o=!0,a=3;!t.equals(r);a+=2)i=i.times(n),r=t,o=!o,t=o?t.plus(i.div(a)):t.minus(i.div(a));return t}function u(e,t){for(var r=e.constructor.ONE,n=e,i=0/0,o=e.times(e),a=t?n:n=r,s=r,u=!0,c=t;!n.equals(i);c+=2)a=a.times(o),s=s.times(c+1).times(c+2),i=n,u=!u,n=u?n.plus(a.div(s)):n.minus(a.div(s));return n}function c(e,r,n){var i=t.pi(r+2),o=t.tau(r);if(e.abs().lte(i.toDP(e.dp())))return[e,!1];var a=e.constructor;if(e.div(i.toDP(e.dp())).toNumber()%2==0)return[new a(1^n),!0];var s=e.mod(o);return s.toDP(e.dp(),1).isZero()?[new a(1^n),!0]:(s.gt(i)&&(n?(s=s.minus(i),s.s=-s.s):s=o.minus(s)),s.constructor=a,[s,!1])}function f(e){var t=e.constructor,r=t.precision;t.config({precision:r+2});var n=t.ONE.minus(e.times(e)).sqrt();return t.config({precision:r}),n.toDP(r-1)}var l=r(351),p=r(175).isNumber,m=r(175).digits,h=r(350).memoize;t.isBigNumber=function(e){return e instanceof l},t.toBigNumber=function(e,t){return new t(m(e)>15?e+"":e)},t.e=h(function(e){var t=l.constructor({precision:e});return new t(1).exp()}),t.phi=h(function(e){var t=l.constructor({precision:e});return new t(1).plus(new t(5).sqrt()).div(2)}),t.pi=h(function(e){var t=l.constructor({precision:e+4}),r=new t(4).times(s(new t(1).div(5))).minus(s(new t(1).div(239)));return t.config({precision:e}),new t(4).times(r)}),t.tau=h(function(e){var r=t.pi(e+2),n=l.constructor({precision:e});return new n(2).times(r)}),t.and=function(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitAnd");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(0/0);if(e.isZero()||t.eq(-1)||e.eq(t))return e;if(t.isZero()||e.eq(-1))return t;if(!e.isFinite()||!t.isFinite()){if(!e.isFinite()&&!t.isFinite())return e.isNegative()==t.isNegative()?e:new r(0);if(!e.isFinite())return t.isNegative()?e:e.isNegative()?new r(0):t;if(!t.isFinite())return e.isNegative()?t:t.isNegative()?new r(0):e}return n(e,t,function(e,t){return e&t})},t.leftShift=function(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function leftShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(0/0):e.isZero()||t.isZero()?e:e.isFinite()||t.isFinite()?e.times(t.lt(55)?Math.pow(2,t.toNumber())+"":new r(2).pow(t)):new r(0/0)},t.not=function(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var t=e.constructor,r=t.precision;t.config({precision:1e9});var e=e.plus(t.ONE);return e.s=-e.s||null,t.config({precision:r}),e},t.or=function(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitOr");var r=e.constructor;if(e.isNaN()||t.isNaN())return new r(0/0);var i=new r(-1);return e.isZero()||t.eq(i)||e.eq(t)?t:t.isZero()||e.eq(i)?e:e.isFinite()&&t.isFinite()?n(e,t,function(e,t){return e|t}):!e.isFinite()&&!e.isNegative()&&t.isNegative()||e.isNegative()&&!t.isNegative()&&!t.isFinite()?i:e.isNegative()&&t.isNegative()?e.isFinite()?e:t:e.isFinite()?t:e},t.rightArithShift=function(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function rightArithShift");var r=e.constructor;return e.isNaN()||t.isNaN()||t.isNegative()&&!t.isZero()?new r(0/0):e.isZero()||t.isZero()?e:t.isFinite()?t.lt(55)?e.div(Math.pow(2,t.toNumber())+"").floor():e.div(new r(2).pow(t)).floor():new r(e.isNegative()?-1:e.isFinite()?0:0/0)},t.xor=function(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitXor");var i=e.constructor;if(e.isNaN()||r.isNaN())return new i(0/0);if(e.isZero())return r;if(r.isZero())return e;if(e.eq(r))return new i(0);var o=new i(-1);return e.eq(o)?t.not(r):r.eq(o)?t.not(e):e.isFinite()&&r.isFinite()?n(e,r,function(e,t){return e^t}):e.isFinite()||r.isFinite()?new i(e.isNegative()==r.isNegative()?1/0:-(1/0)):o},t.arccos_arcsec=function(e,r,n){var i=r.precision;if(n){if(e.abs().lt(r.ONE))throw new Error("asec() only has non-complex values for |x| >= 1.")}else if(e.abs().gt(r.ONE))throw new Error("acos() only has non-complex values for |x| <= 1.");if(e.eq(-1))return t.pi(i);r.config({precision:i+4}),n&&(e=r.ONE.div(e));var o=t.arctan_arccot(r.ONE.minus(e.times(e)).sqrt().div(e.plus(r.ONE)),r).times(2);return r.config({precision:i}),o.toDP(i-1)},t.arcsin_arccsc=function(e,r,n){if(e.isNaN())return new r(0/0);var i=r.precision,s=e.abs();if(n){if(s.lt(r.ONE))throw new Error("acsc() only has non-complex values for |x| >= 1.");r.config({precision:i+2}),e=r.ONE.div(e),r.config({precision:i}),s=e.abs()}else if(s.gt(r.ONE))throw new Error("asin() only has non-complex values for |x| <= 1.");if(s.gt(.8)){r.config({precision:i+4});var u=e.s,c=t.pi(i+4).div(2);return e=c.minus(t.arcsin_arccsc(r.ONE.minus(e.times(e)).sqrt(),r)),e.s=u,e.constructor=r,r.config({precision:i}),e.toDP(i-1)}var f=s.gt(.58);f&&(r.config({precision:i+8}),e=e.div(new r(2).sqrt().times(r.ONE.minus(e.times(e)).sqrt().plus(r.ONE).sqrt())),r.config({precision:i}));var l=60>=i||e.dp()<=Math.log(i)&&e.lt(.05)?a(e,i):o(e,r);return f?l.times(2):l},t.arctan_arccot=function(e,r,n){if(e.isNaN())return new r(0/0);if(!n&&e.isZero()||n&&!e.isFinite())return new r(0);var i=r.precision;if(!n&&!e.isFinite()||n&&e.isZero()){var o=t.pi(i+2).div(2).toDP(i-1);return o.constructor=r,o.s=e.s,o}r.config({precision:i+4}),n&&(e=r.ONE.div(e));var a=e.abs();if(a.lte(.875)){var u=s(e);return u.constructor=r,r.config({precision:i}),u.toDP(r.precision-1)}if(a.gte(1.143)){var o=t.pi(i+4).div(2),u=o.minus(s(r.ONE.div(a)));return u.s=e.s,u.constructor=r,r.config({precision:i}),u.toDP(r.precision-1)}return e=e.div(e.times(e).plus(1).sqrt()),r.config({precision:i}),t.arcsin_arccsc(e,r)},t.arctan2=function(e,r,n){var i=n.precision;if(r.isZero()){if(e.isZero())return new n(0/0);var o=t.pi(i+2).div(2).toDP(i-1);return o.constructor=n,o.s=e.s,o}n.config({precision:i+2});var a=t.arctan_arccot(e.div(r),n,!1);if(r.isNegative()){var s=t.pi(i+2);a=e.isNegative()?a.minus(s):a.plus(s)}return a.constructor=n,n.config({precision:i}),a.toDP(i-1)},t.acosh_asinh_asech_acsch=function(e,t,r,n){if(e.isNaN())return new t(0/0);if(n&&e.isZero())return new t(1/0);if(!r)if(n){if(e.isNegative()||e.gt(t.ONE))throw new Error("asech() only has non-complex values for 0 <= x <= 1.")}else if(e.lt(t.ONE))throw new Error("acosh() only has non-complex values for x >= 1.");var i=t.precision;t.config({precision:i+4});var o=new t(e);o.constructor=t,n&&(o=t.ONE.div(o));var a=r?o.times(o).plus(t.ONE):o.times(o).minus(t.ONE),s=o.plus(a.sqrt()).ln();return t.config({precision:i}),new t(s.toPrecision(i))},t.atanh_acoth=function(e,t,r){if(e.isNaN())return new t(0/0);var n=e.abs();if(n.eq(t.ONE))return new t(e.isNegative()?-(1/0):1/0);if(n.gt(t.ONE)){if(!r)throw new Error("atanh() only has non-complex values for |x| <= 1.")}else if(r)throw new Error("acoth() has complex values for |x| < 1.");if(e.isZero())return new t(0);var i=t.precision;t.config({precision:i+4});var o=new t(e);o.constructor=t,r&&(o=t.ONE.div(o));var a=t.ONE.plus(o).div(t.ONE.minus(o)).ln().div(2);return t.config({precision:i}),new t(a.toPrecision(i))},t.cos_sin_sec_csc=function(e,t,r,n){if(e.isNaN()||!e.isFinite())return new t(0/0);var i=t.precision,o=new t(e),a=o.isNegative();a&&(o.s=-o.s);var s=i+(0|Math.log(i))+3;if(t.config({precision:s}),o=c(o,s,r),o[0].constructor=t,o[1])return o=o[0],n&&o.isZero()&&(o=new t(1/0)),t.config({precision:i}),o;var f;if(o=o[0],r){f=u(o.div(3125),r),t.config({precision:Math.min(s,i+15)});for(var l=new t(5),p=new t(16),m=new t(20),h=0;5>h;++h){var g=f.times(f),v=g.times(f),d=v.times(g);f=p.times(d).minus(m.times(v)).plus(l.times(f))}a&&(f.s=-f.s)}else{var y,x;o.abs().lt(t.ONE)?(y=64,x=3):(y=256,x=4),f=u(o.div(y),r),t.config({precision:Math.min(s,i+8)});for(var w=new t(8);x>0;--x){var g=f.times(f),b=g.times(g);f=w.times(b.minus(g)).plus(t.ONE)}}return n&&(f=f.e<=-i?new t(1/0):t.ONE.div(f)),t.config({precision:i}),f.toDP(i-1)},t.tan_cot=function(e,r,n){if(e.isNaN())return new r(0/0);var i=r.precision,o=t.pi(i+2),a=o.div(2).toDP(i-1);o=o.toDP(i-1);var s=c(e,i,1)[0];if(s.abs().eq(o))return new r(1/0);r.config({precision:i+4});var u=t.cos_sin_sec_csc(s,r,1,!1),l=f(u);u=u.toDP(i),l=l.toDP(i),s.eq(e)?s.gt(a)&&(l.s=-l.s):o.minus(s.abs()).gt(a)&&(l.s=-l.s);var p=n?l.div(u):u.div(l);return r.config({precision:i}),new r(p.toPrecision(i))},t.cosh_sinh_csch_sech=function(e,t,r,n){if(e.isNaN())return new t(0/0);if(!e.isFinite())return new t(n?0:r?e:1/0);var i=t.precision;t.config({precision:i+4});var o=new t(e);return o.constructor=t,o=o.exp(),o=r?o.minus(t.ONE.div(o)):o.plus(t.ONE.div(o)),o=n?new t(2).div(o):o.div(2),t.config({precision:i}),new t(o.toPrecision(i))},t.tanh_coth=function(e,t,r){if(e.isNaN())return new t(0/0);if(!e.isFinite())return new t(e.s);var n=t.precision;t.config({precision:n+4});var i=new t(e);i.constructor=t;var o=i.exp(),a=t.ONE.div(o),s=o.minus(a);return s=r?o.plus(a).div(s):s.div(o.plus(a)),t.config({precision:n}),s.toDP(n-1)},t.format=function(e,r){if("function"==typeof r)return r(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n="auto",i=void 0;switch(void 0!==r&&(r.notation&&(n=r.notation),p(r)?i=r:r.precision&&(i=r.precision)),n){case"fixed":return t.toFixed(e,i);case"exponential":return t.toExponential(e,i);case"auto":var o=.001,a=1e5;r&&r.exponential&&(void 0!==r.exponential.lower&&(o=r.exponential.lower),void 0!==r.exponential.upper&&(a=r.exponential.upper));{({toExpNeg:e.constructor.toExpNeg,toExpPos:e.constructor.toExpPos})}if(e.constructor.config({toExpNeg:Math.round(Math.log(o)/Math.LN10),toExpPos:Math.round(Math.log(a)/Math.LN10)}),e.isZero())return"0";var s,u=e.abs();return s=u.gte(o)&&u.lt(a)?e.toSignificantDigits(i).toFixed():t.toExponential(e,i),s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],t=arguments[4];return"."!==e?e+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},t.toExponential=function(e,t){return void 0!==t?e.toExponential(t-1):e.toExponential()},t.toFixed=function(e,t){return e.toFixed(t||0)}},function(e,t,r){"use strict";function n(e,t,n,o){function a(t){if(!l.hasOwnProperty(t))throw new Error("Unknown distribution "+t);var r=Array.prototype.slice.call(arguments,1),n=l[t].apply(this,r);return function(t){var r={random:function(t,r,o){var s,c,l;if(arguments.length>3)throw new i("random",arguments.length,0,3);if(1===arguments.length?f(t)?s=t:l=t:2===arguments.length?f(t)?(s=t,l=r):(c=t,l=r):(s=t,c=r,l=o),void 0===l&&(l=1),void 0===c&&(c=0),void 0!==s){var p=a(s.valueOf(),c,l,n);return s instanceof e.Matrix?u(p):p}return n(c,l)},randomInt:function(t,r,n){var s,c,l;if(arguments.length>3||arguments.length<1)throw new i("randomInt",arguments.length,1,3);if(1===arguments.length?f(t)?s=t:l=t:2===arguments.length?f(t)?(s=t,l=r):(c=t,l=r):(s=t,c=r,l=n),void 0===c&&(c=0),void 0!==s){var p=a(s.valueOf(),c,l,o);return s instanceof e.Matrix?u(p):p}return o(c,l)},pickRandom:function(t){if(1!==arguments.length)throw new i("pickRandom",arguments.length,1);if(t instanceof e.Matrix)t=t.valueOf();else if(!Array.isArray(t))throw new TypeError("Unsupported type of value in function pickRandom");if(c.size(t).length>1)throw new Error("Only one dimensional vectors supported");return t[Math.floor(Math.random()*t.length)]}},n=function(e,r){return e+t()*(r-e)},o=function(e,r){return Math.floor(e+t()*(r-e))},a=function(e,t,r,n){var i,o,s=[];if(e=e.slice(0),e.length>1)for(o=0,i=e.shift();i>o;o++)s.push(a(e,t,r,n));else for(o=0,i=e.shift();i>o;o++)s.push(n(t,r));return s};return r}(n)}var s=n(r(2)),u=n(r(75)),c=r(172),f=s.isCollection,l={uniform:function(){return Math.random},normal:function(){return function(){for(var e,t,r=-1;0>r||r>1;)e=Math.random(),t=Math.random(),r=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*t)+.5;return r}}};return a}var i=r(177);t.name="distribution",t.factory=n},function(e,t,r){"use strict";t.type=function(e){var t=typeof e;if("object"===t){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";if(e instanceof Function)return"function";if(e instanceof RegExp)return"regexp"}return t}},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(75)),a=n(r(213)),s=n(r(47)),u=n(r(55)),c=n(r(115)),f=n(r(356)),l=e.SparseMatrix,p=e.DenseMatrix,m=i("backwardSubstitution",{"Matrix, Array | Matrix":function(e,t){switch(e.storage()){case"dense":return h(e,t);case"sparse":return g(e,t)}},"Array, Array | Matrix":function(e,t){var r=o(e),n=m(r,t);return n.valueOf()}}),h=function(e,t){t=f(e,t);for(var r=e._size[0],n=e._size[1],i=new Array(r),o=e._data,l=n-1;l>=0;l--){var m,h=t[l]||0;if(c(h,0))m=0;else{var g=o[l][l];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=a(h,g);for(var v=l-1;v>=0;v--)t[v]=u(t[v]||0,s(m,o[v][l]))}i[l]=[m]}return new p({data:i,size:[r,1]})},g=function(e,t){t=f(e,t);var r,n,i=e._size[0],o=e._size[1],p=e._values,m=e._index,h=e._ptr,g=[],v=[],d=[];d.push(0);for(var y=o-1;y>=0;y--){var x=t[y]||0;if(!c(x,0)){var w=0,b=h[y],N=h[y+1];for(n=N-1;n>=b;n--)if(r=m[n],r===y)w=p[n];else if(y>r)break;if(c(w,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var E=a(x,w);n>=b;n--)r=m[n],t[r]=u(t[r]||0,s(E,p[n]));c(E,0)||(g.unshift(E),v.unshift(y))}}return d.push(g.length),new l({values:g,index:v,ptr:d,size:[i,1]})};return m}t.name="backwardSubstitution",t.factory=n},function(e,t,r){"use strict";function n(e,t,n,i){var o=n(r(75)),a=n(r(213)),s=n(r(47)),u=n(r(55)),c=n(r(115)),f=n(r(356)),l=e.SparseMatrix,p=e.DenseMatrix,m=i("forwardSubstitution",{"Matrix, Array | Matrix":function(e,t){switch(e.storage()){case"dense":return h(e,t);case"sparse":return g(e,t)}},"Array, Array | Matrix":function(e,t){var r=o(e),n=m(r,t);return n.valueOf()}}),h=function(e,t){t=f(e,t);for(var r=e._size[0],n=e._size[1],i=new Array(r),o=e._data,l=0;n>l;l++){var m,h=t[l]||0;if(c(h,0))m=0;else{var g=o[l][l];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=a(h,g);for(var v=l+1;r>v;v++)t[v]=u(t[v]||0,s(m,o[v][l]))}i[l]=[m]}return new p({data:i,size:[r,1]})},g=function(e,t){t=f(e,t);var r,n,i=e._size[0],o=e._size[1],p=e._values,m=e._index,h=e._ptr,g=[],v=[],d=[];d.push(0);for(var y=0;o>y;y++){var x=t[y]||0;if(!c(x,0)){var w=0,b=h[y+1];for(n=h[y];b>n;n++)if(r=m[n],r===y)w=p[n];else if(r>y)break;if(c(w,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=a(x,w);b>n;n++)r=m[n],t[r]=u(t[r]||0,s(N,p[n]));c(N,0)||(g.push(N),v.push(y))}}return d.push(g.length),new l({values:g,index:v,ptr:d,size:[i,1]})};return m}t.name="forwardSubstitution",t.factory=n},function(e,t,r){e.exports={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]}},function(e,t,r){e.exports={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i",'"hello" + " world"',"3 cm + 2 inch"],seealso:["subtract"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.exports={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]}},function(e,t,r){e.exports={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]}},function(e,t,r){e.exports={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]}},function(e,t,r){e.exports={name:"dotpow",category:"Operators",syntax:["x .^ y","dotpow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]}},function(e,t,r){e.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:["pow","log"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log10"]}},function(e,t,r){e.exports={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]}},function(e,t,r){e.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:["divide"]}},function(e,t,r){e.exports={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"], -description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]}},function(e,t,r){e.exports={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i))","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)","norm([[1, 2], [3, 4]], 'inf')","norm([[1, 2], [3, 4]], 'fro')"]}},function(e,t,r){e.exports={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["sqrt","pow"]}},function(e,t,r){e.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:["multiply"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.exports={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","multiply"]}},function(e,t,r){e.exports={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]}},function(e,t,r){e.exports={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]}},function(e,t,r){e.exports={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]}},function(e,t,r){e.exports={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]}},function(e,t,r){e.exports={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]}},function(e,t,r){e.exports={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,t,r){e.exports={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,t,r){e.exports={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,t,r){e.exports={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]}},function(e,t,r){e.exports={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]}},function(e,t,r){e.exports={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","leftShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]}},function(e,t,r){e.exports={name:"rightLogShift",category:"Bitwise",syntax:["x >> y","leftShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]}},function(e,t,r){e.exports={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]}},function(e,t,r){e.exports={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]}},function(e,t,r){e.exports={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]}},function(e,t,r){e.exports={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.exports={name:"matrix",category:"Type",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]}},function(e,t,r){e.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])",'number("52cm", "m")'],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]}},function(e,t,r){e.exports={name:"sparse",category:"Type",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]}},function(e,t,r){e.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"]}},function(e,t,r){e.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"]}},function(e,t,r){e.exports={name:"eval",category:"Expression",syntax:["eval(expression)","eval([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['eval("2 + 3")','eval("sqrt(" + 4 + ")")'],seealso:[]}},function(e,t,r){e.exports={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]}},function(e,t,r){e.exports={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]}},function(e,t,r){e.exports={name:"not",category:"Logical",syntax:["!x","not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["!true","not false","!2","!0"],seealso:["and","or","xor"]}},function(e,t,r){e.exports={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]}},function(e,t,r){e.exports={name:"xor",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 or 4"],seealso:["not","and","or"]}},function(e,t,r){e.exports={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]}},function(e,t,r){e.exports={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"dot",category:"Matrix",syntax:["dot(A, B)"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]}},function(e,t,r){e.exports={name:"eye",category:"Matrix",syntax:["eye(n)","eye(m, n)","eye([m, n])","eye"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["eye(3)","eye(3, 5)","a = [1, 2, 3; 4, 5, 6]","eye(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]}},function(e,t,r){e.exports={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","eye","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])","ones"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","eye","inv","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","eye","inv","ones","size","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze"]}},function(e,t,r){e.exports={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","det","diag","eye","inv","ones","range","squeeze","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","eye","inv","ones","range","size","subset","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","trace","transpose","zeros"]}},function(e,t,r){e.exports={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","transpose","zeros"]}},function(e,t,r){e.exports={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","trace","zeros"]}},function(e,t,r){e.exports={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])","zeros"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose"]}},function(e,t,r){e.exports={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["permutations","factorial"]}},function(e,t,r){e.exports={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","permutations","gamma"]}},function(e,t,r){e.exports={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]}},function(e,t,r){e.exports={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","factorial"]}},function(e,t,r){e.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:["random","randomInt"]}},function(e,t,r){e.exports={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]}},function(e,t,r){e.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:["pickRandom","random"]}},function(e,t,r){e.exports={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq"]}},function(e,t,r){e.exports={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["[1,3,4] == [1,3,4]","[1,3,4] == [1,3]"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]}},function(e,t,r){e.exports={name:"equal",category:"Relational",syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]}},function(e,t,r){e.exports={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]}},function(e,t,r){e.exports={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 > 1+1","2 >= 1+1","a = 3.2","b = 6-2.8","(a > b)"],seealso:["equal","unequal","smallerEq","smaller","largerEq","compare"]}},function(e,t,r){e.exports={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]}},function(e,t,r){e.exports={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 1+1","2 <= 1+1","a = 3.2","b = 6-2.8","(a < b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]}},function(e,t,r){e.exports={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]}},function(e,t,r){e.exports={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","var"]}},function(e,t,r){e.exports={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","var"]}},function(e,t,r){e.exports={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","var"]}},function(e,t,r){e.exports={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","var"]}},function(e,t,r){e.exports={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","var"]}},function(e,t,r){e.exports={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","sum","var"]}},function(e,t,r){e.exports={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","var"]}},function(e,t,r){e.exports={name:"var",category:"Statistics",syntax:["var(a, b, c, ...)","var(A)","var(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["var(2, 4, 6)","var([2, 4, 6, 8])",'var([2, 4, 6, 8], "uncorrected")','var([2, 4, 6, 8], "biased")',"var([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]}},function(e,t,r){e.exports={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]}},function(e,t,r){e.exports={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]}},function(e,t,r){e.exports={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]}},function(e,t,r){e.exports={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(0.5)"],seealso:["acsch","asech"]}},function(e,t,r){e.exports={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(0.5)","acsc(csc(0.5))","acsc(2)"],seealso:["csc","asin","asec"]}},function(e,t,r){e.exports={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]}},function(e,t,r){e.exports={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]}},function(e,t,r){e.exports={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]}},function(e,t,r){e.exports={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(2.3))"],seealso:["sin","acos","atan"]}},function(e,t,r){e.exports={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]}},function(e,t,r){e.exports={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(2.3))"],seealso:["tan","acos","asin"]}},function(e,t,r){e.exports={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]}},function(e,t,r){e.exports={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]}},function(e,t,r){e.exports={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]}},function(e,t,r){e.exports={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]}},function(e,t,r){e.exports={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]}},function(e,t,r){e.exports={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]}},function(e,t,r){e.exports={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]}},function(e,t,r){e.exports={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]}},function(e,t,r){e.exports={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]}},function(e,t,r){e.exports={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]}},function(e,t,r){e.exports={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]}},function(e,t,r){e.exports={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]}},function(e,t,r){e.exports={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]}},function(e,t,r){e.exports={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]}},function(e,t,r){e.exports={ -name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]}},function(e,t,r){e.exports={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]}},function(e,t,r){e.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 value * value })"],seealso:["filter","forEach"]}},function(e,t,r){e.exports={name:"filter",category:"Utils",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]}},function(e,t,r){e.exports={name:"forEach",category:"Utils",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]}},function(e,t,r){e.exports={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]}},function(e,t,r){e.exports={name:"import",category:"Utils",syntax:["import(string)"],description:"Import functions from a file.",examples:['import("numbers")','import("./mylib.js")'],seealso:[]}},function(e,t,r){e.exports={name:"sort",category:"Utils",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)'],seealso:["map","filter","forEach"]}},function(e,t,r){e.exports={name:"typeof",category:"Utils",syntax:["typeof(x)"],description:"Get the type of a variable.",examples:["typeof(3.5)","typeof(2 - 4i)","typeof(45 deg)",'typeof("hello world")'],seealso:[]}},function(e,t,r){function n(e){return r(i(e))}function i(e){return o[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var o={"./clone":155,"./clone.js":155,"./config":156,"./config.js":156,"./filter":157,"./filter.js":157,"./forEach":163,"./forEach.js":163,"./format":158,"./format.js":158,"./import":168,"./import.js":168,"./map":159,"./map.js":159,"./print":160,"./print.js":160,"./sort":161,"./sort.js":161,"./typeof":162,"./typeof.js":162};n.keys=function(){return Object.keys(o)},n.resolve=i,e.exports=n,n.id=347},function(e,t,r){e.exports="2.0.0-SNAPSHOT"},function(e,t,r){"use strict";function n(e,t){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.types=Array.prototype.splice.call(arguments,1),e?0==this.types.length?this.message="Unsupported type of argument in function "+e:this.message="Function "+e+"("+this.types.join(", ")+") not supported":this.message="Unsupported type of argument",this.stack=(new Error).stack}n.prototype=new TypeError,n.prototype.constructor=TypeError,n.prototype.name="UnsupportedTypeError",e.exports=n},function(e,t,r){t.memoize=function(e){return function t(){"object"!=typeof t.cache&&(t.cache={});var r=JSON.stringify(arguments);return r in t.cache?t.cache[r]:t.cache[r]=e.apply(e,arguments)}}},function(e,t,r){var n;!function(i){"use strict";function o(e){for(var t,r,n=1,i=e.length,o=e[0]+"";i>n;n++){for(t=e[n]+"",r=_-t.length;r--;)t="0"+t;o+=t}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function a(e,t,r,n){var i,o,a,s,u;for(o=1,a=e[0];a>=10;a/=10,o++);return a=t-o,0>a?(a+=_,i=0):(i=Math.ceil((a+1)/_),a%=_),o=E(10,_-a),u=e[i]%o|0,null==n?3>a?(0==a?u=u/100|0:1==a&&(u=u/10|0),s=4>r&&99999==u||r>3&&49999==u||5e4==u||0==u):s=(4>r&&u+1==o||r>3&&u+1==o/2)&&(e[i+1]/o/100|0)==E(10,a-2)-1||(u==o/2||0==u)&&0==(e[i+1]/o/100|0):4>a?(0==a?u=u/1e3|0:1==a?u=u/100|0:2==a&&(u=u/10|0),s=(n||4>r)&&9999==u||!n&&r>3&&4999==u):s=((n||4>r)&&u+1==o||!n&&r>3&&u+1==o/2)&&(e[i+1]/o/1e3|0)==E(10,a-3)-1,s}function s(e,t,r){var n=e.constructor;return null==t||((y=0>t||t>8)||0!==t&&(n.errors?parseInt:parseFloat)(t)!=t)&&!p(n,"rounding mode",t,r,0)?n.rounding:0|t}function u(e,t,r,n){var i=e.constructor;return!(y=(n||0)>t||t>=z+1)&&(0===t||(i.errors?parseInt:parseFloat)(t)==t)||p(i,"argument",t,r,0)}function c(e,t){var r,n,i,s,u,c,f,l=0,p=0,m=0,h=e.constructor,v=h.ONE,d=h.rounding,y=h.precision;if(!e.c||!e.c[0]||e.e>17)return new h(e.c?e.c[0]?e.s<0?0:1/0:v:e.s?e.s<0?0:e:0/0);for(null==t?(w=!1,u=y):u=t,f=new h(.03125);e.e>-2;)e=e.times(f),m+=5;for(n=Math.log(E(2,m))/Math.LN10*2+5|0,u+=n,r=s=c=new h(v),h.precision=u;;){if(s=g(s.times(e),u,1),r=r.times(++p),f=c.plus(I(s,r,u,1)),o(f.c).slice(0,u)===o(c.c).slice(0,u)){for(i=m;i--;)c=g(c.times(c),u,1);if(null!=t)return h.precision=y,c;if(!(3>l&&a(c.c,u-n,d,l)))return g(c,h.precision=y,d,w=!0);h.precision=u+=10,r=s=f=new h(v),p=0,l++}c=f}}function f(e,t,r,n){var i,a,s=e.constructor,u=(e=new s(e)).e;if(null==t?r=0:(g(e,++t,r),r=n?t:t+e.e-u),u=e.e,i=o(e.c),1==n||2==n&&(u>=t||u<=s.toExpNeg)){for(;i.length1&&(i=i.charAt(0)+"."+i.slice(1)),i+=(0>u?"e":"e+")+u}else{if(n=i.length,0>u){for(a=r-n;++u;i="0"+i);i="0."+i}else if(++u>n){for(a=r-u,u-=n;u--;i+="0");a>0&&(i+=".")}else a=r-n,n>u?i=i.slice(0,u)+"."+i.slice(u):a>0&&(i+=".");if(a>0)for(;a--;i+="0");}return e.s<0&&e.c[0]?"-"+i:i}function l(e){var t=e.length-1,r=t*_+1;if(t=e[t]){for(;t%10==0;t/=10,r--);for(t=e[0];t>=10;t/=10,r++);}return r}function p(e,t,r,n,i){if(e.errors){var o=new Error((n||["new Decimal","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","pow","random","log","sqrt","toNearest","divToInt"][b?0>b?-b:b:0>1/b?1:0])+"() "+(["number type has more than 15 significant digits","LN10 out of digits"][t]||t+([y?" out of range":" not an integer"," not a boolean or binary digit"][i]||""))+": "+r);throw o.name="Decimal Error",y=b=0,o}}function m(e,t,r){var n=new e(e.ONE);for(w=!1;1&r&&(n=n.times(t)),r>>=1,r;)t=t.times(t);return w=!0,n}function h(e,t){var r,n,i,s,u,c,f,l,m,v,d,y=1,x=10,b=e,N=b.c,E=b.constructor,M=E.ONE,A=E.rounding,_=E.precision;if(b.s<0||!N||!N[0]||!b.e&&1==N[0]&&1==N.length)return new E(N&&!N[0]?-1/0:1!=b.s?0/0:N?0:b);if(null==t?(w=!1,f=_):f=t,E.precision=f+=x,r=o(N),n=r.charAt(0),!(Math.abs(s=b.e)<15e14))return b=new E(n+"."+r.slice(1)),f+2>B.length&&p(E,1,f+2,"ln"),b=h(b,f-x).plus(new E(B.slice(0,f+2)).times(s+"")),E.precision=_,null==t?g(b,_,A,w=!0):b;for(;7>n&&1!=n||1==n&&r.charAt(1)>3;)b=b.times(e),r=o(b.c),n=r.charAt(0),y++;for(s=b.e,n>1?(b=new E("0."+r),s++):b=new E(n+"."+r.slice(1)),v=b,l=u=b=I(b.minus(M),b.plus(M),f,1),d=g(b.times(b),f,1),i=3;;){if(u=g(u.times(d),f,1),m=l.plus(I(u,new E(i),f,1)),o(m.c).slice(0,f)===o(l.c).slice(0,f)){if(l=l.times(2),0!==s&&(f+2>B.length&&p(E,1,f+2,"ln"),l=l.plus(new E(B.slice(0,f+2)).times(s+""))),l=I(l,new E(y),f,1),null!=t)return E.precision=_,l;if(!a(l.c,f-x,A,c))return g(l,E.precision=_,A,w=!0);E.precision=f+=x,m=u=b=I(v.minus(M),v.plus(M),f,1),d=g(b.times(b),f,1),i=c=1}l=m,i+=2}}function g(e,t,r,n){var i,o,a,s,u,c,f,l,p=e.constructor;e:if(null!=t){if(!(f=e.c))return e;for(i=1,s=f[0];s>=10;s/=10,i++);if(o=t-i,0>o)o+=_,a=t,u=f[l=0],c=u/E(10,i-a-1)%10|0;else if(l=Math.ceil((o+1)/_),l>=f.length){if(!n)break e;for(;f.length<=l;f.push(0));u=c=0,i=1,o%=_,a=o-_+1}else{for(u=s=f[l],i=1;s>=10;s/=10,i++);o%=_,a=o-_+i,c=0>a?0:N(u/E(10,i-a-1)%10)}if(n=n||0>t||null!=f[l+1]||(0>a?u:u%E(10,i-a-1)),n=4>r?(c||n)&&(0==r||r==(e.s<0?3:2)):c>5||5==c&&(4==r||n||6==r&&(o>0?a>0?u/E(10,i-a):0:f[l-1])%10&1||r==(e.s<0?8:7)),1>t||!f[0])return f.length=0,n?(t-=e.e+1,f[0]=E(10,t%_),e.e=-t||0):f[0]=e.e=0,e;if(0==o?(f.length=l,s=1,l--):(f.length=l+1,s=E(10,_-o),f[l]=a>0?(u/E(10,i-a)%E(10,a)|0)*s:0),n)for(;;){if(0==l){for(o=1,a=f[0];a>=10;a/=10,o++);for(a=f[0]+=s,s=1;a>=10;a/=10,s++);o!=s&&(e.e++,f[0]==A&&(f[0]=1));break}if(f[l]+=s,f[l]!=A)break;f[l--]=0,s=1}for(o=f.length;0===f[--o];f.pop());}return w&&(e.e>p.maxE?e.c=e.e=null:e.ea,!i||!o)return u==c?0:!i^r?1:-1;if(u!=c)return u>c^r?1:-1;for(a=-1,s=(u=i.length)<(c=o.length)?u:c;++ao[a]^r?1:-1;return u==c?0:u>c^r?1:-1},C.decimalPlaces=C.dp=function(){var e,t,r=null;if(e=this.c){if(r=((t=e.length-1)-N(this.e/_))*_,t=e[t])for(;t%10==0;t/=10,r--);0>r&&(r=0)}return r},C.dividedBy=C.div=function(e,t){return b=2,I(this,new this.constructor(e,t))},C.dividedToIntegerBy=C.divToInt=function(e,t){var r=this,n=r.constructor;return b=18,g(I(r,new n(e,t),0,1,1),n.precision,n.rounding)},C.equals=C.eq=function(e,t){return b=3,0===this.cmp(e,t)},C.exponential=C.exp=function(){return c(this)},C.floor=function(){return g(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e,t){return b=4,this.cmp(e,t)>0},C.greaterThanOrEqualTo=C.gte=function(e,t){return b=5,t=this.cmp(e,t),1==t||0===t},C.isFinite=function(){return!!this.c},C.isInteger=C.isInt=function(){return!!this.c&&N(this.e/_)>this.c.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isZero=function(){return!!this.c&&0==this.c[0]},C.lessThan=C.lt=function(e,t){return b=6,this.cmp(e,t)<0},C.lessThanOrEqualTo=C.lte=function(e,t){return b=7,t=this.cmp(e,t),-1==t||0===t},C.logarithm=C.log=function(e,t){var r,n,i,s,u,c,f,l,m,v=this,d=v.constructor,y=d.precision,x=d.rounding,N=5;if(null==e)e=new d(10),r=!0;else{if(b=15,e=new d(e,t),n=e.c,e.s<0||!n||!n[0]||!e.e&&1==n[0]&&1==n.length)return new d(0/0);r=e.eq(10)}if(n=v.c,v.s<0||!n||!n[0]||!v.e&&1==n[0]&&1==n.length)return new d(n&&!n[0]?-1/0:1!=v.s?0/0:n?0:1/0);if(u=r&&(s=n[0],n.length>1||1!=s&&10!=s&&100!=s&&1e3!=s&&1e4!=s&&1e5!=s&&1e6!=s),w=!1,f=y+N,l=f+10,c=h(v,f),r?(l>B.length&&p(d,1,l,"log"),i=new d(B.slice(0,l))):i=h(e,f),m=I(c,i,f,1),a(m.c,s=y,x))do if(f+=10,c=h(v,f),r?(l=f+10,l>B.length&&p(d,1,l,"log"),i=new d(B.slice(0,l))):i=h(e,f),m=I(c,i,f,1),!u){+o(m.c).slice(s+1,s+15)+1==1e14&&(m=g(m,y+1,0));break}while(a(m.c,s+=10,x));return w=!0,g(m,y,x)},C.minus=function(e,t){var r,n,i,o,a=this,s=a.constructor,u=a.s;if(b=8,e=new s(e,t),t=e.s,!u||!t)return new s(0/0);if(u!=t)return e.s=-t,a.plus(e);var c=a.c,f=e.c,l=N(e.e/_),p=N(a.e/_),m=s.precision,h=s.rounding;if(!p||!l){if(!c||!f)return c?(e.s=-t,e):new s(f?a:0/0);if(!c[0]||!f[0])return a=f[0]?(e.s=-t,e):new s(c[0]?a:3==h?-0:0),w?g(a,m,h):a}if(c=c.slice(),n=c.length,u=p-l){for((o=0>u)?(u=-u,r=c,n=f.length):(l=p,r=f),(p=Math.ceil(m/_))>n&&(n=p),u>(n+=2)&&(u=n,r.length=1),r.reverse(),t=u;t--;r.push(0));r.reverse()}else for((o=n<(i=f.length))&&(i=n),u=t=0;i>t;t++)if(c[t]!=f[t]){o=c[t]0)for(;t--;c[i++]=0);for(p=A-1,t=f.length;t>u;){if(c[--t]=10;t/=10,u++);return e.e=u+l*_-1,w?g(e,m,h):e},C.modulo=C.mod=function(e,t){var r,n,i=this,o=i.constructor,a=o.modulo;return b=9,e=new o(e,t),t=e.s,r=!i.c||!t||e.c&&!e.c[0],r||!e.c||i.c&&!i.c[0]?r?new o(0/0):g(new o(i),o.precision,o.rounding):(w=!1,9==a?(e.s=1,n=I(i,e,0,3,1),e.s=t,n.s*=t):n=I(i,e,0,a,1),n=n.times(e),w=!0,i.minus(n))},C.naturalLogarithm=C.ln=function(){return h(this)},C.negated=C.neg=function(){var e=new this.constructor(this);return e.s=-e.s||null,g(e)},C.plus=function(e,t){var r,n=this,i=n.constructor,o=n.s;if(b=10,e=new i(e,t),t=e.s,!o||!t)return new i(0/0);if(o!=t)return e.s=-t,n.minus(e);var a=n.c,s=e.c,u=N(e.e/_),c=N(n.e/_),f=i.precision,l=i.rounding;if(!c||!u){if(!a||!s)return new i(o/0);if(!a[0]||!s[0])return n=s[0]?e:new i(a[0]?n:0*o),w?g(n,f,l):n}if(a=a.slice(),o=c-u){for(0>o?(o=-o,r=a,t=s.length):(u=c,r=s,t=a.length),(c=Math.ceil(f/_))>t&&(t=c),o>++t&&(o=t,r.length=1),r.reverse();o--;r.push(0));r.reverse()}for(a.length-s.length<0&&(r=s,s=a,a=r),o=s.length,t=0,c=A;o;a[o]%=c)t=(a[--o]=a[o]+s[o]+t)/c|0;for(t&&(a.unshift(t),++u),o=a.length;0==a[--o];a.pop());for(e.c=a,o=1,t=a[0];t>=10;t/=10,o++);return e.e=o+u*_-1,w?g(e,f,l):e},C.precision=C.sd=function(e){var t=null,r=this;return e!=t&&e!==!!e&&1!==e&&0!==e&&p(r.constructor,"argument",e,"precision",1),r.c&&(t=l(r.c),e&&r.e+1>t&&(t=r.e+1)),t},C.round=function(){var e=this,t=e.constructor;return g(new t(e),e.e+1,t.rounding)},C.squareRoot=C.sqrt=function(){var e,t,r,n,i,a,s=this,u=s.c,c=s.s,f=s.e,l=s.constructor,p=new l(.5);if(1!==c||!u||!u[0])return new l(!c||0>c&&(!u||u[0])?0/0:u?s:1/0);for(w=!1,c=Math.sqrt(+s),0==c||c==1/0?(t=o(u),(t.length+f)%2==0&&(t+="0"),c=Math.sqrt(t),f=N((f+1)/2)-(0>f||f%2),c==1/0?t="1e"+f:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+f),n=new l(t)):n=new l(c.toString()),r=(f=l.precision)+3;;)if(a=n,n=p.times(a.plus(I(s,a,r+2,1))),o(a.c).slice(0,r)===(t=o(n.c)).slice(0,r)){if(t=t.slice(r-3,r+1),"9999"!=t&&(i||"4999"!=t)){(!+t||!+t.slice(1)&&"5"==t.charAt(0))&&(g(n,f+1,1),e=!n.times(n).eq(s));break}if(!i&&(g(a,f+1,0),a.times(a).eq(s))){n=a;break}r+=4,i=1}return w=!0,g(n,f,l.rounding,e)},C.times=function(e,t){var r,n,i=this,o=i.constructor,a=i.c,s=(b=11,e=new o(e,t),e.c),u=N(i.e/_),c=N(e.e/_),f=i.s;if(t=e.s,e.s=f==t?1:-1,!((u||a&&a[0])&&(c||s&&s[0])))return new o(!f||!t||a&&!a[0]&&!s||s&&!s[0]&&!a?0/0:a&&s?0*e.s:e.s/0);for(n=u+c,f=a.length,t=s.length,t>f&&(r=a,a=s,s=r,c=f,f=t,t=c),c=f+t,r=[];c--;r.push(0));for(u=t-1;u>-1;u--){for(t=0,c=f+u;c>u;)t=r[c]+s[u]*a[c-u-1]+t,r[c--]=t%A|0,t=t/A|0;r[c]=(r[c]+t)%A|0}for(t?++n:r[0]||r.shift(),c=r.length;!r[--c];r.pop());for(e.c=r,f=1,t=r[0];t>=10;t/=10,f++);return e.e=f+n*_-1,w?g(e,o.precision,o.rounding):e},C.toDecimalPlaces=C.toDP=function(e,t){var r=this;return r=new r.constructor(r),null!=e&&u(r,e,"toDP")?g(r,(0|e)+r.e+1,s(r,t,"toDP")):r},C.toExponential=function(e,t){var r=this;return r.c?f(r,null!=e&&u(r,e,"toExponential")?0|e:null,null!=e&&s(r,t,"toExponential"),1):r.toString()},C.toFixed=function(e,t){var r,n=this,i=n.constructor,o=i.toExpNeg,a=i.toExpPos;return null!=e&&(e=u(n,e,r="toFixed")?n.e+(0|e):null,t=s(n,t,r)),i.toExpNeg=-(i.toExpPos=1/0),null!=e&&n.c?(r=f(n,e,t),n.s<0&&n.c&&(n.c[0]?r.indexOf("-")<0&&(r="-"+r):r=r.replace("-",""))):r=n.toString(),i.toExpNeg=o,i.toExpPos=a,r},C.toFormat=function(e,t){var r=this;if(!r.c)return r.toString();var n,i=r.s<0,o=r.constructor.format,a=o.groupSeparator,s=+o.groupSize,u=+o.secondaryGroupSize,c=r.toFixed(e,t).split("."),f=c[0],l=c[1],p=i?f.slice(1):f,m=p.length;if(u&&(n=s,s=u,m-=u=n),s>0&&m>0){for(n=m%s||s,f=p.substr(0,n);m>n;n+=s)f+=a+p.substr(n,s);u>0&&(f+=a+p.slice(n)),i&&(f="-"+f)}return l?f+o.decimalSeparator+((u=+o.fractionGroupSize)?l.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+o.fractionGroupSeparator):l):f},C.toFraction=function(e){var t,r,n,i,a,s,u,c,f=this,m=f.constructor,h=t=new m(m.ONE),g=s=new m(0),v=f.c,d=new m(g);if(!v)return f.toString();for(n=d.e=l(v)-f.e-1,d.c[0]=E(10,(u=n%_)<0?_+u:u),(null==e||(!(b=12,a=new m(e)).s||(y=a.cmp(h)<0||!a.c)||m.errors&&N(a.e/_)0)&&(e=n>0?d:h),w=!1,a=new m(o(v)),u=m.precision,m.precision=n=v.length*_*2;c=I(a,d,0,1,1),r=t.plus(c.times(g)),1!=r.cmp(e);)t=g,g=r,h=s.plus(c.times(r=h)),s=r,d=a.minus(c.times(r=d)),a=r;return r=I(e.minus(t),g,0,1,1),s=s.plus(r.times(h)),t=t.plus(r.times(g)),s.s=h.s=f.s,i=I(h,g,n,1).minus(f).abs().cmp(I(s,t,n,1).minus(f).abs())<1?[h+"",g+""]:[s+"",t+""],w=!0,m.precision=u,i},C.toNearest=function(e,t){var r=this,n=r.constructor;return r=new n(r),null==e?(e=new n(n.ONE),t=n.rounding):(b=17,e=new n(e),t=s(r,t,"toNearest")),e.c?r.c&&(e.c[0]?(w=!1,r=I(r,e,0,4>t?[4,5,7,8][t]:t,1).times(e),w=!0,g(r)):r.c=[r.e=0]):r.s&&(e.s&&(e.s=r.s),r=e),r},C.toNumber=function(){var e=this;return+e||(e.s?0*e.s:0/0)},C.toPower=C.pow=function(e,t){var r,n,i,s,u=this,f=u.constructor,l=u.s,p=(b=13,+(e=new f(e,t))),v=0>p?-p:p,d=f.precision,y=f.rounding;if(!u.c||!e.c||(i=!u.c[0])||!e.c[0])return new f(E(i?0*l:+u,p));if(u=new f(u),r=u.c.length,!u.e&&u.c[0]==u.s&&1==r)return u;if(t=e.c.length-1,e.e||e.c[0]!=e.s||t)if(n=N(e.e/_),i=n>=t,!i&&0>l)s=new f(0/0);else{if(i&&T>r*_*v){if(s=m(f,u,v),e.s<0)return f.ONE.div(s)}else{if(l=0>l&&1&e.c[Math.max(n,t)]?-1:1,t=E(+u,p),n=0!=t&&isFinite(t)?new f(t+"").e:N(p*(Math.log("0."+o(u.c))/Math.LN10+u.e+1)),n>f.maxE+1||n0?l/0:0);w=!1,f.rounding=u.s=1,v=Math.min(12,(n+"").length),s=c(e.times(h(u,d+v)),d),s=g(s,d+5,1),a(s.c,d,y)&&(n=d+10,s=g(c(e.times(h(u,n+v)),n),n+5,1),+o(s.c).slice(d+1,d+15)+1==1e14&&(s=g(s,d+1,0))),s.s=l,w=!0,f.rounding=y}s=g(s,d,y)}else s=g(u,d,y);return s},C.toPrecision=function(e,t){var r=this;return null!=e&&u(r,e,"toPrecision",1)&&r.c?f(r,0|--e,s(r,t,"toPrecision"),2):r.toString()},C.toSignificantDigits=C.toSD=function(e,t){var r=this,n=r.constructor;return r=new n(r),null!=e&&u(r,e,"toSD",1)?g(r,0|e,s(r,t,"toSD")):g(r,n.precision,n.rounding)},C.toString=function(e){var t,r,n,i=this,a=i.constructor,s=i.e;if(null===s)r=i.s?"Infinity":"NaN";else{if(e===t&&(s<=a.toExpNeg||s>=a.toExpPos))return f(i,null,a.rounding,1);if(r=o(i.c),0>s){for(;++s;r="0"+r);r="0."+r}else if(n=r.length,s>0)if(++s>n)for(s-=n;s--;r+="0");else n>s&&(r=r.slice(0,s)+"."+r.slice(s));else if(t=r.charAt(0),n>1)r=t+"."+r.slice(1);else if("0"==t)return t;if(null!=e)if((y=!(e>=2&&65>e))||e!=(0|e)&&a.errors)p(a,"base",e,"toString",0);else if(r=v(a,r,0|e,10,i.s),"0"==r)return r}return i.s<0?"-"+r:r},C.truncated=C.trunc=function(){return g(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){return this.toString()},v=function(){function e(e,t,r){for(var n,i,o=[0],a=0,s=e.length;s>a;){for(i=o.length;i--;o[i]*=t);for(o[n=0]+=O.indexOf(e.charAt(a++));nr-1&&(null==o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}return function(t,r,n,i,o){var a,s,u,c,f,l,p=r.indexOf("."),h=t.precision,g=t.rounding;for(37>i&&(r=r.toLowerCase()),p>=0&&(r=r.replace(".",""),l=new t(i),c=m(t,l,r.length-p),l.c=e(c.toFixed(),10,n),l.e=l.c.length),f=e(r,i,n),a=s=f.length;0==f[--s];f.pop());if(!f[0])return"0";if(0>p?a--:(c.c=f,c.e=a,c.s=o,c=I(c,l,h,g,0,n),f=c.c,u=c.r,a=c.e),p=f[h],s=n/2,u=u||null!=f[h+1],4>g?(null!=p||u)&&(0==g||g==(c.s<0?3:2)):p>s||p==s&&(4==g||u||6==g&&1&f[h-1]||g==(c.s<0?8:7)))for(f.length=h,--n;++f[--h]>n;)f[h]=0,h||(++a,f.unshift(1));else f.length=h;for(s=f.length;!f[--s];);for(p=0,r="";s>=p;r+=O.charAt(f[p++]));if(0>a){for(;++a;r="0"+r);r="0."+r}else if(p=r.length,++a>p)for(a-=p;a--;r+="0");else p>a&&(r=r.slice(0,a)+"."+r.slice(a));return r}}();var I=function(){function e(e,t,r){var n,i=0,o=e.length;for(e=e.slice();o--;)n=e[o]*t+i,e[o]=n%r|0,i=n/r|0;return i&&e.unshift(i),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;r>i;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.shift());}return function(n,i,o,a,s,u){var c,f,l,p,m,h,v,d,y,x,w,b,E,M,O,C,S,z,T,B=n.constructor,I=n.s==i.s?1:-1,q=n.c,P=i.c;if(!(q&&q[0]&&P&&P[0]))return new B(n.s&&i.s&&(q?!P||q[0]!=P[0]:P)?q&&0==q[0]||!P?0*I:I/0:0/0);for(u?(p=1,f=n.e-i.e):(u=A,p=_,f=N(n.e/p)-N(i.e/p)),z=P.length,C=q.length,y=new B(I),x=y.c=[],l=0;P[l]==(q[l]||0);l++);if(P[l]>(q[l]||0)&&f--,null==o?(I=o=B.precision,a=B.rounding):I=s?o+(n.e-i.e)+1:o,0>I)x.push(1),m=!0;else{if(I=I/p+2|0,l=0,1==z){for(h=0,P=P[0],I++;(C>l||h)&&I--;l++)M=h*u+(q[l]||0),x[l]=M/P|0,h=M%P|0;m=h||C>l}else{for(h=u/(P[0]+1)|0,h>1&&(P=e(P,h,u),q=e(q,h,u),z=P.length,C=q.length),O=z,w=q.slice(0,z),b=w.length;z>b;w[b++]=0);T=P.slice(),T.unshift(0),S=P[0],P[1]>=u/2&&S++;do h=0,c=t(P,w,z,b),0>c?(E=w[0],z!=b&&(E=E*u+(w[1]||0)),h=E/S|0,h>1?(h>=u&&(h=u-1),v=e(P,h,u),d=v.length,b=w.length,c=t(v,w,d,b),1==c&&(h--,r(v,d>z?T:P,d,u))):(0==h&&(c=h=1),v=P.slice()),d=v.length,b>d&&v.unshift(0),r(w,v,b,u),-1==c&&(b=w.length,c=t(P,w,z,b),1>c&&(h++,r(w,b>z?T:P,b,u))),b=w.length):0===c&&(h++,w=[0]),x[l++]=h,c&&w[0]?w[b++]=q[O]||0:(w=[q[O]],b=1);while((O++=10;I/=10,l++);y.e=l+f*p-1,g(y,s?o+y.e+1:o,a,m)}return y}}();d=function(){function e(e){var t,r,n,i=this,o="config",a=i.errors?parseInt:parseFloat;return e==r||"object"!=typeof e&&!p(i,"object expected",e,o)?i:((n=e[t="precision"])!=r&&((y=1>n||n>z)||a(n)!=n?p(i,t,n,o,0):i[t]=0|n),(n=e[t="rounding"])!=r&&((y=0>n||n>8)||a(n)!=n?p(i,t,n,o,0):i[t]=0|n),(n=e[t="toExpNeg"])!=r&&((y=-S>n||n>0)||a(n)!=n?p(i,t,n,o,0):i[t]=N(n)),(n=e[t="toExpPos"])!=r&&((y=0>n||n>S)||a(n)!=n?p(i,t,n,o,0):i[t]=N(n)),(n=e[t="minE"])!=r&&((y=-S>n||n>0)||a(n)!=n?p(i,t,n,o,0):i[t]=N(n)),(n=e[t="maxE"])!=r&&((y=0>n||n>S)||a(n)!=n?p(i,t,n,o,0):i[t]=N(n)),(n=e[t="errors"])!=r&&(n===!!n||1===n||0===n?(y=b=0,i[t]=!!n):p(i,t,n,o,1)),(n=e[t="crypto"])!=r&&(n===!!n||1===n||0===n?i[t]=!(!n||!x||"object"!=typeof x):p(i,t,n,o,1)),(n=e[t="modulo"])!=r&&((y=0>n||n>9)||a(n)!=n?p(i,t,n,o,0):i[t]=0|n),(e=e[t="format"])!=r&&("object"==typeof e?i[t]=e:p(i,"format object expected",e,o)),i)}function t(e){return new this(e).exp()}function r(e){return new this(e).ln()}function n(e,t){return new this(e).log(t)}function i(e,t,r){var n,i,o=0;for("[object Array]"==M.call(t[0])&&(t=t[0]),n=new e(t[0]);++oi;)n=t[i],n>=429e7?t[i]=x.getRandomValues(new Uint32Array(1))[0]:o[i++]=n%1e7;else if(x&&x.randomBytes){for(t=x.randomBytes(r*=4);r>i;)n=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((127&t[i+3])<<24),n>=214e7?x.randomBytes(4).copy(t,i):(o.push(n%1e7),i+=4);i=r/4}else p(a,"crypto unavailable",x,"random");if(!i)for(;r>i;)o[i++]=1e7*Math.random()|0;for(r=o[--i],e%=_,r&&e&&(n=E(10,_-e),o[i]=(r/n|0)*n);0===o[i];i--)o.pop();if(0>i)o=[r=0];else{for(r=-1;0===o[0];)o.shift(),r-=_;for(i=1,n=o[0];n>=10;)n/=10,i++;_>i&&(r-=_-i)}return s.e=r,s.c=o,s}function f(e){return new this(e).sqrt()}function l(i){function u(e,t){var r=this;if(!(r instanceof u))return p(u,"Decimal called without new",e),new u(e,t);if(r.constructor=u,e instanceof u){if(null==t)return b=0,r.s=e.s,r.e=e.e,r.c=(e=e.c)?e.slice():e,r;if(10==t)return g(new u(e),u.precision,u.rounding);e+=""}return m(u,r,e,t)}return u.precision=20,u.rounding=4,u.modulo=1,u.toExpNeg=-7,u.toExpPos=21,u.minE=-S,u.maxE=S,u.errors=!0,u.crypto=!1,u.format={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0},u.prototype=C,u.ONE=new u(1),u.ROUND_UP=0,u.ROUND_DOWN=1,u.ROUND_CEIL=2,u.ROUND_FLOOR=3,u.ROUND_HALF_UP=4,u.ROUND_HALF_DOWN=5,u.ROUND_HALF_EVEN=6,u.ROUND_HALF_CEIL=7,u.ROUND_HALF_FLOOR=8,u.EUCLID=9,u.config=e,u.constructor=l,u.exp=t,u.ln=r,u.log=n,u.max=o,u.min=a,u.pow=s,u.sqrt=f,u.random=c,null!=i&&u.config(i),u}var m=function(){var e=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,t=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")};return function(r,n,i,o){var a,s,u,c,f,l;if("string"!=typeof i&&(i=(c="number"==typeof i||"[object Number]"==M.call(i))&&0===i&&0>1/i?"-0":i+""),f=i,null==o&&e.test(i))n.s=45===i.charCodeAt(0)?(i=i.slice(1),-1):1;else{if(10==o)return g(new r(i),r.precision,r.rounding);if(i=t.call(i).replace(/^\+(?!-)/,""),n.s=45===i.charCodeAt(0)?(i=i.replace(/^-(?!-)/,""),-1):1,null!=o?o!=(0|o)&&r.errors||(y=!(o>=2&&65>o))?(p(r,"base",o,0,0),l=e.test(i)):(a="["+O.slice(0,o=0|o)+"]+",i=i.replace(/\.$/,"").replace(/^\./,"0."),(l=new RegExp("^"+a+"(?:\\."+a+")?$",37>o?"i":"").test(i))?(c&&(i.replace(/^0\.0*|\./,"").length>15&&p(r,0,f),c=!c),i=v(r,i,10,o,n.s)):"Infinity"!=i&&"NaN"!=i&&(p(r,"not a base "+o+" number",f),i="NaN")):l=e.test(i),!l)return n.c=n.e=null,"Infinity"!=i&&("NaN"!=i&&p(r,"not a number",f),n.s=null),b=0,n}for((s=i.indexOf("."))>-1&&(i=i.replace(".","")),(u=i.search(/e/i))>0?(0>s&&(s=u),s+=+i.slice(u+1),i=i.substring(0,u)):0>s&&(s=i.length),u=0;48===i.charCodeAt(u);u++);for(o=i.length;48===i.charCodeAt(--o););if(i=i.slice(u,o+1)){if(o=i.length,c&&o>15&&p(r,0,f),n.e=s=s-u-1,n.c=[],u=(s+1)%_,0>s&&(u+=_),o>u){for(u&&n.c.push(+i.slice(0,u)),o-=_;o>u;)n.c.push(+i.slice(u,u+=_));i=i.slice(u),u=_-i.length}else u-=o;for(;u--;i+="0");n.c.push(+i),w&&(n.e>r.maxE?n.c=n.e=null:n.er;r++)t.push(0);return t}n.prototype.toFixed=function(e){var t=this.roundDigits(this.exponent+1+(e||0)),r=t.coefficients,n=t.exponent+1,o=n+(e||0);return r.lengthn&&(r=i(-n+1).concat(r),n=1),e&&r.splice(n,0,0===n?"0.":"."),this.sign+r.join("")},n.prototype.toExponential=function(e){var t=e?this.roundDigits(e):this.clone(),r=t.coefficients,n=t.exponent;r.length0?"."+r.join(""):"")+"e"+(n>=0?"+":"")+n},n.prototype.toPrecision=function(e,t){var r=t&&void 0!==t.lower?t.lower:.001,n=t&&void 0!==t.upper?t.upper:1e5,o=Math.abs(Math.pow(10,this.exponent));if(r>o||o>=n)return this.toExponential(e);var a=e?this.roundDigits(e):this.clone(),s=a.coefficients,u=a.exponent;s.length0?u:0;return c=e;)r.unshift(0),t.exponent++,e++;if(r.length>e){var n=r.splice(e);if(n[0]>=5){var i=e-1;for(r[i]++;10===r[i];)r.pop(),0===i&&(r.unshift(0),t.exponent++,i++),i--,r[i]++}}return t},e.exports=n},function(e,t,r){"use strict";e.exports={end:!0}},function(e,t,r){"use strict";function n(e){for(var t=e.getIdentifier(),r=0;r>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"};var i="\\mathrm{%name%}\\left(%*%\\right)",o={abs:"\\left|%0%\\right|",add:"\\left(%0%+%1%\\right)",ceil:"\\left\\lceil%0%\\right\\rceil",cube:"\\left(%0%\\right)^3",divide:"\\frac{%0%}{%1%}",dotDivide:"\\left(%0%"+t.operators.dotDivide+"%1%\\right)",dotMultiply:"\\left(%0%"+t.operators.dotMultiply+"%1%\\right)",dotPow:"\\left(%0%"+t.operators.dotPow+"%1%\\right)",exp:"\\exp\\left(%0%\\right)",fix:i,floor:"\\left\\lfloor%0%\\right\\rfloor",gcd:"\\gcd\\left(%*%\\right)",lcm:i,log10:"\\log_{10}\\left(%0%\\right)",log:{1:"\\ln\\left(%0%\\right)",2:"\\log_{%1%}\\left(%0%\\right)"},mod:"\\left(%0%"+t.operators.mod+"%1%\\right)",multiply:"\\left(%0%"+t.operators.multiply+"%1%\\right)",norm:{1:"\\left\\|%0%\\right\\|",2:i},nthRoot:"\\sqrt[%1%]{%0%}",pow:"\\left(%0%\\right)"+t.operators.pow+"{%1%}",round:{1:"\\left\\lfloor%0%\\right\\rceil",2:i},sign:i,sqrt:"\\sqrt{%0%}",square:"\\left(%0%\\right)^2",subtract:"\\left(%0%"+t.operators.subtract+"%1%\\right)",unaryMinus:t.operators.unaryMinus+"\\left(%0%\\right)",unaryPlus:t.operators.unaryPlus+"\\left(%0%\\right)",xgcd:i,bitAnd:"\\left(%0%"+t.operators.bitAnd+"%1%\\right)",bitOr:"\\left(%0%"+t.operators.bitOr+"%1%\\right)",bitXor:"\\left(%0%"+t.operators.bitXor+"%1%\\right)",bitNot:t.operators.bitNot+"\\left(%0%\\right)",leftShift:"\\left(%0%"+t.operators.leftShift+"%1%\\right)",rightArithShift:"\\left(%0%"+t.operators.rightArithShift+"%1%\\right)",rightLogShift:"\\left(%0%"+t.operators.rightLogShift+"%1%\\right)",arg:"\\arg\\left(%0%\\right)",conj:"\\left(%0%\\right)^*",im:"\\Im\\left\\lbrace%0%\\right\\rbrace",re:"\\Re\\left\\lbrace%0%\\right\\rbrace",bignumber:{0:"0",1:"\\left(%0%\\right)"},"boolean":i,chain:i,complex:{0:"0",1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)+"+t.symbols.i+"\\cdot\\left(%1%\\right)\\right)"},index:i,matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(%0%\\right)",2:"\\left(%0%\\right)"},number:{0:"0",1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)%1%\\right)"},parser:i,sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(%0%\\right)"},string:{0:'""',1:function(e){return'"'+e.args[0].toString()+'"'}},unit:{1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)%1%\\right)"},compile:i,eval:i,help:i,parse:i,and:"\\left(%0%"+t.operators.and+"%1%\\right)",not:t.operators.not+"\\left(%0%\\right)",or:"\\left(%0%"+t.operators.or+"%1%\\right)",xor:"\\left(%0%"+t.operators.xor+"%1%\\right)",concat:i,cross:"\\left(%0%\\right)\\times\\left(%1%\\right)",det:"\\det\\left(%0%\\right)",diag:i,dot:"\\left(%0%\\cdot%1%\\right)",eye:i,flatten:i,inv:"\\left(%0%\\right)^{-1}",ones:i,range:i,resize:i,size:i,squeeze:i,subset:i,trace:"\\mathrm{tr}\\left(%0%\\right)",transpose:"\\left(%0%\\right)"+t.operators.transpose,zeros:i,combinations:"\\binom{%0%}{%1%}",distribution:i,factorial:"\\left(%0%\\right)"+t.operators.factorial,gamma:"\\Gamma\\left(%0%\\right)",permutations:i,pickRandom:i,randomInt:i,random:i,compare:i,deepEqual:i,equal:"\\left(%0%"+t.operators.equal+"%1%\\right)",largerEq:"\\left(%0%"+t.operators.largerEq+"%1%\\right)",larger:"\\left(%0%"+t.operators.larger+"%1%\\right)",smallerEq:"\\left(%0%"+t.operators.smallerEq+"%1%\\right)",smaller:"\\left(%0%"+t.operators.smaller+"%1%\\right)",unequal:"\\left(%0%"+t.operators.unequal+"%1%\\right)",max:"\\max\\left(%*%\\right)",mean:i,median:i,min:"\\min\\left(%*%\\right)",prod:i,std:i,sum:i,"var":"\\mathrm{Var}\\left(%*%\\right)",acosh:"\\cosh^{-1}\\left(%0%\\right)",acos:"\\cos^{-1}\\left(%0%\\right)",acoth:"\\coth^{-1}\\left(%0%\\right)",acot:"\\cot^{-1}\\left(%0%\\right)",acsch:"\\mathrm{csch}^{-1}\\left(%0%\\right)",acsc:"\\csc^{-1}\\left(%0%\\right)",asech:"\\mathrm{sech}^{-1}\\left(%0%\\right)",asec:"\\sec^{-1}\\left(%0%\\right)",asinh:"\\sinh^{-1}\\left(%0%\\right)",asin:"\\sin^{-1}\\left(%0%\\right)",atan2:"\\mathrm{atan2}\\left(%*%\\right)",atanh:"\\tanh^{-1}\\left(%0%\\right)",atan:"\\tan^{-1}\\left(%0%\\right)",cosh:"\\cosh\\left(%0%\\right)",cos:"\\cos\\left(%0%\\right)",coth:"\\coth\\left(%0%\\right)",cot:"\\cot\\left(%0%\\right)",csch:"\\mathrm{csch}\\left(%0%\\right)",csc:"\\csc\\left(%0%\\right)",sech:"\\mathrm{sech}\\left(%0%\\right)",sec:"\\sec\\left(%0%\\right)",sinh:"\\sinh\\left(%0%\\right)",sin:"\\sin\\left(%0%\\right)",tanh:"\\tanh\\left(%0%\\right)",tan:"\\tan\\left(%0%\\right)",to:"\\left(%0%"+t.operators.to+"%1%\\right)",clone:i,filter:i,forEach:i,format:i,"import":i,map:i,print:i,sort:i,"typeof":i},a={deg:"^\\circ"};t.toSymbol=function(e){if(a.hasOwnProperty(e))return a[e];if(t.symbols.hasOwnProperty(e))return t.symbols[e];if(-1!==e.indexOf("_")){var r=e.indexOf("_");return t.toSymbol(e.substring(0,r))+"_{"+t.toSymbol(e.substring(r+1))+"}"}return"\\mathrm{"+e+"}"},t.toFunction=function(e,t,r){var a=o[r],s=e.args.map(function(e){return e.toTex(t)});switch(typeof a){case"function":return a(e,t);case"string":return n(a,r,s);case"object":switch(typeof a[s.length]){case"function":return a[s.length](e,t);case"string":return n(a[s.length],r,s)}default:return n(i,r,s)}}},function(e,t,r){"use strict";function n(e,t,r,n){var i=e.Matrix,c=function(e,t){var r=e.size();if(2!==r.length)throw new RangeError("Matrix must be two dimensional (size: "+o.format(r)+")");var n=r[0],c=r[1];if(n!==c)throw new RangeError("Matrix must be square (size: "+o.format(r)+")");if(t instanceof i){var f=t.size();if(1===f.length){if(f[0]!==n)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.")}else{if(2!==f.length)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");if(f[0]!==n||1!==f[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.")}var l=new Array(n);return t.forEach(function(e,t){l[t[0]]=s.clone(e)},!0),l}if(u(t)){var p=a.size(t);if(1===p.length){if(p[0]!==n)throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");return s.clone(t)}if(2===p.length){if(p[0]!==n||1!==p[1])throw new RangeError("Dimension mismatch. Matrix columns must match vector length.");return t.map(function(e){return s.clone(e[0])})}throw new RangeError("Dimension mismatch. Matrix columns must match vector length.")}};return c}var i=r(171),o=i.string,a=i.array,s=i.object,u=Array.isArray;t.name="substitutionValidation",t.factory=n},function(e,t,r){var n,i,o;!function(r){i=[],n=r,o="function"==typeof n?n.apply(t,i):n,!(void 0!==o&&(e.exports=o))}(function(){function e(e){var t=d.types[e];if(!t){var r;for(var n in d.types)if(d.types.hasOwnProperty(n)&&n.toLowerCase()==e.toLowerCase()){r=n;break}throw new Error('Unknown type "'+e+'"'+(r?'. Did you mean "'+r+'"?':""))}return t}function t(e,t,r,n,i){var o,a=p(n),s=i?i.split(","):null,u=s&&m(s,"any"),c={fn:e,index:r,actual:n,expected:s};o=s?t>r&&!u?"Unexpected type of argument (expected: "+s.join(" or ")+", actual: "+a+", index: "+r+")":"Too few arguments (expected: "+s.join(" or ")+", index: "+r+")":"Too many arguments (expected: "+r+", actual: "+t+")";var f=new TypeError(o);return f.data=c,f}function r(e){this.name=e||"refs",this.categories={}}function n(e,t){if("string"==typeof e){var r=e.trim(),i="..."===r.substr(0,3);if(i&&(r=r.substr(3)),""===r)this.types=["any"];else{this.types=r.split("|");for(var o=0;op)n[f]=c;else if(0===p)throw new Error('Signature "'+f+'" is defined twice')}else n[f]=c}}for(f in n)n.hasOwnProperty(f)&&o.push(n[f]);for(r=0;rr;r++)t[r]="arg"+r;return t}function f(e,n){var i=new r,o=a(n);if(0==o.length)throw new Error("No signatures provided");var f=u(o,[]),p=[],m=e||"",h=c(l(o));p.push("function "+m+"("+h.join(", ")+") {"),p.push(' "use strict";'),p.push(f.toCode(i," ")),p.push("}");var g=[i.toCode(),"return "+p.join("\n")].join("\n"),v=new Function(i.name,"createError",g),d=v(i,t);return d.signatures=s(o),d}function l(e){for(var t=0,r=0;rt&&(t=n)}return t}function p(e){for(var t in h)if(h.hasOwnProperty(t)&&"Object"!==t&&h[t](e))return t;return h.Object(e)?t:"unknown"}function m(e,t){return-1!==e.indexOf(t)}r.prototype.add=function(e,t){var r=t||"fn";this.categories[r]||(this.categories[r]=[]);var n=this.categories[r].indexOf(e);return-1==n&&(n=this.categories[r].length,this.categories[r].push(e)),r+n},r.prototype.toCode=function(){var e=[],t=this.name+".categories",r=this.categories;for(var n in r)if(r.hasOwnProperty(n))for(var i=r[n],o=0;o0},n.prototype.toString=function(e){for(var t=[],r={},n=0;nt.params.length)return 1;if(e.params.lengthr;r++)e.params[r].hasConversions()&&o++,t.params[r].hasConversions()&&a++;if(o>a)return 1;if(a>o)return-1;for(r=0;r "+o+") {"),i.push(r+" var varArgs = [];"),i.push(r+" for (var i = "+o+"; i < arguments.length; i++) {"),i.push(r+" varArgs.push(arguments[i]);"),i.push(r+" }"),i.push(this.signature.toCode(t,r+" ")),i.push(r+"}");else{for(var u=function(r,n){for(var i=new Array(r.length),o=0;o "+r+") {",t+" throw createError('', arguments.length, "+r+", arguments["+r+"]);",t+"}"].join("\n");for(var n={},i=[],o=0;o0?1:0>e?-1:0},r.format=function(e,t){if("function"==typeof t)return t(e);if(e===1/0)return"Infinity";if(e===-(1/0))return"-Infinity";if(isNaN(e))return"NaN";var n="auto",i=void 0;switch(t&&(t.notation&&(n=t.notation),r.isNumber(t)?i=t:t.precision&&(i=t.precision)),n){case"fixed":return r.toFixed(e,i);case"exponential":return r.toExponential(e,i);case"auto":return r.toPrecision(e,i,t&&t.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},r.toExponential=function(e,r){return new n(e).toExponential(r)},r.toFixed=function(e,r){return new n(e).toFixed(r)},r.toPrecision=function(e,r,t){return new n(e).toPrecision(r,t)},r.digits=function(e){return e.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},r.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,r.nearlyEqual=function(e,t,n){if(null==n)return e==t;if(e==t)return!0;if(isNaN(e)||isNaN(t))return!1;if(isFinite(e)&&isFinite(t)){var i=Math.abs(e-t);return io;o++)0!=o&&(i+=", "),i+=n(e[o],t);return i+="]"}return r.format(e,t)}var i=t(41),a=t(48),o=t(191);r.isString=function(e){return"string"==typeof e},r.endsWith=function(e,r){var t=e.length-r.length,n=e.length;return e.substring(t,n)===r},r.format=function(e,t){return i.isNumber(e)?i.format(e,t):e instanceof o?a.format(e,t):Array.isArray(e)?n(e,t):r.isString(e)?'"'+e+'"':"function"==typeof e?e.syntax?e.syntax+"":"function":e instanceof Object?"function"==typeof e.format?e.format(t):e.toString():String(e)}},function(e,r,t){"use strict";function n(e,r,n,i,a){var o=n(t(52));return i("parser",{"":function(){return new o(a)}})}r.name="parser",r.factory=n,r.math=!0},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("smaller",{"boolean, boolean":function(e,r){return r>e},"number, number":function(e,t){return t>e&&!i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return e.lt(r)},"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.valuee},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(41).nearlyEqual;r.name="smaller",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("larger",{"boolean, boolean":function(e,r){return e>r},"number, number":function(e,t){return e>t&&!i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gt(r)},"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>t.value&&!i(e.value,t.value,r.epsilon)},"string, string":function(e,r){return e>r},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(41).nearlyEqual;r.name="larger",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("equal",{"any, any":function(e,r){return null===e?null===r:null===r?null===e:void 0===e?void 0===r:void 0===r?void 0===e:u(e,r)},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,u)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,u)}}),u=a("_equal",{"boolean, boolean":function(e,r){return e===r},"number, number":function(e,t){return e===t||i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return e.eq(r)},"Complex, Complex":function(e,t){return(e.re===t.re||i(e.re,t.re,r.epsilon))&&(e.im===t.im||i(e.im,t.im,r.epsilon))},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value===t.value||i(e.value,t.value,r.epsilon)},"string, string":function(e,r){return e===r}});return s}var i=t(41).nearlyEqual;r.name="equal",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(192)),s=n(t(193)),u=i("add",{"any, any":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=s.algorithm4(e,r,o);break;default:t=s.algorithm1(r,e,o,!0)}break;default:switch(r.storage()){case"sparse":t=s.algorithm1(e,r,o,!1);break;default:t=s.algorithm12(e,r,o)}}return t},"Array, Array":function(e,r){return u(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return u(a(e),r)},"Matrix, Array":function(e,r){return u(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=s.algorithm9(e,r,o,!1);break;default:t=s.algorithm13(e,r,o,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=s.algorithm9(r,e,o,!0);break;default:t=s.algorithm13(r,e,o,!0)}return t},"Array, any":function(e,r){return s.algorithm13(a(e),r,o,!1).valueOf()},"any, Array":function(e,r){return s.algorithm13(a(r),e,o,!0).valueOf()}});return u}r.name="add",r.factory=n},function(e,r,t){"use strict";function n(e,t,n){var a,o,s=e.constructor,u=+(e.s<0),c=+(t.s<0);if(u){a=i(r.not(e));for(var f=0;f0;)n(l[--h],p[--g])==v&&(d=d.plus(y)),y=y.times(x);for(;g>0;)n(m,p[--g])==v&&(d=d.plus(y)),y=y.times(x);return s.config({precision:w}),0==v&&(d.s=-d.s),d}function i(e){for(var r=e.c,t=r[0]+"",n=1;n0)if(++s>c)for(s-=c;s--;u+="0");else c>s&&(u=u.slice(0,s)+"."+u.slice(s));for(var f=[0],n=0;n1&&(null==f[o+1]&&(f[o+1]=0),f[o+1]+=f[o]>>1,f[o]&=1)}return f.reverse()}function a(e,t){var n=t.precision,i=-(n+4),a=n+8-e.e,o=25-e.e,s=Math.max(1.442695*Math.log(n+2)|5,5);t.config({precision:o});var u=0,c=new t(Math.asin(e.toNumber())+"");do{var l=r.cos_sin_sec_csc(c,t,1,!1),p=f(l);l.isZero()||(l.s=c.s);var m=l.minus(e).div(p);c=c.minus(m),o=Math.min(2*o,a),t.config({precision:o})}while(2*m.e>=i&&!m.isZero()&&++u<=s);if(u==s)throw new Error("asin() failed to converge to the requested accuracy.Try with a higher precision.");return t.config({precision:n}),c.toDP(n-1)}function o(e,r){var t=e.constructor;t.config({precision:r+Math.log(r)|4});for(var n=new t(1),i=e,a=0/0,o=e.times(e),s=e,u=new t(n),c=new t(n),f=new t(n),l=3;!i.equals(a);l+=2)s=s.times(o),u=u.times(f),c=c.times(f.plus(n)),a=i,f=new t(l),i=i.plus(s.times(u).div(f.times(c)));return t.config({precision:r}),i.toDP(r-1)}function s(e){for(var r=e,t=0/0,n=e.times(e),i=e,a=!0,o=3;!r.equals(t);o+=2)i=i.times(n),t=r,a=!a,r=a?r.plus(i.div(o)):r.minus(i.div(o));return r}function u(e,r){for(var t=e.constructor.ONE,n=e,i=0/0,a=e.times(e),o=r?n:n=t,s=t,u=!0,c=r;!n.equals(i);c+=2)o=o.times(a),s=s.times(c+1).times(c+2),i=n,u=!u,n=u?n.plus(o.div(s)):n.minus(o.div(s));return n}function c(e,t,n){var i=r.pi(t+2),a=r.tau(t);if(e.abs().lte(i.toDP(e.dp())))return[e,!1];var o=e.constructor;if(e.div(i.toDP(e.dp())).toNumber()%2==0)return[new o(1^n),!0];var s=e.mod(a);return s.toDP(e.dp(),1).isZero()?[new o(1^n),!0]:(s.gt(i)&&(n?(s=s.minus(i),s.s=-s.s):s=a.minus(s)),s.constructor=o,[s,!1])}function f(e){var r=e.constructor,t=r.precision;r.config({precision:t+2});var n=r.ONE.minus(e.times(e)).sqrt();return r.config({precision:t}),n.toDP(t-1)}var l=t(191),p=t(41).isNumber,m=t(41).digits,h=t(188).memoize;r.isBigNumber=function(e){return e instanceof l},r.toBigNumber=function(e,r){return new r(m(e)>15?e+"":e)},r.e=h(function(e){var r=l.constructor({precision:e});return new r(1).exp()}),r.phi=h(function(e){var r=l.constructor({precision:e});return new r(1).plus(new r(5).sqrt()).div(2)}),r.pi=h(function(e){var r=l.constructor({precision:e+4}),t=new r(4).times(s(new r(1).div(5))).minus(s(new r(1).div(239)));return r.config({precision:e}),new r(4).times(t)}),r.tau=h(function(e){var t=r.pi(e+2),n=l.constructor({precision:e});return new n(2).times(t)}),r.and=function(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitAnd");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(0/0);if(e.isZero()||r.eq(-1)||e.eq(r))return e;if(r.isZero()||e.eq(-1))return r;if(!e.isFinite()||!r.isFinite()){if(!e.isFinite()&&!r.isFinite())return e.isNegative()==r.isNegative()?e:new t(0);if(!e.isFinite())return r.isNegative()?e:e.isNegative()?new t(0):r;if(!r.isFinite())return e.isNegative()?r:r.isNegative()?new t(0):e}return n(e,r,function(e,r){return e&r})},r.leftShift=function(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function leftShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(0/0):e.isZero()||r.isZero()?e:e.isFinite()||r.isFinite()?e.times(r.lt(55)?Math.pow(2,r.toNumber())+"":new t(2).pow(r)):new t(0/0)},r.not=function(e){if(e.isFinite()&&!e.isInteger())throw new Error("Integer expected in function bitNot");var r=e.constructor,t=r.precision;r.config({precision:1e9});var e=e.plus(r.ONE);return e.s=-e.s||null,r.config({precision:t}),e},r.or=function(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function bitOr");var t=e.constructor;if(e.isNaN()||r.isNaN())return new t(0/0);var i=new t(-1);return e.isZero()||r.eq(i)||e.eq(r)?r:r.isZero()||e.eq(i)?e:e.isFinite()&&r.isFinite()?n(e,r,function(e,r){return e|r}):!e.isFinite()&&!e.isNegative()&&r.isNegative()||e.isNegative()&&!r.isNegative()&&!r.isFinite()?i:e.isNegative()&&r.isNegative()?e.isFinite()?e:r:e.isFinite()?r:e},r.rightArithShift=function(e,r){if(e.isFinite()&&!e.isInteger()||r.isFinite()&&!r.isInteger())throw new Error("Integers expected in function rightArithShift");var t=e.constructor;return e.isNaN()||r.isNaN()||r.isNegative()&&!r.isZero()?new t(0/0):e.isZero()||r.isZero()?e:r.isFinite()?r.lt(55)?e.div(Math.pow(2,r.toNumber())+"").floor():e.div(new t(2).pow(r)).floor():new t(e.isNegative()?-1:e.isFinite()?0:0/0)},r.xor=function(e,t){if(e.isFinite()&&!e.isInteger()||t.isFinite()&&!t.isInteger())throw new Error("Integers expected in function bitXor");var i=e.constructor;if(e.isNaN()||t.isNaN())return new i(0/0);if(e.isZero())return t;if(t.isZero())return e;if(e.eq(t))return new i(0);var a=new i(-1);return e.eq(a)?r.not(t):t.eq(a)?r.not(e):e.isFinite()&&t.isFinite()?n(e,t,function(e,r){return e^r}):e.isFinite()||t.isFinite()?new i(e.isNegative()==t.isNegative()?1/0:-(1/0)):a},r.arccos_arcsec=function(e,t,n){var i=t.precision;if(n){if(e.abs().lt(t.ONE))throw new Error("asec() only has non-complex values for |x| >= 1.")}else if(e.abs().gt(t.ONE))throw new Error("acos() only has non-complex values for |x| <= 1.");if(e.eq(-1))return r.pi(i);t.config({precision:i+4}),n&&(e=t.ONE.div(e));var a=r.arctan_arccot(t.ONE.minus(e.times(e)).sqrt().div(e.plus(t.ONE)),t).times(2);return t.config({precision:i}),a.toDP(i-1)},r.arcsin_arccsc=function(e,t,n){if(e.isNaN())return new t(0/0);var i=t.precision,s=e.abs();if(n){if(s.lt(t.ONE))throw new Error("acsc() only has non-complex values for |x| >= 1.");t.config({precision:i+2}),e=t.ONE.div(e),t.config({precision:i}),s=e.abs()}else if(s.gt(t.ONE))throw new Error("asin() only has non-complex values for |x| <= 1.");if(s.gt(.8)){t.config({precision:i+4});var u=e.s,c=r.pi(i+4).div(2);return e=c.minus(r.arcsin_arccsc(t.ONE.minus(e.times(e)).sqrt(),t)),e.s=u,e.constructor=t,t.config({precision:i}),e.toDP(i-1)}var f=s.gt(.58);f&&(t.config({precision:i+8}),e=e.div(new t(2).sqrt().times(t.ONE.minus(e.times(e)).sqrt().plus(t.ONE).sqrt())),t.config({precision:i}));var l=60>=i||e.dp()<=Math.log(i)&&e.lt(.05)?o(e,i):a(e,t);return f?l.times(2):l},r.arctan_arccot=function(e,t,n){if(e.isNaN())return new t(0/0);if(!n&&e.isZero()||n&&!e.isFinite())return new t(0);var i=t.precision;if(!n&&!e.isFinite()||n&&e.isZero()){var a=r.pi(i+2).div(2).toDP(i-1);return a.constructor=t,a.s=e.s,a}t.config({precision:i+4}),n&&(e=t.ONE.div(e));var o=e.abs();if(o.lte(.875)){var u=s(e);return u.constructor=t,t.config({precision:i}),u.toDP(t.precision-1)}if(o.gte(1.143)){var a=r.pi(i+4).div(2),u=a.minus(s(t.ONE.div(o)));return u.s=e.s,u.constructor=t,t.config({precision:i}),u.toDP(t.precision-1)}return e=e.div(e.times(e).plus(1).sqrt()),t.config({precision:i}),r.arcsin_arccsc(e,t)},r.arctan2=function(e,t,n){var i=n.precision;if(t.isZero()){if(e.isZero())return new n(0/0);var a=r.pi(i+2).div(2).toDP(i-1);return a.constructor=n,a.s=e.s,a}n.config({precision:i+2});var o=r.arctan_arccot(e.div(t),n,!1);if(t.isNegative()){var s=r.pi(i+2);o=e.isNegative()?o.minus(s):o.plus(s)}return o.constructor=n,n.config({precision:i}),o.toDP(i-1)},r.acosh_asinh_asech_acsch=function(e,r,t,n){if(e.isNaN())return new r(0/0);if(n&&e.isZero())return new r(1/0);if(!t)if(n){if(e.isNegative()||e.gt(r.ONE))throw new Error("asech() only has non-complex values for 0 <= x <= 1.")}else if(e.lt(r.ONE))throw new Error("acosh() only has non-complex values for x >= 1.");var i=r.precision;r.config({precision:i+4});var a=new r(e);a.constructor=r,n&&(a=r.ONE.div(a));var o=t?a.times(a).plus(r.ONE):a.times(a).minus(r.ONE),s=a.plus(o.sqrt()).ln();return r.config({precision:i}),new r(s.toPrecision(i))},r.atanh_acoth=function(e,r,t){if(e.isNaN())return new r(0/0);var n=e.abs();if(n.eq(r.ONE))return new r(e.isNegative()?-(1/0):1/0);if(n.gt(r.ONE)){if(!t)throw new Error("atanh() only has non-complex values for |x| <= 1.")}else if(t)throw new Error("acoth() has complex values for |x| < 1.");if(e.isZero())return new r(0);var i=r.precision;r.config({precision:i+4});var a=new r(e);a.constructor=r,t&&(a=r.ONE.div(a));var o=r.ONE.plus(a).div(r.ONE.minus(a)).ln().div(2);return r.config({precision:i}),new r(o.toPrecision(i))},r.cos_sin_sec_csc=function(e,r,t,n){if(e.isNaN()||!e.isFinite())return new r(0/0);var i=r.precision,a=new r(e),o=a.isNegative();o&&(a.s=-a.s);var s=i+(0|Math.log(i))+3;if(r.config({precision:s}),a=c(a,s,t),a[0].constructor=r,a[1])return a=a[0],n&&a.isZero()&&(a=new r(1/0)),r.config({precision:i}),a;var f;if(a=a[0],t){f=u(a.div(3125),t),r.config({precision:Math.min(s,i+15)});for(var l=new r(5),p=new r(16),m=new r(20),h=0;5>h;++h){var g=f.times(f),v=g.times(f),d=v.times(g);f=p.times(d).minus(m.times(v)).plus(l.times(f))}o&&(f.s=-f.s)}else{var y,x;a.abs().lt(r.ONE)?(y=64,x=3):(y=256,x=4),f=u(a.div(y),t),r.config({precision:Math.min(s,i+8)});for(var w=new r(8);x>0;--x){var g=f.times(f),b=g.times(g);f=w.times(b.minus(g)).plus(r.ONE)}}return n&&(f=f.e<=-i?new r(1/0):r.ONE.div(f)),r.config({precision:i}),f.toDP(i-1)},r.tan_cot=function(e,t,n){if(e.isNaN())return new t(0/0);var i=t.precision,a=r.pi(i+2),o=a.div(2).toDP(i-1);a=a.toDP(i-1);var s=c(e,i,1)[0];if(s.abs().eq(a))return new t(1/0);t.config({precision:i+4});var u=r.cos_sin_sec_csc(s,t,1,!1),l=f(u);u=u.toDP(i),l=l.toDP(i),s.eq(e)?s.gt(o)&&(l.s=-l.s):a.minus(s.abs()).gt(o)&&(l.s=-l.s);var p=n?l.div(u):u.div(l);return t.config({precision:i}),new t(p.toPrecision(i))},r.cosh_sinh_csch_sech=function(e,r,t,n){if(e.isNaN())return new r(0/0);if(!e.isFinite())return new r(n?0:t?e:1/0);var i=r.precision;r.config({precision:i+4});var a=new r(e);return a.constructor=r,a=a.exp(),a=t?a.minus(r.ONE.div(a)):a.plus(r.ONE.div(a)),a=n?new r(2).div(a):a.div(2),r.config({precision:i}),new r(a.toPrecision(i))},r.tanh_coth=function(e,r,t){if(e.isNaN())return new r(0/0);if(!e.isFinite())return new r(e.s);var n=r.precision;r.config({precision:n+4});var i=new r(e);i.constructor=r;var a=i.exp(),o=r.ONE.div(a),s=a.minus(o);return s=t?a.plus(o).div(s):s.div(a.plus(o)),r.config({precision:n}),s.toDP(n-1)},r.format=function(e,t){if("function"==typeof t)return t(e);if(!e.isFinite())return e.isNaN()?"NaN":e.gt(0)?"Infinity":"-Infinity";var n="auto",i=void 0;switch(void 0!==t&&(t.notation&&(n=t.notation),p(t)?i=t:t.precision&&(i=t.precision)),n){case"fixed":return r.toFixed(e,i);case"exponential":return r.toExponential(e,i);case"auto":var a=.001,o=1e5;t&&t.exponential&&(void 0!==t.exponential.lower&&(a=t.exponential.lower),void 0!==t.exponential.upper&&(o=t.exponential.upper));{({toExpNeg:e.constructor.toExpNeg,toExpPos:e.constructor.toExpPos})}if(e.constructor.config({toExpNeg:Math.round(Math.log(a)/Math.LN10),toExpPos:Math.round(Math.log(o)/Math.LN10)}),e.isZero())return"0";var s,u=e.abs();return s=u.gte(a)&&u.lt(o)?e.toSignificantDigits(i).toFixed():r.toExponential(e,i),s.replace(/((\.\d*?)(0+))($|e)/,function(){var e=arguments[2],r=arguments[4];return"."!==e?e+r:r});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},r.toExponential=function(e,r){return void 0!==r?e.toExponential(r-1):e.toExponential()},r.toFixed=function(e,r){return e.toFixed(r||0)}},function(e,r,t){e.exports="2.0.0-SNAPSHOT"},function(e,r,t){"use strict";r.ArgumentsError=t(194),r.DimensionError=t(39),r.IndexError=t(38)},function(e,r,t){"use strict";function n(e,r,n,a){function o(r,t){if(1!=arguments.length&&2!=arguments.length)throw new i("parse",arguments.length,1,2);if(me=t&&t.nodes?t.nodes:{},"string"==typeof r)return he=r,y();if(Array.isArray(r)||r instanceof e.Matrix)return Q.deepMap(r,function(e){if("string"!=typeof e)throw new TypeError("String expected");return he=e,y()});throw new TypeError("String or matrix expected")}function s(){ge=0,ve=he.charAt(0),xe=0,we=null}function u(){ge++,ve=he.charAt(ge)}function c(){return he.charAt(ge+1)}function f(){return he.charAt(ge+2)}function l(){for(ye=fe.NULL,de="";" "==ve||" "==ve||"\n"==ve&&xe;)u();if("#"==ve)for(;"\n"!=ve&&""!=ve;)u();if(""==ve)return void(ye=fe.DELIMITER);if("\n"==ve&&!xe)return ye=fe.DELIMITER,de=ve,void u();var e=ve+c(),r=e+f();if(3==r.length&&le[r])return ye=fe.DELIMITER,de=r,u(),u(),void u();if(2==e.length&&le[e])return ye=fe.DELIMITER,de=e,u(),void u();if(le[ve])return ye=fe.DELIMITER,de=ve,void u();if(!v(ve)){if(g(ve)){for(;g(ve)||d(ve);)de+=ve,u();return void(ye=pe[de]?fe.DELIMITER:fe.SYMBOL)}for(ye=fe.UNKNOWN;""!=ve;)de+=ve,u();throw X('Syntax error in part "'+de+'"')}if(ye=fe.NUMBER,"."==ve)de+=ve,u(),d(ve)||(ye=fe.UNKNOWN);else{for(;d(ve);)de+=ve,u();"."==ve&&(de+=ve,u())}for(;d(ve);)de+=ve,u();if(e=c(),("E"==ve||"e"==ve)&&(d(e)||"-"==e||"+"==e))for(de+=ve,u(),("+"==ve||"-"==ve)&&(de+=ve,u()),d(ve)||(ye=fe.UNKNOWN);d(ve);)de+=ve,u()}function p(){do l();while("\n"==de)}function m(){xe++}function h(){xe--}function g(e){return e>="a"&&"z">=e||e>="A"&&"Z">=e||"_"==e}function v(e){return e>="0"&&"9">=e||"."==e}function d(e){return e>="0"&&"9">=e}function y(){s(),l();var e=x();if(""!=de)throw ye==fe.DELIMITER?J("Unexpected operator "+de):X('Unexpected part "'+de+'"');return e}function x(){var e,r,t=[];if(""==de)return new te("undefined","undefined");for("\n"!=de&&";"!=de&&(e=w());"\n"==de||";"==de;)0==t.length&&e&&(r=";"!=de,t.push({node:e,visible:r})),l(),"\n"!=de&&";"!=de&&""!=de&&(e=w(),r=";"!=de,t.push({node:e,visible:r}));return t.length>0?new ee(t):e}function w(){if(ye==fe.SYMBOL&&"function"==de)throw X('Deprecated keyword "function". Functions can now be assigned without it, like "f(x) = x^2".');return b()}function b(){var e,r,t,n,i=N();if("="==de){if(i&&i.isSymbolNode)return e=i.name,p(),t=b(),new K(e,t);if(i&&i.isIndexNode)return p(),t=b(),new ce(i,t);if(i&&i.isFunctionNode&&(n=!0,r=[],e=i.name,i.args.forEach(function(e,t){e&&e.isSymbolNode?r[t]=e.name:n=!1}),n))return p(),t=b(),new ne(e,r,t);throw X("Invalid left hand side of assignment operator =")}return i}function N(){for(var e=E();"?"==de;){var r=we;we=xe,p();var t=e,n=E();if(":"!=de)throw X("False part of conditional expression expected");we=null,p();var i=N();e=new re(t,n,i),we=r}return e}function E(){for(var e=M();"or"==de;)p(),e=new ae("or","or",[e,M()]);return e}function M(){for(var e=A();"xor"==de;)p(),e=new ae("xor","xor",[e,A()]);return e}function A(){for(var e=_();"and"==de;)p(),e=new ae("and","and",[e,_()]);return e}function _(){for(var e=O();"|"==de;)p(),e=new ae("|","bitOr",[e,O()]);return e}function O(){for(var e=z();"^|"==de;)p(),e=new ae("^|","bitXor",[e,z()]);return e}function z(){for(var e=C();"&"==de;)p(),e=new ae("&","bitAnd",[e,C()]);return e}function C(){var e,r,t,n,i;for(e=S(),r={"==":"equal","!=":"unequal","<":"smaller",">":"larger","<=":"smallerEq",">=":"largerEq"};de in r;)t=de,n=r[t],p(),i=[e,S()],e=new ae(t,n,i);return e}function S(){var e,r,t,n,i;for(e=B(),r={"<<":"leftShift",">>":"rightArithShift",">>>":"rightLogShift"};de in r;)t=de,n=r[t],p(),i=[e,B()],e=new ae(t,n,i);return e}function B(){var e,r,t,n,i;for(e=T(),r={to:"to","in":"to"};de in r;)t=de,n=r[t],p(),i=[e,T()],e=new ae(t,n,i);return e}function T(){var e,r=[];if(e=":"==de?new te("1","number"):I(),":"==de&&we!==xe){for(r.push(e);":"==de&&r.length<3;)p(),r.push(")"==de||"]"==de||","==de||""==de?new ue("end"):I());e=3==r.length?new se(r[0],r[2],r[1]):new se(r[0],r[1])}return e}function I(){var e,r,t,n,i;for(e=q(),r={"+":"add","-":"subtract"};de in r;)t=de,n=r[t],p(),i=[e,q()],e=new ae(t,n,i);return e}function q(){var e,r,t,n,i;if(e=P(),r={"*":"multiply",".*":"dotMultiply","/":"divide","./":"dotDivide","%":"mod",mod:"mod"},de in r)for(;de in r;)t=de,n=r[t],p(),i=[e,P()],e=new ae(t,n,i);return(ye==fe.SYMBOL||"in"==de&&e&&e.isConstantNode||ye==fe.NUMBER&&(!e||!e.isConstantNode)||"("==de||"["==de)&&(e=new ae("*","multiply",[e,q()])),e}function P(){var e,r,t={"-":"unaryMinus","+":"unaryPlus","~":"bitNot",not:"not"}[de];return t?(e=de,p(),r=[P()],new ae(e,t,r)):k()}function k(){var e,r,t,n;return e=U(),("^"==de||".^"==de)&&(r=de,t="^"==r?"pow":"dotPow",p(),n=[e,P()],e=new ae(r,t,n)),e}function U(){var e,r,t,n,i;for(e=R(),r={"!":"factorial","'":"transpose"};de in r;)t=de,n=r[t],l(),i=[e],e=new ae(t,n,i);return e}function R(){var e,r=[];if(ye==fe.SYMBOL&&me[de]){if(e=me[de],l(),"("==de){if(r=[],m(),l(),")"!=de)for(r.push(N());","==de;)l(),r.push(N());if(")"!=de)throw X("Parenthesis ) expected");h(),l()}return new e(r)}return L()}function L(){var e,r;return ye==fe.SYMBOL||ye==fe.DELIMITER&&de in pe?(r=de,l(),e=j(r),e=F(e)):D()}function j(e){var r;if("("==de){if(r=[],m(),l(),")"!=de)for(r.push(N());","==de;)l(),r.push(N());if(")"!=de)throw X("Parenthesis ) expected");return h(),l(),new oe(e,r)}return new ue(e)}function F(e){for(var r;"["==de;){if(r=[],m(),l(),"]"!=de)for(r.push(N());","==de;)l(),r.push(N());if("]"!=de)throw X("Parenthesis ] expected");h(),l(),e=new ie(e,r)}return e}function D(){var e,r,t;if('"'==de){for(r="",t="";""!=ve&&('"'!=ve||"\\"==t);)r+=ve,t=ve,u();if(l(),'"'!=de)throw X('End of string " expected');return l(),e=new te(r,"string"),e=F(e)}return G()}function G(){var e,r,t,n;if("["==de){if(m(),l(),"]"!=de){var i=V();if(";"==de){for(t=1,r=[i];";"==de;)l(),r[t]=V(),t++;if("]"!=de)throw X("End of matrix ] expected");h(),l(),n=r[0].nodes.length;for(var a=1;t>a;a++)if(r[a].nodes.length!=n)throw J("Column dimensions mismatch ("+r[a].nodes.length+" != "+n+")");e=new $(r)}else{if("]"!=de)throw X("End of matrix ] expected");h(),l(),e=i}}else h(),l(),e=new $([]);return e}return Z()}function V(){for(var e=[b()],r=1;","==de;)l(),e[r]=b(),r++;return new $(e)}function Z(){var e;return ye==fe.NUMBER?(e=de,l(),new te(e,"number")):W()}function W(){var e;if("("==de){if(m(),l(),e=b(),")"!=de)throw X("Parenthesis ) expected");return h(),l(),e}return H()}function H(){throw X(""==de?"Unexpected end of expression":"Value expected")}function Y(){return ge-de.length+1}function X(e){var r=Y(),t=new SyntaxError(e+" (char "+r+")");return t["char"]=r,t}function J(e){var r=Y(),t=new Error(e+" (char "+r+")");return t["char"]=r,t}var Q=n(t(2)),$=n(t(195)),K=n(t(196)),ee=n(t(197)),re=n(t(198)),te=n(t(199)),ne=n(t(200)),ie=n(t(201)),ae=n(t(202)),oe=n(t(203)),se=n(t(204)),ue=n(t(205)),ce=n(t(206)),fe={NULL:0,DELIMITER:1,NUMBER:2,SYMBOL:3,UNKNOWN:4},le={",":!0,"(":!0,")":!0,"[":!0,"]":!0,'"':!0,";":!0,"+":!0,"-":!0,"*":!0,".*":!0,"/":!0,"./":!0,"%":!0,"^":!0,".^":!0,"~":!0,"!":!0,"&":!0,"|":!0,"^|":!0,"'":!0,"=":!0,":":!0,"?":!0,"==":!0,"!=":!0,"<":!0,">":!0,"<=":!0,">=":!0,"<<":!0,">>":!0,">>>":!0},pe={mod:!0,to:!0,"in":!0,and:!0,xor:!0,or:!0,not:!0},me={},he="",ge=0,ve="",de="",ye=fe.NULL,xe=0,we=null;return o}var i=t(194);r.name="parse",r.path="expression",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i,a){function o(){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");this.scope={}}var s=n(t(51));return o.prototype.parse=function(e){throw new Error("Parser.parse is deprecated. Use math.parse instead.")},o.prototype.compile=function(e){throw new Error("Parser.compile is deprecated. Use math.compile instead.")},o.prototype.eval=function(e){return s(e).compile(a).eval(this.scope)},o.prototype.get=function(e){return this.scope[e]},o.prototype.set=function(e,r){return this.scope[e]=r},o.prototype.remove=function(e){delete this.scope[e]},o.prototype.clear=function(){for(var e in this.scope)this.scope.hasOwnProperty(e)&&delete this.scope[e]},o}r.name="Parser",r.path="expression",r.factory=n,r.math=!0},function(e,r,t){"use strict";function n(e,r,t,n){return function(r,t){var n=e[t&&t.mathjs];return n&&"function"==typeof n.fromJSON?n.fromJSON(t):t}}r.name="reviver",r.path="json",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var o=n(t(40)),s=n(t(56)),u=n(t(47)),c=n(t(207)),f=n(t(71)),l=n(t(79)),p=n(t(45)),m=n(t(46)),h=n(t(80)),g=e.SparseMatrix,v=e.DenseMatrix,d=e.Spa,y=i("lup",{Matrix:function(e){switch(e.storage()){case"dense":return x(e);case"sparse":return w(e)}},Array:function(e){var r=o(e),t=y(r);return{L:t.L.valueOf(),U:t.U.valueOf(),P:t.P.valueOf()}}}),x=function(e){var r,t,n,i=e._size[0],o=e._size[1],h=Math.min(i,o),g=a.clone(e._data),d=[],y=[i,h],x=[],w=[h,o],b=v.diagonal([i,i],1,0);for(t=0;o>t;t++){if(t>0)for(r=0;i>r;r++){var N=Math.min(r,t),E=0;for(n=0;N>n;n++)E=u(E,f(g[r][n],g[n][t]));g[r][t]=l(g[r][t],E)}var M=t,A=0,_=0;for(r=t;i>r;r++){var O=g[r][t],z=s(O);p(z,A)&&(M=r,A=z,_=O)}if(t!==M&&(v._swapRows(t,M,b._data),v._swapRows(t,M,g)),i>t)for(r=t+1;i>r;r++){var C=g[r][t];m(C,0)||(g[r][t]=c(g[r][t],_))}}for(t=0;o>t;t++)for(r=0;i>r;r++)0===t&&(o>r&&(x[r]=[]),d[r]=[]),t>r?(o>r&&(x[r][t]=g[r][t]),i>t&&(d[r][t]=0)):r!==t?(o>r&&(x[r][t]=0),i>t&&(d[r][t]=g[r][t])):(o>r&&(x[r][t]=g[r][t]),i>t&&(d[r][t]=1));var S=new v({data:d,size:y}),B=new v({data:x,size:w});return{L:S,U:B,P:b,toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.P.toString()}}},w=function(e){var r,t,n,i=e._size[0],a=e._size[1],o=Math.min(i,a),u=e._values,l=e._index,v=e._ptr,y=[],x=[],w=[],b=[i,o],N=[],E=[],M=[],A=[o,a],_=[],O=[],z=[],C=[i,i],S=new Array(i),B=new Array(i);for(r=0;i>r;r++)S[r]=r,B[r]=r;var T=function(e,r){var t=B[e],n=B[r];S[t]=r,S[n]=e,B[e]=n,B[r]=t};for(t=0;a>t;t++){var I=new d(i);i>t&&(w.push(y.length),y.push(1),x.push(t)),M.push(N.length);var q=v[t],P=v[t+1];for(n=q;P>n;n++)r=l[n],I.set(S[r],u[n]);t>0&&I.forEach(0,t-1,function(e,r){g._forEachRow(e,y,x,w,function(t,n){t>e&&I.accumulate(t,h(f(n,r)))})});var k=t,U=I.get(t),R=s(U);I.forEach(t+1,i-1,function(e,r){var t=s(r);p(t,R)&&(k=e,R=t,U=r)}),t!==k&&(g._swapRows(t,k,b[1],y,x,w),g._swapRows(t,k,A[1],N,E,M),I.swap(t,k),T(t,k)),I.forEach(0,i-1,function(e,r){t>=e?(N.push(r),E.push(e)):(r=c(r,U),m(r,0)||(y.push(r),x.push(e)))})}for(w.push(y.length),M.push(N.length),r=0;i>r;r++)z.push(_.length),_.push(1),O.push(S[r]);return z.push(_.length),{L:new g({values:y,index:x,ptr:w,size:b}),U:new g({values:N,index:E,ptr:M,size:A}),P:new g({values:_,index:O,ptr:z,size:C}),toString:function(){return"L: "+this.L.toString()+"\nU: "+this.U.toString()+"\nP: "+this.P.toString()}}};return y}var i=t(36),a=i.object;r.name="lup",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(40)),s=n(t(54)),u=n(t(71)),c=n(t(208)),f=n(t(209)),l=a("lusolve",{"Array, Array | Matrix":function(e,r){e=o(e);var t=s(e),n=m(t.L,t.U,t.P,r);return n.valueOf()},"Matrix, Array | Matrix":function(e,r){var t=s(e);return m(t.L,t.U,t.P,r)},"Object, Array | Matrix":function(e,r){return m(e.L,e.U,e.P,r)}}),p=function(r){if(r instanceof e.Matrix)return r;if(i(r))return o(r);throw new TypeError("Invalid Matrix LUP decomposition")},m=function(e,r,t,n){e=p(e),r=p(r),t=p(t),n=u(t,n);var i=f(e,n);return c(r,i)};return l}var i=Array.isArray;r.name="lusolve",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("abs",{number:Math.abs,Complex:function(e){var r=Math.abs(e.re),t=Math.abs(e.im);if(1e3>r&&1e3>t)return Math.sqrt(r*r+t*t);if(r>=t){var n=t/r;return r*Math.sqrt(1+n*n)}var i=r/t;return t*Math.sqrt(1+i*i)},BigNumber:function(e){return e.abs()},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="abs",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("ceil",{number:Math.ceil,Complex:function(e){return new e.constructor(Math.ceil(e.re),Math.ceil(e.im))},BigNumber:function(e){return e.ceil()},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="ceil",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=n(t(210)).signatures["Complex,Complex"],s=i("cube",{number:function(e){return e*e*e},Complex:function(e){return o(o(e,e),e)},BigNumber:function(e){return e.times(e).times(e)},"Array | Matrix":function(e){return a.deepMap(e,s,!0)}});return s}r.name="cube",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=n(t(207)),s=n(t(71)),u=n(t(109));return i("divide",{"any, any":o,"Array | Matrix, Array | Matrix":function(e,r){return s(e,u(r))},"Array | Matrix, any":function(e,r){return a.deepMap2(e,r,o)},"any, Array | Matrix":function(e,r){return s(e,u(r))}})}r.name="divide",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(207)),s=n(t(193)),u=i("dotDivide",{"any, any":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=s.algorithm7(e,r,o,!1);break;default:t=s.algorithm2(r,e,o,!0)}break;default:switch(r.storage()){case"sparse":t=s.algorithm3(e,r,o,!1);break;default:t=s.algorithm12(e,r,o)}}return t},"Array, Array":function(e,r){return u(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return u(a(e),r)},"Matrix, Array":function(e,r){return u(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=s.algorithm10(e,r,o,!1);break;default:t=s.algorithm13(e,r,o,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=s.algorithm11(r,e,o,!0);break;default:t=s.algorithm13(r,e,o,!0)}return t},"Array, any":function(e,r){return s.algorithm13(a(e),r,o,!1).valueOf()},"any, Array":function(e,r){return s.algorithm13(a(r),e,o,!0).valueOf()}});return u}r.name="dotDivide",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(210)),s=n(t(193)),u=i("dotMultiply",{ +"any, any":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=s.algorithm6(e,r,o,!1);break;default:t=s.algorithm2(r,e,o,!0)}break;default:switch(r.storage()){case"sparse":t=s.algorithm2(e,r,o,!1);break;default:t=s.algorithm12(e,r,o)}}return t},"Array, Array":function(e,r){return u(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return u(a(e),r)},"Matrix, Array":function(e,r){return u(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=s.algorithm10(e,r,o,!1);break;default:t=s.algorithm13(e,r,o,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=s.algorithm10(r,e,o,!0);break;default:t=s.algorithm13(r,e,o,!0)}return t},"Array, any":function(e,r){return s.algorithm13(a(e),r,o,!1).valueOf()},"any, Array":function(e,r){return s.algorithm13(a(r),e,o,!0).valueOf()}});return u}r.name="dotMultiply",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(74)),s=n(t(193)),u=i("dotPow",{"any, any":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=s.algorithm7(e,r,o,!1);break;default:t=s.algorithm3(r,e,o,!0)}break;default:switch(r.storage()){case"sparse":t=s.algorithm3(e,r,o,!1);break;default:t=s.algorithm12(e,r,o)}}return t},"Array, Array":function(e,r){return u(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return u(a(e),r)},"Matrix, Array":function(e,r){return u(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=s.algorithm10(e,r,u,!1);break;default:t=s.algorithm13(e,r,u,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=s.algorithm11(r,e,u,!0);break;default:t=s.algorithm13(r,e,u,!0)}return t},"Array, any":function(e,r){return s.algorithm13(a(e),r,u,!1).valueOf()},"any, Array":function(e,r){return s.algorithm13(a(r),e,u,!0).valueOf()}});return u}r.name="dotPow",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("exp",{number:Math.exp,Complex:function(r){var t=Math.exp(r.re);return new e.Complex(t*Math.cos(r.im),t*Math.sin(r.im))},BigNumber:function(e){return e.exp()},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="exp",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("fix",{number:function(e){return e>0?Math.floor(e):Math.ceil(e)},Complex:function(e){return new e.constructor(e.re>0?Math.floor(e.re):Math.ceil(e.re),e.im>0?Math.floor(e.im):Math.ceil(e.im))},BigNumber:function(e){return e.isNegative()?e.ceil():e.floor()},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="fix",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("floor",{number:Math.floor,Complex:function(e){return new e.constructor(Math.floor(e.re),Math.floor(e.im))},BigNumber:function(e){return e.floor()},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="floor",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r,t){if(!r.isInt()||!t.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new e.BigNumber(0);!t.isZero();){var i=r.mod(t);r=t,t=i}return r.lt(n)?r.neg():r}var s=n(t(40)),u=n(t(193)),c=a("gcd",{"number, number":i,"BigNumber, BigNumber":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm4(e,r,c);break;default:t=u.algorithm1(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm1(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return c(s(e),r)},"Matrix, Array":function(e,r){return c(e,s(r))},"Matrix, number | BigNumber":function(e,r){var t;switch(e.storage()){case"sparse":t=u.algorithm9(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"number | BigNumber, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=u.algorithm9(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, number | BigNumber":function(e,r){return u.algorithm13(s(e),r,c,!1).valueOf()},"number | BigNumber, Array":function(e,r){return u.algorithm13(s(r),e,c,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,r,t){for(var n=c(e,r),i=0;ie?-e:e}var a=t(41).isInteger;r.name="gcd",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r,t){if(!r.isInt()||!t.isInt())throw new Error("Parameters in function lcm must be integer numbers");if(r.isZero()||t.isZero())return new e.BigNumber(0);for(var n=r.times(t);!t.isZero();){var i=t;t=r.mod(i),r=i}return n.div(r).abs()}var s=n(t(40)),u=n(t(193)),c=a("lcm",{"number, number":i,"BigNumber, BigNumber":o,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm6(e,r,c);break;default:t=u.algorithm2(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm2(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return c(s(e),r)},"Matrix, Array":function(e,r){return c(e,s(r))},"Matrix, number | BigNumber":function(e,r){var t;switch(e.storage()){case"sparse":t=u.algorithm10(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"number | BigNumber, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=u.algorithm10(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, number | BigNumber":function(e,r){return u.algorithm13(s(e),r,c,!1).valueOf()},"number | BigNumber, Array":function(e,r){return u.algorithm13(s(r),e,c,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(e,r,t){for(var n=c(e,r),i=0;i=0?Math.log(r):u(new e.Complex(r,0))}var o=n(t(2)),s=n(t(207)),u=i("log",{number:a,Complex:function(r){return new e.Complex(Math.log(Math.sqrt(r.re*r.re+r.im*r.im)),Math.atan2(r.im,r.re))},BigNumber:function(e){return e.ln()},"Array | Matrix":function(e){return o.deepMap(e,u)},"any, any":function(e,r){return s(u(e),u(r))}});return u}r.name="log",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(r){return new e.Complex(Math.log(Math.sqrt(r.re*r.re+r.im*r.im))/Math.LN10,Math.atan2(r.im,r.re)/Math.LN10)}var o=n(t(2)),s=i("log10",{number:function(r){return r>=0?Math.log(r)/Math.LN10:s(new e.Complex(r,0))},Complex:a,BigNumber:function(r){return r.isNegative()?a(new e.Complex(r.toNumber(),0)):r.log()},"Array | Matrix":function(e){return o.deepMap(e,s)}});return s}r.name="log10",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){if(r>0)return e-r*Math.floor(e/r);if(0===r)return e;throw new Error("Cannot calculate mod for a negative divisor")}var o=n(t(40)),s=n(t(193)),u=i("mod",{"number, number":a,"BigNumber, BigNumber":function(e,r){return r.isZero()?e:e.mod(r)},"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=s.algorithm5(e,r,u,!1);break;default:t=s.algorithm2(r,e,u,!0)}break;default:switch(r.storage()){case"sparse":t=s.algorithm3(e,r,u,!1);break;default:t=s.algorithm12(e,r,u)}}return t},"Array, Array":function(e,r){return u(o(e),o(r)).valueOf()},"Array, Matrix":function(e,r){return u(o(e),r)},"Matrix, Array":function(e,r){return u(e,o(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=s.algorithm10(e,r,u,!1);break;default:t=s.algorithm13(e,r,u,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=s.algorithm11(r,e,u,!0);break;default:t=s.algorithm13(r,e,u,!0)}return t},"Array, any":function(e,r){return s.algorithm13(o(e),r,u,!1).valueOf()},"any, Array":function(e,r){return s.algorithm13(o(r),e,u,!0).valueOf()}});return u}r.name="mod",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var o=n(t(40)),s=n(t(192)),u=n(t(210)),c=n(t(46)),f=n(t(193)),l=e.DenseMatrix,p=e.SparseMatrix,m=i("multiply",{"any, any":u,"Array, Array":function(r,t){h(a.size(r),a.size(t));var n=m(o(r),o(t));return n instanceof e.Matrix?n.valueOf():n},"Matrix, Matrix":function(e,r){var t=e.size(),n=r.size();return h(t,n),1===t.length?1===n.length?g(e,r,t[0]):v(e,r):1===n.length?y(e,r):x(e,r)},"Matrix, Array":function(e,r){return m(e,o(r))},"Array, Matrix":function(e,r){return m(o(e,r.storage()),r)},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=f.algorithm10(e,r,u,!1);break;case"dense":t=f.algorithm13(e,r,u,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=f.algorithm10(r,e,u,!0);break;case"dense":t=f.algorithm13(r,e,u,!0)}return t},"Array, any":function(e,r){return f.algorithm13(o(e),r,u,!1).valueOf()},"any, Array":function(e,r){return f.algorithm13(o(r),e,u,!0).valueOf()}}),h=function(e,r){switch(e.length){case 1:switch(r.length){case 1:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(e[0]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+e[0]+") must match Matrix rows ("+r[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;case 2:switch(r.length){case 1:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+e[1]+") must match Vector length ("+r[0]+")");break;case 2:if(e[1]!==r[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+e[1]+") must match Matrix B rows ("+r[0]+")");break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+r.length+" dimensions)")}break;default:throw new Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+e.length+" dimensions)")}},g=function(e,r,t){if(0===t)throw new Error("Cannot multiply two empty vectors");for(var n=e._data,i=e._datatype,a=r._data,o=r._datatype,c=i&&o&&i===o?i:void 0,f=c?u.signatures[c+","+c]||u:u,l=c?s.signatures[c+","+c]||s:s,p=f(n[0],a[0]),m=1;t>m;m++)p=l(p,f(n[m],a[m]));return p},v=function(e,r){switch(r.storage()){case"dense":return d(e,r)}throw new Error("Not implemented")},d=function(e,r){for(var t=e._data,n=e._size,i=e._datatype,a=r._data,o=r._size,c=r._datatype,f=n[0],p=o[1],m=i&&c&&i===c?i:void 0,h=m?u.signatures[m+","+m]||u:u,g=m?s.signatures[m+","+m]||s:s,v=new Array(p),d=0;p>d;d++){for(var y=h(t[0],a[0][d]),x=1;f>x;x++)y=g(y,h(t[x],a[x][d]));v[d]=y}return 1===p?v[0]:new l({data:v,size:[p],datatype:m})},y=function(e,r){switch(e.storage()){case"dense":return w(e,r);case"sparse":return E(e,r)}},x=function(e,r){switch(e.storage()){case"dense":switch(r.storage()){case"dense":return b(e,r);case"sparse":return N(e,r)}break;case"sparse":switch(r.storage()){case"dense":return M(e,r);case"sparse":return A(e,r)}}},w=function(e,r){for(var t=e._data,n=e._size,i=e._datatype,a=r._data,o=r._datatype,c=n[0],f=n[1],p=i&&o&&i===o?i:void 0,m=p?u.signatures[p+","+p]||u:u,h=p?s.signatures[p+","+p]||s:s,g=new Array(c),v=0;c>v;v++){for(var d=t[v],y=m(d[0],a[0]),x=1;f>x;x++)y=h(y,m(d[x],a[x]));g[v]=y}return 1===c?g[0]:new l({data:g,size:[c],datatype:p})},b=function(e,r){for(var t=e._data,n=e._size,i=e._datatype,a=r._data,o=r._size,c=r._datatype,f=n[0],p=n[1],m=o[1],h=i&&c&&i===c?i:void 0,g=h?u.signatures[h+","+h]||u:u,v=h?s.signatures[h+","+h]||s:s,d=new Array(f),y=0;f>y;y++){var x=t[y];d[y]=new Array(m);for(var w=0;m>w;w++){for(var b=g(x[0],a[0][w]),N=1;p>N;N++)b=v(b,g(x[N],a[N][w]));d[y][w]=b}}return 1===f&&1===m?d[0][0]:new l({data:d,size:[f,m],datatype:h})},N=function(e,r){var t=e._data,n=e._size,i=e._datatype,a=r._values,o=r._index,f=r._ptr,l=r._size,m=r._datatype;if(!a)throw new Error("Cannot multiply Dense Matrix times Pattern only Matrix");for(var h=n[0],g=l[1],v=[],d=[],y=new Array(g+1),x=new p({values:v,index:d,ptr:y,size:[h,g],datatype:w}),w=i&&m&&i===m?i:void 0,b=w?u.signatures[w+","+w]||u:u,N=w?s.signatures[w+","+w]||s:s,E=0;g>E;E++){y[E]=d.length;var M=f[E],A=f[E+1];if(A>M)for(var _=0,O=0;h>O;O++){for(var z,C=O+1,S=M;A>S;S++){var B=o[S];_!==C?(z=b(t[O][B],a[S]),_=C):z=N(z,b(t[O][B],a[S]))}_!==C||c(z,0)||(d.push(O),v.push(z))}}return y[g]=d.length,1===h&&1===g?1===v.length?v[0]:0:x},E=function(e,r){var t=e._values,n=e._index,i=e._ptr,a=e._datatype;if(!t)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");var o=r._data,f=r._datatype,l=e._size[0],m=r._size[0],h=[],g=[],v=new Array(2),d=a&&f&&a===f?a:void 0,y=d?u.signatures[d+","+d]||u:u,x=d?s.signatures[d+","+d]||s:s,w=new Array(l),b=new Array(l);v[0]=0;for(var N=0;m>N;N++){var E=o[N];if(!c(E,0))for(var M=i[N],A=i[N+1],_=M;A>_;_++){var O=n[_];b[O]?w[O]=x(w[O],y(E,t[_])):(b[O]=!0,g.push(O),w[O]=y(E,t[_]))}}for(var z=g.length,C=0;z>C;C++){var S=g[C];h[C]=w[S]}return v[1]=g.length,1===l?1===h.length?h[0]:0:new p({values:h,index:g,ptr:v,size:[l,1],datatype:d})},M=function(e,r){var t=e._values,n=e._index,i=e._ptr,a=e._datatype;if(!t)throw new Error("Cannot multiply Pattern only Matrix times Dense Matrix");for(var o=r._data,f=r._datatype,l=e._size[0],m=r._size[0],h=r._size[1],g=a&&f&&a===f?a:void 0,v=g?u.signatures[g+","+g]||u:u,d=g?s.signatures[g+","+g]||s:s,y=[],x=[],w=new Array(h+1),b=new p({values:y,index:x,ptr:w,size:[l,h],datatype:g}),N=new Array(l),E=new Array(l),M=0;h>M;M++){w[M]=x.length;for(var A=M+1,_=0;m>_;_++){var O=o[_][M];if(!c(O,0))for(var z=i[_],C=i[_+1],S=z;C>S;S++){var B=n[S];E[B]!==A?(E[B]=A,x.push(B),N[B]=v(O,t[S])):N[B]=d(N[B],v(O,t[S]))}}for(var T=w[M],I=x.length,q=T;I>q;q++){var P=x[q];y[q]=N[P]}}return w[h]=x.length,1===l&&1===h?1===y.length?y[0]:0:b},A=function(e,r){for(var t,n,i,a,o,c,f,l,m=e._values,h=e._index,g=e._ptr,v=e._datatype,d=r._values,y=r._index,x=r._ptr,w=r._datatype,b=v&&w&&v===w?v:void 0,N=b?u.signatures[b+","+b]||u:u,E=b?s.signatures[b+","+b]||s:s,M=e._size[0],A=r._size[1],_=m&&d,O=_?[]:void 0,z=[],C=new Array(A+1),S=new p({values:O,index:z,ptr:C,size:[M,A],datatype:b}),B=_?new Array(M):void 0,T=new Array(M),I=0;A>I;I++){C[I]=z.length;var q=I+1;for(o=x[I],c=x[I+1],a=o;c>a;a++)if(l=y[a],_)for(n=g[l],i=g[l+1],t=n;i>t;t++)f=h[t],T[f]!==q?(T[f]=q,z.push(f),B[f]=N(d[a],m[t])):B[f]=E(B[f],N(d[a],m[t]));else for(n=g[l],i=g[l+1],t=n;i>t;t++)f=h[t],T[f]!==q&&(T[f]=q,z.push(f));if(_)for(var P=C[I],k=z.length,U=P;k>U;U++){var R=z[U];O[U]=B[R]}}return C[A]=z.length,1===M&&1===A&&_?1===O.length?O[0]:0:S};return m}var i=t(36),a=i.array;r.name="multiply",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){var t=e.size();if(1==t.length){if(r===Number.POSITIVE_INFINITY||"inf"===r){var n=0;return e.forEach(function(e){var r=o(e);p(r,n)&&(n=r)},!0),n}if(r===Number.NEGATIVE_INFINITY||"-inf"===r){var i;return e.forEach(function(e){var r=o(e);(!i||m(r,i))&&(i=r)},!0),i||0}if("fro"===r)return a(e,2);if("number"==typeof r&&!isNaN(r)){if(!l(r,0)){var h=0;return e.forEach(function(e){h=s(u(o(e),r),h)},!0),u(h,1/r)}return Number.POSITIVE_INFINITY}throw new Error("Unsupported parameter value")}if(2==t.length){if(1===r){var d=[],y=0;return e.forEach(function(e,r){var t=r[1],n=s(d[t]||0,o(e));p(n,y)&&(y=n),d[t]=n},!0),y}if(r===Number.POSITIVE_INFINITY||"inf"===r){var x=[],w=0;return e.forEach(function(e,r){var t=r[0],n=s(x[t]||0,o(e));p(n,w)&&(w=n),x[t]=n},!0),w}if("fro"===r)return c(g(f(v(e),e)));if(2===r)throw new Error("Unsupported parameter value, missing implementation of matrix singular value decomposition");throw new Error("Unsupported parameter value")}}var o=n(t(56)),s=n(t(47)),u=n(t(74)),c=n(t(77)),f=n(t(71)),l=n(t(46)),p=n(t(45)),m=n(t(44)),h=n(t(40)),g=n(t(116)),v=n(t(117)),d=o.signatures.Complex,y=i("norm",{number:Math.abs,Complex:d,BigNumber:function(e){return e.abs()},"boolean | null":function(e){return Math.abs(e)},Array:function(e){return a(h(e),2)},Matrix:function(e){return a(e,2)},"number | Complex | BigNumber | boolean | null, number | BigNumber | string":function(e){return y(e)},"Array, number | BigNumber | string":function(e,r){return a(h(e),r)},"Matrix, number | BigNumber | string":function(e,r){return a(e,r)}});return y}r.name="norm",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r,t){var n=new e.BigNumber(0),i=new e.BigNumber(1),a=t.isNegative();if(a&&(t=t.negated()),t.isZero())throw new Error("Root must be non-zero");if(r.isNegative()&&!t.abs().mod(2).equals(1))throw new Error("Root must be odd when a is negative.");if(r.isZero())return n;if(!r.isFinite())return a?n:r;var o=i,s=0,u=100;do{var c=o,f=r.div(o.pow(t.minus(1))).minus(o).div(t);o=o.plus(f),s++}while(!o.equals(c)&&u>s);return a?i.div(o):o}var s=n(t(2)),u=a("nthRoot",{number:function(e){return i(e,2)},"number, number":i,BigNumber:function(r){return o(r,new e.BigNumber(2))},"BigNumber, BigNumber":o,"Array | Matrix":function(e){return s.deepMap(e,u)},"Array | Matrix, any":function(e,r){return s.deepMap2(e,r,u)},"any, Array | Matrix":function(e,r){return s.deepMap2(e,r,u)}});return u}function i(e,r){var t=0>r;if(t&&(r=-r),0===r)throw new Error("Root must be non-zero");if(0>e&&Math.abs(r)%2!=1)throw new Error("Root must be odd when a is negative.");if(0==e)return 0;if(!Number.isFinite(e))return t?0:e;var n=1e-16,i=1,a=0,o=100;do{var s=(e/Math.pow(i,r-1)-i)/r;i+=s,a++}while(Math.abs(s)>n&&o>a);return t?1/i:i}r.name="nthRoot",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(e,r){return f(m(p(e),r))}function u(e,r){if(!i(r)||0>r)throw new TypeError("For A^b, b must be a positive integer (value is "+r+")");var t=a(e);if(2!=t.length)throw new Error("For A^b, A must be 2 dimensional (A has "+t.length+" dimensions)");if(t[0]!=t[1])throw new Error("For A^b, A must be square (size is "+t[0]+"x"+t[1]+")");for(var n=l(t[0]).valueOf(),o=e;r>=1;)1==(1&r)&&(n=m(o,n)),r>>=1,o=m(o,o);return n}function c(e,r){return h(u(e.valueOf(),r))}var f=(n(t(2)),n(t(63))),l=n(t(107)),p=n(t(68)),m=n(t(71)),h=n(t(40)),g=o("pow",{"number, number":function(r,t){return i(t)||r>=0?Math.pow(r,t):s(new e.Complex(r,0),new e.Complex(t,0))},"BigNumber, BigNumber":function(r,t){return i(t)||r>=0?r.pow(t):s(new e.Complex(r.toNumber(),0),new e.Complex(t.toNumber(),0))},"Complex, Complex":s,"Array, number":u,"Array, BigNumber":function(e,r){return u(e,r.toNumber())},"Matrix, number":c,"Matrix, BigNumber":function(e,r){return c(e,r.toNumber())}});return g}var i=t(41).isInteger,a=t(37).size;r.name="pow",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=n(t(40)),c=n(t(46)),f=n(t(118)),l=n(t(193)),p=o("round",{number:Math.round,"number, number":function(e,r){if(!a(r))throw new TypeError("Number of decimals in function round must be an integer");if(0>r||r>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return i(e,r)},Complex:function(r){return new e.Complex(Math.round(r.re),Math.round(r.im))},"Complex, number":function(r,t){return new e.Complex(i(r.re,t),i(r.im,t))},"Complex, BigNumber":function(r,t){var n=t.toNumber();return new e.Complex(i(r.re,n),i(r.im,n))},BigNumber:function(e){return e.toDecimalPlaces(0)},"BigNumber, BigNumber":function(e,r){if(!r.isInteger())throw new TypeError("Number of decimals in function round must be an integer");return e.toDecimalPlaces(r.toNumber())},"Array | Matrix":function(e){return s.deepMap(e,p,!0)},"Matrix, number | BigNumber":function(e,r){var t;switch(e.storage()){case"sparse":t=l.algorithm10(e,r,p,!1);break;default:t=l.algorithm13(e,r,p,!1)}return t},"number | Complex | BigNumber, Matrix":function(e,r){if(!c(e,0)){var t;switch(r.storage()){case"sparse":t=l.algorithm11(r,e,p,!0);break;default:t=l.algorithm13(r,e,p,!0)}return t}return f(r.size(),r.storage())},"Array, number | BigNumber":function(e,r){return l.algorithm13(u(e),r,p,!1).valueOf()},"number | Complex | BigNumber, Array":function(e,r){return l.algorithm13(u(r),e,p,!0).valueOf()}});return p}function i(e,r){return parseFloat(o(e,r))}var a=t(41).isInteger,o=t(41).toFixed;r.name="round",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("sign",{number:i.sign,Complex:function(e){var r=Math.sqrt(e.re*e.re+e.im*e.im);return new e.constructor(e.re/r,e.im/r)},BigNumber:function(e){return new e.constructor(e.cmp(0))},"Array | Matrix":function(e){return o.deepMap(e,s,!0)}});return s}var i=t(41);r.name="sign",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(r){return r>=0?Math.sqrt(r):o(new e.Complex(r,0))}function o(r){var t,n,i=Math.sqrt(r.re*r.re+r.im*r.im);return t=r.re>=0?.5*Math.sqrt(2*(i+r.re)):Math.abs(r.im)/Math.sqrt(2*(i-r.re)),n=r.re<=0?.5*Math.sqrt(2*(i-r.re)):Math.abs(r.im)/Math.sqrt(2*(i+r.re)),r.im>=0?new e.Complex(t,n):new e.Complex(t,-n)}var s=n(t(2)),u=i("sqrt",{number:a,Complex:o,BigNumber:function(e){return e.isNegative()?a(e.toNumber()):e.sqrt()},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}r.name="sqrt",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("square",{number:function(e){return e*e},Complex:function(e){return new e.constructor(e.re*e.re-e.im*e.im,e.re*e.im+e.im*e.re)},BigNumber:function(e){return e.times(e)},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="square",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(40)),s=n(t(192)),u=n(t(80)),c=n(t(193)),f=a("subtract",{"number, number":function(e,r){return e-r},"Complex, Complex":function(r,t){return new e.Complex(r.re-t.re,r.im-t.im)},"BigNumber, BigNumber":function(e,r){return e.minus(r)},"Unit, Unit":function(e,r){if(null==e.value)throw new Error("Parameter x contains a unit with undefined value");if(null==r.value)throw new Error("Parameter y contains a unit with undefined value");if(!e.equalBase(r))throw new Error("Units do not match");var t=e.clone();return t.value-=r.value,t.fixPrefix=!1,t},"Matrix, Matrix":function(e,r){var t=e.size(),n=r.size();if(t.length!==n.length)throw new i(t.length,n.length);var a;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":a=c.algorithm5(e,r,f);break;default:a=c.algorithm3(r,e,f,!0)}break;default:switch(r.storage()){case"sparse":a=c.algorithm1(e,r,f,!1);break;default:a=c.algorithm12(e,r,f)}}return a},"Array, Array":function(e,r){return f(o(e),o(r)).valueOf()},"Array, Matrix":function(e,r){return f(o(e),r)},"Matrix, Array":function(e,r){return f(e,o(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=c.algorithm9(e,u(r),s);break;default:t=c.algorithm13(e,r,f)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=c.algorithm9(r,e,f,!0);break;default:t=c.algorithm13(r,e,f,!0)}return t},"Array, any":function(e,r){return c.algorithm13(o(e),r,f,!1).valueOf()},"any, Array":function(e,r){return c.algorithm13(o(r),e,f,!0).valueOf()}});return f}var i=t(39);r.name="subtract",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("unaryMinus",{number:function(e){return-e},Complex:function(e){return new e.constructor(-e.re,-e.im)},BigNumber:function(e){return e.neg()},Unit:function(e){var r=e.clone();return r.value=-e.value,r},"Array | Matrix":function(e){return a.deepMap(e,o,!0)}});return o}r.name="unaryMinus",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("unaryPlus",{number:function(e){return e},Complex:function(e){return e.clone()},BigNumber:function(e){return e},Unit:function(e){return e.clone()},"Array | Matrix":function(e){return a.deepMap(e,o,!0)},"boolean | string | null":function(t){return"bignumber"==r.number?new e.BigNumber(+t):+t}});return o}r.name="unaryPlus",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e,t){var n,a,o,s=0,c=1,f=1,l=0;if(!i(e)||!i(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)a=Math.floor(e/t),o=e%t,n=s,s=c-a*s,c=n,n=f,f=l-a*f,l=n,e=t,t=o;var p;return p=0>e?[-e,-c,-l]:[e,e?c:0,l],"array"===r.matrix?p:u(p)}function s(t,n){var i,a,o,s=new e.BigNumber(0),c=new e.BigNumber(0),f=new e.BigNumber(1),l=new e.BigNumber(1),p=new e.BigNumber(0);if(!t.isInt()||!n.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!n.isZero();)a=t.div(n).floor(),o=t.mod(n),i=c,c=f.minus(a.times(c)),f=i,i=l,l=p.minus(a.times(l)),p=i,t=n,n=o;var m;return m=t.lt(s)?[t.neg(),f.neg(),p.neg()]:[t,t.isZero()?0:f,p],"array"===r.matrix?m:u(m)}var u=(n(t(2)),n(t(40)));return a("xgcd",{"number, number":o,"BigNumber, BigNumber":s})}var i=t(41).isInteger;r.name="xgcd",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=n(t(193)),c=o("bitAnd",{"number, number":function(e,r){if(!i(e)||!i(r))throw new Error("Integers expected in function bitAnd");return e&r},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm6(e,r,c,!1);break;default:t=u.algorithm2(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm2(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return c(s(e),r)},"Matrix, Array":function(e,r){return c(e,s(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=u.algorithm10(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=u.algorithm10(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, any":function(e,r){return u.algorithm13(s(e),r,c,!1).valueOf()},"any, Array":function(e,r){return u.algorithm13(s(r),e,c,!0).valueOf()}});return c}var i=t(41).isInteger,a=t(48).and;r.name="bitAnd",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("bitNot",{number:function(e){if(!i(e))throw new Error("Integer expected in function bitNot");return~e},BigNumber:a,"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}var i=t(41).isInteger,a=t(48).not;r.name="bitNot",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=n(t(193)),c=o("bitOr",{"number, number":function(e,r){if(!i(e)||!i(r))throw new Error("Integers expected in function bitOr");return e|r},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm4(e,r,c);break;default:t=u.algorithm1(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm1(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return c(s(e),r)},"Matrix, Array":function(e,r){return c(e,s(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=u.algorithm9(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=u.algorithm9(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, any":function(e,r){return u.algorithm13(s(e),r,c,!1).valueOf()},"any, Array":function(e,r){return u.algorithm13(s(r),e,c,!0).valueOf()}});return c}var i=t(41).isInteger,a=t(48).or;r.name="bitOr",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=n(t(193)),c=o("bitXor",{"number, number":function(e,r){if(!i(e)||!i(r))throw new Error("Integers expected in function bitXor");return e^r},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm7(e,r,c);break;default:t=u.algorithm3(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm3(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return c(s(e),r)},"Matrix, Array":function(e,r){return c(e,s(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=u.algorithm11(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=u.algorithm11(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, any":function(e,r){return u.algorithm13(s(e),r,c,!1).valueOf()},"any, Array":function(e,r){return u.algorithm13(s(r),e,c,!0).valueOf()}});return c}var i=t(41).isInteger,a=t(48).xor;r.name="bitXor",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=n(t(46)),c=n(t(118)),f=n(t(193)),l=o("leftShift",{"number, number":function(e,r){if(!i(e)||!i(r))throw new Error("Integers expected in function leftShift");return e<>r},"BigNumber, BigNumber":a,"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=f.algorithm8(e,r,l,!1);break;default:t=f.algorithm2(r,e,l,!0)}break;default:switch(r.storage()){case"sparse":t=f.algorithm1(e,r,l,!1);break;default:t=f.algorithm12(e,r,l)}}return t},"Array, Array":function(e,r){return l(s(e),s(r)).valueOf()},"Array, Matrix":function(e,r){return l(s(e),r)},"Matrix, Array":function(e,r){return l(e,s(r))},"Matrix, number | BigNumber":function(e,r){if(!u(r,0)){var t;switch(e.storage()){case"sparse":t=f.algorithm10(e,r,l,!1);break;default:t=f.algorithm13(e,r,l,!1)}return t}return e.clone()},"number | BigNumber, Matrix":function(e,r){if(!u(e,0)){var t;switch(r.storage()){case"sparse":t=f.algorithm9(r,e,l,!0);break;default:t=f.algorithm13(r,e,l,!0)}return t}return c(r.size(),r.storage())},"Array, number | BigNumber":function(e,r){return l(s(e),r).valueOf()},"number | BigNumber, Array":function(e,r){return l(e,s(r)).valueOf()}});return l}var i=t(41).isInteger,a=t(48).rightArithShift;r.name="rightArithShift",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(40)),s=n(t(46)),u=n(t(118)),c=n(t(193)),f=a("rightLogShift",{"number, number":function(e,r){if(!i(e)||!i(r))throw new Error("Integers expected in function rightLogShift");return e>>>r},"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=c.algorithm8(e,r,f,!1);break;default:t=c.algorithm2(r,e,f,!0); + +}break;default:switch(r.storage()){case"sparse":t=c.algorithm1(e,r,f,!1);break;default:t=c.algorithm12(e,r,f)}}return t},"Array, Array":function(e,r){return f(o(e),o(r)).valueOf()},"Array, Matrix":function(e,r){return f(o(e),r)},"Matrix, Array":function(e,r){return f(e,o(r))},"Matrix, number | BigNumber":function(e,r){if(!s(r,0)){var t;switch(e.storage()){case"sparse":t=c.algorithm10(e,r,f,!1);break;default:t=c.algorithm13(e,r,f,!1)}return t}return e.clone()},"number | BigNumber, Matrix":function(e,r){if(!s(e,0)){var t;switch(r.storage()){case"sparse":t=c.algorithm9(r,e,f,!0);break;default:t=c.algorithm13(r,e,f,!0)}return t}return u(r.size(),r.storage())},"Array, number | BigNumber":function(e,r){return f(o(e),r).valueOf()},"number | BigNumber, Array":function(e,r){return f(e,o(r)).valueOf()}});return f}var i=t(41).isInteger;r.name="rightLogShift",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("arg",{number:function(e){return Math.atan2(0,e)},Complex:function(e){return Math.atan2(e.im,e.re)},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="arg",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("conj",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return new e.constructor(e.re,-e.im)},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="conj",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("im",{number:function(e){return 0},BigNumber:function(e){return new e.constructor(0)},Complex:function(e){return e.im},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="im",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("re",{number:function(e){return e},BigNumber:function(e){return e},Complex:function(e){return e.re},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="re",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(118)),s=n(t(95)),u=n(t(193)),c=i("and",{"number, number":function(e,r){return!(!e||!r)},"Complex, Complex":function(e,r){return!(0===e.re&&0===e.im||0===r.re&&0===r.im)},"BigNumber, BigNumber":function(e,r){return!(e.isZero()||r.isZero()||e.isNaN()||r.isNaN())},"Unit, Unit":function(e,r){return 0!==e.value&&null!==e.value&&0!==r.value&&null!==r.value},"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=u.algorithm6(e,r,c,!1);break;default:t=u.algorithm2(r,e,c,!0)}break;default:switch(r.storage()){case"sparse":t=u.algorithm2(e,r,c,!1);break;default:t=u.algorithm12(e,r,c)}}return t},"Array, Array":function(e,r){return c(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return c(a(e),r)},"Matrix, Array":function(e,r){return c(e,a(r))},"Matrix, any":function(e,r){if(s(r))return o(e.size(),e.storage());var t;switch(e.storage()){case"sparse":t=u.algorithm10(e,r,c,!1);break;default:t=u.algorithm13(e,r,c,!1)}return t},"any, Matrix":function(e,r){if(s(e))return o(e.size(),e.storage());var t;switch(r.storage()){case"sparse":t=u.algorithm10(r,e,c,!0);break;default:t=u.algorithm13(r,e,c,!0)}return t},"Array, any":function(e,r){return c(a(e),r).valueOf()},"any, Array":function(e,r){return c(e,a(r)).valueOf()}});return c}r.name="and",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("not",{number:function(e){return!e},Complex:function(e){return 0===e.re&&0===e.im},BigNumber:function(e){return e.isZero()||e.isNaN()},Unit:function(e){return null===e.value||0==e.value},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="not",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(193)),s=i("or",{"number, number":function(e,r){return!(!e&&!r)},"Complex, Complex":function(e,r){return 0!==e.re||0!==e.im||0!==r.re||0!==r.im},"BigNumber, BigNumber":function(e,r){return!e.isZero()&&!e.isNaN()||!r.isZero()&&!r.isNaN()},"Unit, Unit":function(e,r){return 0!==e.value&&null!==e.value||0!==r.value&&null!==r.value},"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=o.algorithm5(e,r,s);break;default:t=o.algorithm3(r,e,s,!0)}break;default:switch(r.storage()){case"sparse":t=o.algorithm3(e,r,s,!1);break;default:t=o.algorithm12(e,r,s)}}return t},"Array, Array":function(e,r){return s(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return s(a(e),r)},"Matrix, Array":function(e,r){return s(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=o.algorithm11(e,r,s,!1);break;default:t=o.algorithm13(e,r,s,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=o.algorithm11(r,e,s,!0);break;default:t=o.algorithm13(r,e,s,!0)}return t},"Array, any":function(e,r){return o.algorithm13(a(e),r,s,!1).valueOf()},"any, Array":function(e,r){return o.algorithm13(a(r),e,s,!0).valueOf()}});return s}r.name="or",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(193)),s=i("xor",{"number, number":function(e,r){return!!(!!e^!!r)},"Complex, Complex":function(e,r){return!!((0!==e.re||0!==e.im)^(0!==r.re||0!==r.im))},"BigNumber, BigNumber":function(e,r){return!!((!e.isZero()&&!e.isNaN())^(!r.isZero()&&!r.isNaN()))},"Unit, Unit":function(e,r){return!!((0!==e.value&&null!==e.value)^(0!==r.value&&null!==r.value))},"Matrix, Matrix":function(e,r){var t;switch(e.storage()){case"sparse":switch(r.storage()){case"sparse":t=o.algorithm7(e,r,s);break;default:t=o.algorithm3(r,e,s,!0)}break;default:switch(r.storage()){case"sparse":t=o.algorithm3(e,r,s,!1);break;default:t=o.algorithm12(e,r,s)}}return t},"Array, Array":function(e,r){return s(a(e),a(r)).valueOf()},"Array, Matrix":function(e,r){return s(a(e),r)},"Matrix, Array":function(e,r){return s(e,a(r))},"Matrix, any":function(e,r){var t;switch(e.storage()){case"sparse":t=o.algorithm11(e,r,s,!1);break;default:t=o.algorithm13(e,r,s,!1)}return t},"any, Matrix":function(e,r){var t;switch(r.storage()){case"sparse":t=o.algorithm11(r,e,s,!0);break;default:t=o.algorithm13(r,e,s,!0)}return t},"Array, any":function(e,r){return o.algorithm13(a(e),r,s,!1).valueOf()},"any, Array":function(e,r){return o.algorithm13(a(r),e,s,!0).valueOf()}});return s}r.name="xor",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i,a){var o=n(t(2)),s=n(t(51));return i("compile",{string:function(e){return s(e).compile(a)},"Array | Matrix":function(e){return o.deepMap(e,function(e){return s(e).compile(a)})}})}r.math=!0,r.name="compile",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i,a){var o=n(t(2)),s=n(t(51));return i("compile",{string:function(e){var r={};return s(e).compile(a).eval(r)},"string, Object":function(e,r){return s(e).compile(a).eval(r)},"Array | Matrix":function(e){var r={};return o.deepMap(e,function(e){return s(e).compile(a).eval(r)})},"Array | Matrix, Object":function(e,r){return o.deepMap(e,function(e){return s(e).compile(a).eval(r)})}})}r.math=!0,r.name="eval",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i,a){var o=n(t(185));return i("help",{any:function(r){var t,n=r;if("string"!=typeof r)for(t in a)if(a.hasOwnProperty(t)&&r===a[t]){n=t;break}var i=o[n];if(!i)throw new Error('No documentation found on "'+n+'"');return new e.Help(i)}})}r.math=!0,r.name="help",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(51));return i("parse",{"string | Array | Matrix":a,"string | Array | Matrix, Object":a})}r.name="parse",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,f){var l=n(t(40));return f("concat",{"...Array | Matrix | number | BigNumber":function(r){var t,n,f=r.length,p=-1,m=!1,h=[];for(t=0;f>t;t++){var g=r[t];if(g instanceof e.Matrix&&(m=!0),"number"==typeof g||g instanceof e.BigNumber){if(t!==f-1)throw new Error("Dimension must be specified as last argument");if(n=p,p=g.valueOf(),!o(p))throw new TypeError("Integer number expected for dimension");if(0>p)throw new u(p);if(t>0&&p>n)throw new u(p,n+1)}else{var v=a(g).valueOf(),d=s.size(v);if(h[t]=v,n=p,p=d.length-1,t>0&&p!=n)throw new c(n+1,p+1)}}if(0==h.length)throw new SyntaxError("At least one matrix expected");for(var y=h.shift();h.length;)y=i(y,h.shift(),p,0);return m?l(y):y}})}function i(e,r,t,n){if(t>n){if(e.length!=r.length)throw new c(e.length,r.length);for(var a=[],o=0;ot;t++)n[r][t]=0;for(t=r+1;to;o++)i=l(n(i),e);return r%2==0?p(i[0][0]):i[0][0]}var u=(n(t(2)),n(t(40))),c=n(t(47)),f=n(t(79)),l=n(t(71)),p=n(t(80));return i("det",{any:function(e){return a.clone(e)},"Array | Matrix":function(r){var t;switch(r instanceof e.Matrix?t=r.size():r instanceof Array?(r=u(r),t=r.size()):t=[],t.length){case 0:return a.clone(r);case 1:if(1==t[0])return a.clone(r.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+o.format(t)+")");case 2:var n=t[0],i=t[1];if(n==i)return s(r.clone().valueOf(),n,i);throw new RangeError("Matrix must be square (size: "+o.format(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+o.format(t)+")")}}})}var i=t(36),a=i.object,o=i.string;r.name="det",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,s){function u(e,r,t,n){if(!o(r))throw new TypeError("Second parameter in function diag must be an integer");var i=r>0?r:0,a=0>r?-r:0;switch(t.length){case 1:return c(e,r,n,t[0],a,i);case 2:return f(e,r,n,t,a,i)}throw new RangeError("Matrix for function diag must be 2 dimensional")}function c(r,t,n,i,a,o){var s=[i+a,i+o],u=e.Matrix.storage(n||"dense"),c=u.diagonal(s,r,t);return null!==n?c:c.valueOf()}function f(r,t,n,i,o,s){if(r instanceof e.Matrix){var u=r.diagonal(t);return null!==n?n!==u.storage()?l(u,n):u:u.valueOf()}for(var c=Math.min(i[0]-o,i[1]-s),f=new Array(c),p=0;c>p;p++)f[p]=a(r[p+o][p+s]);return null!==n?l(f):f}var l=n(t(40));return s("diag",{Array:function(e){return u(e,0,i.size(e),null)},"Array, number":function(e,r){return u(e,r,i.size(e),null)},"Array, BigNumber":function(e,r){return u(e,r.toNumber(),i.size(e),null)},"Array, string":function(e,r){return u(e,0,i.size(e),r)},"Array, number, string":function(e,r,t){return u(e,r,i.size(e),t)},"Array, BigNumber, string":function(e,r,t){return u(e,r.toNumber(),i.size(e),t)},Matrix:function(e){return u(e,0,e.size(),e.storage())},"Matrix, number":function(e,r){return u(e,r,e.size(),e.storage())},"Matrix, BigNumber":function(e,r){return u(e,r.toNumber(),e.size(),e.storage())},"Matrix, string":function(e,r){return u(e,0,e.size(),r)},"Matrix, number, string":function(e,r,t){return u(e,r,e.size(),t)},"Matrix, BigNumber, string":function(e,r,t){return u(e,r.toNumber(),e.size(),t)}})}var i=t(37),a=t(33).clone,o=t(41).isInteger;r.name="diag",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e,r){var t=i(e),n=i(r),a=t[0];if(1!==t.length||1!==n.length)throw new RangeError("Vector expected");if(t[0]!=n[0])throw new RangeError("Vectors must have equal length ("+t[0]+" != "+n[0]+")");if(0==a)throw new RangeError("Cannot calculate the dot product of empty vectors");for(var o=0,c=0;a>c;c++)o=s(o,u(e[c],r[c]));return o}var s=n(t(47)),u=n(t(71));return a("dot",{"Matrix, Matrix":function(e,r){return o(e.toArray(),r.toArray())},"Matrix, Array":function(e,r){return o(e.toArray(),r)},"Array, Matrix":function(e,r){return o(e,r.toArray())},"Array, Array":o})}var i=t(37).size;r.name="dot",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(e,r){switch(e.length){case 0:return r?c(r):[];case 1:return u(e[0],e[0],r);case 2:return u(e[0],e[1],r);default:throw new Error("Vector containing two values expected")}}function u(r,t,n){var o=r instanceof e.BigNumber?r.constructor:t instanceof e.BigNumber?t.constructor:null;if(r instanceof e.BigNumber&&(r=r.toNumber()),t instanceof e.BigNumber&&(t=t.toNumber()),!a(r)||1>r)throw new Error("Parameters in function eye must be positive integers");if(!a(t)||1>t)throw new Error("Parameters in function eye must be positive integers");var s=o?new e.BigNumber(1):1,u=o?new o(0):0,c=[r,t];if(n){var f=e.Matrix.storage(n);return f.diagonal(c,s,0,u)}for(var l=i.resize([],c,u),p=t>r?r:t,m=0;p>m;m++)l[m][m]=s;return l}var c=n(t(40));return o("eye",{"":function(){return"matrix"===r.matrix?c([]):[]},string:function(e){return c(e)},"number | BigNumber":function(e){return u(e,e,"matrix"===r.matrix?"default":void 0)},"number | BigNumber, string":function(e,r){return u(e,e,r)},"number | BigNumber, number | BigNumber":function(e,t){return u(e,t,"matrix"===r.matrix?"default":void 0)},"number | BigNumber, number | BigNumber, string":function(e,r,t){return u(e,r,t)},Array:function(e){return s(e)},"Array, string":function(e,r){return s(e,r)},Matrix:function(e){return s(e.valueOf(),e.storage())},"Matrix, string":function(e,r){return s(e.valueOf(),r)}})}var i=t(37),a=t(41).isInteger;r.name="eye",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40));return o("flatten",{Array:function(e){return a(i(e))},Matrix:function(e){var r=a(i(e.toArray()));return s(r)}})}var i=t(33).clone,a=t(37).flatten;r.name="flatten",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e,r,t){var n,i,a,o,s;if(1==r){if(o=e[0][0],0==o)throw Error("Cannot calculate inverse, determinant is zero");return[[u(1,o)]]}if(2==r){var h=p(e);if(0==h)throw Error("Cannot calculate inverse, determinant is zero");return[[u(e[1][1],h),u(l(e[0][1]),h)],[u(l(e[1][0]),h),u(e[0][0],h)]]}var g=e.concat();for(n=0;r>n;n++)g[n]=g[n].concat();for(var v=m(r).valueOf(),d=0;t>d;d++){for(n=d;r>n&&0==g[n][d];)n++;if(n==r||0==g[n][d])throw Error("Cannot calculate inverse, determinant is zero");n!=d&&(s=g[d],g[d]=g[n],g[n]=s,s=v[d],v[d]=v[n],v[n]=s);var y=g[d],x=v[d];for(n=0;r>n;n++){var w=g[n],b=v[n];if(n!=d){if(0!=w[d]){for(a=u(l(w[d]),y[d]),i=d;t>i;i++)w[i]=c(w[i],f(a,y[i]));for(i=0;t>i;i++)b[i]=c(b[i],f(a,x[i]))}}else{for(a=y[d],i=d;t>i;i++)w[i]=u(w[i],a);for(i=0;t>i;i++)b[i]=u(b[i],a)}}}return v}var s=(n(t(2)),n(t(40))),u=n(t(207)),c=n(t(47)),f=n(t(71)),l=n(t(80)),p=n(t(104)),m=n(t(107)),h=a("inv",{"Array | Matrix":function(r){var t=r instanceof e.Matrix?r.size():i.array.size(r);switch(t.length){case 1:if(1==t[0])return r instanceof e.Matrix?s([u(1,r.valueOf()[0])]):[u(1,r[0])];throw new RangeError("Matrix must be square (size: "+i.string.format(t)+")");case 2:var n=t[0],a=t[1];if(n==a)return r instanceof e.Matrix?s(o(r.valueOf(),n,a),r.storage()):o(r,n,a);throw new RangeError("Matrix must be square (size: "+i.string.format(t)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+i.string.format(t)+")")}},any:function(e){return u(1,e)}});return h}var i=t(36);r.name="inv",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(r,t){var n=u(r),i=n?new e.BigNumber(1):1;if(c(r),t){var o=f(t);return r.length>0?o.resize(r,i):o}var s=[];return r.length>0?a(s,r,i):s}function u(r){var t=!1;return r.forEach(function(r,n,i){r instanceof e.BigNumber&&(t=!0,i[n]=r.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||0>e)throw new Error("Parameters in function ones must be positive integers")})}var f=n(t(40));return o("ones",{"":function(){return"array"===r.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var t=e[e.length-1];if("string"==typeof t){var n=e.pop();return s(e,n)}return"array"===r.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var r=e.storage();return s(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return s(e.valueOf(),r)}})}var i=t(41).isInteger,a=t(37).resize;r.name="ones",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e){return"array"===r.matrix?e:p(e)}function o(t,n){var i=l(t);if(!i)throw new SyntaxError('String "'+t+'" is no valid range');var o;return"bignumber"===r.number?(o=n?f:c,a(o(new e.BigNumber(i.start),new e.BigNumber(i.end),new e.BigNumber(i.step)))):(o=n?u:s,a(o(i.start,i.end,i.step)))}function s(e,r,t){var n=[],i=e;if(t>0)for(;r>i;)n.push(i),i+=t;else if(0>t)for(;i>r;)n.push(i),i+=t;return n}function u(e,r,t){var n=[],i=e;if(t>0)for(;r>=i;)n.push(i),i+=t;else if(0>t)for(;i>=r;)n.push(i),i+=t;return n}function c(e,r,t){var n=[],i=e;if(t.gt(m))for(;i.lt(r);)n.push(i),i=i.plus(t);else if(t.lt(m))for(;i.gt(r);)n.push(i),i=i.plus(t);return n}function f(e,r,t){var n=[],i=e;if(t.gt(m))for(;i.lte(r);)n.push(i),i=i.plus(t);else if(t.lt(m))for(;i.gte(r);)n.push(i),i=i.plus(t);return n}function l(e){var r=e.split(":"),t=r.map(function(e){return Number(e)}),n=t.some(function(e){return isNaN(e)});if(n)return null;switch(t.length){case 2:return{start:t[0],end:t[1],step:1};case 3:return{start:t[0],end:t[2],step:t[1]};default:return null}}var p=n(t(40)),m=new e.BigNumber(0),h=new e.BigNumber(1);return i("range",{string:o,"string, boolean":o,"number, number":function(e,r){return a(s(e,r,1))},"number, number, number":function(e,r,t){return a(s(e,r,t))},"number, number, boolean":function(e,r,t){return a(t?u(e,r,1):s(e,r,1))},"number, number, number, boolean":function(e,r,t,n){return a(n?u(e,r,t):s(e,r,t))},"BigNumber, BigNumber":function(e,r){return a(c(e,r,h))},"BigNumber, BigNumber, BigNumber":function(e,r,t){return a(c(e,r,t))},"BigNumber, BigNumber, boolean":function(e,r,t){return a(t?f(e,r,h):c(e,r,h))},"BigNumber, BigNumber, BigNumber, boolean":function(e,r,t,n){return a(n?f(e,r,t):c(e,r,t))}})}r.name="range",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,f){function l(e,r,t){if(void 0!==t){if("string"!=typeof t||1!==t.length)throw new TypeError("Single character expected as defaultValue")}else t=" ";if(1!==r.length)throw new i(r.length,1);var n=r[0];if("number"!=typeof n||!o(n))throw new TypeError("Invalid size, must contain positive integers (size: "+s(r)+")");if(e.length>n)return e.substring(0,n);if(e.lengthu;u++)a+=t;return a}return e}var p=n(t(40));return function(t,n,i){if(2!=arguments.length&&3!=arguments.length)throw new a("resize",arguments.length,2,3);if(n instanceof e.Matrix&&(n=n.valueOf()),n.length&&n[0]instanceof e.BigNumber&&(n=n.map(function(r){return r instanceof e.BigNumber?r.toNumber():r})),t instanceof e.Matrix)return t.resize(n,i,!0);if("string"==typeof t)return l(t,n,i);var o=Array.isArray(t)?!1:"array"!==r.matrix;if(0==n.length){for(;Array.isArray(t);)t=t[0];return u(t)}Array.isArray(t)||(t=[t]),t=u(t);var s=c.resize(t,n,i);return o?p(s):s}}var i=t(39),a=t(194),o=t(41).isInteger,s=t(42).format,u=t(33).clone,c=t(37);r.name="resize",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(40));return a("size",{Matrix:function(e){return o(e.size())},Array:i.size,string:function(e){return"array"===r.matrix?[e.length]:o([e.length])},"number | Complex | BigNumber | Unit | boolean | null":function(e){return"array"===r.matrix?[]:o([])}})}var i=t(37);r.name="size",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40));return o("squeeze",{Array:function(e){return a.squeeze(i.clone(e))},Matrix:function(e){var r=a.squeeze(e.toArray());return Array.isArray(r)?s(r):r},any:function(e){return i.clone(e)}})}var i=t(33),a=t(37);r.name="squeeze",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,s){function u(r,t){if(!(t instanceof e.Index))throw new TypeError("Index expected");if(1!=t.size().length)throw new o(t.size().length,1);var n=r.length;a(t.min()[0],n),a(t.max()[0],n);var i=t.range(0),s="";return i.forEach(function(e){s+=r.charAt(e)}),s}function c(r,t,n,i){if(!(t instanceof e.Index))throw new TypeError("Index expected");if(1!=t.size().length)throw new o(t.size().length,1);if(void 0!==i){if("string"!=typeof i||1!==i.length)throw new TypeError("Single character expected as defaultValue")}else i=" ";var s=t.range(0),u=s.size()[0];if(u!=n.length)throw new o(s.size()[0],n.length);var c=r.length;a(t.min()[0]),a(t.max()[0]);for(var f=[],l=0;c>l;l++)f[l]=r.charAt(l);if(s.forEach(function(e,r){f[e]=n.charAt(r)}),f.length>c)for(l=c-1,u=f.length;u>l;l++)f[l]||(f[l]=i);return f.join("")}var f=n(t(40));return s("subset",{"Array, Index":function(e,r){var t=f(e),n=t.subset(r);return n&&n.valueOf()},"Matrix, Index":function(e,r){return e.subset(r)},"string, Index":u,"Array, Index, any":function(e,r,t){return f(i(e)).subset(r,t,void 0).valueOf()},"Array, Index, any, any":function(e,r,t,n){return f(i(e)).subset(r,t,n).valueOf()},"Matrix, Index, any":function(e,r,t){return e.clone().subset(r,t)},"Matrix, Index, any, any":function(e,r,t,n){return e.clone().subset(r,t,n)},"string, Index, string":c,"string, Index, string, string":c})}var i=t(33).clone,a=t(37).validateIndex,o=t(39);r.name="subset",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=n(t(47)),c=o("trace",{Array:function(e){return c(s(e))},Matrix:function(e){var r;switch(e.storage()){case"dense":r=f(e);break;case"sparse":r=l(e)}return r},any:i}),f=function(e){var r=e._size,t=e._data;switch(r.length){case 1:if(1==r[0])return i(t[0]);throw new RangeError("Matrix must be square (size: "+a(r)+")");case 2:var n=r[0],o=r[1];if(n===o){for(var s=0,c=0;n>c;c++)s=u(s,t[c][c]);return s}throw new RangeError("Matrix must be square (size: "+a(r)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+a(r)+")")}},l=function(e){var r=e._values,t=e._index,n=e._ptr,i=e._size,o=i[0],s=i[1];if(o===s){var c=0;if(r.length>0)for(var f=0;s>f;f++)for(var l=n[f],p=n[f+1],m=l;p>m;m++){var h=t[m];if(h===f){c=u(c,r[m]);break}if(h>f)break}return c}throw new RangeError("Matrix must be square (size: "+a(i)+")")};return c}var i=t(33).clone,a=t(42).format;r.name="trace",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40)),u=e.DenseMatrix,c=e.SparseMatrix,f=o("transpose",{Array:function(e){return f(s(e)).valueOf()},Matrix:function(e){var r,t=e.size();switch(t.length){case 1:r=e.clone();break;case 2:var n=t[0],i=t[1];if(0===i)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+a(t)+")");switch(e.storage()){case"dense":r=l(e,n,i);break;case"sparse":r=p(e,n,i)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+a(this._size)+")")}return r},any:function(e){return i(e)}}),l=function(e,r,t){for(var n,a=e._data,o=[],s=0;t>s;s++){n=o[s]=[];for(var c=0;r>c;c++)n[c]=i(a[c][s])}return new u({data:o,size:[t,r],datatype:e._datatype})},p=function(e,r,t){for(var n=e._values,a=e._index,o=e._ptr,s=[],u=[],f=[],l=new Array(r),p=0;r>p;p++)l[p]=0;var m,h,g;for(m=0,h=a.length;h>m;m++)l[a[m]]++;for(var v=0,d=0;r>d;d++)f.push(v),v+=l[d],l[d]=f[d];for(f.push(v),g=0;t>g;g++)for(var y=o[g],x=o[g+1],w=y;x>w;w++){var b=l[a[w]]++;u[b]=g,s[b]=i(n[w])}return new c({values:s,index:u,ptr:f,size:[t,r],datatype:e._datatype})};return f}var i=t(33).clone,a=t(42).format;r.name="transpose",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(r,t){var n=u(r),i=n?new e.BigNumber(0):0;if(c(r),t){var o=f(t);return r.length>0?o.resize(r,i):o}var s=[];return r.length>0?a(s,r,i):s}function u(r){var t=!1;return r.forEach(function(r,n,i){r instanceof e.BigNumber&&(t=!0,i[n]=r.toNumber())}),t}function c(e){e.forEach(function(e){if("number"!=typeof e||!i(e)||0>e)throw new Error("Parameters in function zeros must be positive integers")})}var f=n(t(40));return o("zeros",{"":function(){return"array"===r.matrix?s([]):s([],"default")},"...number | BigNumber | string":function(e){var t=e[e.length-1];if("string"==typeof t){var n=e.pop();return s(e,n)}return"array"===r.matrix?s(e):s(e,"default")},Array:s,Matrix:function(e){var r=e.storage();return s(e.valueOf(),r)},"Array | Matrix, string":function(e,r){return s(e.valueOf(),r)}})}var i=t(41).isInteger,a=t(37).resize;r.name="zeros",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("bignumber",{"":function(){return new e.BigNumber(0)},number:function(r){return new e.BigNumber(r+"")},string:function(r){return new e.BigNumber(r)},BigNumber:function(e){return e},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="bignumber",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("bool",{"":function(){return!1},"boolean":function(e){return e},number:function(e){return!!e},BigNumber:function(e){return!e.isZero()},string:function(e){var r=e.toLowerCase();if("true"===r)return!0;if("false"===r)return!1;var t=Number(e);if(""!=e&&!isNaN(t))return!!t;throw new Error('Cannot convert "'+e+'" to a boolean')},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="boolean",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("chain",{"":function(){return new e.Chain},any:function(r){return new e.Chain(r)}})}r.name="chain",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("complex",{"":function(){return new e.Complex(0,0)},number:function(r){return new e.Complex(r,0)},"number, number":function(r,t){return new e.Complex(r,t)},"BigNumber, BigNumber":function(r,t){return new e.Complex(r.toNumber(),t.toNumber())},Complex:function(e){return e.clone()},string:function(r){var t=e.Complex.parse(r);if(t)return t;throw new SyntaxError('String "'+r+'" is no valid complex number')},Object:function(r){if("re"in r&&"im"in r)return new e.Complex(r.re,r.im);if("r"in r&&"phi"in r)return e.Complex.fromPolar(r.r,r.phi);throw new Error("Expected object with either properties re and im, or properties r and phi.")},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="complex",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("index",{"...number | BigNumber | Range | Array":function(r){var t=r.map(function(r){return r instanceof e.BigNumber?r.toNumber():Array.isArray(r)?r.map(function(r){return r instanceof e.BigNumber?r.toNumber():r}):r}),n=new e.Index;return e.Index.apply(n,t),n}})}r.name="index",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("number",{"":function(){return 0},number:function(e){return e},string:function(e){var r=Number(e);if(isNaN(r))throw new SyntaxError('String "'+e+'" is no valid number');return r},BigNumber:function(e){return e.toNumber()},Unit:function(e){throw new Error("Second argument with valueless unit expected")},"Unit, string | Unit":function(e,r){return e.toNumber(r)},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="number",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){var i=e.SparseMatrix;return n("sparse",{"":function(){return new i([])},string:function(e){return new i([],e)},"Array | Matrix":function(e){return new i(e)},"Array | Matrix, string":function(e,r){return new i(e,r)}})}r.name="sparse",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("string",{"":function(){return""},number:i.format,"null":function(e){return"null"},"boolean":function(e){return e+""},"Array | Matrix":function(e){return o.deepMap(e,s)},any:function(e){return String(e)}});return s}var i=t(41);r.name="string",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("unit",{Unit:function(e){return e.clone()},string:function(r){if(e.Unit.isValuelessUnit(r))return new e.Unit(null,r);var t=e.Unit.parse(r);if(t)return t;throw new SyntaxError('String "'+r+'" is no valid unit')},"number, string":function(r,t){return new e.Unit(r,t)},"BigNumber, string":function(r,t){return new e.Unit(r.toNumber(),t)},"Array | Matrix":function(e){return a.deepMap(e,o)}});return o}r.name="unit",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("combinations",{"number, number":function(e,r){var t,n,i;if(!a(e)||0>e)throw new TypeError("Positive integer value expected in function combinations");if(r>e)throw new TypeError("k must be less than or equal to n");for(t=Math.max(r,e-r),n=1,i=1;e-t>=i;i++)n=n*(t+i)/i;return n},"BigNumber, BigNumber":function(r,t){var n,a,o,s,u=new e.BigNumber(1);if(!i(r)||!i(t))throw new TypeError("Positive integer value expected in function combinations");if(t.gt(r))throw new TypeError("k must be less than n in function combinations");for(n=r.minus(t),t.lt(n)&&(n=t),a=u,o=u,s=r.minus(n);o.lte(s);o=o.plus(1))a=a.times(n.plus(o)).dividedBy(o);return a}})}function i(e){return e.isInteger()&&e.gte(0)}var a=t(41).isInteger;r.name="combinations",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=n(t(130)),u=a("factorial",{number:function(e){return e===Number.POSITIVE_INFINITY?Math.sqrt(2*Math.PI):s(e+1)},BigNumber:function(e){return e.isFinite()||e.isNegative()?s(e.plus(1)):i.tau(r.precision).sqrt()},"Array | Matrix":function(e){return o.deepMap(e,u)}});return u}var i=t(48);r.name="factorial",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,c){function f(t){var n,i,a,o=t.toNumber();if(op;++p)a[p]=i=i.times(n),n=n.plus(l);return a[o]=i.times(n),new e.BigNumber(a[o].toPrecision(r.precision))}var l=n(t(2)),p=n(t(71)),m=n(t(74)),h=c("gamma",{number:function(e){var r,t;if(i(e)){if(0>=e)return isFinite(e)?1/0:0/0;if(e>171)return 1/0;for(var n=e-2,s=e-1;n>1;)s*=n,n--;return 0==s&&(s=1),s}if(.5>e)return Math.PI/(Math.sin(Math.PI*e)*h(1-e));if(e>=171.35)return 1/0;if(e>85){var u=e*e,c=u*e,f=c*e,l=f*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*u)-139/(51840*c)-571/(2488320*f)+163879/(209018880*l)+5246819/(75246796800*l*e))}--e,t=o[0];for(var p=1;pe)throw new TypeError("Positive integer value expected in function permutations");if(!a(r)||0>r)throw new TypeError("Positive integer value expected in function permutations");if(r>e)throw new TypeError("second argument k must be less than or equal to first argument n");for(t=1,n=e-r+1;e>=n;n++)t*=n;return t},"BigNumber, BigNumber":function(r,t){var n,a;if(!i(r)||!i(t))throw new TypeError("Positive integer value expected in function permutations");if(t.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=new e.BigNumber(1),a=r.minus(t).plus(1);a.lte(r);a=a.plus(1))n=n.times(a);return n}})}function i(e){return e.isInteger()&&e.gte(0)}var a=t(41).isInteger;r.name="permutations",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(211));return a("uniform").pickRandom}r.name="pickRandom",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(211));return a("uniform").random}r.name="random",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(211));return a("uniform").randomInt}r.name="randomInt",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){return u(e,r)?e:r}function o(e){var r=void 0;if(s.deepForEach(e,function(e){(void 0===r||u(e,r))&&(r=e)}),void 0===r)throw new Error("Cannot calculate max of an empty array");return r}var s=n(t(2)),u=n(t(45));return i("max",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){return s.reduce(e,r.valueOf(),a)},"...":function(){return o(arguments)}})}r.name="max",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e,r){var t=u.reduce(e,r,c),n=Array.isArray(e)?i(e):e.size();return f(t,n[r])}function s(e){var r=0,t=0;if(u.deepForEach(e,function(e){r=c(r,e),t++}),0===t)throw new Error("Cannot calculate mean of an empty array");return f(r,t)}var u=n(t(2)),c=n(t(47)),f=n(t(59));return a("mean",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":o,"...":function(){return s(arguments)}})}var i=t(37).size;r.name="mean",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e){var r=i(e.valueOf());r.sort(c);var t=r.length;if(0==t)throw new Error("Cannot calculate median of an empty array");return t%2==0?p(r[t/2-1],r[t/2]):l(r[(t-1)/2])}var s=n(t(47)),u=n(t(59)),c=n(t(168)),f=a("median",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){throw new Error("median(A, dim) is not yet supported")},"...":function(){return o(Array.prototype.slice.call(arguments))}}),l=a("number | BigNumber | Unit",function(e){return e}),p=a("number | BigNumber | Unit, number | BigNumber | Unit",function(e,r){return u(s(e,r),2)});return f}var i=t(37).flatten;r.name="median",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){return u(e,r)?e:r}function o(e){var r=void 0;if(s.deepForEach(e,function(e){(void 0===r||u(e,r))&&(r=e)}),void 0===r)throw new Error("Cannot calculate min of an empty array");return r}var s=n(t(2)),u=n(t(44));return i("min",{"Array | Matrix":o,"Array | Matrix, number | BigNumber":function(e,r){return s.reduce(e,r.valueOf(),a)},"...":function(){return o(arguments)}})}r.name="min",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e){var r=void 0;if(o.deepForEach(e,function(e){r=void 0===r?e:s(r,e)}),void 0===r)throw new Error("Cannot calculate prod of an empty array");return r}var o=n(t(2)),s=n(t(71));return i("prod",{"Array | Matrix":a,"Array | Matrix, number | BigNumber":function(e,r){throw new Error("prod(A, dim) is not yet supported")},"...":function(){return a(arguments)}})}r.name="prod",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){if(0==e.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(s.apply(null,arguments))}var o=(n(t(2)),n(t(77))),s=n(t(142));return i("std",{"Array | Matrix":a,"Array | Matrix, string":a,"...":function(){return a(Array.prototype.slice.call(arguments))}})}r.name="std",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e){var r=void 0;if(o.deepForEach(e,function(e){r=void 0===r?e:s(r,e)}),void 0===r)throw new Error("Cannot calculate sum of an empty array");return r}var o=n(t(2)),s=n(t(47));return i("sum",{"Array | Matrix":function(e){return a(e)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(){return a(arguments)}})}r.name="sum",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r,t){var n=0,i=0;if(0==r.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(s.deepForEach(r,function(e){n=u(n,e),i++}),0===i)throw new Error("Cannot calculate var of an empty array");var a=l(n,i);switch(n=0,s.deepForEach(r,function(e){var r=c(e,a);n=u(n,f(r,r))}),t){case"uncorrected":return l(n,i);case"biased":return l(n,i+1);case"unbiased":var o=n instanceof e.BigNumber?new e.BigNumber(0):0;return 1==i?o:l(n,i-1);default:throw new Error('Unknown normalization "'+t+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}var s=n(t(2)),u=n(t(47)),c=n(t(79)),f=n(t(71)),l=n(t(59));return a("variance",{"Array | Matrix":function(e){return o(e,i)},"Array | Matrix, string":o,"...":function(){return o(arguments,i)}})}var i="unbiased";r.name="var",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){var t=new e.Complex(r.im*r.im-r.re*r.re+1,-2*r.re*r.im),n=u(t),i=new e.Complex(n.re-r.im,n.im+r.re),a=c(i);return new e.Complex(1.5707963267948966-a.im,a.re)}var s=n(t(2)),u=n(t(77)).signatures.Complex,c=n(t(68)).signatures.Complex,f=a("acos",{number:function(r){return r>=-1&&1>=r?Math.acos(r):o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,f)}});return f}var i=t(48).arccos_arcsec;r.name="acos",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e){var r,t=u(e);return t.im<=0?(r=t.re,t.re=-t.im,t.im=r):(r=t.im,t.im=-t.re,t.re=r),t}var s=n(t(2)),u=n(t(143)).signatures.Complex,c=a("acosh",{number:function(r){return r>=1?Math.log(Math.sqrt(r*r-1)+r):-1>=r?new e.Complex(Math.log(Math.sqrt(r*r-1)-r),Math.PI):o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!1,!1)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=t(48).acosh_asinh_asech_acsch;r.name="acosh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=n(t(153)).signatures.Complex,c=o("acot",{number:function(e){return e?Math.atan(1/e):a},Complex:function(r){if(0==r.im)return new e.Complex(r.re?Math.atan(1/r.re):a,0);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re=r.re/t,r.im=-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),u(r)},BigNumber:function(r){return i(r,e.BigNumber,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=t(48).arctan_arccot,a=1.5707963267948966;r.name="acot",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(r){if(0==r.re&&0==r.im)return new e.Complex(0,a);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re/t,-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),u(r)}var u=n(t(155)).signatures.Complex,c=n(t(2)),f=o("acoth",{number:function(r){return r>=1||-1>=r?isFinite(r)?(Math.log((r+1)/r)+Math.log(r/(r-1)))/2:0:0!==r?s(new e.Complex(r,0)):new e.Complex(0,a)},Complex:s,BigNumber:function(r){return i(r,e.BigNumber,!0)},"Array | Matrix":function(e){return c.deepMap(e,f)}});return f}var i=t(48).atanh_acoth,a=1.5707963267948966;r.name="acoth",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){function s(r){if(0==r.re&&0==r.im)return new e.Complex(a,1/0);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re=r.re/t,r.im=-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),c(r)}var u=n(t(2)),c=n(t(151)).signatures.Complex,f=o("acsc",{number:function(r){return-1>=r||r>=1?Math.asin(1/r):s(new e.Complex(r,0))},Complex:s,BigNumber:function(r){return i(r,e.BigNumber,!0)},"Array | Matrix":function(e){return u.deepMap(e,f)}});return f}var i=t(48).arcsin_arccsc,a=1.5707963267948966;r.name="acsc",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=n(t(152)).signatures.Complex,u=a("acsch",{number:function(e){return e=1/e,Math.log(e+Math.sqrt(e*e+1))},Complex:function(r){if(0==r.im)return r=0!=r.re?Math.log(r.re+Math.sqrt(r.re*r.re+1)):1/0,new e.Complex(r,0);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re/t,-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),s(r)},BigNumber:function(r){return i(r,e.BigNumber,!0,!0)},"Array | Matrix":function(e){return o.deepMap(e,u)}});return u}var i=t(48).acosh_asinh_asech_acsch;r.name="acsch",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){if(0==r.re&&0==r.im)return new e.Complex(0,1/0);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re=r.re/t,r.im=-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),u(r)}var s=n(t(2)),u=n(t(143)).signatures.Complex,c=a("asec",{number:function(r){return-1>=r||r>=1?Math.acos(1/r):o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=t(48).arccos_arcsec;r.name="asec",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){if(0==r.re&&0==r.im)return new e.Complex(1/0,0);var t=r.re*r.re+r.im*r.im;return r=0!=t?new e.Complex(r.re/t,-r.im/t):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?-(r.im/0):0),u(r)}var s=n(t(2)),u=n(t(144)).signatures.Complex,c=a("asech",{number:function(r){if(1>=r&&r>=-1){r=1/r;var t=Math.sqrt(r*r-1);return r>0?Math.log(t+r):new e.Complex(Math.log(t-r),Math.PI)}return o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!1,!0)},"Array | Matrix":function(e){return s.deepMap(e,c)}});return c}var i=t(48).acosh_asinh_asech_acsch;r.name="asech",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){var t=r.re,n=r.im,i=new e.Complex(n*n-t*t+1,-2*t*n),a=u(i),o=new e.Complex(a.re-n,a.im+t),s=c(o);return new e.Complex(s.im,-s.re)}var s=n(t(2)),u=n(t(77)).signatures.Complex,c=n(t(68)).signatures.Complex,f=a("asin",{number:function(r){return r>=-1&&1>=r?Math.asin(r):o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,f,!0)}});return f}var i=t(48).arcsin_arccsc;r.name="asin",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=n(t(151)).signatures.Complex,u=a("asinh",{number:function(e){return Math.log(Math.sqrt(e*e+1)+e)},Complex:function(e){var r=e.im;e.im=-e.re,e.re=r;var t=s(e);return e.re=-e.im,e.im=r,r=t.re,t.re=-t.im,t.im=r,t},BigNumber:function(r){return i(r,e.BigNumber,!0,!1)},"Array | Matrix":function(e){return o.deepMap(e,u,!0)}});return u}var i=t(48).acosh_asinh_asech_acsch;r.name="asinh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=n(t(68)).signatures.Complex,u=a("atan",{number:function(e){return Math.atan(e)},Complex:function(r){if(0==r.re){if(1==r.im)return new e.Complex(0,1/0);if(-1==r.im)return new e.Complex(0,-(1/0))}var t=r.re,n=r.im,i=t*t+(1-n)*(1-n),a=new e.Complex((1-n*n-t*t)/i,-2*t/i),o=s(a);return new e.Complex(-.5*o.im,.5*o.re)},BigNumber:function(r){return i(r,e.BigNumber,!1)},"Array | Matrix":function(e){return o.deepMap(e,u,!0)}});return u}var i=t(48).arctan_arccot;r.name="atan",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(r,t){return i(r,t,e.BigNumber)},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(48).arctan2;r.name="atan2",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){var t=r.re>1&&0==r.im,n=1-r.re,i=1+r.re,a=n*n+r.im*r.im;r=0!=a?new e.Complex((i*n-r.im*r.im)/a,(r.im*n+i*r.im)/a):new e.Complex(-1!=r.re?r.re/0:0,0!=r.im?r.im/0:0);var o=r.re;return r.re=Math.log(Math.sqrt(r.re*r.re+r.im*r.im))/2,r.im=Math.atan2(r.im,o)/2,t&&(r.im=-r.im),r}var s=n(t(2)),u=a("atanh",{number:function(r){return 1>=r&&r>=-1?Math.log((1+r)/(1-r))/2:o(new e.Complex(r,0))},Complex:o,BigNumber:function(r){return i(r,e.BigNumber,!1)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}var i=t(48).atanh_acoth;r.name="atanh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=n(t(157)).signatures.number,u=n(t(165)).signatures.number,c=a("cos",{number:Math.cos,Complex:function(r){return new e.Complex(Math.cos(r.re)*s(-r.im),Math.sin(r.re)*u(-r.im))},BigNumber:function(r){return i(r,e.BigNumber,0,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return Math.cos(r.value)},"Array | Matrix":function(e){return o.deepMap(e,c)}});return c}var i=t(48).cos_sin_sec_csc;r.name="cos",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("cosh",{number:i,Complex:function(r){var t=Math.exp(r.re),n=Math.exp(-r.re);return new e.Complex(Math.cos(r.im)*(t+n)/2,Math.sin(r.im)*(t-n)/2)},BigNumber:function(r){return a(r,e.BigNumber,!1,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return(Math.exp(e)+Math.exp(-e))/2}var a=t(48).cosh_sinh_csch_sech;r.name="cosh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("cot",{number:function(e){return 1/Math.tan(e)},Complex:function(r){var t=Math.exp(-4*r.im)-2*Math.exp(-2*r.im)*Math.cos(2*r.re)+1;return new e.Complex(2*Math.exp(-2*r.im)*Math.sin(2*r.re)/t,(Math.exp(-4*r.im)-1)/t)},BigNumber:function(r){return i(r,e.BigNumber,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return 1/Math.tan(r.value)},"Array | Matrix":function(e){return o.deepMap(e,s)}});return s}var i=t(48).tan_cot;r.name="cot",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("coth",{number:i,Complex:function(r){var t=Math.exp(2*r.re),n=t*Math.cos(2*r.im),i=t*Math.sin(2*r.im),a=(n-1)*(n-1)+i*i;return new e.Complex(((n+1)*(n-1)+i*i)/a,-2*i/a)},BigNumber:function(r){return a(r,e.BigNumber,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){var r=Math.exp(2*e);return(r+1)/(r-1)}var a=t(48).tanh_coth;r.name="coth",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("csc",{number:function(e){return 1/Math.sin(e)},Complex:function(r){var t=.25*(Math.exp(-2*r.im)+Math.exp(2*r.im))-.5*Math.cos(2*r.re);return new e.Complex(.5*Math.sin(r.re)*(Math.exp(-r.im)+Math.exp(r.im))/t,.5*Math.cos(r.re)*(Math.exp(-r.im)-Math.exp(r.im))/t)},BigNumber:function(r){return i(r,e.BigNumber,1,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return 1/Math.sin(r.value)},"Array | Matrix":function(e){return o.deepMap(e,s)}});return s}var i=t(48).cos_sin_sec_csc;r.name="csc",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("csch",{number:i,Complex:function(r){var t=Math.exp(r.re),n=Math.exp(-r.re),i=Math.cos(r.im)*(t-n),a=Math.sin(r.im)*(t+n),o=i*i+a*a;return new e.Complex(2*i/o,-2*a/o)},BigNumber:function(r){return a(r,e.BigNumber,!0,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return 0==e?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(e)-Math.exp(-e)))*o(e)}var a=t(48).cosh_sinh_csch_sech,o=t(41).sign;r.name="csch",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("sec",{number:function(e){return 1/Math.cos(e)},Complex:function(r){var t=.25*(Math.exp(-2*r.im)+Math.exp(2*r.im))+.5*Math.cos(2*r.re);return new e.Complex(.5*Math.cos(r.re)*(Math.exp(-r.im)+Math.exp(r.im))/t,.5*Math.sin(r.re)*(Math.exp(r.im)-Math.exp(-r.im))/t)},BigNumber:function(r){return i(r,e.BigNumber,0,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return 1/Math.cos(r.value)},"Array | Matrix":function(e){return o.deepMap(e,s)}});return s}var i=t(48).cos_sin_sec_csc;r.name="sec",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("sech",{number:i,Complex:function(r){var t=Math.exp(r.re),n=Math.exp(-r.re),i=Math.cos(r.im)*(t+n),a=Math.sin(r.im)*(t-n),o=i*i+a*a;return new e.Complex(2*i/o,-2*a/o)},BigNumber:function(r){return a(r,e.BigNumber,!1,!0)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u)}});return u}function i(e){return 2/(Math.exp(e)+Math.exp(-e))}var a=t(48).cosh_sinh_csch_sech;r.name="sech",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(157)).signatures.number,s=n(t(165)).signatures.number,u=n(t(2)),c=a("sin",{number:Math.sin,Complex:function(r){return new e.Complex(Math.sin(r.re)*o(-r.im),Math.cos(r.re)*s(r.im))},BigNumber:function(r){return i(r,e.BigNumber,1,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return Math.sin(r.value)},"Array | Matrix":function(e){return u.deepMap(e,c,!0)}});return c}var i=t(48).cos_sin_sec_csc;r.name="sin",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("sinh",{number:i,Complex:function(r){var t=Math.cos(r.im),n=Math.sin(r.im),i=Math.exp(r.re),a=Math.exp(-r.re);return new e.Complex(t*(i-a)/2,n*(i+a)/2)},BigNumber:function(r){return a(r,e.BigNumber,!0,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}function i(e){return Math.abs(e)<1?e+e*e*e/6+e*e*e*e*e/120:(Math.exp(e)-Math.exp(-e))/2}var a=t(48).cosh_sinh_csch_sech;r.name="sinh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("tan",{number:Math.tan,Complex:function(r){var t=Math.exp(-4*r.im)+2*Math.exp(-2*r.im)*Math.cos(2*r.re)+1;return new e.Complex(2*Math.exp(-2*r.im)*Math.sin(2*r.re)/t,(1-Math.exp(-4*r.im))/t)},BigNumber:function(r){return i(r,e.BigNumber,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return Math.tan(r.value)},"Array | Matrix":function(e){return o.deepMap(e,s,!0)}});return s}var i=t(48).tan_cot;r.name="tan",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(2)),u=o("tanh",{number:i,Complex:function(r){var t=Math.exp(2*r.re),n=t*Math.cos(2*r.im),i=t*Math.sin(2*r.im),a=(n+1)*(n+1)+i*i;return new e.Complex(((n-1)*(n+1)+i*i)/a,2*i/a)},BigNumber:function(r){return a(r,e.BigNumber,!1)},Unit:function(r){if(!r.hasBase(e.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return i(r.value)},"Array | Matrix":function(e){return s.deepMap(e,u,!0)}});return u}function i(e){var r=Math.exp(2*e);return(r-1)/(r+1)}var a=t(48).tanh_coth;r.name="tanh",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("compare",{"boolean, boolean":function(e,r){return e===r?0:e>r?1:-1},"number, number":function(e,t){return e===t||i(e,t,r.epsilon)?0:e>t?1:-1},"BigNumber, BigNumber":function(e,r){return new e.constructor(e.cmp(r))},"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value===t.value||i(e.value,t.value,r.epsilon)?0:e.value>t.value?1:-1},"string, string":function(e,r){return e===r?0:e>r?1:-1},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(41).nearlyEqual;r.name="compare",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){if(Array.isArray(e)){if(Array.isArray(r)){var t=e.length;if(t!==r.length)return!1;for(var n=0;t>n;n++)if(!a(e[n],r[n]))return!1;return!0}return!1}return Array.isArray(r)?!1:o(e,r)}var o=(n(t(2)),n(t(46)));return i("deepEqual",{"any, any":function(e,r){return a(e.valueOf(),r.valueOf())}})}r.name="deepEqual",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("largerEq",{"boolean, boolean":function(e,r){return e>=r},"number, number":function(e,t){return e>=t||i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return e.gte(r)},"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value>=t.value||i(e.value,t.value,r.epsilon)},"string, string":function(e,r){return e>=r},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(41).nearlyEqual;r.name="largerEq",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("smallerEq",{"boolean, boolean":function(e,r){return r>=e},"number, number":function(e,t){return t>=e||i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return e.lte(r)},"Complex, Complex":function(e,r){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return e.value<=t.value||i(e.value,t.value,r.epsilon)},"string, string":function(e,r){return r>=e},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,s)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,s)}});return s}var i=t(41).nearlyEqual;r.name="smallerEq",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(2)),s=a("unequal",{"any, any":function(e,r){return null===e?null!==r:null===r?null!==e:void 0===e?void 0!==r:void 0===r?void 0!==e:u(e,r)},"Array | Matrix, any":function(e,r){return o.deepMap2(e,r,u)},"any, Array | Matrix":function(e,r){return o.deepMap2(e,r,u)}}),u=a("_unequal",{"boolean, boolean":function(e,r){return e!==r},"number, number":function(e,t){return!i(e,t,r.epsilon)},"BigNumber, BigNumber":function(e,r){return!e.eq(r)},"Complex, Complex":function(e,t){return!i(e.re,t.re,r.epsilon)||!i(e.im,t.im,r.epsilon)},"Unit, Unit":function(e,t){if(!e.equalBase(t))throw new Error("Cannot compare units with different base");return!i(e.value,t.value,r.epsilon)},"string, string":function(e,r){return e!==r}});return s}var i=t(41).nearlyEqual;r.name="unequal",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(2)),o=i("to",{"Unit, Unit | string":function(e,r){return e.to(r)},"Array | Matrix, any":function(e,r){return a.deepMap2(e,r,o)},"any, Array | Matrix":function(e,r){return a.deepMap2(e,r,o)}});return o}r.name="to",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("clone",{any:i.clone})}var i=t(33);r.name="clone",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a,o){return function(s){return s&&(i.deepExtend(r,s),s.precision&&e.BigNumber&&e.BigNumber.config({precision:s.precision}),t(15).factory(e,r,n,a,o)),i.clone(r)}}var i=t(33);r.name="config",r.math=!0,r.factory=n},function(e,r,t){"use strict";function n(e,r,n,o){var s=n(t(40));return o("filter",{"Array, function":i,"Array, RegExp":a,"Matrix, function":function(e,r){return s(i(e.toArray(),r))},"Matrix, RegExp":function(e,r){return s(a(e.toArray(),r))}})}function i(e,r){if(1!==o(e).length)throw new Error("Only one dimensional matrices supported");return e.filter(function(e){return r(e)})}function a(e,r){if(1!==o(e).length)throw new Error("Only one dimensional matrices supported");return e.filter(function(e){return r.test(e)})}var o=t(37).size;r.name="filter",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("format",{any:i.format,"any, Object | function | number":i.format})}var i=t(42);r.name="format",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("map",{"Array, function":i,"Matrix, function":function(e,r){return e.map(r)}})}function i(e,r){var t=function(n,i){return Array.isArray(n)?n.map(function(e,r){return t(e,i.concat(r))}):r(n,i,e)};return t(e,[])}r.name="map",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("print",{"string, Object":i,"string, Object, number":i})}function i(e,r,t){return e.replace(/\$([\w\.]+)/g,function(e,n){for(var i=n.split("."),s=r[i.shift()];i.length&&void 0!==s;){var u=i.shift();s=u?s[u]:s+"."}return void 0!==s?a(s)?s:o(s,t):e})}var a=t(42).isString,o=t(42).format;r.name="print",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e){if("asc"===e)return f;if("desc"===e)return l;throw new Error('String "asc" or "desc" expected')}function s(e){if(1!==i(e).length)throw new Error("One dimensional array expected")}function u(e){if(1!==e.size().length)throw new Error("One dimensional matrix expected")}var c=n(t(40)),f=n(t(168)),l=function(e,r){return-f(e,r)};return a("sort",{Array:function(e){return s(e),e.sort(f)},Matrix:function(e){return u(e),c(e.toArray().sort(f),e.storage())},"Array, function":function(e,r){return s(e),e.sort(r)},"Matrix, function":function(e,r){return u(e),c(e.toArray().sort(r),e.storage())},"Array, string":function(e,r){return s(e),e.sort(o(r))},"Matrix, string":function(e,r){return u(e),c(e.toArray().sort(o(r)),e.storage())}})}var i=t(37).size;r.name="sort",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("_typeof",{any:function(r){var t=i.type(r);if("object"===t){if(r instanceof e.Complex)return"complex";if(r instanceof e.Matrix)return"matrix";if(r instanceof e.Unit)return"unit";if(r instanceof e.Index)return"index";if(r instanceof e.Range)return"range";if(r instanceof e.Help)return"help";if(r instanceof e.BigNumber)return"bignumber";if(r instanceof e.Chain)return"chain"}return t}})}var i=t(189);r.name="typeof",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){return n("forEach",{"Array, function":i,"Matrix, function":function(e,r){return e.forEach(r)}})}function i(e,r){var t=function(n,i){Array.isArray(n)?n.forEach(function(e,r){t(e,i.concat(r))}):r(n,i,e)};t(e,[])}r.name="forEach",r.factory=n},function(e,r,t){e.exports=[t(195),t(196),t(197),t(198),t(199),t(201),t(200),t(203),t(212),t(202),t(204),t(205),t(206)]},function(e,r,t){e.exports=[t(213),t(214),t(215),t(216),t(217),t(218),t(219),t(220),t(221),t(222)]},function(e,r,t){function n(e,r,n,i){var a={};return a.e=t(223),a.E=t(223),a["false"]=t(224),a.i=t(225),a.Infinity=t(226),a.LN2=t(227),a.LN10=t(228),a.LOG2E=t(229),a.LOG10E=t(230),a.NaN=t(231),a["null"]=t(232),a.pi=t(233),a.PI=t(233),a.phi=t(234),a.SQRT1_2=t(235),a.SQRT2=t(236),a.tau=t(237),a["true"]=t(238),a.version=t(239),a.abs=t(240),a.add=t(241),a.ceil=t(242),a.cube=t(243),a.divide=t(244),a.dotDivide=t(245),a.dotMultiply=t(246),a.dotPow=t(247),a.exp=t(248),a.fix=t(249),a.floor=t(250),a.gcd=t(251),a.lcm=t(252),a.log=t(253),a.log10=t(254),a.mod=t(255),a.multiply=t(256),a.norm=t(257),a.nthRoot=t(258),a.pow=t(259),a.round=t(260),a.sign=t(261),a.sqrt=t(262),a.square=t(263),a.subtract=t(264),a.unaryMinus=t(265),a.unaryPlus=t(266),a.xgcd=t(267),a.bitAnd=t(268),a.bitNot=t(269),a.bitOr=t(270),a.bitXor=t(271),a.leftShift=t(272),a.rightArithShift=t(273),a.rightLogShift=t(274),a.arg=t(275),a.conj=t(276),a.re=t(277),a.im=t(278),a.bignumber=t(279),a["boolean"]=t(280),a.complex=t(281),a.index=t(282),a.matrix=t(283),a.number=t(284),a.sparse=t(285),a.string=t(286),a.unit=t(287),a.eval=t(288),a.help=t(289),a.and=t(290),a.not=t(291),a.or=t(292),a.xor=t(293),a.concat=t(294),a.cross=t(295),a.det=t(296),a.diag=t(297),a.dot=t(298),a.eye=t(299),a.flatten=t(300),a.inv=t(301),a.ones=t(302),a.range=t(303),a.resize=t(304),a.size=t(305),a.squeeze=t(306),a.subset=t(307),a.trace=t(308),a.transpose=t(309),a.zeros=t(310),a.combinations=t(311),a.factorial=t(312),a.gamma=t(313),a.permutations=t(314),a.pickRandom=t(315),a.random=t(316),a.randomInt=t(317),a.compare=t(318),a.deepEqual=t(319),a.equal=t(320),a.larger=t(321),a.largerEq=t(322),a.smaller=t(323),a.smallerEq=t(324),a.unequal=t(325),a.max=t(326),a.mean=t(327),a.median=t(328),a.min=t(329),a.prod=t(330),a.std=t(331),a.sum=t(332),a["var"]=t(333),a.acos=t(334),a.acosh=t(335),a.acot=t(336),a.acoth=t(337),a.acsc=t(338),a.acsch=t(339),a.asec=t(340),a.asech=t(341),a.asin=t(342),a.asinh=t(343),a.atan=t(344),a.atanh=t(345),a.atan2=t(346),a.cos=t(347),a.cosh=t(348),a.cot=t(349),a.coth=t(350),a.csc=t(351),a.csch=t(352),a.sec=t(353),a.sech=t(354),a.sin=t(355),a.sinh=t(356),a.tan=t(357),a.tanh=t(358),a.to=t(359),a.clone=t(360),a.map=t(361),a.filter=t(362),a.forEach=t(363),a.format=t(364),a["import"]=t(365),a.sort=t(366),a["typeof"]=t(367),a}r.name="docs",r.path="expression",r.factory=n},function(e,r,t){function n(e){return t(i(e))}function i(e){return a[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var a={"./clone":174,"./clone.js":174,"./config":175,"./config.js":175,"./filter":176,"./filter.js":176,"./forEach":182,"./forEach.js":182,"./format":177,"./format.js":177,"./import":35,"./import.js":35,"./index":32,"./index.js":32,"./map":178,"./map.js":178,"./print":179,"./print.js":179,"./sort":180,"./sort.js":180,"./typeof":181,"./typeof.js":181};n.keys=function(){return Object.keys(a)},n.resolve=i,e.exports=n,n.id=186},function(e,r,t){"use strict";r.isBoolean=function(e){return"boolean"==typeof e}},function(e,r,t){r.memoize=function(e){return function r(){"object"!=typeof r.cache&&(r.cache={});var t=JSON.stringify(arguments);return t in r.cache?r.cache[t]:r.cache[t]=e.apply(e,arguments)}}},function(e,r,t){"use strict";r.type=function(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";if(e instanceof Function)return"function";if(e instanceof RegExp)return"regexp"}return r}},function(e,r,t){"use strict";function n(e){var r=String(e).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number");var t=r[1],n=r[2],i=parseFloat(r[4]||"0"),a=n.indexOf(".");i+=-1!==a?a-1:n.length-1,this.sign=t,this.coefficients=n.replace(".","").replace(/^0*/,function(e){return i-=e.length,""}).replace(/0*$/,"").split("").map(function(e){return parseInt(e)}),0===this.coefficients.length&&(this.coefficients.push(0),i++),this.exponent=i}function i(e){for(var r=[],t=0;e>t;t++)r.push(0);return r}n.prototype.toFixed=function(e){var r=this.roundDigits(this.exponent+1+(e||0)),t=r.coefficients,n=r.exponent+1,a=n+(e||0);return t.lengthn&&(t=i(-n+1).concat(t),n=1),e&&t.splice(n,0,0===n?"0.":"."),this.sign+t.join("")},n.prototype.toExponential=function(e){var r=e?this.roundDigits(e):this.clone(),t=r.coefficients,n=r.exponent;t.length0?"."+t.join(""):"")+"e"+(n>=0?"+":"")+n},n.prototype.toPrecision=function(e,r){var t=r&&void 0!==r.lower?r.lower:.001,n=r&&void 0!==r.upper?r.upper:1e5,a=Math.abs(Math.pow(10,this.exponent)); + +if(t>a||a>=n)return this.toExponential(e);var o=e?this.roundDigits(e):this.clone(),s=o.coefficients,u=o.exponent;s.length0?u:0;return c=e;)t.unshift(0),r.exponent++,e++;if(t.length>e){var n=t.splice(e);if(n[0]>=5){var i=e-1;for(t[i]++;10===t[i];)t.pop(),0===i&&(t.unshift(0),r.exponent++,i++),i--,t[i]++}}return r},e.exports=n},function(e,r,t){var n;!function(i){"use strict";function a(e){for(var r,t,n=1,i=e.length,a=e[0]+"";i>n;n++){for(r=e[n]+"",t=_-r.length;t--;)r="0"+r;a+=r}for(i=a.length;48===a.charCodeAt(--i););return a.slice(0,i+1||1)}function o(e,r,t,n){var i,a,o,s,u;for(a=1,o=e[0];o>=10;o/=10,a++);return o=r-a,0>o?(o+=_,i=0):(i=Math.ceil((o+1)/_),o%=_),a=E(10,_-o),u=e[i]%a|0,null==n?3>o?(0==o?u=u/100|0:1==o&&(u=u/10|0),s=4>t&&99999==u||t>3&&49999==u||5e4==u||0==u):s=(4>t&&u+1==a||t>3&&u+1==a/2)&&(e[i+1]/a/100|0)==E(10,o-2)-1||(u==a/2||0==u)&&0==(e[i+1]/a/100|0):4>o?(0==o?u=u/1e3|0:1==o?u=u/100|0:2==o&&(u=u/10|0),s=(n||4>t)&&9999==u||!n&&t>3&&4999==u):s=((n||4>t)&&u+1==a||!n&&t>3&&u+1==a/2)&&(e[i+1]/a/1e3|0)==E(10,o-3)-1,s}function s(e,r,t){var n=e.constructor;return null==r||((y=0>r||r>8)||0!==r&&(n.errors?parseInt:parseFloat)(r)!=r)&&!p(n,"rounding mode",r,t,0)?n.rounding:0|r}function u(e,r,t,n){var i=e.constructor;return!(y=(n||0)>r||r>=S+1)&&(0===r||(i.errors?parseInt:parseFloat)(r)==r)||p(i,"argument",r,t,0)}function c(e,r){var t,n,i,s,u,c,f,l=0,p=0,m=0,h=e.constructor,v=h.ONE,d=h.rounding,y=h.precision;if(!e.c||!e.c[0]||e.e>17)return new h(e.c?e.c[0]?e.s<0?0:1/0:v:e.s?e.s<0?0:e:0/0);for(null==r?(w=!1,u=y):u=r,f=new h(.03125);e.e>-2;)e=e.times(f),m+=5;for(n=Math.log(E(2,m))/Math.LN10*2+5|0,u+=n,t=s=c=new h(v),h.precision=u;;){if(s=g(s.times(e),u,1),t=t.times(++p),f=c.plus(I(s,t,u,1)),a(f.c).slice(0,u)===a(c.c).slice(0,u)){for(i=m;i--;)c=g(c.times(c),u,1);if(null!=r)return h.precision=y,c;if(!(3>l&&o(c.c,u-n,d,l)))return g(c,h.precision=y,d,w=!0);h.precision=u+=10,t=s=f=new h(v),p=0,l++}c=f}}function f(e,r,t,n){var i,o,s=e.constructor,u=(e=new s(e)).e;if(null==r?t=0:(g(e,++r,t),t=n?r:r+e.e-u),u=e.e,i=a(e.c),1==n||2==n&&(u>=r||u<=s.toExpNeg)){for(;i.length1&&(i=i.charAt(0)+"."+i.slice(1)),i+=(0>u?"e":"e+")+u}else{if(n=i.length,0>u){for(o=t-n;++u;i="0"+i);i="0."+i}else if(++u>n){for(o=t-u,u-=n;u--;i+="0");o>0&&(i+=".")}else o=t-n,n>u?i=i.slice(0,u)+"."+i.slice(u):o>0&&(i+=".");if(o>0)for(;o--;i+="0");}return e.s<0&&e.c[0]?"-"+i:i}function l(e){var r=e.length-1,t=r*_+1;if(r=e[r]){for(;r%10==0;r/=10,t--);for(r=e[0];r>=10;r/=10,t++);}return t}function p(e,r,t,n,i){if(e.errors){var a=new Error((n||["new Decimal","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","pow","random","log","sqrt","toNearest","divToInt"][b?0>b?-b:b:0>1/b?1:0])+"() "+(["number type has more than 15 significant digits","LN10 out of digits"][r]||r+([y?" out of range":" not an integer"," not a boolean or binary digit"][i]||""))+": "+t);throw a.name="Decimal Error",y=b=0,a}}function m(e,r,t){var n=new e(e.ONE);for(w=!1;1&t&&(n=n.times(r)),t>>=1,t;)r=r.times(r);return w=!0,n}function h(e,r){var t,n,i,s,u,c,f,l,m,v,d,y=1,x=10,b=e,N=b.c,E=b.constructor,M=E.ONE,A=E.rounding,_=E.precision;if(b.s<0||!N||!N[0]||!b.e&&1==N[0]&&1==N.length)return new E(N&&!N[0]?-1/0:1!=b.s?0/0:N?0:b);if(null==r?(w=!1,f=_):f=r,E.precision=f+=x,t=a(N),n=t.charAt(0),!(Math.abs(s=b.e)<15e14))return b=new E(n+"."+t.slice(1)),f+2>T.length&&p(E,1,f+2,"ln"),b=h(b,f-x).plus(new E(T.slice(0,f+2)).times(s+"")),E.precision=_,null==r?g(b,_,A,w=!0):b;for(;7>n&&1!=n||1==n&&t.charAt(1)>3;)b=b.times(e),t=a(b.c),n=t.charAt(0),y++;for(s=b.e,n>1?(b=new E("0."+t),s++):b=new E(n+"."+t.slice(1)),v=b,l=u=b=I(b.minus(M),b.plus(M),f,1),d=g(b.times(b),f,1),i=3;;){if(u=g(u.times(d),f,1),m=l.plus(I(u,new E(i),f,1)),a(m.c).slice(0,f)===a(l.c).slice(0,f)){if(l=l.times(2),0!==s&&(f+2>T.length&&p(E,1,f+2,"ln"),l=l.plus(new E(T.slice(0,f+2)).times(s+""))),l=I(l,new E(y),f,1),null!=r)return E.precision=_,l;if(!o(l.c,f-x,A,c))return g(l,E.precision=_,A,w=!0);E.precision=f+=x,m=u=b=I(v.minus(M),v.plus(M),f,1),d=g(b.times(b),f,1),i=c=1}l=m,i+=2}}function g(e,r,t,n){var i,a,o,s,u,c,f,l,p=e.constructor;e:if(null!=r){if(!(f=e.c))return e;for(i=1,s=f[0];s>=10;s/=10,i++);if(a=r-i,0>a)a+=_,o=r,u=f[l=0],c=u/E(10,i-o-1)%10|0;else if(l=Math.ceil((a+1)/_),l>=f.length){if(!n)break e;for(;f.length<=l;f.push(0));u=c=0,i=1,a%=_,o=a-_+1}else{for(u=s=f[l],i=1;s>=10;s/=10,i++);a%=_,o=a-_+i,c=0>o?0:N(u/E(10,i-o-1)%10)}if(n=n||0>r||null!=f[l+1]||(0>o?u:u%E(10,i-o-1)),n=4>t?(c||n)&&(0==t||t==(e.s<0?3:2)):c>5||5==c&&(4==t||n||6==t&&(a>0?o>0?u/E(10,i-o):0:f[l-1])%10&1||t==(e.s<0?8:7)),1>r||!f[0])return f.length=0,n?(r-=e.e+1,f[0]=E(10,r%_),e.e=-r||0):f[0]=e.e=0,e;if(0==a?(f.length=l,s=1,l--):(f.length=l+1,s=E(10,_-a),f[l]=o>0?(u/E(10,i-o)%E(10,o)|0)*s:0),n)for(;;){if(0==l){for(a=1,o=f[0];o>=10;o/=10,a++);for(o=f[0]+=s,s=1;o>=10;o/=10,s++);a!=s&&(e.e++,f[0]==A&&(f[0]=1));break}if(f[l]+=s,f[l]!=A)break;f[l--]=0,s=1}for(a=f.length;0===f[--a];f.pop());}return w&&(e.e>p.maxE?e.c=e.e=null:e.eo,!i||!a)return u==c?0:!i^t?1:-1;if(u!=c)return u>c^t?1:-1;for(o=-1,s=(u=i.length)<(c=a.length)?u:c;++oa[o]^t?1:-1;return u==c?0:u>c^t?1:-1},z.decimalPlaces=z.dp=function(){var e,r,t=null;if(e=this.c){if(t=((r=e.length-1)-N(this.e/_))*_,r=e[r])for(;r%10==0;r/=10,t--);0>t&&(t=0)}return t},z.dividedBy=z.div=function(e,r){return b=2,I(this,new this.constructor(e,r))},z.dividedToIntegerBy=z.divToInt=function(e,r){var t=this,n=t.constructor;return b=18,g(I(t,new n(e,r),0,1,1),n.precision,n.rounding)},z.equals=z.eq=function(e,r){return b=3,0===this.cmp(e,r)},z.exponential=z.exp=function(){return c(this)},z.floor=function(){return g(new this.constructor(this),this.e+1,3)},z.greaterThan=z.gt=function(e,r){return b=4,this.cmp(e,r)>0},z.greaterThanOrEqualTo=z.gte=function(e,r){return b=5,r=this.cmp(e,r),1==r||0===r},z.isFinite=function(){return!!this.c},z.isInteger=z.isInt=function(){return!!this.c&&N(this.e/_)>this.c.length-2},z.isNaN=function(){return!this.s},z.isNegative=z.isNeg=function(){return this.s<0},z.isZero=function(){return!!this.c&&0==this.c[0]},z.lessThan=z.lt=function(e,r){return b=6,this.cmp(e,r)<0},z.lessThanOrEqualTo=z.lte=function(e,r){return b=7,r=this.cmp(e,r),-1==r||0===r},z.logarithm=z.log=function(e,r){var t,n,i,s,u,c,f,l,m,v=this,d=v.constructor,y=d.precision,x=d.rounding,N=5;if(null==e)e=new d(10),t=!0;else{if(b=15,e=new d(e,r),n=e.c,e.s<0||!n||!n[0]||!e.e&&1==n[0]&&1==n.length)return new d(0/0);t=e.eq(10)}if(n=v.c,v.s<0||!n||!n[0]||!v.e&&1==n[0]&&1==n.length)return new d(n&&!n[0]?-1/0:1!=v.s?0/0:n?0:1/0);if(u=t&&(s=n[0],n.length>1||1!=s&&10!=s&&100!=s&&1e3!=s&&1e4!=s&&1e5!=s&&1e6!=s),w=!1,f=y+N,l=f+10,c=h(v,f),t?(l>T.length&&p(d,1,l,"log"),i=new d(T.slice(0,l))):i=h(e,f),m=I(c,i,f,1),o(m.c,s=y,x))do if(f+=10,c=h(v,f),t?(l=f+10,l>T.length&&p(d,1,l,"log"),i=new d(T.slice(0,l))):i=h(e,f),m=I(c,i,f,1),!u){+a(m.c).slice(s+1,s+15)+1==1e14&&(m=g(m,y+1,0));break}while(o(m.c,s+=10,x));return w=!0,g(m,y,x)},z.minus=function(e,r){var t,n,i,a,o=this,s=o.constructor,u=o.s;if(b=8,e=new s(e,r),r=e.s,!u||!r)return new s(0/0);if(u!=r)return e.s=-r,o.plus(e);var c=o.c,f=e.c,l=N(e.e/_),p=N(o.e/_),m=s.precision,h=s.rounding;if(!p||!l){if(!c||!f)return c?(e.s=-r,e):new s(f?o:0/0);if(!c[0]||!f[0])return o=f[0]?(e.s=-r,e):new s(c[0]?o:3==h?-0:0),w?g(o,m,h):o}if(c=c.slice(),n=c.length,u=p-l){for((a=0>u)?(u=-u,t=c,n=f.length):(l=p,t=f),(p=Math.ceil(m/_))>n&&(n=p),u>(n+=2)&&(u=n,t.length=1),t.reverse(),r=u;r--;t.push(0));t.reverse()}else for((a=n<(i=f.length))&&(i=n),u=r=0;i>r;r++)if(c[r]!=f[r]){a=c[r]0)for(;r--;c[i++]=0);for(p=A-1,r=f.length;r>u;){if(c[--r]=10;r/=10,u++);return e.e=u+l*_-1,w?g(e,m,h):e},z.modulo=z.mod=function(e,r){var t,n,i=this,a=i.constructor,o=a.modulo;return b=9,e=new a(e,r),r=e.s,t=!i.c||!r||e.c&&!e.c[0],t||!e.c||i.c&&!i.c[0]?t?new a(0/0):g(new a(i),a.precision,a.rounding):(w=!1,9==o?(e.s=1,n=I(i,e,0,3,1),e.s=r,n.s*=r):n=I(i,e,0,o,1),n=n.times(e),w=!0,i.minus(n))},z.naturalLogarithm=z.ln=function(){return h(this)},z.negated=z.neg=function(){var e=new this.constructor(this);return e.s=-e.s||null,g(e)},z.plus=function(e,r){var t,n=this,i=n.constructor,a=n.s;if(b=10,e=new i(e,r),r=e.s,!a||!r)return new i(0/0);if(a!=r)return e.s=-r,n.minus(e);var o=n.c,s=e.c,u=N(e.e/_),c=N(n.e/_),f=i.precision,l=i.rounding;if(!c||!u){if(!o||!s)return new i(a/0);if(!o[0]||!s[0])return n=s[0]?e:new i(o[0]?n:0*a),w?g(n,f,l):n}if(o=o.slice(),a=c-u){for(0>a?(a=-a,t=o,r=s.length):(u=c,t=s,r=o.length),(c=Math.ceil(f/_))>r&&(r=c),a>++r&&(a=r,t.length=1),t.reverse();a--;t.push(0));t.reverse()}for(o.length-s.length<0&&(t=s,s=o,o=t),a=s.length,r=0,c=A;a;o[a]%=c)r=(o[--a]=o[a]+s[a]+r)/c|0;for(r&&(o.unshift(r),++u),a=o.length;0==o[--a];o.pop());for(e.c=o,a=1,r=o[0];r>=10;r/=10,a++);return e.e=a+u*_-1,w?g(e,f,l):e},z.precision=z.sd=function(e){var r=null,t=this;return e!=r&&e!==!!e&&1!==e&&0!==e&&p(t.constructor,"argument",e,"precision",1),t.c&&(r=l(t.c),e&&t.e+1>r&&(r=t.e+1)),r},z.round=function(){var e=this,r=e.constructor;return g(new r(e),e.e+1,r.rounding)},z.squareRoot=z.sqrt=function(){var e,r,t,n,i,o,s=this,u=s.c,c=s.s,f=s.e,l=s.constructor,p=new l(.5);if(1!==c||!u||!u[0])return new l(!c||0>c&&(!u||u[0])?0/0:u?s:1/0);for(w=!1,c=Math.sqrt(+s),0==c||c==1/0?(r=a(u),(r.length+f)%2==0&&(r+="0"),c=Math.sqrt(r),f=N((f+1)/2)-(0>f||f%2),c==1/0?r="1e"+f:(r=c.toExponential(),r=r.slice(0,r.indexOf("e")+1)+f),n=new l(r)):n=new l(c.toString()),t=(f=l.precision)+3;;)if(o=n,n=p.times(o.plus(I(s,o,t+2,1))),a(o.c).slice(0,t)===(r=a(n.c)).slice(0,t)){if(r=r.slice(t-3,t+1),"9999"!=r&&(i||"4999"!=r)){(!+r||!+r.slice(1)&&"5"==r.charAt(0))&&(g(n,f+1,1),e=!n.times(n).eq(s));break}if(!i&&(g(o,f+1,0),o.times(o).eq(s))){n=o;break}t+=4,i=1}return w=!0,g(n,f,l.rounding,e)},z.times=function(e,r){var t,n,i=this,a=i.constructor,o=i.c,s=(b=11,e=new a(e,r),e.c),u=N(i.e/_),c=N(e.e/_),f=i.s;if(r=e.s,e.s=f==r?1:-1,!((u||o&&o[0])&&(c||s&&s[0])))return new a(!f||!r||o&&!o[0]&&!s||s&&!s[0]&&!o?0/0:o&&s?0*e.s:e.s/0);for(n=u+c,f=o.length,r=s.length,r>f&&(t=o,o=s,s=t,c=f,f=r,r=c),c=f+r,t=[];c--;t.push(0));for(u=r-1;u>-1;u--){for(r=0,c=f+u;c>u;)r=t[c]+s[u]*o[c-u-1]+r,t[c--]=r%A|0,r=r/A|0;t[c]=(t[c]+r)%A|0}for(r?++n:t[0]||t.shift(),c=t.length;!t[--c];t.pop());for(e.c=t,f=1,r=t[0];r>=10;r/=10,f++);return e.e=f+n*_-1,w?g(e,a.precision,a.rounding):e},z.toDecimalPlaces=z.toDP=function(e,r){var t=this;return t=new t.constructor(t),null!=e&&u(t,e,"toDP")?g(t,(0|e)+t.e+1,s(t,r,"toDP")):t},z.toExponential=function(e,r){var t=this;return t.c?f(t,null!=e&&u(t,e,"toExponential")?0|e:null,null!=e&&s(t,r,"toExponential"),1):t.toString()},z.toFixed=function(e,r){var t,n=this,i=n.constructor,a=i.toExpNeg,o=i.toExpPos;return null!=e&&(e=u(n,e,t="toFixed")?n.e+(0|e):null,r=s(n,r,t)),i.toExpNeg=-(i.toExpPos=1/0),null!=e&&n.c?(t=f(n,e,r),n.s<0&&n.c&&(n.c[0]?t.indexOf("-")<0&&(t="-"+t):t=t.replace("-",""))):t=n.toString(),i.toExpNeg=a,i.toExpPos=o,t},z.toFormat=function(e,r){var t=this;if(!t.c)return t.toString();var n,i=t.s<0,a=t.constructor.format,o=a.groupSeparator,s=+a.groupSize,u=+a.secondaryGroupSize,c=t.toFixed(e,r).split("."),f=c[0],l=c[1],p=i?f.slice(1):f,m=p.length;if(u&&(n=s,s=u,m-=u=n),s>0&&m>0){for(n=m%s||s,f=p.substr(0,n);m>n;n+=s)f+=o+p.substr(n,s);u>0&&(f+=o+p.slice(n)),i&&(f="-"+f)}return l?f+a.decimalSeparator+((u=+a.fractionGroupSize)?l.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+a.fractionGroupSeparator):l):f},z.toFraction=function(e){var r,t,n,i,o,s,u,c,f=this,m=f.constructor,h=r=new m(m.ONE),g=s=new m(0),v=f.c,d=new m(g);if(!v)return f.toString();for(n=d.e=l(v)-f.e-1,d.c[0]=E(10,(u=n%_)<0?_+u:u),(null==e||(!(b=12,o=new m(e)).s||(y=o.cmp(h)<0||!o.c)||m.errors&&N(o.e/_)0)&&(e=n>0?d:h),w=!1,o=new m(a(v)),u=m.precision,m.precision=n=v.length*_*2;c=I(o,d,0,1,1),t=r.plus(c.times(g)),1!=t.cmp(e);)r=g,g=t,h=s.plus(c.times(t=h)),s=t,d=o.minus(c.times(t=d)),o=t;return t=I(e.minus(r),g,0,1,1),s=s.plus(t.times(h)),r=r.plus(t.times(g)),s.s=h.s=f.s,i=I(h,g,n,1).minus(f).abs().cmp(I(s,r,n,1).minus(f).abs())<1?[h+"",g+""]:[s+"",r+""],w=!0,m.precision=u,i},z.toNearest=function(e,r){var t=this,n=t.constructor;return t=new n(t),null==e?(e=new n(n.ONE),r=n.rounding):(b=17,e=new n(e),r=s(t,r,"toNearest")),e.c?t.c&&(e.c[0]?(w=!1,t=I(t,e,0,4>r?[4,5,7,8][r]:r,1).times(e),w=!0,g(t)):t.c=[t.e=0]):t.s&&(e.s&&(e.s=t.s),t=e),t},z.toNumber=function(){var e=this;return+e||(e.s?0*e.s:0/0)},z.toPower=z.pow=function(e,r){var t,n,i,s,u=this,f=u.constructor,l=u.s,p=(b=13,+(e=new f(e,r))),v=0>p?-p:p,d=f.precision,y=f.rounding;if(!u.c||!e.c||(i=!u.c[0])||!e.c[0])return new f(E(i?0*l:+u,p));if(u=new f(u),t=u.c.length,!u.e&&u.c[0]==u.s&&1==t)return u;if(r=e.c.length-1,e.e||e.c[0]!=e.s||r)if(n=N(e.e/_),i=n>=r,!i&&0>l)s=new f(0/0);else{if(i&&B>t*_*v){if(s=m(f,u,v),e.s<0)return f.ONE.div(s)}else{if(l=0>l&&1&e.c[Math.max(n,r)]?-1:1,r=E(+u,p),n=0!=r&&isFinite(r)?new f(r+"").e:N(p*(Math.log("0."+a(u.c))/Math.LN10+u.e+1)),n>f.maxE+1||n0?l/0:0);w=!1,f.rounding=u.s=1,v=Math.min(12,(n+"").length),s=c(e.times(h(u,d+v)),d),s=g(s,d+5,1),o(s.c,d,y)&&(n=d+10,s=g(c(e.times(h(u,n+v)),n),n+5,1),+a(s.c).slice(d+1,d+15)+1==1e14&&(s=g(s,d+1,0))),s.s=l,w=!0,f.rounding=y}s=g(s,d,y)}else s=g(u,d,y);return s},z.toPrecision=function(e,r){var t=this;return null!=e&&u(t,e,"toPrecision",1)&&t.c?f(t,0|--e,s(t,r,"toPrecision"),2):t.toString()},z.toSignificantDigits=z.toSD=function(e,r){var t=this,n=t.constructor;return t=new n(t),null!=e&&u(t,e,"toSD",1)?g(t,0|e,s(t,r,"toSD")):g(t,n.precision,n.rounding)},z.toString=function(e){var r,t,n,i=this,o=i.constructor,s=i.e;if(null===s)t=i.s?"Infinity":"NaN";else{if(e===r&&(s<=o.toExpNeg||s>=o.toExpPos))return f(i,null,o.rounding,1);if(t=a(i.c),0>s){for(;++s;t="0"+t);t="0."+t}else if(n=t.length,s>0)if(++s>n)for(s-=n;s--;t+="0");else n>s&&(t=t.slice(0,s)+"."+t.slice(s));else if(r=t.charAt(0),n>1)t=r+"."+t.slice(1);else if("0"==r)return r;if(null!=e)if((y=!(e>=2&&65>e))||e!=(0|e)&&o.errors)p(o,"base",e,"toString",0);else if(t=v(o,t,0|e,10,i.s),"0"==t)return t}return i.s<0?"-"+t:t},z.truncated=z.trunc=function(){return g(new this.constructor(this),this.e+1,1)},z.valueOf=z.toJSON=function(){return this.toString()},v=function(){function e(e,r,t){for(var n,i,a=[0],o=0,s=e.length;s>o;){for(i=a.length;i--;a[i]*=r);for(a[n=0]+=O.indexOf(e.charAt(o++));nt-1&&(null==a[n+1]&&(a[n+1]=0),a[n+1]+=a[n]/t|0,a[n]%=t)}return a.reverse()}return function(r,t,n,i,a){var o,s,u,c,f,l,p=t.indexOf("."),h=r.precision,g=r.rounding;for(37>i&&(t=t.toLowerCase()),p>=0&&(t=t.replace(".",""),l=new r(i),c=m(r,l,t.length-p),l.c=e(c.toFixed(),10,n),l.e=l.c.length),f=e(t,i,n),o=s=f.length;0==f[--s];f.pop());if(!f[0])return"0";if(0>p?o--:(c.c=f,c.e=o,c.s=a,c=I(c,l,h,g,0,n),f=c.c,u=c.r,o=c.e),p=f[h],s=n/2,u=u||null!=f[h+1],4>g?(null!=p||u)&&(0==g||g==(c.s<0?3:2)):p>s||p==s&&(4==g||u||6==g&&1&f[h-1]||g==(c.s<0?8:7)))for(f.length=h,--n;++f[--h]>n;)f[h]=0,h||(++o,f.unshift(1));else f.length=h;for(s=f.length;!f[--s];);for(p=0,t="";s>=p;t+=O.charAt(f[p++]));if(0>o){for(;++o;t="0"+t);t="0."+t}else if(p=t.length,++o>p)for(o-=p;o--;t+="0");else p>o&&(t=t.slice(0,o)+"."+t.slice(o));return t}}();var I=function(){function e(e,r,t){var n,i=0,a=e.length;for(e=e.slice();a--;)n=e[a]*r+i,e[a]=n%t|0,i=n/t|0;return i&&e.unshift(i),e}function r(e,r,t,n){var i,a;if(t!=n)a=t>n?1:-1;else for(i=a=0;t>i;i++)if(e[i]!=r[i]){a=e[i]>r[i]?1:-1;break}return a}function t(e,r,t,n){for(var i=0;t--;)e[t]-=i,i=e[t]1;e.shift());}return function(n,i,a,o,s,u){var c,f,l,p,m,h,v,d,y,x,w,b,E,M,O,z,C,S,B,T=n.constructor,I=n.s==i.s?1:-1,q=n.c,P=i.c;if(!(q&&q[0]&&P&&P[0]))return new T(n.s&&i.s&&(q?!P||q[0]!=P[0]:P)?q&&0==q[0]||!P?0*I:I/0:0/0);for(u?(p=1,f=n.e-i.e):(u=A,p=_,f=N(n.e/p)-N(i.e/p)),S=P.length,z=q.length,y=new T(I),x=y.c=[],l=0;P[l]==(q[l]||0);l++);if(P[l]>(q[l]||0)&&f--,null==a?(I=a=T.precision,o=T.rounding):I=s?a+(n.e-i.e)+1:a,0>I)x.push(1),m=!0;else{if(I=I/p+2|0,l=0,1==S){for(h=0,P=P[0],I++;(z>l||h)&&I--;l++)M=h*u+(q[l]||0),x[l]=M/P|0,h=M%P|0;m=h||z>l}else{for(h=u/(P[0]+1)|0,h>1&&(P=e(P,h,u),q=e(q,h,u),S=P.length,z=q.length),O=S,w=q.slice(0,S),b=w.length;S>b;w[b++]=0);B=P.slice(),B.unshift(0),C=P[0],P[1]>=u/2&&C++;do h=0,c=r(P,w,S,b),0>c?(E=w[0],S!=b&&(E=E*u+(w[1]||0)),h=E/C|0,h>1?(h>=u&&(h=u-1),v=e(P,h,u),d=v.length,b=w.length,c=r(v,w,d,b),1==c&&(h--,t(v,d>S?B:P,d,u))):(0==h&&(c=h=1),v=P.slice()),d=v.length,b>d&&v.unshift(0),t(w,v,b,u),-1==c&&(b=w.length,c=r(P,w,S,b),1>c&&(h++,t(w,b>S?B:P,b,u))),b=w.length):0===c&&(h++,w=[0]),x[l++]=h,c&&w[0]?w[b++]=q[O]||0:(w=[q[O]],b=1);while((O++=10;I/=10,l++);y.e=l+f*p-1,g(y,s?a+y.e+1:a,o,m)}return y}}();d=function(){function e(e){var r,t,n,i=this,a="config",o=i.errors?parseInt:parseFloat;return e==t||"object"!=typeof e&&!p(i,"object expected",e,a)?i:((n=e[r="precision"])!=t&&((y=1>n||n>S)||o(n)!=n?p(i,r,n,a,0):i[r]=0|n),(n=e[r="rounding"])!=t&&((y=0>n||n>8)||o(n)!=n?p(i,r,n,a,0):i[r]=0|n),(n=e[r="toExpNeg"])!=t&&((y=-C>n||n>0)||o(n)!=n?p(i,r,n,a,0):i[r]=N(n)),(n=e[r="toExpPos"])!=t&&((y=0>n||n>C)||o(n)!=n?p(i,r,n,a,0):i[r]=N(n)),(n=e[r="minE"])!=t&&((y=-C>n||n>0)||o(n)!=n?p(i,r,n,a,0):i[r]=N(n)),(n=e[r="maxE"])!=t&&((y=0>n||n>C)||o(n)!=n?p(i,r,n,a,0):i[r]=N(n)),(n=e[r="errors"])!=t&&(n===!!n||1===n||0===n?(y=b=0,i[r]=!!n):p(i,r,n,a,1)),(n=e[r="crypto"])!=t&&(n===!!n||1===n||0===n?i[r]=!(!n||!x||"object"!=typeof x):p(i,r,n,a,1)),(n=e[r="modulo"])!=t&&((y=0>n||n>9)||o(n)!=n?p(i,r,n,a,0):i[r]=0|n),(e=e[r="format"])!=t&&("object"==typeof e?i[r]=e:p(i,"format object expected",e,a)),i)}function r(e){return new this(e).exp()}function t(e){return new this(e).ln()}function n(e,r){return new this(e).log(r)}function i(e,r,t){var n,i,a=0;for("[object Array]"==M.call(r[0])&&(r=r[0]),n=new e(r[0]);++ai;)n=r[i],n>=429e7?r[i]=x.getRandomValues(new Uint32Array(1))[0]:a[i++]=n%1e7;else if(x&&x.randomBytes){for(r=x.randomBytes(t*=4);t>i;)n=r[i]+(r[i+1]<<8)+(r[i+2]<<16)+((127&r[i+3])<<24),n>=214e7?x.randomBytes(4).copy(r,i):(a.push(n%1e7),i+=4);i=t/4}else p(o,"crypto unavailable",x,"random");if(!i)for(;t>i;)a[i++]=1e7*Math.random()|0;for(t=a[--i],e%=_,t&&e&&(n=E(10,_-e),a[i]=(t/n|0)*n);0===a[i];i--)a.pop();if(0>i)a=[t=0];else{for(t=-1;0===a[0];)a.shift(),t-=_;for(i=1,n=a[0];n>=10;)n/=10,i++;_>i&&(t-=_-i)}return s.e=t,s.c=a,s}function f(e){return new this(e).sqrt()}function l(i){function u(e,r){var t=this;if(!(t instanceof u))return p(u,"Decimal called without new",e),new u(e,r);if(t.constructor=u,e instanceof u){if(null==r)return b=0,t.s=e.s,t.e=e.e,t.c=(e=e.c)?e.slice():e,t;if(10==r)return g(new u(e),u.precision,u.rounding);e+=""}return m(u,t,e,r)}return u.precision=20,u.rounding=4,u.modulo=1,u.toExpNeg=-7,u.toExpPos=21,u.minE=-C,u.maxE=C,u.errors=!0,u.crypto=!1,u.format={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0},u.prototype=z,u.ONE=new u(1),u.ROUND_UP=0,u.ROUND_DOWN=1,u.ROUND_CEIL=2,u.ROUND_FLOOR=3,u.ROUND_HALF_UP=4,u.ROUND_HALF_DOWN=5,u.ROUND_HALF_EVEN=6,u.ROUND_HALF_CEIL=7,u.ROUND_HALF_FLOOR=8,u.EUCLID=9,u.config=e,u.constructor=l,u.exp=r,u.ln=t,u.log=n,u.max=a,u.min=o,u.pow=s,u.sqrt=f,u.random=c,null!=i&&u.config(i),u}var m=function(){var e=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,r=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")};return function(t,n,i,a){var o,s,u,c,f,l;if("string"!=typeof i&&(i=(c="number"==typeof i||"[object Number]"==M.call(i))&&0===i&&0>1/i?"-0":i+""),f=i,null==a&&e.test(i))n.s=45===i.charCodeAt(0)?(i=i.slice(1),-1):1;else{if(10==a)return g(new t(i),t.precision,t.rounding);if(i=r.call(i).replace(/^\+(?!-)/,""),n.s=45===i.charCodeAt(0)?(i=i.replace(/^-(?!-)/,""),-1):1,null!=a?a!=(0|a)&&t.errors||(y=!(a>=2&&65>a))?(p(t,"base",a,0,0),l=e.test(i)):(o="["+O.slice(0,a=0|a)+"]+",i=i.replace(/\.$/,"").replace(/^\./,"0."),(l=new RegExp("^"+o+"(?:\\."+o+")?$",37>a?"i":"").test(i))?(c&&(i.replace(/^0\.0*|\./,"").length>15&&p(t,0,f),c=!c),i=v(t,i,10,a,n.s)):"Infinity"!=i&&"NaN"!=i&&(p(t,"not a base "+a+" number",f),i="NaN")):l=e.test(i),!l)return n.c=n.e=null,"Infinity"!=i&&("NaN"!=i&&p(t,"not a number",f),n.s=null),b=0,n}for((s=i.indexOf("."))>-1&&(i=i.replace(".","")),(u=i.search(/e/i))>0?(0>s&&(s=u),s+=+i.slice(u+1),i=i.substring(0,u)):0>s&&(s=i.length),u=0;48===i.charCodeAt(u);u++);for(a=i.length;48===i.charCodeAt(--a););if(i=i.slice(u,a+1)){if(a=i.length,c&&a>15&&p(t,0,f),n.e=s=s-u-1,n.c=[],u=(s+1)%_,0>s&&(u+=_),a>u){for(u&&n.c.push(+i.slice(0,u)),a-=_;a>u;)n.c.push(+i.slice(u,u+=_));i=i.slice(u),u=_-i.length}else u-=a;for(;u--;i+="0");n.c.push(+i),w&&(n.e>t.maxE?n.c=n.e=null:n.ew;w++)for(var b=p[w],N=p[w+1],E=b;N>E;E++){var M=l[E];x[M][w]=n?y(f[E],x[M][w]):y(x[M][w],f[E])}return new s({data:x,size:[g,v],datatype:d})},f=function(e,r,t,n){var o=e._data,s=e._size,c=e._datatype,f=r._values,l=r._index,p=r._ptr,m=r._size,h=r._datatype;if(s.length!==m.length)throw new a(s.length,m.length);if(s[0]!==m[0]||s[1]!==m[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+m+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");for(var g=s[0],v=s[1],d=c&&h&&c===h?c:void 0,y=d&&t.signatures?t.signatures[d+","+d]||t:t,x=[],w=[],b=new Array(v+1),N=0;v>N;N++){b[N]=w.length;for(var E=p[N],M=p[N+1],A=E;M>A;A++){var _=l[A],O=n?y(f[A],o[_][N]):y(o[_][N],f[A]);i(O,0)||(w.push(_),x.push(O))}}return b[v]=w.length,new u({values:x,index:w,ptr:b,size:[g,v],datatype:d})},l=function(e,r,t,n){var i=e._data,o=e._size,u=e._datatype,c=r._values,f=r._index,l=r._ptr,p=r._size,m=r._datatype,h=r._zero;if(o.length!==p.length)throw new a(o.length,p.length);if(o[0]!==p[0]||o[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+p+")");if(!c)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");for(var g=o[0],v=o[1],d=u&&m&&"undefined"!=typeof h&&null!==h&&u===m?u:void 0,y=d&&t.signatures?t.signatures[d+","+d]||t:t,x=d?h:0,w=new Array(g),b=0;g>b;b++)w[b]=new Array(v);for(var N=new Array(g),E=new Array(g),M=0;v>M;M++){for(var A=M+1,_=l[M],O=l[M+1],z=_;O>z;z++){var C=f[z];N[C]=n?y(c[z],i[C][M]):y(i[C][M],c[z]),E[C]=A}for(var S=0;g>S;S++)E[S]===A?w[S][M]=N[S]:w[S][M]=n?y(x,i[S][M]):y(i[S][M],x)}return new s({data:w,size:[g,v],datatype:d})},p=function(e,r,t){var n=e._values,o=e._size,s=e._datatype,c=e._zero,f=r._values,l=r._size,p=r._datatype,m=r._zero;if(o.length!==l.length)throw new a(o.length,l.length);if(o[0]!==l[0]||o[1]!==l[1])throw new RangeError("Dimension mismatch. Matrix A ("+o+") must match Matrix B ("+l+")");for(var h=o[0],g=o[1],v=s&&p&&"undefined"!=typeof c&&null!==c&&"undefined"!=typeof m&&null!==m&&s===p?s:void 0,d=v&&t.signatures?t.signatures[v+","+v]||t:t,y=v?i.signatures[v+","+v]||i:i,x=v?c:0,w=n&&f?[]:void 0,b=[],E=new Array(g+1),M=new u({values:w,index:b,ptr:E,size:[h,g],datatype:v}),A=n&&f?new Array(h):void 0,_=new Array(h),O=new Array(h),z=0;g>z;z++){E[z]=b.length;var C=z+1;if(N(e,z,_,A,O,C,M,d,!1),N(r,z,_,A,O,C,M,d,!1),A)for(var S=E[z];Sz;z++){E[z]=b.length;var C=z+1;if(N(e,z,_,A,O,C,M),N(r,z,_,A,O,C,M,d,!1,!0,x),A)for(var S=E[z];Sz;z++){E[z]=b.length;var C=z+1;if(N(e,z,_,A,O,C,M,d),N(r,z,_,A,O,C,M,d),A)for(var S=E[z];SM;M++){var A=M+1;N(e,M,w,y,E,A,void 0,h),N(r,M,b,x,E,A,void 0,h);for(var _=0;l>_;_++){0===M&&(v[_]=new Array(p));var O=w[_]===A?y[_]:g,z=b[_]===A?x[_]:g;v[_][M]=t(O,z)}}return d},v=function(e,r,t){var n=e._values,o=e._index,s=e._ptr,c=e._size,f=e._datatype,l=e._zero,p=r._values,m=r._index,h=r._ptr,g=r._size,v=r._datatype,d=r._zero;if(c.length!==g.length)throw new a(c.length,g.length);if(c[0]!==g[0]||c[1]!==g[1])throw new RangeError("Dimension mismatch. Matrix A ("+c+") must match Matrix B ("+g+")");if(!n||!p)throw new Error("Cannot perform operation on Pattern Sparse Matrices");for(var y,x,w,b,N=c[0],E=c[1],M=f&&v&&"undefined"!=typeof l&&null!==l&&"undefined"!=typeof d&&null!==d&&f===v?f:void 0,A=M&&t.signatures?t.signatures[M+","+M]||t:t,_=M?i.signatures[M+","+M]||i:i,O=M?l:0,z=[],C=[],S=new Array(E+1),B=new u({values:z,index:C,ptr:S,size:[N,E],datatype:M}),T=new Array(N),I=new Array(N),q=0;E>q;q++){S[q]=C.length;var P=q+1;for(x=s[q],w=s[q+1],y=x;w>y;y++)b=o[y],I[b]=P,T[b]=n[y],C.push(b);for(x=h[q],w=h[q+1],y=x;w>y;y++)b=m[y],I[b]===P&&(T[b]=A(T[b],p[y]));for(y=S[q];yg;g++){for(var v=g+1,d=o[g],y=o[g+1],x=d;y>x;x++){var w=a[x];m[w]=i[x],h[w]=v}for(var b=0;c>b;b++)0===g&&(l[b]=new Array(f)),h[b]===v?l[b][g]=n?t(r,m[b]):t(m[b],r):l[b][g]=r}return p},y=function(e,r,t,n){var a=e._values,o=e._index,s=e._ptr,c=e._size;if(!a)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");for(var f=c[0],l=c[1],p=[],m=[],h=new Array(l+1),g=new u({values:p,index:m,ptr:h,size:[f,l]}),v=0;l>v;v++){h[v]=m.length;for(var d=s[v],y=s[v+1],x=d;y>x;x++){var w=o[x],b=n?t(r,a[x]):t(a[x],r);i(b,0)||(m.push(w),p.push(b))}}return h[l]=m.length,g},x=function(e,r,t,n){var i=e._values,a=e._index,o=e._ptr,u=e._size;if(!i)throw new Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");for(var c=u[0],f=u[1],l=new Array(c),p=new s({data:l,size:[c,f]}),m=new Array(c),h=new Array(c),g=0;f>g;g++){for(var v=g+1,d=o[g],y=o[g+1],x=d;y>x;x++){var w=a[x];m[w]=i[x],h[w]=v}for(var b=0;c>b;b++)0===g&&(l[b]=new Array(f)), +h[b]===v?l[b][g]=n?t(r,m[b]):t(m[b],r):l[b][g]=n?t(r,0):t(0,r)}return p},w=function(e,r,t){var n=e._data,i=e._size,u=e._datatype,c=r._data,f=r._size,l=r._datatype;if(i.length!==f.length)throw new a(i.length,f.length);for(var p=0;po;o++)a[o]=h(t[o],n[o]);else for(var s=0;r>s;s++){var u=new Array(r);d(e+1,i[e+1],t[s],n[s],u),a[s]=u}};return d(0,g.length,n,c,g),v},b=function(e,r,t,n){var i=e._data,a=e._size,u=new Array(a[0]),c=new s({data:u,size:o.clone(a)}),f=function(e,i,o,s){if(e===a.length-1)for(var u=0;i>u;u++)s[u]=n?t(r,o[u]):t(o[u],r);else for(var c=0;i>c;c++){var l=new Array(i);f(e+1,a[e+1],o[c],l),s[c]=l}};return f(0,u.length,i,u),c},N=function(e,r,t,n,i,a,o,s,u,c,f){var l,p,m,h,g=e._values,v=e._index,d=e._ptr,y=o?o._index:void 0;if(n)for(p=d[r],m=d[r+1],l=p;m>l;l++)h=v[l],t[h]!==a?(t[h]=a,y&&y.push(h),c?(n[h]=u?s(g[l],f):s(f,g[l]),i[h]=a):n[h]=g[l]):(n[h]=u?s(g[l],n[h]):s(n[h],g[l]),i[h]=a);else for(p=d[r],m=d[r+1],l=p;m>l;l++)h=v[l],t[h]!==a?(t[h]=a,y&&y.push(h)):i[h]=a};return{algorithm1:c,algorithm2:f,algorithm3:l,algorithm4:p,algorithm5:m,algorithm6:h,algorithm7:g,algorithm8:v,algorithm9:d,algorithm10:y,algorithm11:x,algorithm12:w,algorithm13:b}}var i=t(36),a=t(39),o=i.object;r.name="elementWiseOperations",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.fn=e,this.count=r,this.min=t,this.max=i,this.message="Wrong number of arguments in function "+e+" ("+r+" provided, "+t+(void 0!=i?"-"+i:"")+" expected)",this.stack=(new Error).stack}n.prototype=new Error,n.prototype.constructor=Error,n.prototype.name="ArgumentsError",e.exports=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(this.nodes=e||[],!Array.isArray(this.nodes)||!this.nodes.every(function(e){return e&&e.isNode}))throw new TypeError("Array containing Nodes expected")}var s=n(t(212));return o.prototype=new s,o.prototype.type="ArrayNode",o.prototype.isArrayNode=!0,o.prototype._compile=function(e){var r="array"!==e.math.config().matrix,t=this.nodes.map(function(r){return r._compile(e)});return(r?"math.matrix([":"[")+t.join(",")+(r?"])":"]")},o.prototype.forEach=function(e){for(var r=0;r=r&&(t="("+t+")"),this.name+" = "+t},o.prototype._toTex=function(e){var r=c.getPrecedence(this),t=c.getPrecedence(this.expr),n=this.expr.toTex(e);return null!==t&&r>=t&&(n="\\left("+n+"\\right)"),i.toSymbol(this.name)+":="+n},o}var i=t(369);r.name="AssignmentNode",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!Array.isArray(e))throw new Error("Array expected");this.blocks=e.map(function(e){var r=e&&e.node,t=e&&void 0!==e.visible?e.visible:!0;if(!r||!r.isNode)throw new TypeError('Property "node" must be a Node');if("boolean"!=typeof t)throw new TypeError('Property "visible" must be a boolean');return{node:r,visible:t}})}var o=n(t(212)),s=n(t(9));return a.prototype=new o,a.prototype.type="BlockNode",a.prototype.isBlockNode=!0,a.prototype._compile=function(e){e.ResultSet=s;var r=this.blocks.map(function(r){var t=r.node._compile(e);return r.visible?"results.push("+t+");":t+";"});return"(function () {var results = [];"+r.join("")+"return new ResultSet(results);})()"},a.prototype.forEach=function(e){for(var r=0;r=t)&&(r="("+r+")");var n=this.trueExpr._toString(),a=i.getPrecedence(this.trueExpr);("OperatorNode"===this.trueExpr.type||null!==a&&e>=a)&&(n="("+n+")");var o=this.falseExpr._toString(),s=i.getPrecedence(this.falseExpr);return("OperatorNode"===this.falseExpr.type||null!==s&&e>=s)&&(o="("+o+")"),r+" ? "+n+" : "+o},o.prototype._toTex=function(e){return"\\left\\{\\begin{array}{l l}{"+this.trueExpr.toTex(e)+"}, &\\quad{\\text{if}\\;"+this.condition.toTex(e)+"}\\\\{"+this.falseExpr.toTex(e)+"}, &\\quad{\\text{otherwise}}\\end{array}\\right."},o}var i=(t(369),t(371));r.name="ConditionalNode",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(e,r){if(!(this instanceof o))throw new SyntaxError("Constructor must be called with the new operator");if(r){if("string"!=typeof r)throw new TypeError('String expected for parameter "valueType"');if("string"!=typeof e)throw new TypeError('String expected for parameter "value"');this.value=e,this.valueType=r}else this.value=e+"",this.valueType=i(e);if(!u[this.valueType])throw new TypeError('Unsupported type of value "'+this.valueType+'"')}var s=n(t(212)),u={number:!0,string:!0,"boolean":!0,undefined:!0,"null":!0};return o.prototype=new s,o.prototype.type="ConstantNode",o.prototype.isConstantNode=!0,o.prototype._compile=function(e){switch(this.valueType){case"number":return"bignumber"===e.math.config().number?'math.bignumber("'+this.value+'")':this.value.replace(/^(0*)[0-9]/,function(e,r){return e.substring(r.length)});case"string":return'"'+this.value+'"';case"boolean":return this.value;case"undefined":return this.value;case"null":return this.value;default:throw new TypeError('Unsupported type of constant "'+this.valueType+'"')}},o.prototype.forEach=function(e){},o.prototype.map=function(e){return this.clone()},o.prototype.clone=function(){return new o(this.value,this.valueType)},o.prototype._toString=function(){switch(this.valueType){case"string":return'"'+this.value+'"';default:return this.value}},o.prototype._toTex=function(e){var r,t=this.value;switch(this.valueType){case"string":return'\\mathtt{"'+t+'"}';case"number":return r=t.toLowerCase().indexOf("e"),-1!==r?t.substring(0,r)+"\\cdot10^{"+t.substring(r+1)+"}":t;default:return t}},o}var i=t(189).type;r.name="ConstantNode",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e){return"string"==typeof e}function i(e,r,i,u){function c(e,r,t){if(!(this instanceof c))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');if(!Array.isArray(r)||!r.every(n))throw new TypeError('Array containing strings expected for parameter "params"');if(!t||!t.isNode)throw new TypeError('Node expected for parameter "expr"');if(e in a)throw new Error('Illegal function name, "'+e+'" is a reserved keyword');this.name=e,this.params=r,this.expr=t}var f=i(t(212));return c.prototype=new f,c.prototype.type="FunctionAssignmentNode",c.prototype.isFunctionAssignmentNode=!0,c.prototype._compile=function(e){return this.params.forEach(function(r){e.args[r]=!0}),'scope["'+this.name+'"] = (function () { var fn = function '+this.name+"("+this.params.join(",")+") { if (arguments.length != "+this.params.length+') { throw new SyntaxError("Wrong number of arguments in function '+this.name+' (" + arguments.length + " provided, '+this.params.length+' expected)"); } return '+this.expr._compile(e)+' }; fn.syntax = "'+this.name+"("+this.params.join(", ")+')"; return fn; })();'},c.prototype.forEach=function(e){e(this.expr,"expr",this)},c.prototype.map=function(e){var r=this._ifNode(e(this.expr,"expr",this));return new c(this.name,this.params.slice(0),r)},c.prototype.clone=function(){return new c(this.name,this.params.slice(0),this.expr)},c.prototype._toString=function(){var e=s.getPrecedence(this),r=s.getPrecedence(this.expr),t=this.expr._toString();return null!==r&&e>=r&&(t="("+t+")"),"function "+this.name+"("+this.params.join(", ")+") = "+t},c.prototype._toTex=function(e){var r=s.getPrecedence(this),t=s.getPrecedence(this.expr),n=this.expr.toTex(e);return null!==t&&r>=t&&(n="\\left("+n+"\\right)"),"\\mathrm{"+this.name+"}\\left("+this.params.map(o.toSymbol).join(",")+"\\right):="+n},c}var a=t(370),o=t(369),s=t(371);r.name="FunctionAssignmentNode",r.path="expression.node",r.factory=i},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e||!e.isNode)throw new TypeError('Node expected for parameter "object"');if(!c(r)||!r.every(function(e){return e&&e.isNode}))throw new TypeError('Array containing Nodes expected for parameter "ranges"');this.object=e,this.ranges=r}var o=n(t(212)),s=(n(t(204)),n(t(205)),n(t(10))),u=n(t(4)),c=Array.isArray;return a.prototype=new o,a.prototype.type="IndexNode",a.prototype.isIndexNode=!0,a.prototype._compile=function(e){return this.compileSubset(e)},a.prototype.compileSubset=function(e,r){function t(e){return e&&e.isSymbolNode&&"end"==e.name}var n=!1,i=this.ranges.map(function(e){var r=e.filter(t).length>0;return n=r?r:n,r});e.range=function(e,r,t){return new u(e instanceof s?e.toNumber():e,r instanceof s?r.toNumber():r,t instanceof s?t.toNumber():t)};var a=this.ranges.map(function(r,t){var n=i[t];return r&&r.isRangeNode?n?(e.args.end=!0,"(function () { var end = size["+t+"]; return range( "+r.start._compile(e)+", "+r.end._compile(e)+", "+(r.step?r.step._compile(e):"1")+" );})()"):"range("+r.start._compile(e)+", "+r.end._compile(e)+", "+(r.step?r.step._compile(e):"1")+")":n?(e.args.end=!0,"(function () { var end = size["+t+"]; return "+r._compile(e)+";})()"):r._compile(e)});return n?"(function () { var obj = "+this.object._compile(e)+"; var size = math.size(obj).valueOf(); return math.subset( obj, math.index("+a.join(", ")+") "+(r?", "+r:"")+" );})()":"math.subset("+this.object._compile(e)+",math.index("+a.join(", ")+")"+(r?", "+r:"")+")"},a.prototype.forEach=function(e){e(this.object,"object",this);for(var r=0;r=o?[!0]:[!1];case 2:var c,f=a.getPrecedence(r[0]),l=a.isAssociativeWith(e,r[0]);c=null===f?!1:f!==n||"right"!==i||l?n>f?!0:!1:!0;var p,m=a.getPrecedence(r[1]),h=a.isAssociativeWith(e,r[1]);if(p=null===m?!1:m!==n||"left"!==i||h?n>m?!0:!1:!0,t){var u=e.getIdentifier(),g=e.args[0].getIdentifier(),v=e.args[1].getIdentifier();null!==f&&(a.properties[n][u].latexLeftParens===!1&&(c=!1),a.properties[f][g].latexParens===!1&&(c=!1)),null!==m&&(a.properties[n][u].latexRightParens===!1&&(p=!1),a.properties[m][v].latexParens===!1&&(p=!1))}return[c,p];default:var d=[];return r.forEach(function(){d.push(!0)}),d}}{var f=n(t(212));n(t(199)),n(t(205)),n(t(203))}return u.prototype=new f,u.prototype.type="OperatorNode",u.prototype.isOperatorNode=!0,u.prototype._compile=function(e){if(!(this.fn in e.math))throw new Error("Function "+this.fn+' missing in provided namespace "math"');var r=this.args.map(function(r){return r._compile(e)});return"math."+this.fn+"("+r.join(", ")+")"},u.prototype.forEach=function(e){for(var r=0;r3)throw new Error("Too many arguments");this.start=e,this.end=r,this.step=t||null}var s=n(t(212));return o.prototype=new s,o.prototype.type="RangeNode",o.prototype.isRangeNode=!0,o.prototype._compile=function(e){return"math.range("+this.start._compile(e)+", "+this.end._compile(e)+(this.step?", "+this.step._compile(e):"")+")"},o.prototype.forEach=function(e){e(this.start,"start",this),e(this.end,"end",this),this.step&&e(this.step,"step",this)},o.prototype.map=function(e){return new o(this._ifNode(e(this.start,"start",this)),this._ifNode(e(this.end,"end",this)),this.step&&this._ifNode(e(this.step,"step",this)))},o.prototype.clone=function(){return new o(this.start,this.end,this.step&&this.step)},o.prototype._toString=function(){var e,r=i.getPrecedence(this),t=this.start._toString(),n=i.getPrecedence(this.start);if(null!==n&&r>=n&&(t="("+t+")"),e=t,this.step){var a=this.step._toString(),o=i.getPrecedence(this.step);null!==o&&r>=o&&(a="("+a+")"),e+=":"+a}var s=this.end._toString(),u=i.getPrecedence(this.end);return null!==u&&r>=u&&(s="("+s+")"),e+=":"+s},o.prototype._toTex=function(e){var r=this.start.toTex(e);return this.step&&(r+=":"+this.step.toTex(e)),r+=":"+this.end.toTex(e)},o}var i=t(371);r.name="RangeNode",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a,o){function s(e){if(!(this instanceof s))throw new SyntaxError("Constructor must be called with the new operator");if("string"!=typeof e)throw new TypeError('String expected for parameter "name"');this.name=e}function u(e){throw new Error("Undefined symbol "+e)}var c=n(t(212)),f=n(t(7));return s.prototype=new c,s.prototype.type="SymbolNode",s.prototype.isSymbolNode=!0,s.prototype._compile=function(e){return e.undef=u,e.Unit=f,this.name in e.args?this.name:this.name in e.math?'("'+this.name+'" in scope ? scope["'+this.name+'"] : math["'+this.name+'"])':'("'+this.name+'" in scope ? scope["'+this.name+'"] : '+(f.isValuelessUnit(this.name)?'new Unit(null, "'+this.name+'")':'undef("'+this.name+'")')+")"},s.prototype.forEach=function(e){},s.prototype.map=function(e){return this.clone()},s.prototype.clone=function(){return new s(this.name)},s.prototype._toString=function(){return this.name},s.prototype._toTex=function(e){var r=!1;"undefined"==typeof o[this.name]&&f.isValuelessUnit(this.name)&&(r=!0);var t=i.toSymbol(this.name,r);return"\\"===t[0]?t:" "+t},s}var i=t(369);r.name="SymbolNode",r.path="expression.node",r.math=!0,r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){function a(e,r){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");if(!e||!e.isIndexNode)throw new TypeError('Expected IndexNode for parameter "index"');if(!r||!r.isNode)throw new TypeError('Expected Node for parameter "expr"');this.index=e,this.expr=r}{var o=n(t(212));n(t(201))}return a.prototype=new o,a.prototype.type="UpdateNode",a.prototype.isUpdateNode=!0,a.prototype._compile=function(e){var r=this.index.objectName()in e.args?this.name+" = ":'scope["'+this.index.objectName()+'"]',t=this.index.compileSubset(e,this.expr._compile(e));return r+" = "+t},a.prototype.forEach=function(e){e(this.index,"index",this),e(this.expr,"expr",this)},a.prototype.map=function(e){return new a(this._ifNode(e(this.index,"index",this)),this._ifNode(e(this.expr,"expr",this)))},a.prototype.clone=function(){return new a(this.index,this.expr)},a.prototype._toString=function(){return this.index._toString()+" = "+this.expr._toString()},a.prototype._toTex=function(e){return this.index.toTex(e)+":="+this.expr.toTex(e)},a}r.name="UpdateNode",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function i(r,t){var n=t.re*t.re+t.im*t.im;return 0!=n?new e.Complex((r.re*t.re+r.im*t.im)/n,(r.im*t.re-r.re*t.im)/n):new e.Complex(0!=r.re?r.re/0:0,0!=r.im?r.im/0:0)}var a=n("divideScalar",{"number, number":function(e,r){return e/r},"Complex, Complex":i,"BigNumber, BigNumber":function(e,r){return e.div(r)},"Unit, number":function(e,r){var t=e.clone();return t.value=(null===t.value?t._normalize(1):t.value)/r,t}});return a}r.name="divideScalar",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(207)),s=n(t(71)),u=n(t(79)),c=n(t(46)),f=n(t(372)),l=e.SparseMatrix,p=e.DenseMatrix,m=i("backwardSubstitution",{"Matrix, Array | Matrix":function(e,r){switch(e.storage()){case"dense":return h(e,r);case"sparse":return g(e,r)}},"Array, Array | Matrix":function(e,r){var t=a(e),n=m(t,r);return n.valueOf()}}),h=function(e,r){r=f(e,r);for(var t=e._size[0],n=e._size[1],i=new Array(t),a=e._data,l=n-1;l>=0;l--){var m,h=r[l]||0;if(c(h,0))m=0;else{var g=a[l][l];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=o(h,g);for(var v=l-1;v>=0;v--)r[v]=u(r[v]||0,s(m,a[v][l]))}i[l]=[m]}return new p({data:i,size:[t,1]})},g=function(e,r){r=f(e,r);var t,n,i=e._size[0],a=e._size[1],p=e._values,m=e._index,h=e._ptr,g=[],v=[],d=[];d.push(0);for(var y=a-1;y>=0;y--){var x=r[y]||0;if(!c(x,0)){var w=0,b=h[y],N=h[y+1];for(n=N-1;n>=b;n--)if(t=m[n],t===y)w=p[n];else if(y>t)break;if(c(w,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var E=o(x,w);n>=b;n--)t=m[n],r[t]=u(r[t]||0,s(E,p[n]));c(E,0)||(g.unshift(E),v.unshift(y))}}return d.push(g.length),new l({values:g,index:v,ptr:d,size:[i,1]})};return m}r.name="backwardSubstitution",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(40)),o=n(t(207)),s=n(t(71)),u=n(t(79)),c=n(t(46)),f=n(t(372)),l=e.SparseMatrix,p=e.DenseMatrix,m=i("forwardSubstitution",{"Matrix, Array | Matrix":function(e,r){switch(e.storage()){case"dense":return h(e,r);case"sparse":return g(e,r)}},"Array, Array | Matrix":function(e,r){var t=a(e),n=m(t,r);return n.valueOf()}}),h=function(e,r){r=f(e,r);for(var t=e._size[0],n=e._size[1],i=new Array(t),a=e._data,l=0;n>l;l++){var m,h=r[l]||0;if(c(h,0))m=0;else{var g=a[l][l];if(c(g,0))throw new Error("Linear system cannot be solved since matrix is singular");m=o(h,g);for(var v=l+1;t>v;v++)r[v]=u(r[v]||0,s(m,a[v][l]))}i[l]=[m]}return new p({data:i,size:[t,1]})},g=function(e,r){r=f(e,r);var t,n,i=e._size[0],a=e._size[1],p=e._values,m=e._index,h=e._ptr,g=[],v=[],d=[];d.push(0);for(var y=0;a>y;y++){var x=r[y]||0;if(!c(x,0)){var w=0,b=h[y+1];for(n=h[y];b>n;n++)if(t=m[n],t===y)w=p[n];else if(t>y)break;if(c(w,0))throw new Error("Linear system cannot be solved since matrix is singular");for(var N=o(x,w);b>n;n++)t=m[n],r[t]=u(r[t]||0,s(N,p[n]));c(N,0)||(g.push(N),v.push(y))}}return d.push(g.length),new l({values:g,index:v,ptr:d,size:[i,1]})};return m}r.name="forwardSubstitution",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){var i=n("multiplyScalar",{"number, number":function(e,r){return e*r},"Complex, Complex":function(r,t){return new e.Complex(r.re*t.re-r.im*t.im,r.re*t.im+r.im*t.re)},"BigNumber, BigNumber":function(e,r){return e.times(r)},"number, Unit":function(e,r){var t=r.clone();return t.value=null===t.value?t._normalize(e):t.value*e,t},"Unit, number":function(e,r){var t=e.clone();return t.value=null===t.value?t._normalize(r):t.value*r,t}});return i}r.name="multiplyScalar",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){function o(r){if(!l.hasOwnProperty(r))throw new Error("Unknown distribution "+r);var t=Array.prototype.slice.call(arguments,1),n=l[r].apply(this,t);return function(r){var t={random:function(r,t,a){var s,c,l;if(arguments.length>3)throw new i("random",arguments.length,0,3);if(1===arguments.length?f(r)?s=r:l=r:2===arguments.length?f(r)?(s=r,l=t):(c=r,l=t):(s=r,c=t,l=a),void 0===l&&(l=1),void 0===c&&(c=0),void 0!==s){var p=o(s.valueOf(),c,l,n);return s instanceof e.Matrix?u(p):p}return n(c,l)},randomInt:function(r,t,n){var s,c,l;if(arguments.length>3||arguments.length<1)throw new i("randomInt",arguments.length,1,3);if(1===arguments.length?f(r)?s=r:l=r:2===arguments.length?f(r)?(s=r,l=t):(c=r,l=t):(s=r,c=t,l=n),void 0===c&&(c=0),void 0!==s){var p=o(s.valueOf(),c,l,a);return s instanceof e.Matrix?u(p):p}return a(c,l)},pickRandom:function(r){if(1!==arguments.length)throw new i("pickRandom",arguments.length,1);if(r instanceof e.Matrix)r=r.valueOf();else if(!Array.isArray(r))throw new TypeError("Unsupported type of value in function pickRandom");if(c.size(r).length>1)throw new Error("Only one dimensional vectors supported");return r[Math.floor(Math.random()*r.length)]}},n=function(e,t){return e+r()*(t-e)},a=function(e,t){return Math.floor(e+r()*(t-e))},o=function(e,r,t,n){var i,a,s=[];if(e=e.slice(0),e.length>1)for(a=0,i=e.shift();i>a;a++)s.push(o(e,r,t,n));else for(a=0,i=e.shift();i>a;a++)s.push(n(r,t));return s};return t}(n)}var s=n(t(2)),u=n(t(40)),c=t(37),f=s.isCollection,l={uniform:function(){return Math.random},normal:function(){return function(){for(var e,r,t=-1;0>t||t>1;)e=Math.random(),r=Math.random(),t=1/6*Math.pow(-2*Math.log(e),.5)*Math.cos(2*Math.PI*r)+.5;return t}}};return o}var i=t(194);r.name="distribution",r.factory=n},function(e,r,t){"use strict";function n(e,r,t,n){function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator")}function o(e){for(var r in e)if(e.hasOwnProperty(r)&&r in i)throw new Error('Scope contains an illegal symbol, "'+r+'" is a reserved keyword')}function s(e){var r=Object.create(e);for(var t in e)if(e.hasOwnProperty(t)){var n=e[t];n&&"function"==typeof n.transform&&(r[t]=n.transform)}return r}return a.prototype.eval=function(){throw new Error("Node.eval is deprecated. Use Node.compile(math).eval([scope]) instead.")},a.prototype.type="Node",a.prototype.isNode=!0,a.prototype.compile=function(e){if(!(e instanceof Object))throw new TypeError("Object expected for parameter math");var r={math:s(e),args:{},_validateScope:o},t=this._compile(r),n=Object.keys(r).map(function(e){return" var "+e+' = defs["'+e+'"];'}),i=n.join(" ")+'return { "eval": function (scope) { if (scope) _validateScope(scope); scope = scope || {}; return '+t+"; }};",a=new Function("defs",i);return a(r)},a.prototype._compile=function(e){throw new Error("Cannot compile a Node interface")},a.prototype.forEach=function(e){throw new Error("Cannot run forEach on a Node interface")},a.prototype.map=function(e){throw new Error("Cannot run map on a Node interface")},a.prototype._ifNode=function(e){if(!e||!e.isNode)throw new TypeError("Callback function must return a Node");return e},a.prototype.traverse=function(e){function r(e,t){e.forEach(function(e,n,i){t(e,n,i),r(e,t)})}e(this,null,null),r(this,e)},a.prototype.transform=function(e){function r(e,t){return e.map(function(e,n,i){var a=t(e,n,i);return a!==e?a:r(e,t)})}var t=e(this,null,null);return t!==this?t:r(this,e)},a.prototype.filter=function(e){var r=[];return this.traverse(function(t,n,i){e(t,n,i)&&r.push(t)}),r},a.prototype.find=function(){throw new Error("Function Node.find is deprecated. Use Node.filter instead.")},a.prototype.match=function(){throw new Error("Function Node.match is deprecated. See functions Node.filter, Node.transform, Node.traverse.")},a.prototype.clone=function(){throw new Error("Cannot clone a Node interface")},a.prototype.toString=function(){return this._toString()},a.prototype._toString=function(){if("Node"===this.type)return"";throw new Error("_toString not implemented for "+this.type)},a.prototype.toTex=function(e){var r;if("object"==typeof e)"FunctionNode"===this.type&&e.hasOwnProperty(this.name)&&(r=e[this.name](this,e));else if("function"==typeof e)r=e(this,e);else if("undefined"!=typeof e)throw new TypeError("Object or function expected as callback");return"undefined"!=typeof r?r:this._toTex(e)},a.prototype._toTex=function(){if("Node"===this.type)return"";throw new Error("_toTex not implemented for "+this.type)},a.prototype.getIdentifier=function(){return this.type},a}var i=t(370);r.name="Node",r.path="expression.node",r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(102));return o.transform=a("concat",{"...any":function(r){var t=r.length-1,n=r[t];"number"==typeof n?r[t]=n-1:n instanceof e.BigNumber&&(r[t]=n.minus(1)); + +try{return o.apply(null,r)}catch(a){throw i(a)}}}),o.transform}var i=t(373).transform;r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){{var a=n(t(176));n(t(205))}return a.transform=function(e,r,t){var n,i;if(e[0]&&(n=e[0].compile(r).eval(t)),e[1])if(e[1]&&e[1].isSymbolNode)i=e[1].compile(r).eval(t);else{var o=t||{},s=e[1].filter(function(e){return!(!e||!e.isSymbolNode||e.name in r||e.name in o)})[0],u=Object.create(o),c=e[1].compile(r);if(!s)throw new Error("No undefined variable found in filter equation");var f=s.name;i=function(e){return u[f]=e,c.eval(u)}}return a(n,i)},a.transform.rawArgs=!0,a.transform}r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(182));return a.transform=i("forEach",{"Array | Matrix, function":function(e,r){var t=function(n,i){Array.isArray(n)?n.forEach(function(e,r){t(e,i.concat(r+1))}):r(n,i,e)};t(e.valueOf(),[])}}),a.transform}r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(123));return a.transform=function(){for(var r=[],t=0,n=arguments.length;n>t;t++){var i=arguments[t];if(i instanceof e.Range)i.start--,i.end-=i.step>0?0:2;else if("number"==typeof i)i--;else{if(!(i instanceof e.BigNumber))throw new TypeError("Ranges must be a Number or Range");i=i.toNumber()-1}r[t]=i}var a=new e.Index;return e.Index.apply(a,r),a},a.transform}r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(178)),s=n(t(40));return o.transform=a("max",{"Array, function":function(e,r){return i(e,r,e)},"Matrix, function":function(e,r){return s(i(e.valueOf(),r,e))}}),o.transform}function i(e,r,t){function n(e,i){return Array.isArray(e)?e.map(function(e,r){return n(e,i.concat(r+1))}):r(e,i,t)}return n(e,[])}r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(135)),s=n(t(2)).isCollection;return o.transform=a("max",{"...any":function(r){if(2==r.length&&s(r[0])){var t=r[1];"number"==typeof t?r[1]=t-1:t instanceof e.BigNumber&&(r[1]=t.minus(1))}try{return o.apply(null,r)}catch(n){throw i(n)}}}),o.transform}var i=t(373).transform;r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(136)),s=n(t(2)).isCollection;return o.transform=a("mean",{"...any":function(r){if(2==r.length&&s(r[0])){var t=r[1];"number"==typeof t?r[1]=t-1:t instanceof e.BigNumber&&(r[1]=t.minus(1))}try{return o.apply(null,r)}catch(n){throw i(n)}}}),o.transform}var i=t(373).transform;r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(138)),s=n(t(2)).isCollection;return o.transform=a("min",{"...any":function(r){if(2==r.length&&s(r[0])){var t=r[1];"number"==typeof t?r[1]=t-1:t instanceof e.BigNumber&&(r[1]=t.minus(1))}try{return o.apply(null,r)}catch(n){throw i(n)}}}),o.transform}var i=t(373).transform;r.factory=n},function(e,r,t){"use strict";function n(e,r,n,i){var a=n(t(111));return a.transform=i("range",{"...any":function(e){var r=e.length-1,t=e[r];return"boolean"!=typeof t&&e.push(!0),a.apply(null,e)}}),a.transform}r.factory=n},function(e,r,t){"use strict";function n(e,r,n,a){var o=n(t(115));return o.transform=a("subset",{"...any":function(e){try{return o.apply(null,e)}catch(r){throw i(r)}}}),o.transform}var i=t(373).transform;r.factory=n},function(e,r,t){e.exports={name:"e",category:"Constants",syntax:["e"],description:"Euler's number, the base of the natural logarithm. Approximately equal to 2.71828",examples:["e","e ^ 2","exp(2)","log(e)"],seealso:["exp"]}},function(e,r,t){e.exports={name:"false",category:"Constants",syntax:["false"],description:"Boolean value false",examples:["false"],seealso:["true"]}},function(e,r,t){e.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:[]}},function(e,r,t){e.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:[]}},function(e,r,t){e.exports={name:"LN2",category:"Constants",syntax:["LN2"],description:"Returns the natural logarithm of 2, approximately equal to 0.693",examples:["LN2","log(2)"],seealso:[]}},function(e,r,t){e.exports={name:"LN10",category:"Constants",syntax:["LN10"],description:"Returns the natural logarithm of 10, approximately equal to 2.302",examples:["LN10","log(10)"],seealso:[]}},function(e,r,t){e.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:[]}},function(e,r,t){e.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:[]}},function(e,r,t){e.exports={name:"NaN",category:"Constants",syntax:["NaN"],description:"Not a number",examples:["NaN","0 / 0"],seealso:[]}},function(e,r,t){e.exports={name:"null",category:"Constants",syntax:["null"],description:"Value null",examples:["null"],seealso:["true","false"]}},function(e,r,t){e.exports={name:"pi",category:"Constants",syntax:["pi"],description:"The number pi is a mathematical constant that is the ratio of a circle's circumference to its diameter, and is approximately equal to 3.14159",examples:["pi","sin(pi/2)"],seealso:["tau"]}},function(e,r,t){e.exports={name:"phi",category:"Constants",syntax:["phi"],description:"Phi is the golden ratio. Two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities. Phi is defined as `(1 + sqrt(5)) / 2` and is approximately 1.618034...",examples:["tau"],seealso:[]}},function(e,r,t){e.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:[]}},function(e,r,t){e.exports={name:"SQRT2",category:"Constants",syntax:["SQRT2"],description:"Returns the square root of 2, approximately equal to 1.414",examples:["SQRT2","sqrt(2)"],seealso:[]}},function(e,r,t){e.exports={name:"tau",category:"Constants",syntax:["tau"],description:"Tau is the ratio constant of a circle's circumference to radius, equal to 2 * pi, approximately 6.2832.",examples:["tau","2 * pi"],seealso:["pi"]}},function(e,r,t){e.exports={name:"true",category:"Constants",syntax:["true"],description:"Boolean value true",examples:["true"],seealso:["false"]}},function(e,r,t){e.exports={name:"version",category:"Constants",syntax:["version"],description:"A string with the version number of math.js",examples:["version"],seealso:[]}},function(e,r,t){e.exports={name:"abs",category:"Arithmetic",syntax:["abs(x)"],description:"Compute the absolute value.",examples:["abs(3.5)","abs(-4.2)"],seealso:["sign"]}},function(e,r,t){e.exports={name:"add",category:"Operators",syntax:["x + y","add(x, y)"],description:"Add two values.",examples:["a = 2.1 + 3.6","a - 3.6","3 + 2i",'"hello" + " world"',"3 cm + 2 inch"],seealso:["subtract"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.exports={name:"divide",category:"Operators",syntax:["x / y","divide(x, y)"],description:"Divide two values.",examples:["a = 2 / 3","a * 3","4.5 / 2","3 + 4 / 2","(3 + 4) / 2","18 km / 4.5"],seealso:["multiply"]}},function(e,r,t){e.exports={name:"dotDivide",category:"Operators",syntax:["x ./ y","dotDivide(x, y)"],description:"Divide two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a ./ b"],seealso:["multiply","dotMultiply","divide"]}},function(e,r,t){e.exports={name:"dotMultiply",category:"Operators",syntax:["x .* y","dotMultiply(x, y)"],description:"Multiply two values element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","b = [2, 1, 1; 3, 2, 5]","a .* b"],seealso:["multiply","divide","dotDivide"]}},function(e,r,t){e.exports={name:"dotpow",category:"Operators",syntax:["x .^ y","dotpow(x, y)"],description:"Calculates the power of x to y element wise.",examples:["a = [1, 2, 3; 4, 5, 6]","a .^ 2"],seealso:["pow"]}},function(e,r,t){e.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:["pow","log"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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 ^ 4","log(10000, 10)","log(10000) / log(10)","b = log(1024, 2)","2 ^ b"],seealso:["exp","log10"]}},function(e,r,t){e.exports={name:"log10",category:"Arithmetic",syntax:["log10(x)"],description:"Compute the 10-base logarithm of a value.",examples:["log10(0.00001)","log10(10000)","10 ^ 4","log(10000) / log(10)","log(10000, 10)"],seealso:["exp","log"]}},function(e,r,t){e.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:["divide"]}},function(e,r,t){e.exports={name:"multiply",category:"Operators",syntax:["x * y","multiply(x, y)"],description:"multiply two values.",examples:["a = 2.1 * 3.4","a / 3.4","2 * 3 + 4","2 * (3 + 4)","3 * 2.1 km"],seealso:["divide"]}},function(e,r,t){e.exports={name:"norm",category:"Arithmetic",syntax:["norm(x)","norm(x, p)"],description:"Calculate the norm of a number, vector or matrix.",examples:["abs(-3.5)","norm(-3.5)","norm(3 - 4i))","norm([1, 2, -3], Infinity)","norm([1, 2, -3], -Infinity)","norm([3, 4], 2)","norm([[1, 2], [3, 4]], 1)","norm([[1, 2], [3, 4]], 'inf')","norm([[1, 2], [3, 4]], 'fro')"]}},function(e,r,t){e.exports={name:"nthRoot",category:"Arithmetic",syntax:["nthRoot(a)","nthRoot(a, root)"],description:'Calculate the nth root of a value. The principal nth root of a positive real number A, is the positive real solution of the equation "x^root = A".',examples:["4 ^ 3","nthRoot(64, 3)","nthRoot(9, 2)","sqrt(9)"],seealso:["sqrt","pow"]}},function(e,r,t){e.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:["multiply"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.exports={name:"sqrt",category:"Arithmetic",syntax:["sqrt(x)"],description:"Compute the square root value. If x = y * y, then y is the square root of x.",examples:["sqrt(25)","5 * 5","sqrt(-1)"],seealso:["square","multiply"]}},function(e,r,t){e.exports={name:"square",category:"Arithmetic",syntax:["square(x)"],description:"Compute the square of a value. The square of x is x * x.",examples:["square(3)","sqrt(9)","3^2","3 * 3"],seealso:["multiply","pow","sqrt","cube"]}},function(e,r,t){e.exports={name:"subtract",category:"Operators",syntax:["x - y","subtract(x, y)"],description:"subtract two values.",examples:["a = 5.3 - 2","a + 2","2/3 - 1/6","2 * 3 - 3","2.1 km - 500m"],seealso:["add"]}},function(e,r,t){e.exports={name:"unaryMinus",category:"Operators",syntax:["-x","unaryMinus(x)"],description:"Inverse the sign of a value. Converts booleans and strings to numbers.",examples:["-4.5","-(-5.6)",'-"22"'],seealso:["add","subtract","unaryPlus"]}},function(e,r,t){e.exports={name:"unaryPlus",category:"Operators",syntax:["+x","unaryPlus(x)"],description:"Converts booleans and strings to numbers.",examples:["+true",'+"2"'],seealso:["add","subtract","unaryMinus"]}},function(e,r,t){e.exports={name:"xgcd",category:"Arithmetic",syntax:["xgcd(a, b)"],description:"Calculate the extended greatest common divisor for two values",examples:["xgcd(8, 12)","gcd(8, 12)","xgcd(36163, 21199)"],seealso:["gcd","lcm"]}},function(e,r,t){e.exports={name:"bitAnd",category:"Bitwise",syntax:["x & y","bitAnd(x, y)"],description:"Bitwise AND operation. Performs the logical AND operation on each pair of the corresponding bits of the two given values by multiplying them. If both bits in the compared position are 1, the bit in the resulting binary representation is 1, otherwise, the result is 0",examples:["5 & 3","bitAnd(53, 131)","[1, 12, 31] & 42"],seealso:["bitNot","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,r,t){e.exports={name:"bitNot",category:"Bitwise",syntax:["~x","bitNot(x)"],description:"Bitwise NOT operation. Performs a logical negation on each bit of the given value. Bits that are 0 become 1, and those that are 1 become 0.",examples:["~1","~2","bitNot([2, -3, 4])"],seealso:["bitAnd","bitOr","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,r,t){e.exports={name:"bitOr",category:"Bitwise",syntax:["x | y","bitOr(x, y)"],description:"Bitwise OR operation. Performs the logical inclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if the first bit is 1 or the second bit is 1 or both bits are 1, otherwise, the result is 0.",examples:["5 | 3","bitOr([1, 2, 3], 4)"],seealso:["bitAnd","bitNot","bitXor","leftShift","rightArithShift","rightLogShift"]}},function(e,r,t){e.exports={name:"bitXor",category:"Bitwise",syntax:["bitXor(x, y)"],description:"Bitwise XOR operation, exclusive OR. Performs the logical exclusive OR operation on each pair of corresponding bits of the two given values. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1.",examples:["bitOr(1, 2)","bitXor([2, 3, 4], 4)"],seealso:["bitAnd","bitNot","bitOr","leftShift","rightArithShift","rightLogShift"]}},function(e,r,t){e.exports={name:"leftShift",category:"Bitwise",syntax:["x << y","leftShift(x, y)"],description:"Bitwise left logical shift of a value x by y number of bits.",examples:["4 << 1","8 >> 1"],seealso:["bitAnd","bitNot","bitOr","bitXor","rightArithShift","rightLogShift"]}},function(e,r,t){e.exports={name:"rightArithShift",category:"Bitwise",syntax:["x >> y","leftShift(x, y)"],description:"Bitwise right arithmetic shift of a value x by y number of bits.",examples:["8 >> 1","4 << 1","-12 >> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightLogShift"]}},function(e,r,t){e.exports={name:"rightLogShift",category:"Bitwise",syntax:["x >> y","leftShift(x, y)"],description:"Bitwise right logical shift of a value x by y number of bits.",examples:["8 >>> 1","4 << 1","-12 >>> 2"],seealso:["bitAnd","bitNot","bitOr","bitXor","leftShift","rightArithShift"]}},function(e,r,t){e.exports={name:"arg",category:"Complex",syntax:["arg(x)"],description:"Compute the argument of a complex value. If x = a+bi, the argument is computed as atan2(b, a).",examples:["arg(2 + 2i)","atan2(3, 2)","arg(2 + 3i)"],seealso:["re","im","conj","abs"]}},function(e,r,t){e.exports={name:"conj",category:"Complex",syntax:["conj(x)"],description:"Compute the complex conjugate of a complex value. If x = a+bi, the complex conjugate is a-bi.",examples:["conj(2 + 3i)","conj(2 - 3i)","conj(-5.2i)"],seealso:["re","im","abs","arg"]}},function(e,r,t){e.exports={name:"re",category:"Complex",syntax:["re(x)"],description:"Get the real part of a complex number.",examples:["re(2 + 3i)","im(2 + 3i)","re(-5.2i)","re(2.4)"],seealso:["im","conj","abs","arg"]}},function(e,r,t){e.exports={name:"im",category:"Complex",syntax:["im(x)"],description:"Get the imaginary part of a complex number.",examples:["im(2 + 3i)","re(2 + 3i)","im(-5.2i)","im(2.4)"],seealso:["re","conj","abs","arg"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.exports={name:"matrix",category:"Type",syntax:["[]","[a1, b1, ...; a2, b2, ...]","matrix()",'matrix("dense")',"matrix([...])"],description:"Create a matrix.",examples:["[]","[1, 2, 3]","[1, 2, 3; 4, 5, 6]","matrix()","matrix([3, 4])",'matrix([3, 4; 5, 6], "sparse")','matrix([3, 4; 5, 6], "sparse", "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","sparse"]}},function(e,r,t){e.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])",'number("52cm", "m")'],seealso:["bignumber","boolean","complex","index","matrix","string","unit"]}},function(e,r,t){e.exports={name:"sparse",category:"Type",syntax:["sparse()","sparse([a1, b1, ...; a1, b2, ...])",'sparse([a1, b1, ...; a1, b2, ...], "number")'],description:"Create a sparse matrix.",examples:["sparse()","sparse([3, 4; 5, 6])",'sparse([3, 0; 5, 0], "number")'],seealso:["bignumber","boolean","complex","index","number","string","unit","matrix"]}},function(e,r,t){e.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"]}},function(e,r,t){e.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"]}},function(e,r,t){e.exports={name:"eval",category:"Expression",syntax:["eval(expression)","eval([expr1, expr2, expr3, ...])"],description:"Evaluate an expression or an array with expressions.",examples:['eval("2 + 3")','eval("sqrt(" + 4 + ")")'],seealso:[]}},function(e,r,t){e.exports={name:"help",category:"Expression",syntax:["help(object)","help(string)"],description:"Display documentation on a function or data type.",examples:["help(sqrt)",'help("complex")'],seealso:[]}},function(e,r,t){e.exports={name:"and",category:"Logical",syntax:["x and y","and(x, y)"],description:"Logical and. Test whether two values are both defined with a nonzero/nonempty value.",examples:["true and false","true and true","2 and 4"],seealso:["not","or","xor"]}},function(e,r,t){e.exports={name:"not",category:"Logical",syntax:["!x","not x","not(x)"],description:"Logical not. Flips the boolean value of given argument.",examples:["!true","not false","!2","!0"],seealso:["and","or","xor"]}},function(e,r,t){e.exports={name:"or",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical or. Test if at least one value is defined with a nonzero/nonempty value.",examples:["true or false","false or false","0 or 4"],seealso:["not","and","xor"]}},function(e,r,t){e.exports={name:"xor",category:"Logical",syntax:["x or y","or(x, y)"],description:"Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.",examples:["true xor false","false xor false","true xor true","0 or 4"],seealso:["not","and","or"]}},function(e,r,t){e.exports={name:"concat",category:"Matrix",syntax:["concat(A, B, C, ...)","concat(A, B, C, ..., dim)"],description:"Concatenate matrices. By default, the matrices are concatenated by the last dimension. The dimension on which to concatenate can be provided as last argument.",examples:["A = [1, 2; 5, 6]","B = [3, 4; 7, 8]","concat(A, B)","concat(A, B, 1)","concat(A, B, 2)"],seealso:["det","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"cross",category:"Matrix",syntax:["cross(A, B)"],description:"Calculate the cross product for two vectors in three dimensional space.",examples:["cross([1, 1, 0], [0, 1, 1])","cross([3, -3, 1], [4, 9, 2])","cross([2, 3, 4], [5, 6, 7])"],seealso:["multiply","dot"]}},function(e,r,t){e.exports={name:"det",category:"Matrix",syntax:["det(x)"],description:"Calculate the determinant of a matrix",examples:["det([1, 2; 3, 4])","det([-2, 2, 3; -1, 1, 3; 2, 0, -1])"],seealso:["concat","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"diag",category:"Matrix",syntax:["diag(x)","diag(x, k)"],description:"Create a diagonal matrix or retrieve the diagonal of a matrix. When x is a vector, a matrix with the vector values on the diagonal will be returned. When x is a matrix, a vector with the diagonal values of the matrix is returned. When k is provided, the k-th diagonal will be filled in or retrieved, if k is positive, the values are placed on the super diagonal. When k is negative, the values are placed on the sub diagonal.",examples:["diag(1:3)","diag(1:3, 1)","a = [1, 2, 3; 4, 5, 6; 7, 8, 9]","diag(a)"],seealso:["concat","det","eye","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"dot",category:"Matrix",syntax:["dot(A, B)"],description:"Calculate the dot product of two vectors. The dot product of A = [a1, a2, a3, ..., an] and B = [b1, b2, b3, ..., bn] is defined as dot(A, B) = a1 * b1 + a2 * b2 + a3 * b3 + ... + an * bn",examples:["dot([2, 4, 1], [2, 2, 3])","[2, 4, 1] * [2, 2, 3]"],seealso:["multiply","cross"]}},function(e,r,t){e.exports={name:"eye",category:"Matrix",syntax:["eye(n)","eye(m, n)","eye([m, n])","eye"],description:"Returns the identity matrix with size m-by-n. The matrix has ones on the diagonal and zeros elsewhere.",examples:["eye(3)","eye(3, 5)","a = [1, 2, 3; 4, 5, 6]","eye(size(a))"],seealso:["concat","det","diag","inv","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"flatten",category:"Matrix",syntax:["flatten(x)"],description:"Flatten a multi dimensional matrix into a single dimensional matrix.",examples:["a = [1, 2, 3; 4, 5, 6]","size(a)","b = flatten(a)","size(b)"],seealso:["concat","resize","size","squeeze"]}},function(e,r,t){e.exports={name:"inv",category:"Matrix",syntax:["inv(x)"],description:"Calculate the inverse of a matrix",examples:["inv([1, 2; 3, 4])","inv(4)","1 / 4"],seealso:["concat","det","diag","eye","ones","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"ones",category:"Matrix",syntax:["ones(m)","ones(m, n)","ones(m, n, p, ...)","ones([m])","ones([m, n])","ones([m, n, p, ...])","ones"],description:"Create a matrix containing ones.",examples:["ones(3)","ones(3, 5)","ones([2,3]) * 4.5","a = [1, 2, 3; 4, 5, 6]","ones(size(a))"],seealso:["concat","det","diag","eye","inv","range","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"range",category:"Type",syntax:["start:end","start:step:end","range(start, end)","range(start, end, step)","range(string)"],description:"Create a range. Lower bound of the range is included, upper bound is excluded.",examples:["1:5","3:-1:-3","range(3, 7)","range(0, 12, 2)",'range("4:10")',"a = [1, 2, 3, 4; 5, 6, 7, 8]","a[1:2, 1:2]"],seealso:["concat","det","diag","eye","inv","ones","size","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"resize",category:"Matrix",syntax:["resize(x, size)","resize(x, size, defaultValue)"],description:"Resize a matrix.",examples:["resize([1,2,3,4,5], [3])","resize([1,2,3], [5])","resize([1,2,3], [5], -1)","resize(2, [2, 3])",'resize("hello", [8], "!")'],seealso:["size","subset","squeeze"]}},function(e,r,t){e.exports={name:"size",category:"Matrix",syntax:["size(x)"],description:"Calculate the size of a matrix.",examples:["size(2.3)",'size("hello world")',"a = [1, 2; 3, 4; 5, 6]","size(a)","size(1:6)"],seealso:["concat","det","diag","eye","inv","ones","range","squeeze","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"squeeze",category:"Matrix",syntax:["squeeze(x)"],description:"Remove inner and outer singleton dimensions from a matrix.",examples:["a = zeros(3,2,1)","size(squeeze(a))","b = zeros(1,1,3)","size(squeeze(b))"],seealso:["concat","det","diag","eye","inv","ones","range","size","subset","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"subset",category:"Matrix",syntax:["value(index)","value(index) = replacement","subset(value, [index])","subset(value, [index], replacement)"],description:"Get or set a subset of a matrix or string. Indexes are one-based. Both the ranges lower-bound and upper-bound are included.",examples:["d = [1, 2; 3, 4]","e = []","e[1, 1:2] = [5, 6]","e[2, :] = [7, 8]","f = d * e","f[2, 1]","f[:, 1]"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","trace","transpose","zeros"]}},function(e,r,t){e.exports={name:"trace",category:"Matrix",syntax:["trace(A)"],description:"Calculate the trace of a matrix: the sum of the elements on the main diagonal of a square matrix.",examples:["A = [1, 2, 3; -1, 2, 3; 2, 0, 3]","trace(A)"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","transpose","zeros"]}},function(e,r,t){e.exports={name:"transpose",category:"Matrix",syntax:["x'","transpose(x)"],description:"Transpose a matrix",examples:["a = [1, 2, 3; 4, 5, 6]","a'","transpose(a)"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","trace","zeros"]}},function(e,r,t){e.exports={name:"zeros",category:"Matrix",syntax:["zeros(m)","zeros(m, n)","zeros(m, n, p, ...)","zeros([m])","zeros([m, n])","zeros([m, n, p, ...])","zeros"],description:"Create a matrix containing zeros.",examples:["zeros(3)","zeros(3, 5)","a = [1, 2, 3; 4, 5, 6]","zeros(size(a))"],seealso:["concat","det","diag","eye","inv","ones","range","size","squeeze","subset","trace","transpose"]}},function(e,r,t){e.exports={name:"combinations",category:"Probability",syntax:["combinations(n, k)"],description:"Compute the number of combinations of n items taken k at a time",examples:["combinations(7, 5)"],seealso:["permutations","factorial"]}},function(e,r,t){e.exports={name:"factorial",category:"Probability",syntax:["n!","factorial(n)"],description:"Compute the factorial of a value",examples:["5!","5 * 4 * 3 * 2 * 1","3!"],seealso:["combinations","permutations","gamma"]}},function(e,r,t){e.exports={name:"gamma",category:"Probability",syntax:["gamma(n)"],description:"Compute the gamma function. For small values, the Lanczos approximation is used, and for large values the extended Stirling approximation.",examples:["gamma(4)","3!","gamma(1/2)","sqrt(pi)"],seealso:["factorial"]}},function(e,r,t){e.exports={name:"permutations",category:"Probability",syntax:["permutations(n)","permutations(n, k)"],description:"Compute the number of permutations of n items taken k at a time",examples:["permutations(5)","permutations(5, 3)"],seealso:["combinations","factorial"]}},function(e,r,t){e.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:["random","randomInt"]}},function(e,r,t){e.exports={name:"random",category:"Probability",syntax:["random()","random(max)","random(min, max)","random(size)","random(size, max)","random(size, min, max)"],description:"Return a random number.",examples:["random()","random(10, 20)","random([2, 3])"],seealso:["pickRandom","randomInt"]}},function(e,r,t){e.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:["pickRandom","random"]}},function(e,r,t){e.exports={name:"compare",category:"Relational",syntax:["compare(x, y)"],description:"Compare two values. Returns 1 if x is larger than y, -1 if x is smaller than y, and 0 if x and y are equal.",examples:["compare(2, 3)","compare(3, 2)","compare(2, 2)","compare(5cm, 40mm)","compare(2, [1, 2, 3])"],seealso:["equal","unequal","smaller","smallerEq","largerEq"]}},function(e,r,t){e.exports={name:"deepEqual",category:"Relational",syntax:["deepEqual(x, y)"],description:"Check equality of two matrices element wise. Returns true if the size of both matrices is equal and when and each of the elements are equal.",examples:["[1,3,4] == [1,3,4]","[1,3,4] == [1,3]"],seealso:["equal","unequal","smaller","larger","smallerEq","largerEq","compare"]}},function(e,r,t){e.exports={name:"equal",category:"Relational", +syntax:["x == y","equal(x, y)"],description:"Check equality of two values. Returns true if the values are equal, and false if not.",examples:["2+2 == 3","2+2 == 4","a = 3.2","b = 6-2.8","a == b","50cm == 0.5m"],seealso:["unequal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]}},function(e,r,t){e.exports={name:"larger",category:"Relational",syntax:["x > y","larger(x, y)"],description:"Check if value x is larger than y. Returns true if x is larger than y, and false if not.",examples:["2 > 3","5 > 2*2","a = 3.3","b = 6-2.8","(a > b)","(b < a)","5 cm > 2 inch"],seealso:["equal","unequal","smaller","smallerEq","largerEq","compare"]}},function(e,r,t){e.exports={name:"largerEq",category:"Relational",syntax:["x >= y","largerEq(x, y)"],description:"Check if value x is larger or equal to y. Returns true if x is larger or equal to y, and false if not.",examples:["2 > 1+1","2 >= 1+1","a = 3.2","b = 6-2.8","(a > b)"],seealso:["equal","unequal","smallerEq","smaller","largerEq","compare"]}},function(e,r,t){e.exports={name:"smaller",category:"Relational",syntax:["x < y","smaller(x, y)"],description:"Check if value x is smaller than value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 3","5 < 2*2","a = 3.3","b = 6-2.8","(a < b)","5 cm < 2 inch"],seealso:["equal","unequal","larger","smallerEq","largerEq","compare"]}},function(e,r,t){e.exports={name:"smallerEq",category:"Relational",syntax:["x <= y","smallerEq(x, y)"],description:"Check if value x is smaller or equal to value y. Returns true if x is smaller than y, and false if not.",examples:["2 < 1+1","2 <= 1+1","a = 3.2","b = 6-2.8","(a < b)"],seealso:["equal","unequal","larger","smaller","largerEq","compare"]}},function(e,r,t){e.exports={name:"unequal",category:"Relational",syntax:["x != y","unequal(x, y)"],description:"Check unequality of two values. Returns true if the values are unequal, and false if they are equal.",examples:["2+2 != 3","2+2 != 4","a = 3.2","b = 6-2.8","a != b","50cm != 0.5m","5 cm != 2 inch"],seealso:["equal","smaller","larger","smallerEq","largerEq","compare","deepEqual"]}},function(e,r,t){e.exports={name:"max",category:"Statistics",syntax:["max(a, b, c, ...)","max(A)","max(A, dim)"],description:"Compute the maximum value of a list of values.",examples:["max(2, 3, 4, 1)","max([2, 3, 4, 1])","max([2, 5; 4, 3])","max([2, 5; 4, 3], 1)","max([2, 5; 4, 3], 2)","max(2.7, 7.1, -4.5, 2.0, 4.1)","min(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["mean","median","min","prod","std","sum","var"]}},function(e,r,t){e.exports={name:"mean",category:"Statistics",syntax:["mean(a, b, c, ...)","mean(A)","mean(A, dim)"],description:"Compute the arithmetic mean of a list of values.",examples:["mean(2, 3, 4, 1)","mean([2, 3, 4, 1])","mean([2, 5; 4, 3])","mean([2, 5; 4, 3], 1)","mean([2, 5; 4, 3], 2)","mean([1.0, 2.7, 3.2, 4.0])"],seealso:["max","median","min","prod","std","sum","var"]}},function(e,r,t){e.exports={name:"median",category:"Statistics",syntax:["median(a, b, c, ...)","median(A)"],description:"Compute the median of all values. The values are sorted and the middle value is returned. In case of an even number of values, the average of the two middle values is returned.",examples:["median(5, 2, 7)","median([3, -1, 5, 7])"],seealso:["max","mean","min","prod","std","sum","var"]}},function(e,r,t){e.exports={name:"min",category:"Statistics",syntax:["min(a, b, c, ...)","min(A)","min(A, dim)"],description:"Compute the minimum value of a list of values.",examples:["min(2, 3, 4, 1)","min([2, 3, 4, 1])","min([2, 5; 4, 3])","min([2, 5; 4, 3], 1)","min([2, 5; 4, 3], 2)","min(2.7, 7.1, -4.5, 2.0, 4.1)","max(2.7, 7.1, -4.5, 2.0, 4.1)"],seealso:["max","mean","median","prod","std","sum","var"]}},function(e,r,t){e.exports={name:"prod",category:"Statistics",syntax:["prod(a, b, c, ...)","prod(A)"],description:"Compute the product of all values.",examples:["prod(2, 3, 4)","prod([2, 3, 4])","prod([2, 5; 4, 3])"],seealso:["max","mean","min","median","min","std","sum","var"]}},function(e,r,t){e.exports={name:"std",category:"Statistics",syntax:["std(a, b, c, ...)","std(A)","std(A, normalization)"],description:'Compute the standard deviation of all values, defined as std(A) = sqrt(var(A)). Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["std(2, 4, 6)","std([2, 4, 6, 8])",'std([2, 4, 6, 8], "uncorrected")','std([2, 4, 6, 8], "biased")',"std([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","sum","var"]}},function(e,r,t){e.exports={name:"sum",category:"Statistics",syntax:["sum(a, b, c, ...)","sum(A)"],description:"Compute the sum of all values.",examples:["sum(2, 3, 4, 1)","sum([2, 3, 4, 1])","sum([2, 5; 4, 3])"],seealso:["max","mean","median","min","prod","std","sum","var"]}},function(e,r,t){e.exports={name:"var",category:"Statistics",syntax:["var(a, b, c, ...)","var(A)","var(A, normalization)"],description:'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',examples:["var(2, 4, 6)","var([2, 4, 6, 8])",'var([2, 4, 6, 8], "uncorrected")','var([2, 4, 6, 8], "biased")',"var([1, 2, 3; 4, 5, 6])"],seealso:["max","mean","min","median","min","prod","std","sum"]}},function(e,r,t){e.exports={name:"acos",category:"Trigonometry",syntax:["acos(x)"],description:"Compute the inverse cosine of a value in radians.",examples:["acos(0.5)","acos(cos(2.3))"],seealso:["cos","atan","asin"]}},function(e,r,t){e.exports={name:"acosh",category:"Trigonometry",syntax:["acosh(x)"],description:"Calculate the hyperbolic arccos of a value, defined as `acosh(x) = ln(sqrt(x^2 - 1) + x)`.",examples:["acosh(1.5)"],seealso:["cosh","asinh","atanh"]}},function(e,r,t){e.exports={name:"acot",category:"Trigonometry",syntax:["acot(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acot(0.5)","acot(cot(0.5))","acot(2)"],seealso:["cot","atan"]}},function(e,r,t){e.exports={name:"acoth",category:"Trigonometry",syntax:["acoth(x)"],description:"Calculate the hyperbolic arccotangent of a value, defined as `acoth(x) = (ln((x+1)/x) + ln(x/(x-1))) / 2`.",examples:["acoth(0.5)"],seealso:["acsch","asech"]}},function(e,r,t){e.exports={name:"acsc",category:"Trigonometry",syntax:["acsc(x)"],description:"Calculate the inverse cotangent of a value.",examples:["acsc(0.5)","acsc(csc(0.5))","acsc(2)"],seealso:["csc","asin","asec"]}},function(e,r,t){e.exports={name:"acsch",category:"Trigonometry",syntax:["acsch(x)"],description:"Calculate the hyperbolic arccosecant of a value, defined as `acsch(x) = ln(1/x + sqrt(1/x^2 + 1))`.",examples:["acsch(0.5)"],seealso:["asech","acoth"]}},function(e,r,t){e.exports={name:"asec",category:"Trigonometry",syntax:["asec(x)"],description:"Calculate the inverse secant of a value.",examples:["asec(0.5)","asec(sec(0.5))","asec(2)"],seealso:["acos","acot","acsc"]}},function(e,r,t){e.exports={name:"asech",category:"Trigonometry",syntax:["asech(x)"],description:"Calculate the inverse secant of a value.",examples:["asech(0.5)"],seealso:["acsch","acoth"]}},function(e,r,t){e.exports={name:"asin",category:"Trigonometry",syntax:["asin(x)"],description:"Compute the inverse sine of a value in radians.",examples:["asin(0.5)","asin(sin(2.3))"],seealso:["sin","acos","atan"]}},function(e,r,t){e.exports={name:"asinh",category:"Trigonometry",syntax:["asinh(x)"],description:"Calculate the hyperbolic arcsine of a value, defined as `asinh(x) = ln(x + sqrt(x^2 + 1))`.",examples:["asinh(0.5)"],seealso:["acosh","atanh"]}},function(e,r,t){e.exports={name:"atan",category:"Trigonometry",syntax:["atan(x)"],description:"Compute the inverse tangent of a value in radians.",examples:["atan(0.5)","atan(tan(2.3))"],seealso:["tan","acos","asin"]}},function(e,r,t){e.exports={name:"atanh",category:"Trigonometry",syntax:["atanh(x)"],description:"Calculate the hyperbolic arctangent of a value, defined as `atanh(x) = ln((1 + x)/(1 - x)) / 2`.",examples:["atanh(0.5)"],seealso:["acosh","asinh"]}},function(e,r,t){e.exports={name:"atan2",category:"Trigonometry",syntax:["atan2(y, x)"],description:"Computes the principal value of the arc tangent of y/x in radians.",examples:["atan2(2, 2) / pi","angle = 60 deg in rad","x = cos(angle)","y = sin(angle)","atan2(y, x)"],seealso:["sin","cos","tan"]}},function(e,r,t){e.exports={name:"cos",category:"Trigonometry",syntax:["cos(x)"],description:"Compute the cosine of x in radians.",examples:["cos(2)","cos(pi / 4) ^ 2","cos(180 deg)","cos(60 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["acos","sin","tan"]}},function(e,r,t){e.exports={name:"cosh",category:"Trigonometry",syntax:["cosh(x)"],description:"Compute the hyperbolic cosine of x in radians.",examples:["cosh(0.5)"],seealso:["sinh","tanh","coth"]}},function(e,r,t){e.exports={name:"cot",category:"Trigonometry",syntax:["cot(x)"],description:"Compute the cotangent of x in radians. Defined as 1/tan(x)",examples:["cot(2)","1 / tan(2)"],seealso:["sec","csc","tan"]}},function(e,r,t){e.exports={name:"coth",category:"Trigonometry",syntax:["coth(x)"],description:"Compute the hyperbolic cotangent of x in radians.",examples:["coth(2)","1 / tanh(2)"],seealso:["sech","csch","tanh"]}},function(e,r,t){e.exports={name:"csc",category:"Trigonometry",syntax:["csc(x)"],description:"Compute the cosecant of x in radians. Defined as 1/sin(x)",examples:["csc(2)","1 / sin(2)"],seealso:["sec","cot","sin"]}},function(e,r,t){e.exports={name:"csch",category:"Trigonometry",syntax:["csch(x)"],description:"Compute the hyperbolic cosecant of x in radians. Defined as 1/sinh(x)",examples:["csch(2)","1 / sinh(2)"],seealso:["sech","coth","sinh"]}},function(e,r,t){e.exports={name:"sec",category:"Trigonometry",syntax:["sec(x)"],description:"Compute the secant of x in radians. Defined as 1/cos(x)",examples:["sec(2)","1 / cos(2)"],seealso:["cot","csc","cos"]}},function(e,r,t){e.exports={name:"sech",category:"Trigonometry",syntax:["sech(x)"],description:"Compute the hyperbolic secant of x in radians. Defined as 1/cosh(x)",examples:["sech(2)","1 / cosh(2)"],seealso:["coth","csch","cosh"]}},function(e,r,t){e.exports={name:"sin",category:"Trigonometry",syntax:["sin(x)"],description:"Compute the sine of x in radians.",examples:["sin(2)","sin(pi / 4) ^ 2","sin(90 deg)","sin(30 deg)","sin(0.2)^2 + cos(0.2)^2"],seealso:["asin","cos","tan"]}},function(e,r,t){e.exports={name:"sinh",category:"Trigonometry",syntax:["sinh(x)"],description:"Compute the hyperbolic sine of x in radians.",examples:["sinh(0.5)"],seealso:["cosh","tanh"]}},function(e,r,t){e.exports={name:"tan",category:"Trigonometry",syntax:["tan(x)"],description:"Compute the tangent of x in radians.",examples:["tan(0.5)","sin(0.5) / cos(0.5)","tan(pi / 4)","tan(45 deg)"],seealso:["atan","sin","cos"]}},function(e,r,t){e.exports={name:"tanh",category:"Trigonometry",syntax:["tanh(x)"],description:"Compute the hyperbolic tangent of x in radians.",examples:["tanh(0.5)","sinh(0.5) / cosh(0.5)"],seealso:["sinh","cosh"]}},function(e,r,t){e.exports={name:"to",category:"Units",syntax:["x to unit","to(x, unit)"],description:"Change the unit of a value.",examples:["5 inch to cm","3.2kg to g","16 bytes in bits"],seealso:[]}},function(e,r,t){e.exports={name:"clone",category:"Utils",syntax:["clone(x)"],description:"Clone a variable. Creates a copy of primitive variables,and a deep copy of matrices",examples:["clone(3.5)","clone(2 - 4i)","clone(45 deg)","clone([1, 2; 3, 4])",'clone("hello world")'],seealso:[]}},function(e,r,t){e.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 value * value })"],seealso:["filter","forEach"]}},function(e,r,t){e.exports={name:"filter",category:"Utils",syntax:["filter(x, test)"],description:"Filter items in a matrix.",examples:["isPositive(x) = x > 0","filter([6, -2, -1, 4, 3], isPositive)","filter([6, -2, 0, 1, 0], x != 0)"],seealso:["sort","map","forEach"]}},function(e,r,t){e.exports={name:"forEach",category:"Utils",syntax:["forEach(x, callback)"],description:"Iterates over all elements of a matrix/array, and executes the given callback function.",examples:["forEach([1, 2, 3], function(val) { console.log(val) })"],seealso:["map","sort","filter"]}},function(e,r,t){e.exports={name:"format",category:"Utils",syntax:["format(value)","format(value, precision)"],description:"Format a value of any type as string.",examples:["format(2.3)","format(3 - 4i)","format([])","format(pi, 3)"],seealso:["print"]}},function(e,r,t){e.exports={name:"import",category:"Utils",syntax:["import(string)"],description:"Import functions from a file.",examples:['import("numbers")','import("./mylib.js")'],seealso:[]}},function(e,r,t){e.exports={name:"sort",category:"Utils",syntax:["sort(x)","sort(x, compare)"],description:'Sort the items in a matrix. Compare can be a string "asc" or "desc", or a custom sort function.',examples:["sort([5, 10, 1])",'sort(["C", "B", "A", "D"])',"sortByLength(a, b) = size(a)[1] - size(b)[1]",'sort(["Langdon", "Tom", "Sara"], sortByLength)'],seealso:["map","filter","forEach"]}},function(e,r,t){e.exports={name:"typeof",category:"Utils",syntax:["typeof(x)"],description:"Get the type of a variable.",examples:["typeof(3.5)","typeof(2 - 4i)","typeof(45 deg)",'typeof("hello world")'],seealso:[]}},function(e,r,t){var n,i,a;!function(t){i=[],n=t,a="function"==typeof n?n.apply(r,i):n,!(void 0!==a&&(e.exports=a))}(function(){function e(e){var r=d.types[e];if(!r){var t;for(var n in d.types)if(d.types.hasOwnProperty(n)&&n.toLowerCase()==e.toLowerCase()){t=n;break}throw new Error('Unknown type "'+e+'"'+(t?'. Did you mean "'+t+'"?':""))}return r}function r(e,r,t,n,i){var a,o=p(n),s=i?i.split(","):null,u=s&&m(s,"any"),c={fn:e,index:t,actual:n,expected:s};a=s?r>t&&!u?"Unexpected type of argument (expected: "+s.join(" or ")+", actual: "+o+", index: "+t+")":"Too few arguments (expected: "+s.join(" or ")+", index: "+t+")":"Too many arguments (expected: "+t+", actual: "+r+")";var f=new TypeError(a);return f.data=c,f}function t(e){this.name=e||"refs",this.categories={}}function n(e,r){if("string"==typeof e){var t=e.trim(),i="..."===t.substr(0,3);if(i&&(t=t.substr(3)),""===t)this.types=["any"];else{this.types=t.split("|");for(var a=0;ap)n[f]=c;else if(0===p)throw new Error('Signature "'+f+'" is defined twice')}else n[f]=c}}for(f in n)n.hasOwnProperty(f)&&a.push(n[f]);for(t=0;tt;t++)r[t]="arg"+t;return r}function f(e,n){var i=new t,a=o(n);if(0==a.length)throw new Error("No signatures provided");var f=u(a,[]),p=[],m=e||"",h=c(l(a));p.push("function "+m+"("+h.join(", ")+") {"),p.push(' "use strict";'),p.push(f.toCode(i," ")),p.push("}");var g=[i.toCode(),"return "+p.join("\n")].join("\n"),v=new Function(i.name,"createError",g),d=v(i,r);return d.signatures=s(a),d}function l(e){for(var r=0,t=0;tr&&(r=n)}return r}function p(e){for(var r in h)if(h.hasOwnProperty(r)&&"Object"!==r&&h[r](e))return r;return h.Object(e)?r:"unknown"}function m(e,r){return-1!==e.indexOf(r)}t.prototype.add=function(e,r){var t=r||"fn";this.categories[t]||(this.categories[t]=[]);var n=this.categories[t].indexOf(e);return-1==n&&(n=this.categories[t].length,this.categories[t].push(e)),t+n},t.prototype.toCode=function(){var e=[],r=this.name+".categories",t=this.categories;for(var n in t)if(t.hasOwnProperty(n))for(var i=t[n],a=0;a0},n.prototype.toString=function(e){for(var r=[],t={},n=0;nr.params.length)return 1;if(e.params.lengtht;t++)e.params[t].hasConversions()&&a++,r.params[t].hasConversions()&&o++;if(a>o)return 1;if(o>a)return-1;for(t=0;t "+a+") {"),i.push(t+" var varArgs = [];"),i.push(t+" for (var i = "+a+"; i < arguments.length; i++) {"),i.push(t+" varArgs.push(arguments[i]);"),i.push(t+" }"),i.push(this.signature.toCode(r,t+" ")),i.push(t+"}");else{for(var u=function(t,n){for(var i=new Array(t.length),a=0;a "+t+") {",r+" throw createError('', arguments.length, "+t+", arguments["+t+"]);",r+"}"].join("\n");for(var n={},i=[],a=0;a>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"};var i="\\mathrm{%name%}\\left(%*%\\right)",a={abs:"\\left|%0%\\right|",add:"\\left(%0%+%1%\\right)",ceil:"\\left\\lceil%0%\\right\\rceil",cube:"\\left(%0%\\right)^3",divide:"\\frac{%0%}{%1%}",dotDivide:"\\left(%0%"+r.operators.dotDivide+"%1%\\right)",dotMultiply:"\\left(%0%"+r.operators.dotMultiply+"%1%\\right)",dotPow:"\\left(%0%"+r.operators.dotPow+"%1%\\right)",exp:"\\exp\\left(%0%\\right)",fix:i,floor:"\\left\\lfloor%0%\\right\\rfloor",gcd:"\\gcd\\left(%*%\\right)",lcm:i,log10:"\\log_{10}\\left(%0%\\right)",log:{1:"\\ln\\left(%0%\\right)",2:"\\log_{%1%}\\left(%0%\\right)"},mod:"\\left(%0%"+r.operators.mod+"%1%\\right)",multiply:"\\left(%0%"+r.operators.multiply+"%1%\\right)",norm:{1:"\\left\\|%0%\\right\\|",2:i},nthRoot:"\\sqrt[%1%]{%0%}",pow:"\\left(%0%\\right)"+r.operators.pow+"{%1%}",round:{1:"\\left\\lfloor%0%\\right\\rceil",2:i},sign:i,sqrt:"\\sqrt{%0%}",square:"\\left(%0%\\right)^2",subtract:"\\left(%0%"+r.operators.subtract+"%1%\\right)",unaryMinus:r.operators.unaryMinus+"\\left(%0%\\right)",unaryPlus:r.operators.unaryPlus+"\\left(%0%\\right)",xgcd:i,bitAnd:"\\left(%0%"+r.operators.bitAnd+"%1%\\right)",bitOr:"\\left(%0%"+r.operators.bitOr+"%1%\\right)",bitXor:"\\left(%0%"+r.operators.bitXor+"%1%\\right)",bitNot:r.operators.bitNot+"\\left(%0%\\right)",leftShift:"\\left(%0%"+r.operators.leftShift+"%1%\\right)",rightArithShift:"\\left(%0%"+r.operators.rightArithShift+"%1%\\right)",rightLogShift:"\\left(%0%"+r.operators.rightLogShift+"%1%\\right)",arg:"\\arg\\left(%0%\\right)",conj:"\\left(%0%\\right)^*",im:"\\Im\\left\\lbrace%0%\\right\\rbrace",re:"\\Re\\left\\lbrace%0%\\right\\rbrace",bignumber:{0:"0",1:"\\left(%0%\\right)"},"boolean":i,chain:i,complex:{0:"0",1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)+"+r.symbols.i+"\\cdot\\left(%1%\\right)\\right)"},index:i,matrix:{0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(%0%\\right)",2:"\\left(%0%\\right)"},number:{0:"0",1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)%1%\\right)"},parser:i,sparse:{0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(%0%\\right)"},string:{0:'\\mathtt{""}',1:"\\mathrm{string}\\left(%0%\\right)"},unit:{1:"\\left(%0%\\right)",2:"\\left(\\left(%0%\\right)%1%\\right)"},compile:i,eval:i,help:i,parse:i,and:"\\left(%0%"+r.operators.and+"%1%\\right)",not:r.operators.not+"\\left(%0%\\right)",or:"\\left(%0%"+r.operators.or+"%1%\\right)",xor:"\\left(%0%"+r.operators.xor+"%1%\\right)",concat:i,cross:"\\left(%0%\\right)\\times\\left(%1%\\right)",det:"\\det\\left(%0%\\right)",diag:i,dot:"\\left(%0%\\cdot%1%\\right)",eye:i,flatten:i,inv:"\\left(%0%\\right)^{-1}",ones:i,range:i,resize:i,size:i,squeeze:i,subset:i,trace:"\\mathrm{tr}\\left(%0%\\right)",transpose:"\\left(%0%\\right)"+r.operators.transpose,zeros:i,combinations:"\\binom{%0%}{%1%}",distribution:i,factorial:"\\left(%0%\\right)"+r.operators.factorial,gamma:"\\Gamma\\left(%0%\\right)",permutations:i,pickRandom:i,randomInt:i,random:i,compare:i,deepEqual:i,equal:"\\left(%0%"+r.operators.equal+"%1%\\right)",largerEq:"\\left(%0%"+r.operators.largerEq+"%1%\\right)",larger:"\\left(%0%"+r.operators.larger+"%1%\\right)",smallerEq:"\\left(%0%"+r.operators.smallerEq+"%1%\\right)",smaller:"\\left(%0%"+r.operators.smaller+"%1%\\right)",unequal:"\\left(%0%"+r.operators.unequal+"%1%\\right)",max:"\\max\\left(%*%\\right)",mean:i,median:i,min:"\\min\\left(%*%\\right)",prod:i,std:i,sum:i,"var":"\\mathrm{Var}\\left(%*%\\right)",acosh:"\\cosh^{-1}\\left(%0%\\right)",acos:"\\cos^{-1}\\left(%0%\\right)",acoth:"\\coth^{-1}\\left(%0%\\right)",acot:"\\cot^{-1}\\left(%0%\\right)",acsch:"\\mathrm{csch}^{-1}\\left(%0%\\right)",acsc:"\\csc^{-1}\\left(%0%\\right)",asech:"\\mathrm{sech}^{-1}\\left(%0%\\right)",asec:"\\sec^{-1}\\left(%0%\\right)",asinh:"\\sinh^{-1}\\left(%0%\\right)",asin:"\\sin^{-1}\\left(%0%\\right)",atan2:"\\mathrm{atan2}\\left(%*%\\right)",atanh:"\\tanh^{-1}\\left(%0%\\right)",atan:"\\tan^{-1}\\left(%0%\\right)",cosh:"\\cosh\\left(%0%\\right)",cos:"\\cos\\left(%0%\\right)",coth:"\\coth\\left(%0%\\right)",cot:"\\cot\\left(%0%\\right)",csch:"\\mathrm{csch}\\left(%0%\\right)",csc:"\\csc\\left(%0%\\right)",sech:"\\mathrm{sech}\\left(%0%\\right)",sec:"\\sec\\left(%0%\\right)",sinh:"\\sinh\\left(%0%\\right)",sin:"\\sin\\left(%0%\\right)",tanh:"\\tanh\\left(%0%\\right)",tan:"\\tan\\left(%0%\\right)",to:"\\left(%0%"+r.operators.to+"%1%\\right)",clone:i,filter:i,forEach:i,format:i,"import":i,map:i,print:i,sort:i,"typeof":i},o={deg:"^\\circ"};r.toSymbol=function(e,t){if(t="undefined"==typeof t?!1:t)return o.hasOwnProperty(e)?o[e]:"\\mathrm{"+e+"}";if(r.symbols.hasOwnProperty(e))return r.symbols[e];if(-1!==e.indexOf("_")){var n=e.indexOf("_");return r.toSymbol(e.substring(0,n))+"_{"+r.toSymbol(e.substring(n+1))+"}"}return e},r.toFunction=function(e,r,t){var o=a[t],s=e.args.map(function(e){return e.toTex(r)});switch(typeof o){case"function":return o(e,r);case"string":return n(o,t,s);case"object":switch(typeof o[s.length]){case"function":return o[s.length](e,r);case"string":return n(o[s.length],t,s)}default:return n(i,t,s)}}},function(e,r,t){"use strict";e.exports={end:!0}},function(e,r,t){"use strict";function n(e){for(var r=e.getIdentifier(),t=0;t