diff --git a/README.md b/README.md index cd7a05c..030b712 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@
BCI.js is a library for EEG-based brain computer interface (BCI) design with JavaScript and Node.js. It allows for the creation of BCI enabled web apps or Node.js applications, with features such as: - - Signal processing and machine learning (LDA, CSP, ICA, PSD, etc.) + - Signal processing and machine learning (Bandpower, PSD, LDA, CSP, ICA, etc.) - Data manipulation (MATLAB style array subscripting, data windowing, CSV file support, etc.) - Networking (data collection, streaming via OSC, etc.) @@ -27,7 +27,7 @@ npm install bcijs Browser ```html - + ``` ## Tutorials @@ -45,7 +45,7 @@ const bci = require('bcijs'); // Generate 1 second of sample data let sampleRate = 512; let duration = 1; -let amplitudes = [1, 2, 4, 8]; +let amplitudes = [8, 4, 2, 1]; let frequencies = [ 1, // 1 Hz, delta range 5, // 5 Hz, theta range @@ -55,21 +55,22 @@ let frequencies = [ let signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration); -// Compute average power in each frequency band -let fftSize = sampleRate * duration; -let bandpowers = bci.signalBandPower( +// Compute relative power in each frequency band +let bandpowers = bci.bandpower( signal, sampleRate, ['delta', 'theta', 'alpha', 'beta'], - {fftSize: fftSize} // optional, defaults to next power of 2 larger than or equal to signal length + {relative: true} ); console.log(bandpowers); /* -[ 85.33333333333366, - 128.00000000000122, - 204.80000000000047, - 113.77777777777825 ] +[ + 0.7171876695851037, + 0.22444067394892755, + 0.04489131763080717, + 0.013469490282877555 +] */ ``` @@ -159,7 +160,7 @@ console.log(subarr); BCI.js can be loaded from the jsDelivr CDN with ```html - + ``` You can also find `bci.js` and `bci.min.js` in the [/dist](https://github.com/pwstegman/bci.js/tree/master/dist) directory. @@ -186,6 +187,8 @@ BCI.js methods can be found in the [lib/](https://github.com/pwstegman/bci.js/tr Documentation can be found at [https://bci.js.org/docs](https://bci.js.org/docs) or by viewing [api.md](https://github.com/pwstegman/bci.js/blob/master/docs/docs/api.md) +Deprecated methods can be found at [deprecated.md](https://github.com/pwstegman/bci.js/blob/master/docs/docs/deprecated.md) + ## Building See [dev.md](dev.md) for info on how to modify and build BCI.js diff --git a/browser.js b/browser.js index 090ac92..4d4d559 100644 --- a/browser.js +++ b/browser.js @@ -1,18 +1,22 @@ // This file was auto generated, changes will be overwritten -// Created on Sat Nov 09 2019 13:46:57 GMT-0600 (Central Standard Time) +// Created on Sat Apr 11 2020 09:57:09 GMT-0400 (Eastern Daylight Time) // This module excludes Node.js specific methods so it can be used in the browser /** @module bcijs */ +module.exports.averageBandPowers = require('./lib/compat/averageBandPowers.js'); module.exports.csp = require('./lib/compat/csp.js'); module.exports.f1score = require('./lib/compat/f1score.js'); module.exports.lda = require('./lib/compat/lda.js'); +module.exports.psd = require('./lib/compat/psd.js'); +module.exports.psdBandPower = require('./lib/compat/psdBandPower.js'); module.exports.signal = require('./lib/compat/signal.js'); +module.exports.signalBandPower = require('./lib/compat/signalBandPower.js'); module.exports.partition = require('./lib/data/partition.js'); module.exports.round = require('./lib/data/round.js'); module.exports.subscript = require('./lib/data/subscript.js'); module.exports.toFixed = require('./lib/data/toFixed.js'); module.exports.toTable = require('./lib/data/toTable.js'); module.exports.windowApply = require('./lib/data/windowApply.js'); -module.exports.averageBandPowers = require('./lib/math/averageBandPowers.js'); +module.exports.bandpower = require('./lib/math/bandpower.js'); module.exports.cspLearn = require('./lib/math/cspLearn.js'); module.exports.cspProject = require('./lib/math/cspProject.js'); module.exports.fastICA = require('./lib/math/fastICA.js'); @@ -22,9 +26,7 @@ module.exports.ldaClassify = require('./lib/math/ldaClassify.js'); module.exports.ldaLearn = require('./lib/math/ldaLearn.js'); module.exports.ldaProject = require('./lib/math/ldaProject.js'); module.exports.nextpow2 = require('./lib/math/nextpow2.js'); -module.exports.psd = require('./lib/math/psd.js'); -module.exports.psdBandPower = require('./lib/math/psdBandPower.js'); -module.exports.signalBandPower = require('./lib/math/signalBandPower.js'); +module.exports.periodogram = require('./lib/math/periodogram.js'); module.exports.transpose = require('./lib/math/transpose.js'); module.exports.accuracy = require('./lib/metrics/accuracy.js'); module.exports.balancedAccuracy = require('./lib/metrics/balancedAccuracy.js'); diff --git a/dist/bci.js b/dist/bci.js index e486d37..4cb8130 100644 --- a/dist/bci.js +++ b/dist/bci.js @@ -1,30 +1,34 @@ /** - * bci.js v1.6.5 + * bci.js v1.7.0 * https://github.com/pwstegman/bci.js * * License: MIT - * Generated 2019-11-09T19:46:57Z + * Generated 2020-04-11T13:56:44Z */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bci = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 3 && arguments[3] !== undefined ? arguments[3] : null; + var powers = new Array(bands.length); + + for (var i = 0; i < bands.length; i++) { + powers[i] = 0; + } + + var channels = transpose(samples); + + for (var _i = 0; _i < channels.length; _i++) { + for (var j = 0; j < bands.length; j++) { + var bandPower = signalBandPower(channels[_i], sampleRate, bands[j], fftSize); + powers[j] += bandPower; + } + } + + for (var _i2 = 0; _i2 < bands.length; _i2++) { + powers[_i2] = powers[_i2] / channels.length; + } + + return powers; +} + +module.exports = averageBandPowers; + +},{"../math/transpose.js":27,"./signalBandPower.js":9}],3:[function(require,module,exports){ "use strict"; var pwcsp = require('pw-csp'); @@ -77,7 +134,7 @@ var pwcsp = require('pw-csp'); module.exports = pwcsp; -},{"pw-csp":234}],3:[function(require,module,exports){ +},{"pw-csp":236}],4:[function(require,module,exports){ "use strict"; /** @@ -108,7 +165,7 @@ function f1score(confusionMatrix) { module.exports = f1score; -},{}],4:[function(require,module,exports){ +},{}],5:[function(require,module,exports){ "use strict"; var pwlda = require('pw-lda'); @@ -134,7 +191,144 @@ var pwlda = require('pw-lda'); module.exports = pwlda; -},{"pw-lda":235}],5:[function(require,module,exports){ +},{"pw-lda":358}],6:[function(require,module,exports){ +"use strict"; + +var fft = require('fft.js'); + +var nextpow2 = require('../math/nextpow2.js'); + +var fftCache = {}; +/** + * The functionality of this method has been replaced with the 'periodogram' method. + * See the docs for 'periodogram' for more information. + * + * Computes the magnitude of each frequency bin of the FFT. Units are that of the input signal. + * For example, if the input signal is measured in μV, then this method returns values in μV. + * + * As a PSD (particularly for EEG data) would be expected to return units of μV^2/Hz, this method has + * been deprecated to avoid confusion. It has been replaced with the periodogram method, which returns units + * of μV^2/Hz. + * + * @deprecated + * Deprecated since version 1.7.0, will be removed in version 2.0.0 + * + * @memberof module:bcijs + * @param {number[]} signal - The signal. + * @param {Object} [options] + * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2. + * @param {boolean} [options.truncate=false] - If true, only the first half of the PSD array is returned + * @returns {number[]} magnitude of each frequency bin of the FFT + */ + +function psd(signal, options) { + var _Object$assign = Object.assign({ + fftSize: Math.pow(2, nextpow2(signal.length)), + truncate: false + }, options), + fftSize = _Object$assign.fftSize, + truncate = _Object$assign.truncate; + + var f; + + if (fftCache.hasOwnProperty(fftSize)) { + f = fftCache[fftSize]; + } else { + f = new fft(fftSize); + fftCache[fftSize] = f; + } // Zero pad signal to length if needed + + + if (signal.length < fftSize) { + signal = signal.concat(Array(fftSize - signal.length).fill(0)); + } + + var freqs = f.createComplexArray(); + f.realTransform(freqs, signal); + f.completeSpectrum(freqs); + + if (truncate) { + var powers = getPowers(freqs, freqs.length / 2); + } else { + var powers = getPowers(freqs, freqs.length); + } + + return powers; +} + +function getPowers(complexArray, length) { + var magnitudes = []; + + for (var i = 0; i < length - 1; i += 2) { + magnitudes.push(Math.sqrt(complexArray[i] * complexArray[i] + complexArray[i + 1] * complexArray[i + 1])); + } + + return magnitudes; +} + +module.exports = psd; + +},{"../math/nextpow2.js":25,"fft.js":46}],7:[function(require,module,exports){ +"use strict"; + +var nextpow2 = require('../math/nextpow2.js'); +/** + * Deprecated, please use bci.bandpower() for output in proper units. + * + * The functionality of this method has been replaced with the 'bandpower' method. + * See the docs for 'bandpower' for more information. + * + * Computes the average magnitude across each frequency band given the output of the PSD method. + * + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0 + * + * @memberof module:bcijs + * @param {number[]} psd - Power spectral density of the signal. + * @param {number} sampleRate - The sample rate of the signal. + * @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a + * string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). + * While string representations + * allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in + * future updates. + * @param {number} [fftSize=Math.pow(2, bci.nextpow2(psd.length))] - Size of the fourier transform used to compute the PSD. + * @returns {number} The average power in the frequency band. + */ + + +function psdBandPower(psd, sampleRate, band) { + var fftSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + + if (fftSize === null) { + fftSize = Math.pow(2, nextpow2(psd.length)); + } + + var bands = { + // From Dan Szafir's "Pay Attention!", 2012 + 'delta': [1, 3], + 'theta': [4, 7], + 'alpha': [8, 12], + 'beta': [13, 30], + 'gamma': [31, 50] + }; + + if (typeof band === 'string' || band instanceof String) { + band = bands[band]; + } + + var startIndex = Math.floor(band[0] / sampleRate * fftSize); + var endIndex = Math.min(Math.ceil(band[1] / sampleRate * fftSize), psd.length - 1); + var power = 0; + + for (var i = startIndex; i < endIndex + 1; i++) { + power += psd[i]; + } + + return power / (endIndex - startIndex + 1); +} + +module.exports = psdBandPower; + +},{"../math/nextpow2.js":25}],8:[function(require,module,exports){ "use strict"; /** @@ -332,7 +526,121 @@ exports.getPSD = getPSD; exports.getBandPower = getBandPower; exports.CSP = require('./csp.js'); -},{"./csp.js":2,"fft.js":44,"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/function/trigonometry":162,"mathjs/lib/type/bignumber":181,"mathjs/lib/type/matrix":197}],6:[function(require,module,exports){ +},{"./csp.js":3,"fft.js":46,"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/function/trigonometry":164,"mathjs/lib/type/bignumber":183,"mathjs/lib/type/matrix":199}],9:[function(require,module,exports){ +"use strict"; + +var psd = require('./psd.js'); + +var psdBandPower = require('./psdBandPower.js'); + +var nextpow2 = require('../math/nextpow2.js'); + +var transpose = require('../math/transpose.js'); +/** + * Deprecated, please use bci.bandpower() for output in proper units. + * + * The functionality of this method has been replaced with the 'bandpower' method. + * See the docs for 'bandpower' for more information. + * + * Computes the average magnitude across each frequency band. + * + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0 + * + * @memberof module:bcijs + * @param {number[]|number[][]} samples - The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals. + * @param {number} sampleRate - The sample rate of the signal. + * @param {(Array|string)} bands - The frequency band or array of bands, where a single band is provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz).
+ * While string representations allow for easier prototyping, the use of a specific band passed as an array is + * recommended, as band string representations may change in future updates. + * @param {Object} [options] + * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2. + * @returns {number} The average power in the frequency band. + * @example + * // Example outputs are rounded + * + * // Single signal examples + * let sampleRate = 512; + * let signal = bci.generateSignal([2,16], [10,20], sampleRate, 1); + * // Get a single power in one band + * console.log(bci.signalBandPower(signal, sampleRate, 'alpha')); // returns 102.4 + * // Specify a custom band as an array (Ex: 8 Hz - 12 Hz) + * console.log(bci.signalBandPower(signal, sampleRate, [8, 12])); // returns 102.4 + * // Obtain multiple band powers + * console.log(bci.signalBandPower(signal, sampleRate, ['alpha', 'beta'])); // returns [ 102.4, 227.6 ] + * // Multiple band powers works with custom bands too + * console.log(bci.signalBandPower(signal, sampleRate, [[8, 12], [13, 30]])); // returns [ 102.4, 227.6 ] + * + * // Works with multiple signals too (example with 2 signals) + * let signal2 = bci.generateSignal([16, 2], [10, 20], 512, 1); + * let samples = bci.transpose([signal, signal2]); + * console.log(bci.signalBandPower(samples, sampleRate, 'alpha')); + * // Returns an array containing the alpha value for each signal + * console.log(bci.signalBandPower(samples, sampleRate, ['alpha', 'beta', 'gamma'])); + * // Returns a 2d array with number_of_bands rows and number_of_signals columns + */ + + +function signalBandPower(samples, sampleRate, bands, options) { + // Backwards compat for previous option to directly pass fftSize + if (typeof options === 'number') { + options = { + fftSize: options + }; + } // Defaults + // TODO: Average channels option + + + var _Object$assign = Object.assign({ + fftSize: Math.pow(2, nextpow2(samples.length)), + averageChannels: false + }, options), + fftSize = _Object$assign.fftSize, + averageChannels = _Object$assign.averageChannels; + + function getSignalPower(signal, band) { + var p = psd(signal, { + fftSize: fftSize + }); + return psdBandPower(p, sampleRate, band, fftSize); + } // Store if bands was passed as just a string or frequency range (not an array of bands) + + + var notBandArray = typeof bands === 'string' || !Array.isArray(bands[0]) && typeof bands[0] !== 'string'; // Now convert it to an array of bands so the matrix operations will work + + if (notBandArray) bands = [bands]; // Store the resulting matrix or array of powers + + var result; // If samples is a matrix (multiple signals) + + if (Array.isArray(samples[0])) { + var num_signals = samples[0].length; + var channels = transpose(samples); + result = new Array(bands.length); + + for (var r = 0; r < bands.length; r++) { + result[r] = new Array(num_signals); + + for (var c = 0; c < num_signals; c++) { + result[r][c] = getSignalPower(channels[c], bands[r]); + } + } + } else { + // Else, must be single signal as row vector (1d array) + result = new Array(bands.length); + + for (var i = 0; i < bands.length; i++) { + result[i] = getSignalPower(samples, bands[i]); + } + } // If bands wasn't an array of bands, return the 1d array of results for that band + + + if (notBandArray) return result[0]; // If bands was multiple bands, return the result as a matrix + + return result; +} + +module.exports = signalBandPower; + +},{"../math/nextpow2.js":25,"../math/transpose.js":27,"./psd.js":6,"./psdBandPower.js":7}],10:[function(require,module,exports){ "use strict"; /** @@ -365,7 +673,7 @@ function partition(array) { module.exports = partition; -},{}],7:[function(require,module,exports){ +},{}],11:[function(require,module,exports){ "use strict"; /** @@ -391,16 +699,20 @@ function round(array, places) { module.exports = round; -},{}],8:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ "use strict"; -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } /** * Subscript an array with MATLAB-like syntax @@ -495,7 +807,7 @@ function subscript(array) { module.exports = subscript; -},{}],9:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ "use strict"; /** @@ -521,7 +833,7 @@ function toFixed(array, places) { module.exports = toFixed; -},{}],10:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ "use strict"; var Table = require('easy-table'); @@ -541,7 +853,7 @@ function toTable(array) { module.exports = toTable; -},{"./toFixed.js":9,"easy-table":42}],11:[function(require,module,exports){ +},{"./toFixed.js":13,"easy-table":44}],15:[function(require,module,exports){ "use strict"; /** @@ -590,53 +902,254 @@ function windowApply(array, func, length) { module.exports = windowApply; -},{}],12:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ "use strict"; +var periodogram = require('./periodogram.js'); + var transpose = require('./transpose.js'); -var signalBandPower = require('./signalBandPower.js'); +var nextpow2 = require('./nextpow2.js'); +/** + * Integrate area under the curve using the rectangle method + * @private + * @param {number[]} x - Array of samples + * @param {number} [dx=1] - Spacing between points. Default is 1. + * @returns area under the curve + */ + + +function integrate(x) { + var dx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; + var sum = 0; + + for (var i = 0; i < x.length; i++) { + sum += x[i]; + } + + return sum * dx; +} /** - * Computes the power in each frequency band averaged across all channels + * Given a mixed array of strings and bands, ex: ['alpha', [4,10], 'beta'] + * Or simply a string, ex: 'alpha' + * Or simple a band, ex: [4,10] + * Reduce it to a common format of number[][]. + * Examples: + * input => output + * ['alpha', [4, 10], 'beta'] => [[8, 12], [4, 10], [13, 30]] + * 'alpha' => [[8, 12]] + * [4, 10] => [[4, 10]] + * @private + * @param {string|Array} bands + */ + + +function reduceBands(bands) { + var band_names = { + // From Dan Szafir's "Pay Attention!", 2012 + 'delta': [1, 3], + 'theta': [4, 7], + 'alpha': [8, 12], + 'beta': [13, 30], + 'gamma': [31, 50] + }; // If they pass only a string or only a single band + // Example: 'alpha' or [4, 10] + + if (typeof bands === 'string' || typeof bands[0] === 'number') { + bands = [bands]; + } // For each item in the array, replace a string with its matching band + + + return bands.map(function (band) { + if (typeof band === 'string') { + var band_as_numbers = band_names[band]; + if (band_as_numbers) return band_as_numbers; + throw new Error('Invalid band type passed'); + } + + return band; + }); +} +/** + * Calculate the bandpower of a signal or multiple signals in the specified frequency bands. + * + * Uses a modified periodogram with a Hann window by default. (see: bci.periodogram()) + * Bandpower is calculated as the area under the PSD curve estimated using the rectangular method. + * + * Units of bandpower are the square of the input signal's units. If the input signal has units of μV, + * then the bandpower estimate has units μV^2. + * + * Returns absolute power by default. Relative band power (absolute power divided by total power in the signal) + * can be calculated by passing the option {relative: true}. + * + * You can also pass custom PSD estimates instead of directly passing the signal. This may be useful if you wish + * to use your own PSD estimation method of choice, such as Welch's method. In this case, pass a single PSD array + * or pass multiple PSDs in the same form as multiple signals (columns are channels). Then be sure to pass the option {input: 'psd'}. + * + * Example usages are provided below. + * * @memberof module:bcijs - * @param {number[][]} samples - The signals where rows are samples and columns are electrodes - * @param {number} sampleRate - Sample rate of the data - * @param {Array} bands - An array of frequency bands. See signalBandPower for more info on frequency bands. - * @param {number} [fftSize] - The size of the fft to use. See signalBandPower for more info on fft sizes. - * @returns {number[]} Array containing the average power across all channels in each band + * @param {number[]|number[][]} samples - An array of samples, ex: [1,2,3,4, ...], or, in the case of multiple channels, ex (2 channels): [[1,2], [3,4], [5,6], ...] + * @param {number} sample_rate - Sample rate + * @param {string|Array} bands - The frequency band provided as an array [frequencyStart, frequencyStop] or a string 'delta' (1-3 Hz), 'theta' (4-7 Hz), 'alpha' (8-12 Hz), 'beta' (13-30 Hz), or 'gamma' (31-50 Hz). + * @param {object} options + * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2. + * @param {boolean} [options.average=false] - Average powers across channels. Default is false. + * @param {boolean} [options.input='samples'] - Input type. Can be either 'samples' (default) or 'psd'. If you already have a PSD calculated, you can pass the estimates as an array with the input type 'psd'. You can also pass the entire PSD object if it was calculated using the bci.periodogram method, and the input type of 'psd' will be inferred. + * @param {boolean} [options.relative=false] - Calculate relative bandpower instead of absolute bandpower. Default is false. + * @param {number} [options.window='hann'] - Window function to apply, either 'hann' or 'rectangular'. Default is 'hann'. + * @returns {number|number[]|number[][]} Bandpower | array of bandpowers if an array of bands is passed as input for a single signal or multiple signals are passed with a single band | array of array of powers for each band if multiple signals are passed + * * @example - * let feature = bci.averageBandPowers(samples, 256, ['alpha', 'beta']); - * // returns [alpha_power_averaged_across_channels, beta_power_averaged_across_channels] + * // Single signal example + * let samples = [0.23, 0.14, 0.78, ...]; + * let sample_rate = 256; // Hz + * + * bandpower(samples, sample_rate, 'alpha'); // returns power, ex: 1.652 + * bandpower(samples, sample_rate, ['alpha', 'beta']); // returns an array with the powers in the alpha and beta bands. Ex: [1.473, 0.383] + * + * // 2 channel example + * samples = [[0.1, 0.3], [0.4, 0.2], [0.6, 0.5], ...] + * + * bandpower(samples, sample_rate, 'alpha'); // returns an array of alpha powers for each channel, ex: [1.342, 0.342] + * + * bandpower(samples, sample_rate, ['alpha', 'beta']); + * // returns an array of arrays of powers in each band, ex: [[1.342, 0.342], [0.245, 1.343]]. + * // The first array is an array of alpha powers for channels 1 and 2 + * // The second array is an array of beta powers for channels 1 and 2 + * + * bandpower(samples, sample_rate, ['alpha', 'beta'], {average: true}); + * // Calculate average alpha across all channels and average beta across all channels + * // Returns a value such as [0.842, 0.794] + * // Note these are the average of [1.342, 0.342] and the average of [0.245, 1.343] from the previous example */ -function averageBandPowers(samples, sampleRate, bands) { - var fftSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - var powers = new Array(bands.length); +function bandpower(samples, sample_rate, bands, options) { + // Determine signal length + var signal_length = samples.length; - for (var i = 0; i < bands.length; i++) { - powers[i] = 0; + if (samples.estimates) { + signal_length = samples.estimates.length; + } // Handle default options + + + var _Object$assign = Object.assign({ + fftSize: Math.pow(2, nextpow2(signal_length)), + average: false, + input: 'samples', + relative: false, + window: 'hann' + }, options), + fftSize = _Object$assign.fftSize, + average = _Object$assign.average, + input = _Object$assign.input, + relative = _Object$assign.relative, + window = _Object$assign.window; // If they passed a PSD object, enforce the input type 'psd' + + + if (options && options['input'] == 'samples' && !Array.isArray(samples)) { + throw new Error('Expecting array of samples when input type of \'samples\' is passed'); } - var channels = transpose(samples); + if (samples.estimates) { + samples = samples.estimates; + input = 'psd'; + } // Check FFT size - for (var _i = 0; _i < channels.length; _i++) { - for (var j = 0; j < bands.length; j++) { - var bandPower = signalBandPower(channels[_i], sampleRate, bands[j], fftSize); - powers[j] += bandPower; + + if (fftSize < samples.length) { + throw new Error('fftSize must be greater than or equal to the length of samples'); + } // If matrix with muliple signals, process each signal + + + if (Array.isArray(samples[0])) { + var channels = transpose(samples); + var powers = channels.map(function (channel) { + return bandpower(channel, sample_rate, bands, options); + }); // Handle the 2D case (multiple channels and multiple bands) + + if (Array.isArray(powers[0])) { + // Return to same row/col format as input (channels are columns) + powers = transpose(powers); // Instead of calculating, for example, alpha power at each channel, calculate the average alpha + // across all channels. + + if (average) { + for (var i = 0; i < powers.length; i++) { + var sum = 0; + + for (var j = 0; j < powers[i].length; j++) { + sum += powers[i][j]; + } + + powers[i] = sum / powers[i].length; + } + } } - } - for (var _i2 = 0; _i2 < bands.length; _i2++) { - powers[_i2] = powers[_i2] / channels.length; + return powers; + } // Start by calculating the PSD + + + var psd; + + if (input == 'samples') { + psd = periodogram(samples, sample_rate, { + fftSize: fftSize, + window: window + }); + } else if (input == 'psd') { + if (Array.isArray(samples)) { + psd = { + estimates: samples + }; + } else { + throw new Error('Invalid PSD'); + } + } else { + throw new Error('Invalid input type'); + } // Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high]) + + + var original_bands = bands; + bands = reduceBands(bands); // Calculate the total power for relative power calculation if selected in options + + var total_power = 1; + var dx = sample_rate / fftSize; + + if (relative) { + total_power = integrate(psd.estimates, dx); + } // Calculate area in each band + + + var areas = new Array(bands.lenth); + + for (var _i = 0; _i < bands.length; _i++) { + // Get the proper section of the periodogram + var band = bands[_i]; + var low_index = Math.floor(band[0] / sample_rate * fftSize); + var high_index = Math.min(Math.ceil(band[1] / sample_rate * fftSize), psd.estimates.length - 1); + var psd_band = psd.estimates.slice(low_index, high_index + 1); + + if (psd_band.length < 2) { + throw new Error('Unable to calculate power in specified bands. Please increase fftSize or sample length'); + } + + areas[_i] = integrate(psd_band, dx) / total_power; + } // If they only passed a single band (not an array of bands), then the array of areas will + // have a length of 1. Return the single power value, not an array. + + + if (typeof original_bands === 'string' || typeof original_bands[0] === 'number') { + return areas[0]; } - return powers; + return areas; } -module.exports = averageBandPowers; +module.exports = bandpower; -},{"./signalBandPower.js":24,"./transpose.js":25}],13:[function(require,module,exports){ +},{"./nextpow2.js":25,"./periodogram.js":26,"./transpose.js":27}],17:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -671,7 +1184,7 @@ function cspLearn(class1, class2) { module.exports = cspLearn; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/type/matrix":197,"numeric":233,"pw-stat":236}],14:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/type/matrix":199,"numeric":235,"pw-stat":480}],18:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -721,14 +1234,18 @@ function cspProject(cspParams, data, dimensions) { module.exports = cspProject; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/type/matrix":197}],15:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/type/matrix":199}],19:[function(require,module,exports){ "use strict"; -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } -function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } @@ -900,7 +1417,7 @@ function fastICA(signals, options) { module.exports = fastICA; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/function/probability":118,"mathjs/lib/function/statistics":131,"mathjs/lib/function/trigonometry":162,"mathjs/lib/function/utils":170,"mathjs/lib/type/complex":184,"mathjs/lib/type/matrix":197,"numeric":233,"pw-stat":236}],16:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/function/probability":120,"mathjs/lib/function/statistics":133,"mathjs/lib/function/trigonometry":164,"mathjs/lib/function/utils":172,"mathjs/lib/type/complex":186,"mathjs/lib/type/matrix":199,"numeric":235,"pw-stat":480}],20:[function(require,module,exports){ "use strict"; /** @@ -915,8 +1432,6 @@ math.import(require('mathjs/lib/function/matrix')); math.import(require('mathjs/lib/function/arithmetic')); math.import(require('mathjs/lib/function/statistics')); -var sbp = require('./signalBandPower.js'); - var transpose = require('./transpose.js'); /** * Computes the log of the variance along the specified dimension @@ -1010,7 +1525,7 @@ function rootMeanSquare(window) { module.exports.rootMeanSquare = rootMeanSquare; -},{"./signalBandPower.js":24,"./transpose.js":25,"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/function/statistics":131,"mathjs/lib/type/matrix":197}],17:[function(require,module,exports){ +},{"./transpose.js":27,"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/function/statistics":133,"mathjs/lib/type/matrix":199}],21:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -1050,7 +1565,7 @@ function generateSignal(amplitudes, frequencies, sampleRate, duration) { module.exports = generateSignal; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/function/trigonometry":162,"mathjs/lib/type/bignumber":181,"mathjs/lib/type/matrix":197}],18:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/function/trigonometry":164,"mathjs/lib/type/bignumber":183,"mathjs/lib/type/matrix":199}],22:[function(require,module,exports){ "use strict"; var ldaProject = require('./ldaProject'); @@ -1083,7 +1598,7 @@ function ldaClassify(ldaParams, point) { module.exports = ldaClassify; -},{"./ldaProject":20}],19:[function(require,module,exports){ +},{"./ldaProject":24}],23:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -1123,7 +1638,7 @@ function ldaLearn(class1, class2) { module.exports = ldaLearn; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/type/matrix":197,"pw-stat":236}],20:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/type/matrix":199,"pw-stat":480}],24:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -1144,7 +1659,7 @@ function ldaProject(ldaParams, point) { module.exports = ldaProject; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/type/matrix":197}],21:[function(require,module,exports){ +},{"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/type/matrix":199}],25:[function(require,module,exports){ "use strict"; /** @@ -1165,7 +1680,7 @@ function nextpow2(num) { module.exports = nextpow2; -},{}],22:[function(require,module,exports){ +},{}],26:[function(require,module,exports){ "use strict"; var fft = require('fft.js'); @@ -1174,22 +1689,49 @@ var nextpow2 = require('./nextpow2.js'); var fftCache = {}; /** - * Compute the power spectral density of a given signal. + * Apply a Hann window to a signal + * @private + */ + +function hann(signal) { + var windowed = []; + var L = signal.length - 1; + var C = Math.PI / L; + var scale = 0; + + for (var i = 0; i < signal.length; i++) { + var w = Math.pow(Math.sin(C * i), 2); + windowed.push(signal[i] * w); + scale += Math.pow(w, 2); + } + + return { + signal: windowed, + scale: scale + }; +} +/** + * Estimates the power spectral density of a real-valued input signal using the periodogram method and a rectangular window. + * Output units are based on that of the input signal, of the form X^2/Hz, where X is the units of the input signal. + * For example, if the input is an EEG signal measured in μV, then this method returns values of μV^2/Hz. + * * @memberof module:bcijs * @param {number[]} signal - The signal. + * @param {number} sample_rate - sample rate in Hz * @param {Object} [options] * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2. - * @param {boolean} [options.truncate=false] - If true, only the first half of the PSD array is returned - * @returns {number[]} The PSD. + * @param {number} [options.window='rectangular'] - Window function to apply, either 'hann' or 'rectangular'. Default is 'rectangular'. + * @returns {Object} Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies) */ -function psd(signal, options) { + +function periodogram(signal, sample_rate, options) { var _Object$assign = Object.assign({ fftSize: Math.pow(2, nextpow2(signal.length)), - truncate: false + window: 'rectangular' }, options), fftSize = _Object$assign.fftSize, - truncate = _Object$assign.truncate; + window = _Object$assign.window; var f; @@ -1198,196 +1740,63 @@ function psd(signal, options) { } else { f = new fft(fftSize); fftCache[fftSize] = f; - } // Zero pad signal to length if needed + } // Apply window - if (signal.length < fftSize) { - signal = signal.concat(Array(fftSize - signal.length).fill(0)); - } - - var freqs = f.createComplexArray(); - f.realTransform(freqs, signal); - - if (truncate) { - var powers = getPowers(freqs, freqs.length / 2); - } else { - var powers = getPowers(freqs, freqs.length); - } + var num_samples = signal.length; + var S = num_samples; - return powers; -} + if (window == 'hann') { + var h = hann(signal); + signal = h.signal; + S = h.scale; + } else if (window != 'rectangular') { + throw new Error('Unknown window type'); + } // Zero pad signal to fftSize if needed -function getPowers(complexArray, length) { - var magnitudes = []; - for (var i = 0; i < length - 1; i += 2) { - magnitudes.push(Math.sqrt(complexArray[i] * complexArray[i] + complexArray[i + 1] * complexArray[i + 1])); - } + if (num_samples < fftSize) { + signal = signal.concat(Array(fftSize - signal.length).fill(0)); + } // Complex array [real, imag, real, imag, etc.] - return magnitudes; -} -module.exports = psd; + var freqs = f.createComplexArray(); // Fill in complex array with the FFT values -},{"./nextpow2.js":21,"fft.js":44}],23:[function(require,module,exports){ -"use strict"; + f.realTransform(freqs, signal); + f.completeSpectrum(freqs); // Get the power of each FFT bin value -var nextpow2 = require('./nextpow2.js'); -/** - * Compute the average power across a given frequency band given the PSD. - * @memberof module:bcijs - * @param {number[]} psd - Power spectral density of the signal. - * @param {number} sampleRate - The sample rate of the signal. - * @param {(number[]|string)} - The frequency band provided as an array [frequencyStart, frequencyStop] or a - * string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). - * While string representations - * allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in - * future updates. - * @param {number} [fftSize=Math.pow(2, bci.nextpow2(psd.length))] - Size of the fourier transform used to compute the PSD. - * @returns {number} The average power in the frequency band. - */ + var powers = []; + var scaling_factor = 2 / (sample_rate * S); + for (var i = 0; i < freqs.length - 1; i += 2) { + // magnitude is sqrt(real^2 + imag^2) + var magnitude = Math.sqrt(Math.pow(freqs[i], 2) + Math.pow(freqs[i + 1], 2)); // apply scaling -function psdBandPower(psd, sampleRate, band) { - var fftSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + var power = scaling_factor * Math.pow(magnitude, 2); + powers.push(power); + } // Toss values past Nyquist - if (fftSize === null) { - fftSize = Math.pow(2, nextpow2(psd.length)); - } - var bands = { - // From Dan Szafir's "Pay Attention!", 2012 - 'delta': [1, 3], - 'theta': [4, 7], - 'alpha': [8, 12], - 'beta': [13, 30], - 'gamma': [31, 50] - }; + powers = powers.slice(0, powers.length / 2 + 1); // Don't scale DC or Nyquist by 2 - if (typeof band === 'string' || band instanceof String) { - band = bands[band]; - } + powers[0] /= 2; + powers[powers.length - 1] /= 2; // Compute frequencies - var startIndex = Math.floor(band[0] / sampleRate * fftSize); - var endIndex = Math.min(Math.ceil(band[1] / sampleRate * fftSize), psd.length - 1); - var power = 0; + var frequencies = new Array(powers.length); - for (var i = startIndex; i < endIndex + 1; i++) { - power += psd[i]; + for (var _i = 0; _i < frequencies.length; _i++) { + frequencies[_i] = _i * (sample_rate / fftSize); } - return power / (endIndex - startIndex + 1); -} - -module.exports = psdBandPower; - -},{"./nextpow2.js":21}],24:[function(require,module,exports){ -"use strict"; - -var psd = require('./psd.js'); - -var psdBandPower = require('./psdBandPower.js'); - -var nextpow2 = require('./nextpow2.js'); - -var transpose = require('./transpose.js'); -/** - * Compute the average power across a given frequency band in a signal. - * @memberof module:bcijs - * @param {number[]|number[][]} samples - The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals. - * @param {number} sampleRate - The sample rate of the signal. - * @param {(Array|string)} bands - The frequency band or array of bands, where a single band is provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz).
- * While string representations allow for easier prototyping, the use of a specific band passed as an array is - * recommended, as band string representations may change in future updates. - * @param {Object} [options] - * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2. - * @returns {number} The average power in the frequency band. - * @example - * // Example outputs are rounded - * - * // Single signal examples - * let sampleRate = 512; - * let signal = bci.generateSignal([2,16], [10,20], sampleRate, 1); - * // Get a single power in one band - * console.log(bci.signalBandPower(signal, sampleRate, 'alpha')); // returns 102.4 - * // Specify a custom band as an array (Ex: 8 Hz - 12 Hz) - * console.log(bci.signalBandPower(signal, sampleRate, [8, 12])); // returns 102.4 - * // Obtain multiple band powers - * console.log(bci.signalBandPower(signal, sampleRate, ['alpha', 'beta'])); // returns [ 102.4, 227.6 ] - * // Multiple band powers works with custom bands too - * console.log(bci.signalBandPower(signal, sampleRate, [[8, 12], [13, 30]])); // returns [ 102.4, 227.6 ] - * - * // Works with multiple signals too (example with 2 signals) - * let signal2 = bci.generateSignal([16, 2], [10, 20], 512, 1); - * let samples = bci.transpose([signal, signal2]); - * console.log(bci.signalBandPower(samples, sampleRate, 'alpha')); - * // Returns an array containing the alpha value for each signal - * console.log(bci.signalBandPower(samples, sampleRate, ['alpha', 'beta', 'gamma'])); - * // Returns a 2d array with number_of_bands rows and number_of_signals columns - */ - - -function signalBandPower(samples, sampleRate, bands, options) { - // Backwards compat for previous option to directly pass fftSize - if (typeof options === 'number') { - options = { - fftSize: options - }; - } // Defaults - // TODO: Average channels option - - - var _Object$assign = Object.assign({ - fftSize: Math.pow(2, nextpow2(samples.length)), - averageChannels: false - }, options), - fftSize = _Object$assign.fftSize, - averageChannels = _Object$assign.averageChannels; - - function getSignalPower(signal, band) { - var p = psd(signal, { - fftSize: fftSize - }); - return psdBandPower(p, sampleRate, band, fftSize); - } // Store if bands was passed as just a string or frequency range (not an array of bands) - - - var notBandArray = typeof bands === 'string' || !Array.isArray(bands[0]) && typeof bands[0] !== 'string'; // Now convert it to an array of bands so the matrix operations will work - - if (notBandArray) bands = [bands]; // Store the resulting matrix or array of powers - - var result; // If samples is a matrix (multiple signals) - - if (Array.isArray(samples[0])) { - var num_signals = samples[0].length; - var channels = transpose(samples); - result = new Array(bands.length); - - for (var r = 0; r < bands.length; r++) { - result[r] = new Array(num_signals); - - for (var c = 0; c < num_signals; c++) { - result[r][c] = getSignalPower(channels[c], bands[r]); - } - } - } else { - // Else, must be single signal as row vector (1d array) - result = new Array(bands.length); - - for (var i = 0; i < bands.length; i++) { - result[i] = getSignalPower(samples, bands[i]); - } - } // If bands wasn't an array of bands, return the 1d array of results for that band - - - if (notBandArray) return result[0]; // If bands was multiple bands, return the result as a matrix - - return result; + return { + estimates: powers, + frequencies: frequencies + }; } -module.exports = signalBandPower; +module.exports = periodogram; -},{"./nextpow2.js":21,"./psd.js":22,"./psdBandPower.js":23,"./transpose.js":25}],25:[function(require,module,exports){ +},{"./nextpow2.js":25,"fft.js":46}],27:[function(require,module,exports){ "use strict"; /** @@ -1422,7 +1831,7 @@ function transpose(array) { module.exports = transpose; -},{}],26:[function(require,module,exports){ +},{}],28:[function(require,module,exports){ "use strict"; /** @@ -1451,7 +1860,7 @@ function accuracy(confusionMatrix) { module.exports = accuracy; -},{}],27:[function(require,module,exports){ +},{}],29:[function(require,module,exports){ "use strict"; var recall = require('./recall.js'); @@ -1473,16 +1882,20 @@ function balancedAccuracy(confusionMatrix) { module.exports = balancedAccuracy; -},{"./recall.js":32,"./specificity.js":33}],28:[function(require,module,exports){ +},{"./recall.js":34,"./specificity.js":35}],30:[function(require,module,exports){ "use strict"; -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } + +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } + +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } +function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } -function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } /** * Generate a confusion matrix C where rows are actual classes and columns are predicted classes. @@ -1520,7 +1933,7 @@ function confusionMatrix(predictedClasses, actualClasses) { module.exports = confusionMatrix; -},{}],29:[function(require,module,exports){ +},{}],31:[function(require,module,exports){ "use strict"; var precision = require('./precision.js'); @@ -1547,7 +1960,7 @@ function f1(confusionMatrix) { module.exports = f1; -},{"./precision.js":31,"./recall.js":32}],30:[function(require,module,exports){ +},{"./precision.js":33,"./recall.js":34}],32:[function(require,module,exports){ "use strict"; /** @@ -1570,7 +1983,7 @@ function mcc(confusionMatrix) { module.exports = mcc; -},{}],31:[function(require,module,exports){ +},{}],33:[function(require,module,exports){ "use strict"; /** @@ -1589,7 +2002,7 @@ function precision(confusionMatrix) { module.exports = precision; -},{}],32:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ "use strict"; /** @@ -1608,7 +2021,7 @@ function recall(confusionMatrix) { module.exports = recall; -},{}],33:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ "use strict"; /** @@ -1627,7 +2040,7 @@ function specificity(confusionMatrix) { module.exports = specificity; -},{}],34:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ "use strict"; // Use setTimeout as a promise @@ -1645,7 +2058,7 @@ module.exports = function (ms) { }); }; -},{}],35:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ 'use strict'; module.exports = function () { @@ -1653,7 +2066,7 @@ module.exports = function () { return new RegExp(pattern, 'g'); }; -},{}],36:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ 'use strict'; exports.byteLength = byteLength; @@ -1774,7 +2187,7 @@ function fromByteArray(uint8) { return parts.join(''); } -},{}],37:[function(require,module,exports){ +},{}],39:[function(require,module,exports){ (function (Buffer){ /*! * The buffer module from node.js, for the browser. @@ -1786,13 +2199,12 @@ function fromByteArray(uint8) { /* eslint-disable no-proto */ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var base64 = require('base64-js'); var ieee754 = require('ieee754'); -var customInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : null; exports.Buffer = Buffer; exports.SlowBuffer = SlowBuffer; exports.INSPECT_MAX_BYTES = 50; @@ -1823,13 +2235,12 @@ function typedArraySupport() { // Can typed array instances can be augmented? try { var arr = new Uint8Array(1); - var proto = { + arr.__proto__ = { + __proto__: Uint8Array.prototype, foo: function foo() { return 42; } }; - Object.setPrototypeOf(proto, Uint8Array.prototype); - Object.setPrototypeOf(arr, proto); return arr.foo() === 42; } catch (e) { return false; @@ -1858,7 +2269,7 @@ function createBuffer(length) { var buf = new Uint8Array(length); - Object.setPrototypeOf(buf, Buffer.prototype); + buf.__proto__ = Buffer.prototype; return buf; } /** @@ -1907,7 +2318,7 @@ function from(value, encodingOrOffset, length) { } if (value == null) { - throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); + throw TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value)); } if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) { @@ -1949,8 +2360,8 @@ Buffer.from = function (value, encodingOrOffset, length) { // https://github.com/feross/buffer/pull/148 -Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype); -Object.setPrototypeOf(Buffer, Uint8Array); +Buffer.prototype.__proto__ = Uint8Array.prototype; +Buffer.__proto__ = Uint8Array; function assertSize(size) { if (typeof size !== 'number') { @@ -2061,7 +2472,7 @@ function fromArrayBuffer(array, byteOffset, length) { } // Return an augmented `Uint8Array` instance - Object.setPrototypeOf(buf, Buffer.prototype); + buf.__proto__ = Buffer.prototype; return buf; } @@ -2406,10 +2817,6 @@ Buffer.prototype.inspect = function inspect() { return ''; }; -if (customInspectSymbol) { - Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect; -} - Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) { if (isInstance(target, Uint8Array)) { target = Buffer.from(target, target.offset, target.byteLength); @@ -2884,7 +3291,7 @@ function hexSlice(buf, start, end) { var out = ''; for (var i = start; i < end; ++i) { - out += hexSliceLookupTable[buf[i]]; + out += toHex(buf[i]); } return out; @@ -2923,7 +3330,7 @@ Buffer.prototype.slice = function slice(start, end) { if (end < start) end = start; var newBuf = this.subarray(start, end); // Return an augmented `Uint8Array` instance - Object.setPrototypeOf(newBuf, Buffer.prototype); + newBuf.__proto__ = Buffer.prototype; return newBuf; }; /* @@ -3407,8 +3814,6 @@ Buffer.prototype.fill = function fill(val, start, end, encoding) { } } else if (typeof val === 'number') { val = val & 255; - } else if (typeof val === 'boolean') { - val = Number(val); } // Invalid ranges are not set to a default, so can range check early. @@ -3464,6 +3869,11 @@ function base64clean(str) { return str; } +function toHex(n) { + if (n < 16) return '0' + n.toString(16); + return n.toString(16); +} + function utf8ToBytes(string, units) { units = units || Infinity; var codePoint; @@ -3579,31 +3989,14 @@ function isInstance(obj, type) { function numberIsNaN(obj) { // For IE11 support return obj !== obj; // eslint-disable-line no-self-compare -} // Create lookup table for `toString('hex')` -// See: https://github.com/feross/buffer/issues/219 - - -var hexSliceLookupTable = function () { - var alphabet = '0123456789abcdef'; - var table = new Array(256); - - for (var i = 0; i < 16; ++i) { - var i16 = i * 16; - - for (var j = 0; j < 16; ++j) { - table[i16 + j] = alphabet[i] + alphabet[j]; - } - } - - return table; -}(); +} }).call(this,require("buffer").Buffer) -},{"base64-js":36,"buffer":37,"ieee754":45}],38:[function(require,module,exports){ +},{"base64-js":38,"buffer":39,"ieee754":47}],40:[function(require,module,exports){ (function (Buffer){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var clone = function () { 'use strict'; @@ -3778,10 +4171,10 @@ if ((typeof module === "undefined" ? "undefined" : _typeof(module)) === 'object' } }).call(this,require("buffer").Buffer) -},{"buffer":37}],39:[function(require,module,exports){ +},{"buffer":39}],41:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** * @license Complex.js v2.0.3 11/02/2016 @@ -4831,10 +5224,10 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat } })(void 0); -},{}],40:[function(require,module,exports){ +},{}],42:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /*! decimal.js v9.0.1 https://github.com/MikeMcl/decimal.js/LICENCE */ ; @@ -9523,7 +9916,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat } })(void 0); -},{}],41:[function(require,module,exports){ +},{}],43:[function(require,module,exports){ "use strict"; var clone = require('clone'); @@ -9538,7 +9931,7 @@ module.exports = function (options, defaults) { return options; }; -},{"clone":38}],42:[function(require,module,exports){ +},{"clone":40}],44:[function(require,module,exports){ "use strict"; var ansiRegex = require('ansi-regex'); @@ -9986,7 +10379,7 @@ Table.prototype.log = function () { console.log(this.toString()); }; -},{"ansi-regex":35,"wcwidth":241}],43:[function(require,module,exports){ +},{"ansi-regex":37,"wcwidth":485}],45:[function(require,module,exports){ "use strict"; // Map the characters to escape to their escaped values. The list is derived // from http://www.cespedes.org/blog/85/how-to-escape-latex-special-characters @@ -10080,7 +10473,7 @@ module.exports = function (str) { return result; }; -},{}],44:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ 'use strict'; function FFT(size) { @@ -10552,7 +10945,7 @@ FFT.prototype._singleRealTransform4 = function _singleRealTransform4(outOff, off out[outOff + 7] = FDi; }; -},{}],45:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ "use strict"; exports.read = function (buffer, offset, isLE, mLen, nBytes) { @@ -10644,10 +11037,10 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128; }; -},{}],46:[function(require,module,exports){ +},{}],48:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /* * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license @@ -10713,12 +11106,12 @@ module.exports = function naturalSort(a, b) { return 0; }; -},{}],47:[function(require,module,exports){ +},{}],49:[function(require,module,exports){ "use strict"; module.exports = require('./lib/core/core'); -},{"./lib/core/core":48}],48:[function(require,module,exports){ +},{"./lib/core/core":50}],50:[function(require,module,exports){ "use strict"; var isFactory = require('./../utils/object').isFactory; @@ -10847,7 +11240,7 @@ exports.create = function create(options) { return math; }; -},{"./../utils/emitter":225,"./../utils/object":230,"./function/config":49,"./function/import":50,"./typed":51}],49:[function(require,module,exports){ +},{"./../utils/emitter":227,"./../utils/object":232,"./function/config":51,"./function/import":52,"./typed":53}],51:[function(require,module,exports){ 'use strict'; var object = require('../../utils/object'); @@ -10968,10 +11361,10 @@ exports.math = true; // request the math namespace as fifth argument exports.factory = factory; -},{"../../utils/object":230}],50:[function(require,module,exports){ +},{"../../utils/object":232}],52:[function(require,module,exports){ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var lazy = require('../../utils/object').lazy; @@ -11173,7 +11566,7 @@ function factory(type, config, load, typed, math) { function _importFactory(factory, options) { if (typeof factory.name === 'string') { var name = factory.name; - var existingTransform = name in math.expression.transform; + var existingTransform = (name in math.expression.transform); var namespace = factory.path ? traverse(math, factory.path) : math; var existing = namespace.hasOwnProperty(name) ? namespace[name] : undefined; @@ -11277,10 +11670,10 @@ exports.name = 'import'; exports.factory = factory; exports.lazy = true; -},{"../../error/ArgumentsError":52,"../../utils/object":230}],51:[function(require,module,exports){ +},{"../../error/ArgumentsError":54,"../../utils/object":232}],53:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var typedFunction = require('typed-function'); @@ -11737,7 +12130,7 @@ exports.create = function create(type) { return typed; }; -},{"./../utils/bignumber/isBigNumber":214,"./../utils/collection/isMatrix":221,"./../utils/number":229,"typed-function":239}],52:[function(require,module,exports){ +},{"./../utils/bignumber/isBigNumber":216,"./../utils/collection/isMatrix":223,"./../utils/number":231,"typed-function":483}],54:[function(require,module,exports){ 'use strict'; /** * Create a syntax error with the message: @@ -11768,7 +12161,7 @@ ArgumentsError.prototype.name = 'ArgumentsError'; ArgumentsError.prototype.isArgumentsError = true; module.exports = ArgumentsError; -},{}],53:[function(require,module,exports){ +},{}],55:[function(require,module,exports){ 'use strict'; /** * Create a range error with the message: @@ -11798,7 +12191,7 @@ DimensionError.prototype.name = 'DimensionError'; DimensionError.prototype.isDimensionError = true; module.exports = DimensionError; -},{}],54:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ 'use strict'; /** * Create a range error with the message: @@ -11843,7 +12236,7 @@ IndexError.prototype.name = 'IndexError'; IndexError.prototype.isIndexError = true; module.exports = IndexError; -},{}],55:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -11901,7 +12294,7 @@ function factory(type, config, load, typed) { exports.name = 'abs'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],56:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],58:[function(require,module,exports){ 'use strict'; var extend = require('../../utils/object').extend; @@ -12064,7 +12457,7 @@ function factory(type, config, load, typed) { exports.name = 'add'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm01":198,"../../type/matrix/utils/algorithm04":201,"../../type/matrix/utils/algorithm10":206,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex.js":228,"../../utils/object":230,"./addScalar":57}],57:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm01":200,"../../type/matrix/utils/algorithm04":203,"../../type/matrix/utils/algorithm10":208,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex.js":230,"../../utils/object":232,"./addScalar":59}],59:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -12109,7 +12502,7 @@ function factory(type, config, load, typed) { exports.factory = factory; -},{}],58:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -12285,7 +12678,7 @@ var _cbrtNumber = Math.cbrt || function (x) { exports.name = 'cbrt'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/collection/deepMap":219,"../utils/isNegative":173,"./unaryMinus":86}],59:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/collection/deepMap":221,"../utils/isNegative":175,"./unaryMinus":88}],61:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -12344,7 +12737,7 @@ function factory(type, config, load, typed) { exports.name = 'ceil'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],60:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],62:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -12404,7 +12797,7 @@ function factory(type, config, load, typed) { exports.name = 'cube'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],61:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],63:[function(require,module,exports){ 'use strict'; var extend = require('../../utils/object').extend; @@ -12490,7 +12883,7 @@ function factory(type, config, load, typed) { exports.name = 'divide'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm14":210,"../../utils/object":230,"../matrix/inv":99,"./divideScalar":62,"./multiply":76}],62:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm14":212,"../../utils/object":232,"../matrix/inv":101,"./divideScalar":64,"./multiply":78}],64:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -12543,7 +12936,7 @@ function factory(type, config, load, typed) { exports.factory = factory; -},{"./multiplyScalar":77}],63:[function(require,module,exports){ +},{"./multiplyScalar":79}],65:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -12688,7 +13081,7 @@ function factory(type, config, load, typed) { exports.name = 'dotDivide'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm07":204,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228,"./divideScalar":62}],64:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm07":206,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230,"./divideScalar":64}],66:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -12831,7 +13224,7 @@ function factory(type, config, load, typed) { exports.name = 'dotMultiply'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm09":205,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228,"./multiplyScalar":77}],65:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm09":207,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230,"./multiplyScalar":79}],67:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -12972,7 +13365,7 @@ function factory(type, config, load, typed) { exports.name = 'dotPow'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm07":204,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228,"./pow":80}],66:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm07":206,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230,"./pow":82}],68:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -13028,7 +13421,7 @@ function factory(type, config, load, typed) { exports.name = 'exp'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],67:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],69:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -13088,7 +13481,7 @@ function factory(type, config, load, typed) { exports.name = 'fix'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],68:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],70:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -13146,7 +13539,7 @@ function factory(type, config, load, typed) { exports.name = 'floor'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],69:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],71:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -13347,7 +13740,7 @@ function _gcd(a, b) { exports.name = 'gcd'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm01":198,"../../type/matrix/utils/algorithm04":201,"../../type/matrix/utils/algorithm10":206,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/number":229}],70:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm01":200,"../../type/matrix/utils/algorithm04":203,"../../type/matrix/utils/algorithm10":208,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/number":231}],72:[function(require,module,exports){ 'use strict'; var flatten = require('../../utils/array').flatten; @@ -13431,12 +13824,12 @@ function factory(type, config, load, typed) { exports.name = 'hypot'; exports.factory = factory; -},{"../../utils/array":212,"../relational/smaller":130,"../utils/isPositive":175,"./abs":55,"./addScalar":57,"./divideScalar":62,"./multiplyScalar":77,"./sqrt":83}],71:[function(require,module,exports){ +},{"../../utils/array":214,"../relational/smaller":132,"../utils/isPositive":177,"./abs":57,"./addScalar":59,"./divideScalar":64,"./multiplyScalar":79,"./sqrt":85}],73:[function(require,module,exports){ "use strict"; module.exports = [require('./abs'), require('./add'), require('./addScalar'), require('./cbrt'), require('./ceil'), require('./cube'), require('./divide'), require('./dotDivide'), require('./dotMultiply'), require('./dotPow'), require('./exp'), require('./fix'), require('./floor'), require('./gcd'), require('./hypot'), require('./lcm'), require('./log'), require('./log10'), require('./mod'), require('./multiply'), require('./norm'), require('./nthRoot'), require('./pow'), require('./round'), require('./sign'), require('./sqrt'), require('./square'), require('./subtract'), require('./unaryMinus'), require('./unaryPlus'), require('./xgcd')]; -},{"./abs":55,"./add":56,"./addScalar":57,"./cbrt":58,"./ceil":59,"./cube":60,"./divide":61,"./dotDivide":63,"./dotMultiply":64,"./dotPow":65,"./exp":66,"./fix":67,"./floor":68,"./gcd":69,"./hypot":70,"./lcm":72,"./log":73,"./log10":74,"./mod":75,"./multiply":76,"./norm":78,"./nthRoot":79,"./pow":80,"./round":81,"./sign":82,"./sqrt":83,"./square":84,"./subtract":85,"./unaryMinus":86,"./unaryPlus":87,"./xgcd":88}],72:[function(require,module,exports){ +},{"./abs":57,"./add":58,"./addScalar":59,"./cbrt":60,"./ceil":61,"./cube":62,"./divide":63,"./dotDivide":65,"./dotMultiply":66,"./dotPow":67,"./exp":68,"./fix":69,"./floor":70,"./gcd":71,"./hypot":72,"./lcm":74,"./log":75,"./log10":76,"./mod":77,"./multiply":78,"./norm":80,"./nthRoot":81,"./pow":82,"./round":83,"./sign":84,"./sqrt":85,"./square":86,"./subtract":87,"./unaryMinus":88,"./unaryPlus":89,"./xgcd":90}],74:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -13653,7 +14046,7 @@ function _lcm(a, b) { exports.name = 'lcm'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm06":203,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/number":229}],73:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm06":205,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/number":231}],75:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -13733,7 +14126,7 @@ function factory(type, config, load, typed) { exports.name = 'log'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"./divideScalar":62}],74:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"./divideScalar":64}],76:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -13808,7 +14201,7 @@ var _log10 = Math.log10 || function (x) { exports.name = 'log10'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],75:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],77:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -13989,7 +14382,7 @@ function factory(type, config, load, typed) { exports.name = 'mod'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228}],76:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230}],78:[function(require,module,exports){ 'use strict'; var extend = require('../../utils/object').extend; @@ -14957,7 +15350,7 @@ function factory(type, config, load, typed) { exports.name = 'multiply'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm14":210,"../../utils/array":212,"../../utils/latex":228,"../../utils/object":230,"../relational/equalScalar":128,"./addScalar":57,"./multiplyScalar":77}],77:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm14":212,"../../utils/array":214,"../../utils/latex":230,"../../utils/object":232,"../relational/equalScalar":130,"./addScalar":59,"./multiplyScalar":79}],79:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -15006,7 +15399,7 @@ function factory(type, config, load, typed) { exports.factory = factory; -},{}],78:[function(require,module,exports){ +},{}],80:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -15208,7 +15601,7 @@ function factory(type, config, load, typed) { exports.name = 'norm'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../arithmetic/abs":55,"../arithmetic/add":56,"../arithmetic/multiply":76,"../arithmetic/pow":80,"../arithmetic/sqrt":83,"../matrix/trace":111,"../matrix/transpose":112,"../relational/equalScalar":128,"../relational/larger":129,"../relational/smaller":130}],79:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../arithmetic/abs":57,"../arithmetic/add":58,"../arithmetic/multiply":78,"../arithmetic/pow":82,"../arithmetic/sqrt":85,"../matrix/trace":113,"../matrix/transpose":114,"../relational/equalScalar":130,"../relational/larger":131,"../relational/smaller":132}],81:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -15516,7 +15909,7 @@ function _nthComplexRoot(a, root) { exports.name = 'nthRoot'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm01":198,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm06":203,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210}],80:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm01":200,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm06":205,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212}],82:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -15706,7 +16099,7 @@ function factory(type, config, load, typed) { exports.name = 'pow'; exports.factory = factory; -},{"../../type/fraction/function/fraction":185,"../../type/matrix/function/matrix":195,"../../type/number":211,"../../utils/array":212,"../../utils/latex":228,"../../utils/number":229,"../matrix/eye":94,"./multiply":76}],81:[function(require,module,exports){ +},{"../../type/fraction/function/fraction":187,"../../type/matrix/function/matrix":197,"../../type/number":213,"../../utils/array":214,"../../utils/latex":230,"../../utils/number":231,"../matrix/eye":96,"./multiply":78}],83:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -15890,7 +16283,7 @@ function _round(value, decimals) { exports.name = 'round'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm14":210,"../../utils/collection/deepMap":219,"../../utils/number":229,"../matrix/zeros":113,"../relational/equalScalar":128}],82:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm14":212,"../../utils/collection/deepMap":221,"../../utils/number":231,"../matrix/zeros":115,"../relational/equalScalar":130}],84:[function(require,module,exports){ 'use strict'; var number = require('../../utils/number'); @@ -15956,7 +16349,7 @@ function factory(type, config, load, typed) { exports.name = 'sign'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],83:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],85:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -16032,7 +16425,7 @@ function factory(type, config, load, typed) { exports.name = 'sqrt'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],84:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],86:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -16094,7 +16487,7 @@ function factory(type, config, load, typed) { exports.name = 'square'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],85:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],87:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../error/DimensionError'); @@ -16283,7 +16676,7 @@ function factory(type, config, load, typed) { exports.name = 'subtract'; exports.factory = factory; -},{"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm01":198,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm10":206,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228,"./addScalar":57,"./unaryMinus":86}],86:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm01":200,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm10":208,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230,"./addScalar":59,"./unaryMinus":88}],88:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -16348,7 +16741,7 @@ function factory(type, config, load, typed) { exports.name = 'unaryMinus'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/latex":228}],87:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/latex":230}],89:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -16415,7 +16808,7 @@ function factory(type, config, load, typed) { exports.name = 'unaryPlus'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/latex":228}],88:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/latex":230}],90:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -16558,7 +16951,7 @@ function factory(type, config, load, typed) { exports.name = 'xgcd'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/number":229}],89:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/number":231}],91:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -16707,7 +17100,7 @@ function _concat(a, b, concatDim, dim) { exports.name = 'concat'; exports.factory = factory; -},{"../../error/DimensionError":53,"../../error/IndexError":54,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229,"../../utils/object":230}],90:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../error/IndexError":56,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231,"../../utils/object":232}],92:[function(require,module,exports){ 'use strict'; var array = require('../../utils/array'); @@ -16798,7 +17191,7 @@ function factory(type, config, load, typed) { exports.name = 'cross'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../arithmetic/multiply":76,"../arithmetic/subtract":85}],91:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../arithmetic/multiply":78,"../arithmetic/subtract":87}],93:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -16958,7 +17351,7 @@ function factory(type, config, load, typed) { exports.name = 'det'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/index":227,"../arithmetic/add":56,"../arithmetic/multiply":76,"../arithmetic/subtract":85,"../arithmetic/unaryMinus":86}],92:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/index":229,"../arithmetic/add":58,"../arithmetic/multiply":78,"../arithmetic/subtract":87,"../arithmetic/unaryMinus":88}],94:[function(require,module,exports){ 'use strict'; var array = require('../../utils/array'); @@ -17121,7 +17514,7 @@ function factory(type, config, load, typed) { exports.name = 'diag'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229,"../../utils/object":230}],93:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231,"../../utils/object":232}],95:[function(require,module,exports){ 'use strict'; var size = require('../../utils/array').size; @@ -17199,7 +17592,7 @@ function factory(type, config, load, typed) { exports.name = 'dot'; exports.factory = factory; -},{"../../utils/array":212,"../arithmetic/add":56,"../arithmetic/multiply":76}],94:[function(require,module,exports){ +},{"../../utils/array":214,"../arithmetic/add":58,"../arithmetic/multiply":78}],96:[function(require,module,exports){ 'use strict'; var array = require('../../utils/array'); @@ -17341,7 +17734,7 @@ function factory(type, config, load, typed) { exports.name = 'eye'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],95:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],97:[function(require,module,exports){ 'use strict'; var filter = require('../../utils/array').filter; @@ -17424,7 +17817,7 @@ function _filterCallback(x, callback) { exports.name = 'filter'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/function":226}],96:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/function":228}],98:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -17471,7 +17864,7 @@ function factory(type, config, load, typed) { exports.name = 'flatten'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/object":230}],97:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/object":232}],99:[function(require,module,exports){ 'use strict'; var maxArgumentCount = require('../../utils/function').maxArgumentCount; @@ -17549,12 +17942,12 @@ function _forEach(array, callback) { exports.name = 'forEach'; exports.factory = factory; -},{"../../utils/array":212,"../../utils/function":226}],98:[function(require,module,exports){ +},{"../../utils/array":214,"../../utils/function":228}],100:[function(require,module,exports){ "use strict"; module.exports = [require('./concat'), require('./cross'), require('./det'), require('./diag'), require('./dot'), require('./eye'), require('./filter'), require('./flatten'), require('./forEach'), require('./inv'), require('./kron'), require('./map'), require('./ones'), require('./partitionSelect'), require('./range'), require('./reshape'), require('./resize'), require('./size'), require('./sort'), require('./squeeze'), require('./subset'), require('./trace'), require('./transpose'), require('./zeros')]; -},{"./concat":89,"./cross":90,"./det":91,"./diag":92,"./dot":93,"./eye":94,"./filter":95,"./flatten":96,"./forEach":97,"./inv":99,"./kron":100,"./map":101,"./ones":102,"./partitionSelect":103,"./range":104,"./reshape":105,"./resize":106,"./size":107,"./sort":108,"./squeeze":109,"./subset":110,"./trace":111,"./transpose":112,"./zeros":113}],99:[function(require,module,exports){ +},{"./concat":91,"./cross":92,"./det":93,"./diag":94,"./dot":95,"./eye":96,"./filter":97,"./flatten":98,"./forEach":99,"./inv":101,"./kron":102,"./map":103,"./ones":104,"./partitionSelect":105,"./range":106,"./reshape":107,"./resize":108,"./size":109,"./sort":110,"./squeeze":111,"./subset":112,"./trace":113,"./transpose":114,"./zeros":115}],101:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -17752,7 +18145,7 @@ function factory(type, config, load, typed) { exports.name = 'inv'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/index":227,"../arithmetic/addScalar":57,"../arithmetic/divideScalar":62,"../arithmetic/multiply":76,"../arithmetic/unaryMinus":86,"../matrix/det":91,"./eye":94}],100:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/index":229,"../arithmetic/addScalar":59,"../arithmetic/divideScalar":64,"../arithmetic/multiply":78,"../arithmetic/unaryMinus":88,"../matrix/det":93,"./eye":96}],102:[function(require,module,exports){ 'use strict'; var size = require('../../utils/array').size; @@ -17842,7 +18235,7 @@ function factory(type, config, load, typed) { exports.name = 'kron'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../arithmetic/multiplyScalar":77}],101:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../arithmetic/multiplyScalar":79}],103:[function(require,module,exports){ 'use strict'; var maxArgumentCount = require('../../utils/function').maxArgumentCount; @@ -17920,7 +18313,7 @@ function _map(array, callback) { exports.name = 'map'; exports.factory = factory; -},{"../../utils/function":226}],102:[function(require,module,exports){ +},{"../../utils/function":228}],104:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -18054,7 +18447,7 @@ function factory(type, config, load, typed) { exports.name = 'ones'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],103:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],105:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -18193,7 +18586,7 @@ function factory(type, config, load, typed) { exports.name = 'partitionSelect'; exports.factory = factory; -},{"../../utils/number":229,"../relational/compare":126}],104:[function(require,module,exports){ +},{"../../utils/number":231,"../relational/compare":128}],106:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -18461,7 +18854,7 @@ function factory(type, config, load, typed) { exports.name = 'range'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195}],105:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197}],107:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../error/DimensionError'); @@ -18534,7 +18927,7 @@ function factory(type, config, load, typed) { exports.name = 'reshape'; exports.factory = factory; -},{"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],106:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],108:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../error/DimensionError'); @@ -18677,7 +19070,7 @@ function factory(type, config, load, typed) { exports.name = 'resize'; exports.factory = factory; -},{"../../error/ArgumentsError":52,"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229,"../../utils/object":230,"../../utils/string":231}],107:[function(require,module,exports){ +},{"../../error/ArgumentsError":54,"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231,"../../utils/object":232,"../../utils/string":233}],109:[function(require,module,exports){ 'use strict'; var array = require('../../utils/array'); @@ -18730,7 +19123,7 @@ function factory(type, config, load, typed) { exports.name = 'size'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212}],108:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214}],110:[function(require,module,exports){ 'use strict'; var size = require('../../utils/array').size; @@ -18858,7 +19251,7 @@ function factory(type, config, load, typed) { exports.name = 'sort'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../relational/compare":126,"../relational/compareNatural":127}],109:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../relational/compare":128,"../relational/compareNatural":129}],111:[function(require,module,exports){ 'use strict'; var object = require('../../utils/object'); @@ -18919,7 +19312,7 @@ function factory(type, config, load, typed) { exports.name = 'squeeze'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/object":230}],110:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/object":232}],112:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -19146,7 +19539,7 @@ function _setObjectProperty(object, index, replacement) { exports.name = 'subset'; exports.factory = factory; -},{"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/customs":224,"../../utils/object":230}],111:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/customs":226,"../../utils/object":232}],113:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -19304,7 +19697,7 @@ function factory(type, config, load, typed) { exports.name = 'trace'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/object":230,"../../utils/string":231,"../arithmetic/add":56}],112:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/object":232,"../../utils/string":233,"../arithmetic/add":58}],114:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -19488,7 +19881,7 @@ function factory(type, config, load, typed) { exports.name = 'transpose'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/latex":228,"../../utils/object":230,"../../utils/string":231}],113:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/latex":230,"../../utils/object":232,"../../utils/string":233}],115:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -19621,7 +20014,7 @@ function factory(type, config, load, typed) { exports.name = 'zeros'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],114:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],116:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -19718,7 +20111,7 @@ function isPositiveInteger(n) { exports.name = 'combinations'; exports.factory = factory; -},{"../../utils/number":229}],115:[function(require,module,exports){ +},{"../../utils/number":231}],117:[function(require,module,exports){ 'use strict'; var ArgumentsError = require('../../error/ArgumentsError'); @@ -20020,7 +20413,7 @@ function factory(type, config, load, typed, math) { exports.name = 'distribution'; exports.factory = factory; -},{"../../error/ArgumentsError":52,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/collection/isCollection":220,"../../utils/number":229,"./seededRNG":125}],116:[function(require,module,exports){ +},{"../../error/ArgumentsError":54,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/collection/isCollection":222,"../../utils/number":231,"./seededRNG":127}],118:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -20081,7 +20474,7 @@ function factory(type, config, load, typed) { exports.name = 'factorial'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/latex":228,"./gamma":117}],117:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/latex":230,"./gamma":119}],119:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -20267,13 +20660,13 @@ var p = [0.99999999999999709182, 57.156235665862923517, -59.597960355475491248, exports.name = 'gamma'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229,"../arithmetic/multiply":76,"../arithmetic/pow":80}],118:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231,"../arithmetic/multiply":78,"../arithmetic/pow":82}],120:[function(require,module,exports){ "use strict"; module.exports = [//require('./distribution'), // TODO: rethink math.distribution require('./combinations'), require('./factorial'), require('./gamma'), require('./kldivergence'), require('./multinomial'), require('./permutations'), require('./pickRandom'), require('./random'), require('./randomInt')]; -},{"./combinations":114,"./factorial":116,"./gamma":117,"./kldivergence":119,"./multinomial":120,"./permutations":121,"./pickRandom":122,"./random":123,"./randomInt":124}],119:[function(require,module,exports){ +},{"./combinations":116,"./factorial":118,"./gamma":119,"./kldivergence":121,"./multinomial":122,"./permutations":123,"./pickRandom":124,"./random":125,"./randomInt":126}],121:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -20362,7 +20755,7 @@ function factory(type, config, load, typed) { exports.name = 'kldivergence'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../arithmetic/divide":61,"../arithmetic/dotDivide":63,"../arithmetic/log":73,"../arithmetic/multiply":76,"../statistics/sum":141,"../utils/isNumeric":174}],120:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../arithmetic/divide":63,"../arithmetic/dotDivide":65,"../arithmetic/log":75,"../arithmetic/multiply":78,"../statistics/sum":143,"../utils/isNumeric":176}],122:[function(require,module,exports){ 'use strict'; var deepForEach = require('../../utils/collection/deepForEach'); @@ -20416,7 +20809,7 @@ function factory(type, config, load, typed) { exports.name = 'multinomial'; exports.factory = factory; -},{"../../utils/collection/deepForEach":218,"../arithmetic/add":56,"../arithmetic/divide":61,"../arithmetic/multiply":76,"../probability/factorial":116,"../utils/isInteger":171,"../utils/isPositive":175}],121:[function(require,module,exports){ +},{"../../utils/collection/deepForEach":220,"../arithmetic/add":58,"../arithmetic/divide":63,"../arithmetic/multiply":78,"../probability/factorial":118,"../utils/isInteger":173,"../utils/isPositive":177}],123:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -20514,7 +20907,7 @@ function isPositiveInteger(n) { exports.name = 'permutations'; exports.factory = factory; -},{"../../utils/number":229,"./factorial":116}],122:[function(require,module,exports){ +},{"../../utils/number":231,"./factorial":118}],124:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -20560,7 +20953,7 @@ function factory(type, config, load, typed) { exports.name = 'pickRandom'; exports.factory = factory; -},{"./distribution":115}],123:[function(require,module,exports){ +},{"./distribution":117}],125:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -20606,7 +20999,7 @@ function factory(type, config, load, typed) { exports.name = 'random'; exports.factory = factory; -},{"./distribution":115}],124:[function(require,module,exports){ +},{"./distribution":117}],126:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -20650,7 +21043,7 @@ function factory(type, config, load, typed) { exports.name = 'randomInt'; exports.factory = factory; -},{"./distribution":115}],125:[function(require,module,exports){ +},{"./distribution":117}],127:[function(require,module,exports){ 'use strict'; var seedrandom = require('seed-random'); // create a random seed here to prevent an infinite loop from seed-random @@ -20691,7 +21084,7 @@ function factory(type, config, load, typed, math) { exports.factory = factory; exports.math = true; -},{"seed-random":237}],126:[function(require,module,exports){ +},{"seed-random":481}],128:[function(require,module,exports){ 'use strict'; var nearlyEqual = require('../../utils/number').nearlyEqual; @@ -20864,7 +21257,7 @@ function factory(type, config, load, typed) { exports.name = 'compare'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/bignumber/nearlyEqual":215,"../../utils/number":229}],127:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/bignumber/nearlyEqual":217,"../../utils/number":231}],129:[function(require,module,exports){ 'use strict'; var naturalSort = require('javascript-natural-sort'); @@ -21152,7 +21545,7 @@ function compareComplexNumbers(x, y) { exports.name = 'compareNatural'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../utils/typeof":178,"./compare":126,"javascript-natural-sort":46}],128:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../utils/typeof":180,"./compare":128,"javascript-natural-sort":48}],130:[function(require,module,exports){ 'use strict'; var nearlyEqual = require('../../utils/number').nearlyEqual; @@ -21200,7 +21593,7 @@ function factory(type, config, load, typed) { exports.factory = factory; -},{"../../utils/bignumber/nearlyEqual":215,"../../utils/number":229}],129:[function(require,module,exports){ +},{"../../utils/bignumber/nearlyEqual":217,"../../utils/number":231}],131:[function(require,module,exports){ 'use strict'; var nearlyEqual = require('../../utils/number').nearlyEqual; @@ -21374,7 +21767,7 @@ function factory(type, config, load, typed) { exports.name = 'larger'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm07":204,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/bignumber/nearlyEqual":215,"../../utils/latex":228,"../../utils/number":229}],130:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm07":206,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/bignumber/nearlyEqual":217,"../../utils/latex":230,"../../utils/number":231}],132:[function(require,module,exports){ 'use strict'; var nearlyEqual = require('../../utils/number').nearlyEqual; @@ -21548,12 +21941,12 @@ function factory(type, config, load, typed) { exports.name = 'smaller'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm07":204,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/bignumber/nearlyEqual":215,"../../utils/latex":228,"../../utils/number":229}],131:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm07":206,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/bignumber/nearlyEqual":217,"../../utils/latex":230,"../../utils/number":231}],133:[function(require,module,exports){ "use strict"; module.exports = [require('./mad'), require('./max'), require('./mean'), require('./median'), require('./min'), require('./mode'), require('./prod'), require('./quantileSeq'), require('./std'), require('./sum'), require('./var')]; -},{"./mad":132,"./max":133,"./mean":134,"./median":135,"./min":136,"./mode":137,"./prod":138,"./quantileSeq":139,"./std":140,"./sum":141,"./var":142}],132:[function(require,module,exports){ +},{"./mad":134,"./max":135,"./mean":136,"./median":137,"./min":138,"./mode":139,"./prod":140,"./quantileSeq":141,"./std":142,"./sum":143,"./var":144}],134:[function(require,module,exports){ 'use strict'; var flatten = require('../../utils/array').flatten; @@ -21617,7 +22010,7 @@ function factory(type, config, load, typed) { exports.name = 'mad'; exports.factory = factory; -},{"../../utils/array":212,"../arithmetic/abs":55,"../arithmetic/subtract":85,"../matrix/map":101,"../statistics/median":135}],133:[function(require,module,exports){ +},{"../../utils/array":214,"../arithmetic/abs":57,"../arithmetic/subtract":87,"../matrix/map":103,"../statistics/median":137}],135:[function(require,module,exports){ 'use strict'; var deepForEach = require('../../utils/collection/deepForEach'); @@ -21716,7 +22109,7 @@ function factory(type, config, load, typed) { exports.name = 'max'; exports.factory = factory; -},{"../../utils/collection/containsCollections":217,"../../utils/collection/deepForEach":218,"../../utils/collection/reduce":222,"../relational/larger":129}],134:[function(require,module,exports){ +},{"../../utils/collection/containsCollections":219,"../../utils/collection/deepForEach":220,"../../utils/collection/reduce":224,"../relational/larger":131}],136:[function(require,module,exports){ 'use strict'; var size = require('../../utils/array').size; @@ -21816,7 +22209,7 @@ function factory(type, config, load, typed) { exports.name = 'mean'; exports.factory = factory; -},{"../../utils/array":212,"../../utils/collection/containsCollections":217,"../../utils/collection/deepForEach":218,"../../utils/collection/reduce":222,"../arithmetic/add":56,"../arithmetic/divide":61}],135:[function(require,module,exports){ +},{"../../utils/array":214,"../../utils/collection/containsCollections":219,"../../utils/collection/deepForEach":220,"../../utils/collection/reduce":224,"../arithmetic/add":58,"../arithmetic/divide":63}],137:[function(require,module,exports){ 'use strict'; var flatten = require('../../utils/array').flatten; @@ -21930,7 +22323,7 @@ function factory(type, config, load, typed) { exports.name = 'median'; exports.factory = factory; -},{"../../utils/array":212,"../../utils/collection/containsCollections":217,"../../utils/collection/reduce":222,"../arithmetic/addScalar":57,"../arithmetic/divideScalar":62,"../matrix/partitionSelect":103,"../relational/compare":126}],136:[function(require,module,exports){ +},{"../../utils/array":214,"../../utils/collection/containsCollections":219,"../../utils/collection/reduce":224,"../arithmetic/addScalar":59,"../arithmetic/divideScalar":64,"../matrix/partitionSelect":105,"../relational/compare":128}],138:[function(require,module,exports){ 'use strict'; var deepForEach = require('../../utils/collection/deepForEach'); @@ -22029,7 +22422,7 @@ function factory(type, config, load, typed) { exports.name = 'min'; exports.factory = factory; -},{"../../utils/collection/containsCollections":217,"../../utils/collection/deepForEach":218,"../../utils/collection/reduce":222,"../relational/smaller":130}],137:[function(require,module,exports){ +},{"../../utils/collection/containsCollections":219,"../../utils/collection/deepForEach":220,"../../utils/collection/reduce":224,"../relational/smaller":132}],139:[function(require,module,exports){ 'use strict'; var flatten = require('../../utils/array').flatten; @@ -22110,7 +22503,7 @@ function factory(type, config, load, typed) { exports.name = 'mode'; exports.factory = factory; -},{"../../utils/array":212}],138:[function(require,module,exports){ +},{"../../utils/array":214}],140:[function(require,module,exports){ 'use strict'; var deepForEach = require('../../utils/collection/deepForEach'); @@ -22183,7 +22576,7 @@ function factory(type, config, load, typed) { exports.name = 'prod'; exports.factory = factory; -},{"../../utils/collection/deepForEach":218,"../arithmetic/multiplyScalar":77}],139:[function(require,module,exports){ +},{"../../utils/collection/deepForEach":220,"../arithmetic/multiplyScalar":79}],141:[function(require,module,exports){ 'use strict'; var isInteger = require('../../utils/number').isInteger; @@ -22454,7 +22847,7 @@ function factory(type, config, load, typed) { exports.name = 'quantileSeq'; exports.factory = factory; -},{"../../utils/array":212,"../../utils/collection/isCollection":220,"../../utils/number":229,"../arithmetic/add":56,"../arithmetic/multiply":76,"../matrix/partitionSelect":103,"../relational/compare":126}],140:[function(require,module,exports){ +},{"../../utils/array":214,"../../utils/collection/isCollection":222,"../../utils/number":231,"../arithmetic/add":58,"../arithmetic/multiply":78,"../matrix/partitionSelect":105,"../relational/compare":128}],142:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -22527,7 +22920,7 @@ function factory(type, config, load, typed) { exports.name = 'std'; exports.factory = factory; -},{"../arithmetic/sqrt":83,"../statistics/var":142}],141:[function(require,module,exports){ +},{"../arithmetic/sqrt":85,"../statistics/var":144}],143:[function(require,module,exports){ 'use strict'; var deepForEach = require('../../utils/collection/deepForEach'); @@ -22612,7 +23005,7 @@ function factory(type, config, load, typed) { exports.name = 'sum'; exports.factory = factory; -},{"../../utils/collection/deepForEach":218,"../arithmetic/addScalar":57}],142:[function(require,module,exports){ +},{"../../utils/collection/deepForEach":220,"../arithmetic/addScalar":59}],144:[function(require,module,exports){ 'use strict'; var DEFAULT_NORMALIZATION = 'unbiased'; @@ -22735,7 +23128,7 @@ function factory(type, config, load, typed) { exports.name = 'var'; exports.factory = factory; -},{"../../utils/collection/deepForEach":218,"../arithmetic/addScalar":57,"../arithmetic/divideScalar":62,"../arithmetic/multiplyScalar":77,"../arithmetic/subtract":85}],143:[function(require,module,exports){ +},{"../../utils/collection/deepForEach":220,"../arithmetic/addScalar":59,"../arithmetic/divideScalar":64,"../arithmetic/multiplyScalar":79,"../arithmetic/subtract":87}],145:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -22791,7 +23184,7 @@ function factory(type, config, load, typed) { exports.name = 'acos'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],144:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],146:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -22860,7 +23253,7 @@ var _acosh = Math.acosh || function (x) { exports.name = 'acosh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],145:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],147:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -22912,7 +23305,7 @@ function factory(type, config, load, typed) { exports.name = 'acot'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],146:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],148:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -22966,7 +23359,7 @@ function factory(type, config, load, typed) { exports.name = 'acoth'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],147:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],149:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23022,7 +23415,7 @@ function factory(type, config, load, typed) { exports.name = 'acsc'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],148:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],150:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23073,7 +23466,7 @@ function factory(type, config, load, typed) { exports.name = 'acsch'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],149:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],151:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23129,7 +23522,7 @@ function factory(type, config, load, typed) { exports.name = 'asec'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],150:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],152:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23192,7 +23585,7 @@ function factory(type, config, load, typed) { exports.name = 'asech'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"./acosh":144}],151:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"./acosh":146}],153:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23249,7 +23642,7 @@ function factory(type, config, load, typed) { exports.name = 'asin'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],152:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],154:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23300,7 +23693,7 @@ function factory(type, config, load, typed) { exports.name = 'asinh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],153:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],155:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23353,7 +23746,7 @@ function factory(type, config, load, typed) { exports.name = 'atan'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],154:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],156:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -23503,7 +23896,7 @@ function factory(type, config, load, typed) { exports.name = 'atan2'; exports.factory = factory; -},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm09":205,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210}],155:[function(require,module,exports){ +},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm09":207,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212}],157:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23569,7 +23962,7 @@ var _atanh = Math.atanh || function (x) { exports.name = 'atanh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],156:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],158:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23629,7 +24022,7 @@ function factory(type, config, load, typed) { exports.name = 'cos'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],157:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],159:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23695,7 +24088,7 @@ var _cosh = Math.cosh || function (x) { exports.name = 'cosh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],158:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],160:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23752,7 +24145,7 @@ function factory(type, config, load, typed) { exports.name = 'cot'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],159:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],161:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23821,7 +24214,7 @@ function _coth(x) { exports.name = 'coth'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],160:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],162:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23878,7 +24271,7 @@ function factory(type, config, load, typed) { exports.name = 'csc'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],161:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],163:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -23953,12 +24346,12 @@ function _csch(x) { exports.name = 'csch'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],162:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],164:[function(require,module,exports){ "use strict"; module.exports = [require('./acos'), require('./acosh'), require('./acot'), require('./acoth'), require('./acsc'), require('./acsch'), require('./asec'), require('./asech'), require('./asin'), require('./asinh'), require('./atan'), require('./atan2'), require('./atanh'), require('./cos'), require('./cosh'), require('./cot'), require('./coth'), require('./csc'), require('./csch'), require('./sec'), require('./sech'), require('./sin'), require('./sinh'), require('./tan'), require('./tanh')]; -},{"./acos":143,"./acosh":144,"./acot":145,"./acoth":146,"./acsc":147,"./acsch":148,"./asec":149,"./asech":150,"./asin":151,"./asinh":152,"./atan":153,"./atan2":154,"./atanh":155,"./cos":156,"./cosh":157,"./cot":158,"./coth":159,"./csc":160,"./csch":161,"./sec":163,"./sech":164,"./sin":165,"./sinh":166,"./tan":167,"./tanh":168}],163:[function(require,module,exports){ +},{"./acos":145,"./acosh":146,"./acot":147,"./acoth":148,"./acsc":149,"./acsch":150,"./asec":151,"./asech":152,"./asin":153,"./asinh":154,"./atan":155,"./atan2":156,"./atanh":157,"./cos":158,"./cosh":159,"./cot":160,"./coth":161,"./csc":162,"./csch":163,"./sec":165,"./sech":166,"./sin":167,"./sinh":168,"./tan":169,"./tanh":170}],165:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24015,7 +24408,7 @@ function factory(type, config, load, typed) { exports.name = 'sec'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],164:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],166:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24083,7 +24476,7 @@ function _sech(x) { exports.name = 'sech'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],165:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],167:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24144,7 +24537,7 @@ function factory(type, config, load, typed) { exports.name = 'sin'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],166:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],168:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24211,7 +24604,7 @@ var _sinh = Math.sinh || function (x) { exports.name = 'sinh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],167:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],169:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24269,7 +24662,7 @@ function factory(type, config, load, typed) { exports.name = 'tan'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],168:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],170:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24340,7 +24733,7 @@ var _tanh = Math.tanh || function (x) { exports.name = 'tanh'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],169:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],171:[function(require,module,exports){ 'use strict'; var object = require('../../utils/object'); @@ -24375,12 +24768,12 @@ function factory(type, config, load, typed) { exports.name = 'clone'; exports.factory = factory; -},{"../../utils/object":230}],170:[function(require,module,exports){ +},{"../../utils/object":232}],172:[function(require,module,exports){ "use strict"; module.exports = [require('./clone'), require('./isInteger'), require('./isNegative'), require('./isNumeric'), require('./isPositive'), require('./isPrime'), require('./isZero'), require('./isNaN'), require('./typeof')]; -},{"./clone":169,"./isInteger":171,"./isNaN":172,"./isNegative":173,"./isNumeric":174,"./isPositive":175,"./isPrime":176,"./isZero":177,"./typeof":178}],171:[function(require,module,exports){ +},{"./clone":171,"./isInteger":173,"./isNaN":174,"./isNegative":175,"./isNumeric":176,"./isPositive":177,"./isPrime":178,"./isZero":179,"./typeof":180}],173:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24436,7 +24829,7 @@ function factory(type, config, load, typed) { exports.name = 'isInteger'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],172:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],174:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24499,7 +24892,7 @@ function factory(type, config, load, typed) { exports.name = 'isNaN'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],173:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],175:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24559,7 +24952,7 @@ function factory(type, config, load, typed) { exports.name = 'isNegative'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],174:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],176:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24612,7 +25005,7 @@ function factory(type, config, load, typed) { exports.name = 'isNumeric'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],175:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],177:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24674,7 +25067,7 @@ function factory(type, config, load, typed) { exports.name = 'isPositive'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],176:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],178:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24761,7 +25154,7 @@ function factory(type, config, load, typed) { exports.name = 'isPrime'; exports.factory = factory; -},{"../../utils/collection/deepMap":219}],177:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221}],179:[function(require,module,exports){ 'use strict'; var deepMap = require('../../utils/collection/deepMap'); @@ -24828,7 +25221,7 @@ function factory(type, config, load, typed) { exports.name = 'isZero'; exports.factory = factory; -},{"../../utils/collection/deepMap":219,"../../utils/number":229}],178:[function(require,module,exports){ +},{"../../utils/collection/deepMap":221,"../../utils/number":231}],180:[function(require,module,exports){ 'use strict'; var types = require('../../utils/types'); @@ -24906,7 +25299,7 @@ function factory(type, config, load, typed) { exports.name = 'typeof'; exports.factory = factory; -},{"../../utils/types":232}],179:[function(require,module,exports){ +},{"../../utils/types":234}],181:[function(require,module,exports){ "use strict"; var Decimal = require('decimal.js/decimal.js'); // make sure to pick the es5 version @@ -24963,7 +25356,7 @@ exports.path = 'type'; exports.factory = factory; exports.math = true; // request access to the math namespace -},{"decimal.js/decimal.js":40}],180:[function(require,module,exports){ +},{"decimal.js/decimal.js":42}],182:[function(require,module,exports){ 'use strict'; var deepMap = require('../../../utils/collection/deepMap'); @@ -25026,17 +25419,17 @@ function factory(type, config, load, typed) { exports.name = 'bignumber'; exports.factory = factory; -},{"../../../utils/collection/deepMap":219}],181:[function(require,module,exports){ +},{"../../../utils/collection/deepMap":221}],183:[function(require,module,exports){ "use strict"; module.exports = [// type require('./BigNumber'), // construction function require('./function/bignumber')]; -},{"./BigNumber":179,"./function/bignumber":180}],182:[function(require,module,exports){ +},{"./BigNumber":181,"./function/bignumber":182}],184:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var Complex = require('complex.js'); @@ -25256,7 +25649,7 @@ exports.path = 'type'; exports.factory = factory; exports.math = true; // request access to the math namespace -},{"../../utils/number":229,"complex.js":39}],183:[function(require,module,exports){ +},{"../../utils/number":231,"complex.js":41}],185:[function(require,module,exports){ 'use strict'; var deepMap = require('../../../utils/collection/deepMap'); @@ -25349,14 +25742,14 @@ function factory(type, config, load, typed) { exports.name = 'complex'; exports.factory = factory; -},{"../../../utils/collection/deepMap":219,"../../../utils/latex":228}],184:[function(require,module,exports){ +},{"../../../utils/collection/deepMap":221,"../../../utils/latex":230}],186:[function(require,module,exports){ "use strict"; module.exports = [// type require('./Complex'), // construction function require('./function/complex')]; -},{"./Complex":182,"./function/complex":183}],185:[function(require,module,exports){ +},{"./Complex":184,"./function/complex":185}],187:[function(require,module,exports){ 'use strict'; var deepMap = require('../../../utils/collection/deepMap'); @@ -25420,7 +25813,7 @@ function factory(type, config, load, typed) { exports.name = 'fraction'; exports.factory = factory; -},{"../../../utils/collection/deepMap":219}],186:[function(require,module,exports){ +},{"../../../utils/collection/deepMap":221}],188:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -26315,7 +26708,7 @@ exports.path = 'type'; exports.factory = factory; exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage -},{"../../error/DimensionError":53,"../../utils/customs":224,"../../utils/index":227,"./Matrix":189}],187:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../utils/customs":226,"../../utils/index":229,"./Matrix":191}],189:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -26675,7 +27068,7 @@ exports.name = 'FibonacciHeap'; exports.path = 'type'; exports.factory = factory; -},{"../../function/relational/larger":129,"../../function/relational/smaller":130}],188:[function(require,module,exports){ +},{"../../function/relational/larger":131,"../../function/relational/smaller":132}],190:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -26912,7 +27305,7 @@ exports.name = 'ImmutableDenseMatrix'; exports.path = 'type'; exports.factory = factory; -},{"../../function/relational/smaller":130,"../../utils/index":227,"./DenseMatrix":186}],189:[function(require,module,exports){ +},{"../../function/relational/smaller":132,"../../utils/index":229,"./DenseMatrix":188}],191:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -27196,7 +27589,7 @@ exports.name = 'Matrix'; exports.path = 'type'; exports.factory = factory; -},{"../../utils/index":227}],190:[function(require,module,exports){ +},{"../../utils/index":229}],192:[function(require,module,exports){ 'use strict'; var clone = require('../../utils/object').clone; @@ -27498,7 +27891,7 @@ exports.name = 'Index'; exports.path = 'type'; exports.factory = factory; -},{"../../utils/number":229,"../../utils/object":230}],191:[function(require,module,exports){ +},{"../../utils/number":231,"../../utils/object":232}],193:[function(require,module,exports){ 'use strict'; var number = require('../../utils/number'); @@ -27819,7 +28212,7 @@ exports.name = 'Range'; exports.path = 'type'; exports.factory = factory; -},{"../../utils/number":229}],192:[function(require,module,exports){ +},{"../../utils/number":231}],194:[function(require,module,exports){ 'use strict'; function factory(type, config, load) { @@ -27959,7 +28352,7 @@ exports.name = 'Spa'; exports.path = 'type'; exports.factory = factory; -},{"../../function/arithmetic/add":56,"../../function/relational/equalScalar":128}],193:[function(require,module,exports){ +},{"../../function/arithmetic/add":58,"../../function/relational/equalScalar":130}],195:[function(require,module,exports){ 'use strict'; var util = require('../../utils/index'); @@ -29394,7 +29787,7 @@ exports.path = 'type'; exports.factory = factory; exports.lazy = false; // no lazy loading, as we alter type.Matrix._storage -},{"../../error/DimensionError":53,"../../function/relational/equalScalar":128,"../../utils/index":227,"./Matrix":189}],194:[function(require,module,exports){ +},{"../../error/DimensionError":55,"../../function/relational/equalScalar":130,"../../utils/index":229,"./Matrix":191}],196:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -29457,7 +29850,7 @@ function factory(type, config, load, typed) { exports.name = 'index'; exports.factory = factory; -},{}],195:[function(require,module,exports){ +},{}],197:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -29538,7 +29931,7 @@ function factory(type, config, load, typed) { exports.name = 'matrix'; exports.factory = factory; -},{}],196:[function(require,module,exports){ +},{}],198:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -29595,14 +29988,14 @@ function factory(type, config, load, typed) { exports.name = 'sparse'; exports.factory = factory; -},{}],197:[function(require,module,exports){ +},{}],199:[function(require,module,exports){ "use strict"; module.exports = [// types require('./Matrix'), require('./DenseMatrix'), require('./SparseMatrix'), require('./Spa'), require('./FibonacciHeap'), require('./ImmutableDenseMatrix'), require('./MatrixIndex'), require('./Range'), // construction functions require('./function/index'), require('./function/matrix'), require('./function/sparse')]; -},{"./DenseMatrix":186,"./FibonacciHeap":187,"./ImmutableDenseMatrix":188,"./Matrix":189,"./MatrixIndex":190,"./Range":191,"./Spa":192,"./SparseMatrix":193,"./function/index":194,"./function/matrix":195,"./function/sparse":196}],198:[function(require,module,exports){ +},{"./DenseMatrix":188,"./FibonacciHeap":189,"./ImmutableDenseMatrix":190,"./Matrix":191,"./MatrixIndex":192,"./Range":193,"./Spa":194,"./SparseMatrix":195,"./function/index":196,"./function/matrix":197,"./function/sparse":198}],200:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -29707,7 +30100,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm01'; exports.factory = factory; -},{"../../../error/DimensionError":53}],199:[function(require,module,exports){ +},{"../../../error/DimensionError":55}],201:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -29816,7 +30209,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm02'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../function/relational/equalScalar":128}],200:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../function/relational/equalScalar":130}],202:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -29931,7 +30324,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm03'; exports.factory = factory; -},{"../../../error/DimensionError":53}],201:[function(require,module,exports){ +},{"../../../error/DimensionError":55}],203:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -30104,7 +30497,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm04'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../function/relational/equalScalar":128}],202:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../function/relational/equalScalar":130}],204:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -30270,7 +30663,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm05'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../function/relational/equalScalar":128}],203:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../function/relational/equalScalar":130}],205:[function(require,module,exports){ 'use strict'; var scatter = require('./../../../utils/collection/scatter'); @@ -30421,7 +30814,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm06'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../function/relational/equalScalar":128,"./../../../utils/collection/scatter":223}],204:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../function/relational/equalScalar":130,"./../../../utils/collection/scatter":225}],206:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -30539,7 +30932,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm07'; exports.factory = factory; -},{"../../../error/DimensionError":53}],205:[function(require,module,exports){ +},{"../../../error/DimensionError":55}],207:[function(require,module,exports){ 'use strict'; var DimensionError = require('../../../error/DimensionError'); @@ -30678,7 +31071,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm09'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../function/relational/equalScalar":128}],206:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../function/relational/equalScalar":130}],208:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -30783,7 +31176,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm10'; exports.factory = factory; -},{}],207:[function(require,module,exports){ +},{}],209:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -30886,7 +31279,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm11'; exports.factory = factory; -},{"../../../function/relational/equalScalar":128}],208:[function(require,module,exports){ +},{"../../../function/relational/equalScalar":130}],210:[function(require,module,exports){ 'use strict'; function factory(type, config, load, typed) { @@ -30991,7 +31384,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm12'; exports.factory = factory; -},{}],209:[function(require,module,exports){ +},{}],211:[function(require,module,exports){ 'use strict'; var util = require('../../../utils/index'); @@ -31091,7 +31484,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm13'; exports.factory = factory; -},{"../../../error/DimensionError":53,"../../../utils/index":227}],210:[function(require,module,exports){ +},{"../../../error/DimensionError":55,"../../../utils/index":229}],212:[function(require,module,exports){ 'use strict'; var clone = require('../../../utils/object').clone; @@ -31171,7 +31564,7 @@ function factory(type, config, load, typed) { exports.name = 'algorithm14'; exports.factory = factory; -},{"../../../utils/object":230}],211:[function(require,module,exports){ +},{"../../../utils/object":232}],213:[function(require,module,exports){ 'use strict'; var deepMap = require('./../utils/collection/deepMap'); @@ -31245,7 +31638,7 @@ function factory(type, config, load, typed) { exports.name = 'number'; exports.factory = factory; -},{"./../utils/collection/deepMap":219}],212:[function(require,module,exports){ +},{"./../utils/collection/deepMap":221}],214:[function(require,module,exports){ 'use strict'; var number = require('./number'); @@ -31808,7 +32201,7 @@ exports.generalize = function (a) { exports.isArray = Array.isArray; -},{"../error/DimensionError":53,"../error/IndexError":54,"./number":229,"./object":230,"./string":231,"./types":232}],213:[function(require,module,exports){ +},{"../error/DimensionError":55,"../error/IndexError":56,"./number":231,"./object":232,"./string":233,"./types":234}],215:[function(require,module,exports){ "use strict"; /** @@ -31992,7 +32385,7 @@ exports.toFixed = function (value, precision) { // undefined default precision instead of 0. }; -},{}],214:[function(require,module,exports){ +},{}],216:[function(require,module,exports){ "use strict"; /** @@ -32004,7 +32397,7 @@ module.exports = function isBigNumber(x) { return x && x.constructor.prototype.isBigNumber || false; }; -},{}],215:[function(require,module,exports){ +},{}],217:[function(require,module,exports){ 'use strict'; /** * Compares two BigNumbers. @@ -32050,7 +32443,7 @@ module.exports = function nearlyEqual(x, y, epsilon) { return false; }; -},{}],216:[function(require,module,exports){ +},{}],218:[function(require,module,exports){ 'use strict'; /** * Test whether value is a boolean @@ -32062,7 +32455,7 @@ exports.isBoolean = function (value) { return typeof value == 'boolean'; }; -},{}],217:[function(require,module,exports){ +},{}],219:[function(require,module,exports){ 'use strict'; var isCollection = require('./isCollection'); @@ -32084,7 +32477,7 @@ module.exports = function containsCollections(array) { return false; }; -},{"./isCollection":220}],218:[function(require,module,exports){ +},{"./isCollection":222}],220:[function(require,module,exports){ 'use strict'; var isMatrix = require('./isMatrix'); @@ -32113,7 +32506,7 @@ module.exports = function deepForEach(array, callback) { } }; -},{"./isMatrix":221}],219:[function(require,module,exports){ +},{"./isMatrix":223}],221:[function(require,module,exports){ 'use strict'; /** * Execute the callback function element wise for each element in array and any @@ -32139,7 +32532,7 @@ module.exports = function deepMap(array, callback, skipZeros) { } }; -},{}],220:[function(require,module,exports){ +},{}],222:[function(require,module,exports){ 'use strict'; var isMatrix = require('./isMatrix'); @@ -32154,7 +32547,7 @@ module.exports = function isCollection(x) { return Array.isArray(x) || isMatrix(x); }; -},{"./isMatrix":221}],221:[function(require,module,exports){ +},{"./isMatrix":223}],223:[function(require,module,exports){ 'use strict'; /** * Test whether a value is a Matrix @@ -32167,7 +32560,7 @@ module.exports = function isMatrix(x) { return x && x.constructor.prototype.isMatrix || false; }; -},{}],222:[function(require,module,exports){ +},{}],224:[function(require,module,exports){ 'use strict'; var arraySize = require('../array').size; @@ -32269,7 +32662,7 @@ function _switch(mat) { return ret; } -},{"../../error/IndexError":54,"../array":212,"../collection/isMatrix":221}],223:[function(require,module,exports){ +},{"../../error/IndexError":56,"../array":214,"../collection/isMatrix":223}],225:[function(require,module,exports){ 'use strict'; module.exports = function scatter(a, j, w, x, u, mark, c, f, inverse, update, value) { @@ -32329,10 +32722,10 @@ module.exports = function scatter(a, j, w, x, u, mark, c, f, inverse, update, va } }; -},{}],224:[function(require,module,exports){ +},{}],226:[function(require,module,exports){ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var hasOwnProperty = require('./object').hasOwnProperty; /** @@ -32498,7 +32891,7 @@ exports.validateSafeMethod = validateSafeMethod; exports.isSafeMethod = isSafeMethod; exports.isPlainObject = isPlainObject; -},{"./object":230}],225:[function(require,module,exports){ +},{"./object":232}],227:[function(require,module,exports){ "use strict"; var Emitter = require('tiny-emitter'); @@ -32520,10 +32913,10 @@ exports.mixin = function (obj) { return obj; }; -},{"tiny-emitter":238}],226:[function(require,module,exports){ +},{"tiny-emitter":482}],228:[function(require,module,exports){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } // function utils @@ -32588,7 +32981,7 @@ exports.callWithRightArgumentCount = function (fn, args, argCount) { }, -1); }; -},{}],227:[function(require,module,exports){ +},{}],229:[function(require,module,exports){ 'use strict'; exports.array = require('./array'); @@ -32600,7 +32993,7 @@ exports.string = require('./string'); exports.types = require('./types'); exports.emitter = require('./emitter'); -},{"./array":212,"./boolean":216,"./emitter":225,"./function":226,"./number":229,"./object":230,"./string":231,"./types":232}],228:[function(require,module,exports){ +},{"./array":214,"./boolean":218,"./emitter":227,"./function":228,"./number":231,"./object":232,"./string":233,"./types":234}],230:[function(require,module,exports){ 'use strict'; var escape_latex = require('escape-latex'); @@ -32745,7 +33138,7 @@ exports.toSymbol = function (name, isUnit) { return exports.escape(name); }; -},{"escape-latex":43}],229:[function(require,module,exports){ +},{"escape-latex":45}],231:[function(require,module,exports){ 'use strict'; /** * @typedef {{sign: '+' | '-' | '', coefficients: number[], exponent: number}} SplitValue @@ -33237,10 +33630,10 @@ exports.nearlyEqual = function (x, y, epsilon) { return false; }; -},{}],230:[function(require,module,exports){ +},{}],232:[function(require,module,exports){ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var isBigNumber = require('./bignumber/isBigNumber'); /** @@ -33524,10 +33917,10 @@ exports.isFactory = function (object) { return object && typeof object.factory === 'function'; }; -},{"./bignumber/isBigNumber":214}],231:[function(require,module,exports){ +},{"./bignumber/isBigNumber":216}],233:[function(require,module,exports){ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var formatNumber = require('./number').format; @@ -33738,7 +34131,7 @@ function looksLikeFraction(value) { return value && _typeof(value) === 'object' && typeof value.s === 'number' && typeof value.n === 'number' && typeof value.d === 'number' || false; } -},{"./bignumber/formatter":213,"./bignumber/isBigNumber":214,"./number":229}],232:[function(require,module,exports){ +},{"./bignumber/formatter":215,"./bignumber/isBigNumber":216,"./number":231}],234:[function(require,module,exports){ 'use strict'; /** * Determine the type of a variable @@ -33764,7 +34157,7 @@ function looksLikeFraction(value) { * For example 'number', 'string', 'Array', 'Date'. */ -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } exports.type = function (x) { var type = _typeof(x); @@ -33784,11 +34177,11 @@ exports.type = function (x) { return type; }; -},{}],233:[function(require,module,exports){ +},{}],235:[function(require,module,exports){ (function (global){ "use strict"; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } var numeric = typeof exports === "undefined" ? function numeric() {} : exports; @@ -40390,7 +40783,7 @@ numeric.svd = function svd(A) { }; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],234:[function(require,module,exports){ +},{}],236:[function(require,module,exports){ "use strict"; var math = require('mathjs/core').create(); @@ -40449,430 +40842,245 @@ CSP.prototype.project = function (data, dimensions) { module.exports = CSP; -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/type/matrix":197,"numeric":233,"pw-stat":236}],235:[function(require,module,exports){ -"use strict"; - -var math = require('mathjs/core').create(); - -math.import(require('mathjs/lib/type/matrix')); -math.import(require('mathjs/lib/function/arithmetic')); -math.import(require('mathjs/lib/function/matrix')); - -var stat = require('pw-stat'); -/** - * An LDA object. - * @constructor - * @param {...number[][]} classes - Each parameter is a 2d class array. In each class array, rows are samples, columns are variables. - * @example - * let classifier = new LDA(class1, class2, class3); - */ - - -function LDA() { - for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { - classes[_key] = arguments[_key]; - } - - // Compute pairwise LDA classes (needed for multiclass LDA) - if (classes.length < 2) { - throw new Error('Please pass at least 2 classes'); - } - - var numberOfPairs = classes.length * (classes.length - 1) / 2; - var pair1 = 0; - var pair2 = 1; - var pairs = new Array(numberOfPairs); - - for (var i = 0; i < numberOfPairs; i++) { - pairs[i] = computeLdaParams(classes[pair1], classes[pair2], pair1, pair2); - pair2++; - - if (pair2 == classes.length) { - pair1++; - pair2 = pair1 + 1; - } - } - - this.pairs = pairs; - this.numberOfClasses = classes.length; -} - -function computeLdaParams(class1, class2, class1id, class2id) { - var mu1 = math.transpose(stat.mean(class1)); - var mu2 = math.transpose(stat.mean(class2)); - var pooledCov = math.add(stat.cov(class1), stat.cov(class2)); - var theta = math.multiply(math.inv(pooledCov), math.subtract(mu2, mu1)); - var b = math.multiply(-1, math.transpose(theta), math.add(mu1, mu2), 1 / 2); - return { - theta: theta, - b: b, - class1id: class1id, - class2id: class2id - }; -} -/** - * Project the unknown data point to one dimension. - * Currently only supports binary LDA. - * @param {number[]} point - The data point to be projected. - * @returns {number} value less than 0 if predicted to be in class 1, 0 if exactly in between, greater than 0 if class 2 - */ - - -LDA.prototype.project = function (point) { - if (this.pairs.length != 1) { - throw new Error('LDA project currently only supports 2 classes. LDA classify can be used to perform multiclass classification.'); - } - - return projectPoint(point, this.pairs[0].theta, this.pairs[0].b); -}; - -function projectPoint(point, theta, b) { - return math.add(math.multiply(point, theta), b); -} -/** - * Classify an unknown point. Uses a pairwise voting system in the event of multiclass classification. - * @param {number[]} point - The data point to be classified. - * @returns {number} Returns the predicted class. Class numbers range from 0 to (number_of_classes - 1). - */ - - -LDA.prototype.classify = function (point) { - // In the event of a binary classifier, skip the voting process - if (this.numberOfClasses == 2) { - return projectPoint(point, this.pairs[0].theta, this.pairs[0].b) <= 0 ? 0 : 1; - } // Start each class with 0 votes - - - var votes = new Array(this.numberOfClasses); - - for (var i = 0; i < this.numberOfClasses; i++) { - votes[i] = 0; - } // Allow each pair to cast a vote - - - for (var _i = 0; _i < this.pairs.length; _i++) { - var params = this.pairs[_i]; - var projection = projectPoint(point, params.theta, params.b); - - if (projection <= 0) { - votes[params.class1id]++; - } else { - votes[params.class2id]++; - } - } // Find the winning class - - - var classificaion = 0; - var maxVotes = votes[0]; - - for (var _i2 = 1; _i2 < votes.length; _i2++) { - if (votes[_i2] > maxVotes) { - classificaion = _i2; - maxVotes = votes[_i2]; - } - } - - return classificaion; -}; - -module.exports = LDA; - -},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/type/matrix":197,"pw-stat":236}],236:[function(require,module,exports){ -"use strict"; - -/** - * Returns the covariance matrix for a given matrix. - * @param {number[][]} x - A matrix where rows are samples and columns are variables. - */ -function cov(x) { - // Useful variables - var N = x.length; // Step 1: Find expected value for each variable (columns are variables, rows are samples) - - var E = []; - - for (var c = 0; c < x[0].length; c++) { - var u = 0; - - for (var r = 0; r < N; r++) { - u += x[r][c]; - } - - E.push(u / N); - } // Step 2: Center each variable at 0 - - - var centered = []; - - for (var _r = 0; _r < N; _r++) { - centered.push([]); - - for (var _c = 0; _c < x[0].length; _c++) { - centered[_r].push(x[_r][_c] - E[_c]); - } - } // Step 3: Calculate covariance between each possible combination of variables - - - var S = []; - - for (var i = 0; i < x[0].length; i++) { - S.push([]); - } - - for (var c1 = 0; c1 < x[0].length; c1++) { - // Doing c2 = c1; because, for example, cov(1,2) = cov(2, 1) - // so no need to recalculate - for (var c2 = c1; c2 < x[0].length; c2++) { - // Solve cov(c1, c2) = average of elementwise products of each variable sample - var _cov = 0; - - for (var _r2 = 0; _r2 < N; _r2++) { - _cov += centered[_r2][c1] * centered[_r2][c2]; - } - - _cov /= N - 1; // N-1 for sample covariance, N for population. In this case, using sample covariance - - S[c1][c2] = _cov; - S[c2][c1] = _cov; // Matrix is symmetric - } - } - - return S; -} -/** - * Returns the mean of each column in the provided matrix. - * @param {number[][]} x - Two-dimensional matrix. - */ - - -function mean(x) { - var result = []; - - for (var c = 0; c < x[0].length; c++) { - result.push(0); - } - - for (var r = 0; r < x.length; r++) { - for (var _c2 = 0; _c2 < x[r].length; _c2++) { - result[_c2] += x[r][_c2]; - } - } - - for (var _c3 = 0; _c3 < x[0].length; _c3++) { - result[_c3] /= x.length; - } - - return result; -} - -exports.cov = cov; -exports.mean = mean; - -},{}],237:[function(require,module,exports){ -(function (global){ -'use strict'; - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -var width = 256; // each RC4 output is 0 <= x < 256 - -var chunks = 6; // at least six RC4 outputs for each double - -var digits = 52; // there are 52 significant digits in a double - -var pool = []; // pool: entropy pool starts empty - -var GLOBAL = typeof global === 'undefined' ? window : global; // -// The following constants are related to IEEE 754 limits. -// - -var startdenom = Math.pow(width, chunks), - significance = Math.pow(2, digits), - overflow = significance * 2, - mask = width - 1; -var oldRandom = Math.random; // -// seedrandom() -// This is the seedrandom function described above. -// - -module.exports = function (seed, options) { - if (options && options.global === true) { - options.global = false; - Math.random = module.exports(seed, options); - options.global = true; - return Math.random; - } - - var use_entropy = options && options.entropy || false; - var key = []; // Flatten the seed string or build one from local entropy if needed. - - var shortseed = mixkey(flatten(use_entropy ? [seed, tostring(pool)] : 0 in arguments ? seed : autoseed(), 3), key); // Use the seed to initialize an ARC4 generator. - - var arc4 = new ARC4(key); // Mix the randomness into accumulated entropy. - - mixkey(tostring(arc4.S), pool); // Override Math.random - // This function returns a random double in [0, 1) that contains - // randomness in every bit of the mantissa of the IEEE 754 value. - - return function () { - // Closure to return a random double: - var n = arc4.g(chunks), - // Start with a numerator n < 2 ^ 48 - d = startdenom, - // and denominator d = 2 ^ 48. - x = 0; // and no 'extra last byte'. - - while (n < significance) { - // Fill up all significant digits by - n = (n + x) * width; // shifting numerator and - - d *= width; // denominator and generating a - - x = arc4.g(1); // new least-significant-byte. - } - - while (n >= overflow) { - // To avoid rounding up, before adding - n /= 2; // last byte, shift everything - - d /= 2; // right using integer Math until - - x >>>= 1; // we have exactly the desired bits. - } - - return (n + x) / d; // Form the number within [0, 1). - }; -}; - -module.exports.resetGlobal = function () { - Math.random = oldRandom; -}; // -// ARC4 -// -// An ARC4 implementation. The constructor takes a key in the form of -// an array of at most (width) integers that should be 0 <= x < (width). -// -// The g(count) method returns a pseudorandom integer that concatenates -// the next (count) outputs from ARC4. Its return value is a number x -// that is in the range 0 <= x < (width ^ count). -// - -/** @constructor */ - - -function ARC4(key) { - var t, - keylen = key.length, - me = this, - i = 0, - j = me.i = me.j = 0, - s = me.S = []; // The empty key [] is treated as [0]. - - if (!keylen) { - key = [keylen++]; - } // Set up S using the standard key scheduling algorithm. - - - while (i < width) { - s[i] = i++; - } - - for (i = 0; i < width; i++) { - s[i] = s[j = mask & j + key[i % keylen] + (t = s[i])]; - s[j] = t; - } // The "g" method returns the next (count) outputs as one number. - - - (me.g = function (count) { - // Using instance members instead of closure state nearly doubles speed. - var t, - r = 0, - i = me.i, - j = me.j, - s = me.S; - - while (count--) { - t = s[i = mask & i + 1]; - r = r * width + s[mask & (s[i] = s[j = mask & j + t]) + (s[j] = t)]; - } - - me.i = i; - me.j = j; - return r; // For robust unpredictability discard an initial batch of values. - // See http://www.rsa.com/rsalabs/node.asp?id=2009 - })(width); -} // -// flatten() -// Converts an object tree to nested arrays of strings. -// - - -function flatten(obj, depth) { - var result = [], - typ = _typeof(obj)[0], - prop; - - if (depth && typ == 'o') { - for (prop in obj) { - try { - result.push(flatten(obj[prop], depth - 1)); - } catch (e) {} - } - } - - return result.length ? result : typ == 's' ? obj : obj + '\0'; -} // -// mixkey() -// Mixes a string seed into a key that is an array of integers, and -// returns a shortened string seed that is equivalent to the result key. -// - - -function mixkey(seed, key) { - var stringseed = seed + '', - smear, - j = 0; - - while (j < stringseed.length) { - key[mask & j] = mask & (smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++); - } - - return tostring(key); -} // -// autoseed() -// Returns an object for autoseeding, using window.crypto if available. -// - -/** @param {Uint8Array=} seed */ - - -function autoseed(seed) { - try { - GLOBAL.crypto.getRandomValues(seed = new Uint8Array(width)); - return tostring(seed); - } catch (e) { - return [+new Date(), GLOBAL, GLOBAL.navigator && GLOBAL.navigator.plugins, GLOBAL.screen, tostring(pool)]; - } -} // -// tostring() -// Converts an array of charcodes to a string -// - - -function tostring(a) { - return String.fromCharCode.apply(0, a); -} // -// When seedrandom.js is loaded, we immediately mix a few bits -// from the built-in RNG into the entropy pool. Because we do -// not want to intefere with determinstic PRNG state later, -// seedrandom will not call Math.random on its own again after -// initialization. -// - - -mixkey(Math.random(), pool); - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],238:[function(require,module,exports){ +},{"mathjs/core":237,"mathjs/lib/function/arithmetic":261,"mathjs/lib/function/matrix":288,"mathjs/lib/type/matrix":324,"numeric":235,"pw-stat":480}],237:[function(require,module,exports){ +arguments[4][49][0].apply(exports,arguments) +},{"./lib/core/core":238,"dup":49}],238:[function(require,module,exports){ +arguments[4][50][0].apply(exports,arguments) +},{"./../utils/emitter":348,"./../utils/object":353,"./function/config":239,"./function/import":240,"./typed":241,"dup":50}],239:[function(require,module,exports){ +arguments[4][51][0].apply(exports,arguments) +},{"../../utils/object":353,"dup":51}],240:[function(require,module,exports){ +arguments[4][52][0].apply(exports,arguments) +},{"../../error/ArgumentsError":242,"../../utils/object":353,"dup":52}],241:[function(require,module,exports){ +arguments[4][53][0].apply(exports,arguments) +},{"./../utils/bignumber/isBigNumber":341,"./../utils/collection/isMatrix":345,"./../utils/number":352,"dup":53,"typed-function":357}],242:[function(require,module,exports){ +arguments[4][54][0].apply(exports,arguments) +},{"dup":54}],243:[function(require,module,exports){ +arguments[4][55][0].apply(exports,arguments) +},{"dup":55}],244:[function(require,module,exports){ +arguments[4][56][0].apply(exports,arguments) +},{"dup":56}],245:[function(require,module,exports){ +arguments[4][57][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":57}],246:[function(require,module,exports){ +arguments[4][58][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm01":325,"../../type/matrix/utils/algorithm04":328,"../../type/matrix/utils/algorithm10":333,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex.js":351,"../../utils/object":353,"./addScalar":247,"dup":58}],247:[function(require,module,exports){ +arguments[4][59][0].apply(exports,arguments) +},{"dup":59}],248:[function(require,module,exports){ +arguments[4][60][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/collection/deepMap":344,"../utils/isNegative":309,"./unaryMinus":276,"dup":60}],249:[function(require,module,exports){ +arguments[4][61][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":61}],250:[function(require,module,exports){ +arguments[4][62][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":62}],251:[function(require,module,exports){ +arguments[4][63][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm14":337,"../../utils/object":353,"../matrix/inv":289,"./divideScalar":252,"./multiply":266,"dup":63}],252:[function(require,module,exports){ +arguments[4][64][0].apply(exports,arguments) +},{"./multiplyScalar":267,"dup":64}],253:[function(require,module,exports){ +arguments[4][65][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm02":326,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm07":331,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex":351,"./divideScalar":252,"dup":65}],254:[function(require,module,exports){ +arguments[4][66][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm02":326,"../../type/matrix/utils/algorithm09":332,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex":351,"./multiplyScalar":267,"dup":66}],255:[function(require,module,exports){ +arguments[4][67][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm07":331,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex":351,"./pow":270,"dup":67}],256:[function(require,module,exports){ +arguments[4][68][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":68}],257:[function(require,module,exports){ +arguments[4][69][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":69}],258:[function(require,module,exports){ +arguments[4][70][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":70}],259:[function(require,module,exports){ +arguments[4][71][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm01":325,"../../type/matrix/utils/algorithm04":328,"../../type/matrix/utils/algorithm10":333,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/number":352,"dup":71}],260:[function(require,module,exports){ +arguments[4][72][0].apply(exports,arguments) +},{"../../utils/array":339,"../relational/smaller":308,"../utils/isPositive":310,"./abs":245,"./addScalar":247,"./divideScalar":252,"./multiplyScalar":267,"./sqrt":273,"dup":72}],261:[function(require,module,exports){ +arguments[4][73][0].apply(exports,arguments) +},{"./abs":245,"./add":246,"./addScalar":247,"./cbrt":248,"./ceil":249,"./cube":250,"./divide":251,"./dotDivide":253,"./dotMultiply":254,"./dotPow":255,"./exp":256,"./fix":257,"./floor":258,"./gcd":259,"./hypot":260,"./lcm":262,"./log":263,"./log10":264,"./mod":265,"./multiply":266,"./norm":268,"./nthRoot":269,"./pow":270,"./round":271,"./sign":272,"./sqrt":273,"./square":274,"./subtract":275,"./unaryMinus":276,"./unaryPlus":277,"./xgcd":278,"dup":73}],262:[function(require,module,exports){ +arguments[4][74][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm02":326,"../../type/matrix/utils/algorithm06":330,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/number":352,"dup":74}],263:[function(require,module,exports){ +arguments[4][75][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"./divideScalar":252,"dup":75}],264:[function(require,module,exports){ +arguments[4][76][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":76}],265:[function(require,module,exports){ +arguments[4][77][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm02":326,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm05":329,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex":351,"dup":77}],266:[function(require,module,exports){ +arguments[4][78][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm14":337,"../../utils/array":339,"../../utils/latex":351,"../../utils/object":353,"../relational/equalScalar":306,"./addScalar":247,"./multiplyScalar":267,"dup":78}],267:[function(require,module,exports){ +arguments[4][79][0].apply(exports,arguments) +},{"dup":79}],268:[function(require,module,exports){ +arguments[4][80][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../arithmetic/abs":245,"../arithmetic/add":246,"../arithmetic/multiply":266,"../arithmetic/pow":270,"../arithmetic/sqrt":273,"../matrix/trace":301,"../matrix/transpose":302,"../relational/equalScalar":306,"../relational/larger":307,"../relational/smaller":308,"dup":80}],269:[function(require,module,exports){ +arguments[4][81][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm01":325,"../../type/matrix/utils/algorithm02":326,"../../type/matrix/utils/algorithm06":330,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"dup":81}],270:[function(require,module,exports){ +arguments[4][82][0].apply(exports,arguments) +},{"../../type/fraction/function/fraction":312,"../../type/matrix/function/matrix":322,"../../type/number":338,"../../utils/array":339,"../../utils/latex":351,"../../utils/number":352,"../matrix/eye":284,"./multiply":266,"dup":82}],271:[function(require,module,exports){ +arguments[4][83][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm11":334,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm14":337,"../../utils/collection/deepMap":344,"../../utils/number":352,"../matrix/zeros":303,"../relational/equalScalar":306,"dup":83}],272:[function(require,module,exports){ +arguments[4][84][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"../../utils/number":352,"dup":84}],273:[function(require,module,exports){ +arguments[4][85][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":85}],274:[function(require,module,exports){ +arguments[4][86][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"dup":86}],275:[function(require,module,exports){ +arguments[4][87][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm01":325,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm05":329,"../../type/matrix/utils/algorithm10":333,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/latex":351,"./addScalar":247,"./unaryMinus":276,"dup":87}],276:[function(require,module,exports){ +arguments[4][88][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"../../utils/latex":351,"dup":88}],277:[function(require,module,exports){ +arguments[4][89][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"../../utils/latex":351,"dup":89}],278:[function(require,module,exports){ +arguments[4][90][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/number":352,"dup":90}],279:[function(require,module,exports){ +arguments[4][91][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../error/IndexError":244,"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"../../utils/object":353,"dup":91}],280:[function(require,module,exports){ +arguments[4][92][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../arithmetic/multiply":266,"../arithmetic/subtract":275,"dup":92}],281:[function(require,module,exports){ +arguments[4][93][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/index":350,"../arithmetic/add":246,"../arithmetic/multiply":266,"../arithmetic/subtract":275,"../arithmetic/unaryMinus":276,"dup":93}],282:[function(require,module,exports){ +arguments[4][94][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"../../utils/object":353,"dup":94}],283:[function(require,module,exports){ +arguments[4][95][0].apply(exports,arguments) +},{"../../utils/array":339,"../arithmetic/add":246,"../arithmetic/multiply":266,"dup":95}],284:[function(require,module,exports){ +arguments[4][96][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"dup":96}],285:[function(require,module,exports){ +arguments[4][97][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/function":349,"dup":97}],286:[function(require,module,exports){ +arguments[4][98][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/object":353,"dup":98}],287:[function(require,module,exports){ +arguments[4][99][0].apply(exports,arguments) +},{"../../utils/array":339,"../../utils/function":349,"dup":99}],288:[function(require,module,exports){ +arguments[4][100][0].apply(exports,arguments) +},{"./concat":279,"./cross":280,"./det":281,"./diag":282,"./dot":283,"./eye":284,"./filter":285,"./flatten":286,"./forEach":287,"./inv":289,"./kron":290,"./map":291,"./ones":292,"./partitionSelect":293,"./range":294,"./reshape":295,"./resize":296,"./size":297,"./sort":298,"./squeeze":299,"./subset":300,"./trace":301,"./transpose":302,"./zeros":303,"dup":100}],289:[function(require,module,exports){ +arguments[4][101][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/index":350,"../arithmetic/addScalar":247,"../arithmetic/divideScalar":252,"../arithmetic/multiply":266,"../arithmetic/unaryMinus":276,"../matrix/det":281,"./eye":284,"dup":101}],290:[function(require,module,exports){ +arguments[4][102][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../arithmetic/multiplyScalar":267,"dup":102}],291:[function(require,module,exports){ +arguments[4][103][0].apply(exports,arguments) +},{"../../utils/function":349,"dup":103}],292:[function(require,module,exports){ +arguments[4][104][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"dup":104}],293:[function(require,module,exports){ +arguments[4][105][0].apply(exports,arguments) +},{"../../utils/number":352,"../relational/compare":304,"dup":105}],294:[function(require,module,exports){ +arguments[4][106][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"dup":106}],295:[function(require,module,exports){ +arguments[4][107][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"dup":107}],296:[function(require,module,exports){ +arguments[4][108][0].apply(exports,arguments) +},{"../../error/ArgumentsError":242,"../../error/DimensionError":243,"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"../../utils/object":353,"../../utils/string":354,"dup":108}],297:[function(require,module,exports){ +arguments[4][109][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"dup":109}],298:[function(require,module,exports){ +arguments[4][110][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../relational/compare":304,"../relational/compareNatural":305,"dup":110}],299:[function(require,module,exports){ +arguments[4][111][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/object":353,"dup":111}],300:[function(require,module,exports){ +arguments[4][112][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/customs":347,"../../utils/object":353,"dup":112}],301:[function(require,module,exports){ +arguments[4][113][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/object":353,"../../utils/string":354,"../arithmetic/add":246,"dup":113}],302:[function(require,module,exports){ +arguments[4][114][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/latex":351,"../../utils/object":353,"../../utils/string":354,"dup":114}],303:[function(require,module,exports){ +arguments[4][115][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../utils/array":339,"../../utils/number":352,"dup":115}],304:[function(require,module,exports){ +arguments[4][128][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm05":329,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/bignumber/nearlyEqual":342,"../../utils/number":352,"dup":128}],305:[function(require,module,exports){ +arguments[4][129][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../utils/typeof":311,"./compare":304,"dup":129,"javascript-natural-sort":48}],306:[function(require,module,exports){ +arguments[4][130][0].apply(exports,arguments) +},{"../../utils/bignumber/nearlyEqual":342,"../../utils/number":352,"dup":130}],307:[function(require,module,exports){ +arguments[4][131][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm07":331,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/bignumber/nearlyEqual":342,"../../utils/latex":351,"../../utils/number":352,"dup":131}],308:[function(require,module,exports){ +arguments[4][132][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":322,"../../type/matrix/utils/algorithm03":327,"../../type/matrix/utils/algorithm07":331,"../../type/matrix/utils/algorithm12":335,"../../type/matrix/utils/algorithm13":336,"../../type/matrix/utils/algorithm14":337,"../../utils/bignumber/nearlyEqual":342,"../../utils/latex":351,"../../utils/number":352,"dup":132}],309:[function(require,module,exports){ +arguments[4][175][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"../../utils/number":352,"dup":175}],310:[function(require,module,exports){ +arguments[4][177][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":344,"../../utils/number":352,"dup":177}],311:[function(require,module,exports){ +arguments[4][180][0].apply(exports,arguments) +},{"../../utils/types":355,"dup":180}],312:[function(require,module,exports){ +arguments[4][187][0].apply(exports,arguments) +},{"../../../utils/collection/deepMap":344,"dup":187}],313:[function(require,module,exports){ +arguments[4][188][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../utils/customs":347,"../../utils/index":350,"./Matrix":316,"dup":188}],314:[function(require,module,exports){ +arguments[4][189][0].apply(exports,arguments) +},{"../../function/relational/larger":307,"../../function/relational/smaller":308,"dup":189}],315:[function(require,module,exports){ +arguments[4][190][0].apply(exports,arguments) +},{"../../function/relational/smaller":308,"../../utils/index":350,"./DenseMatrix":313,"dup":190}],316:[function(require,module,exports){ +arguments[4][191][0].apply(exports,arguments) +},{"../../utils/index":350,"dup":191}],317:[function(require,module,exports){ +arguments[4][192][0].apply(exports,arguments) +},{"../../utils/number":352,"../../utils/object":353,"dup":192}],318:[function(require,module,exports){ +arguments[4][193][0].apply(exports,arguments) +},{"../../utils/number":352,"dup":193}],319:[function(require,module,exports){ +arguments[4][194][0].apply(exports,arguments) +},{"../../function/arithmetic/add":246,"../../function/relational/equalScalar":306,"dup":194}],320:[function(require,module,exports){ +arguments[4][195][0].apply(exports,arguments) +},{"../../error/DimensionError":243,"../../function/relational/equalScalar":306,"../../utils/index":350,"./Matrix":316,"dup":195}],321:[function(require,module,exports){ +arguments[4][196][0].apply(exports,arguments) +},{"dup":196}],322:[function(require,module,exports){ +arguments[4][197][0].apply(exports,arguments) +},{"dup":197}],323:[function(require,module,exports){ +arguments[4][198][0].apply(exports,arguments) +},{"dup":198}],324:[function(require,module,exports){ +arguments[4][199][0].apply(exports,arguments) +},{"./DenseMatrix":313,"./FibonacciHeap":314,"./ImmutableDenseMatrix":315,"./Matrix":316,"./MatrixIndex":317,"./Range":318,"./Spa":319,"./SparseMatrix":320,"./function/index":321,"./function/matrix":322,"./function/sparse":323,"dup":199}],325:[function(require,module,exports){ +arguments[4][200][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"dup":200}],326:[function(require,module,exports){ +arguments[4][201][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../function/relational/equalScalar":306,"dup":201}],327:[function(require,module,exports){ +arguments[4][202][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"dup":202}],328:[function(require,module,exports){ +arguments[4][203][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../function/relational/equalScalar":306,"dup":203}],329:[function(require,module,exports){ +arguments[4][204][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../function/relational/equalScalar":306,"dup":204}],330:[function(require,module,exports){ +arguments[4][205][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../function/relational/equalScalar":306,"./../../../utils/collection/scatter":346,"dup":205}],331:[function(require,module,exports){ +arguments[4][206][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"dup":206}],332:[function(require,module,exports){ +arguments[4][207][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../function/relational/equalScalar":306,"dup":207}],333:[function(require,module,exports){ +arguments[4][208][0].apply(exports,arguments) +},{"dup":208}],334:[function(require,module,exports){ +arguments[4][209][0].apply(exports,arguments) +},{"../../../function/relational/equalScalar":306,"dup":209}],335:[function(require,module,exports){ +arguments[4][210][0].apply(exports,arguments) +},{"dup":210}],336:[function(require,module,exports){ +arguments[4][211][0].apply(exports,arguments) +},{"../../../error/DimensionError":243,"../../../utils/index":350,"dup":211}],337:[function(require,module,exports){ +arguments[4][212][0].apply(exports,arguments) +},{"../../../utils/object":353,"dup":212}],338:[function(require,module,exports){ +arguments[4][213][0].apply(exports,arguments) +},{"./../utils/collection/deepMap":344,"dup":213}],339:[function(require,module,exports){ +arguments[4][214][0].apply(exports,arguments) +},{"../error/DimensionError":243,"../error/IndexError":244,"./number":352,"./object":353,"./string":354,"./types":355,"dup":214}],340:[function(require,module,exports){ +arguments[4][215][0].apply(exports,arguments) +},{"dup":215}],341:[function(require,module,exports){ +arguments[4][216][0].apply(exports,arguments) +},{"dup":216}],342:[function(require,module,exports){ +arguments[4][217][0].apply(exports,arguments) +},{"dup":217}],343:[function(require,module,exports){ +arguments[4][218][0].apply(exports,arguments) +},{"dup":218}],344:[function(require,module,exports){ +arguments[4][221][0].apply(exports,arguments) +},{"dup":221}],345:[function(require,module,exports){ +arguments[4][223][0].apply(exports,arguments) +},{"dup":223}],346:[function(require,module,exports){ +arguments[4][225][0].apply(exports,arguments) +},{"dup":225}],347:[function(require,module,exports){ +arguments[4][226][0].apply(exports,arguments) +},{"./object":353,"dup":226}],348:[function(require,module,exports){ +arguments[4][227][0].apply(exports,arguments) +},{"dup":227,"tiny-emitter":356}],349:[function(require,module,exports){ +arguments[4][228][0].apply(exports,arguments) +},{"dup":228}],350:[function(require,module,exports){ +arguments[4][229][0].apply(exports,arguments) +},{"./array":339,"./boolean":343,"./emitter":348,"./function":349,"./number":352,"./object":353,"./string":354,"./types":355,"dup":229}],351:[function(require,module,exports){ +arguments[4][230][0].apply(exports,arguments) +},{"dup":230,"escape-latex":45}],352:[function(require,module,exports){ +arguments[4][231][0].apply(exports,arguments) +},{"dup":231}],353:[function(require,module,exports){ +arguments[4][232][0].apply(exports,arguments) +},{"./bignumber/isBigNumber":341,"dup":232}],354:[function(require,module,exports){ +arguments[4][233][0].apply(exports,arguments) +},{"./bignumber/formatter":340,"./bignumber/isBigNumber":341,"./number":352,"dup":233}],355:[function(require,module,exports){ +arguments[4][234][0].apply(exports,arguments) +},{"dup":234}],356:[function(require,module,exports){ "use strict"; function E() {// Keep this empty so it's easier to inherit from @@ -40932,7 +41140,7 @@ E.prototype = { }; module.exports = E; -},{}],239:[function(require,module,exports){ +},{}],357:[function(require,module,exports){ /** * typed-function * @@ -40942,7 +41150,7 @@ module.exports = E; */ 'use strict'; -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } (function (root, factory) { if (typeof define === 'function' && define.amd) { @@ -42375,12 +42583,681 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat return create(); }); -},{}],240:[function(require,module,exports){ +},{}],358:[function(require,module,exports){ +"use strict"; + +var math = require('mathjs/core').create(); + +math.import(require('mathjs/lib/type/matrix')); +math.import(require('mathjs/lib/function/arithmetic')); +math.import(require('mathjs/lib/function/matrix')); + +var stat = require('pw-stat'); +/** + * An LDA object. + * @constructor + * @param {...number[][]} classes - Each parameter is a 2d class array. In each class array, rows are samples, columns are variables. + * @example + * let classifier = new LDA(class1, class2, class3); + */ + + +function LDA() { + for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) { + classes[_key] = arguments[_key]; + } + + // Compute pairwise LDA classes (needed for multiclass LDA) + if (classes.length < 2) { + throw new Error('Please pass at least 2 classes'); + } + + var numberOfPairs = classes.length * (classes.length - 1) / 2; + var pair1 = 0; + var pair2 = 1; + var pairs = new Array(numberOfPairs); + + for (var i = 0; i < numberOfPairs; i++) { + pairs[i] = computeLdaParams(classes[pair1], classes[pair2], pair1, pair2); + pair2++; + + if (pair2 == classes.length) { + pair1++; + pair2 = pair1 + 1; + } + } + + this.pairs = pairs; + this.numberOfClasses = classes.length; +} + +function computeLdaParams(class1, class2, class1id, class2id) { + var mu1 = math.transpose(stat.mean(class1)); + var mu2 = math.transpose(stat.mean(class2)); + var pooledCov = math.add(stat.cov(class1), stat.cov(class2)); + var theta = math.multiply(math.inv(pooledCov), math.subtract(mu2, mu1)); + var b = math.multiply(-1, math.transpose(theta), math.add(mu1, mu2), 1 / 2); + return { + theta: theta, + b: b, + class1id: class1id, + class2id: class2id + }; +} +/** + * Project the unknown data point to one dimension. + * Currently only supports binary LDA. + * @param {number[]} point - The data point to be projected. + * @returns {number} value less than 0 if predicted to be in class 1, 0 if exactly in between, greater than 0 if class 2 + */ + + +LDA.prototype.project = function (point) { + if (this.pairs.length != 1) { + throw new Error('LDA project currently only supports 2 classes. LDA classify can be used to perform multiclass classification.'); + } + + return projectPoint(point, this.pairs[0].theta, this.pairs[0].b); +}; + +function projectPoint(point, theta, b) { + return math.add(math.multiply(point, theta), b); +} +/** + * Classify an unknown point. Uses a pairwise voting system in the event of multiclass classification. + * @param {number[]} point - The data point to be classified. + * @returns {number} Returns the predicted class. Class numbers range from 0 to (number_of_classes - 1). + */ + + +LDA.prototype.classify = function (point) { + // In the event of a binary classifier, skip the voting process + if (this.numberOfClasses == 2) { + return projectPoint(point, this.pairs[0].theta, this.pairs[0].b) <= 0 ? 0 : 1; + } // Start each class with 0 votes + + + var votes = new Array(this.numberOfClasses); + + for (var i = 0; i < this.numberOfClasses; i++) { + votes[i] = 0; + } // Allow each pair to cast a vote + + + for (var _i = 0; _i < this.pairs.length; _i++) { + var params = this.pairs[_i]; + var projection = projectPoint(point, params.theta, params.b); + + if (projection <= 0) { + votes[params.class1id]++; + } else { + votes[params.class2id]++; + } + } // Find the winning class + + + var classificaion = 0; + var maxVotes = votes[0]; + + for (var _i2 = 1; _i2 < votes.length; _i2++) { + if (votes[_i2] > maxVotes) { + classificaion = _i2; + maxVotes = votes[_i2]; + } + } + + return classificaion; +}; + +module.exports = LDA; + +},{"mathjs/core":359,"mathjs/lib/function/arithmetic":383,"mathjs/lib/function/matrix":410,"mathjs/lib/type/matrix":446,"pw-stat":480}],359:[function(require,module,exports){ +arguments[4][49][0].apply(exports,arguments) +},{"./lib/core/core":360,"dup":49}],360:[function(require,module,exports){ +arguments[4][50][0].apply(exports,arguments) +},{"./../utils/emitter":470,"./../utils/object":475,"./function/config":361,"./function/import":362,"./typed":363,"dup":50}],361:[function(require,module,exports){ +arguments[4][51][0].apply(exports,arguments) +},{"../../utils/object":475,"dup":51}],362:[function(require,module,exports){ +arguments[4][52][0].apply(exports,arguments) +},{"../../error/ArgumentsError":364,"../../utils/object":475,"dup":52}],363:[function(require,module,exports){ +arguments[4][53][0].apply(exports,arguments) +},{"./../utils/bignumber/isBigNumber":463,"./../utils/collection/isMatrix":467,"./../utils/number":474,"dup":53,"typed-function":479}],364:[function(require,module,exports){ +arguments[4][54][0].apply(exports,arguments) +},{"dup":54}],365:[function(require,module,exports){ +arguments[4][55][0].apply(exports,arguments) +},{"dup":55}],366:[function(require,module,exports){ +arguments[4][56][0].apply(exports,arguments) +},{"dup":56}],367:[function(require,module,exports){ +arguments[4][57][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":57}],368:[function(require,module,exports){ +arguments[4][58][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm04":450,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex.js":473,"../../utils/object":475,"./addScalar":369,"dup":58}],369:[function(require,module,exports){ +arguments[4][59][0].apply(exports,arguments) +},{"dup":59}],370:[function(require,module,exports){ +arguments[4][60][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/collection/deepMap":466,"../utils/isNegative":431,"./unaryMinus":398,"dup":60}],371:[function(require,module,exports){ +arguments[4][61][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":61}],372:[function(require,module,exports){ +arguments[4][62][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":62}],373:[function(require,module,exports){ +arguments[4][63][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm14":459,"../../utils/object":475,"../matrix/inv":411,"./divideScalar":374,"./multiply":388,"dup":63}],374:[function(require,module,exports){ +arguments[4][64][0].apply(exports,arguments) +},{"./multiplyScalar":389,"dup":64}],375:[function(require,module,exports){ +arguments[4][65][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./divideScalar":374,"dup":65}],376:[function(require,module,exports){ +arguments[4][66][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm09":454,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./multiplyScalar":389,"dup":66}],377:[function(require,module,exports){ +arguments[4][67][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./pow":392,"dup":67}],378:[function(require,module,exports){ +arguments[4][68][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":68}],379:[function(require,module,exports){ +arguments[4][69][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":69}],380:[function(require,module,exports){ +arguments[4][70][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":70}],381:[function(require,module,exports){ +arguments[4][71][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm04":450,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/number":474,"dup":71}],382:[function(require,module,exports){ +arguments[4][72][0].apply(exports,arguments) +},{"../../utils/array":461,"../relational/smaller":430,"../utils/isPositive":432,"./abs":367,"./addScalar":369,"./divideScalar":374,"./multiplyScalar":389,"./sqrt":395,"dup":72}],383:[function(require,module,exports){ +arguments[4][73][0].apply(exports,arguments) +},{"./abs":367,"./add":368,"./addScalar":369,"./cbrt":370,"./ceil":371,"./cube":372,"./divide":373,"./dotDivide":375,"./dotMultiply":376,"./dotPow":377,"./exp":378,"./fix":379,"./floor":380,"./gcd":381,"./hypot":382,"./lcm":384,"./log":385,"./log10":386,"./mod":387,"./multiply":388,"./norm":390,"./nthRoot":391,"./pow":392,"./round":393,"./sign":394,"./sqrt":395,"./square":396,"./subtract":397,"./unaryMinus":398,"./unaryPlus":399,"./xgcd":400,"dup":73}],384:[function(require,module,exports){ +arguments[4][74][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm06":452,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/number":474,"dup":74}],385:[function(require,module,exports){ +arguments[4][75][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"./divideScalar":374,"dup":75}],386:[function(require,module,exports){ +arguments[4][76][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":76}],387:[function(require,module,exports){ +arguments[4][77][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"dup":77}],388:[function(require,module,exports){ +arguments[4][78][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm14":459,"../../utils/array":461,"../../utils/latex":473,"../../utils/object":475,"../relational/equalScalar":428,"./addScalar":369,"./multiplyScalar":389,"dup":78}],389:[function(require,module,exports){ +arguments[4][79][0].apply(exports,arguments) +},{"dup":79}],390:[function(require,module,exports){ +arguments[4][80][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../arithmetic/abs":367,"../arithmetic/add":368,"../arithmetic/multiply":388,"../arithmetic/pow":392,"../arithmetic/sqrt":395,"../matrix/trace":423,"../matrix/transpose":424,"../relational/equalScalar":428,"../relational/larger":429,"../relational/smaller":430,"dup":80}],391:[function(require,module,exports){ +arguments[4][81][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm06":452,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"dup":81}],392:[function(require,module,exports){ +arguments[4][82][0].apply(exports,arguments) +},{"../../type/fraction/function/fraction":434,"../../type/matrix/function/matrix":444,"../../type/number":460,"../../utils/array":461,"../../utils/latex":473,"../../utils/number":474,"../matrix/eye":406,"./multiply":388,"dup":82}],393:[function(require,module,exports){ +arguments[4][83][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm14":459,"../../utils/collection/deepMap":466,"../../utils/number":474,"../matrix/zeros":425,"../relational/equalScalar":428,"dup":83}],394:[function(require,module,exports){ +arguments[4][84][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"../../utils/number":474,"dup":84}],395:[function(require,module,exports){ +arguments[4][85][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":85}],396:[function(require,module,exports){ +arguments[4][86][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"dup":86}],397:[function(require,module,exports){ +arguments[4][87][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./addScalar":369,"./unaryMinus":398,"dup":87}],398:[function(require,module,exports){ +arguments[4][88][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"../../utils/latex":473,"dup":88}],399:[function(require,module,exports){ +arguments[4][89][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"../../utils/latex":473,"dup":89}],400:[function(require,module,exports){ +arguments[4][90][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/number":474,"dup":90}],401:[function(require,module,exports){ +arguments[4][91][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../error/IndexError":366,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,"dup":91}],402:[function(require,module,exports){ +arguments[4][92][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../arithmetic/multiply":388,"../arithmetic/subtract":397,"dup":92}],403:[function(require,module,exports){ +arguments[4][93][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/index":472,"../arithmetic/add":368,"../arithmetic/multiply":388,"../arithmetic/subtract":397,"../arithmetic/unaryMinus":398,"dup":93}],404:[function(require,module,exports){ +arguments[4][94][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,"dup":94}],405:[function(require,module,exports){ +arguments[4][95][0].apply(exports,arguments) +},{"../../utils/array":461,"../arithmetic/add":368,"../arithmetic/multiply":388,"dup":95}],406:[function(require,module,exports){ +arguments[4][96][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"dup":96}],407:[function(require,module,exports){ +arguments[4][97][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/function":471,"dup":97}],408:[function(require,module,exports){ +arguments[4][98][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/object":475,"dup":98}],409:[function(require,module,exports){ +arguments[4][99][0].apply(exports,arguments) +},{"../../utils/array":461,"../../utils/function":471,"dup":99}],410:[function(require,module,exports){ +arguments[4][100][0].apply(exports,arguments) +},{"./concat":401,"./cross":402,"./det":403,"./diag":404,"./dot":405,"./eye":406,"./filter":407,"./flatten":408,"./forEach":409,"./inv":411,"./kron":412,"./map":413,"./ones":414,"./partitionSelect":415,"./range":416,"./reshape":417,"./resize":418,"./size":419,"./sort":420,"./squeeze":421,"./subset":422,"./trace":423,"./transpose":424,"./zeros":425,"dup":100}],411:[function(require,module,exports){ +arguments[4][101][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/index":472,"../arithmetic/addScalar":369,"../arithmetic/divideScalar":374,"../arithmetic/multiply":388,"../arithmetic/unaryMinus":398,"../matrix/det":403,"./eye":406,"dup":101}],412:[function(require,module,exports){ +arguments[4][102][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../arithmetic/multiplyScalar":389,"dup":102}],413:[function(require,module,exports){ +arguments[4][103][0].apply(exports,arguments) +},{"../../utils/function":471,"dup":103}],414:[function(require,module,exports){ +arguments[4][104][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"dup":104}],415:[function(require,module,exports){ +arguments[4][105][0].apply(exports,arguments) +},{"../../utils/number":474,"../relational/compare":426,"dup":105}],416:[function(require,module,exports){ +arguments[4][106][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"dup":106}],417:[function(require,module,exports){ +arguments[4][107][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"dup":107}],418:[function(require,module,exports){ +arguments[4][108][0].apply(exports,arguments) +},{"../../error/ArgumentsError":364,"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,"../../utils/string":476,"dup":108}],419:[function(require,module,exports){ +arguments[4][109][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"dup":109}],420:[function(require,module,exports){ +arguments[4][110][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../relational/compare":426,"../relational/compareNatural":427,"dup":110}],421:[function(require,module,exports){ +arguments[4][111][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/object":475,"dup":111}],422:[function(require,module,exports){ +arguments[4][112][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/customs":469,"../../utils/object":475,"dup":112}],423:[function(require,module,exports){ +arguments[4][113][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/object":475,"../../utils/string":476,"../arithmetic/add":368,"dup":113}],424:[function(require,module,exports){ +arguments[4][114][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/latex":473,"../../utils/object":475,"../../utils/string":476,"dup":114}],425:[function(require,module,exports){ +arguments[4][115][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"dup":115}],426:[function(require,module,exports){ +arguments[4][128][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/number":474,"dup":128}],427:[function(require,module,exports){ +arguments[4][129][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../utils/typeof":433,"./compare":426,"dup":129,"javascript-natural-sort":48}],428:[function(require,module,exports){ +arguments[4][130][0].apply(exports,arguments) +},{"../../utils/bignumber/nearlyEqual":464,"../../utils/number":474,"dup":130}],429:[function(require,module,exports){ +arguments[4][131][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/latex":473,"../../utils/number":474,"dup":131}],430:[function(require,module,exports){ +arguments[4][132][0].apply(exports,arguments) +},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/latex":473,"../../utils/number":474,"dup":132}],431:[function(require,module,exports){ +arguments[4][175][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"../../utils/number":474,"dup":175}],432:[function(require,module,exports){ +arguments[4][177][0].apply(exports,arguments) +},{"../../utils/collection/deepMap":466,"../../utils/number":474,"dup":177}],433:[function(require,module,exports){ +arguments[4][180][0].apply(exports,arguments) +},{"../../utils/types":477,"dup":180}],434:[function(require,module,exports){ +arguments[4][187][0].apply(exports,arguments) +},{"../../../utils/collection/deepMap":466,"dup":187}],435:[function(require,module,exports){ +arguments[4][188][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../utils/customs":469,"../../utils/index":472,"./Matrix":438,"dup":188}],436:[function(require,module,exports){ +arguments[4][189][0].apply(exports,arguments) +},{"../../function/relational/larger":429,"../../function/relational/smaller":430,"dup":189}],437:[function(require,module,exports){ +arguments[4][190][0].apply(exports,arguments) +},{"../../function/relational/smaller":430,"../../utils/index":472,"./DenseMatrix":435,"dup":190}],438:[function(require,module,exports){ +arguments[4][191][0].apply(exports,arguments) +},{"../../utils/index":472,"dup":191}],439:[function(require,module,exports){ +arguments[4][192][0].apply(exports,arguments) +},{"../../utils/number":474,"../../utils/object":475,"dup":192}],440:[function(require,module,exports){ +arguments[4][193][0].apply(exports,arguments) +},{"../../utils/number":474,"dup":193}],441:[function(require,module,exports){ +arguments[4][194][0].apply(exports,arguments) +},{"../../function/arithmetic/add":368,"../../function/relational/equalScalar":428,"dup":194}],442:[function(require,module,exports){ +arguments[4][195][0].apply(exports,arguments) +},{"../../error/DimensionError":365,"../../function/relational/equalScalar":428,"../../utils/index":472,"./Matrix":438,"dup":195}],443:[function(require,module,exports){ +arguments[4][196][0].apply(exports,arguments) +},{"dup":196}],444:[function(require,module,exports){ +arguments[4][197][0].apply(exports,arguments) +},{"dup":197}],445:[function(require,module,exports){ +arguments[4][198][0].apply(exports,arguments) +},{"dup":198}],446:[function(require,module,exports){ +arguments[4][199][0].apply(exports,arguments) +},{"./DenseMatrix":435,"./FibonacciHeap":436,"./ImmutableDenseMatrix":437,"./Matrix":438,"./MatrixIndex":439,"./Range":440,"./Spa":441,"./SparseMatrix":442,"./function/index":443,"./function/matrix":444,"./function/sparse":445,"dup":199}],447:[function(require,module,exports){ +arguments[4][200][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"dup":200}],448:[function(require,module,exports){ +arguments[4][201][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"dup":201}],449:[function(require,module,exports){ +arguments[4][202][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"dup":202}],450:[function(require,module,exports){ +arguments[4][203][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"dup":203}],451:[function(require,module,exports){ +arguments[4][204][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"dup":204}],452:[function(require,module,exports){ +arguments[4][205][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"./../../../utils/collection/scatter":468,"dup":205}],453:[function(require,module,exports){ +arguments[4][206][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"dup":206}],454:[function(require,module,exports){ +arguments[4][207][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"dup":207}],455:[function(require,module,exports){ +arguments[4][208][0].apply(exports,arguments) +},{"dup":208}],456:[function(require,module,exports){ +arguments[4][209][0].apply(exports,arguments) +},{"../../../function/relational/equalScalar":428,"dup":209}],457:[function(require,module,exports){ +arguments[4][210][0].apply(exports,arguments) +},{"dup":210}],458:[function(require,module,exports){ +arguments[4][211][0].apply(exports,arguments) +},{"../../../error/DimensionError":365,"../../../utils/index":472,"dup":211}],459:[function(require,module,exports){ +arguments[4][212][0].apply(exports,arguments) +},{"../../../utils/object":475,"dup":212}],460:[function(require,module,exports){ +arguments[4][213][0].apply(exports,arguments) +},{"./../utils/collection/deepMap":466,"dup":213}],461:[function(require,module,exports){ +arguments[4][214][0].apply(exports,arguments) +},{"../error/DimensionError":365,"../error/IndexError":366,"./number":474,"./object":475,"./string":476,"./types":477,"dup":214}],462:[function(require,module,exports){ +arguments[4][215][0].apply(exports,arguments) +},{"dup":215}],463:[function(require,module,exports){ +arguments[4][216][0].apply(exports,arguments) +},{"dup":216}],464:[function(require,module,exports){ +arguments[4][217][0].apply(exports,arguments) +},{"dup":217}],465:[function(require,module,exports){ +arguments[4][218][0].apply(exports,arguments) +},{"dup":218}],466:[function(require,module,exports){ +arguments[4][221][0].apply(exports,arguments) +},{"dup":221}],467:[function(require,module,exports){ +arguments[4][223][0].apply(exports,arguments) +},{"dup":223}],468:[function(require,module,exports){ +arguments[4][225][0].apply(exports,arguments) +},{"dup":225}],469:[function(require,module,exports){ +arguments[4][226][0].apply(exports,arguments) +},{"./object":475,"dup":226}],470:[function(require,module,exports){ +arguments[4][227][0].apply(exports,arguments) +},{"dup":227,"tiny-emitter":478}],471:[function(require,module,exports){ +arguments[4][228][0].apply(exports,arguments) +},{"dup":228}],472:[function(require,module,exports){ +arguments[4][229][0].apply(exports,arguments) +},{"./array":461,"./boolean":465,"./emitter":470,"./function":471,"./number":474,"./object":475,"./string":476,"./types":477,"dup":229}],473:[function(require,module,exports){ +arguments[4][230][0].apply(exports,arguments) +},{"dup":230,"escape-latex":45}],474:[function(require,module,exports){ +arguments[4][231][0].apply(exports,arguments) +},{"dup":231}],475:[function(require,module,exports){ +arguments[4][232][0].apply(exports,arguments) +},{"./bignumber/isBigNumber":463,"dup":232}],476:[function(require,module,exports){ +arguments[4][233][0].apply(exports,arguments) +},{"./bignumber/formatter":462,"./bignumber/isBigNumber":463,"./number":474,"dup":233}],477:[function(require,module,exports){ +arguments[4][234][0].apply(exports,arguments) +},{"dup":234}],478:[function(require,module,exports){ +arguments[4][356][0].apply(exports,arguments) +},{"dup":356}],479:[function(require,module,exports){ +arguments[4][357][0].apply(exports,arguments) +},{"dup":357}],480:[function(require,module,exports){ +"use strict"; + +/** + * Returns the covariance matrix for a given matrix. + * @param {number[][]} x - A matrix where rows are samples and columns are variables. + */ +function cov(x) { + // Useful variables + var N = x.length; // Step 1: Find expected value for each variable (columns are variables, rows are samples) + + var E = []; + + for (var c = 0; c < x[0].length; c++) { + var u = 0; + + for (var r = 0; r < N; r++) { + u += x[r][c]; + } + + E.push(u / N); + } // Step 2: Center each variable at 0 + + + var centered = []; + + for (var _r = 0; _r < N; _r++) { + centered.push([]); + + for (var _c = 0; _c < x[0].length; _c++) { + centered[_r].push(x[_r][_c] - E[_c]); + } + } // Step 3: Calculate covariance between each possible combination of variables + + + var S = []; + + for (var i = 0; i < x[0].length; i++) { + S.push([]); + } + + for (var c1 = 0; c1 < x[0].length; c1++) { + // Doing c2 = c1; because, for example, cov(1,2) = cov(2, 1) + // so no need to recalculate + for (var c2 = c1; c2 < x[0].length; c2++) { + // Solve cov(c1, c2) = average of elementwise products of each variable sample + var _cov = 0; + + for (var _r2 = 0; _r2 < N; _r2++) { + _cov += centered[_r2][c1] * centered[_r2][c2]; + } + + _cov /= N - 1; // N-1 for sample covariance, N for population. In this case, using sample covariance + + S[c1][c2] = _cov; + S[c2][c1] = _cov; // Matrix is symmetric + } + } + + return S; +} +/** + * Returns the mean of each column in the provided matrix. + * @param {number[][]} x - Two-dimensional matrix. + */ + + +function mean(x) { + var result = []; + + for (var c = 0; c < x[0].length; c++) { + result.push(0); + } + + for (var r = 0; r < x.length; r++) { + for (var _c2 = 0; _c2 < x[r].length; _c2++) { + result[_c2] += x[r][_c2]; + } + } + + for (var _c3 = 0; _c3 < x[0].length; _c3++) { + result[_c3] /= x.length; + } + + return result; +} + +exports.cov = cov; +exports.mean = mean; + +},{}],481:[function(require,module,exports){ +(function (global){ +'use strict'; + +function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var width = 256; // each RC4 output is 0 <= x < 256 + +var chunks = 6; // at least six RC4 outputs for each double + +var digits = 52; // there are 52 significant digits in a double + +var pool = []; // pool: entropy pool starts empty + +var GLOBAL = typeof global === 'undefined' ? window : global; // +// The following constants are related to IEEE 754 limits. +// + +var startdenom = Math.pow(width, chunks), + significance = Math.pow(2, digits), + overflow = significance * 2, + mask = width - 1; +var oldRandom = Math.random; // +// seedrandom() +// This is the seedrandom function described above. +// + +module.exports = function (seed, options) { + if (options && options.global === true) { + options.global = false; + Math.random = module.exports(seed, options); + options.global = true; + return Math.random; + } + + var use_entropy = options && options.entropy || false; + var key = []; // Flatten the seed string or build one from local entropy if needed. + + var shortseed = mixkey(flatten(use_entropy ? [seed, tostring(pool)] : 0 in arguments ? seed : autoseed(), 3), key); // Use the seed to initialize an ARC4 generator. + + var arc4 = new ARC4(key); // Mix the randomness into accumulated entropy. + + mixkey(tostring(arc4.S), pool); // Override Math.random + // This function returns a random double in [0, 1) that contains + // randomness in every bit of the mantissa of the IEEE 754 value. + + return function () { + // Closure to return a random double: + var n = arc4.g(chunks), + // Start with a numerator n < 2 ^ 48 + d = startdenom, + // and denominator d = 2 ^ 48. + x = 0; // and no 'extra last byte'. + + while (n < significance) { + // Fill up all significant digits by + n = (n + x) * width; // shifting numerator and + + d *= width; // denominator and generating a + + x = arc4.g(1); // new least-significant-byte. + } + + while (n >= overflow) { + // To avoid rounding up, before adding + n /= 2; // last byte, shift everything + + d /= 2; // right using integer Math until + + x >>>= 1; // we have exactly the desired bits. + } + + return (n + x) / d; // Form the number within [0, 1). + }; +}; + +module.exports.resetGlobal = function () { + Math.random = oldRandom; +}; // +// ARC4 +// +// An ARC4 implementation. The constructor takes a key in the form of +// an array of at most (width) integers that should be 0 <= x < (width). +// +// The g(count) method returns a pseudorandom integer that concatenates +// the next (count) outputs from ARC4. Its return value is a number x +// that is in the range 0 <= x < (width ^ count). +// + +/** @constructor */ + + +function ARC4(key) { + var t, + keylen = key.length, + me = this, + i = 0, + j = me.i = me.j = 0, + s = me.S = []; // The empty key [] is treated as [0]. + + if (!keylen) { + key = [keylen++]; + } // Set up S using the standard key scheduling algorithm. + + + while (i < width) { + s[i] = i++; + } + + for (i = 0; i < width; i++) { + s[i] = s[j = mask & j + key[i % keylen] + (t = s[i])]; + s[j] = t; + } // The "g" method returns the next (count) outputs as one number. + + + (me.g = function (count) { + // Using instance members instead of closure state nearly doubles speed. + var t, + r = 0, + i = me.i, + j = me.j, + s = me.S; + + while (count--) { + t = s[i = mask & i + 1]; + r = r * width + s[mask & (s[i] = s[j = mask & j + t]) + (s[j] = t)]; + } + + me.i = i; + me.j = j; + return r; // For robust unpredictability discard an initial batch of values. + // See http://www.rsa.com/rsalabs/node.asp?id=2009 + })(width); +} // +// flatten() +// Converts an object tree to nested arrays of strings. +// + + +function flatten(obj, depth) { + var result = [], + typ = _typeof(obj)[0], + prop; + + if (depth && typ == 'o') { + for (prop in obj) { + try { + result.push(flatten(obj[prop], depth - 1)); + } catch (e) {} + } + } + + return result.length ? result : typ == 's' ? obj : obj + '\0'; +} // +// mixkey() +// Mixes a string seed into a key that is an array of integers, and +// returns a shortened string seed that is equivalent to the result key. +// + + +function mixkey(seed, key) { + var stringseed = seed + '', + smear, + j = 0; + + while (j < stringseed.length) { + key[mask & j] = mask & (smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++); + } + + return tostring(key); +} // +// autoseed() +// Returns an object for autoseeding, using window.crypto if available. +// + +/** @param {Uint8Array=} seed */ + + +function autoseed(seed) { + try { + GLOBAL.crypto.getRandomValues(seed = new Uint8Array(width)); + return tostring(seed); + } catch (e) { + return [+new Date(), GLOBAL, GLOBAL.navigator && GLOBAL.navigator.plugins, GLOBAL.screen, tostring(pool)]; + } +} // +// tostring() +// Converts an array of charcodes to a string +// + + +function tostring(a) { + return String.fromCharCode.apply(0, a); +} // +// When seedrandom.js is loaded, we immediately mix a few bits +// from the built-in RNG into the entropy pool. Because we do +// not want to intefere with determinstic PRNG state later, +// seedrandom will not call Math.random on its own again after +// initialization. +// + + +mixkey(Math.random(), pool); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],482:[function(require,module,exports){ +arguments[4][356][0].apply(exports,arguments) +},{"dup":356}],483:[function(require,module,exports){ +arguments[4][357][0].apply(exports,arguments) +},{"dup":357}],484:[function(require,module,exports){ "use strict"; module.exports = [[0x0300, 0x036F], [0x0483, 0x0486], [0x0488, 0x0489], [0x0591, 0x05BD], [0x05BF, 0x05BF], [0x05C1, 0x05C2], [0x05C4, 0x05C5], [0x05C7, 0x05C7], [0x0600, 0x0603], [0x0610, 0x0615], [0x064B, 0x065E], [0x0670, 0x0670], [0x06D6, 0x06E4], [0x06E7, 0x06E8], [0x06EA, 0x06ED], [0x070F, 0x070F], [0x0711, 0x0711], [0x0730, 0x074A], [0x07A6, 0x07B0], [0x07EB, 0x07F3], [0x0901, 0x0902], [0x093C, 0x093C], [0x0941, 0x0948], [0x094D, 0x094D], [0x0951, 0x0954], [0x0962, 0x0963], [0x0981, 0x0981], [0x09BC, 0x09BC], [0x09C1, 0x09C4], [0x09CD, 0x09CD], [0x09E2, 0x09E3], [0x0A01, 0x0A02], [0x0A3C, 0x0A3C], [0x0A41, 0x0A42], [0x0A47, 0x0A48], [0x0A4B, 0x0A4D], [0x0A70, 0x0A71], [0x0A81, 0x0A82], [0x0ABC, 0x0ABC], [0x0AC1, 0x0AC5], [0x0AC7, 0x0AC8], [0x0ACD, 0x0ACD], [0x0AE2, 0x0AE3], [0x0B01, 0x0B01], [0x0B3C, 0x0B3C], [0x0B3F, 0x0B3F], [0x0B41, 0x0B43], [0x0B4D, 0x0B4D], [0x0B56, 0x0B56], [0x0B82, 0x0B82], [0x0BC0, 0x0BC0], [0x0BCD, 0x0BCD], [0x0C3E, 0x0C40], [0x0C46, 0x0C48], [0x0C4A, 0x0C4D], [0x0C55, 0x0C56], [0x0CBC, 0x0CBC], [0x0CBF, 0x0CBF], [0x0CC6, 0x0CC6], [0x0CCC, 0x0CCD], [0x0CE2, 0x0CE3], [0x0D41, 0x0D43], [0x0D4D, 0x0D4D], [0x0DCA, 0x0DCA], [0x0DD2, 0x0DD4], [0x0DD6, 0x0DD6], [0x0E31, 0x0E31], [0x0E34, 0x0E3A], [0x0E47, 0x0E4E], [0x0EB1, 0x0EB1], [0x0EB4, 0x0EB9], [0x0EBB, 0x0EBC], [0x0EC8, 0x0ECD], [0x0F18, 0x0F19], [0x0F35, 0x0F35], [0x0F37, 0x0F37], [0x0F39, 0x0F39], [0x0F71, 0x0F7E], [0x0F80, 0x0F84], [0x0F86, 0x0F87], [0x0F90, 0x0F97], [0x0F99, 0x0FBC], [0x0FC6, 0x0FC6], [0x102D, 0x1030], [0x1032, 0x1032], [0x1036, 0x1037], [0x1039, 0x1039], [0x1058, 0x1059], [0x1160, 0x11FF], [0x135F, 0x135F], [0x1712, 0x1714], [0x1732, 0x1734], [0x1752, 0x1753], [0x1772, 0x1773], [0x17B4, 0x17B5], [0x17B7, 0x17BD], [0x17C6, 0x17C6], [0x17C9, 0x17D3], [0x17DD, 0x17DD], [0x180B, 0x180D], [0x18A9, 0x18A9], [0x1920, 0x1922], [0x1927, 0x1928], [0x1932, 0x1932], [0x1939, 0x193B], [0x1A17, 0x1A18], [0x1B00, 0x1B03], [0x1B34, 0x1B34], [0x1B36, 0x1B3A], [0x1B3C, 0x1B3C], [0x1B42, 0x1B42], [0x1B6B, 0x1B73], [0x1DC0, 0x1DCA], [0x1DFE, 0x1DFF], [0x200B, 0x200F], [0x202A, 0x202E], [0x2060, 0x2063], [0x206A, 0x206F], [0x20D0, 0x20EF], [0x302A, 0x302F], [0x3099, 0x309A], [0xA806, 0xA806], [0xA80B, 0xA80B], [0xA825, 0xA826], [0xFB1E, 0xFB1E], [0xFE00, 0xFE0F], [0xFE20, 0xFE23], [0xFEFF, 0xFEFF], [0xFFF9, 0xFFFB], [0x10A01, 0x10A03], [0x10A05, 0x10A06], [0x10A0C, 0x10A0F], [0x10A38, 0x10A3A], [0x10A3F, 0x10A3F], [0x1D167, 0x1D169], [0x1D173, 0x1D182], [0x1D185, 0x1D18B], [0x1D1AA, 0x1D1AD], [0x1D242, 0x1D244], [0xE0001, 0xE0001], [0xE0020, 0xE007F], [0xE0100, 0xE01EF]]; -},{}],241:[function(require,module,exports){ +},{}],485:[function(require,module,exports){ "use strict"; var defaults = require('defaults'); @@ -42471,5 +43348,5 @@ function bisearch(ucs) { return false; } -},{"./combining":240,"defaults":41}]},{},[1])(1) +},{"./combining":484,"defaults":43}]},{},[1])(1) }); diff --git a/dist/bci.min.js b/dist/bci.min.js index 54056f8..5c71336 100644 --- a/dist/bci.min.js +++ b/dist/bci.min.js @@ -1,9 +1,9 @@ /** - * bci.js v1.6.5 + * bci.js v1.7.0 * https://github.com/pwstegman/bci.js * * License: MIT - * Generated 2019-11-09T19:46:57Z + * Generated 2020-04-11T13:56:44Z */ -!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).bci=r()}}(function(){var define,module,exports;return function(){return function r(t,e,n){function i(a,u){if(!e[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=e[a]={exports:{}};t[a][0].call(f.exports,function(r){return i(t[a][1][r]||r)},f,f.exports,r,t,e,n)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;a=this.size&&(this.callback(this.channels),this.clear())},u.prototype.clear=function(){this.length=0;for(var r=0;r1?i-1:0),a=1;a1?t-1:0),i=1;i1?e-1:0),o=1;o2&&void 0!==arguments[2]?arguments[2]:"python";t=t.split(" ");var o=[];return t.forEach(function(t){t.indexOf(":");var e=t.split(":");e.length>2||""==t?console.error("Invalid subscript string"):(""==e[1]&&(e[1]=r.length),e=e.map(Number),"matlab"!=i&&"mat"!=i||(e[0]>0&&(e[0]-=1),-1==e[1]&&(e[1]=r.length),e[1]<0&&(e[1]+=1)),1==e.length&&e.push(e[0]+1),o.push(r.slice.apply(r,n(e))))}),(e=[]).concat.apply(e,o)}(t,i.shift(),"matlab");if(0!=i.length)for(var u=0;u3&&void 0!==arguments[3]?arguments[3]:-1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];-1==n&&(n=e);for(var o=[],a=0;a3&&void 0!==arguments[3]?arguments[3]:null,a=new Array(e.length),u=0;u1&&void 0!==arguments[1]?arguments[1]:null;if(null==t)return n.log(n.var(r));if(-1==["rows","cols","columns"].indexOf(t))throw"Invalid dimension";return"cols"!=t&&"columns"!=t||(r=i(r)),r.map(function(r){return n.log(n.var(r))})},t.exports.variance=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null==t)return n.log(n.var(r));if(-1==["rows","cols","columns"].indexOf(t))throw"Invalid dimension";return"cols"!=t&&"columns"!=t||(r=i(r)),r.map(function(r){return n.var(r)})},t.exports.rootMeanSquare=function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null==t)return n.sqrt(n.mean(n.square(r)));if(-1==["rows","cols","columns"].indexOf(t))throw"Invalid dimension";return"cols"!=t&&"columns"!=t||(r=i(r)),r.map(function(r){return n.sqrt(n.mean(n.square(r)))})}},{"./signalBandPower.js":24,"./transpose.js":25,"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/function/statistics":131,"mathjs/lib/type/matrix":197}],17:[function(r,t,e){"use strict";var n=r("mathjs/core").create();n.import(r("mathjs/lib/type/matrix")),n.import(r("mathjs/lib/type/bignumber")),n.import(r("mathjs/lib/function/arithmetic")),n.import(r("mathjs/lib/function/matrix")),n.import(r("mathjs/lib/function/trigonometry")),t.exports=function(r,t,e,i){for(var o=n.range(0,i,1/e),a=n.zeros(o.size()[0]),u=0;u3&&void 0!==arguments[3]?arguments[3]:null;null===i&&(i=Math.pow(2,n(r.length))),("string"==typeof e||e instanceof String)&&(e={delta:[1,3],theta:[4,7],alpha:[8,12],beta:[13,30],gamma:[31,50]}[e]);for(var o=Math.floor(e[0]/t*i),a=Math.min(Math.ceil(e[1]/t*i),r.length-1),u=0,s=o;s<~]))"].join("|");return new RegExp(r,"g")}},{}],36:[function(r,t,e){"use strict";e.byteLength=function(r){var t=c(r),e=t[0],n=t[1];return 3*(e+n)/4-n},e.toByteArray=function(r){var t,e,n=c(r),a=n[0],u=n[1],s=new o(function(r,t,e){return 3*(t+e)/4-e}(0,a,u)),f=0,l=u>0?a-4:a;for(e=0;e>16&255,s[f++]=t>>8&255,s[f++]=255&t;2===u&&(t=i[r.charCodeAt(e)]<<2|i[r.charCodeAt(e+1)]>>4,s[f++]=255&t);1===u&&(t=i[r.charCodeAt(e)]<<10|i[r.charCodeAt(e+1)]<<4|i[r.charCodeAt(e+2)]>>2,s[f++]=t>>8&255,s[f++]=255&t);return s},e.fromByteArray=function(r){for(var t,e=r.length,i=e%3,o=[],a=0,u=e-i;au?u:a+16383));1===i?(t=r[e-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(r[e-2]<<8)+r[e-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,s=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function f(r,t,e){for(var i,o,a=[],u=t;u>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],37:[function(r,t,e){(function(t){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i=r("base64-js"),o=r("ieee754"),a="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=t,e.SlowBuffer=function(r){+r!=r&&(r=0);return t.alloc(+r)},e.INSPECT_MAX_BYTES=50;var u=2147483647;function s(r){if(r>u)throw new RangeError('The value "'+r+'" is invalid for option "size"');var e=new Uint8Array(r);return Object.setPrototypeOf(e,t.prototype),e}function t(r,t,e){if("number"==typeof r){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return l(r)}return c(r,t,e)}function c(r,e,i){if("string"==typeof r)return function(r,e){"string"==typeof e&&""!==e||(e="utf8");if(!t.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var n=0|p(r,e),i=s(n),o=i.write(r,e);o!==n&&(i=i.slice(0,o));return i}(r,e);if(ArrayBuffer.isView(r))return m(r);if(null==r)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+n(r));if(D(r,ArrayBuffer)||r&&D(r.buffer,ArrayBuffer))return function(r,e,n){if(e<0||r.byteLength=u)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+u.toString(16)+" bytes");return 0|r}function p(r,e){if(t.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||D(r,ArrayBuffer))return r.byteLength;if("string"!=typeof r)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+n(r));var i=r.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===i)return 0;for(var a=!1;;)switch(e){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return F(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return q(r).length;default:if(a)return o?-1:F(r).length;e=(""+e).toLowerCase(),a=!0}}function g(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function y(r,e,n,i,o){if(0===r.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),R(n=+n)&&(n=o?0:r.length-1),n<0&&(n=r.length+n),n>=r.length){if(o)return-1;n=r.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof e&&(e=t.from(e,i)),t.isBuffer(e))return 0===e.length?-1:d(r,e,n,i,o);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(r,e,n):Uint8Array.prototype.lastIndexOf.call(r,e,n):d(r,[e],n,i,o);throw new TypeError("val must be string, number or Buffer")}function d(r,t,e,n,i){var o,a=1,u=r.length,s=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(r.length<2||t.length<2)return-1;a=2,u/=2,s/=2,e/=2}function c(r,t){return 1===a?r[t]:r.readUInt16BE(t*a)}if(i){var f=-1;for(o=e;ou&&(e=u-s),o=e;o>=0;o--){for(var l=!0,m=0;mi&&(n=i):n=i;var o=t.length;n>o/2&&(n=o/2);for(var a=0;a>8,i=e%256,o.push(i),o.push(n);return o}(t,r.length-e),r,e,n)}function N(r,t,e){return 0===t&&e===r.length?i.fromByteArray(r):i.fromByteArray(r.slice(t,e))}function _(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+l<=e)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=r[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=r[i+1],a=r[i+2],128==(192&o)&&128==(192&a)&&(s=(15&c)<<12|(63&o)<<6|63&a)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=r[i+1],a=r[i+2],u=r[i+3],128==(192&o)&&128==(192&a)&&128==(192&u)&&(s=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&u)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(r){var t=r.length;if(t<=E)return String.fromCharCode.apply(String,r);var e="",n=0;for(;nthis.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(t>>>=0))return"";for(r||(r="utf8");;)switch(r){case"hex":return B(this,t,e);case"utf8":case"utf-8":return _(this,t,e);case"ascii":return S(this,t,e);case"latin1":case"binary":return j(this,t,e);case"base64":return N(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(r){if(!t.isBuffer(r))throw new TypeError("Argument must be a Buffer");return this===r||0===t.compare(this,r)},t.prototype.inspect=function(){var r="",t=e.INSPECT_MAX_BYTES;return r=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(r+=" ... "),""},a&&(t.prototype[a]=t.prototype.inspect),t.prototype.compare=function(r,e,i,o,a){if(D(r,Uint8Array)&&(r=t.from(r,r.offset,r.byteLength)),!t.isBuffer(r))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+n(r));if(void 0===e&&(e=0),void 0===i&&(i=r?r.length:0),void 0===o&&(o=0),void 0===a&&(a=this.length),e<0||i>r.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&e>=i)return 0;if(o>=a)return-1;if(e>=i)return 1;if(this===r)return 0;for(var u=(a>>>=0)-(o>>>=0),s=(i>>>=0)-(e>>>=0),c=Math.min(u,s),f=this.slice(o,a),l=r.slice(e,i),m=0;m>>=0,isFinite(e)?(e>>>=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var i=this.length-t;if((void 0===e||e>i)&&(e=i),r.length>0&&(e<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,r,t,e);case"utf8":case"utf-8":return x(this,r,t,e);case"ascii":return b(this,r,t,e);case"latin1":case"binary":return w(this,r,t,e);case"base64":return M(this,r,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,r,t,e);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var E=4096;function S(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;in)&&(e=n);for(var i="",o=t;oe)throw new RangeError("Trying to access beyond buffer length")}function C(r,e,n,i,o,a){if(!t.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||er.length)throw new RangeError("Index out of range")}function O(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function k(r,t,e,n,i){return t=+t,e>>>=0,i||O(r,0,e,4),o.write(r,t,e,n,23,4),e+4}function I(r,t,e,n,i){return t=+t,e>>>=0,i||O(r,0,e,8),o.write(r,t,e,n,52,8),e+8}t.prototype.slice=function(r,e){var n=this.length;(r=~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,t>>>=0,e||z(r,t,this.length);for(var n=this[r],i=1,o=0;++o>>=0,t>>>=0,e||z(r,t,this.length);for(var n=this[r+--t],i=1;t>0&&(i*=256);)n+=this[r+--t]*i;return n},t.prototype.readUInt8=function(r,t){return r>>>=0,t||z(r,1,this.length),this[r]},t.prototype.readUInt16LE=function(r,t){return r>>>=0,t||z(r,2,this.length),this[r]|this[r+1]<<8},t.prototype.readUInt16BE=function(r,t){return r>>>=0,t||z(r,2,this.length),this[r]<<8|this[r+1]},t.prototype.readUInt32LE=function(r,t){return r>>>=0,t||z(r,4,this.length),(this[r]|this[r+1]<<8|this[r+2]<<16)+16777216*this[r+3]},t.prototype.readUInt32BE=function(r,t){return r>>>=0,t||z(r,4,this.length),16777216*this[r]+(this[r+1]<<16|this[r+2]<<8|this[r+3])},t.prototype.readIntLE=function(r,t,e){r>>>=0,t>>>=0,e||z(r,t,this.length);for(var n=this[r],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},t.prototype.readIntBE=function(r,t,e){r>>>=0,t>>>=0,e||z(r,t,this.length);for(var n=t,i=1,o=this[r+--n];n>0&&(i*=256);)o+=this[r+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},t.prototype.readInt8=function(r,t){return r>>>=0,t||z(r,1,this.length),128&this[r]?-1*(255-this[r]+1):this[r]},t.prototype.readInt16LE=function(r,t){r>>>=0,t||z(r,2,this.length);var e=this[r]|this[r+1]<<8;return 32768&e?4294901760|e:e},t.prototype.readInt16BE=function(r,t){r>>>=0,t||z(r,2,this.length);var e=this[r+1]|this[r]<<8;return 32768&e?4294901760|e:e},t.prototype.readInt32LE=function(r,t){return r>>>=0,t||z(r,4,this.length),this[r]|this[r+1]<<8|this[r+2]<<16|this[r+3]<<24},t.prototype.readInt32BE=function(r,t){return r>>>=0,t||z(r,4,this.length),this[r]<<24|this[r+1]<<16|this[r+2]<<8|this[r+3]},t.prototype.readFloatLE=function(r,t){return r>>>=0,t||z(r,4,this.length),o.read(this,r,!0,23,4)},t.prototype.readFloatBE=function(r,t){return r>>>=0,t||z(r,4,this.length),o.read(this,r,!1,23,4)},t.prototype.readDoubleLE=function(r,t){return r>>>=0,t||z(r,8,this.length),o.read(this,r,!0,52,8)},t.prototype.readDoubleBE=function(r,t){return r>>>=0,t||z(r,8,this.length),o.read(this,r,!1,52,8)},t.prototype.writeUIntLE=function(r,t,e,n){(r=+r,t>>>=0,e>>>=0,n)||C(this,r,t,e,Math.pow(2,8*e)-1,0);var i=1,o=0;for(this[t]=255&r;++o>>=0,e>>>=0,n)||C(this,r,t,e,Math.pow(2,8*e)-1,0);var i=e-1,o=1;for(this[t+i]=255&r;--i>=0&&(o*=256);)this[t+i]=r/o&255;return t+e},t.prototype.writeUInt8=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,1,255,0),this[t]=255&r,t+1},t.prototype.writeUInt16LE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,2,65535,0),this[t]=255&r,this[t+1]=r>>>8,t+2},t.prototype.writeUInt16BE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,2,65535,0),this[t]=r>>>8,this[t+1]=255&r,t+2},t.prototype.writeUInt32LE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,4,4294967295,0),this[t+3]=r>>>24,this[t+2]=r>>>16,this[t+1]=r>>>8,this[t]=255&r,t+4},t.prototype.writeUInt32BE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,4,4294967295,0),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r,t+4},t.prototype.writeIntLE=function(r,t,e,n){if(r=+r,t>>>=0,!n){var i=Math.pow(2,8*e-1);C(this,r,t,e,i-1,-i)}var o=0,a=1,u=0;for(this[t]=255&r;++o>0)-u&255;return t+e},t.prototype.writeIntBE=function(r,t,e,n){if(r=+r,t>>>=0,!n){var i=Math.pow(2,8*e-1);C(this,r,t,e,i-1,-i)}var o=e-1,a=1,u=0;for(this[t+o]=255&r;--o>=0&&(a*=256);)r<0&&0===u&&0!==this[t+o+1]&&(u=1),this[t+o]=(r/a>>0)-u&255;return t+e},t.prototype.writeInt8=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,1,127,-128),r<0&&(r=255+r+1),this[t]=255&r,t+1},t.prototype.writeInt16LE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,2,32767,-32768),this[t]=255&r,this[t+1]=r>>>8,t+2},t.prototype.writeInt16BE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,2,32767,-32768),this[t]=r>>>8,this[t+1]=255&r,t+2},t.prototype.writeInt32LE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,4,2147483647,-2147483648),this[t]=255&r,this[t+1]=r>>>8,this[t+2]=r>>>16,this[t+3]=r>>>24,t+4},t.prototype.writeInt32BE=function(r,t,e){return r=+r,t>>>=0,e||C(this,r,t,4,2147483647,-2147483648),r<0&&(r=4294967295+r+1),this[t]=r>>>24,this[t+1]=r>>>16,this[t+2]=r>>>8,this[t+3]=255&r,t+4},t.prototype.writeFloatLE=function(r,t,e){return k(this,r,t,!0,e)},t.prototype.writeFloatBE=function(r,t,e){return k(this,r,t,!1,e)},t.prototype.writeDoubleLE=function(r,t,e){return I(this,r,t,!0,e)},t.prototype.writeDoubleBE=function(r,t,e){return I(this,r,t,!1,e)},t.prototype.copy=function(r,e,n,i){if(!t.isBuffer(r))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=r.length&&(e=r.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),r.length-e=0;--a)r[a+e]=this[a+n];else Uint8Array.prototype.set.call(r,this.subarray(n,i),e);return o},t.prototype.fill=function(r,e,n,i){if("string"==typeof r){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!t.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===r.length){var o=r.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(r=o)}}else"number"==typeof r?r&=255:"boolean"==typeof r&&(r=Number(r));if(e<0||this.length>>=0,n=void 0===n?this.length:n>>>0,r||(r=0),"number"==typeof r)for(a=e;a55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=65536+(i-55296<<10|e-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,63&e|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return o}function q(r){return i.toByteArray(function(r){if((r=(r=r.split("=")[0]).trim().replace(P,"")).length<2)return"";for(;r.length%4!=0;)r+="=";return r}(r))}function U(r,t,e,n){for(var i=0;i=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function D(r,t){return r instanceof t||null!=r&&null!=r.constructor&&null!=r.constructor.name&&r.constructor.name===t.name}function R(r){return r!=r}var L=function(){for(var r=new Array(256),t=0;t<16;++t)for(var e=16*t,n=0;n<16;++n)r[e+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return r}()}).call(this,r("buffer").Buffer)},{"base64-js":36,buffer:37,ieee754:45}],38:[function(r,t,e){(function(r){"use strict";function e(r){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var n=function(){function t(n,o,a,u){"object"===e(o)&&(a=o.depth,u=o.prototype,o.filter,o=o.circular);var s=[],c=[],f=void 0!==r;return void 0===o&&(o=!0),void 0===a&&(a=1/0),function n(a,l){if(null===a)return null;if(0==l)return a;var m,h;if("object"!=e(a))return a;if(t.__isArray(a))m=[];else if(t.__isRegExp(a))m=new RegExp(a.source,i(a)),a.lastIndex&&(m.lastIndex=a.lastIndex);else if(t.__isDate(a))m=new Date(a.getTime());else{if(f&&r.isBuffer(a))return m=r.allocUnsafe?r.allocUnsafe(a.length):new r(a.length),a.copy(m),m;void 0===u?(h=Object.getPrototypeOf(a),m=Object.create(h)):(m=Object.create(u),h=u)}if(o){var p=s.indexOf(a);if(-1!=p)return c[p];s.push(a),c.push(m)}for(var g in a){var y;h&&(y=Object.getOwnPropertyDescriptor(h,g)),y&&null==y.set||(m[g]=n(a[g],l-1))}return m}(n,a)}function n(r){return Object.prototype.toString.call(r)}function i(r){var t="";return r.global&&(t+="g"),r.ignoreCase&&(t+="i"),r.multiline&&(t+="m"),t}return t.clonePrototype=function(r){if(null===r)return null;var t=function(){};return t.prototype=r,new t},t.__objToStr=n,t.__isDate=function(r){return"object"===e(r)&&"[object Date]"===n(r)},t.__isArray=function(r){return"object"===e(r)&&"[object Array]"===n(r)},t.__isRegExp=function(r){return"object"===e(r)&&"[object RegExp]"===n(r)},t.__getRegExpFlags=i,t}();"object"===(void 0===t?"undefined":e(t))&&t.exports&&(t.exports=n)}).call(this,r("buffer").Buffer)},{buffer:37}],39:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}!function(r){var i={re:0,im:0},o=function(r){return.5*(Math.exp(r)+Math.exp(-r))},a=function(r){return.5*(Math.exp(r)-Math.exp(-r))},u=function(){throw SyntaxError("Invalid Param")};function s(r,t){var e=Math.abs(r),n=Math.abs(t);return 0===r?Math.log(n):0===t?Math.log(e):e<3e3&&n<3e3?.5*Math.log(r*r+t*t):Math.log(r/Math.cos(Math.atan2(t,r)))}var c=function(r,t){if(null==r)i.re=i.im=0;else if(void 0!==t)i.re=r,i.im=t;else switch(n(r)){case"object":"im"in r&&"re"in r?(i.re=r.re,i.im=r.im):"abs"in r&&"arg"in r?(i.re=r.abs*Math.cos(r.arg),i.im=r.abs*Math.sin(r.arg)):"r"in r&&"phi"in r?(i.re=r.r*Math.cos(r.phi),i.im=r.r*Math.sin(r.phi)):2===r.length?(i.re=r[0],i.im=r[1]):u();break;case"string":i.im=i.re=0;var e=r.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),o=1,a=0;null===e&&u();for(var s=0;s0&&u();break;case"number":i.im=0,i.re=r;break;default:u()}isNaN(i.re)||isNaN(i.im)};function f(r,t){if(!(this instanceof f))return new f(r,t);c(r,t),this.re=i.re,this.im=i.im}f.prototype={re:0,im:0,sign:function(){var r=this.abs();return new f(this.re/r,this.im/r)},add:function(r,t){return c(r,t),new f(this.re+i.re,this.im+i.im)},sub:function(r,t){return c(r,t),new f(this.re-i.re,this.im-i.im)},mul:function(r,t){return c(r,t),0===i.im&&0===this.im?new f(this.re*i.re,0):new f(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)},div:function(r,t){c(r,t),r=this.re,t=this.im;var e,n,o=i.re,a=i.im;return 0===a?0===o?new f(0!==r?r/0:0,0!==t?t/0:0):new f(r/o,t/o):Math.abs(o)=0)return new f(Math.pow(r,i.re),0);if(0===r)switch((i.re%4+4)%4){case 0:return new f(Math.pow(t,i.re),0);case 1:return new f(0,Math.pow(t,i.re));case 2:return new f(-Math.pow(t,i.re),0);case 3:return new f(0,-Math.pow(t,i.re))}}var e=Math.atan2(t,r),n=s(r,t);return r=Math.exp(i.re*n-i.im*e),t=i.im*n+i.re*e,new f(r*Math.cos(t),r*Math.sin(t))},sqrt:function(){var r,t,e=this.re,n=this.im,i=this.abs();if(e>=0){if(0===n)return new f(Math.sqrt(e),0);r=.5*Math.sqrt(2*(i+e))}else r=Math.abs(n)/Math.sqrt(2*(i-e));return t=e<=0?.5*Math.sqrt(2*(i-e)):Math.abs(n)/Math.sqrt(2*(i+e)),new f(r,n<0?-t:t)},exp:function(){var r=Math.exp(this.re);return this.im,new f(r*Math.cos(this.im),r*Math.sin(this.im))},log:function(){var r=this.re,t=this.im;return new f(s(r,t),Math.atan2(t,r))},abs:function(){return r=this.re,t=this.im,e=Math.abs(r),n=Math.abs(t),e<3e3&&n<3e3?Math.sqrt(e*e+n*n):(e1&&0===t,n=1-r,i=1+r,o=n*n+t*t,a=0!==o?new f((i*n-t*t)/o,(t*n+i*t)/o):new f(-1!==r?r/0:0,0!==t?t/0:0),u=a.re;return a.re=s(a.re,a.im)/2,a.im=Math.atan2(a.im,u)/2,e&&(a.im=-a.im),a},acoth:function(){var r=this.re,t=this.im;if(0===r&&0===t)return new f(0,Math.PI/2);var e=r*r+t*t;return 0!==e?new f(r/e,-t/e).atanh():new f(0!==r?r/0:0,0!==t?-t/0:0).atanh()},acsch:function(){var r=this.re,t=this.im;if(0===t)return new f(0!==r?Math.log(r+Math.sqrt(r*r+1)):1/0,0);var e=r*r+t*t;return 0!==e?new f(r/e,-t/e).asinh():new f(0!==r?r/0:0,0!==t?-t/0:0).asinh()},asech:function(){var r=this.re,t=this.im;if(0===r&&0===t)return new f(1/0,0);var e=r*r+t*t;return 0!==e?new f(r/e,-t/e).acosh():new f(0!==r?r/0:0,0!==t?-t/0:0).acosh()},inverse:function(){var r=this.re,t=this.im,e=r*r+t*t;return new f(0!==r?r/e:0,0!==t?-t/e:0)},conjugate:function(){return new f(this.re,-this.im)},neg:function(){return new f(-this.re,-this.im)},ceil:function(r){return r=Math.pow(10,r||0),new f(Math.ceil(this.re*r)/r,Math.ceil(this.im*r)/r)},floor:function(r){return r=Math.pow(10,r||0),new f(Math.floor(this.re*r)/r,Math.floor(this.im*r)/r)},round:function(r){return r=Math.pow(10,r||0),new f(Math.round(this.re*r)/r,Math.round(this.im*r)/r)},equals:function(r,t){return c(r,t),Math.abs(i.re-this.re)<=f.EPSILON&&Math.abs(i.im-this.im)<=f.EPSILON},clone:function(){return new f(this.re,this.im)},toString:function(){var r=this.re,t=this.im,e="";return isNaN(r)||isNaN(t)?"NaN":(0!==r&&(e+=r),0!==t&&(0!==r?e+=t<0?" - ":" + ":t<0&&(e+="-"),1!==(t=Math.abs(t))&&(e+=t),e+="i"),e||"0")},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(r){function t(){return r.apply(this,arguments)}return t.toString=function(){return r.toString()},t}(function(){return isNaN(this.re)||isNaN(this.im)}),isFinite:function(r){function t(){return r.apply(this,arguments)}return t.toString=function(){return r.toString()},t}(function(){return isFinite(this.re)&&isFinite(this.im)})},f.ZERO=new f(0,0),f.ONE=new f(1,0),f.I=new f(0,1),f.PI=new f(Math.PI,0),f.E=new f(Math.E,0),f.EPSILON=1e-16,"function"==typeof define&&define.amd?define([],function(){return f}):"object"===(void 0===e?"undefined":n(e))?t.exports=f:(void 0).Complex=f}()},{}],40:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}!function(r){var e,i,o,a,u=9e15,s=1e9,c="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",l="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",m={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},h=!0,p="[DecimalError] ",g=p+"Invalid argument: ",y=p+"Precision limit exceeded",d=p+"crypto unavailable",v=Math.floor,x=Math.pow,b=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,w=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,M=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,A=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,N=1e7,_=7,E=f.length-1,S=l.length-1,j={name:"[object Decimal]"};function B(r){var t,e,n,i=r.length-1,o="",a=r[0];if(i>0){for(o+=a,t=1;te)throw Error(g+r)}function z(r,t,e,n){var i,o,a,u;for(o=r[0];o>=10;o/=10)--t;return--t<0?(t+=_,i=0):(i=Math.ceil((t+1)/_),t%=_),o=x(10,_-t),u=r[i]%o|0,null==n?t<3?(0==t?u=u/100|0:1==t&&(u=u/10|0),a=e<4&&99999==u||e>3&&49999==u||5e4==u||0==u):a=(e<4&&u+1==o||e>3&&u+1==o/2)&&(r[i+1]/o/100|0)==x(10,t-2)-1||(u==o/2||0==u)&&0==(r[i+1]/o/100|0):t<4?(0==t?u=u/1e3|0:1==t?u=u/100|0:2==t&&(u=u/10|0),a=(n||e<4)&&9999==u||!n&&e>3&&4999==u):a=((n||e<4)&&u+1==o||!n&&e>3&&u+1==o/2)&&(r[i+1]/o/1e3|0)==x(10,t-3)-1,a}function C(r,t,e){for(var n,i,o=[0],a=0,u=r.length;ae-1&&(void 0===o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/e|0,o[n]%=e)}return o.reverse()}j.absoluteValue=j.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),k(r)},j.ceil=function(){return k(new this.constructor(this),this.e+1,2)},j.comparedTo=j.cmp=function(r){var t,e,n,i,o=this,a=o.d,u=(r=new o.constructor(r)).d,s=o.s,c=r.s;if(!a||!u)return s&&c?s!==c?s:a===u?0:!a^s<0?1:-1:NaN;if(!a[0]||!u[0])return a[0]?s:u[0]?-c:0;if(s!==c)return s;if(o.e!==r.e)return o.e>r.e^s<0?1:-1;for(t=0,e=(n=a.length)<(i=u.length)?n:i;tu[t]^s<0?1:-1;return n===i?0:n>i^s<0?1:-1},j.cosine=j.cos=function(){var r,t,e=this,n=e.constructor;return e.d?e.d[0]?(r=n.precision,t=n.rounding,n.precision=r+Math.max(e.e,e.sd())+_,n.rounding=1,e=function(r,t){var e,n,i=t.d.length;i<32?(e=Math.ceil(i/3),n=Math.pow(4,-e).toString()):(e=16,n="2.3283064365386962890625e-10");r.precision+=e,t=J(r,1,t.times(n),new r(1));for(var o=e;o--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return r.precision-=e,t}(n,G(n,e)),n.precision=r,n.rounding=t,k(2==a||3==a?e.neg():e,r,t,!0)):new n(1):new n(NaN)},j.cubeRoot=j.cbrt=function(){var r,t,e,n,i,o,a,u,s,c,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(h=!1,(o=f.s*Math.pow(f.s*f,1/3))&&Math.abs(o)!=1/0?n=new l(o.toString()):(e=B(f.d),(o=((r=f.e)-e.length+1)%3)&&(e+=1==o||-2==o?"0":"00"),o=Math.pow(e,1/3),r=v((r+1)/3)-(r%3==(r<0?-1:2)),(n=new l(e=o==1/0?"5e"+r:(e=o.toExponential()).slice(0,e.indexOf("e")+1)+r)).s=f.s),a=(r=l.precision)+3;;)if(c=(s=(u=n).times(u).times(u)).plus(f),n=O(c.plus(f).times(u),c.plus(s),a+2,1),B(u.d).slice(0,a)===(e=B(n.d)).slice(0,a)){if("9999"!=(e=e.slice(a-3,a+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(k(n,r+1,1),t=!n.times(n).times(n).eq(f));break}if(!i&&(k(u,r+1,0),u.times(u).times(u).eq(f))){n=u;break}a+=4,i=1}return h=!0,k(n,r,l.rounding,t)},j.decimalPlaces=j.dp=function(){var r,t=this.d,e=NaN;if(t){if(e=((r=t.length-1)-v(this.e/_))*_,r=t[r])for(;r%10==0;r/=10)e--;e<0&&(e=0)}return e},j.dividedBy=j.div=function(r){return O(this,new this.constructor(r))},j.dividedToIntegerBy=j.divToInt=function(r){var t=this.constructor;return k(O(this,new t(r),0,1,1),t.precision,t.rounding)},j.equals=j.eq=function(r){return 0===this.cmp(r)},j.floor=function(){return k(new this.constructor(this),this.e+1,3)},j.greaterThan=j.gt=function(r){return this.cmp(r)>0},j.greaterThanOrEqualTo=j.gte=function(r){var t=this.cmp(r);return 1==t||0===t},j.hyperbolicCosine=j.cosh=function(){var r,t,e,n,i,o=this,a=o.constructor,u=new a(1);if(!o.isFinite())return new a(o.s?1/0:NaN);if(o.isZero())return u;e=a.precision,n=a.rounding,a.precision=e+Math.max(o.e,o.sd())+4,a.rounding=1,(i=o.d.length)<32?(r=Math.ceil(i/3),t=Math.pow(4,-r).toString()):(r=16,t="2.3283064365386962890625e-10"),o=J(a,1,o.times(t),new a(1),!0);for(var s,c=r,f=new a(8);c--;)s=o.times(o),o=u.minus(s.times(f.minus(s.times(f))));return k(o,a.precision=e,a.rounding=n,!0)},j.hyperbolicSine=j.sinh=function(){var r,t,e,n,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(t=o.precision,e=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,(n=i.d.length)<3)i=J(o,2,i,i,!0);else{r=(r=1.4*Math.sqrt(n))>16?16:0|r,i=J(o,2,i=i.times(Math.pow(5,-r)),i,!0);for(var a,u=new o(5),s=new o(16),c=new o(20);r--;)a=i.times(i),i=i.times(u.plus(a.times(s.times(a).plus(c))))}return o.precision=t,o.rounding=e,k(i,t,e,!0)},j.hyperbolicTangent=j.tanh=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+7,n.rounding=1,O(e.sinh(),e.cosh(),n.precision=r,n.rounding=t)):new n(e.s)},j.inverseCosine=j.acos=function(){var r,t=this,e=t.constructor,n=t.abs().cmp(1),i=e.precision,o=e.rounding;return-1!==n?0===n?t.isNeg()?q(e,i,o):new e(0):new e(NaN):t.isZero()?q(e,i+4,o).times(.5):(e.precision=i+6,e.rounding=1,t=t.asin(),r=q(e,i+4,o).times(.5),e.precision=i,e.rounding=o,r.minus(t))},j.inverseHyperbolicCosine=j.acosh=function(){var r,t,e=this,n=e.constructor;return e.lte(1)?new n(e.eq(1)?0:NaN):e.isFinite()?(r=n.precision,t=n.rounding,n.precision=r+Math.max(Math.abs(e.e),e.sd())+4,n.rounding=1,h=!1,e=e.times(e).minus(1).sqrt().plus(e),h=!0,n.precision=r,n.rounding=t,e.ln()):new n(e)},j.inverseHyperbolicSine=j.asinh=function(){var r,t,e=this,n=e.constructor;return!e.isFinite()||e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+2*Math.max(Math.abs(e.e),e.sd())+6,n.rounding=1,h=!1,e=e.times(e).plus(1).sqrt().plus(e),h=!0,n.precision=r,n.rounding=t,e.ln())},j.inverseHyperbolicTangent=j.atanh=function(){var r,t,e,n,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=o.precision,t=o.rounding,n=i.sd(),Math.max(n,r)<2*-i.e-1?k(new o(i),r,t,!0):(o.precision=e=n-i.e,i=O(i.plus(1),new o(1).minus(i),e+r,1),o.precision=r+4,o.rounding=1,i=i.ln(),o.precision=r,o.rounding=t,i.times(.5))):new o(NaN)},j.inverseSine=j.asin=function(){var r,t,e,n,i=this,o=i.constructor;return i.isZero()?new o(i):(t=i.abs().cmp(1),e=o.precision,n=o.rounding,-1!==t?0===t?((r=q(o,e+4,n).times(.5)).s=i.s,r):new o(NaN):(o.precision=e+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=e,o.rounding=n,i.times(2)))},j.inverseTangent=j.atan=function(){var r,t,e,n,i,o,a,u,s,c=this,f=c.constructor,l=f.precision,m=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&l+4<=S)return(a=q(f,l+4,m).times(.25)).s=c.s,a}else{if(!c.s)return new f(NaN);if(l+4<=S)return(a=q(f,l+4,m).times(.5)).s=c.s,a}for(f.precision=u=l+10,f.rounding=1,r=e=Math.min(28,u/_+2|0);r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(h=!1,t=Math.ceil(u/_),n=1,s=c.times(c),a=new f(c),i=c;-1!==r;)if(i=i.times(s),o=a.minus(i.div(n+=2)),i=i.times(s),void 0!==(a=o.plus(i.div(n+=2))).d[t])for(r=t;a.d[r]===o.d[r]&&r--;);return e&&(a=a.times(2<this.d.length-2},j.isNaN=function(){return!this.s},j.isNegative=j.isNeg=function(){return this.s<0},j.isPositive=j.isPos=function(){return this.s>0},j.isZero=function(){return!!this.d&&0===this.d[0]},j.lessThan=j.lt=function(r){return this.cmp(r)<0},j.lessThanOrEqualTo=j.lte=function(r){return this.cmp(r)<1},j.logarithm=j.log=function(r){var t,e,n,i,o,a,u,s,c=this.constructor,f=c.precision,l=c.rounding;if(null==r)r=new c(10),t=!0;else{if(e=(r=new c(r)).d,r.s<0||!e||!e[0]||r.eq(1))return new c(NaN);t=r.eq(10)}if(e=this.d,this.s<0||!e||!e[0]||this.eq(1))return new c(e&&!e[0]?-1/0:1!=this.s?NaN:e?0:1/0);if(t)if(e.length>1)o=!0;else{for(i=e[0];i%10==0;)i/=10;o=1!==i}if(h=!1,a=Z(this,u=f+5),n=t?F(c,u+10):Z(r,u),z((s=O(a,n,u,1)).d,i=f,l))do{if(a=Z(this,u+=10),n=t?F(c,u+10):Z(r,u),s=O(a,n,u,1),!o){+B(s.d).slice(i+1,i+15)+1==1e14&&(s=k(s,f+1,0));break}}while(z(s.d,i+=10,l));return h=!0,k(s,f,l)},j.minus=j.sub=function(r){var t,e,n,i,o,a,u,s,c,f,l,m,p=this,g=p.constructor;if(r=new g(r),!p.d||!r.d)return p.s&&r.s?p.d?r.s=-r.s:r=new g(r.d||p.s!==r.s?p:NaN):r=new g(NaN),r;if(p.s!=r.s)return r.s=-r.s,p.plus(r);if(c=p.d,m=r.d,u=g.precision,s=g.rounding,!c[0]||!m[0]){if(m[0])r.s=-r.s;else{if(!c[0])return new g(3===s?-0:0);r=new g(p)}return h?k(r,u,s):r}if(e=v(r.e/_),f=v(p.e/_),c=c.slice(),o=f-e){for((l=o<0)?(t=c,o=-o,a=m.length):(t=m,e=f,a=c.length),o>(n=Math.max(Math.ceil(u/_),a)+2)&&(o=n,t.length=1),t.reverse(),n=o;n--;)t.push(0);t.reverse()}else{for((l=(n=c.length)<(a=m.length))&&(a=n),n=0;n0;--n)c[a++]=0;for(n=m.length;n>o;){if(c[--n](a=(o=Math.ceil(u/_))>a?o+1:a+1)&&(i=a,e.length=1),e.reverse();i--;)e.push(0);e.reverse()}for((a=c.length)-(i=f.length)<0&&(i=a,e=f,f=c,c=e),t=0;i;)t=(c[--i]=c[i]+f[i]+t)/N|0,c[i]%=N;for(t&&(c.unshift(t),++n),a=c.length;0==c[--a];)c.pop();return r.d=c,r.e=P(c,n),h?k(r,u,s):r},j.precision=j.sd=function(r){var t,e=this;if(void 0!==r&&r!==!!r&&1!==r&&0!==r)throw Error(g+r);return e.d?(t=U(e.d),r&&e.e+1>t&&(t=e.e+1)):t=NaN,t},j.round=function(){var r=this,t=r.constructor;return k(new t(r),r.e+1,t.rounding)},j.sine=j.sin=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+Math.max(e.e,e.sd())+_,n.rounding=1,e=function(r,t){var e,n=t.d.length;if(n<3)return J(r,2,t,t);e=(e=1.4*Math.sqrt(n))>16?16:0|e,t=t.times(Math.pow(5,-e)),t=J(r,2,t,t);for(var i,o=new r(5),a=new r(16),u=new r(20);e--;)i=t.times(t),t=t.times(o.plus(i.times(a.times(i).minus(u))));return t}(n,G(n,e)),n.precision=r,n.rounding=t,k(a>2?e.neg():e,r,t,!0)):new n(NaN)},j.squareRoot=j.sqrt=function(){var r,t,e,n,i,o,a=this,u=a.d,s=a.e,c=a.s,f=a.constructor;if(1!==c||!u||!u[0])return new f(!c||c<0&&(!u||u[0])?NaN:u?a:1/0);for(h=!1,0==(c=Math.sqrt(+a))||c==1/0?(((t=B(u)).length+s)%2==0&&(t+="0"),c=Math.sqrt(t),s=v((s+1)/2)-(s<0||s%2),n=new f(t=c==1/0?"1e"+s:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+s)):n=new f(c.toString()),e=(s=f.precision)+3;;)if(n=(o=n).plus(O(a,o,e+2,1)).times(.5),B(o.d).slice(0,e)===(t=B(n.d)).slice(0,e)){if("9999"!=(t=t.slice(e-3,e+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(k(n,s+1,1),r=!n.times(n).eq(a));break}if(!i&&(k(o,s+1,0),o.times(o).eq(a))){n=o;break}e+=4,i=1}return h=!0,k(n,s,f.rounding,r)},j.tangent=j.tan=function(){var r,t,e=this,n=e.constructor;return e.isFinite()?e.isZero()?new n(e):(r=n.precision,t=n.rounding,n.precision=r+10,n.rounding=1,(e=e.sin()).s=1,e=O(e,new n(1).minus(e.times(e)).sqrt(),r+10,0),n.precision=r,n.rounding=t,k(2==a||4==a?e.neg():e,r,t,!0)):new n(NaN)},j.times=j.mul=function(r){var t,e,n,i,o,a,u,s,c,f=this,l=f.constructor,m=f.d,p=(r=new l(r)).d;if(r.s*=f.s,!(m&&m[0]&&p&&p[0]))return new l(!r.s||m&&!m[0]&&!p||p&&!p[0]&&!m?NaN:m&&p?0*r.s:r.s/0);for(e=v(f.e/_)+v(r.e/_),(s=m.length)<(c=p.length)&&(o=m,m=p,p=o,a=s,s=c,c=a),o=[],n=a=s+c;n--;)o.push(0);for(n=c;--n>=0;){for(t=0,i=s+n;i>n;)u=o[i]+p[n]*m[i-n-1]+t,o[i--]=u%N|0,t=u/N|0;o[i]=(o[i]+t)%N|0}for(;!o[--a];)o.pop();return t?++e:o.shift(),r.d=o,r.e=P(o,e),h?k(r,l.precision,l.rounding):r},j.toBinary=function(r,t){return W(this,2,r,t)},j.toDecimalPlaces=j.toDP=function(r,t){var e=this,n=e.constructor;return e=new n(e),void 0===r?e:(T(r,0,s),void 0===t?t=n.rounding:T(t,0,8),k(e,r+e.e+1,t))},j.toExponential=function(r,t){var e,n=this,i=n.constructor;return void 0===r?e=I(n,!0):(T(r,0,s),void 0===t?t=i.rounding:T(t,0,8),e=I(n=k(new i(n),r+1,t),!0,r+1)),n.isNeg()&&!n.isZero()?"-"+e:e},j.toFixed=function(r,t){var e,n,i=this,o=i.constructor;return void 0===r?e=I(i):(T(r,0,s),void 0===t?t=o.rounding:T(t,0,8),e=I(n=k(new o(i),r+i.e+1,t),!1,r+n.e+1)),i.isNeg()&&!i.isZero()?"-"+e:e},j.toFraction=function(r){var t,e,n,i,o,a,u,s,c,f,l,m,p=this,y=p.d,d=p.constructor;if(!y)return new d(p);if(c=e=new d(1),n=s=new d(0),a=(o=(t=new d(n)).e=U(y)-p.e-1)%_,t.d[0]=x(10,a<0?_+a:a),null==r)r=o>0?t:c;else{if(!(u=new d(r)).isInt()||u.lt(c))throw Error(g+u);r=u.gt(t)?o>0?t:c:u}for(h=!1,u=new d(B(y)),f=d.precision,d.precision=o=y.length*_*2;l=O(u,t,0,1,1),1!=(i=e.plus(l.times(n))).cmp(r);)e=n,n=i,i=c,c=s.plus(l.times(i)),s=i,i=t,t=u.minus(l.times(i)),u=i;return i=O(r.minus(e),n,0,1,1),s=s.plus(i.times(c)),e=e.plus(i.times(n)),s.s=c.s=p.s,m=O(c,n,o,1).minus(p).abs().cmp(O(s,e,o,1).minus(p).abs())<1?[c,n]:[s,e],d.precision=f,h=!0,m},j.toHexadecimal=j.toHex=function(r,t){return W(this,16,r,t)},j.toNearest=function(r,t){var e=this,n=e.constructor;if(e=new n(e),null==r){if(!e.d)return e;r=new n(1),t=n.rounding}else{if(r=new n(r),void 0!==t&&T(t,0,8),!e.d)return r.s?e:r;if(!r.d)return r.s&&(r.s=e.s),r}return r.d[0]?(h=!1,t<4&&(t=[4,5,7,8][t]),e=O(e,r,0,t,1).times(r),h=!0,k(e)):(r.s=e.s,e=r),e},j.toNumber=function(){return+this},j.toOctal=function(r,t){return W(this,8,r,t)},j.toPower=j.pow=function(r){var t,e,n,i,o,a,u=this,s=u.constructor,c=+(r=new s(r));if(!(u.d&&r.d&&u.d[0]&&r.d[0]))return new s(x(+u,c));if((u=new s(u)).eq(1))return u;if(n=s.precision,o=s.rounding,r.eq(1))return k(u,n,o);if((t=v(r.e/_))>=r.d.length-1&&(e=c<0?-c:c)<=9007199254740991)return i=R(s,u,e,n),r.s<0?new s(1).div(i):k(i,n,o);if((a=u.s)<0){if(ts.maxE+1||t0?a/0:0):(h=!1,s.rounding=u.s=1,e=Math.min(12,(t+"").length),(i=V(r.times(Z(u,n+e)),n)).d&&z((i=k(i,n+5,1)).d,n,o)&&(t=n+10,+B((i=k(V(r.times(Z(u,t+e)),t),t+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=k(i,n+1,0))),i.s=a,h=!0,s.rounding=o,k(i,n,o))},j.toPrecision=function(r,t){var e,n=this,i=n.constructor;return void 0===r?e=I(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(T(r,1,s),void 0===t?t=i.rounding:T(t,0,8),e=I(n=k(new i(n),r,t),r<=n.e||n.e<=i.toExpNeg,r)),n.isNeg()&&!n.isZero()?"-"+e:e},j.toSignificantDigits=j.toSD=function(r,t){var e=this.constructor;return void 0===r?(r=e.precision,t=e.rounding):(T(r,1,s),void 0===t?t=e.rounding:T(t,0,8)),k(new e(this),r,t)},j.toString=function(){var r=this,t=r.constructor,e=I(r,r.e<=t.toExpNeg||r.e>=t.toExpPos);return r.isNeg()&&!r.isZero()?"-"+e:e},j.truncated=j.trunc=function(){return k(new this.constructor(this),this.e+1,1)},j.valueOf=j.toJSON=function(){var r=this,t=r.constructor,e=I(r,r.e<=t.toExpNeg||r.e>=t.toExpPos);return r.isNeg()?"-"+e:e};var O=function(){function r(r,t,e){var n,i=0,o=r.length;for(r=r.slice();o--;)n=r[o]*t+i,r[o]=n%e|0,i=n/e|0;return i&&r.unshift(i),r}function t(r,t,e,n){var i,o;if(e!=n)o=e>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function e(r,t,e,n){for(var i=0;e--;)r[e]-=i,i=r[e]1;)r.shift()}return function(n,o,a,u,s,c){var f,l,m,h,p,g,y,d,x,b,w,M,A,E,S,j,B,T,z,C,O=n.constructor,I=n.s==o.s?1:-1,P=n.d,F=o.d;if(!(P&&P[0]&&F&&F[0]))return new O(n.s&&o.s&&(P?!F||P[0]!=F[0]:F)?P&&0==P[0]||!F?0*I:I/0:NaN);for(c?(p=1,l=n.e-o.e):(c=N,p=_,l=v(n.e/p)-v(o.e/p)),z=F.length,B=P.length,b=(x=new O(I)).d=[],m=0;F[m]==(P[m]||0);m++);if(F[m]>(P[m]||0)&&l--,null==a?(E=a=O.precision,u=O.rounding):E=s?a+(n.e-o.e)+1:a,E<0)b.push(1),g=!0;else{if(E=E/p+2|0,m=0,1==z){for(h=0,F=F[0],E++;(m1&&(F=r(F,h,c),P=r(P,h,c),z=F.length,B=P.length),j=z,M=(w=P.slice(0,z)).length;M=c/2&&++T;do{h=0,(f=t(F,w,z,M))<0?(A=w[0],z!=M&&(A=A*c+(w[1]||0)),(h=A/T|0)>1?(h>=c&&(h=c-1),1==(f=t(y=r(F,h,c),w,d=y.length,M=w.length))&&(h--,e(y,z=10;h/=10)m++;x.e=m+l*p-1,k(x,s?a+x.e+1:a,u,g)}return x}}();function k(r,t,e,n){var i,o,a,u,s,c,f,l,m,p=r.constructor;r:if(null!=t){if(!(l=r.d))return r;for(i=1,u=l[0];u>=10;u/=10)i++;if((o=t-i)<0)o+=_,a=t,s=(f=l[m=0])/x(10,i-a-1)%10|0;else if((m=Math.ceil((o+1)/_))>=(u=l.length)){if(!n)break r;for(;u++<=m;)l.push(0);f=s=0,i=1,a=(o%=_)-_+1}else{for(f=u=l[m],i=1;u>=10;u/=10)i++;s=(a=(o%=_)-_+i)<0?0:f/x(10,i-a-1)%10|0}if(n=n||t<0||void 0!==l[m+1]||(a<0?f:f%x(10,i-a-1)),c=e<4?(s||n)&&(0==e||e==(r.s<0?3:2)):s>5||5==s&&(4==e||n||6==e&&(o>0?a>0?f/x(10,i-a):0:l[m-1])%10&1||e==(r.s<0?8:7)),t<1||!l[0])return l.length=0,c?(t-=r.e+1,l[0]=x(10,(_-t%_)%_),r.e=-t||0):l[0]=r.e=0,r;if(0==o?(l.length=m,u=1,m--):(l.length=m+1,u=x(10,_-o),l[m]=a>0?(f/x(10,i-a)%x(10,a)|0)*u:0),c)for(;;){if(0==m){for(o=1,a=l[0];a>=10;a/=10)o++;for(a=l[0]+=u,u=1;a>=10;a/=10)u++;o!=u&&(r.e++,l[0]==N&&(l[0]=1));break}if(l[m]+=u,l[m]!=N)break;l[m--]=0,u=1}for(o=l.length;0===l[--o];)l.pop()}return h&&(r.e>p.maxE?(r.d=null,r.e=NaN):r.e0?o=o.charAt(0)+"."+o.slice(1)+D(n):a>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(r.e<0?"e":"e+")+r.e):i<0?(o="0."+D(-i-1)+o,e&&(n=e-a)>0&&(o+=D(n))):i>=a?(o+=D(i+1-a),e&&(n=e-i-1)>0&&(o=o+"."+D(n))):((n=i+1)0&&(i+1===a&&(o+="."),o+=D(n))),o}function P(r,t){var e=r[0];for(t*=_;e>=10;e/=10)t++;return t}function F(r,t,e){if(t>E)throw h=!0,e&&(r.precision=e),Error(y);return k(new r(f),t,1,!0)}function q(r,t,e){if(t>S)throw Error(y);return k(new r(l),t,e,!0)}function U(r){var t=r.length-1,e=t*_+1;if(t=r[t]){for(;t%10==0;t/=10)e--;for(t=r[0];t>=10;t/=10)e++}return e}function D(r){for(var t="";r--;)t+="0";return t}function R(r,t,e,n){var i,o=new r(1),a=Math.ceil(n/_+4);for(h=!1;;){if(e%2&&Q((o=o.times(t)).d,a)&&(i=!0),0===(e=v(e/2))){e=o.d.length-1,i&&0===o.d[e]&&++o.d[e];break}Q((t=t.times(t)).d,a)}return h=!0,o}function L(r){return 1&r.d[r.d.length-1]}function $(r,t,e){for(var n,i=new r(t[0]),o=0;++o17)return new m(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(null==t?(h=!1,s=g):s=t,u=new m(.03125);r.e>-2;)r=r.times(u),l+=5;for(s+=n=Math.log(x(2,l))/Math.LN10*2+5|0,e=o=a=new m(1),m.precision=s;;){if(o=k(o.times(r),s,1),e=e.times(++f),B((u=a.plus(O(o,e,s,1))).d).slice(0,s)===B(a.d).slice(0,s)){for(i=l;i--;)a=k(a.times(a),s,1);if(null!=t)return m.precision=g,a;if(!(c<3&&z(a.d,s-n,p,c)))return k(a,m.precision=g,p,h=!0);m.precision=s+=10,e=o=u=new m(1),f=0,c++}a=u}}function Z(r,t){var e,n,i,o,a,u,s,c,f,l,m,p=1,g=r,y=g.d,d=g.constructor,v=d.rounding,x=d.precision;if(g.s<0||!y||!y[0]||!g.e&&1==y[0]&&1==y.length)return new d(y&&!y[0]?-1/0:1!=g.s?NaN:y?0:g);if(null==t?(h=!1,f=x):f=t,d.precision=f+=10,n=(e=B(y)).charAt(0),!(Math.abs(o=g.e)<15e14))return c=F(d,f+2,x).times(o+""),g=Z(new d(n+"."+e.slice(1)),f-10).plus(c),d.precision=x,null==t?k(g,x,v,h=!0):g;for(;n<7&&1!=n||1==n&&e.charAt(1)>3;)n=(e=B((g=g.times(r)).d)).charAt(0),p++;for(o=g.e,n>1?(g=new d("0."+e),o++):g=new d(n+"."+e.slice(1)),l=g,s=a=g=O(g.minus(1),g.plus(1),f,1),m=k(g.times(g),f,1),i=3;;){if(a=k(a.times(m),f,1),B((c=s.plus(O(a,new d(i),f,1))).d).slice(0,f)===B(s.d).slice(0,f)){if(s=s.times(2),0!==o&&(s=s.plus(F(d,f+2,x).times(o+""))),s=O(s,new d(p),f,1),null!=t)return d.precision=x,s;if(!z(s.d,f-10,v,u))return k(s,d.precision=x,v,h=!0);d.precision=f+=10,c=a=g=O(l.minus(1),l.plus(1),f,1),m=k(g.times(g),f,1),i=u=1}s=c,i+=2}}function X(r){return String(r.s*r.s/0)}function H(r,t){var e,n,i;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(e<0&&(e=n),e+=+t.slice(n+1),t=t.substring(0,n)):e<0&&(e=t.length),n=0;48===t.charCodeAt(n);n++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(n,i)){if(i-=n,r.e=e=e-n-1,r.d=[],n=(e+1)%_,e<0&&(n+=_),nr.constructor.maxE?(r.d=null,r.e=NaN):r.e0?(c=+t.slice(a+1),t=t.substring(2,a)):t=t.slice(2),u=(a=t.indexOf("."))>=0,i=r.constructor,u&&(a=(s=(t=t.replace(".","")).length)-a,o=R(i,new i(n),a,2*a)),a=l=(f=C(t,n,N)).length-1;0===f[a];--a)f.pop();return a<0?new i(0*r.s):(r.e=P(f,l),r.d=f,h=!1,u&&(r=O(r,o,4*s)),c&&(r=r.times(Math.abs(c)<54?Math.pow(2,c):e.pow(2,c))),h=!0,r)}function J(r,t,e,n,i){var o,a,u,s,c=r.precision,f=Math.ceil(c/_);for(h=!1,s=e.times(e),u=new r(n);;){if(a=O(u.times(s),new r(t++*t++),c,1),u=i?n.plus(a):n.minus(a),n=O(a.times(s),new r(t++*t++),c,1),void 0!==(a=u.plus(n)).d[f]){for(o=f;a.d[o]===u.d[o]&&o--;);if(-1==o)break}o=u,u=n,n=a,a=o,0}return h=!0,a.d.length=f+1,a}function G(r,t){var e,n=t.s<0,i=q(r,r.precision,1),o=i.times(.5);if((t=t.abs()).lte(o))return a=n?4:1,t;if((e=t.divToInt(i)).isZero())a=n?3:2;else{if((t=t.minus(e.times(i))).lte(o))return a=L(e)?n?2:3:n?4:1,t;a=L(e)?n?1:4:n?3:2}return t.minus(i).abs()}function W(r,t,e,n){var o,a,u,f,l,m,h,p,g,y=r.constructor,d=void 0!==e;if(d?(T(e,1,s),void 0===n?n=y.rounding:T(n,0,8)):(e=y.precision,n=y.rounding),r.isFinite()){for(d?(o=2,16==t?e=4*e-3:8==t&&(e=3*e-2)):o=t,(u=(h=I(r)).indexOf("."))>=0&&(h=h.replace(".",""),(g=new y(1)).e=h.length-u,g.d=C(I(g),10,o),g.e=g.d.length),a=l=(p=C(h,10,o)).length;0==p[--l];)p.pop();if(p[0]){if(u<0?a--:((r=new y(r)).d=p,r.e=a,p=(r=O(r,g,e,n,0,o)).d,a=r.e,m=i),u=p[e],f=o/2,m=m||void 0!==p[e+1],m=n<4?(void 0!==u||m)&&(0===n||n===(r.s<0?3:2)):u>f||u===f&&(4===n||m||6===n&&1&p[e-1]||n===(r.s<0?8:7)),p.length=e,m)for(;++p[--e]>o-1;)p[e]=0,e||(++a,p.unshift(1));for(l=p.length;!p[l-1];--l);for(u=0,h="";u1)if(16==t||8==t){for(u=16==t?4:3,--l;l%u;l++)h+="0";for(l=(p=C(h,o,t)).length;!p[l-1];--l);for(u=1,h="1.";ul)for(a-=l;a--;)h+="0";else at)return r.length=t,!0}function K(r){return new this(r).abs()}function rr(r){return new this(r).acos()}function tr(r){return new this(r).acosh()}function er(r,t){return new this(r).plus(t)}function nr(r){return new this(r).asin()}function ir(r){return new this(r).asinh()}function or(r){return new this(r).atan()}function ar(r){return new this(r).atanh()}function ur(r,t){r=new this(r),t=new this(t);var e,n=this.precision,i=this.rounding,o=n+4;return r.s&&t.s?r.d||t.d?!t.d||r.isZero()?(e=t.s<0?q(this,n,i):new this(0)).s=r.s:!r.d||t.isZero()?(e=q(this,o,1).times(.5)).s=r.s:t.s<0?(this.precision=o,this.rounding=1,e=this.atan(O(r,t,o,1)),t=q(this,o,1),this.precision=n,this.rounding=i,e=r.s<0?e.minus(t):e.plus(t)):e=this.atan(O(r,t,o,1)):(e=q(this,o,1).times(t.s>0?.25:.75)).s=r.s:e=new this(NaN),e}function sr(r){return new this(r).cbrt()}function cr(r){return k(r=new this(r),r.e+1,2)}function fr(r){if(!r||"object"!==n(r))throw Error(p+"Object expected");var t,e,i,o=!0===r.defaults,a=["precision",1,s,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(t=0;t=a[t+1]&&i<=a[t+2]))throw Error(g+e+": "+i);this[e]=i}if(e="crypto",o&&(this[e]=m[e]),void 0!==(i=r[e])){if(!0!==i&&!1!==i&&0!==i&&1!==i)throw Error(g+e+": "+i);if(i){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[e]=!0}else this[e]=!1}return this}function lr(r){return new this(r).cos()}function mr(r){return new this(r).cosh()}function hr(r,t){return new this(r).div(t)}function pr(r){return new this(r).exp()}function gr(r){return k(r=new this(r),r.e+1,3)}function yr(){var r,t,e=new this(0);for(h=!1,r=0;r=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(d);for(t=crypto.randomBytes(n*=4);o=214e7?crypto.randomBytes(4).copy(t,o):(u.push(i%1e7),o+=4);o=n/4}else for(;o=10;i/=10)n++;n<_&&(e-=_-n)}return a.e=e,a.d=u,a}function jr(r){return k(r=new this(r),r.e+1,this.rounding)}function Br(r){return(r=new this(r)).d?r.d[0]?r.s:0*r.s:r.s||NaN}function Tr(r){return new this(r).sin()}function zr(r){return new this(r).sinh()}function Cr(r){return new this(r).sqrt()}function Or(r,t){return new this(r).sub(t)}function kr(r){return new this(r).tan()}function Ir(r){return new this(r).tanh()}function Pr(r){return k(r=new this(r),r.e+1,1)}(e=function r(t){var e,i,o;function a(r){var t,e,i,o=this;if(!(o instanceof a))return new a(r);if(o.constructor=a,r instanceof a)return o.s=r.s,o.e=r.e,void(o.d=(r=r.d)?r.slice():r);if("number"===(i=n(r))){if(0===r)return o.s=1/r<0?-1:1,o.e=0,void(o.d=[0]);if(r<0?(r=-r,o.s=-1):o.s=1,r===~~r&&r<1e7){for(t=0,e=r;e>=10;e/=10)t++;return o.e=t,void(o.d=[r])}return 0*r!=0?(r||(o.s=NaN),o.e=NaN,void(o.d=null)):H(o,r.toString())}if("string"!==i)throw Error(g+r);return 45===r.charCodeAt(0)?(r=r.slice(1),o.s=-1):o.s=1,A.test(r)?H(o,r):Y(o,r)}if(a.prototype=j,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=fr,a.clone=r,a.isDecimal=dr,a.abs=K,a.acos=rr,a.acosh=tr,a.add=er,a.asin=nr,a.asinh=ir,a.atan=or,a.atanh=ar,a.atan2=ur,a.cbrt=sr,a.ceil=cr,a.cos=lr,a.cosh=mr,a.div=hr,a.exp=pr,a.floor=gr,a.hypot=yr,a.ln=vr,a.log=xr,a.log10=wr,a.log2=br,a.max=Mr,a.min=Ar,a.mod=Nr,a.mul=_r,a.pow=Er,a.random=Sr,a.round=jr,a.sign=Br,a.sin=Tr,a.sinh=zr,a.sqrt=Cr,a.sub=Or,a.tan=kr,a.tanh=Ir,a.trunc=Pr,void 0===t&&(t={}),t&&!0!==t.defaults)for(o=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;ei?Array(e-i+1).join(r):"")+n}}t.exports=o,o.prototype.newRow=function(){return this.rows.push(this.row),this.row={__printers:{}},this},o.prototype.cell=function(r,t,e){return this.row[r]=t,this.row.__printers[r]=e||a,this},o.prototype.separator=" ",o.string=a,o.leftPadder=s;var c=o.padLeft=s(" ");function f(r){return function(t,e){var n=a(t),i=u(n);return n+(e>i?Array(e-i+1).join(r):"")}}o.rightPadder=f;var l=f(" ");function m(r,t){for(var e in r)"__printers"!=e&&t(e,r[e])}function h(r,t){return r===t?0:void 0===r?1:void 0===t?-1:null===r?1:null===t?-1:r>t?1:r1&&void 0!==arguments[1]?arguments[1]:{},e=t.preserveFormatting,u=void 0!==e&&e,s=t.escapeMapFn,c=void 0===s?a:s,f=String(r),l="",m=c(n({},i),u?n({},o):{}),h=Object.keys(m),p=function(){var r=!1;h.forEach(function(t,e){r||f.length>=t.length&&f.slice(0,t.length)===t&&(l+=m[h[e]],f=f.slice(t.length,f.length),r=!0)}),r||(l+=f.slice(0,1),f=f.slice(1,f.length))};f;)p();return l}},{}],44:[function(r,t,e){"use strict";function n(r){if(this.size=0|r,this.size<=1||0!=(this.size&this.size-1))throw new Error("FFT size must be a power of two and bigger than 1");this._csize=r<<1;for(var t=new Array(2*this.size),e=0;eo;o<<=1)i++;this._width=i%2==0?i-1:i,this._bitrev=new Array(1<>>u&3)<>>1),n=0;n>>1]=r[n];return e},n.prototype.createComplexArray=function(){for(var r=new Array(this._csize),t=0;t>>1],e[n+1]=0;return e},n.prototype.completeSpectrum=function(r){for(var t=this._csize,e=t>>>1,n=2;n>=2;i>=2;i>>=2){var l=(o=n/i<<1)>>>2;for(r=0;r>>1,i>>>1)}else for(r=0,t=0;r>>1,i>>>1)}var c=this._inv?-1:1,f=this.table;for(i>>=2;i>=2;i>>=2){var l=(o=n/i<<1)>>>1,m=l>>>1,h=m>>>1;for(r=0;r>1,f=-7,l=e?i-1:0,m=e?-1:1,h=r[t+l];for(l+=m,o=h&(1<<-f)-1,h>>=-f,f+=u;f>0;o=256*o+r[t+l],l+=m,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+r[t+l],l+=m,f-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(h?-1:1);a+=Math.pow(2,n),o-=c}return(h?-1:1)*a*Math.pow(2,o-n)},e.write=function(r,t,e,n,i,o){var a,u,s,c=8*o-i-1,f=(1<>1,m=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,a=f):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),(t+=a+l>=1?m/s:m*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(t*s-1)*Math.pow(2,i),a+=l):(u=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;r[e+h]=255&u,h+=p,u/=256,i-=8);for(a=a<0;r[e+h]=255&a,h+=p,a/=256,c-=8);r[e+h-p]|=128*g}},{}],46:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}t.exports=function r(t,e){var i,o,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,u=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,f=/^0/,l=function(t){return r.insensitive&&(""+t).toLowerCase()||""+t},m=l(t).replace(u,"")||"",h=l(e).replace(u,"")||"",p=m.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),g=h.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),y=parseInt(m.match(c),16)||1!==p.length&&m.match(s)&&Date.parse(m),d=parseInt(h.match(c),16)||y&&h.match(s)&&Date.parse(h)||null;if(d){if(yd)return 1}for(var v=0,x=Math.max(p.length,g.length);vo)return 1}return 0}},{}],47:[function(r,t,e){"use strict";t.exports=r("./lib/core/core")},{"./lib/core/core":48}],48:[function(r,t,e){"use strict";var n=r("./../utils/object").isFactory,i=r("./typed"),o=r("./../utils/emitter"),a=r("./function/import"),u=r("./function/config");e.create=function(r){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=[],e=[],s=o.mixin({});s.type={},s.expression={transform:{},mathWithTransform:{}},s.typed=i.create(s.type);var c={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function f(r){if(!n(r))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var i,o=t.indexOf(r);return-1===o?(i=!0===r.math?r.factory(s.type,c,f,s.typed,s):r.factory(s.type,c,f,s.typed),t.push(r),e.push(i)):i=e[o],i}return s.import=f(a),s.config=f(u),s.expression.mathWithTransform.config=s.config,r&&s.config(r),s}},{"./../utils/emitter":225,"./../utils/object":230,"./function/config":49,"./function/import":50,"./typed":51}],49:[function(r,t,e){"use strict";var n=r("../../utils/object");function i(r,t,e){if(void 0!==r[t]&&(i=e,o=r[t],-1===i.indexOf(o))){var n=function(r,t){return r.map(function(r){return r.toLowerCase()}).indexOf(t.toLowerCase())}(e,r[t]);-1!==n?(console.warn('Warning: Wrong casing for configuration option "'+t+'", should be "'+e[n]+'" instead of "'+r[t]+'".'),r[t]=e[n]):console.warn('Warning: Unknown value "'+r[t]+'" for configuration option "'+t+'". Available options: '+e.map(JSON.stringify).join(", ")+".")}var i,o}e.name="config",e.math=!0,e.factory=function(r,t,e,o,a){var u=["Matrix","Array"],s=["number","BigNumber","Fraction"];function c(r){if(r){var e=n.map(t,n.clone);i(r,"matrix",u),i(r,"number",s),n.deepExtend(t,r);var o=n.map(t,n.clone),c=n.map(r,n.clone);return a.emit("config",o,e,c),o}return n.map(t,n.clone)}return c.MATRIX=u,c.NUMBER=s,c}},{"../../utils/object":230}],50:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i=r("../../utils/object").lazy,o=r("../../utils/object").isFactory,a=r("../../utils/object").traverse,u=r("../../error/ArgumentsError");e.math=!0,e.name="import",e.factory=function(r,t,e,s,c){function f(r,t,e){if(e.wrap&&"function"==typeof t&&(i=function(){for(var r=[],t=0,e=arguments.length;t15)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 r.BigNumber(t)}},{from:"number",to:"Complex",convert:function(t){return new r.Complex(t,0)}},{from:"number",to:"string",convert:function(r){return r+""}},{from:"BigNumber",to:"Complex",convert:function(t){return new r.Complex(t.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(r){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(t){return new r.Complex(t.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(t){if(new r.Fraction(t).valueOf()!==t)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+t+"). Use function fraction(x) to convert to Fraction.");return new r.Fraction(t)}},{from:"string",to:"number",convert:function(r){var t=Number(r);if(isNaN(t))throw new Error('Cannot convert "'+r+'" to a number');return t}},{from:"string",to:"BigNumber",convert:function(t){try{return new r.BigNumber(t)}catch(r){throw new Error('Cannot convert "'+t+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(t){try{return new r.Fraction(t)}catch(r){throw new Error('Cannot convert "'+t+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(t){try{return new r.Complex(t)}catch(r){throw new Error('Cannot convert "'+t+'" to Complex')}}},{from:"boolean",to:"number",convert:function(r){return+r}},{from:"boolean",to:"BigNumber",convert:function(t){return new r.BigNumber(+t)}},{from:"boolean",to:"Fraction",convert:function(t){return new r.Fraction(+t)}},{from:"boolean",to:"string",convert:function(r){return+r}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new r.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new r.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(t){return new r.DenseMatrix(t)}},{from:"Matrix",to:"Array",convert:function(r){return r.valueOf()}}],t}},{"./../utils/bignumber/isBigNumber":214,"./../utils/collection/isMatrix":221,"./../utils/number":229,"typed-function":239}],52:[function(r,t,e){"use strict";function n(r,t,e,i){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.fn=r,this.count=t,this.min=e,this.max=i,this.message="Wrong number of arguments in function "+r+" ("+t+" provided, "+e+(null!=i?"-"+i:"")+" expected)",this.stack=(new Error).stack}n.prototype=new Error,n.prototype.constructor=Error,n.prototype.name="ArgumentsError",n.prototype.isArgumentsError=!0,t.exports=n},{}],53:[function(r,t,e){"use strict";function n(r,t,e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.actual=r,this.expected=t,this.relation=e,this.message="Dimension mismatch ("+(Array.isArray(r)?"["+r.join(", ")+"]":r)+" "+(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",n.prototype.isDimensionError=!0,t.exports=n},{}],54:[function(r,t,e){"use strict";function n(r,t,e){if(!(this instanceof n))throw new SyntaxError("Constructor must be called with the new operator");this.index=r,arguments.length<3?(this.min=0,this.max=t):(this.min=t,this.max=e),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",n.prototype.isIndexError=!0,t.exports=n},{}],55:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="abs",e.factory=function(r,t,e,i){var o=i("abs",{number:Math.abs,Complex:function(r){return r.abs()},BigNumber:function(r){return r.abs()},Fraction:function(r){return r.abs()},"Array | Matrix":function(r){return n(r,o,!0)},Unit:function(r){return r.abs()}});return o.toTex={1:"\\left|${args[0]}\\right|"},o}},{"../../utils/collection/deepMap":219}],56:[function(r,t,e){"use strict";var n=r("../../utils/object").extend;e.name="add",e.factory=function(t,e,i,o){var a=i(r("../../type/matrix/function/matrix")),u=i(r("./addScalar")),s=r("../../utils/latex.js"),c=i(r("../../type/matrix/utils/algorithm01")),f=i(r("../../type/matrix/utils/algorithm04")),l=i(r("../../type/matrix/utils/algorithm10")),m=i(r("../../type/matrix/utils/algorithm13")),h=i(r("../../type/matrix/utils/algorithm14")),p=o("add",n({"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=f(r,t,u);break;default:e=c(t,r,u,!0)}break;default:switch(t.storage()){case"sparse":e=c(r,t,u,!1);break;default:e=m(r,t,u)}}return e},"Array, Array":function(r,t){return p(a(r),a(t)).valueOf()},"Array, Matrix":function(r,t){return p(a(r),t)},"Matrix, Array":function(r,t){return p(r,a(t))},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=l(r,t,u,!1);break;default:e=h(r,t,u,!1)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=l(t,r,u,!0);break;default:e=h(t,r,u,!0)}return e},"Array, any":function(r,t){return h(a(r),t,u,!1).valueOf()},"any, Array":function(r,t){return h(a(t),r,u,!0).valueOf()},"any, any":u,"Array | Matrix | any, Array | Matrix | any, ...any":function(r,t,e){for(var n=p(r,t),i=0;i0?Math.floor(r):Math.ceil(r)},Complex:function(t){return new r.Complex(t.re>0?Math.floor(t.re):Math.ceil(t.re),t.im>0?Math.floor(t.im):Math.ceil(t.im))},BigNumber:function(r){return r.isNegative()?r.ceil():r.floor()},Fraction:function(r){return r.s<0?r.ceil():r.floor()},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],68:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="floor",e.factory=function(r,t,e,i){var o=i("floor",{number:Math.floor,Complex:function(r){return r.floor()},BigNumber:function(r){return r.floor()},Fraction:function(r){return r.floor()},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\left\\lfloor${args[0]}\\right\\rfloor"},o}},{"../../utils/collection/deepMap":219}],69:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger;function i(r,t){if(!n(r)||!n(t))throw new Error("Parameters in function gcd must be integer numbers");for(var e;0!=t;)e=r%t,r=t,t=e;return r<0?-r:r}e.name="gcd",e.factory=function(t,e,n,o){var a=n(r("../../type/matrix/function/matrix")),u=n(r("../../type/matrix/utils/algorithm01")),s=n(r("../../type/matrix/utils/algorithm04")),c=n(r("../../type/matrix/utils/algorithm10")),f=n(r("../../type/matrix/utils/algorithm13")),l=n(r("../../type/matrix/utils/algorithm14")),m=o("gcd",{"number, number":i,"BigNumber, BigNumber":function(r,e){if(!r.isInt()||!e.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var n=new t.BigNumber(0);!e.isZero();){var i=r.mod(e);r=e,e=i}return r.lt(n)?r.neg():r},"Fraction, Fraction":function(r,t){return r.gcd(t)},"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=s(r,t,m);break;default:e=u(t,r,m,!0)}break;default:switch(t.storage()){case"sparse":e=u(r,t,m,!1);break;default:e=f(r,t,m)}}return e},"Array, Array":function(r,t){return m(a(r),a(t)).valueOf()},"Array, Matrix":function(r,t){return m(a(r),t)},"Matrix, Array":function(r,t){return m(r,a(t))},"Matrix, number | BigNumber":function(r,t){var e;switch(r.storage()){case"sparse":e=c(r,t,m,!1);break;default:e=l(r,t,m,!1)}return e},"number | BigNumber, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=c(t,r,m,!0);break;default:e=l(t,r,m,!0)}return e},"Array, number | BigNumber":function(r,t){return l(a(r),t,m,!1).valueOf()},"number | BigNumber, Array":function(r,t){return l(a(t),r,m,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(r,t,e){for(var n=m(r,t),i=0;i=0||e.predictable?Math.log(r):new t.Complex(r,0).log()},Complex:function(r){return r.log()},BigNumber:function(r){return!r.isNegative()||e.predictable?r.ln():new t.Complex(r.toNumber(),0).log()},"Array | Matrix":function(r){return n(r,u)},"any, any":function(r,t){return a(u(r),u(t))}});return u.toTex={1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":219,"./divideScalar":62}],74:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.log10||function(r){return Math.log(r)/Math.LN10};e.name="log10",e.factory=function(r,t,e,o){var a=o("log10",{number:function(e){return e>=0||t.predictable?i(e):new r.Complex(e,0).log().div(Math.LN10)},Complex:function(t){return new r.Complex(t).log().div(Math.LN10)},BigNumber:function(e){return!e.isNegative()||t.predictable?e.log():new r.Complex(e.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\log_{10}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],75:[function(r,t,e){"use strict";e.name="mod",e.factory=function(t,e,n,i){var o=n(r("../../type/matrix/function/matrix")),a=r("../../utils/latex"),u=n(r("../../type/matrix/utils/algorithm02")),s=n(r("../../type/matrix/utils/algorithm03")),c=n(r("../../type/matrix/utils/algorithm05")),f=n(r("../../type/matrix/utils/algorithm11")),l=n(r("../../type/matrix/utils/algorithm12")),m=n(r("../../type/matrix/utils/algorithm13")),h=n(r("../../type/matrix/utils/algorithm14")),p=i("mod",{"number, number":function(r,t){if(t>0)return r-t*Math.floor(r/t);if(0===t)return r;throw new Error("Cannot calculate mod for a negative divisor")},"BigNumber, BigNumber":function(r,t){return t.isZero()?r:r.mod(t)},"Fraction, Fraction":function(r,t){return r.mod(t)},"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=c(r,t,p,!1);break;default:e=u(t,r,p,!0)}break;default:switch(t.storage()){case"sparse":e=s(r,t,p,!1);break;default:e=m(r,t,p)}}return e},"Array, Array":function(r,t){return p(o(r),o(t)).valueOf()},"Array, Matrix":function(r,t){return p(o(r),t)},"Matrix, Array":function(r,t){return p(r,o(t))},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=f(r,t,p,!1);break;default:e=h(r,t,p,!1)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=l(t,r,p,!0);break;default:e=h(t,r,p,!0)}return e},"Array, any":function(r,t){return h(o(r),t,p,!1).valueOf()},"any, Array":function(r,t){return h(o(t),r,p,!0).valueOf()}});return p.toTex={2:"\\left(${args[0]}"+a.operators.mod+"${args[1]}\\right)"},p}},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228}],76:[function(r,t,e){"use strict";var n=r("../../utils/object").extend,i=r("../../utils/array");e.name="multiply",e.factory=function(t,e,o,a){var u=r("../../utils/latex"),s=o(r("../../type/matrix/function/matrix")),c=o(r("./addScalar")),f=o(r("./multiplyScalar")),l=o(r("../relational/equalScalar")),m=o(r("../../type/matrix/utils/algorithm11")),h=o(r("../../type/matrix/utils/algorithm14")),p=t.DenseMatrix,g=t.SparseMatrix,y=a("multiply",n({"Array, Array":function(r,e){d(i.size(r),i.size(e));var n=y(s(r),s(e));return t.isMatrix(n)?n.valueOf():n},"Matrix, Matrix":function(r,t){var e=r.size(),n=t.size();return d(e,n),1===e.length?1===n.length?v(r,t,e[0]):x(r,t):1===n.length?w(r,t):M(r,t)},"Matrix, Array":function(r,t){return y(r,s(t))},"Array, Matrix":function(r,t){return y(s(r,t.storage()),t)},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=m(r,t,f,!1);break;case"dense":e=h(r,t,f,!1)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=m(t,r,f,!0);break;case"dense":e=h(t,r,f,!0)}return e},"Array, any":function(r,t){return h(s(r),t,f,!1).valueOf()},"any, Array":function(r,t){return h(s(t),r,f,!0).valueOf()},"any, any":f,"Array | Matrix | any, Array | Matrix | any, ...any":function(r,t,e){for(var n=y(r,t),i=0;iS)for(var B=0,T=0;T=0||e.predictable?r.pow(n):new t.Complex(r.toNumber(),0).pow(n.toNumber(),0)},"Fraction, Fraction":function(r,t){if(1!==t.d){if(e.predictable)throw new Error("Function pow does not support non-integer exponents for fractions.");return p(r.valueOf(),t.valueOf())}return r.pow(t)},"Array, number":g,"Array, BigNumber":function(r,t){return g(r,t.toNumber())},"Matrix, number":y,"Matrix, BigNumber":function(r,t){return y(r,t.toNumber())},"Unit, number":function(r,t){return r.pow(t)}});function p(r,i){if(e.predictable&&!n(i)&&r<0)try{var o=l(i),a=m(o);if((i===a||Math.abs((i-a)/i)<1e-14)&&o.d%2==1)return(o.n%2==0?1:-1)*Math.pow(-r,i)}catch(r){}return r*r<1&&i===1/0||r*r>1&&i===-1/0?0:e.predictable&&(r<-1&&i===1/0||r>-1&&r<0&&i===-1/0)?NaN:n(i)||r>=0||e.predictable?Math.pow(r,i):new t.Complex(r,0).pow(i,0)}function g(r,t){if(!n(t)||t<0)throw new TypeError("For A^b, b must be a positive integer (value is "+t+")");var e=i(r);if(2!=e.length)throw new Error("For A^b, A must be 2 dimensional (A has "+e.length+" dimensions)");if(e[0]!=e[1])throw new Error("For A^b, A must be square (size is "+e[0]+"x"+e[1]+")");for(var o=s(e[0]).valueOf(),a=r;t>=1;)1==(1&t)&&(o=c(a,o)),t>>=1,a=c(a,a);return o}function y(r,t){return f(g(r.valueOf(),t))}return h.toTex={2:"\\left(${args[0]}\\right)"+u.operators.pow+"{${args[1]}}"},h}},{"../../type/fraction/function/fraction":185,"../../type/matrix/function/matrix":195,"../../type/number":211,"../../utils/array":212,"../../utils/latex":228,"../../utils/number":229,"../matrix/eye":94,"./multiply":76}],81:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger,i=r("../../utils/number").toFixed,o=r("../../utils/collection/deepMap"),a="Number of decimals in function round must be an integer";e.name="round",e.factory=function(t,e,u,s){var c=u(r("../../type/matrix/function/matrix")),f=u(r("../relational/equalScalar")),l=u(r("../matrix/zeros")),m=u(r("../../type/matrix/utils/algorithm11")),h=u(r("../../type/matrix/utils/algorithm12")),p=u(r("../../type/matrix/utils/algorithm14")),g=s("round",{number:Math.round,"number, number":function(r,t){if(!n(t))throw new TypeError(a);if(t<0||t>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return parseFloat(i(r,t))},Complex:function(r){return r.round()},"Complex, number":function(r,t){if(t%1)throw new TypeError(a);return r.round(t)},"Complex, BigNumber":function(r,t){if(!t.isInteger())throw new TypeError(a);var e=t.toNumber();return r.round(e)},"number, BigNumber":function(r,e){if(!e.isInteger())throw new TypeError(a);return new t.BigNumber(r).toDecimalPlaces(e.toNumber())},BigNumber:function(r){return r.toDecimalPlaces(0)},"BigNumber, BigNumber":function(r,t){if(!t.isInteger())throw new TypeError(a);return r.toDecimalPlaces(t.toNumber())},Fraction:function(r){return r.round()},"Fraction, number":function(r,t){if(t%1)throw new TypeError(a);return r.round(t)},"Array | Matrix":function(r){return o(r,g,!0)},"Matrix, number | BigNumber":function(r,t){var e;switch(r.storage()){case"sparse":e=m(r,t,g,!1);break;default:e=p(r,t,g,!1)}return e},"number | Complex | BigNumber, Matrix":function(r,t){if(!f(r,0)){var e;switch(t.storage()){case"sparse":e=h(t,r,g,!0);break;default:e=p(t,r,g,!0)}return e}return l(t.size(),t.storage())},"Array, number | BigNumber":function(r,t){return p(c(r),t,g,!1).valueOf()},"number | Complex | BigNumber, Array":function(r,t){return p(c(t),r,g,!0).valueOf()}});return g.toTex={1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},g}},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm14":210,"../../utils/collection/deepMap":219,"../../utils/number":229,"../matrix/zeros":113,"../relational/equalScalar":128}],82:[function(r,t,e){"use strict";var n=r("../../utils/number"),i=r("../../utils/collection/deepMap");e.name="sign",e.factory=function(r,t,e,o){var a=o("sign",{number:n.sign,Complex:function(r){return r.sign()},BigNumber:function(t){return new r.BigNumber(t.cmp(0))},Fraction:function(t){return new r.Fraction(t.s,1)},"Array | Matrix":function(r){return i(r,a,!0)},Unit:function(r){return a(r.value)}});return a.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],83:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="sqrt",e.factory=function(r,t,e,i){var o=i("sqrt",{number:a,Complex:function(r){return r.sqrt()},BigNumber:function(r){return!r.isNegative()||t.predictable?r.sqrt():a(r.toNumber())},"Array | Matrix":function(r){return n(r,o,!0)},Unit:function(r){return r.pow(.5)}});function a(e){return e>=0||t.predictable?Math.sqrt(e):new r.Complex(e,0).sqrt()}return o.toTex={1:"\\sqrt{${args[0]}}"},o}},{"../../utils/collection/deepMap":219}],84:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="square",e.factory=function(r,t,e,i){var o=i("square",{number:function(r){return r*r},Complex:function(r){return r.mul(r)},BigNumber:function(r){return r.times(r)},Fraction:function(r){return r.mul(r)},"Array | Matrix":function(r){return n(r,o,!0)},Unit:function(r){return r.pow(2)}});return o.toTex={1:"\\left(${args[0]}\\right)^2"},o}},{"../../utils/collection/deepMap":219}],85:[function(r,t,e){"use strict";var n=r("../../error/DimensionError");e.name="subtract",e.factory=function(t,e,i,o){var a=r("../../utils/latex"),u=i(r("../../type/matrix/function/matrix")),s=i(r("./addScalar")),c=i(r("./unaryMinus")),f=i(r("../../type/matrix/utils/algorithm01")),l=i(r("../../type/matrix/utils/algorithm03")),m=i(r("../../type/matrix/utils/algorithm05")),h=i(r("../../type/matrix/utils/algorithm10")),p=i(r("../../type/matrix/utils/algorithm13")),g=i(r("../../type/matrix/utils/algorithm14")),y=o("subtract",{"number, number":function(r,t){return r-t},"Complex, Complex":function(r,t){return r.sub(t)},"BigNumber, BigNumber":function(r,t){return r.minus(t)},"Fraction, Fraction":function(r,t){return r.sub(t)},"Unit, Unit":function(r,t){if(null==r.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(!r.equalBase(t))throw new Error("Units do not match");var e=r.clone();return e.value=y(e.value,t.value),e.fixPrefix=!1,e},"Matrix, Matrix":function(r,t){var e,i=r.size(),o=t.size();if(i.length!==o.length)throw new n(i.length,o.length);switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=m(r,t,y);break;default:e=l(t,r,y,!0)}break;default:switch(t.storage()){case"sparse":e=f(r,t,y,!1);break;default:e=p(r,t,y)}}return e},"Array, Array":function(r,t){return y(u(r),u(t)).valueOf()},"Array, Matrix":function(r,t){return y(u(r),t)},"Matrix, Array":function(r,t){return y(r,u(t))},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=h(r,c(t),s);break;default:e=g(r,t,y)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=h(t,r,y,!0);break;default:e=g(t,r,y,!0)}return e},"Array, any":function(r,t){return g(u(r),t,y,!1).valueOf()},"any, Array":function(r,t){return g(u(t),r,y,!0).valueOf()}});return y.toTex={2:"\\left(${args[0]}"+a.operators.subtract+"${args[1]}\\right)"},y}},{"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm01":198,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm10":206,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/latex":228,"./addScalar":57,"./unaryMinus":86}],86:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="unaryMinus",e.factory=function(t,e,i,o){var a=r("../../utils/latex"),u=o("unaryMinus",{number:function(r){return-r},Complex:function(r){return r.neg()},BigNumber:function(r){return r.neg()},Fraction:function(r){return r.neg()},Unit:function(r){var t=r.clone();return t.value=u(r.value),t},"Array | Matrix":function(r){return n(r,u,!0)}});return u.toTex={1:a.operators.unaryMinus+"\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":219,"../../utils/latex":228}],87:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="unaryPlus",e.factory=function(t,e,i,o){var a=r("../../utils/latex"),u=o("unaryPlus",{number:function(r){return r},Complex:function(r){return r},BigNumber:function(r){return r},Fraction:function(r){return r},Unit:function(r){return r.clone()},"Array | Matrix":function(r){return n(r,u,!0)},"boolean | string | null":function(r){return"BigNumber"==e.number?new t.BigNumber(+r):+r}});return u.toTex={1:a.operators.unaryPlus+"\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":219,"../../utils/latex":228}],88:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger;e.name="xgcd",e.factory=function(t,e,i,o){var a=i(r("../../type/matrix/function/matrix")),u=o("xgcd",{"number, number":function(r,t){var i,o,u,s,c=0,f=1,l=1,m=0;if(!n(r)||!n(t))throw new Error("Parameters in function xgcd must be integer numbers");for(;t;)o=Math.floor(r/t),u=r-o*t,i=c,c=f-o*c,f=i,i=l,l=m-o*l,m=i,r=t,t=u;return s=r<0?[-r,-f,-m]:[r,r?f:0,m],"Array"===e.matrix?s:a(s)},"BigNumber, BigNumber":function(r,n){var i,o,u,s,c=new t.BigNumber(0),f=new t.BigNumber(1),l=c,m=f,h=f,p=c;if(!r.isInt()||!n.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!n.isZero();)o=r.div(n).floor(),u=r.mod(n),i=l,l=m.minus(o.times(l)),m=i,i=h,h=p.minus(o.times(h)),p=i,r=n,n=u;return s=r.lt(c)?[r.neg(),m.neg(),p.neg()]:[r,r.isZero()?0:m,p],"Array"===e.matrix?s:a(s)}});return u.toTex=void 0,u}},{"../../type/matrix/function/matrix":195,"../../utils/number":229}],89:[function(r,t,e){"use strict";var n=r("../../utils/object").clone,i=r("../../utils/number").isInteger,o=r("../../utils/array"),a=r("../../error/IndexError"),u=r("../../error/DimensionError");function s(r,t,e,n){if(n0&&m>c)throw new a(m,c+1)}else{var y=n(g).valueOf(),d=o.size(y);if(p[e]=y,c=m,m=d.length-1,e>0&&m!=c)throw new u(c+1,m+1)}}if(0==p.length)throw new SyntaxError("At least one matrix expected");for(var v=p.shift();p.length;)v=s(v,p.shift(),m,0);return h?l(v):v},"...string":function(r){return r.join("")}});return m.toTex=void 0,m}},{"../../error/DimensionError":53,"../../error/IndexError":54,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229,"../../utils/object":230}],90:[function(r,t,e){"use strict";var n=r("../../utils/array");e.name="cross",e.factory=function(t,e,i,o){var a=i(r("../../type/matrix/function/matrix")),u=i(r("../arithmetic/subtract")),s=i(r("../arithmetic/multiply")),c=o("cross",{"Matrix, Matrix":function(r,t){return a(f(r.toArray(),t.toArray()))},"Matrix, Array":function(r,t){return a(f(r.toArray(),t))},"Array, Matrix":function(r,t){return a(f(r,t.toArray()))},"Array, Array":f});return c.toTex={2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},c;function f(r,t){var e=Math.max(n.size(r).length,n.size(t).length);r=n.squeeze(r),t=n.squeeze(t);var i=n.size(r),o=n.size(t);if(1!=i.length||1!=o.length||3!=i[0]||3!=o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+o.join(", ")+"])");var a=[u(s(r[1],t[2]),s(r[2],t[1])),u(s(r[2],t[0]),s(r[0],t[2])),u(s(r[0],t[1]),s(r[1],t[0]))];return e>1?[a]:a}}},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../arithmetic/multiply":76,"../arithmetic/subtract":85}],91:[function(r,t,e){"use strict";var n=r("../../utils/index"),i=n.object,o=n.string;e.name="det",e.factory=function(t,e,n,a){var u=n(r("../../type/matrix/function/matrix")),s=n(r("../arithmetic/add")),c=n(r("../arithmetic/subtract")),f=n(r("../arithmetic/multiply")),l=n(r("../arithmetic/unaryMinus")),m=a("det",{any:function(r){return i.clone(r)},"Array | Matrix":function(r){var e;switch((e=t.isMatrix(r)?r.size():Array.isArray(r)?(r=u(r)).size():[]).length){case 0:return i.clone(r);case 1:if(1==e[0])return i.clone(r.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+o.format(e)+")");case 2:var n=e[0],a=e[1];if(n==a)return function(r,t,e){if(1==t)return i.clone(r[0][0]);if(2==t)return c(f(r[0][0],r[1][1]),f(r[1][0],r[0][1]));for(var n=function(r){var t,e,n=new Array(r.length),i=0;for(t=1;t0?e:0,s=e<0?-e:0;switch(n.length){case 1:return function(r,e,n,i,o,a){var u=[i+o,i+a],s=t.Matrix.storage(n||"dense").diagonal(u,r,e);return null!==n?s:s.valueOf()}(r,e,o,n[0],s,a);case 2:return function(r,e,n,i,o,a){if(t.isMatrix(r)){var s=r.diagonal(e);return null!==n?n!==s.storage()?u(s,n):s:s.valueOf()}for(var c=Math.min(i[0]-o,i[1]-a),f=[],l=0;l2||n(t).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(r.length)+", y = "+JSON.stringify(t.length)+")");var e=[],i=[];return r.map(function(r){return t.map(function(t){return r.map(function(r){return t.map(function(t){return i.push(u(r,t))})},e.push(i=[]))})},e=[])&&e}}},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../arithmetic/multiplyScalar":77}],101:[function(r,t,e){"use strict";var n=r("../../utils/function").maxArgumentCount;function i(r,t){var e=n(t);return function n(i,o){return Array.isArray(i)?i.map(function(r,t){return n(r,o.concat(t))}):1===e?t(i):2===e?t(i,o):t(i,o,r)}(r,[])}e.name="map",e.factory=function(r,t,e,n){var o=n("map",{"Array, function":i,"Matrix, function":function(r,t){return r.map(t)}});return o.toTex=void 0,o}},{"../../utils/function":226}],102:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger,i=r("../../utils/array").resize;e.name="ones",e.factory=function(t,e,o,a){var u=o(r("../../type/matrix/function/matrix")),s=a("ones",{"":function(){return"Array"===e.matrix?c([]):c([],"default")},"...number | BigNumber | string":function(r){if("string"==typeof r[r.length-1]){var t=r.pop();return c(r,t)}return"Array"===e.matrix?c(r):c(r,"default")},Array:c,Matrix:function(r){var t=r.storage();return c(r.valueOf(),t)},"Array | Matrix, string":function(r,t){return c(r.valueOf(),t)}});return s.toTex=void 0,s;function c(r,e){var o=function(r){var e=!1;return r.forEach(function(r,n,i){t.isBigNumber(r)&&(e=!0,i[n]=r.toNumber())}),e}(r)?new t.BigNumber(1):1;if(function(r){r.forEach(function(r){if("number"!=typeof r||!n(r)||r<0)throw new Error("Parameters in function ones must be positive integers")})}(r),e){var a=u(e);return r.length>0?a.resize(r,o):a}var s=[];return r.length>0?i(s,r,o):s}}},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],103:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger;e.name="partitionSelect",e.factory=function(t,e,i,o){var a=i(r("../relational/compare"));function u(r,t){return-a(r,t)}return o("partitionSelect",{"Array | Matrix, number":function(r,t){return s(r,t,a)},"Array | Matrix, number, string":function(r,t,e){if("asc"===e)return s(r,t,a);if("desc"===e)return s(r,t,u);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(r,e,i){if(!n(e)||e<0)throw new Error("k must be a non-negative integer");if(t.isMatrix(r)){if(r.size().length>1)throw new Error("Only one dimensional matrices supported");return c(r.valueOf(),e,i)}if(Array.isArray(r))return c(r,e,i)}function c(r,t,e){if(t>=r.length)throw new Error("k out of bounds");for(var n=0,i=r.length-1;n=0){var s=r[a];r[a]=r[o],r[o]=s,--a}else++o;e(r[o],u)>0&&--o,t<=o?i=o:n=o+1}return r[t]}}},{"../../utils/number":229,"../relational/compare":126}],104:[function(r,t,e){"use strict";e.name="range",e.factory=function(t,e,n,i){var o=n(r("../../type/matrix/function/matrix")),a=new t.BigNumber(0),u=new t.BigNumber(1),s=i("range",{string:f,"string, boolean":f,"number, number":function(r,t){return c(l(r,t,1))},"number, number, number":function(r,t,e){return c(l(r,t,e))},"number, number, boolean":function(r,t,e){return c(e?m(r,t,1):l(r,t,1))},"number, number, number, boolean":function(r,t,e,n){return c(n?m(r,t,e):l(r,t,e))},"BigNumber, BigNumber":function(r,t){return c(h(r,t,u))},"BigNumber, BigNumber, BigNumber":function(r,t,e){return c(h(r,t,e))},"BigNumber, BigNumber, boolean":function(r,t,e){return c(e?p(r,t,u):h(r,t,u))},"BigNumber, BigNumber, BigNumber, boolean":function(r,t,e,n){return c(n?p(r,t,e):h(r,t,e))}});return s.toTex=void 0,s;function c(r){return"Array"===e.matrix?r:o(r)}function f(r,n){var i=function(r){var t=r.split(":").map(function(r){return Number(r)});if(t.some(function(r){return isNaN(r)}))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}}(r);if(!i)throw new SyntaxError('String "'+r+'" is no valid range');return"BigNumber"===e.number?c((n?p:h)(new t.BigNumber(i.start),new t.BigNumber(i.end),new t.BigNumber(i.step))):c((n?m:l)(i.start,i.end,i.step))}function l(r,t,e){var n=[],i=r;if(e>0)for(;it;)n.push(i),i+=e;return n}function m(r,t,e){var n=[],i=r;if(e>0)for(;i<=t;)n.push(i),i+=e;else if(e<0)for(;i>=t;)n.push(i),i+=e;return n}function h(r,t,e){var n=[],i=r;if(e.gt(a))for(;i.lt(t);)n.push(i),i=i.plus(e);else if(e.lt(a))for(;i.gt(t);)n.push(i),i=i.plus(e);return n}function p(r,t,e){var n=[],i=r;if(e.gt(a))for(;i.lte(t);)n.push(i),i=i.plus(e);else if(e.lt(a))for(;i.gte(t);)n.push(i),i=i.plus(e);return n}}},{"../../type/matrix/function/matrix":195}],105:[function(r,t,e){"use strict";r("../../error/DimensionError");var n=r("../../utils/number").isInteger,i=r("../../utils/array");e.name="reshape",e.factory=function(t,e,o,a){var u=o(r("../../type/matrix/function/matrix")),s=a("reshape",{"Matrix, Array":function(r,t){return r.reshape?r.reshape(t):u(i.reshape(r.valueOf(),t))},"Array, Array":function(r,t){return t.forEach(function(r){if(!n(r))throw new TypeError("Invalid size for dimension: "+r)}),i.reshape(r,t)}});return s.toTex=void 0,s}},{"../../error/DimensionError":53,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],106:[function(r,t,e){"use strict";var n=r("../../error/DimensionError"),i=r("../../error/ArgumentsError"),o=r("../../utils/number").isInteger,a=r("../../utils/string").format,u=r("../../utils/object").clone,s=r("../../utils/array");e.name="resize",e.factory=function(t,e,c,f){var l=c(r("../../type/matrix/function/matrix")),m=function(r,c,f){if(2!=arguments.length&&3!=arguments.length)throw new i("resize",arguments.length,2,3);if(t.isMatrix(c)&&(c=c.valueOf()),t.isBigNumber(c[0])&&(c=c.map(function(r){return t.isBigNumber(r)?r.toNumber():r})),t.isMatrix(r))return r.resize(c,f,!0);if("string"==typeof r)return function(r,t,e){if(void 0!==e){if("string"!=typeof e||1!==e.length)throw new TypeError("Single character expected as defaultValue")}else e=" ";if(1!==t.length)throw new n(t.length,1);var i=t[0];if("number"!=typeof i||!o(i))throw new TypeError("Invalid size, must contain positive integers (size: "+a(t)+")");if(r.length>i)return r.substring(0,i);if(r.lengths)for(f=s-1,a=c.length;f0)for(var f=0;ff)break}return c}throw new RangeError("Matrix must be square (size: "+i(o)+")")};return c.toTex={1:"\\mathrm{tr}\\left(${args[0]}\\right)"},c}},{"../../type/matrix/function/matrix":195,"../../utils/object":230,"../../utils/string":231,"../arithmetic/add":56}],112:[function(r,t,e){"use strict";var n=r("../../utils/object").clone,i=r("../../utils/string").format;e.name="transpose",e.factory=function(t,e,o,a){var u=r("../../utils/latex"),s=o(r("../../type/matrix/function/matrix")),c=t.DenseMatrix,f=t.SparseMatrix,l=a("transpose",{Array:function(r){return l(s(r)).valueOf()},Matrix:function(r){var t,e=r.size();switch(e.length){case 1:t=r.clone();break;case 2:var n=e[0],o=e[1];if(0===o)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+i(e)+")");switch(r.storage()){case"dense":t=m(r,n,o);break;case"sparse":t=h(r,n,o)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+i(this._size)+")")}return t},any:function(r){return n(r)}}),m=function(r,t,e){for(var i,o=r._data,a=[],u=0;u0?a.resize(r,o):a}var s=[];return r.length>0?i(s,r,o):s}}},{"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/number":229}],114:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger;function i(r){return r.isInteger()&&r.gte(0)}e.name="combinations",e.factory=function(r,t,e,o){var a=o("combinations",{"number, number":function(r,t){var e,i,o;if(!n(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(!n(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(t>r)throw new TypeError("k must be less than or equal to n");for(e=Math.max(t,r-t),i=1,o=1;o<=r-e;o++)i=i*(e+o)/o;return i},"BigNumber, BigNumber":function(t,e){var n,o,a,u,s=new r.BigNumber(1);if(!i(t)||!i(e))throw new TypeError("Positive integer value expected in function combinations");if(e.gt(t))throw new TypeError("k must be less than n in function combinations");for(n=t.minus(e),e.lt(n)&&(n=e),o=s,a=s,u=t.minus(n);a.lte(u);a=a.plus(1))o=o.times(n.plus(a)).dividedBy(a);return o}});return a.toTex={2:"\\binom{${args[0]}}{${args[1]}}"},a}},{"../../utils/number":229}],115:[function(r,t,e){"use strict";var n=r("../../error/ArgumentsError"),i=r("../../utils/collection/isCollection"),o=r("../../utils/number").isNumber;e.name="distribution",e.factory=function(t,e,a,u,s){var c=a(r("../../type/matrix/function/matrix")),f=r("../../utils/array"),l=a(r("./seededRNG"));function m(r){if(!h.hasOwnProperty(r))throw new Error("Unknown distribution "+r);var e=Array.prototype.slice.call(arguments,1);return function(r){var e={random:function(r,e,a){var u,f,l;if(arguments.length>3)throw new n("random",arguments.length,0,3);if(1===arguments.length?i(r)?u=r:l=r:2===arguments.length?i(r)?(u=r,l=e):(f=r,l=e):(u=r,f=e,l=a),void 0!==f&&!o(f)||void 0!==l&&!o(l))throw new TypeError("Invalid argument in function random");if(void 0===l&&(l=1),void 0===f&&(f=0),void 0!==u){var m=h(u.valueOf(),f,l,s);return t.isMatrix(u)?c(m):m}return s(f,l)},randomInt:u({"number | Array":function(r){if(i(r)){var e=r,n=1,o=h(e.valueOf(),0,n,m);return t.isMatrix(e)?c(o):o}return m(0,n=r)},"number | Array, number":function(r,e){if(i(r)){var n=r,o=e,a=0,u=h(n.valueOf(),a,o,m);return t.isMatrix(n)?c(u):u}return m(a=r,o=e)},"Array, number, number":function(r,t,e){var n=h(r.valueOf(),t,e,m);return r&&!0===r.isMatrix?c(n):n}}),pickRandom:u({Array:function(r){return a(r)},"Array, number | Array":function(r,t){var e,n;if(Array.isArray(t))n=t;else{if(!o(t))throw new TypeError("Invalid argument in function pickRandom");e=t}return a(r,e,n)},"Array, number | Array, Array | number":function(r,t,e){var n,i;if(Array.isArray(t)?(i=t,n=e):(i=e,n=t),!Array.isArray(i)||!o(n))throw new TypeError("Invalid argument in function pickRandom");return a(r,n,i)}})},a=function(r,e,n){var i=void 0===e;if(i&&(e=1),t.isMatrix(r))r=r.valueOf();else if(!Array.isArray(r))throw new TypeError("Unsupported type of value in function pickRandom");if(f.size(r).length>1)throw new Error("Only one dimensional vectors supported");if(void 0!==n){if(n.length!=r.length)throw new Error("Weights must have the same length as possibles");for(var a=0,u=0,s=n.length;u=c)return e>1?r:r[0];for(var m,h=[];h.length1)for(var a=0,u=t.shift();a1;)r=l(),t=l(),e=1/6*Math.pow(-2*Math.log(r),.5)*Math.cos(2*Math.PI*t)+.5;return e}}};return m.toTex=void 0,m}},{"../../error/ArgumentsError":52,"../../type/matrix/function/matrix":195,"../../utils/array":212,"../../utils/collection/isCollection":220,"../../utils/number":229,"./seededRNG":125}],116:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="factorial",e.factory=function(t,e,i,o){var a=i(r("./gamma")),u=r("../../utils/latex"),s=o("factorial",{number:function(r){if(r<0)throw new Error("Value must be non-negative");return a(r+1)},BigNumber:function(r){if(r.isNegative())throw new Error("Value must be non-negative");return a(r.plus(1))},"Array | Matrix":function(r){return n(r,s)}});return s.toTex={1:"\\left(${args[0]}\\right)"+u.operators.factorial},s}},{"../../utils/collection/deepMap":219,"../../utils/latex":228,"./gamma":117}],117:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap"),i=r("../../utils/number").isInteger;var o=4.7421875,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];e.name="gamma",e.factory=function(t,e,u,s){var c=u(r("../arithmetic/multiply")),f=u(r("../arithmetic/pow")),l=s("gamma",{number:function(r){var t,e;if(i(r)){if(r<=0)return isFinite(r)?1/0:NaN;if(r>171)return 1/0;for(var n=r-2,u=r-1;n>1;)u*=n,n--;return 0==u&&(u=1),u}if(r<.5)return Math.PI/(Math.sin(Math.PI*r)*l(1-r));if(r>=171.35)return 1/0;if(r>85){var s=r*r,c=s*r,f=c*r,m=f*r;return Math.sqrt(2*Math.PI/r)*Math.pow(r/Math.E,r)*(1+1/(12*r)+1/(288*s)-139/(51840*c)-571/(2488320*f)+163879/(209018880*m)+5246819/(75246796800*m*r))}--r,e=a[0];for(var h=1;h1;)i=i.times(o),o--;return new t.BigNumber(i.toPrecision(t.BigNumber.precision))}(r.minus(1));if(!r.isFinite())return new t.BigNumber(r.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(r){return n(r,l)}});return l.toTex={1:"\\Gamma\\left(${args[0]}\\right)"},l}},{"../../utils/collection/deepMap":219,"../../utils/number":229,"../arithmetic/multiply":76,"../arithmetic/pow":80}],118:[function(r,t,e){"use strict";t.exports=[r("./combinations"),r("./factorial"),r("./gamma"),r("./kldivergence"),r("./multinomial"),r("./permutations"),r("./pickRandom"),r("./random"),r("./randomInt")]},{"./combinations":114,"./factorial":116,"./gamma":117,"./kldivergence":119,"./multinomial":120,"./permutations":121,"./pickRandom":122,"./random":123,"./randomInt":124}],119:[function(r,t,e){"use strict";e.name="kldivergence",e.factory=function(t,e,n,i){var o=n(r("../../type/matrix/function/matrix")),a=n(r("../arithmetic/divide")),u=n(r("../statistics/sum")),s=n(r("../arithmetic/multiply")),c=n(r("../arithmetic/dotDivide")),f=n(r("../arithmetic/log")),l=n(r("../utils/isNumeric"));function m(r,t){var e=t.size().length,n=r.size().length;if(e>1)throw new Error("first object must be one dimensional");if(n>1)throw new Error("second object must be one dimensional");if(e!==n)throw new Error("Length of two vectors must be equal");if(0===u(r))throw new Error("Sum of elements in first object must be non zero");if(0===u(t))throw new Error("Sum of elements in second object must be non zero");var i=a(r,u(r)),o=a(t,u(t)),m=u(s(i,f(c(i,o))));return l(m)?m:Number.NaN}return i("kldivergence",{"Array, Array":function(r,t){return m(o(r),o(t))},"Matrix, Array":function(r,t){return m(r,o(t))},"Array, Matrix":function(r,t){return m(o(r),t)},"Matrix, Matrix":function(r,t){return m(r,t)}})}},{"../../type/matrix/function/matrix":195,"../arithmetic/divide":61,"../arithmetic/dotDivide":63,"../arithmetic/log":73,"../arithmetic/multiply":76,"../statistics/sum":141,"../utils/isNumeric":174}],120:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepForEach");e.name="multinomial",e.factory=function(t,e,i,o){var a=i(r("../arithmetic/add")),u=i(r("../arithmetic/multiply")),s=i(r("../arithmetic/divide")),c=i(r("../probability/factorial")),f=i(r("../utils/isInteger")),l=i(r("../utils/isPositive"));return o("multinomial",{"Array | Matrix":function(r){var t=0,e=1;return n(r,function(r){if(!f(r)||!l(r))throw new TypeError("Positive integer value expected in function multinomial");t=a(t,r),e=u(e,c(r))}),s(c(t),e)}})}},{"../../utils/collection/deepForEach":218,"../arithmetic/add":56,"../arithmetic/divide":61,"../arithmetic/multiply":76,"../probability/factorial":116,"../utils/isInteger":171,"../utils/isPositive":175}],121:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger;function i(r){return r.isInteger()&&r.gte(0)}e.name="permutations",e.factory=function(t,e,o,a){var u=a("permutations",{"number | BigNumber":o(r("./factorial")),"number, number":function(r,t){var e,i;if(!n(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(!n(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(t>r)throw new TypeError("second argument k must be less than or equal to first argument n");for(e=1,i=r-t+1;i<=r;i++)e*=i;return e},"BigNumber, BigNumber":function(r,e){var n,o;if(!i(r)||!i(e))throw new TypeError("Positive integer value expected in function permutations");if(e.gt(r))throw new TypeError("second argument k must be less than or equal to first argument n");for(n=new t.BigNumber(1),o=r.minus(e).plus(1);o.lte(r);o=o.plus(1))n=n.times(o);return n}});return u.toTex=void 0,u}},{"../../utils/number":229,"./factorial":116}],122:[function(r,t,e){"use strict";e.name="pickRandom",e.factory=function(t,e,n,i){var o=n(r("./distribution"))("uniform").pickRandom;return o.toTex=void 0,o}},{"./distribution":115}],123:[function(r,t,e){"use strict";e.name="random",e.factory=function(t,e,n,i){var o=n(r("./distribution"))("uniform").random;return o.toTex=void 0,o}},{"./distribution":115}],124:[function(r,t,e){"use strict";e.name="randomInt",e.factory=function(t,e,n,i){var o=n(r("./distribution"))("uniform").randomInt;return o.toTex=void 0,o}},{"./distribution":115}],125:[function(r,t,e){"use strict";var n=r("seed-random"),i=n();e.factory=function(r,t,e,o,a){var u;function s(r){u=null===r?i:n(String(r))}return s(t.randomSeed),a.on("config",function(r,t,e){void 0!==e.randomSeed&&s(r.randomSeed)}),function(){return u()}},e.math=!0},{"seed-random":237}],126:[function(r,t,e){"use strict";var n=r("../../utils/number").nearlyEqual,i=r("../../utils/bignumber/nearlyEqual");e.name="compare",e.factory=function(t,e,o,a){var u=o(r("../../type/matrix/function/matrix")),s=o(r("../../type/matrix/utils/algorithm03")),c=o(r("../../type/matrix/utils/algorithm05")),f=o(r("../../type/matrix/utils/algorithm12")),l=o(r("../../type/matrix/utils/algorithm13")),m=o(r("../../type/matrix/utils/algorithm14")),h=a("compare",{"boolean, boolean":function(r,t){return r===t?0:r>t?1:-1},"number, number":function(r,t){return r===t||n(r,t,e.epsilon)?0:r>t?1:-1},"BigNumber, BigNumber":function(r,n){return r.eq(n)||i(r,n,e.epsilon)?new t.BigNumber(0):new t.BigNumber(r.cmp(n))},"Fraction, Fraction":function(r,e){return new t.Fraction(r.compare(e))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(r,t){if(!r.equalBase(t))throw new Error("Cannot compare units with different base");return h(r.value,t.value)},"string, string":function(r,t){return r===t?0:r>t?1:-1},"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=c(r,t,h);break;default:e=s(t,r,h,!0)}break;default:switch(t.storage()){case"sparse":e=s(r,t,h,!1);break;default:e=l(r,t,h)}}return e},"Array, Array":function(r,t){return h(u(r),u(t)).valueOf()},"Array, Matrix":function(r,t){return h(u(r),t)},"Matrix, Array":function(r,t){return h(r,u(t))},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=f(r,t,h,!1);break;default:e=m(r,t,h,!1)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=f(t,r,h,!0);break;default:e=m(t,r,h,!0)}return e},"Array, any":function(r,t){return m(u(r),t,h,!1).valueOf()},"any, Array":function(r,t){return m(u(t),r,h,!0).valueOf()}});return h.toTex=void 0,h}},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm05":202,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/bignumber/nearlyEqual":215,"../../utils/number":229}],127:[function(r,t,e){"use strict";var n=r("javascript-natural-sort");e.name="compareNatural",e.factory=function(t,e,i,o){var a=i(r("../utils/typeof")),u=(i(r("../../type/matrix/function/matrix")),i(r("./compare"))),s=u.signatures["boolean,boolean"],c=o("compareNatural",{"any, any":function(r,e){var i,o=a(r),l=a(e);if(!("number"!==o&&"BigNumber"!==o&&"Fraction"!==o||"number"!==l&&"BigNumber"!==l&&"Fraction"!==l))return"0"!==(i=u(r,e)).toString()?i>0?1:-1:n(o,l);if("Array"===o||"Matrix"===o||"Array"===l||"Matrix"===l)return 0!==(i=function r(e,n){return t.isSparseMatrix(e)&&t.isSparseMatrix(n)?f(e.toJSON().values,n.toJSON().values):t.isSparseMatrix(e)?r(e.toArray(),n):t.isSparseMatrix(n)?r(e,n.toArray()):t.isDenseMatrix(e)?r(e.toJSON().data,n):t.isDenseMatrix(n)?r(e,n.toJSON().data):Array.isArray(e)?Array.isArray(n)?f(e,n):r(e,[n]):r([e],n)}(r,e))?i:n(o,l);if(o!==l)return n(o,l);if("Complex"===o)return function(r,t){return r.re>t.re?1:r.ret.im?1:r.imt.length?1:r.lengtht},"number, number":function(r,t){return r>t&&!n(r,t,e.epsilon)},"BigNumber, BigNumber":function(r,t){return r.gt(t)&&!i(r,t,e.epsilon)},"Fraction, Fraction":function(r,t){return 1===r.compare(t)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(r,t){if(!r.equalBase(t))throw new Error("Cannot compare units with different base");return p(r.value,t.value)},"string, string":function(r,t){return r>t},"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=c(r,t,p);break;default:e=s(t,r,p,!0)}break;default:switch(t.storage()){case"sparse":e=s(r,t,p,!1);break;default:e=l(r,t,p)}}return e},"Array, Array":function(r,t){return p(u(r),u(t)).valueOf()},"Array, Matrix":function(r,t){return p(u(r),t)},"Matrix, Array":function(r,t){return p(r,u(t))},"Matrix, any":function(r,t){var e;switch(r.storage()){case"sparse":e=f(r,t,p,!1);break;default:e=m(r,t,p,!1)}return e},"any, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=f(t,r,p,!0);break;default:e=m(t,r,p,!0)}return e},"Array, any":function(r,t){return m(u(r),t,p,!1).valueOf()},"any, Array":function(r,t){return m(u(t),r,p,!0).valueOf()}});return p.toTex={2:"\\left(${args[0]}"+h.operators.larger+"${args[1]}\\right)"},p}},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm07":204,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210,"../../utils/bignumber/nearlyEqual":215,"../../utils/latex":228,"../../utils/number":229}],130:[function(r,t,e){"use strict";var n=r("../../utils/number").nearlyEqual,i=r("../../utils/bignumber/nearlyEqual");e.name="smaller",e.factory=function(t,e,o,a){var u=o(r("../../type/matrix/function/matrix")),s=o(r("../../type/matrix/utils/algorithm03")),c=o(r("../../type/matrix/utils/algorithm07")),f=o(r("../../type/matrix/utils/algorithm12")),l=o(r("../../type/matrix/utils/algorithm13")),m=o(r("../../type/matrix/utils/algorithm14")),h=r("../../utils/latex"),p=a("smaller",{"boolean, boolean":function(r,t){return r0&&(o=r[a]);return p(o,i)}var u=f(r,(t-1)/2);return h(u)}var h=a({"number | BigNumber | Complex | Unit":function(r){return r}}),p=a({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(r,t){return s(u(r,t),2)}});return l.toTex=void 0,l}},{"../../utils/array":212,"../../utils/collection/containsCollections":217,"../../utils/collection/reduce":222,"../arithmetic/addScalar":57,"../arithmetic/divideScalar":62,"../matrix/partitionSelect":103,"../relational/compare":126}],136:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepForEach"),i=r("../../utils/collection/reduce"),o=r("../../utils/collection/containsCollections");e.name="min",e.factory=function(t,e,a,u){var s=a(r("../relational/smaller")),c=u("min",{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(r,t){return i(r,t.valueOf(),f)},"...":function(r){if(o(r))throw new TypeError("Scalar values expected in function min");return l(r)}});return c.toTex="\\min\\left(${args}\\right)",c;function f(r,t){return s(r,t)?r:t}function l(r){var t=void 0;if(n(r,function(r){(void 0===t||s(r,t))&&(t=r)}),void 0===t)throw new Error("Cannot calculate min of an empty array");return t}}},{"../../utils/collection/containsCollections":217,"../../utils/collection/deepForEach":218,"../../utils/collection/reduce":222,"../relational/smaller":130}],137:[function(r,t,e){"use strict";var n=r("../../utils/array").flatten;e.name="mode",e.factory=function(r,t,e,i){return i("mode",{"Array | Matrix":o,"...":function(r){return o(r)}});function o(r){if(0==(r=n(r.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");var t={},e=[],i=0;for(var o in r)r[o]in t||(t[r[o]]=0),t[r[o]]++,t[r[o]]==i?e.push(r[o]):t[r[o]]>i&&(i=t[r[o]],e=[r[o]]);return e}}},{"../../utils/array":212}],138:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepForEach");e.name="prod",e.factory=function(t,e,i,o){var a=i(r("../arithmetic/multiplyScalar")),u=o("prod",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(r,t){throw new Error("prod(A, dim) is not yet supported")},"...":function(r){return s(r)}});return u.toTex=void 0,u;function s(r){var t=void 0;if(n(r,function(r){t=void 0===t?r:a(t,r)}),void 0===t)throw new Error("Cannot calculate prod of an empty array");return t}}},{"../../utils/collection/deepForEach":218,"../arithmetic/multiplyScalar":77}],139:[function(r,t,e){"use strict";var n=r("../../utils/number").isInteger,i=r("../../utils/number").isNumber,o=r("../../utils/array").flatten,a=r("../../utils/collection/isCollection");e.name="quantileSeq",e.factory=function(t,e,u,s){var c=u(r("../arithmetic/add")),f=u(r("../arithmetic/multiply")),l=u(r("../matrix/partitionSelect")),m=u(r("../relational/compare"));function h(r,t,e){var n=o(r),a=n.length;if(0===a)throw new Error("Cannot calculate quantile of an empty sequence");if(i(t)){var u;if(0==(v=(u=t*(a-1))%1)){var s=e?n[u]:l(n,u);return p(s),s}var h=Math.floor(u);if(e)y=n[h],d=n[h+1];else{d=l(n,h+1),y=n[h];for(var g=0;g0&&(y=n[g])}return p(y),p(d),c(f(y,1-v),f(d,v))}if((u=t.times(a-1)).isInteger())return u=u.toNumber(),s=e?n[u]:l(n,u),p(s),s;h=u.floor();var y,d,v=u.minus(h),x=h.toNumber();if(e)y=n[x],d=n[x+1];else for(d=l(n,x+1),y=n[x],g=0;g0&&(y=n[g]);p(y),p(d);var b=new v.constructor(1);return c(f(y,b.minus(v)),f(d,v))}var p=s({"number | BigNumber | Unit":function(r){return r}});return function(r,e,o){var u,s,c;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(a(r)){if("boolean"==typeof(o=o||!1)){if(s=r.valueOf(),i(e)){if(e<0)throw new Error("N/prob must be non-negative");if(e<=1)return h(s,e,o);if(e>1){if(!n(e))throw new Error("N must be a positive integer");var f=e+1;u=new Array(e);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");for(f=new t.BigNumber(m+1),u=new Array(m),l=0;l1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!t.isBigNumber(p))throw new TypeError("Unexpected type of argument in function quantileSeq");if(c=new p.constructor(1),p.isNegative()||p.gt(c))throw new Error("Probability must be between 0 and 1, inclusive")}u[l]=h(s,p,o)}return u}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}},{"../../utils/array":212,"../../utils/collection/isCollection":220,"../../utils/number":229,"../arithmetic/add":56,"../arithmetic/multiply":76,"../matrix/partitionSelect":103,"../relational/compare":126}],140:[function(r,t,e){"use strict";e.name="std",e.factory=function(t,e,n,i){var o=n(r("../arithmetic/sqrt")),a=n(r("../statistics/var")),u=i("std",{"Array | Matrix":s,"Array | Matrix, string":s,"...":function(r){return s(r)}});return u.toTex=void 0,u;function s(r,t){if(0==r.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(a.apply(null,arguments))}}},{"../arithmetic/sqrt":83,"../statistics/var":142}],141:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepForEach");e.name="sum",e.factory=function(t,e,i,o){var a=i(r("../arithmetic/addScalar")),u=o("sum",{"Array | Matrix":function(r){return s(r)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(r){return s(r)}});return u.toTex=void 0,u;function s(r){var i=void 0;if(n(r,function(r){i=void 0===i?r:a(i,r)}),void 0===i)switch(e.number){case"number":return 0;case"BigNumber":return new t.BigNumber(0);case"Fraction":return new t.Fraction(0);default:return 0}return i}}},{"../../utils/collection/deepForEach":218,"../arithmetic/addScalar":57}],142:[function(r,t,e){"use strict";var n="unbiased",i=r("../../utils/collection/deepForEach");e.name="var",e.factory=function(t,e,o,a){var u=o(r("../arithmetic/addScalar")),s=o(r("../arithmetic/subtract")),c=o(r("../arithmetic/multiplyScalar")),f=o(r("../arithmetic/divideScalar")),l=a("variance",{"Array | Matrix":function(r){return m(r,n)},"Array | Matrix, string":m,"...":function(r){return m(r,n)}});return l.toTex="\\mathrm{Var}\\left(${args}\\right)",l;function m(r,e){var n=0,o=0;if(0==r.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(i(r,function(r){n=u(n,r),o++}),0===o)throw new Error("Cannot calculate var of an empty array");var a=f(n,o);switch(n=0,i(r,function(r){var t=s(r,a);n=u(n,c(t,t))}),e){case"uncorrected":return f(n,o);case"biased":return f(n,o+1);case"unbiased":var l=t.isBigNumber(n)?new t.BigNumber(0):0;return 1==o?l:f(n,o-1);default:throw new Error('Unknown normalization "'+e+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}}},{"../../utils/collection/deepForEach":218,"../arithmetic/addScalar":57,"../arithmetic/divideScalar":62,"../arithmetic/multiplyScalar":77,"../arithmetic/subtract":85}],143:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="acos",e.factory=function(r,t,e,i){var o=i("acos",{number:function(e){return e>=-1&&e<=1||t.predictable?Math.acos(e):new r.Complex(e,0).acos()},Complex:function(r){return r.acos()},BigNumber:function(r){return r.acos()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\cos^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],144:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.acosh||function(r){return Math.log(Math.sqrt(r*r-1)+r)};e.name="acosh",e.factory=function(r,t,e,o){var a=o("acosh",{number:function(e){return e>=1||t.predictable?i(e):e<=-1?new r.Complex(Math.log(Math.sqrt(e*e-1)-e),Math.PI):new r.Complex(e,0).acosh()},Complex:function(r){return r.acosh()},BigNumber:function(r){return r.acosh()},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\cosh^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],145:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="acot",e.factory=function(r,t,e,i){var o=i("acot",{number:function(r){return Math.atan(1/r)},Complex:function(r){return r.acot()},BigNumber:function(t){return new r.BigNumber(1).div(t).atan()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\cot^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],146:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="acoth",e.factory=function(r,t,e,i){var o=i("acoth",{number:function(e){return e>=1||e<=-1||t.predictable?isFinite(e)?(Math.log((e+1)/e)+Math.log(e/(e-1)))/2:0:new r.Complex(e,0).acoth()},Complex:function(r){return r.acoth()},BigNumber:function(t){return new r.BigNumber(1).div(t).atanh()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\coth^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],147:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="acsc",e.factory=function(r,t,e,i){var o=i("acsc",{number:function(e){return e<=-1||e>=1||t.predictable?Math.asin(1/e):new r.Complex(e,0).acsc()},Complex:function(r){return r.acsc()},BigNumber:function(t){return new r.BigNumber(1).div(t).asin()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\csc^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],148:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="acsch",e.factory=function(r,t,e,i){var o=i("acsch",{number:function(r){return r=1/r,Math.log(r+Math.sqrt(r*r+1))},Complex:function(r){return r.acsch()},BigNumber:function(t){return new r.BigNumber(1).div(t).asinh()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],149:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="asec",e.factory=function(r,t,e,i){var o=i("asec",{number:function(e){return e<=-1||e>=1||t.predictable?Math.acos(1/e):new r.Complex(e,0).asec()},Complex:function(r){return r.asec()},BigNumber:function(t){return new r.BigNumber(1).div(t).acos()},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\sec^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],150:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="asech",e.factory=function(t,e,i,o){o.find(i(r("./acosh")),["Complex"]);var a=o("asech",{number:function(r){if(r<=1&&r>=-1||e.predictable){r=1/r;var n=Math.sqrt(r*r-1);return r>0||e.predictable?Math.log(n+r):new t.Complex(Math.log(n-r),Math.PI)}return new t.Complex(r,0).asech()},Complex:function(r){return r.asech()},BigNumber:function(r){return new t.BigNumber(1).div(r).acosh()},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219,"./acosh":144}],151:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="asin",e.factory=function(r,t,e,i){var o=i("asin",{number:function(e){return e>=-1&&e<=1||t.predictable?Math.asin(e):new r.Complex(e,0).asin()},Complex:function(r){return r.asin()},BigNumber:function(r){return r.asin()},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\sin^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],152:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="asinh",e.factory=function(r,t,e,i){var o=i("asinh",{number:Math.asinh||function(r){return Math.log(Math.sqrt(r*r+1)+r)},Complex:function(r){return r.asinh()},BigNumber:function(r){return r.asinh()},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\sinh^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],153:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="atan",e.factory=function(r,t,e,i){var o=i("atan",{number:function(r){return Math.atan(r)},Complex:function(r){return r.atan()},BigNumber:function(r){return r.atan()},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\tan^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],154:[function(r,t,e){"use strict";e.name="atan2",e.factory=function(t,e,n,i){var o=n(r("../../type/matrix/function/matrix")),a=n(r("../../type/matrix/utils/algorithm02")),u=n(r("../../type/matrix/utils/algorithm03")),s=n(r("../../type/matrix/utils/algorithm09")),c=n(r("../../type/matrix/utils/algorithm11")),f=n(r("../../type/matrix/utils/algorithm12")),l=n(r("../../type/matrix/utils/algorithm13")),m=n(r("../../type/matrix/utils/algorithm14")),h=i("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(r,e){return t.BigNumber.atan2(r,e)},"Matrix, Matrix":function(r,t){var e;switch(r.storage()){case"sparse":switch(t.storage()){case"sparse":e=s(r,t,h,!1);break;default:e=a(t,r,h,!0)}break;default:switch(t.storage()){case"sparse":e=u(r,t,h,!1);break;default:e=l(r,t,h)}}return e},"Array, Array":function(r,t){return h(o(r),o(t)).valueOf()},"Array, Matrix":function(r,t){return h(o(r),t)},"Matrix, Array":function(r,t){return h(r,o(t))},"Matrix, number | BigNumber":function(r,t){var e;switch(r.storage()){case"sparse":e=c(r,t,h,!1);break;default:e=m(r,t,h,!1)}return e},"number | BigNumber, Matrix":function(r,t){var e;switch(t.storage()){case"sparse":e=f(t,r,h,!0);break;default:e=m(t,r,h,!0)}return e},"Array, number | BigNumber":function(r,t){return m(o(r),t,h,!1).valueOf()},"number | BigNumber, Array":function(r,t){return m(o(t),r,h,!0).valueOf()}});return h.toTex={2:"\\mathrm{atan2}\\left(${args}\\right)"},h}},{"../../type/matrix/function/matrix":195,"../../type/matrix/utils/algorithm02":199,"../../type/matrix/utils/algorithm03":200,"../../type/matrix/utils/algorithm09":205,"../../type/matrix/utils/algorithm11":207,"../../type/matrix/utils/algorithm12":208,"../../type/matrix/utils/algorithm13":209,"../../type/matrix/utils/algorithm14":210}],155:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.atanh||function(r){return Math.log((1+r)/(1-r))/2};e.name="atanh",e.factory=function(r,t,e,o){var a=o("atanh",{number:function(e){return e<=1&&e>=-1||t.predictable?i(e):new r.Complex(e,0).atanh()},Complex:function(r){return r.atanh()},BigNumber:function(r){return r.atanh()},"Array | Matrix":function(r){return n(r,a,!0)}});return a.toTex={1:"\\tanh^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],156:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="cos",e.factory=function(r,t,e,i){var o=i("cos",{number:Math.cos,Complex:function(r){return r.cos()},BigNumber:function(r){return r.cos()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\cos\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],157:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.cosh||function(r){return(Math.exp(r)+Math.exp(-r))/2};e.name="cosh",e.factory=function(r,t,e,o){var a=o("cosh",{number:i,Complex:function(r){return r.cosh()},BigNumber:function(r){return r.cosh()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\cosh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],158:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="cot",e.factory=function(r,t,e,i){var o=i("cot",{number:function(r){return 1/Math.tan(r)},Complex:function(r){return r.cot()},BigNumber:function(t){return new r.BigNumber(1).div(t.tan())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\cot\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],159:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");function i(r){var t=Math.exp(2*r);return(t+1)/(t-1)}e.name="coth",e.factory=function(r,t,e,o){var a=o("coth",{number:i,Complex:function(r){return r.coth()},BigNumber:function(t){return new r.BigNumber(1).div(t.tanh())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\coth\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],160:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="csc",e.factory=function(r,t,e,i){var o=i("csc",{number:function(r){return 1/Math.sin(r)},Complex:function(r){return r.csc()},BigNumber:function(t){return new r.BigNumber(1).div(t.sin())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\csc\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],161:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap"),i=r("../../utils/number").sign;function o(r){return 0==r?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(r)-Math.exp(-r)))*i(r)}e.name="csch",e.factory=function(r,t,e,i){var a=i("csch",{number:o,Complex:function(r){return r.csch()},BigNumber:function(t){return new r.BigNumber(1).div(t.sinh())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\mathrm{csch}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],162:[function(r,t,e){"use strict";t.exports=[r("./acos"),r("./acosh"),r("./acot"),r("./acoth"),r("./acsc"),r("./acsch"),r("./asec"),r("./asech"),r("./asin"),r("./asinh"),r("./atan"),r("./atan2"),r("./atanh"),r("./cos"),r("./cosh"),r("./cot"),r("./coth"),r("./csc"),r("./csch"),r("./sec"),r("./sech"),r("./sin"),r("./sinh"),r("./tan"),r("./tanh")]},{"./acos":143,"./acosh":144,"./acot":145,"./acoth":146,"./acsc":147,"./acsch":148,"./asec":149,"./asech":150,"./asin":151,"./asinh":152,"./atan":153,"./atan2":154,"./atanh":155,"./cos":156,"./cosh":157,"./cot":158,"./coth":159,"./csc":160,"./csch":161,"./sec":163,"./sech":164,"./sin":165,"./sinh":166,"./tan":167,"./tanh":168}],163:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="sec",e.factory=function(r,t,e,i){var o=i("sec",{number:function(r){return 1/Math.cos(r)},Complex:function(r){return r.sec()},BigNumber:function(t){return new r.BigNumber(1).div(t.cos())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={1:"\\sec\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],164:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");function i(r){return 2/(Math.exp(r)+Math.exp(-r))}e.name="sech",e.factory=function(r,t,e,o){var a=o("sech",{number:i,Complex:function(r){return r.sech()},BigNumber:function(t){return new r.BigNumber(1).div(t.cosh())},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a)}});return a.toTex={1:"\\mathrm{sech}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],165:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="sin",e.factory=function(r,t,e,i){var o=i("sin",{number:Math.sin,Complex:function(r){return r.sin()},BigNumber:function(r){return r.sin()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\sin\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],166:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.sinh||function(r){return(Math.exp(r)-Math.exp(-r))/2};e.name="sinh",e.factory=function(r,t,e,o){var a=o("sinh",{number:i,Complex:function(r){return r.sinh()},BigNumber:function(r){return r.sinh()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a,!0)}});return a.toTex={1:"\\sinh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],167:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="tan",e.factory=function(r,t,e,i){var o=i("tan",{number:Math.tan,Complex:function(r){return r.tan()},BigNumber:function(r){return r.tan()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return o(t.value)},"Array | Matrix":function(r){return n(r,o,!0)}});return o.toTex={1:"\\tan\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":219}],168:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");var i=Math.tanh||function(r){var t=Math.exp(2*r);return(t-1)/(t+1)};e.name="tanh",e.factory=function(r,t,e,o){var a=o("tanh",{number:i,Complex:function(r){return r.tanh()},BigNumber:function(r){return r.tanh()},Unit:function(t){if(!t.hasBase(r.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return a(t.value)},"Array | Matrix":function(r){return n(r,a,!0)}});return a.toTex={1:"\\tanh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":219}],169:[function(r,t,e){"use strict";var n=r("../../utils/object");e.name="clone",e.factory=function(r,t,e,i){var o=i("clone",{any:n.clone});return o.toTex=void 0,o}},{"../../utils/object":230}],170:[function(r,t,e){"use strict";t.exports=[r("./clone"),r("./isInteger"),r("./isNegative"),r("./isNumeric"),r("./isPositive"),r("./isPrime"),r("./isZero"),r("./isNaN"),r("./typeof")]},{"./clone":169,"./isInteger":171,"./isNaN":172,"./isNegative":173,"./isNumeric":174,"./isPositive":175,"./isPrime":176,"./isZero":177,"./typeof":178}],171:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap"),i=r("../../utils/number");e.name="isInteger",e.factory=function(r,t,e,o){var a=o("isInteger",{number:i.isInteger,BigNumber:function(r){return r.isInt()},Fraction:function(r){return 1===r.d&&isFinite(r.n)},"Array | Matrix":function(r){return n(r,a)}});return a}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],172:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");r("../../utils/number");e.name="isNaN",e.factory=function(r,t,e,i){return i("isNaN",{number:function(r){return Number.isNaN(r)},BigNumber:function(r){return r.isNaN()},Fraction:function(r){return!1},Complex:function(r){return r.isNaN()},Unit:function(r){return Number.isNaN(r.value)},"Array | Matrix":function(r){return n(r,Number.isNaN)}})}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],173:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");r("../../utils/number");e.name="isNegative",e.factory=function(r,t,e,i){var o=i("isNegative",{number:function(r){return r<0},BigNumber:function(r){return r.isNeg()&&!r.isZero()&&!r.isNaN()},Fraction:function(r){return r.s<0},Unit:function(r){return o(r.value)},"Array | Matrix":function(r){return n(r,o)}});return o}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],174:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");r("../../utils/number");e.name="isNumeric",e.factory=function(r,t,e,i){var o=i("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string":function(){return!1},"Array | Matrix":function(r){return n(r,o)}});return o}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],175:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");r("../../utils/number");e.name="isPositive",e.factory=function(r,t,e,i){var o=i("isPositive",{number:function(r){return r>0},BigNumber:function(r){return!r.isNeg()&&!r.isZero()&&!r.isNaN()},Fraction:function(r){return r.s>0&&r.n>0},Unit:function(r){return o(r.value)},"Array | Matrix":function(r){return n(r,o)}});return o}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],176:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");e.name="isPrime",e.factory=function(r,t,e,i){var o=i("isPrime",{number:function(r){if(r<2)return!1;if(2==r)return!0;if(r%2==0)return!1;for(var t=3;t*t<=r;t+=2)if(r%t==0)return!1;return!0},BigNumber:function(t){if(t.lt(2))return!1;if(t.equals(2))return!0;if(t.mod(2).isZero())return!1;for(var e=r.BigNumber(3);e.times(e).lte(t);e=e.plus(1))if(t.mod(e).isZero())return!1;return!0},"Array | Matrix":function(r){return n(r,o)}});return o}},{"../../utils/collection/deepMap":219}],177:[function(r,t,e){"use strict";var n=r("../../utils/collection/deepMap");r("../../utils/number");e.name="isZero",e.factory=function(r,t,e,i){var o=i("isZero",{number:function(r){return 0===r},BigNumber:function(r){return r.isZero()},Complex:function(r){return 0===r.re&&0===r.im},Fraction:function(r){return 1===r.d&&0===r.n},Unit:function(r){return o(r.value)},"Array | Matrix":function(r){return n(r,o)}});return o}},{"../../utils/collection/deepMap":219,"../../utils/number":229}],178:[function(r,t,e){"use strict";var n=r("../../utils/types");e.name="typeof",e.factory=function(r,t,e,i){var o=i("_typeof",{any:function(t){var e=n.type(t);if("Object"===e){if(r.isBigNumber(t))return"BigNumber";if(r.isComplex(t))return"Complex";if(r.isFraction(t))return"Fraction";if(r.isMatrix(t))return"Matrix";if(r.isUnit(t))return"Unit";if(r.isIndex(t))return"Index";if(r.isRange(t))return"Range";if(r.isChain(t))return"Chain";if(r.isHelp(t))return"Help"}return e}});return o.toTex=void 0,o}},{"../../utils/types":232}],179:[function(r,t,e){"use strict";var n=r("decimal.js/decimal.js");e.name="BigNumber",e.path="type",e.factory=function(r,t,e,i,o){var a=n.clone({precision:t.precision});return a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(r){return new a(r.value)},o.on("config",function(r,t){r.precision!==t.precision&&a.config({precision:r.precision})}),a},e.math=!0},{"decimal.js/decimal.js":40}],180:[function(r,t,e){"use strict";var n=r("../../../utils/collection/deepMap");e.name="bignumber",e.factory=function(r,t,e,i){var o=i("bignumber",{"":function(){return new r.BigNumber(0)},number:function(t){return new r.BigNumber(t+"")},string:function(t){return new r.BigNumber(t)},BigNumber:function(r){return r},Fraction:function(t){return new r.BigNumber(t.n).div(t.d)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={0:"0",1:"\\left(${args[0]}\\right)"},o}},{"../../../utils/collection/deepMap":219}],181:[function(r,t,e){"use strict";t.exports=[r("./BigNumber"),r("./function/bignumber")]},{"./BigNumber":179,"./function/bignumber":180}],182:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var i=r("complex.js"),o=r("../../utils/number").format,a=r("../../utils/number").isNumber;e.name="Complex",e.path="type",e.factory=function(r,t,e,u,s){return i.prototype.type="Complex",i.prototype.isComplex=!0,i.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},i.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},i.prototype.format=function(r){var t=this.im,e=this.re,n=o(this.re,r),i=o(this.im,r),u=a(r)?r:r?r.precision:null;if(null!==u){var s=Math.pow(10,-u);Math.abs(e/t)t.re?1:r.ret.im?1:r.im");var p=e.max().map(function(r){return r+1});v(r,p,o);var g=c.length;!function r(t,e,n,i,o){var a=o===i-1,u=e.dimension(o);a?u.forEach(function(r,e){h(r),t[r]=n[e[0]]}):u.forEach(function(a,u){h(a),r(t[a],e,n[u[0]],i,o+1)})}(r._data,e,n,g,0)}return r}(this,r,e,n);default:throw new SyntaxError("Wrong number of arguments")}},y.prototype.get=function(r){if(!c(r))throw new TypeError("Array expected");if(r.length!=this._size.length)throw new i(r.length,this._size.length);for(var t=0;tn[o]&&(n[o]=t[o],i=!0);i&&d(r,n,e)}return y.prototype.reshape=function(r,t){var e=t?this.clone():this;return e._data=a.reshape(e._data,r),e._size=r.slice(0),e},y.prototype.clone=function(){return new y({data:u.clone(this._data),size:u.clone(this._size),datatype:this._datatype})},y.prototype.size=function(){return this._size.slice(0)},y.prototype.map=function(r){var t=this;return new y({data:function e(n,i){return c(n)?n.map(function(r,t){return e(r,i.concat(t))}):r(n,i,t)}(this._data,[]),size:u.clone(this._size),datatype:this._datatype})},y.prototype.forEach=function(r){var t=this;!function e(n,i){c(n)?n.forEach(function(r,t){e(r,i.concat(t))}):r(n,i,t)}(this._data,[])},y.prototype.toArray=function(){return u.clone(this._data)},y.prototype.valueOf=function(){return this._data},y.prototype.format=function(r){return o.format(this._data,r)},y.prototype.toString=function(){return o.format(this._data)},y.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},y.prototype.diagonal=function(r){if(r){if(t.isBigNumber(r)&&(r=r.toNumber()),!f(r)||!l(r))throw new TypeError("The parameter k must be an integer number")}else r=0;for(var e=r>0?r:0,n=r<0?-r:0,i=this._size[0],o=this._size[1],a=Math.min(i-n,o-e),u=[],s=0;s0?n:0,h=n<0?-n:0,g=r[0],d=r[1],v=Math.min(g-h,d-s);if(c(e)){if(e.length!==v)throw new Error("Invalid value array length");u=function(r){return e[r]}}else if(t.isMatrix(e)){var x=e.size();if(1!==x.length||x[0]!==v)throw new Error("Invalid matrix length");u=function(r){return e.get([r])}}else u=function(){return e};i||(i=t.isBigNumber(u(0))?new t.BigNumber(0):0);var b=[];if(r.length>0){b=a.resize(b,r,i);for(var w=0;w0;){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,e--}return r.left.right=r.right,r.right.left=r.left,r==r.right?t=null:(t=r.right,t=m(t,this._size)),this._size--,this._minimum=t,r},s.prototype.remove=function(r){this._minimum=c(this._minimum,r,-1),this.extractMinimum()};var c=function(r,t,e){t.key=e;var n=t.parent;return n&&o(t.key,n.key)&&(f(r,t,n),l(r,n)),o(t.key,r.key)&&(r=t),r},f=function(r,t,e){t.left.right=t.right,t.right.left=t.left,e.degree--,e.child==t&&(e.child=t.right),0===e.degree&&(e.child=null),t.left=r,t.right=r.right,r.right=t,t.right.left=t,t.parent=null,t.mark=!1},l=function r(t,e){var n=e.parent;n&&(e.mark?(f(t,e,n),r(n)):e.mark=!0)},m=function(r,t){var e,n,i,s=Math.floor(Math.log(t)*u)+1,c=new Array(s),f=0,l=r;if(l)for(f++,l=l.right;l!==r;)f++,l=l.right;for(;f>0;){for(var m=l.degree,h=l.right;e=c[m];){if(a(l.key,e.key)){var p=e;e=l,l=p}i=l,(n=e).left.right=n.right,n.right.left=n.left,n.parent=i,i.child?(n.left=i.child,n.right=i.child.right,i.child.right=n,n.right.left=n):(i.child=n,n.right=n,n.left=n),i.degree++,n.mark=!1,c[m]=null,m++}c[m]=l,l=h,f--}r=null;for(var g=0;g0?this.step>0?this.start:this.start+(r-1)*this.step:void 0},o.prototype.max=function(){var r=this.size()[0];return r>0?this.step>0?this.start+(r-1)*this.step:this.start:void 0},o.prototype.forEach=function(r){var t=this.start,e=this.step,n=this.end,i=0;if(e>0)for(;tn;)r(t,[i],this),t+=e,i++},o.prototype.map=function(r){var t=[];return this.forEach(function(e,n,i){t[n[0]]=r(e,n,i)}),t},o.prototype.toArray=function(){var r=[];return this.forEach(function(t,e){r[e[0]]=t}),r},o.prototype.valueOf=function(){return this.toArray()},o.prototype.format=function(r){var t=n.format(this.start,r);return 1!=this.step&&(t+=":"+n.format(this.step,r)),t+=":"+n.format(this.end,r)},o.prototype.toString=function(){return this.format()},o.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},o.fromJSON=function(r){return new o(r.start,r.end,r.step)},o}},{"../../utils/number":229}],192:[function(r,t,e){"use strict";e.name="Spa",e.path="type",e.factory=function(t,e,n){var i=n(r("../../function/arithmetic/add")),o=n(r("../../function/relational/equalScalar"));function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new t.FibonacciHeap}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(r,t){if(this._values[r])this._values[r].value=t;else{var e=this._heap.insert(r,t);this._values[r]=e}},a.prototype.get=function(r){var t=this._values[r];return t?t.value:0},a.prototype.accumulate=function(r,t){var e=this._values[r];e?e.value=i(e.value,t):(e=this._heap.insert(r,t),this._values[r]=e)},a.prototype.forEach=function(r,t,e){var n=this._heap,i=this._values,a=[],u=n.extractMinimum();for(u&&a.push(u);u&&u.key<=t;)u.key>=r&&(o(u.value,0)||e(u.key,u.value,this)),(u=n.extractMinimum())&&a.push(u);for(var s=0;s0){var u=0;do{r._ptr.push(r._index.length);for(var s=0;s");for(var h=e.min()[0],p=e.min()[1],g=s[0],y=s[1],d=0;da-1||o>u-1)&&(E(this,Math.max(n+1,a),Math.max(o+1,u),e),a=this._size[0],u=this._size[1]),h(n,a),h(o,u);var l=A(n,this._ptr[o],this._ptr[o+1],this._index);return lh){for(s=h;sl){if(f){var p=0;for(s=0;st-1&&(r._values.splice(c,1),r._index.splice(c,1),v++)}r._ptr[s]=r._values.length}return r._size[0]=t,r._size[1]=e,r};v.prototype.reshape=function(r,t){if(!c(r))throw new TypeError("Array expected");if(2!==r.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");if(r.forEach(function(t){if(!s.isNumber(t)||!s.isInteger(t)||t<0)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(r)+")")}),this._size[0]*this._size[1]!=r[0]*r[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var e=t?this.clone():this;if(this._size[0]===r[0]&&this._size[1]===r[1])return e;for(var n=[],i=0;i=t&&M<=e){if(!a)for(var A=b;A "+(this._values?u.format(this._values[c],r):"X")}return i},v.prototype.toString=function(){return u.format(this.toArray())},v.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},v.prototype.diagonal=function(r){if(r){if(t.isBigNumber(r)&&(r=r.toNumber()),!f(r)||!l(r))throw new TypeError("The parameter k must be an integer number")}else r=0;var e=r>0?r:0,n=r<0?-r:0,i=this._size[0],o=this._size[1],a=Math.min(i-n,o-e),u=[],s=[],c=[];c[0]=0;for(var m=e;m0?n:0,p=n<0?-n:0,y=r[0],x=r[1],b=Math.min(y-p,x-h);if(c(e)){if(e.length!==b)throw new Error("Invalid value array length");s=function(r){return e[r]}}else if(t.isMatrix(e)){var w=e.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");s=function(r){return e.get([r])}}else s=function(){return e};for(var M=[],A=[],N=[],_=0;_=0&&E=s||i[f]!==t)){var m=n?n[c]:void 0;i.splice(f,0,t),n&&n.splice(f,0,m),i.splice(f<=c?c+1:c,1),n&&n.splice(f<=c?c+1:c,1)}else if(f=s||i[c]!==r)){var h=n?n[f]:void 0;i.splice(c,0,r),n&&n.splice(c,0,h),i.splice(c<=f?f+1:f,1),n&&n.splice(c<=f?f+1:f,1)}}},t.Matrix._storage.sparse=v,v},e.lazy=!1},{"../../error/DimensionError":53,"../../function/relational/equalScalar":128,"../../utils/index":227,"./Matrix":189}],194:[function(r,t,e){"use strict";e.name="index",e.factory=function(r,t,e,n){return n("index",{"...number | string | BigNumber | Range | Array | Matrix":function(t){var e=t.map(function(t){return r.isBigNumber(t)?t.toNumber():Array.isArray(t)||r.isMatrix(t)?t.map(function(t){return r.isBigNumber(t)?t.toNumber():t}):t}),n=new r.Index;return r.Index.apply(n,e),n}})}},{}],195:[function(r,t,e){"use strict";e.name="matrix",e.factory=function(r,t,e,n){var i=n("matrix",{"":function(){return o([])},string:function(r){return o([],r)},"string, string":function(r,t){return o([],r,t)},Array:function(r){return o(r)},Matrix:function(r){return o(r,r.storage())},"Array | Matrix, string":o,"Array | Matrix, string, string":o});return i.toTex={0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},i;function o(t,e,n){return new(r.Matrix.storage(e||"default"))(t,n)}}},{}],196:[function(r,t,e){"use strict";e.name="sparse",e.factory=function(r,t,e,n){var i=r.SparseMatrix,o=n("sparse",{"":function(){return new i([])},string:function(r){return new i([],r)},"Array | Matrix":function(r){return new i(r)},"Array | Matrix, string":function(r,t){return new i(r,t)}});return o.toTex={0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},o}},{}],197:[function(r,t,e){"use strict";t.exports=[r("./Matrix"),r("./DenseMatrix"),r("./SparseMatrix"),r("./Spa"),r("./FibonacciHeap"),r("./ImmutableDenseMatrix"),r("./MatrixIndex"),r("./Range"),r("./function/index"),r("./function/matrix"),r("./function/sparse")]},{"./DenseMatrix":186,"./FibonacciHeap":187,"./ImmutableDenseMatrix":188,"./Matrix":189,"./MatrixIndex":190,"./Range":191,"./Spa":192,"./SparseMatrix":193,"./function/index":194,"./function/matrix":195,"./function/sparse":196}],198:[function(r,t,e){"use strict";var n=r("../../../error/DimensionError");e.name="algorithm01",e.factory=function(r,t,e,i){var o=r.DenseMatrix;return function(r,t,e,a){var u=r._data,s=r._size,c=r._datatype,f=t._values,l=t._index,m=t._ptr,h=t._size,p=t._datatype;if(s.length!==h.length)throw new n(s.length,h.length);if(s[0]!==h[0]||s[1]!==h[1])throw new RangeError("Dimension mismatch. Matrix A ("+s+") must match Matrix B ("+h+")");if(!f)throw new Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");var g,y,d=s[0],v=s[1],x="string"==typeof c&&c===p?c:void 0,b=x?i.find(e,[x,x]):e,w=[];for(g=0;g0?a(y,0,p,p[0],s,l):[];return new o({data:d,size:p,datatype:u})}}},{"../../../error/DimensionError":53,"../../../utils/index":227}],210:[function(r,t,e){"use strict";var n=r("../../../utils/object").clone;e.name="algorithm14",e.factory=function(r,t,e,i){var o=r.DenseMatrix,a=function r(t,e,n,i,o,a,u){var s=[];if(e===n.length-1)for(var c=0;c0?a(m,0,f,f[0],c,t,u):[];return new o({data:h,size:n(f),datatype:s})}}},{"../../../utils/object":230}],211:[function(r,t,e){"use strict";var n=r("./../utils/collection/deepMap");e.name="number",e.factory=function(r,t,e,i){var o=i("number",{"":function(){return 0},number:function(r){return r},string:function(r){var t=Number(r);if(isNaN(t))throw new SyntaxError('String "'+r+'" is no valid number');return t},BigNumber:function(r){return r.toNumber()},Fraction:function(r){return r.valueOf()},Unit:function(r){throw new Error("Second argument with valueless unit expected")},"Unit, string | Unit":function(r,t){return r.toNumber(t)},"Array | Matrix":function(r){return n(r,o)}});return o.toTex={0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},o}},{"./../utils/collection/deepMap":219}],212:[function(r,t,e){"use strict";var n=r("./number"),i=r("./string"),o=(r("./object"),r("./types"),r("../error/DimensionError")),a=r("../error/IndexError");e.size=function(r){for(var t=[];Array.isArray(r);)t.push(r.length),r=r[0];return t},e.validate=function(r,t){if(0==t.length){if(Array.isArray(r))throw new o(r.length,0)}else!function r(t,e,n){var i,a=t.length;if(a!=e[n])throw new o(a,e[n]);if(n")}(r,t,0)},e.validateIndex=function(r,t){if(!n.isNumber(r)||!n.isInteger(r))throw new TypeError("Index must be an integer (value: "+r+")");if(r<0||"number"==typeof t&&r>=t)throw new a(r,t)},e.UNINITIALIZED={},e.resize=function(r,t,o){if(!Array.isArray(r)||!Array.isArray(t))throw new TypeError("Array expected");if(0===t.length)throw new Error("Resizing to scalar is not supported");return t.forEach(function(r){if(!n.isNumber(r)||!n.isInteger(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+i.format(t)+")")}),function r(t,n,i,o){var a;var u;var s=t.length;var c=n[i];var f=Math.min(s,c);t.length=c;if(i=u.length)throw new o(t,u.length);return i(r)?r.create(a(r.valueOf(),t,e)):a(r,t,e)}},{"../../error/IndexError":54,"../array":212,"../collection/isMatrix":221}],223:[function(r,t,e){"use strict";t.exports=function(r,t,e,n,i,o,a,u,s,c,f){var l,m,h,p,g=r._values,y=r._index,d=r._ptr,v=a._index;if(n)for(m=d[t],h=d[t+1],l=m;l>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},e.defaultTemplate="\\mathrm{${name}}\\left(${args}\\right)";var i={deg:"^\\circ"};e.escape=function(r){return n(r,{preserveFormatting:!0})},e.toSymbol=function(r,t){return(t=void 0!==t&&t)?i.hasOwnProperty(r)?i[r]:"\\mathrm{"+e.escape(r)+"}":e.symbols.hasOwnProperty(r)?e.symbols[r]:e.escape(r)}},{"escape-latex":43}],229:[function(r,t,e){"use strict";function n(r){for(var t=[],e=0;e0?1:r<0?-1:0},e.format=function(r,t){if("function"==typeof t)return t(r);if(r===1/0)return"Infinity";if(r===-1/0)return"-Infinity";if(isNaN(r))return"NaN";var n="auto",i=void 0;switch(t&&(t.notation&&(n=t.notation),e.isNumber(t)?i=t:t.precision&&(i=t.precision)),n){case"fixed":return e.toFixed(r,i);case"exponential":return e.toExponential(r,i);case"engineering":return e.toEngineering(r,i);case"auto":return e.toPrecision(r,i,t&&t.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var r=arguments[2],t=arguments[4];return"."!==r?r+t:t});default:throw new Error('Unknown notation "'+n+'". Choose "auto", "exponential", or "fixed".')}},e.splitNumber=function(r){var t=String(r).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!t)throw new SyntaxError("Invalid number "+r);var e=t[1],n=t[2],i=parseFloat(t[4]||"0"),o=n.indexOf(".");i+=-1!==o?o-1:n.length-1;var a=n.replace(".","").replace(/^0*/,function(r){return i-=r.length,""}).replace(/0*$/,"").split("").map(function(r){return parseInt(r)});return 0===a.length&&(a.push(0),i++),{sign:e,coefficients:a,exponent:i}},e.toEngineering=function(r,t){if(isNaN(r)||!isFinite(r))return String(r);var i=e.roundDigits(e.splitNumber(r),t),o=i.exponent,a=i.coefficients,u=o%3==0?o:o<0?o-3-o%3:o-o%3,s=o>=0?o:Math.abs(u);a.length-1=0;)f++;var l=a.slice(f).join(""),m=l.match(/[1-9]/)?"."+l:"",h=a.slice(0,f).join("")+m+"e"+(o>=0?"+":"")+u.toString();return i.sign+h},e.toFixed=function(r,t){if(isNaN(r)||!isFinite(r))return String(r);var i=e.splitNumber(r),o=e.roundDigits(i,i.exponent+1+(t||0)),a=o.coefficients,u=o.exponent+1,s=u+(t||0);return a.length0?"."+a.join(""):"")+"e"+(u>=0?"+":"")+u},e.toPrecision=function(r,t,i){if(isNaN(r)||!isFinite(r))return String(r);var o=i&&void 0!==i.lower?i.lower:.001,a=i&&void 0!==i.upper?i.upper:1e5,u=e.splitNumber(r),s=Math.abs(Math.pow(10,u.exponent));if(s=a)return e.toExponential(r,t);var c=t?e.roundDigits(u,t):u,f=c.coefficients,l=c.exponent;f.length0?l:0;return m<(f=n(-l).concat(f)).length-1&&f.splice(m+1,0,"."),c.sign+f.join("")},e.roundDigits=function(r,t){for(var e={sign:r.sign,coefficients:r.coefficients,exponent:r.exponent},n=e.coefficients;t<=0;)n.unshift(0),e.exponent++,t++;if(n.length>t&&n.splice(t,n.length-t)[0]>=5){var i=t-1;for(n[i]++;10===n[i];)n.pop(),0===i&&(n.unshift(0),e.exponent++,i++),n[--i]++}return e},e.digits=function(r){return r.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},e.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,e.nearlyEqual=function(r,t,n){if(null==n)return r==t;if(r==t)return!0;if(isNaN(r)||isNaN(t))return!1;if(isFinite(r)&&isFinite(t)){var i=Math.abs(r-t);return i/g,">")}},{"./bignumber/formatter":213,"./bignumber/isBigNumber":214,"./number":229}],232:[function(r,t,e){"use strict";function n(r){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}e.type=function(r){var t=n(r);return"object"===t?null===r?"null":Array.isArray(r)?"Array":r instanceof Date?"Date":r instanceof RegExp?"RegExp":r instanceof Boolean?"boolean":r instanceof Number?"number":r instanceof String?"string":"Object":"function"===t?"Function":t}},{}],233:[function(require,module,exports){(function(global){"use strict";function _typeof(r){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var numeric=void 0===exports?function(){}:exports;void 0!==global&&(global.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(r,t){var e,n,i;for(void 0===t&&(t=15),n=.5,e=new Date;;){for(i=n*=2;i>3;i-=4)r(),r(),r(),r();for(;i>0;)r(),i--;if(new Date-e>t)break}for(i=n;i>3;i-=4)r(),r(),r(),r();for(;i>0;)r(),i--;return 1e3*(3*n-1)/(new Date-e)},numeric._myIndexOf=function(r){var t,e=this.length;for(t=0;tnumeric.largeArray)return t.push("...Large Array..."),!0;for(s=!1,t.push("["),n=0;n0&&(t.push(","),s&&t.push("\n ")),s=r(e[n]);return t.push("]"),!0}t.push("{");s=!1;for(n in e)e.hasOwnProperty(n)&&(s&&t.push(",\n"),s=!0,t.push(n),t.push(": \n"),r(e[n]));return t.push("}"),!0}(r),t.join("")},numeric.parseDate=function(r){return function r(t){if("string"==typeof t)return Date.parse(t.replace(/-/g,"/"));if(!(t instanceof Array))throw new Error("parseDate: parameter must be arrays of strings");var e,n=[];for(e=0;e0){for(o[s]=[],t=0;t>>8^i[255&(o^r[n])];return-1^o}var e,n,i,o,a,u,s,c,f,l,m=r[0].length,h=r[0][0].length,p=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,h>>24&255,h>>16&255,h>>8&255,255&h,m>>24&255,m>>16&255,m>>8&255,255&m,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(l=t(p,12,29),p[29]=l>>24&255,p[30]=l>>16&255,p[31]=l>>8&255,p[32]=255&l,e=1,n=0,s=0;s>8&255,p.push(a),p.push(u),p.push(255&~a),p.push(255&~u),0===s&&p.push(0),c=0;c255?255:a<0?0:Math.round(a)))%65521))%65521,p.push(a);p.push(0)}return f=(n<<16)+e,p.push(f>>24&255),p.push(f>>16&255),p.push(f>>8&255),p.push(255&f),o=p.length-41,p[33]=o>>24&255,p[34]=o>>16&255,p[35]=o>>8&255,p[36]=255&o,l=t(p,37),p.push(l>>24&255),p.push(l>>16&255),p.push(l>>8&255),p.push(255&l),p.push(0),p.push(0),p.push(0),p.push(0),p.push(73),p.push(69),p.push(78),p.push(68),p.push(174),p.push(66),p.push(96),p.push(130),"data:image/png;base64,"+function(r){var t,e,n,i,o,a,u,s=r.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="";for(t=0;t>4),a=((15&n)<<2)+((i=r[t+2])>>6),u=63&i,t+1>=s?a=u=64:t+2>=s&&(u=64),f+=c.charAt(e>>2)+c.charAt(o)+c.charAt(a)+c.charAt(u);return f}(p)},numeric._dim=function(r){for(var t=[];"object"===_typeof(r);)t.push(r.length),r=r[0];return t},numeric.dim=function(r){var t;return"object"===_typeof(r)?"object"===_typeof(t=r[0])?"object"===_typeof(t[0])?numeric._dim(r):[r.length,t.length]:[r.length]:[]},numeric.mapreduce=function(r,t){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+t+';\nif(typeof x === "number") { var xi = x; '+r+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+r+";\n xi = x[i-1];\n "+r+";\n}\nif(i === 0) {\n xi = x[i];\n "+r+"\n}\nreturn accum;")},numeric.mapreduce2=function(r,t){return Function("x","var n = x.length;\nvar i,xi;\n"+t+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+r+";\n}\nreturn accum;")},numeric.same=function r(t,e){var n,i;if(!(t instanceof Array&&e instanceof Array))return!1;if((i=t.length)!==e.length)return!1;for(n=0;n=0;n-=2)o[n+1]=t,o[n]=t;return-1===n&&(o[0]=t),o}for(n=i-1;n>=0;n--)o[n]=numeric.rep(r,t,e+1);return o},numeric.dotMMsmall=function(r,t){var e,n,i,o,a,u,s,c,f,l,m;for(o=r.length,a=t.length,u=t[0].length,s=Array(o),e=o-1;e>=0;e--){for(c=Array(u),f=r[e],i=u-1;i>=0;i--){for(l=f[a-1]*t[a-1][i],n=a-2;n>=1;n-=2)m=n-1,l+=f[n]*t[n][i]+f[m]*t[m][i];0===n&&(l+=f[0]*t[0][i]),c[i]=l}s[e]=c}return s},numeric._getCol=function(r,t,e){var n;for(n=r.length-1;n>0;--n)e[n]=r[n][t],e[--n]=r[n][t];0===n&&(e[0]=r[0][t])},numeric.dotMMbig=function(r,t){var e,n,i,o=numeric._getCol,a=t.length,u=Array(a),s=r.length,c=t[0].length,f=new Array(s),l=numeric.dotVV;for(--a,n=--s;-1!==n;--n)f[n]=Array(c);for(n=--c;-1!==n;--n)for(o(t,n,u),i=s;-1!==i;--i)0,e=r[i],f[i][n]=l(e,u);return f},numeric.dotMV=function(r,t){var e,n=r.length,i=(t.length,Array(n)),o=numeric.dotVV;for(e=n-1;e>=0;e--)i[e]=o(r[e],t);return i},numeric.dotVM=function(r,t){var e,n,i,o,a,u,s;for(i=r.length,o=t[0].length,a=Array(o),n=o-1;n>=0;n--){for(u=r[i-1]*t[i-1][n],e=i-2;e>=1;e-=2)s=e-1,u+=r[e]*t[e][n]+r[s]*t[s][n];0===e&&(u+=r[0]*t[0][n]),a[n]=u}return a},numeric.dotVV=function(r,t){var e,n,i=r.length,o=r[i-1]*t[i-1];for(e=i-2;e>=1;e-=2)n=e-1,o+=r[e]*t[e]+r[n]*t[n];return 0===e&&(o+=r[0]*t[0]),o},numeric.dot=function(r,t){var e=numeric.dim;switch(1e3*e(r).length+e(t).length){case 2002:return t.length<10?numeric.dotMMsmall(r,t):numeric.dotMMbig(r,t);case 2001:return numeric.dotMV(r,t);case 1002:return numeric.dotVM(r,t);case 1001:return numeric.dotVV(r,t);case 1e3:return numeric.mulVS(r,t);case 1:return numeric.mulSV(r,t);case 0:return r*t;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(r){var t,e,n,i,o=r.length,a=Array(o);for(t=o-1;t>=0;t--){for(i=Array(o),e=t+2,n=o-1;n>=e;n-=2)i[n]=0,i[n-1]=0;for(n>t&&(i[n]=0),i[t]=r[t],n=t-1;n>=1;n-=2)i[n]=0,i[n-1]=0;0===n&&(i[0]=0),a[t]=i}return a},numeric.getDiag=function(r){var t,e=Math.min(r.length,r[0].length),n=Array(e);for(t=e-1;t>=1;--t)n[t]=r[t][t],n[--t]=r[t][t];return 0===t&&(n[0]=r[0][0]),n},numeric.identity=function(r){return numeric.diag(numeric.rep([r],1))},numeric.pointwise=function(r,t,e){void 0===e&&(e="");var n,i,o=[],a=/\[i\]$/,u="",s=!1;for(n=0;n=0;i--) ret[i] = arguments.callee("+r.join(",")+",_s,_k+1);\n return ret;\n}\n"+e+"\nfor(i=_n-1;i!==-1;--i) {\n "+t+"\n}\nreturn ret;",Function.apply(null,o)},numeric.pointwise2=function(r,t,e){void 0===e&&(e="");var n,i,o=[],a=/\[i\]$/,u="",s=!1;for(n=0;n=0;a--)r("object"===_typeof(t)?t[a]:t,"object"===_typeof(e)?e[a]:e,n,i+1,o);else o(t,e)},numeric._biforeach2=function r(t,e,n,i,o){if(i===n.length-1)return o(t,e);var a,u=n[i],s=Array(u);for(a=u-1;a>=0;--a)s[a]=r("object"===_typeof(t)?t[a]:t,"object"===_typeof(e)?e[a]:e,n,i+1,o);return s},numeric._foreach=function r(t,e,n,i){var o;if(n!==e.length-1)for(o=e[n]-1;o>=0;o--)r(t[o],e,n+1,i);else i(t)},numeric._foreach2=function r(t,e,n,i){if(n===e.length-1)return i(t);var o,a=e[n],u=Array(a);for(o=a-1;o>=0;o--)u[o]=r(t[o],e,n+1,i);return u},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var r,t;for(r=0;rg&&(p=o,g=u);for(e=m[p],m[p]=m[a],m[a]=e,i=h[p],h[p]=h[a],h[a]=i,r=e[a],u=a;u!==l;++u)e[u]/=r;for(u=l-1;-1!==u;--u)i[u]/=r;for(o=f-1;-1!==o;--o)if(o!==a){for(t=m[o],n=h[o],r=t[a],u=a+1;u!==l;++u)t[u]-=e[u]*r;for(u=l-1;u>0;--u)n[u]-=i[u]*r,n[--u]-=i[u]*r;0===u&&(n[0]-=i[0]*r)}}return h},numeric.det=function(r){var t=numeric.dim(r);if(2!==t.length||t[0]!==t[1])throw new Error("numeric: det() only works on square matrices");var e,n,i,o,a,u,s,c,f=t[0],l=1,m=numeric.clone(r);for(n=0;nMath.abs(m[i][n])&&(i=e);for(i!==n&&(s=m[i],m[i]=m[n],m[n]=s,l*=-1),o=m[n],e=n+1;e=1;t-=2){for(i=r[t],n=r[t-1],e=u-1;e>=1;--e)(o=s[e])[t]=i[e],o[t-1]=n[e],(o=s[--e])[t]=i[e],o[t-1]=n[e];0===e&&((o=s[0])[t]=i[0],o[t-1]=n[0])}if(0===t){for(n=r[0],e=u-1;e>=1;--e)s[e][0]=n[e],s[--e][0]=n[e];0===e&&(s[0][0]=n[0])}return s},numeric.negtranspose=function(r){var t,e,n,i,o,a=r.length,u=r[0].length,s=Array(u);for(e=0;e=1;t-=2){for(i=r[t],n=r[t-1],e=u-1;e>=1;--e)(o=s[e])[t]=-i[e],o[t-1]=-n[e],(o=s[--e])[t]=-i[e],o[t-1]=-n[e];0===e&&((o=s[0])[t]=-i[0],o[t-1]=-n[0])}if(0===t){for(n=r[0],e=u-1;e>=1;--e)s[e][0]=-n[e],s[--e][0]=-n[e];0===e&&(s[0][0]=-n[0])}return s},numeric._random=function r(t,e){var n,i,o=t[e],a=Array(o);if(e===t.length-1){for(i=Math.random,n=o-1;n>=1;n-=2)a[n]=i(),a[n-1]=i();return 0===n&&(a[0]=i()),a}for(n=o-1;n>=0;n--)a[n]=r(t,e+1);return a},numeric.random=function(r){return numeric._random(r,0)},numeric.norm2=function(r){return Math.sqrt(numeric.norm2Squared(r))},numeric.linspace=function(r,t,e){if(void 0===e&&(e=Math.max(Math.round(t-r)+1,1)),e<2)return 1===e?[r]:[];var n,i=Array(e);for(n=--e;n>=0;n--)i[n]=(n*t+(e-n)*r)/e;return i},numeric.getBlock=function(r,t,e){var n=numeric.dim(r);return function r(i,o){var a,u=t[o],s=e[o]-u,c=Array(s);if(o===n.length-1){for(a=s;a>=0;a--)c[a]=i[a+u];return c}for(a=s;a>=0;a--)c[a]=r(i[a+u],o+1);return c}(r,0)},numeric.setBlock=function(r,t,e,n){var i=numeric.dim(r);return function r(n,o,a){var u,s=t[a],c=e[a]-s;if(a===i.length-1)for(u=c;u>=0;u--)n[u+s]=o[u];for(u=c;u>=0;u--)r(n[u+s],o[u],a+1)}(r,n,0),r},numeric.getRange=function(r,t,e){var n,i,o,a,u=t.length,s=e.length,c=Array(u);for(n=u-1;-1!==n;--n)for(c[n]=Array(s),o=c[n],a=r[t[n]],i=s-1;-1!==i;--i)o[i]=a[e[i]];return c},numeric.blockMatrix=function(r){var t=numeric.dim(r);if(t.length<4)return numeric.blockMatrix([r]);var e,n,i,o,a,u=t[0],s=t[1];for(e=0,n=0,i=0;i=0;o--){for(i=Array(c),u=r[o],a=c-1;a>=3;--a)i[a]=u*t[a],i[--a]=u*t[a],i[--a]=u*t[a],i[--a]=u*t[a];for(;a>=0;)i[a]=u*t[a],--a;f[o]=i}return f},numeric.T=function(r,t){this.x=r,this.y=t},numeric.t=function(r,t){return new numeric.T(r,t)},numeric.Tbinop=function(r,t,e,n,i){var o;numeric.indexOf;if("string"!=typeof i)for(o in i="",numeric)numeric.hasOwnProperty(o)&&(r.indexOf(o)>=0||t.indexOf(o)>=0||e.indexOf(o)>=0||n.indexOf(o)>=0)&&o.length>1&&(i+="var "+o+" = numeric."+o+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+i+"\nif(x.y) { if(y.y) { return new numeric.T("+n+");\n }\n return new numeric.T("+e+");\n}\nif(y.y) {\n return new numeric.T("+t+");\n}\nreturn new numeric.T("+r+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var r=numeric.mul,t=numeric.div;if(this.y){var e=numeric.add(r(this.x,this.x),r(this.y,this.y));return new numeric.T(t(this.x,e),t(numeric.neg(this.y),e))}return new T(t(1,this.x))},numeric.T.prototype.div=function(r){if(r instanceof numeric.T||(r=new numeric.T(r)),r.y)return this.mul(r.reciprocal());var t=numeric.div;return this.y?new numeric.T(t(this.x,r.x),t(this.y,r.x)):new numeric.T(t(this.x,r.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var r=numeric.transpose,t=this.x,e=this.y;return e?new numeric.T(r(t),r(e)):new numeric.T(r(t))},numeric.T.prototype.transjugate=function(){var r=numeric.transpose,t=this.x,e=this.y;return e?new numeric.T(r(t),numeric.negtranspose(e)):new numeric.T(r(t))},numeric.Tunop=function(r,t,e){return"string"!=typeof e&&(e=""),Function("var x = this;\n"+e+"\nif(x.y) { "+t+";\n}\n"+r+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var r=this;if(void 0===r.y)return new numeric.T(numeric.inv(r.x));var t,e,n,i,o,a,u,s,c,f,l,m,h,p,g,y,d,v,x=r.x.length,b=numeric.identity(x),w=numeric.rep([x,x],0),M=numeric.clone(r.x),A=numeric.clone(r.y);for(c=0;cm&&(l=f,m=h);for(l!==c&&(v=M[c],M[c]=M[l],M[l]=v,v=A[c],A[c]=A[l],A[l]=v,v=b[c],b[c]=b[l],b[l]=v,v=w[c],w[c]=w[l],w[l]=v),t=M[c],e=A[c],o=b[c],a=w[c],p=t[c],g=e[c],f=c+1;f0;c--)for(o=b[c],a=w[c],f=c-1;f>=0;f--)for(u=b[f],s=w[f],p=M[f][c],g=A[f][c],l=x-1;l>=0;l--)y=o[l],d=a[l],u[l]-=p*y-g*d,s[l]-=p*d+g*y;return new numeric.T(b,w)},numeric.T.prototype.get=function(r){var t,e=this.x,n=this.y,i=0,o=r.length;if(n){for(;i=0?1:-1)*numeric.norm2(r);t[0]+=e;var n=numeric.norm2(t);if(0===n)throw new Error("eig: internal error");return numeric.div(t,n)},numeric.toUpperHessenberg=function(r){var t=numeric.dim(r);if(2!==t.length||t[0]!==t[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var e,n,i,o,a,u,s,c,f,l,m=t[0],h=numeric.clone(r),p=numeric.identity(m);for(n=0;n0){for(a=numeric.house(o),u=numeric.getBlock(h,[n+1,n],[m-1,m-1]),s=numeric.tensor(a,numeric.dot(a,u)),e=n+1;e=4*s)_=.5*(c+Math.sqrt(c*c-4*s)),E=.5*(c-Math.sqrt(c*c-4*s)),f=numeric.add(numeric.sub(numeric.dot(f,f),numeric.mul(f,_+E)),numeric.diag(numeric.rep([3],_*E)));else f=numeric.add(numeric.sub(numeric.dot(f,f),numeric.mul(f,c)),numeric.diag(numeric.rep([3],s)));for(e=[f[0][0],f[1][0],f[2][0]],n=numeric.house(e),h=[r[0],r[1],r[2]],p=numeric.tensor(n,numeric.dot(n,h)),y=0;y<3;y++)for(m=r[y],g=p[y],v=0;v=0?((y=(a-(m=f<0?-.5*(f-E(l)):-.5*(f+E(l))))*(a-m)+u*u)>(d=s*s+(c-m)*(c-m))?(p=(a-m)/(y=E(y)),g=u/y):(p=s/(d=E(d)),g=(c-m)/d),i=new b([[g,-p],[p,g]]),N.setRows(e,o,i.dot(N.getRows(e,o)))):(m=-.5*f,h=.5*E(-l),(y=(a-m)*(a-m)+u*u)>(d=s*s+(c-m)*(c-m))?(p=(a-m)/(y=E(y+h*h)),g=u/y,m=0,h/=y):(p=s/(d=E(d+h*h)),g=(c-m)/d,m=h/d,h=0),i=new b([[g,-p],[p,g]],[[m,h],[h,-m]]),N.setRows(e,o,i.dot(N.getRows(e,o))))}var S=N.dot(r).dot(N.transjugate()),j=(w=r.length,numeric.T.identity(w));for(o=0;o0)for(n=o-1;n>=0;n--){var B=S.get([n,n]),T=S.get([o,o]);numeric.neq(B.x,T.x)||numeric.neq(B.y,T.y)?(m=S.getRow(n).getBlock([n],[o-1]),h=j.getRow(o).getBlock([n],[o-1]),j.set([o,n],S.get([n,o]).neg().sub(m.dot(h)).div(B.sub(T)))):j.setRow(o,j.getRow(n))}for(o=0;o=o.length;)o[o.length]=0;0!==t[n]&&o[n]++}var a=o.length,u=Array(a+1);for(u[0]=0,e=0;e=s){if(i[f]=h[c],0===c)return;++f,u=l[--c],s=m[c]}else 0===n[a=o[e[u]]]?(n[a]=1,l[c]=u,h[++c]=a,u=t[a],m[c]=s=t[a+1]):++u},numeric.ccsLPSolve=function(r,t,e,n,i,o,a){var u,s,c,f,l,m,h,p,g,y=r[0],d=r[1],v=r[2],x=(y.length,t[0]),b=t[1],w=t[2];for(s=x[i],c=x[i+1],n.length=0,u=s;uo&&(a=i,o=u);for(w(v[e])=c){if(i[l]=o[p[f]],0===f)return;++l,s=m[--f],c=h[f]}else 0===n[u=e[s]]?(n[u]=1,m[f]=s,p[++f]=u,s=t[u=o[u]],h[f]=c=t[u+1]):++s}},numeric.ccsLPSolve0=function(r,t,e,n,i,o,a,u){var s,c,f,l,m,h,p,g,y,d=r[0],v=r[1],x=r[2],b=(d.length,t[0]),w=t[1],M=t[2];for(c=b[i],f=b[i+1],n.length=0,s=c;so&&(a=i,o=u);for(w(v[M[e]])e[n]&&(e[n]=t.length),t)t.hasOwnProperty(i)&&r(t[i],e,n+1);return e},numeric.sclone=function r(t,e,n){void 0===e&&(e=0),void 0===n&&(n=numeric.sdim(t).length);var i,o=Array(t.length);if(e===n-1){for(i in t)t.hasOwnProperty(i)&&(o[i]=t[i]);return o}for(i in t)t.hasOwnProperty(i)&&(o[i]=r(t[i],e+1,n));return o},numeric.sdiag=function(r){var t,e,n=r.length,i=Array(n);for(t=n-1;t>=1;t-=2)e=t-1,i[t]=[],i[t][t]=r[t],i[e]=[],i[e][e]=r[e];return 0===t&&(i[0]=[],i[0][0]=r[t]),i},numeric.sidentity=function(r){return numeric.sdiag(numeric.rep([r],1))},numeric.stranspose=function(r){var t,e,n,i=[];r.length;for(t in r)if(r.hasOwnProperty(t))for(e in n=r[t])n.hasOwnProperty(e)&&("object"!==_typeof(i[e])&&(i[e]=[]),i[e][t]=n[e]);return i},numeric.sLUP=function(r,t){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(r,t){var e,n,i,o,a,u,s,c=r.length,f=(t.length,numeric.stranspose(t)),l=f.length,m=Array(c);for(i=c-1;i>=0;i--){for(s=[],e=r[i],a=l-1;a>=0;a--){for(o in u=0,n=f[a],e)e.hasOwnProperty(o)&&o in n&&(u+=e[o]*n[o]);u&&(s[a]=u)}m[i]=s}return m},numeric.sdotMV=function(r,t){var e,n,i,o,a=r.length,u=Array(a);for(n=a-1;n>=0;n--){for(i in o=0,e=r[n])e.hasOwnProperty(i)&&t[i]&&(o+=e[i]*t[i]);o&&(u[n]=o)}return u},numeric.sdotVM=function(r,t){var e,n,i,o,a=[];for(e in r)if(r.hasOwnProperty(e))for(n in i=t[e],o=r[e],i)i.hasOwnProperty(n)&&(a[n]||(a[n]=0),a[n]+=o*i[n]);return a},numeric.sdotVV=function(r,t){var e,n=0;for(e in r)r[e]&&t[e]&&(n+=r[e]*t[e]);return n},numeric.sdot=function(r,t){var e=numeric.sdim(r).length,n=numeric.sdim(t).length;switch(1e3*e+n){case 0:return r*t;case 1001:return numeric.sdotVV(r,t);case 2001:return numeric.sdotMV(r,t);case 1002:return numeric.sdotVM(r,t);case 2002:return numeric.sdotMM(r,t);default:throw new Error("numeric.sdot not implemented for tensors of order "+e+" and "+n)}},numeric.sscatter=function(r){var t,e,n,i,o=r[0].length,a=r.length,u=[];for(e=o-1;e>=0;--e)if(r[a-1][e]){for(i=u,n=0;n=0;--o)e[o]=[];for(o=i;o>=0;--o)e[o].push(n[o]);e[i+1].push(a)}}else r(a,e,n);return n.length>i&&n.pop(),e},numeric.cLU=function(r){var t,e,n,i,o,a,u=r[0],s=r[1],c=r[2],f=u.length,l=0;for(t=0;tl&&(l=u[t]);l++;var m,h=Array(l),p=Array(l),g=numeric.rep([l],1/0),y=numeric.rep([l],-1/0);for(n=0;ny[t]&&(y[t]=e);for(t=0;ty[t+1]&&(y[t+1]=y[t]);for(t=l-1;t>=1;t--)g[t]=0;e--){for(;l[n]>e;)a[e]-=m[n]*a[l[n]],n--;a[e]/=m[n],n--}return a},numeric.cgrid=function(r,t){"number"==typeof r&&(r=[r,r]);var e,n,i,o=numeric.rep(r,-1);if("function"!=typeof t)switch(t){case"L":t=function(t,e){return t>=r[0]/2||ei&&(i=o[n]);for(i++,e=numeric.rep([i],0),n=0;n1;)i[n=a((t+e)/2)]<=r?t=n:e=n;return this._at(r,t)}o=r.length;var u,s=Array(o);for(u=o-1;-1!==u;--u)s[u]=this.at(r[u]);return s},numeric.Spline.prototype.diff=function(){var r,t,e,n=this.x,i=this.yl,o=this.yr,a=this.kl,u=this.kr,s=i.length,c=a,f=u,l=Array(s),m=Array(s),h=numeric.add,p=numeric.mul,g=numeric.div,y=numeric.sub;for(r=s-1;-1!==r;--r)t=n[r+1]-n[r],e=y(o[r+1],i[r]),l[r]=g(h(p(e,6),p(a[r],-4*t),p(u[r+1],-2*t)),t*t),m[r+1]=g(h(p(e,-6),p(a[r],2*t),p(u[r+1],4*t)),t*t);return new numeric.Spline(n,c,f,l,m)},numeric.Spline.prototype.roots=function(){function r(r){return r*r}var t=[],e=this.x,n=this.yl,i=this.yr,o=this.kl,a=this.kr;"number"==typeof n[0]&&(n=[n],i=[i],o=[o],a=[a]);var u,s,c,f,l,m,h,p,g,y,d,v,x,b,w,M,A,N,_,E,S,j,B,T=n.length,z=e.length-1,C=(t=Array(T),Math.sqrt);for(u=0;u!==T;++u){for(f=n[u],l=i[u],m=o[u],h=a[u],p=[],s=0;s!==z;s++){for(s>0&&l[s]*f[s]<0&&p.push(e[s]),M=e[s+1]-e[s],e[s],d=f[s],v=l[s+1],g=m[s]/M,x=(y=h[s+1]/M)+3*d+2*g-3*v,b=3*(y+g+2*(d-v)),(w=r(g-y+3*(d-v))+12*y*d)<=0?A=(N=x/b)>e[s]&&Ne[s]&&Ne[s]&&_0)S=j,N=_;else{for(var O=0;!((B=(N*j-_*S)/(N-_))<=S||B>=j);)if((E=this._at(B,s))*_>0)j=B,_=E,-1===O&&(N*=.5),O=-1;else{if(!(E*N>0))break;S=B,N=E,1===O&&(_*=.5),O=1}p.push(B),S=A[c+1],N=this._at(S,s)}else p.push(S),S=j,N=_;0===_&&p.push(j)}t[u]=p}return"number"==typeof this.yl[0]?t[0]:t},numeric.spline=function(r,t,e,n){var i,o=r.length,a=[],u=[],s=[],c=numeric.sub,f=numeric.mul,l=numeric.add;for(i=o-2;i>=0;i--)u[i]=r[i+1]-r[i],s[i]=c(t[i+1],t[i]);"string"!=typeof e&&"string"!=typeof n||(e=n="periodic");var m=[[],[],[]];switch(_typeof(e)){case"undefined":a[0]=f(3/(u[0]*u[0]),s[0]),m[0].push(0,0),m[1].push(0,1),m[2].push(2/u[0],1/u[0]);break;case"string":a[0]=l(f(3/(u[o-2]*u[o-2]),s[o-2]),f(3/(u[0]*u[0]),s[0])),m[0].push(0,0,0),m[1].push(o-2,0,1),m[2].push(1/u[o-2],2/u[o-2]+2/u[0],1/u[0]);break;default:a[0]=e,m[0].push(0),m[1].push(0),m[2].push(1)}for(i=1;i20)throw new Error("Numerical gradient fails");if(p[i]=t[i]+x,o=r(p),p[i]=t[i]-x,a=r(p),p[i]=t[i],isNaN(o)||isNaN(a))x/=16;else{if(g[i]=(o-a)/(2*x),u=t[i]-x,s=t[i],c=t[i]+x,f=(o-n)/x,l=(n-a)/x,m=h(y(g[i]),y(n),y(o),y(a),y(u),y(s),y(c),1e-8),!(d(h(y(f-g[i]),y(l-g[i]),y(f-l))/m,x/m)>.001))break;x/=16}}return g},numeric.uncmin=function(r,t,e,n,i,o,a){var u=numeric.gradient;void 0===a&&(a={}),void 0===e&&(e=1e-8),void 0===n&&(n=function(t){return u(r,t)}),void 0===i&&(i=1e3);var s,c,f=(t=numeric.clone(t)).length,l=r(t);if(isNaN(l))throw new Error("uncmin: f(x0) is a NaN!");var m=Math.max,h=numeric.norm2;e=m(e,numeric.epsilon);var p,g,y,d,v,x,b,w,M,A,N=a.Hinv||numeric.identity(f),_=numeric.dot,E=(numeric.inv,numeric.sub),S=numeric.add,j=numeric.tensor,B=numeric.div,T=numeric.mul,z=numeric.all,C=numeric.isFinite,O=numeric.neg,k=0,I="";for(g=n(t);k=.1*M*c||isNaN(s));)M*=.5,++k;if(M*A1;)u[n=i(.5*(t+e))]<=r?t=n:e=n;return this._at(r,t)},numeric.dopri=function(r,t,e,n,i,o,a){void 0===i&&(i=1e-6),void 0===o&&(o=1e3);var u,s,c,f,l,m,h,p,g,y,d,v,x,b=[r],w=[e],M=[n(r,e)],A=[],N=[.075,.225],_=[44/45,-56/15,32/9],E=[19372/6561,-25360/2187,64448/6561,-212/729],S=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],j=[35/384,0,500/1113,125/192,-2187/6784,11/84],B=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],T=[.2,.3,.8,8/9,1,1],z=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],C=0,O=(t-r)/10,k=0,I=numeric.add,P=numeric.mul,F=(Math.max,Math.min),q=Math.abs,U=numeric.norminf,D=Math.pow,R=numeric.any,L=numeric.lt,$=numeric.and,V=(numeric.sub,new numeric.Dopri(b,w,M,A,-1,""));for("function"==typeof a&&(d=a(r,e));rt&&(O=t-r),u=n(r+T[0]*O,I(e,P(.2*O,M[C]))),s=n(r+T[1]*O,I(I(e,P(N[0]*O,M[C])),P(N[1]*O,u))),c=n(r+T[2]*O,I(I(I(e,P(_[0]*O,M[C])),P(_[1]*O,u)),P(_[2]*O,s))),f=n(r+T[3]*O,I(I(I(I(e,P(E[0]*O,M[C])),P(E[1]*O,u)),P(E[2]*O,s)),P(E[3]*O,c))),l=n(r+T[4]*O,I(I(I(I(I(e,P(S[0]*O,M[C])),P(S[1]*O,u)),P(S[2]*O,s)),P(S[3]*O,c)),P(S[4]*O,f))),m=n(r+O,g=I(I(I(I(I(e,P(M[C],O*j[0])),P(s,O*j[2])),P(c,O*j[3])),P(f,O*j[4])),P(l,O*j[5]))),(y="number"==typeof(h=I(I(I(I(I(P(M[C],O*z[0]),P(s,O*z[2])),P(c,O*z[3])),P(f,O*z[4])),P(l,O*z[5])),P(m,O*z[6])))?q(h):U(h))>i){if(r+(O=.2*O*D(i/y,.25))===r){V.msg="Step size became too small";break}}else{if(A[C]=I(I(I(I(I(I(e,P(M[C],O*B[0])),P(s,O*B[2])),P(c,O*B[3])),P(f,O*B[4])),P(l,O*B[5])),P(m,O*B[6])),b[++C]=r+O,w[C]=g,M[C]=m,"function"==typeof a){var Z,X,H=r,Y=r+.5*O;if(v=a(Y,A[C-1]),R(x=$(L(d,0),L(0,v)))||(H=Y,d=v,v=a(Y=r+O,g),x=$(L(d,0),L(0,v))),R(x)){for(var J,G,W=0,Q=1,K=1;;){if("number"==typeof d)X=(K*v*H-Q*d*Y)/(K*v-Q*d);else for(X=Y,p=d.length-1;-1!==p;--p)d[p]<0&&v[p]>0&&(X=F(X,(K*v[p]*H-Q*d[p]*Y)/(K*v[p]-Q*d[p])));if(X<=H||X>=Y)break;G=a(X,Z=V._at(X,C-1)),R(J=$(L(d,0),L(0,G)))?(Y=X,v=G,x=J,K=1,-1===W?Q*=.5:Q=1,W=-1):(H=X,d=G,Q=1,1===W?K*=.5:K=1,W=1)}return g=V._at(.5*(r+X),C-1),V.f[C]=n(X,Z),V.x[C]=X,V.y[C]=Z,V.ymid[C-1]=g,V.events=x,V.iterations=k,V}}r+=O,e=g,d=v,O=F(.8*O*D(i/y,.25),4*O)}return V.iterations=k,V},numeric.LU=function(r,t){t=t||!1;var e,n,i,o,a,u,s,c,f,l=Math.abs,m=r.length,h=m-1,p=new Array(m);for(t||(r=numeric.clone(r)),i=0;i=0;--e){for(o=u[e],n=e+1;nI)&&(b=I),f=y(r,m(b,S)),s=p(k,j),C=d-1;-1!==C;--C)s[C][C]+=1;O=B(s,g(f,b),!0);var P=g(T,p(t,O)),F=1;for(C=v-1;-1!==C;--C)P[C]<0&&(F=N(F,-.999*P[C]));if(u=h(o,m(O,F)),!_(E(T=h(e,p(t,u)),0)))return{solution:o,message:"",iterations:c};if(o=u,b=0);if(x)return{solution:u,message:"Unbounded",iterations:c}}return{solution:o,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(r,t,e,n,i){var o=r.length,a=e.length,u=(numeric.sum,numeric.log,numeric.mul,numeric.sub),s=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([o],0).concat([1])),f=numeric.rep([a,1],-1),l=numeric.blockMatrix([[t,f]]),m=e,h=numeric.rep([o],0).concat(Math.max(0,numeric.sup(numeric.neg(e)))+1),p=numeric.__solveLP(c,l,m,n,i,h,!1),g=numeric.clone(p.solution);if(g.length=o,numeric.inf(u(e,s(t,g)))<0)return{solution:NaN,message:"Infeasible",iterations:p.iterations};var y=numeric.__solveLP(r,t,e,n,i-p.iterations,g,!0);return y.iterations+=p.iterations,y},numeric.solveLP=function(r,t,e,n,i,o,a){if(void 0===a&&(a=1e3),void 0===o&&(o=numeric.epsilon),void 0===n)return numeric._solveLP(r,t,e,o,a);var u,s=n.length,c=n[0].length,f=t.length,l=numeric.echelonize(n),m=numeric.rep([c],0),h=l.P,p=[];for(u=h.length-1;-1!==u;--u)m[h[u]]=1;for(u=c-1;-1!==u;--u)0===m[u]&&p.push(u);var g=numeric.getRange,y=numeric.linspace(0,s-1),d=numeric.linspace(0,f-1),v=g(n,y,p),x=g(t,d,h),b=g(t,d,p),w=numeric.dot,M=numeric.sub,A=w(x,l.I),N=M(b,w(A,v)),_=M(e,w(A,i)),E=Array(h.length),S=Array(p.length);for(u=h.length-1;-1!==u;--u)E[u]=r[h[u]];for(u=p.length-1;-1!==u;--u)S[u]=r[p[u]];var j=M(S,w(E,w(l.I,v))),B=numeric._solveLP(j,N,_,o,a),T=B.solution;if(T!=T)return B;var z=w(l.I,M(i,w(v,T))),C=Array(r.length);for(u=h.length-1;-1!==u;--u)C[h[u]]=z[u];for(u=p.length-1;-1!==u;--u)C[p[u]]=T[u];return{solution:C,message:B.message,iterations:B.iterations}},numeric.MPStoLP=function(r){r instanceof String&&r.split("\n");var t,e,n,i,o=0,a=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],u=r.length,s=0,c={},f=[],l=0,m={},h=0,p=[],g=[],y=[];function d(e){throw new Error("MPStoLP: "+e+"\nLine "+t+": "+r[t]+"\nCurrent state: "+a[o]+"\n")}for(t=0;t=o;)r/=2,t/=2,n>>>=1;return(r+n)/t},n},a=t.pow(e,6),i=t.pow(2,i),o=2*i,s(t.random(),r)}([],numeric.seedrandom,256,0,52),function(r){function t(r){if("object"!==_typeof(r))return r;var e,n=[],i=r.length;for(e=0;ef)p[v]=z;else if(p[v]=-Math.abs(z),z>0){for(d=1;d<=n;d+=1)a[d][y]=-a[d][y];u[y]=-u[y]}}for(y=1;y<=m;y+=1)p[_+l[y]]=0;for(S=0,T=0,y=1;y<=c;y+=1)p[_+y]=1;y-=1){for(z=p[y],x=(v=N+y*(y+3)/2)-y,d=y+1;d<=m;d+=1)z-=p[v]*p[A+d],v+=d;if(z/=p[x],p[A+y]=z,l[y]f)p[_+S]=z;else if(p[_+S]=-Math.abs(z),z>0){for(d=1;d<=n;d+=1)a[d][S]=-a[d][S];u[S]=-u[S]}return 700}for(l[m+=1]=S,v=N+(m-1)*m/2+1,y=1;y<=m-1;y+=1)p[v]=p[y],v+=1;if(m===n)p[v]=p[n];else{for(y=n;y>=m+1&&0!==p[y]&&(k=Math.max(Math.abs(p[y-1]),Math.abs(p[y])),I=Math.min(Math.abs(p[y-1]),Math.abs(p[y])),T=p[y-1]>=0?Math.abs(k*Math.sqrt(1+I*I/(k*k))):-Math.abs(k*Math.sqrt(1+I*I/(k*k))),k=p[y-1]/T,I=p[y]/T,1!==k);y-=1)if(0===k)for(p[y-1]=I*T,d=1;d<=n;d+=1)T=r[d][y-1],r[d][y-1]=r[d][y],r[d][y]=T;else for(p[y-1]=T,P=I/(1+k),d=1;d<=n;d+=1)T=k*r[d][y-1]+I*r[d][y],r[d][y]=P*(r[d][y-1]+T)-r[d][y],r[d][y-1]=T;p[v]=p[m]}return 0}function Z(){if(0===p[x=(v=N+w*(w+1)/2+1)+w])return 798;if(k=Math.max(Math.abs(p[x-1]),Math.abs(p[x])),I=Math.min(Math.abs(p[x-1]),Math.abs(p[x])),T=p[x-1]>=0?Math.abs(k*Math.sqrt(1+I*I/(k*k))):-Math.abs(k*Math.sqrt(1+I*I/(k*k))),k=p[x-1]/T,I=p[x]/T,1===k)return 798;if(0===k){for(y=w+1;y<=m;y+=1)T=p[x-1],p[x-1]=p[x],p[x]=T,x+=y;for(y=1;y<=n;y+=1)T=r[y][w],r[y][w]=r[y][w+1],r[y][w+1]=T}else{for(P=I/(1+k),y=w+1;y<=m;y+=1)T=k*p[x-1]+I*p[x],p[x]=P*(p[x-1]+T)-p[x],p[x-1]=T,x+=y;for(y=1;y<=n;y+=1)T=k*r[y][w]+I*r[y][w+1],r[y][w+1]=P*(r[y][w]+T)-r[y][w+1],r[y][w]=T}return 0}function X(){for(x=v-w,y=1;y<=w;y+=1)p[x]=p[v],v+=1,x+=1;return p[E+w]=p[E+w+1],l[w]=l[w+1],(w+=1)(t=Math.abs(t))?r*Math.sqrt(1+t*t/r/r):0==t?r:t*Math.sqrt(1+r*r/t/t)}var y=0,d=0,v=0,x=0,b=0,w=0,M=0;for(o=0;o=0&&(d=-d),v=y*d-M,c[o][o]=y-d,a=s;a=0&&(d=-d),v=y*d-M,c[o][o+1]=y-d,a=s;ax&&(x=b)}for(o=l-1;-1!=o;o+=-1){if(0!=d){for(v=d*c[o][o+1],a=s;a=49)throw"Error: no convergence.";for(x=h[s],d=g(y=(((b=h[u-1])-w)*(b+w)+((d=m[u-1])-(v=m[u]))*(d+v))/(2*v*b),1),y=y<0?((x-w)*(x+w)+v*(b/(y-d)-v))/x:((x-w)*(x+w)+v*(b/(y+d)-v))/x,i=1,M=1,o=s+1;o=0;a--)if(h[a]u&&(o=s,u=t[s]);return o},t.exports=o},{"mathjs/core":47,"mathjs/lib/function/arithmetic":71,"mathjs/lib/function/matrix":98,"mathjs/lib/type/matrix":197,"pw-stat":236}],236:[function(r,t,e){"use strict";e.cov=function(r){for(var t=r.length,e=[],n=0;n=s;)r/=2,t/=2,e>>>=1;return(r+e)/t}},t.exports.resetGlobal=function(){Math.random=f},m(Math.random(),i)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],238:[function(r,t,e){"use strict";function n(){}n.prototype={on:function(r,t,e){var n=this.e||(this.e={});return(n[r]||(n[r]=[])).push({fn:t,ctx:e}),this},once:function(r,t,e){var n=this;function i(){n.off(r,i),t.apply(e,arguments)}return i._=t,this.on(r,i,e)},emit:function(r){for(var t=[].slice.call(arguments,1),e=((this.e||(this.e={}))[r]||[]).slice(),n=0,i=e.length;ne&&!c?"Unexpected type of argument in function "+s+" (expected: "+u.join(" or ")+", actual: "+a+", index: "+e+")":"Too few arguments in function "+s+" (expected: "+u.join(" or ")+", index: "+e+")":"Too many arguments in function "+s+" (expected: "+e+", actual: "+t+")";var h=new TypeError(o);return h.data=m,h}function o(r){this.name=r||"refs",this.categories={}}function a(r,t){if("string"==typeof r){var e=r.trim(),n="..."===e.substr(0,3);if(n&&(e=e.substr(3)),""===e)this.types=["any"];else{this.types=e.split("|");for(var i=0;it&&(t=n)}return t}(n));f.push("function "+m+"("+h.join(", ")+") {"),f.push(' "use strict";'),f.push(" var name = "+JSON.stringify(r||"")+";"),f.push(c.toCode(e," ",!1)),f.push("}");var p=[e.toCode(),"return "+f.join("\n")].join("\n"),g=new Function(e.name,"createError",p)(e,i);return g.signatures=function(r){for(var t={},e=0;e0},a.prototype.contains=function(r){for(var t=0;tt.params.length)return 1;if(r.params.lengtho)return 1;if(i "+i+") {"),n.push(e+" var varArgs = [];"),n.push(e+" for (var i = "+i+"; i < arguments.length; i++) {"),n.push(e+" varArgs.push(arguments[i]);"),n.push(e+" }"),n.push(this.signature.toCode(r,e+" ")),n.push(e+"}");else{for(var u=function(e,n){for(var i=[],o=0;o "+e+") {",t+" throw createError(name, arguments.length, "+e+", arguments["+e+"]);",t+"}"].join("\n");for(var n={},i=[],o=0;o=127&&r<160?t.control:function(r){var t,e=0,n=i.length-1;if(ri[n][1])return!1;for(;n>=e;)if(t=Math.floor((e+n)/2),r>i[t][1])e=t+1;else{if(!(r=4352&&(r<=4447||9001==r||9002==r||r>=11904&&r<=42191&&12351!=r||r>=44032&&r<=55203||r>=63744&&r<=64255||r>=65040&&r<=65049||r>=65072&&r<=65135||r>=65280&&r<=65376||r>=65504&&r<=65510||r>=131072&&r<=196605||r>=196608&&r<=262141))}t.exports=function(r){return a(r,o)},t.exports.config=function(r){return r=n(r||{},o),function(t){return a(t,r)}}},{"./combining":240,defaults:41}]},{},[1])(1)}); \ No newline at end of file +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).bci=t()}}(function(){var define,module,exports;return function(){return function t(r,n,e){function i(a,u){if(!n[a]){if(!r[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[a]={exports:{}};r[a][0].call(f.exports,function(t){return i(r[a][1][t]||t)},f,f.exports,t,r,n,e)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a3&&void 0!==arguments[3]?arguments[3]:null,a=new Array(n.length),u=0;u3&&void 0!==arguments[3]?arguments[3]:null;null===i&&(i=Math.pow(2,e(t.length))),("string"==typeof n||n instanceof String)&&(n={delta:[1,3],theta:[4,7],alpha:[8,12],beta:[13,30],gamma:[31,50]}[n]);for(var o=Math.floor(n[0]/r*i),a=Math.min(Math.ceil(n[1]/r*i),t.length-1),u=0,s=o;s=this.size&&(this.callback(this.channels),this.clear())},u.prototype.clear=function(){this.length=0;for(var t=0;t1?i-1:0),a=1;at.length)&&(r=t.length);for(var n=0,e=new Array(r);n1?r-1:0),i=1;i1?n-1:0),o=1;o2&&void 0!==arguments[2]?arguments[2]:"python";r=r.split(" ");var o=[];return r.forEach(function(r){r.indexOf(":");var n=r.split(":");n.length>2||""==r?console.error("Invalid subscript string"):(""==n[1]&&(n[1]=t.length),n=n.map(Number),"matlab"!=i&&"mat"!=i||(n[0]>0&&(n[0]-=1),-1==n[1]&&(n[1]=t.length),n[1]<0&&(n[1]+=1)),1==n.length&&n.push(n[0]+1),o.push(t.slice.apply(t,e(n))))}),(n=[]).concat.apply(n,o)}(r,i.shift(),"matlab");if(0!=i.length)for(var u=0;u3&&void 0!==arguments[3]?arguments[3]:-1,i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];-1==e&&(e=n);for(var o=[],a=0;a1&&void 0!==arguments[1]?arguments[1]:1,n=0,e=0;et.length)&&(r=t.length);for(var n=0,e=new Array(r);n1&&void 0!==arguments[1]?arguments[1]:null;if(null==r)return e.log(e.var(t));if(-1==["rows","cols","columns"].indexOf(r))throw"Invalid dimension";return"cols"!=r&&"columns"!=r||(t=i(t)),t.map(function(t){return e.log(e.var(t))})},r.exports.variance=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null==r)return e.log(e.var(t));if(-1==["rows","cols","columns"].indexOf(r))throw"Invalid dimension";return"cols"!=r&&"columns"!=r||(t=i(t)),t.map(function(t){return e.var(t)})},r.exports.rootMeanSquare=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(null==r)return e.sqrt(e.mean(e.square(t)));if(-1==["rows","cols","columns"].indexOf(r))throw"Invalid dimension";return"cols"!=r&&"columns"!=r||(t=i(t)),t.map(function(t){return e.sqrt(e.mean(e.square(t)))})}},{"./transpose.js":27,"mathjs/core":49,"mathjs/lib/function/arithmetic":73,"mathjs/lib/function/matrix":100,"mathjs/lib/function/statistics":133,"mathjs/lib/type/matrix":199}],21:[function(t,r,n){"use strict";var e=t("mathjs/core").create();e.import(t("mathjs/lib/type/matrix")),e.import(t("mathjs/lib/type/bignumber")),e.import(t("mathjs/lib/function/arithmetic")),e.import(t("mathjs/lib/function/matrix")),e.import(t("mathjs/lib/function/trigonometry")),r.exports=function(t,r,n,i){for(var o=e.range(0,i,1/n),a=e.zeros(o.size()[0]),u=0;ut.length)&&(r=t.length);for(var n=0,e=new Array(r);n<~]))"].join("|");return new RegExp(t,"g")}},{}],38:[function(t,r,n){"use strict";n.byteLength=function(t){var r=c(t),n=r[0],e=r[1];return 3*(n+e)/4-e},n.toByteArray=function(t){var r,n,e=c(t),a=e[0],u=e[1],s=new o(function(t,r,n){return 3*(r+n)/4-n}(0,a,u)),f=0,l=u>0?a-4:a;for(n=0;n>16&255,s[f++]=r>>8&255,s[f++]=255&r;2===u&&(r=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,s[f++]=255&r);1===u&&(r=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,s[f++]=r>>8&255,s[f++]=255&r);return s},n.fromByteArray=function(t){for(var r,n=t.length,i=n%3,o=[],a=0,u=n-i;au?u:a+16383));1===i?(r=t[n-1],o.push(e[r>>2]+e[r<<4&63]+"==")):2===i&&(r=(t[n-2]<<8)+t[n-1],o.push(e[r>>10]+e[r>>4&63]+e[r<<2&63]+"="));return o.join("")};for(var e=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,s=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=r),[n,n===r?0:4-n%4]}function f(t,r,n){for(var i,o,a=[],u=r;u>18&63]+e[o>>12&63]+e[o>>6&63]+e[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],39:[function(t,r,n){(function(r){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=t("base64-js"),o=t("ieee754");n.Buffer=r,n.SlowBuffer=function(t){+t!=t&&(t=0);return r.alloc(+t)},n.INSPECT_MAX_BYTES=50;var a=2147483647;function u(t){if(t>a)throw new RangeError('The value "'+t+'" is invalid for option "size"');var n=new Uint8Array(t);return n.__proto__=r.prototype,n}function r(t,r,n){if("number"==typeof t){if("string"==typeof r)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return s(t,r,n)}function s(t,n,i){if("string"==typeof t)return function(t,n){"string"==typeof n&&""!==n||(n="utf8");if(!r.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var e=0|m(t,n),i=u(e),o=i.write(t,n);o!==e&&(i=i.slice(0,o));return i}(t,n);if(ArrayBuffer.isView(t))return l(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+e(t));if(U(t,ArrayBuffer)||t&&U(t.buffer,ArrayBuffer))return function(t,n,e){if(n<0||t.byteLength=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function m(t,n){if(r.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||U(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+e(t));var i=t.length,o=arguments.length>2&&!0===arguments[2];if(!o&&0===i)return 0;for(var a=!1;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return P(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*i;case"hex":return i>>>1;case"base64":return F(t).length;default:if(a)return o?-1:P(t).length;n=(""+n).toLowerCase(),a=!0}}function h(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function y(t,n,e,i,o){if(0===t.length)return-1;if("string"==typeof e?(i=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),R(e=+e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof n&&(n=r.from(n,i)),r.isBuffer(n))return 0===n.length?-1:g(t,n,e,i,o);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,n,e):Uint8Array.prototype.lastIndexOf.call(t,n,e):g(t,[n],e,i,o);throw new TypeError("val must be string, number or Buffer")}function g(t,r,n,e,i){var o,a=1,u=t.length,s=r.length;if(void 0!==e&&("ucs2"===(e=String(e).toLowerCase())||"ucs-2"===e||"utf16le"===e||"utf-16le"===e)){if(t.length<2||r.length<2)return-1;a=2,u/=2,s/=2,n/=2}function c(t,r){return 1===a?t[r]:t.readUInt16BE(r*a)}if(i){var f=-1;for(o=n;ou&&(n=u-s),o=n;o>=0;o--){for(var l=!0,p=0;pi&&(e=i):e=i;var o=r.length;e>o/2&&(e=o/2);for(var a=0;a>8,i=n%256,o.push(i),o.push(e);return o}(r,t.length-n),t,n,e)}function A(t,r,n){return 0===r&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(r,n))}function _(t,r,n){n=Math.min(t.length,n);for(var e=[],i=r;i239?4:c>223?3:c>191?2:1;if(i+l<=n)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(s=(15&c)<<12|(63&o)<<6|63&a)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],a=t[i+2],u=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&u)&&(s=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&u)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,e.push(f>>>10&1023|55296),f=56320|1023&f),e.push(f),i+=l}return function(t){var r=t.length;if(r<=N)return String.fromCharCode.apply(String,t);var n="",e=0;for(;ethis.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return j(this,r,n);case"utf8":case"utf-8":return _(this,r,n);case"ascii":return E(this,r,n);case"latin1":case"binary":return S(this,r,n);case"base64":return A(this,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,r,n);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}.apply(this,arguments)},r.prototype.toLocaleString=r.prototype.toString,r.prototype.equals=function(t){if(!r.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===r.compare(this,t)},r.prototype.inspect=function(){var t="",r=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),""},r.prototype.compare=function(t,n,i,o,a){if(U(t,Uint8Array)&&(t=r.from(t,t.offset,t.byteLength)),!r.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+e(t));if(void 0===n&&(n=0),void 0===i&&(i=t?t.length:0),void 0===o&&(o=0),void 0===a&&(a=this.length),n<0||i>t.length||o<0||a>this.length)throw new RangeError("out of range index");if(o>=a&&n>=i)return 0;if(o>=a)return-1;if(n>=i)return 1;if(this===t)return 0;for(var u=(a>>>=0)-(o>>>=0),s=(i>>>=0)-(n>>>=0),c=Math.min(u,s),f=this.slice(o,a),l=t.slice(n,i),p=0;p>>=0,isFinite(n)?(n>>>=0,void 0===e&&(e="utf8")):(e=n,n=void 0)}var i=this.length-r;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");e||(e="utf8");for(var o=!1;;)switch(e){case"hex":return d(this,t,r,n);case"utf8":case"utf-8":return v(this,t,r,n);case"ascii":return x(this,t,r,n);case"latin1":case"binary":return b(this,t,r,n);case"base64":return w(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,r,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),o=!0}},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var N=4096;function E(t,r,n){var e="";n=Math.min(t.length,n);for(var i=r;ie)&&(n=e);for(var i="",o=r;on)throw new RangeError("Trying to access beyond buffer length")}function z(t,n,e,i,o,a){if(!r.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>o||nt.length)throw new RangeError("Index out of range")}function C(t,r,n,e,i,o){if(n+e>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function O(t,r,n,e,i){return r=+r,n>>>=0,i||C(t,0,n,4),o.write(t,r,n,e,23,4),n+4}function k(t,r,n,e,i){return r=+r,n>>>=0,i||C(t,0,n,8),o.write(t,r,n,e,52,8),n+8}r.prototype.slice=function(t,n){var e=this.length;(t=~~t)<0?(t+=e)<0&&(t=0):t>e&&(t=e),(n=void 0===n?e:~~n)<0?(n+=e)<0&&(n=0):n>e&&(n=e),n>>=0,r>>>=0,n||T(t,r,this.length);for(var e=this[t],i=1,o=0;++o>>=0,r>>>=0,n||T(t,r,this.length);for(var e=this[t+--r],i=1;r>0&&(i*=256);)e+=this[t+--r]*i;return e},r.prototype.readUInt8=function(t,r){return t>>>=0,r||T(t,1,this.length),this[t]},r.prototype.readUInt16LE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]|this[t+1]<<8},r.prototype.readUInt16BE=function(t,r){return t>>>=0,r||T(t,2,this.length),this[t]<<8|this[t+1]},r.prototype.readUInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},r.prototype.readUInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},r.prototype.readIntLE=function(t,r,n){t>>>=0,r>>>=0,n||T(t,r,this.length);for(var e=this[t],i=1,o=0;++o=(i*=128)&&(e-=Math.pow(2,8*r)),e},r.prototype.readIntBE=function(t,r,n){t>>>=0,r>>>=0,n||T(t,r,this.length);for(var e=r,i=1,o=this[t+--e];e>0&&(i*=256);)o+=this[t+--e]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*r)),o},r.prototype.readInt8=function(t,r){return t>>>=0,r||T(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},r.prototype.readInt16LE=function(t,r){t>>>=0,r||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(t,r){t>>>=0,r||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},r.prototype.readInt32BE=function(t,r){return t>>>=0,r||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},r.prototype.readFloatLE=function(t,r){return t>>>=0,r||T(t,4,this.length),o.read(this,t,!0,23,4)},r.prototype.readFloatBE=function(t,r){return t>>>=0,r||T(t,4,this.length),o.read(this,t,!1,23,4)},r.prototype.readDoubleLE=function(t,r){return t>>>=0,r||T(t,8,this.length),o.read(this,t,!0,52,8)},r.prototype.readDoubleBE=function(t,r){return t>>>=0,r||T(t,8,this.length),o.read(this,t,!1,52,8)},r.prototype.writeUIntLE=function(t,r,n,e){(t=+t,r>>>=0,n>>>=0,e)||z(this,t,r,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[r]=255&t;++o>>=0,n>>>=0,e)||z(this,t,r,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[r+i]=255&t;--i>=0&&(o*=256);)this[r+i]=t/o&255;return r+n},r.prototype.writeUInt8=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,1,255,0),this[r]=255&t,r+1},r.prototype.writeUInt16LE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,2,65535,0),this[r]=255&t,this[r+1]=t>>>8,r+2},r.prototype.writeUInt16BE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=255&t,r+2},r.prototype.writeUInt32LE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t,r+4},r.prototype.writeUInt32BE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},r.prototype.writeIntLE=function(t,r,n,e){if(t=+t,r>>>=0,!e){var i=Math.pow(2,8*n-1);z(this,t,r,n,i-1,-i)}var o=0,a=1,u=0;for(this[r]=255&t;++o>0)-u&255;return r+n},r.prototype.writeIntBE=function(t,r,n,e){if(t=+t,r>>>=0,!e){var i=Math.pow(2,8*n-1);z(this,t,r,n,i-1,-i)}var o=n-1,a=1,u=0;for(this[r+o]=255&t;--o>=0&&(a*=256);)t<0&&0===u&&0!==this[r+o+1]&&(u=1),this[r+o]=(t/a>>0)-u&255;return r+n},r.prototype.writeInt8=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=255&t,r+1},r.prototype.writeInt16LE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,2,32767,-32768),this[r]=255&t,this[r+1]=t>>>8,r+2},r.prototype.writeInt16BE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=255&t,r+2},r.prototype.writeInt32LE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,4,2147483647,-2147483648),this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4},r.prototype.writeInt32BE=function(t,r,n){return t=+t,r>>>=0,n||z(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t,r+4},r.prototype.writeFloatLE=function(t,r,n){return O(this,t,r,!0,n)},r.prototype.writeFloatBE=function(t,r,n){return O(this,t,r,!1,n)},r.prototype.writeDoubleLE=function(t,r,n){return k(this,t,r,!0,n)},r.prototype.writeDoubleBE=function(t,r,n){return k(this,t,r,!1,n)},r.prototype.copy=function(t,n,e,i){if(!r.isBuffer(t))throw new TypeError("argument should be a Buffer");if(e||(e=0),i||0===i||(i=this.length),n>=t.length&&(n=t.length),n||(n=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-n=0;--a)t[a+n]=this[a+e];else Uint8Array.prototype.set.call(t,this.subarray(e,i),n);return o},r.prototype.fill=function(t,n,e,i){if("string"==typeof t){if("string"==typeof n?(i=n,n=0,e=this.length):"string"==typeof e&&(i=e,e=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!r.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var o=t.charCodeAt(0);("utf8"===i&&o<128||"latin1"===i)&&(t=o)}}else"number"==typeof t&&(t&=255);if(n<0||this.length>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(a=n;a55295&&n<57344){if(!i){if(n>56319){(r-=3)>-1&&o.push(239,191,189);continue}if(a+1===e){(r-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(r-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(r-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((r-=1)<0)break;o.push(n)}else if(n<2048){if((r-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((r-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function F(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(I,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function D(t,r,n,e){for(var i=0;i=r.length||i>=t.length);++i)r[i+n]=t[i];return i}function U(t,r){return t instanceof r||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===r.name}function R(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":38,buffer:39,ieee754:47}],40:[function(t,r,n){(function(t){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var e=function(){function r(e,o,a,u){"object"===n(o)&&(a=o.depth,u=o.prototype,o.filter,o=o.circular);var s=[],c=[],f=void 0!==t;return void 0===o&&(o=!0),void 0===a&&(a=1/0),function e(a,l){if(null===a)return null;if(0==l)return a;var p,m;if("object"!=n(a))return a;if(r.__isArray(a))p=[];else if(r.__isRegExp(a))p=new RegExp(a.source,i(a)),a.lastIndex&&(p.lastIndex=a.lastIndex);else if(r.__isDate(a))p=new Date(a.getTime());else{if(f&&t.isBuffer(a))return p=t.allocUnsafe?t.allocUnsafe(a.length):new t(a.length),a.copy(p),p;void 0===u?(m=Object.getPrototypeOf(a),p=Object.create(m)):(p=Object.create(u),m=u)}if(o){var h=s.indexOf(a);if(-1!=h)return c[h];s.push(a),c.push(p)}for(var y in a){var g;m&&(g=Object.getOwnPropertyDescriptor(m,y)),g&&null==g.set||(p[y]=e(a[y],l-1))}return p}(e,a)}function e(t){return Object.prototype.toString.call(t)}function i(t){var r="";return t.global&&(r+="g"),t.ignoreCase&&(r+="i"),t.multiline&&(r+="m"),r}return r.clonePrototype=function(t){if(null===t)return null;var r=function(){};return r.prototype=t,new r},r.__objToStr=e,r.__isDate=function(t){return"object"===n(t)&&"[object Date]"===e(t)},r.__isArray=function(t){return"object"===n(t)&&"[object Array]"===e(t)},r.__isRegExp=function(t){return"object"===n(t)&&"[object RegExp]"===e(t)},r.__getRegExpFlags=i,r}();"object"===(void 0===r?"undefined":n(r))&&r.exports&&(r.exports=e)}).call(this,t("buffer").Buffer)},{buffer:39}],41:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t){var i={re:0,im:0},o=function(t){return.5*(Math.exp(t)+Math.exp(-t))},a=function(t){return.5*(Math.exp(t)-Math.exp(-t))},u=function(){throw SyntaxError("Invalid Param")};function s(t,r){var n=Math.abs(t),e=Math.abs(r);return 0===t?Math.log(e):0===r?Math.log(n):n<3e3&&e<3e3?.5*Math.log(t*t+r*r):Math.log(t/Math.cos(Math.atan2(r,t)))}var c=function(t,r){if(null==t)i.re=i.im=0;else if(void 0!==r)i.re=t,i.im=r;else switch(e(t)){case"object":"im"in t&&"re"in t?(i.re=t.re,i.im=t.im):"abs"in t&&"arg"in t?(i.re=t.abs*Math.cos(t.arg),i.im=t.abs*Math.sin(t.arg)):"r"in t&&"phi"in t?(i.re=t.r*Math.cos(t.phi),i.im=t.r*Math.sin(t.phi)):2===t.length?(i.re=t[0],i.im=t[1]):u();break;case"string":i.im=i.re=0;var n=t.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),o=1,a=0;null===n&&u();for(var s=0;s0&&u();break;case"number":i.im=0,i.re=t;break;default:u()}isNaN(i.re)||isNaN(i.im)};function f(t,r){if(!(this instanceof f))return new f(t,r);c(t,r),this.re=i.re,this.im=i.im}f.prototype={re:0,im:0,sign:function(){var t=this.abs();return new f(this.re/t,this.im/t)},add:function(t,r){return c(t,r),new f(this.re+i.re,this.im+i.im)},sub:function(t,r){return c(t,r),new f(this.re-i.re,this.im-i.im)},mul:function(t,r){return c(t,r),0===i.im&&0===this.im?new f(this.re*i.re,0):new f(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)},div:function(t,r){c(t,r),t=this.re,r=this.im;var n,e,o=i.re,a=i.im;return 0===a?0===o?new f(0!==t?t/0:0,0!==r?r/0:0):new f(t/o,r/o):Math.abs(o)=0)return new f(Math.pow(t,i.re),0);if(0===t)switch((i.re%4+4)%4){case 0:return new f(Math.pow(r,i.re),0);case 1:return new f(0,Math.pow(r,i.re));case 2:return new f(-Math.pow(r,i.re),0);case 3:return new f(0,-Math.pow(r,i.re))}}var n=Math.atan2(r,t),e=s(t,r);return t=Math.exp(i.re*e-i.im*n),r=i.im*e+i.re*n,new f(t*Math.cos(r),t*Math.sin(r))},sqrt:function(){var t,r,n=this.re,e=this.im,i=this.abs();if(n>=0){if(0===e)return new f(Math.sqrt(n),0);t=.5*Math.sqrt(2*(i+n))}else t=Math.abs(e)/Math.sqrt(2*(i-n));return r=n<=0?.5*Math.sqrt(2*(i-n)):Math.abs(e)/Math.sqrt(2*(i+n)),new f(t,e<0?-r:r)},exp:function(){var t=Math.exp(this.re);return this.im,new f(t*Math.cos(this.im),t*Math.sin(this.im))},log:function(){var t=this.re,r=this.im;return new f(s(t,r),Math.atan2(r,t))},abs:function(){return t=this.re,r=this.im,n=Math.abs(t),e=Math.abs(r),n<3e3&&e<3e3?Math.sqrt(n*n+e*e):(n1&&0===r,e=1-t,i=1+t,o=e*e+r*r,a=0!==o?new f((i*e-r*r)/o,(r*e+i*r)/o):new f(-1!==t?t/0:0,0!==r?r/0:0),u=a.re;return a.re=s(a.re,a.im)/2,a.im=Math.atan2(a.im,u)/2,n&&(a.im=-a.im),a},acoth:function(){var t=this.re,r=this.im;if(0===t&&0===r)return new f(0,Math.PI/2);var n=t*t+r*r;return 0!==n?new f(t/n,-r/n).atanh():new f(0!==t?t/0:0,0!==r?-r/0:0).atanh()},acsch:function(){var t=this.re,r=this.im;if(0===r)return new f(0!==t?Math.log(t+Math.sqrt(t*t+1)):1/0,0);var n=t*t+r*r;return 0!==n?new f(t/n,-r/n).asinh():new f(0!==t?t/0:0,0!==r?-r/0:0).asinh()},asech:function(){var t=this.re,r=this.im;if(0===t&&0===r)return new f(1/0,0);var n=t*t+r*r;return 0!==n?new f(t/n,-r/n).acosh():new f(0!==t?t/0:0,0!==r?-r/0:0).acosh()},inverse:function(){var t=this.re,r=this.im,n=t*t+r*r;return new f(0!==t?t/n:0,0!==r?-r/n:0)},conjugate:function(){return new f(this.re,-this.im)},neg:function(){return new f(-this.re,-this.im)},ceil:function(t){return t=Math.pow(10,t||0),new f(Math.ceil(this.re*t)/t,Math.ceil(this.im*t)/t)},floor:function(t){return t=Math.pow(10,t||0),new f(Math.floor(this.re*t)/t,Math.floor(this.im*t)/t)},round:function(t){return t=Math.pow(10,t||0),new f(Math.round(this.re*t)/t,Math.round(this.im*t)/t)},equals:function(t,r){return c(t,r),Math.abs(i.re-this.re)<=f.EPSILON&&Math.abs(i.im-this.im)<=f.EPSILON},clone:function(){return new f(this.re,this.im)},toString:function(){var t=this.re,r=this.im,n="";return isNaN(t)||isNaN(r)?"NaN":(0!==t&&(n+=t),0!==r&&(0!==t?n+=r<0?" - ":" + ":r<0&&(n+="-"),1!==(r=Math.abs(r))&&(n+=r),n+="i"),n||"0")},toVector:function(){return[this.re,this.im]},valueOf:function(){return 0===this.im?this.re:null},isNaN:function(t){function r(){return t.apply(this,arguments)}return r.toString=function(){return t.toString()},r}(function(){return isNaN(this.re)||isNaN(this.im)}),isFinite:function(t){function r(){return t.apply(this,arguments)}return r.toString=function(){return t.toString()},r}(function(){return isFinite(this.re)&&isFinite(this.im)})},f.ZERO=new f(0,0),f.ONE=new f(1,0),f.I=new f(0,1),f.PI=new f(Math.PI,0),f.E=new f(Math.E,0),f.EPSILON=1e-16,"function"==typeof define&&define.amd?define([],function(){return f}):"object"===(void 0===n?"undefined":e(n))?r.exports=f:(void 0).Complex=f}()},{}],42:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t){var n,i,o,a,u=9e15,s=1e9,c="0123456789abcdef",f="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",l="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",p={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-u,maxE:u,crypto:!1},m=!0,h="[DecimalError] ",y=h+"Invalid argument: ",g=h+"Precision limit exceeded",d=h+"crypto unavailable",v=Math.floor,x=Math.pow,b=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,w=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,M=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,A=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,_=1e7,N=7,E=f.length-1,S=l.length-1,j={name:"[object Decimal]"};function B(t){var r,n,e,i=t.length-1,o="",a=t[0];if(i>0){for(o+=a,r=1;rn)throw Error(y+t)}function z(t,r,n,e){var i,o,a,u;for(o=t[0];o>=10;o/=10)--r;return--r<0?(r+=N,i=0):(i=Math.ceil((r+1)/N),r%=N),o=x(10,N-r),u=t[i]%o|0,null==e?r<3?(0==r?u=u/100|0:1==r&&(u=u/10|0),a=n<4&&99999==u||n>3&&49999==u||5e4==u||0==u):a=(n<4&&u+1==o||n>3&&u+1==o/2)&&(t[i+1]/o/100|0)==x(10,r-2)-1||(u==o/2||0==u)&&0==(t[i+1]/o/100|0):r<4?(0==r?u=u/1e3|0:1==r?u=u/100|0:2==r&&(u=u/10|0),a=(e||n<4)&&9999==u||!e&&n>3&&4999==u):a=((e||n<4)&&u+1==o||!e&&n>3&&u+1==o/2)&&(t[i+1]/o/1e3|0)==x(10,r-3)-1,a}function C(t,r,n){for(var e,i,o=[0],a=0,u=t.length;an-1&&(void 0===o[e+1]&&(o[e+1]=0),o[e+1]+=o[e]/n|0,o[e]%=n)}return o.reverse()}j.absoluteValue=j.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),k(t)},j.ceil=function(){return k(new this.constructor(this),this.e+1,2)},j.comparedTo=j.cmp=function(t){var r,n,e,i,o=this,a=o.d,u=(t=new o.constructor(t)).d,s=o.s,c=t.s;if(!a||!u)return s&&c?s!==c?s:a===u?0:!a^s<0?1:-1:NaN;if(!a[0]||!u[0])return a[0]?s:u[0]?-c:0;if(s!==c)return s;if(o.e!==t.e)return o.e>t.e^s<0?1:-1;for(r=0,n=(e=a.length)<(i=u.length)?e:i;ru[r]^s<0?1:-1;return e===i?0:e>i^s<0?1:-1},j.cosine=j.cos=function(){var t,r,n=this,e=n.constructor;return n.d?n.d[0]?(t=e.precision,r=e.rounding,e.precision=t+Math.max(n.e,n.sd())+N,e.rounding=1,n=function(t,r){var n,e,i=r.d.length;i<32?(n=Math.ceil(i/3),e=Math.pow(4,-n).toString()):(n=16,e="2.3283064365386962890625e-10");t.precision+=n,r=J(t,1,r.times(e),new t(1));for(var o=n;o--;){var a=r.times(r);r=a.times(a).minus(a).times(8).plus(1)}return t.precision-=n,r}(e,G(e,n)),e.precision=t,e.rounding=r,k(2==a||3==a?n.neg():n,t,r,!0)):new e(1):new e(NaN)},j.cubeRoot=j.cbrt=function(){var t,r,n,e,i,o,a,u,s,c,f=this,l=f.constructor;if(!f.isFinite()||f.isZero())return new l(f);for(m=!1,(o=f.s*Math.pow(f.s*f,1/3))&&Math.abs(o)!=1/0?e=new l(o.toString()):(n=B(f.d),(o=((t=f.e)-n.length+1)%3)&&(n+=1==o||-2==o?"0":"00"),o=Math.pow(n,1/3),t=v((t+1)/3)-(t%3==(t<0?-1:2)),(e=new l(n=o==1/0?"5e"+t:(n=o.toExponential()).slice(0,n.indexOf("e")+1)+t)).s=f.s),a=(t=l.precision)+3;;)if(c=(s=(u=e).times(u).times(u)).plus(f),e=O(c.plus(f).times(u),c.plus(s),a+2,1),B(u.d).slice(0,a)===(n=B(e.d)).slice(0,a)){if("9999"!=(n=n.slice(a-3,a+1))&&(i||"4999"!=n)){+n&&(+n.slice(1)||"5"!=n.charAt(0))||(k(e,t+1,1),r=!e.times(e).times(e).eq(f));break}if(!i&&(k(u,t+1,0),u.times(u).times(u).eq(f))){e=u;break}a+=4,i=1}return m=!0,k(e,t,l.rounding,r)},j.decimalPlaces=j.dp=function(){var t,r=this.d,n=NaN;if(r){if(n=((t=r.length-1)-v(this.e/N))*N,t=r[t])for(;t%10==0;t/=10)n--;n<0&&(n=0)}return n},j.dividedBy=j.div=function(t){return O(this,new this.constructor(t))},j.dividedToIntegerBy=j.divToInt=function(t){var r=this.constructor;return k(O(this,new r(t),0,1,1),r.precision,r.rounding)},j.equals=j.eq=function(t){return 0===this.cmp(t)},j.floor=function(){return k(new this.constructor(this),this.e+1,3)},j.greaterThan=j.gt=function(t){return this.cmp(t)>0},j.greaterThanOrEqualTo=j.gte=function(t){var r=this.cmp(t);return 1==r||0===r},j.hyperbolicCosine=j.cosh=function(){var t,r,n,e,i,o=this,a=o.constructor,u=new a(1);if(!o.isFinite())return new a(o.s?1/0:NaN);if(o.isZero())return u;n=a.precision,e=a.rounding,a.precision=n+Math.max(o.e,o.sd())+4,a.rounding=1,(i=o.d.length)<32?(t=Math.ceil(i/3),r=Math.pow(4,-t).toString()):(t=16,r="2.3283064365386962890625e-10"),o=J(a,1,o.times(r),new a(1),!0);for(var s,c=t,f=new a(8);c--;)s=o.times(o),o=u.minus(s.times(f.minus(s.times(f))));return k(o,a.precision=n,a.rounding=e,!0)},j.hyperbolicSine=j.sinh=function(){var t,r,n,e,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(r=o.precision,n=o.rounding,o.precision=r+Math.max(i.e,i.sd())+4,o.rounding=1,(e=i.d.length)<3)i=J(o,2,i,i,!0);else{t=(t=1.4*Math.sqrt(e))>16?16:0|t,i=J(o,2,i=i.times(Math.pow(5,-t)),i,!0);for(var a,u=new o(5),s=new o(16),c=new o(20);t--;)a=i.times(i),i=i.times(u.plus(a.times(s.times(a).plus(c))))}return o.precision=r,o.rounding=n,k(i,r,n,!0)},j.hyperbolicTangent=j.tanh=function(){var t,r,n=this,e=n.constructor;return n.isFinite()?n.isZero()?new e(n):(t=e.precision,r=e.rounding,e.precision=t+7,e.rounding=1,O(n.sinh(),n.cosh(),e.precision=t,e.rounding=r)):new e(n.s)},j.inverseCosine=j.acos=function(){var t,r=this,n=r.constructor,e=r.abs().cmp(1),i=n.precision,o=n.rounding;return-1!==e?0===e?r.isNeg()?F(n,i,o):new n(0):new n(NaN):r.isZero()?F(n,i+4,o).times(.5):(n.precision=i+6,n.rounding=1,r=r.asin(),t=F(n,i+4,o).times(.5),n.precision=i,n.rounding=o,t.minus(r))},j.inverseHyperbolicCosine=j.acosh=function(){var t,r,n=this,e=n.constructor;return n.lte(1)?new e(n.eq(1)?0:NaN):n.isFinite()?(t=e.precision,r=e.rounding,e.precision=t+Math.max(Math.abs(n.e),n.sd())+4,e.rounding=1,m=!1,n=n.times(n).minus(1).sqrt().plus(n),m=!0,e.precision=t,e.rounding=r,n.ln()):new e(n)},j.inverseHyperbolicSine=j.asinh=function(){var t,r,n=this,e=n.constructor;return!n.isFinite()||n.isZero()?new e(n):(t=e.precision,r=e.rounding,e.precision=t+2*Math.max(Math.abs(n.e),n.sd())+6,e.rounding=1,m=!1,n=n.times(n).plus(1).sqrt().plus(n),m=!0,e.precision=t,e.rounding=r,n.ln())},j.inverseHyperbolicTangent=j.atanh=function(){var t,r,n,e,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,r=o.rounding,e=i.sd(),Math.max(e,t)<2*-i.e-1?k(new o(i),t,r,!0):(o.precision=n=e-i.e,i=O(i.plus(1),new o(1).minus(i),n+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=r,i.times(.5))):new o(NaN)},j.inverseSine=j.asin=function(){var t,r,n,e,i=this,o=i.constructor;return i.isZero()?new o(i):(r=i.abs().cmp(1),n=o.precision,e=o.rounding,-1!==r?0===r?((t=F(o,n+4,e).times(.5)).s=i.s,t):new o(NaN):(o.precision=n+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=n,o.rounding=e,i.times(2)))},j.inverseTangent=j.atan=function(){var t,r,n,e,i,o,a,u,s,c=this,f=c.constructor,l=f.precision,p=f.rounding;if(c.isFinite()){if(c.isZero())return new f(c);if(c.abs().eq(1)&&l+4<=S)return(a=F(f,l+4,p).times(.25)).s=c.s,a}else{if(!c.s)return new f(NaN);if(l+4<=S)return(a=F(f,l+4,p).times(.5)).s=c.s,a}for(f.precision=u=l+10,f.rounding=1,t=n=Math.min(28,u/N+2|0);t;--t)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(m=!1,r=Math.ceil(u/N),e=1,s=c.times(c),a=new f(c),i=c;-1!==t;)if(i=i.times(s),o=a.minus(i.div(e+=2)),i=i.times(s),void 0!==(a=o.plus(i.div(e+=2))).d[r])for(t=r;a.d[t]===o.d[t]&&t--;);return n&&(a=a.times(2<this.d.length-2},j.isNaN=function(){return!this.s},j.isNegative=j.isNeg=function(){return this.s<0},j.isPositive=j.isPos=function(){return this.s>0},j.isZero=function(){return!!this.d&&0===this.d[0]},j.lessThan=j.lt=function(t){return this.cmp(t)<0},j.lessThanOrEqualTo=j.lte=function(t){return this.cmp(t)<1},j.logarithm=j.log=function(t){var r,n,e,i,o,a,u,s,c=this.constructor,f=c.precision,l=c.rounding;if(null==t)t=new c(10),r=!0;else{if(n=(t=new c(t)).d,t.s<0||!n||!n[0]||t.eq(1))return new c(NaN);r=t.eq(10)}if(n=this.d,this.s<0||!n||!n[0]||this.eq(1))return new c(n&&!n[0]?-1/0:1!=this.s?NaN:n?0:1/0);if(r)if(n.length>1)o=!0;else{for(i=n[0];i%10==0;)i/=10;o=1!==i}if(m=!1,a=Z(this,u=f+5),e=r?P(c,u+10):Z(t,u),z((s=O(a,e,u,1)).d,i=f,l))do{if(a=Z(this,u+=10),e=r?P(c,u+10):Z(t,u),s=O(a,e,u,1),!o){+B(s.d).slice(i+1,i+15)+1==1e14&&(s=k(s,f+1,0));break}}while(z(s.d,i+=10,l));return m=!0,k(s,f,l)},j.minus=j.sub=function(t){var r,n,e,i,o,a,u,s,c,f,l,p,h=this,y=h.constructor;if(t=new y(t),!h.d||!t.d)return h.s&&t.s?h.d?t.s=-t.s:t=new y(t.d||h.s!==t.s?h:NaN):t=new y(NaN),t;if(h.s!=t.s)return t.s=-t.s,h.plus(t);if(c=h.d,p=t.d,u=y.precision,s=y.rounding,!c[0]||!p[0]){if(p[0])t.s=-t.s;else{if(!c[0])return new y(3===s?-0:0);t=new y(h)}return m?k(t,u,s):t}if(n=v(t.e/N),f=v(h.e/N),c=c.slice(),o=f-n){for((l=o<0)?(r=c,o=-o,a=p.length):(r=p,n=f,a=c.length),o>(e=Math.max(Math.ceil(u/N),a)+2)&&(o=e,r.length=1),r.reverse(),e=o;e--;)r.push(0);r.reverse()}else{for((l=(e=c.length)<(a=p.length))&&(a=e),e=0;e0;--e)c[a++]=0;for(e=p.length;e>o;){if(c[--e](a=(o=Math.ceil(u/N))>a?o+1:a+1)&&(i=a,n.length=1),n.reverse();i--;)n.push(0);n.reverse()}for((a=c.length)-(i=f.length)<0&&(i=a,n=f,f=c,c=n),r=0;i;)r=(c[--i]=c[i]+f[i]+r)/_|0,c[i]%=_;for(r&&(c.unshift(r),++e),a=c.length;0==c[--a];)c.pop();return t.d=c,t.e=q(c,e),m?k(t,u,s):t},j.precision=j.sd=function(t){var r,n=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(y+t);return n.d?(r=D(n.d),t&&n.e+1>r&&(r=n.e+1)):r=NaN,r},j.round=function(){var t=this,r=t.constructor;return k(new r(t),t.e+1,r.rounding)},j.sine=j.sin=function(){var t,r,n=this,e=n.constructor;return n.isFinite()?n.isZero()?new e(n):(t=e.precision,r=e.rounding,e.precision=t+Math.max(n.e,n.sd())+N,e.rounding=1,n=function(t,r){var n,e=r.d.length;if(e<3)return J(t,2,r,r);n=(n=1.4*Math.sqrt(e))>16?16:0|n,r=r.times(Math.pow(5,-n)),r=J(t,2,r,r);for(var i,o=new t(5),a=new t(16),u=new t(20);n--;)i=r.times(r),r=r.times(o.plus(i.times(a.times(i).minus(u))));return r}(e,G(e,n)),e.precision=t,e.rounding=r,k(a>2?n.neg():n,t,r,!0)):new e(NaN)},j.squareRoot=j.sqrt=function(){var t,r,n,e,i,o,a=this,u=a.d,s=a.e,c=a.s,f=a.constructor;if(1!==c||!u||!u[0])return new f(!c||c<0&&(!u||u[0])?NaN:u?a:1/0);for(m=!1,0==(c=Math.sqrt(+a))||c==1/0?(((r=B(u)).length+s)%2==0&&(r+="0"),c=Math.sqrt(r),s=v((s+1)/2)-(s<0||s%2),e=new f(r=c==1/0?"1e"+s:(r=c.toExponential()).slice(0,r.indexOf("e")+1)+s)):e=new f(c.toString()),n=(s=f.precision)+3;;)if(e=(o=e).plus(O(a,o,n+2,1)).times(.5),B(o.d).slice(0,n)===(r=B(e.d)).slice(0,n)){if("9999"!=(r=r.slice(n-3,n+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(k(e,s+1,1),t=!e.times(e).eq(a));break}if(!i&&(k(o,s+1,0),o.times(o).eq(a))){e=o;break}n+=4,i=1}return m=!0,k(e,s,f.rounding,t)},j.tangent=j.tan=function(){var t,r,n=this,e=n.constructor;return n.isFinite()?n.isZero()?new e(n):(t=e.precision,r=e.rounding,e.precision=t+10,e.rounding=1,(n=n.sin()).s=1,n=O(n,new e(1).minus(n.times(n)).sqrt(),t+10,0),e.precision=t,e.rounding=r,k(2==a||4==a?n.neg():n,t,r,!0)):new e(NaN)},j.times=j.mul=function(t){var r,n,e,i,o,a,u,s,c,f=this,l=f.constructor,p=f.d,h=(t=new l(t)).d;if(t.s*=f.s,!(p&&p[0]&&h&&h[0]))return new l(!t.s||p&&!p[0]&&!h||h&&!h[0]&&!p?NaN:p&&h?0*t.s:t.s/0);for(n=v(f.e/N)+v(t.e/N),(s=p.length)<(c=h.length)&&(o=p,p=h,h=o,a=s,s=c,c=a),o=[],e=a=s+c;e--;)o.push(0);for(e=c;--e>=0;){for(r=0,i=s+e;i>e;)u=o[i]+h[e]*p[i-e-1]+r,o[i--]=u%_|0,r=u/_|0;o[i]=(o[i]+r)%_|0}for(;!o[--a];)o.pop();return r?++n:o.shift(),t.d=o,t.e=q(o,n),m?k(t,l.precision,l.rounding):t},j.toBinary=function(t,r){return W(this,2,t,r)},j.toDecimalPlaces=j.toDP=function(t,r){var n=this,e=n.constructor;return n=new e(n),void 0===t?n:(T(t,0,s),void 0===r?r=e.rounding:T(r,0,8),k(n,t+n.e+1,r))},j.toExponential=function(t,r){var n,e=this,i=e.constructor;return void 0===t?n=I(e,!0):(T(t,0,s),void 0===r?r=i.rounding:T(r,0,8),n=I(e=k(new i(e),t+1,r),!0,t+1)),e.isNeg()&&!e.isZero()?"-"+n:n},j.toFixed=function(t,r){var n,e,i=this,o=i.constructor;return void 0===t?n=I(i):(T(t,0,s),void 0===r?r=o.rounding:T(r,0,8),n=I(e=k(new o(i),t+i.e+1,r),!1,t+e.e+1)),i.isNeg()&&!i.isZero()?"-"+n:n},j.toFraction=function(t){var r,n,e,i,o,a,u,s,c,f,l,p,h=this,g=h.d,d=h.constructor;if(!g)return new d(h);if(c=n=new d(1),e=s=new d(0),a=(o=(r=new d(e)).e=D(g)-h.e-1)%N,r.d[0]=x(10,a<0?N+a:a),null==t)t=o>0?r:c;else{if(!(u=new d(t)).isInt()||u.lt(c))throw Error(y+u);t=u.gt(r)?o>0?r:c:u}for(m=!1,u=new d(B(g)),f=d.precision,d.precision=o=g.length*N*2;l=O(u,r,0,1,1),1!=(i=n.plus(l.times(e))).cmp(t);)n=e,e=i,i=c,c=s.plus(l.times(i)),s=i,i=r,r=u.minus(l.times(i)),u=i;return i=O(t.minus(n),e,0,1,1),s=s.plus(i.times(c)),n=n.plus(i.times(e)),s.s=c.s=h.s,p=O(c,e,o,1).minus(h).abs().cmp(O(s,n,o,1).minus(h).abs())<1?[c,e]:[s,n],d.precision=f,m=!0,p},j.toHexadecimal=j.toHex=function(t,r){return W(this,16,t,r)},j.toNearest=function(t,r){var n=this,e=n.constructor;if(n=new e(n),null==t){if(!n.d)return n;t=new e(1),r=e.rounding}else{if(t=new e(t),void 0!==r&&T(r,0,8),!n.d)return t.s?n:t;if(!t.d)return t.s&&(t.s=n.s),t}return t.d[0]?(m=!1,r<4&&(r=[4,5,7,8][r]),n=O(n,t,0,r,1).times(t),m=!0,k(n)):(t.s=n.s,n=t),n},j.toNumber=function(){return+this},j.toOctal=function(t,r){return W(this,8,t,r)},j.toPower=j.pow=function(t){var r,n,e,i,o,a,u=this,s=u.constructor,c=+(t=new s(t));if(!(u.d&&t.d&&u.d[0]&&t.d[0]))return new s(x(+u,c));if((u=new s(u)).eq(1))return u;if(e=s.precision,o=s.rounding,t.eq(1))return k(u,e,o);if((r=v(t.e/N))>=t.d.length-1&&(n=c<0?-c:c)<=9007199254740991)return i=R(s,u,n,e),t.s<0?new s(1).div(i):k(i,e,o);if((a=u.s)<0){if(rs.maxE+1||r0?a/0:0):(m=!1,s.rounding=u.s=1,n=Math.min(12,(r+"").length),(i=V(t.times(Z(u,e+n)),e)).d&&z((i=k(i,e+5,1)).d,e,o)&&(r=e+10,+B((i=k(V(t.times(Z(u,r+n)),r),r+5,1)).d).slice(e+1,e+15)+1==1e14&&(i=k(i,e+1,0))),i.s=a,m=!0,s.rounding=o,k(i,e,o))},j.toPrecision=function(t,r){var n,e=this,i=e.constructor;return void 0===t?n=I(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(T(t,1,s),void 0===r?r=i.rounding:T(r,0,8),n=I(e=k(new i(e),t,r),t<=e.e||e.e<=i.toExpNeg,t)),e.isNeg()&&!e.isZero()?"-"+n:n},j.toSignificantDigits=j.toSD=function(t,r){var n=this.constructor;return void 0===t?(t=n.precision,r=n.rounding):(T(t,1,s),void 0===r?r=n.rounding:T(r,0,8)),k(new n(this),t,r)},j.toString=function(){var t=this,r=t.constructor,n=I(t,t.e<=r.toExpNeg||t.e>=r.toExpPos);return t.isNeg()&&!t.isZero()?"-"+n:n},j.truncated=j.trunc=function(){return k(new this.constructor(this),this.e+1,1)},j.valueOf=j.toJSON=function(){var t=this,r=t.constructor,n=I(t,t.e<=r.toExpNeg||t.e>=r.toExpPos);return t.isNeg()?"-"+n:n};var O=function(){function t(t,r,n){var e,i=0,o=t.length;for(t=t.slice();o--;)e=t[o]*r+i,t[o]=e%n|0,i=e/n|0;return i&&t.unshift(i),t}function r(t,r,n,e){var i,o;if(n!=e)o=n>e?1:-1;else for(i=o=0;ir[i]?1:-1;break}return o}function n(t,r,n,e){for(var i=0;n--;)t[n]-=i,i=t[n]1;)t.shift()}return function(e,o,a,u,s,c){var f,l,p,m,h,y,g,d,x,b,w,M,A,E,S,j,B,T,z,C,O=e.constructor,I=e.s==o.s?1:-1,q=e.d,P=o.d;if(!(q&&q[0]&&P&&P[0]))return new O(e.s&&o.s&&(q?!P||q[0]!=P[0]:P)?q&&0==q[0]||!P?0*I:I/0:NaN);for(c?(h=1,l=e.e-o.e):(c=_,h=N,l=v(e.e/h)-v(o.e/h)),z=P.length,B=q.length,b=(x=new O(I)).d=[],p=0;P[p]==(q[p]||0);p++);if(P[p]>(q[p]||0)&&l--,null==a?(E=a=O.precision,u=O.rounding):E=s?a+(e.e-o.e)+1:a,E<0)b.push(1),y=!0;else{if(E=E/h+2|0,p=0,1==z){for(m=0,P=P[0],E++;(p1&&(P=t(P,m,c),q=t(q,m,c),z=P.length,B=q.length),j=z,M=(w=q.slice(0,z)).length;M=c/2&&++T;do{m=0,(f=r(P,w,z,M))<0?(A=w[0],z!=M&&(A=A*c+(w[1]||0)),(m=A/T|0)>1?(m>=c&&(m=c-1),1==(f=r(g=t(P,m,c),w,d=g.length,M=w.length))&&(m--,n(g,z=10;m/=10)p++;x.e=p+l*h-1,k(x,s?a+x.e+1:a,u,y)}return x}}();function k(t,r,n,e){var i,o,a,u,s,c,f,l,p,h=t.constructor;t:if(null!=r){if(!(l=t.d))return t;for(i=1,u=l[0];u>=10;u/=10)i++;if((o=r-i)<0)o+=N,a=r,s=(f=l[p=0])/x(10,i-a-1)%10|0;else if((p=Math.ceil((o+1)/N))>=(u=l.length)){if(!e)break t;for(;u++<=p;)l.push(0);f=s=0,i=1,a=(o%=N)-N+1}else{for(f=u=l[p],i=1;u>=10;u/=10)i++;s=(a=(o%=N)-N+i)<0?0:f/x(10,i-a-1)%10|0}if(e=e||r<0||void 0!==l[p+1]||(a<0?f:f%x(10,i-a-1)),c=n<4?(s||e)&&(0==n||n==(t.s<0?3:2)):s>5||5==s&&(4==n||e||6==n&&(o>0?a>0?f/x(10,i-a):0:l[p-1])%10&1||n==(t.s<0?8:7)),r<1||!l[0])return l.length=0,c?(r-=t.e+1,l[0]=x(10,(N-r%N)%N),t.e=-r||0):l[0]=t.e=0,t;if(0==o?(l.length=p,u=1,p--):(l.length=p+1,u=x(10,N-o),l[p]=a>0?(f/x(10,i-a)%x(10,a)|0)*u:0),c)for(;;){if(0==p){for(o=1,a=l[0];a>=10;a/=10)o++;for(a=l[0]+=u,u=1;a>=10;a/=10)u++;o!=u&&(t.e++,l[0]==_&&(l[0]=1));break}if(l[p]+=u,l[p]!=_)break;l[p--]=0,u=1}for(o=l.length;0===l[--o];)l.pop()}return m&&(t.e>h.maxE?(t.d=null,t.e=NaN):t.e0?o=o.charAt(0)+"."+o.slice(1)+U(e):a>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+U(-i-1)+o,n&&(e=n-a)>0&&(o+=U(e))):i>=a?(o+=U(i+1-a),n&&(e=n-i-1)>0&&(o=o+"."+U(e))):((e=i+1)0&&(i+1===a&&(o+="."),o+=U(e))),o}function q(t,r){var n=t[0];for(r*=N;n>=10;n/=10)r++;return r}function P(t,r,n){if(r>E)throw m=!0,n&&(t.precision=n),Error(g);return k(new t(f),r,1,!0)}function F(t,r,n){if(r>S)throw Error(g);return k(new t(l),r,n,!0)}function D(t){var r=t.length-1,n=r*N+1;if(r=t[r]){for(;r%10==0;r/=10)n--;for(r=t[0];r>=10;r/=10)n++}return n}function U(t){for(var r="";t--;)r+="0";return r}function R(t,r,n,e){var i,o=new t(1),a=Math.ceil(e/N+4);for(m=!1;;){if(n%2&&Q((o=o.times(r)).d,a)&&(i=!0),0===(n=v(n/2))){n=o.d.length-1,i&&0===o.d[n]&&++o.d[n];break}Q((r=r.times(r)).d,a)}return m=!0,o}function L(t){return 1&t.d[t.d.length-1]}function $(t,r,n){for(var e,i=new t(r[0]),o=0;++o17)return new p(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==r?(m=!1,s=y):s=r,u=new p(.03125);t.e>-2;)t=t.times(u),l+=5;for(s+=e=Math.log(x(2,l))/Math.LN10*2+5|0,n=o=a=new p(1),p.precision=s;;){if(o=k(o.times(t),s,1),n=n.times(++f),B((u=a.plus(O(o,n,s,1))).d).slice(0,s)===B(a.d).slice(0,s)){for(i=l;i--;)a=k(a.times(a),s,1);if(null!=r)return p.precision=y,a;if(!(c<3&&z(a.d,s-e,h,c)))return k(a,p.precision=y,h,m=!0);p.precision=s+=10,n=o=u=new p(1),f=0,c++}a=u}}function Z(t,r){var n,e,i,o,a,u,s,c,f,l,p,h=1,y=t,g=y.d,d=y.constructor,v=d.rounding,x=d.precision;if(y.s<0||!g||!g[0]||!y.e&&1==g[0]&&1==g.length)return new d(g&&!g[0]?-1/0:1!=y.s?NaN:g?0:y);if(null==r?(m=!1,f=x):f=r,d.precision=f+=10,e=(n=B(g)).charAt(0),!(Math.abs(o=y.e)<15e14))return c=P(d,f+2,x).times(o+""),y=Z(new d(e+"."+n.slice(1)),f-10).plus(c),d.precision=x,null==r?k(y,x,v,m=!0):y;for(;e<7&&1!=e||1==e&&n.charAt(1)>3;)e=(n=B((y=y.times(t)).d)).charAt(0),h++;for(o=y.e,e>1?(y=new d("0."+n),o++):y=new d(e+"."+n.slice(1)),l=y,s=a=y=O(y.minus(1),y.plus(1),f,1),p=k(y.times(y),f,1),i=3;;){if(a=k(a.times(p),f,1),B((c=s.plus(O(a,new d(i),f,1))).d).slice(0,f)===B(s.d).slice(0,f)){if(s=s.times(2),0!==o&&(s=s.plus(P(d,f+2,x).times(o+""))),s=O(s,new d(h),f,1),null!=r)return d.precision=x,s;if(!z(s.d,f-10,v,u))return k(s,d.precision=x,v,m=!0);d.precision=f+=10,c=a=y=O(l.minus(1),l.plus(1),f,1),p=k(y.times(y),f,1),i=u=1}s=c,i+=2}}function H(t){return String(t.s*t.s/0)}function X(t,r){var n,e,i;for((n=r.indexOf("."))>-1&&(r=r.replace(".","")),(e=r.search(/e/i))>0?(n<0&&(n=e),n+=+r.slice(e+1),r=r.substring(0,e)):n<0&&(n=r.length),e=0;48===r.charCodeAt(e);e++);for(i=r.length;48===r.charCodeAt(i-1);--i);if(r=r.slice(e,i)){if(i-=e,t.e=n=n-e-1,t.d=[],e=(n+1)%N,n<0&&(e+=N),et.constructor.maxE?(t.d=null,t.e=NaN):t.e0?(c=+r.slice(a+1),r=r.substring(2,a)):r=r.slice(2),u=(a=r.indexOf("."))>=0,i=t.constructor,u&&(a=(s=(r=r.replace(".","")).length)-a,o=R(i,new i(e),a,2*a)),a=l=(f=C(r,e,_)).length-1;0===f[a];--a)f.pop();return a<0?new i(0*t.s):(t.e=q(f,l),t.d=f,m=!1,u&&(t=O(t,o,4*s)),c&&(t=t.times(Math.abs(c)<54?Math.pow(2,c):n.pow(2,c))),m=!0,t)}function J(t,r,n,e,i){var o,a,u,s,c=t.precision,f=Math.ceil(c/N);for(m=!1,s=n.times(n),u=new t(e);;){if(a=O(u.times(s),new t(r++*r++),c,1),u=i?e.plus(a):e.minus(a),e=O(a.times(s),new t(r++*r++),c,1),void 0!==(a=u.plus(e)).d[f]){for(o=f;a.d[o]===u.d[o]&&o--;);if(-1==o)break}o=u,u=e,e=a,a=o,0}return m=!0,a.d.length=f+1,a}function G(t,r){var n,e=r.s<0,i=F(t,t.precision,1),o=i.times(.5);if((r=r.abs()).lte(o))return a=e?4:1,r;if((n=r.divToInt(i)).isZero())a=e?3:2;else{if((r=r.minus(n.times(i))).lte(o))return a=L(n)?e?2:3:e?4:1,r;a=L(n)?e?1:4:e?3:2}return r.minus(i).abs()}function W(t,r,n,e){var o,a,u,f,l,p,m,h,y,g=t.constructor,d=void 0!==n;if(d?(T(n,1,s),void 0===e?e=g.rounding:T(e,0,8)):(n=g.precision,e=g.rounding),t.isFinite()){for(d?(o=2,16==r?n=4*n-3:8==r&&(n=3*n-2)):o=r,(u=(m=I(t)).indexOf("."))>=0&&(m=m.replace(".",""),(y=new g(1)).e=m.length-u,y.d=C(I(y),10,o),y.e=y.d.length),a=l=(h=C(m,10,o)).length;0==h[--l];)h.pop();if(h[0]){if(u<0?a--:((t=new g(t)).d=h,t.e=a,h=(t=O(t,y,n,e,0,o)).d,a=t.e,p=i),u=h[n],f=o/2,p=p||void 0!==h[n+1],p=e<4?(void 0!==u||p)&&(0===e||e===(t.s<0?3:2)):u>f||u===f&&(4===e||p||6===e&&1&h[n-1]||e===(t.s<0?8:7)),h.length=n,p)for(;++h[--n]>o-1;)h[n]=0,n||(++a,h.unshift(1));for(l=h.length;!h[l-1];--l);for(u=0,m="";u1)if(16==r||8==r){for(u=16==r?4:3,--l;l%u;l++)m+="0";for(l=(h=C(m,o,r)).length;!h[l-1];--l);for(u=1,m="1.";ul)for(a-=l;a--;)m+="0";else ar)return t.length=r,!0}function K(t){return new this(t).abs()}function tt(t){return new this(t).acos()}function rt(t){return new this(t).acosh()}function nt(t,r){return new this(t).plus(r)}function et(t){return new this(t).asin()}function it(t){return new this(t).asinh()}function ot(t){return new this(t).atan()}function at(t){return new this(t).atanh()}function ut(t,r){t=new this(t),r=new this(r);var n,e=this.precision,i=this.rounding,o=e+4;return t.s&&r.s?t.d||r.d?!r.d||t.isZero()?(n=r.s<0?F(this,e,i):new this(0)).s=t.s:!t.d||r.isZero()?(n=F(this,o,1).times(.5)).s=t.s:r.s<0?(this.precision=o,this.rounding=1,n=this.atan(O(t,r,o,1)),r=F(this,o,1),this.precision=e,this.rounding=i,n=t.s<0?n.minus(r):n.plus(r)):n=this.atan(O(t,r,o,1)):(n=F(this,o,1).times(r.s>0?.25:.75)).s=t.s:n=new this(NaN),n}function st(t){return new this(t).cbrt()}function ct(t){return k(t=new this(t),t.e+1,2)}function ft(t){if(!t||"object"!==e(t))throw Error(h+"Object expected");var r,n,i,o=!0===t.defaults,a=["precision",1,s,"rounding",0,8,"toExpNeg",-u,0,"toExpPos",0,u,"maxE",0,u,"minE",-u,0,"modulo",0,9];for(r=0;r=a[r+1]&&i<=a[r+2]))throw Error(y+n+": "+i);this[n]=i}if(n="crypto",o&&(this[n]=p[n]),void 0!==(i=t[n])){if(!0!==i&&!1!==i&&0!==i&&1!==i)throw Error(y+n+": "+i);if(i){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[n]=!0}else this[n]=!1}return this}function lt(t){return new this(t).cos()}function pt(t){return new this(t).cosh()}function mt(t,r){return new this(t).div(r)}function ht(t){return new this(t).exp()}function yt(t){return k(t=new this(t),t.e+1,3)}function gt(){var t,r,n=new this(0);for(m=!1,t=0;t=429e7?r[o]=crypto.getRandomValues(new Uint32Array(1))[0]:u[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(d);for(r=crypto.randomBytes(e*=4);o=214e7?crypto.randomBytes(4).copy(r,o):(u.push(i%1e7),o+=4);o=e/4}else for(;o=10;i/=10)e++;e=10;n/=10)r++;return o.e=r,void(o.d=[t])}return 0*t!=0?(t||(o.s=NaN),o.e=NaN,void(o.d=null)):X(o,t.toString())}if("string"!==i)throw Error(y+t);return 45===t.charCodeAt(0)?(t=t.slice(1),o.s=-1):o.s=1,A.test(t)?X(o,t):Y(o,t)}if(a.prototype=j,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=a.set=ft,a.clone=t,a.isDecimal=dt,a.abs=K,a.acos=tt,a.acosh=rt,a.add=nt,a.asin=et,a.asinh=it,a.atan=ot,a.atanh=at,a.atan2=ut,a.cbrt=st,a.ceil=ct,a.cos=lt,a.cosh=pt,a.div=mt,a.exp=ht,a.floor=yt,a.hypot=gt,a.ln=vt,a.log=xt,a.log10=wt,a.log2=bt,a.max=Mt,a.min=At,a.mod=_t,a.mul=Nt,a.pow=Et,a.random=St,a.round=jt,a.sign=Bt,a.sin=Tt,a.sinh=zt,a.sqrt=Ct,a.sub=Ot,a.tan=kt,a.tanh=It,a.trunc=qt,void 0===r&&(r={}),r&&!0!==r.defaults)for(o=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;ni?Array(n-i+1).join(t):"")+e}}r.exports=o,o.prototype.newRow=function(){return this.rows.push(this.row),this.row={__printers:{}},this},o.prototype.cell=function(t,r,n){return this.row[t]=r,this.row.__printers[t]=n||a,this},o.prototype.separator=" ",o.string=a,o.leftPadder=s;var c=o.padLeft=s(" ");function f(t){return function(r,n){var e=a(r),i=u(e);return e+(n>i?Array(n-i+1).join(t):"")}}o.rightPadder=f;var l=f(" ");function p(t,r){for(var n in t)"__printers"!=n&&r(n,t[n])}function m(t,r){return t===r?0:void 0===t?1:void 0===r?-1:null===t?1:null===r?-1:t>r?1:t1&&void 0!==arguments[1]?arguments[1]:{},n=r.preserveFormatting,u=void 0!==n&&n,s=r.escapeMapFn,c=void 0===s?a:s,f=String(t),l="",p=c(e({},i),u?e({},o):{}),m=Object.keys(p),h=function(){var t=!1;m.forEach(function(r,n){t||f.length>=r.length&&f.slice(0,r.length)===r&&(l+=p[m[n]],f=f.slice(r.length,f.length),t=!0)}),t||(l+=f.slice(0,1),f=f.slice(1,f.length))};f;)h();return l}},{}],46:[function(t,r,n){"use strict";function e(t){if(this.size=0|t,this.size<=1||0!=(this.size&this.size-1))throw new Error("FFT size must be a power of two and bigger than 1");this._csize=t<<1;for(var r=new Array(2*this.size),n=0;no;o<<=1)i++;this._width=i%2==0?i-1:i,this._bitrev=new Array(1<>>u&3)<>>1),e=0;e>>1]=t[e];return n},e.prototype.createComplexArray=function(){for(var t=new Array(this._csize),r=0;r>>1],n[e+1]=0;return n},e.prototype.completeSpectrum=function(t){for(var r=this._csize,n=r>>>1,e=2;e>=2;i>=2;i>>=2){var l=(o=e/i<<1)>>>2;for(t=0;t>>1,i>>>1)}else for(t=0,r=0;t>>1,i>>>1)}var c=this._inv?-1:1,f=this.table;for(i>>=2;i>=2;i>>=2){var l=(o=e/i<<1)>>>1,p=l>>>1,m=p>>>1;for(t=0;t>1,f=-7,l=n?i-1:0,p=n?-1:1,m=t[r+l];for(l+=p,o=m&(1<<-f)-1,m>>=-f,f+=u;f>0;o=256*o+t[r+l],l+=p,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=e;f>0;a=256*a+t[r+l],l+=p,f-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(m?-1:1);a+=Math.pow(2,e),o-=c}return(m?-1:1)*a*Math.pow(2,o-e)},n.write=function(t,r,n,e,i,o){var a,u,s,c=8*o-i-1,f=(1<>1,p=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,m=e?0:o-1,h=e?1:-1,y=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,a=f):(a=Math.floor(Math.log(r)/Math.LN2),r*(s=Math.pow(2,-a))<1&&(a--,s*=2),(r+=a+l>=1?p/s:p*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(r*s-1)*Math.pow(2,i),a+=l):(u=r*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+m]=255&u,m+=h,u/=256,i-=8);for(a=a<0;t[n+m]=255&a,m+=h,a/=256,c-=8);t[n+m-h]|=128*y}},{}],48:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}r.exports=function t(r,n){var i,o,a=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,u=/(^[ ]*|[ ]*$)/g,s=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,c=/^0x[0-9a-f]+$/i,f=/^0/,l=function(r){return t.insensitive&&(""+r).toLowerCase()||""+r},p=l(r).replace(u,"")||"",m=l(n).replace(u,"")||"",h=p.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),y=m.replace(a,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),g=parseInt(p.match(c),16)||1!==h.length&&p.match(s)&&Date.parse(p),d=parseInt(m.match(c),16)||g&&m.match(s)&&Date.parse(m)||null;if(d){if(gd)return 1}for(var v=0,x=Math.max(h.length,y.length);vo)return 1}return 0}},{}],49:[function(t,r,n){"use strict";r.exports=t("./lib/core/core")},{"./lib/core/core":50}],50:[function(t,r,n){"use strict";var e=t("./../utils/object").isFactory,i=t("./typed"),o=t("./../utils/emitter"),a=t("./function/import"),u=t("./function/config");n.create=function(t){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=[],n=[],s=o.mixin({});s.type={},s.expression={transform:{},mathWithTransform:{}},s.typed=i.create(s.type);var c={epsilon:1e-12,matrix:"Matrix",number:"number",precision:64,predictable:!1,randomSeed:null};function f(t){if(!e(t))throw new Error("Factory object with properties `type`, `name`, and `factory` expected");var i,o=r.indexOf(t);return-1===o?(i=!0===t.math?t.factory(s.type,c,f,s.typed,s):t.factory(s.type,c,f,s.typed),r.push(t),n.push(i)):i=n[o],i}return s.import=f(a),s.config=f(u),s.expression.mathWithTransform.config=s.config,t&&s.config(t),s}},{"./../utils/emitter":227,"./../utils/object":232,"./function/config":51,"./function/import":52,"./typed":53}],51:[function(t,r,n){"use strict";var e=t("../../utils/object");function i(t,r,n){if(void 0!==t[r]&&(i=n,o=t[r],-1===i.indexOf(o))){var e=function(t,r){return t.map(function(t){return t.toLowerCase()}).indexOf(r.toLowerCase())}(n,t[r]);-1!==e?(console.warn('Warning: Wrong casing for configuration option "'+r+'", should be "'+n[e]+'" instead of "'+t[r]+'".'),t[r]=n[e]):console.warn('Warning: Unknown value "'+t[r]+'" for configuration option "'+r+'". Available options: '+n.map(JSON.stringify).join(", ")+".")}var i,o}n.name="config",n.math=!0,n.factory=function(t,r,n,o,a){var u=["Matrix","Array"],s=["number","BigNumber","Fraction"];function c(t){if(t){var n=e.map(r,e.clone);i(t,"matrix",u),i(t,"number",s),e.deepExtend(r,t);var o=e.map(r,e.clone),c=e.map(t,e.clone);return a.emit("config",o,n,c),o}return e.map(r,e.clone)}return c.MATRIX=u,c.NUMBER=s,c}},{"../../utils/object":232}],52:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=t("../../utils/object").lazy,o=t("../../utils/object").isFactory,a=t("../../utils/object").traverse,u=t("../../error/ArgumentsError");n.math=!0,n.name="import",n.factory=function(t,r,n,s,c){function f(t,r,n){if(n.wrap&&"function"==typeof r&&(i=function(){for(var t=[],r=0,n=arguments.length;r15)throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+r+"). Use function bignumber(x) to convert to BigNumber.");return new t.BigNumber(r)}},{from:"number",to:"Complex",convert:function(r){return new t.Complex(r,0)}},{from:"number",to:"string",convert:function(t){return t+""}},{from:"BigNumber",to:"Complex",convert:function(r){return new t.Complex(r.toNumber(),0)}},{from:"Fraction",to:"BigNumber",convert:function(t){throw new TypeError("Cannot implicitly convert a Fraction to BigNumber or vice versa. Use function bignumber(x) to convert to BigNumber or fraction(x) to convert to Fraction.")}},{from:"Fraction",to:"Complex",convert:function(r){return new t.Complex(r.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(r){if(new t.Fraction(r).valueOf()!==r)throw new TypeError("Cannot implicitly convert a number to a Fraction when there will be a loss of precision (value: "+r+"). Use function fraction(x) to convert to Fraction.");return new t.Fraction(r)}},{from:"string",to:"number",convert:function(t){var r=Number(t);if(isNaN(r))throw new Error('Cannot convert "'+t+'" to a number');return r}},{from:"string",to:"BigNumber",convert:function(r){try{return new t.BigNumber(r)}catch(t){throw new Error('Cannot convert "'+r+'" to BigNumber')}}},{from:"string",to:"Fraction",convert:function(r){try{return new t.Fraction(r)}catch(t){throw new Error('Cannot convert "'+r+'" to Fraction')}}},{from:"string",to:"Complex",convert:function(r){try{return new t.Complex(r)}catch(t){throw new Error('Cannot convert "'+r+'" to Complex')}}},{from:"boolean",to:"number",convert:function(t){return+t}},{from:"boolean",to:"BigNumber",convert:function(r){return new t.BigNumber(+r)}},{from:"boolean",to:"Fraction",convert:function(r){return new t.Fraction(+r)}},{from:"boolean",to:"string",convert:function(t){return+t}},{from:"null",to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new t.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new t.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(r){return new t.DenseMatrix(r)}},{from:"Matrix",to:"Array",convert:function(t){return t.valueOf()}}],r}},{"./../utils/bignumber/isBigNumber":216,"./../utils/collection/isMatrix":223,"./../utils/number":231,"typed-function":483}],54:[function(t,r,n){"use strict";function e(t,r,n,i){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.fn=t,this.count=r,this.min=n,this.max=i,this.message="Wrong number of arguments in function "+t+" ("+r+" provided, "+n+(null!=i?"-"+i:"")+" expected)",this.stack=(new Error).stack}e.prototype=new Error,e.prototype.constructor=Error,e.prototype.name="ArgumentsError",e.prototype.isArgumentsError=!0,r.exports=e},{}],55:[function(t,r,n){"use strict";function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.actual=t,this.expected=r,this.relation=n,this.message="Dimension mismatch ("+(Array.isArray(t)?"["+t.join(", ")+"]":t)+" "+(this.relation||"!=")+" "+(Array.isArray(r)?"["+r.join(", ")+"]":r)+")",this.stack=(new Error).stack}e.prototype=new RangeError,e.prototype.constructor=RangeError,e.prototype.name="DimensionError",e.prototype.isDimensionError=!0,r.exports=e},{}],56:[function(t,r,n){"use strict";function e(t,r,n){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");this.index=t,arguments.length<3?(this.min=0,this.max=r):(this.min=r,this.max=n),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}e.prototype=new RangeError,e.prototype.constructor=RangeError,e.prototype.name="IndexError",e.prototype.isIndexError=!0,r.exports=e},{}],57:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="abs",n.factory=function(t,r,n,i){var o=i("abs",{number:Math.abs,Complex:function(t){return t.abs()},BigNumber:function(t){return t.abs()},Fraction:function(t){return t.abs()},"Array | Matrix":function(t){return e(t,o,!0)},Unit:function(t){return t.abs()}});return o.toTex={1:"\\left|${args[0]}\\right|"},o}},{"../../utils/collection/deepMap":221}],58:[function(t,r,n){"use strict";var e=t("../../utils/object").extend;n.name="add",n.factory=function(r,n,i,o){var a=i(t("../../type/matrix/function/matrix")),u=i(t("./addScalar")),s=t("../../utils/latex.js"),c=i(t("../../type/matrix/utils/algorithm01")),f=i(t("../../type/matrix/utils/algorithm04")),l=i(t("../../type/matrix/utils/algorithm10")),p=i(t("../../type/matrix/utils/algorithm13")),m=i(t("../../type/matrix/utils/algorithm14")),h=o("add",e({"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=f(t,r,u);break;default:n=c(r,t,u,!0)}break;default:switch(r.storage()){case"sparse":n=c(t,r,u,!1);break;default:n=p(t,r,u)}}return n},"Array, Array":function(t,r){return h(a(t),a(r)).valueOf()},"Array, Matrix":function(t,r){return h(a(t),r)},"Matrix, Array":function(t,r){return h(t,a(r))},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=l(t,r,u,!1);break;default:n=m(t,r,u,!1)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=l(r,t,u,!0);break;default:n=m(r,t,u,!0)}return n},"Array, any":function(t,r){return m(a(t),r,u,!1).valueOf()},"any, Array":function(t,r){return m(a(r),t,u,!0).valueOf()},"any, any":u,"Array | Matrix | any, Array | Matrix | any, ...any":function(t,r,n){for(var e=h(t,r),i=0;i0?Math.floor(t):Math.ceil(t)},Complex:function(r){return new t.Complex(r.re>0?Math.floor(r.re):Math.ceil(r.re),r.im>0?Math.floor(r.im):Math.ceil(r.im))},BigNumber:function(t){return t.isNegative()?t.ceil():t.floor()},Fraction:function(t){return t.s<0?t.ceil():t.floor()},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],70:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="floor",n.factory=function(t,r,n,i){var o=i("floor",{number:Math.floor,Complex:function(t){return t.floor()},BigNumber:function(t){return t.floor()},Fraction:function(t){return t.floor()},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\left\\lfloor${args[0]}\\right\\rfloor"},o}},{"../../utils/collection/deepMap":221}],71:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger;function i(t,r){if(!e(t)||!e(r))throw new Error("Parameters in function gcd must be integer numbers");for(var n;0!=r;)n=t%r,t=r,r=n;return t<0?-t:t}n.name="gcd",n.factory=function(r,n,e,o){var a=e(t("../../type/matrix/function/matrix")),u=e(t("../../type/matrix/utils/algorithm01")),s=e(t("../../type/matrix/utils/algorithm04")),c=e(t("../../type/matrix/utils/algorithm10")),f=e(t("../../type/matrix/utils/algorithm13")),l=e(t("../../type/matrix/utils/algorithm14")),p=o("gcd",{"number, number":i,"BigNumber, BigNumber":function(t,n){if(!t.isInt()||!n.isInt())throw new Error("Parameters in function gcd must be integer numbers");for(var e=new r.BigNumber(0);!n.isZero();){var i=t.mod(n);t=n,n=i}return t.lt(e)?t.neg():t},"Fraction, Fraction":function(t,r){return t.gcd(r)},"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=s(t,r,p);break;default:n=u(r,t,p,!0)}break;default:switch(r.storage()){case"sparse":n=u(t,r,p,!1);break;default:n=f(t,r,p)}}return n},"Array, Array":function(t,r){return p(a(t),a(r)).valueOf()},"Array, Matrix":function(t,r){return p(a(t),r)},"Matrix, Array":function(t,r){return p(t,a(r))},"Matrix, number | BigNumber":function(t,r){var n;switch(t.storage()){case"sparse":n=c(t,r,p,!1);break;default:n=l(t,r,p,!1)}return n},"number | BigNumber, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=c(r,t,p,!0);break;default:n=l(r,t,p,!0)}return n},"Array, number | BigNumber":function(t,r){return l(a(t),r,p,!1).valueOf()},"number | BigNumber, Array":function(t,r){return l(a(r),t,p,!0).valueOf()},"Array | Matrix | number | BigNumber, Array | Matrix | number | BigNumber, ...Array | Matrix | number | BigNumber":function(t,r,n){for(var e=p(t,r),i=0;i=0||n.predictable?Math.log(t):new r.Complex(t,0).log()},Complex:function(t){return t.log()},BigNumber:function(t){return!t.isNegative()||n.predictable?t.ln():new r.Complex(t.toNumber(),0).log()},"Array | Matrix":function(t){return e(t,u)},"any, any":function(t,r){return a(u(t),u(r))}});return u.toTex={1:"\\ln\\left(${args[0]}\\right)",2:"\\log_{${args[1]}}\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":221,"./divideScalar":64}],76:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.log10||function(t){return Math.log(t)/Math.LN10};n.name="log10",n.factory=function(t,r,n,o){var a=o("log10",{number:function(n){return n>=0||r.predictable?i(n):new t.Complex(n,0).log().div(Math.LN10)},Complex:function(r){return new t.Complex(r).log().div(Math.LN10)},BigNumber:function(n){return!n.isNegative()||r.predictable?n.log():new t.Complex(n.toNumber(),0).log().div(Math.LN10)},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\log_{10}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],77:[function(t,r,n){"use strict";n.name="mod",n.factory=function(r,n,e,i){var o=e(t("../../type/matrix/function/matrix")),a=t("../../utils/latex"),u=e(t("../../type/matrix/utils/algorithm02")),s=e(t("../../type/matrix/utils/algorithm03")),c=e(t("../../type/matrix/utils/algorithm05")),f=e(t("../../type/matrix/utils/algorithm11")),l=e(t("../../type/matrix/utils/algorithm12")),p=e(t("../../type/matrix/utils/algorithm13")),m=e(t("../../type/matrix/utils/algorithm14")),h=i("mod",{"number, number":function(t,r){if(r>0)return t-r*Math.floor(t/r);if(0===r)return t;throw new Error("Cannot calculate mod for a negative divisor")},"BigNumber, BigNumber":function(t,r){return r.isZero()?t:t.mod(r)},"Fraction, Fraction":function(t,r){return t.mod(r)},"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=c(t,r,h,!1);break;default:n=u(r,t,h,!0)}break;default:switch(r.storage()){case"sparse":n=s(t,r,h,!1);break;default:n=p(t,r,h)}}return n},"Array, Array":function(t,r){return h(o(t),o(r)).valueOf()},"Array, Matrix":function(t,r){return h(o(t),r)},"Matrix, Array":function(t,r){return h(t,o(r))},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=f(t,r,h,!1);break;default:n=m(t,r,h,!1)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=l(r,t,h,!0);break;default:n=m(r,t,h,!0)}return n},"Array, any":function(t,r){return m(o(t),r,h,!1).valueOf()},"any, Array":function(t,r){return m(o(r),t,h,!0).valueOf()}});return h.toTex={2:"\\left(${args[0]}"+a.operators.mod+"${args[1]}\\right)"},h}},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230}],78:[function(t,r,n){"use strict";var e=t("../../utils/object").extend,i=t("../../utils/array");n.name="multiply",n.factory=function(r,n,o,a){var u=t("../../utils/latex"),s=o(t("../../type/matrix/function/matrix")),c=o(t("./addScalar")),f=o(t("./multiplyScalar")),l=o(t("../relational/equalScalar")),p=o(t("../../type/matrix/utils/algorithm11")),m=o(t("../../type/matrix/utils/algorithm14")),h=r.DenseMatrix,y=r.SparseMatrix,g=a("multiply",e({"Array, Array":function(t,n){d(i.size(t),i.size(n));var e=g(s(t),s(n));return r.isMatrix(e)?e.valueOf():e},"Matrix, Matrix":function(t,r){var n=t.size(),e=r.size();return d(n,e),1===n.length?1===e.length?v(t,r,n[0]):x(t,r):1===e.length?w(t,r):M(t,r)},"Matrix, Array":function(t,r){return g(t,s(r))},"Array, Matrix":function(t,r){return g(s(t,r.storage()),r)},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=p(t,r,f,!1);break;case"dense":n=m(t,r,f,!1)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=p(r,t,f,!0);break;case"dense":n=m(r,t,f,!0)}return n},"Array, any":function(t,r){return m(s(t),r,f,!1).valueOf()},"any, Array":function(t,r){return m(s(r),t,f,!0).valueOf()},"any, any":f,"Array | Matrix | any, Array | Matrix | any, ...any":function(t,r,n){for(var e=g(t,r),i=0;iS)for(var B=0,T=0;T=0||n.predictable?t.pow(e):new r.Complex(t.toNumber(),0).pow(e.toNumber(),0)},"Fraction, Fraction":function(t,r){if(1!==r.d){if(n.predictable)throw new Error("Function pow does not support non-integer exponents for fractions.");return h(t.valueOf(),r.valueOf())}return t.pow(r)},"Array, number":y,"Array, BigNumber":function(t,r){return y(t,r.toNumber())},"Matrix, number":g,"Matrix, BigNumber":function(t,r){return g(t,r.toNumber())},"Unit, number":function(t,r){return t.pow(r)}});function h(t,i){if(n.predictable&&!e(i)&&t<0)try{var o=l(i),a=p(o);if((i===a||Math.abs((i-a)/i)<1e-14)&&o.d%2==1)return(o.n%2==0?1:-1)*Math.pow(-t,i)}catch(t){}return t*t<1&&i===1/0||t*t>1&&i===-1/0?0:n.predictable&&(t<-1&&i===1/0||t>-1&&t<0&&i===-1/0)?NaN:e(i)||t>=0||n.predictable?Math.pow(t,i):new r.Complex(t,0).pow(i,0)}function y(t,r){if(!e(r)||r<0)throw new TypeError("For A^b, b must be a positive integer (value is "+r+")");var n=i(t);if(2!=n.length)throw new Error("For A^b, A must be 2 dimensional (A has "+n.length+" dimensions)");if(n[0]!=n[1])throw new Error("For A^b, A must be square (size is "+n[0]+"x"+n[1]+")");for(var o=s(n[0]).valueOf(),a=t;r>=1;)1==(1&r)&&(o=c(a,o)),r>>=1,a=c(a,a);return o}function g(t,r){return f(y(t.valueOf(),r))}return m.toTex={2:"\\left(${args[0]}\\right)"+u.operators.pow+"{${args[1]}}"},m}},{"../../type/fraction/function/fraction":187,"../../type/matrix/function/matrix":197,"../../type/number":213,"../../utils/array":214,"../../utils/latex":230,"../../utils/number":231,"../matrix/eye":96,"./multiply":78}],83:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger,i=t("../../utils/number").toFixed,o=t("../../utils/collection/deepMap"),a="Number of decimals in function round must be an integer";n.name="round",n.factory=function(r,n,u,s){var c=u(t("../../type/matrix/function/matrix")),f=u(t("../relational/equalScalar")),l=u(t("../matrix/zeros")),p=u(t("../../type/matrix/utils/algorithm11")),m=u(t("../../type/matrix/utils/algorithm12")),h=u(t("../../type/matrix/utils/algorithm14")),y=s("round",{number:Math.round,"number, number":function(t,r){if(!e(r))throw new TypeError(a);if(r<0||r>15)throw new Error("Number of decimals in function round must be in te range of 0-15");return parseFloat(i(t,r))},Complex:function(t){return t.round()},"Complex, number":function(t,r){if(r%1)throw new TypeError(a);return t.round(r)},"Complex, BigNumber":function(t,r){if(!r.isInteger())throw new TypeError(a);var n=r.toNumber();return t.round(n)},"number, BigNumber":function(t,n){if(!n.isInteger())throw new TypeError(a);return new r.BigNumber(t).toDecimalPlaces(n.toNumber())},BigNumber:function(t){return t.toDecimalPlaces(0)},"BigNumber, BigNumber":function(t,r){if(!r.isInteger())throw new TypeError(a);return t.toDecimalPlaces(r.toNumber())},Fraction:function(t){return t.round()},"Fraction, number":function(t,r){if(r%1)throw new TypeError(a);return t.round(r)},"Array | Matrix":function(t){return o(t,y,!0)},"Matrix, number | BigNumber":function(t,r){var n;switch(t.storage()){case"sparse":n=p(t,r,y,!1);break;default:n=h(t,r,y,!1)}return n},"number | Complex | BigNumber, Matrix":function(t,r){if(!f(t,0)){var n;switch(r.storage()){case"sparse":n=m(r,t,y,!0);break;default:n=h(r,t,y,!0)}return n}return l(r.size(),r.storage())},"Array, number | BigNumber":function(t,r){return h(c(t),r,y,!1).valueOf()},"number | Complex | BigNumber, Array":function(t,r){return h(c(r),t,y,!0).valueOf()}});return y.toTex={1:"\\left\\lfloor${args[0]}\\right\\rceil",2:void 0},y}},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm14":212,"../../utils/collection/deepMap":221,"../../utils/number":231,"../matrix/zeros":115,"../relational/equalScalar":130}],84:[function(t,r,n){"use strict";var e=t("../../utils/number"),i=t("../../utils/collection/deepMap");n.name="sign",n.factory=function(t,r,n,o){var a=o("sign",{number:e.sign,Complex:function(t){return t.sign()},BigNumber:function(r){return new t.BigNumber(r.cmp(0))},Fraction:function(r){return new t.Fraction(r.s,1)},"Array | Matrix":function(t){return i(t,a,!0)},Unit:function(t){return a(t.value)}});return a.toTex={1:"\\mathrm{${name}}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],85:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="sqrt",n.factory=function(t,r,n,i){var o=i("sqrt",{number:a,Complex:function(t){return t.sqrt()},BigNumber:function(t){return!t.isNegative()||r.predictable?t.sqrt():a(t.toNumber())},"Array | Matrix":function(t){return e(t,o,!0)},Unit:function(t){return t.pow(.5)}});function a(n){return n>=0||r.predictable?Math.sqrt(n):new t.Complex(n,0).sqrt()}return o.toTex={1:"\\sqrt{${args[0]}}"},o}},{"../../utils/collection/deepMap":221}],86:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="square",n.factory=function(t,r,n,i){var o=i("square",{number:function(t){return t*t},Complex:function(t){return t.mul(t)},BigNumber:function(t){return t.times(t)},Fraction:function(t){return t.mul(t)},"Array | Matrix":function(t){return e(t,o,!0)},Unit:function(t){return t.pow(2)}});return o.toTex={1:"\\left(${args[0]}\\right)^2"},o}},{"../../utils/collection/deepMap":221}],87:[function(t,r,n){"use strict";var e=t("../../error/DimensionError");n.name="subtract",n.factory=function(r,n,i,o){var a=t("../../utils/latex"),u=i(t("../../type/matrix/function/matrix")),s=i(t("./addScalar")),c=i(t("./unaryMinus")),f=i(t("../../type/matrix/utils/algorithm01")),l=i(t("../../type/matrix/utils/algorithm03")),p=i(t("../../type/matrix/utils/algorithm05")),m=i(t("../../type/matrix/utils/algorithm10")),h=i(t("../../type/matrix/utils/algorithm13")),y=i(t("../../type/matrix/utils/algorithm14")),g=o("subtract",{"number, number":function(t,r){return t-r},"Complex, Complex":function(t,r){return t.sub(r)},"BigNumber, BigNumber":function(t,r){return t.minus(r)},"Fraction, Fraction":function(t,r){return t.sub(r)},"Unit, Unit":function(t,r){if(null==t.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(!t.equalBase(r))throw new Error("Units do not match");var n=t.clone();return n.value=g(n.value,r.value),n.fixPrefix=!1,n},"Matrix, Matrix":function(t,r){var n,i=t.size(),o=r.size();if(i.length!==o.length)throw new e(i.length,o.length);switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=p(t,r,g);break;default:n=l(r,t,g,!0)}break;default:switch(r.storage()){case"sparse":n=f(t,r,g,!1);break;default:n=h(t,r,g)}}return n},"Array, Array":function(t,r){return g(u(t),u(r)).valueOf()},"Array, Matrix":function(t,r){return g(u(t),r)},"Matrix, Array":function(t,r){return g(t,u(r))},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=m(t,c(r),s);break;default:n=y(t,r,g)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=m(r,t,g,!0);break;default:n=y(r,t,g,!0)}return n},"Array, any":function(t,r){return y(u(t),r,g,!1).valueOf()},"any, Array":function(t,r){return y(u(r),t,g,!0).valueOf()}});return g.toTex={2:"\\left(${args[0]}"+a.operators.subtract+"${args[1]}\\right)"},g}},{"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm01":200,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm10":208,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/latex":230,"./addScalar":59,"./unaryMinus":88}],88:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="unaryMinus",n.factory=function(r,n,i,o){var a=t("../../utils/latex"),u=o("unaryMinus",{number:function(t){return-t},Complex:function(t){return t.neg()},BigNumber:function(t){return t.neg()},Fraction:function(t){return t.neg()},Unit:function(t){var r=t.clone();return r.value=u(t.value),r},"Array | Matrix":function(t){return e(t,u,!0)}});return u.toTex={1:a.operators.unaryMinus+"\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":221,"../../utils/latex":230}],89:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="unaryPlus",n.factory=function(r,n,i,o){var a=t("../../utils/latex"),u=o("unaryPlus",{number:function(t){return t},Complex:function(t){return t},BigNumber:function(t){return t},Fraction:function(t){return t},Unit:function(t){return t.clone()},"Array | Matrix":function(t){return e(t,u,!0)},"boolean | string | null":function(t){return"BigNumber"==n.number?new r.BigNumber(+t):+t}});return u.toTex={1:a.operators.unaryPlus+"\\left(${args[0]}\\right)"},u}},{"../../utils/collection/deepMap":221,"../../utils/latex":230}],90:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger;n.name="xgcd",n.factory=function(r,n,i,o){var a=i(t("../../type/matrix/function/matrix")),u=o("xgcd",{"number, number":function(t,r){var i,o,u,s,c=0,f=1,l=1,p=0;if(!e(t)||!e(r))throw new Error("Parameters in function xgcd must be integer numbers");for(;r;)o=Math.floor(t/r),u=t-o*r,i=c,c=f-o*c,f=i,i=l,l=p-o*l,p=i,t=r,r=u;return s=t<0?[-t,-f,-p]:[t,t?f:0,p],"Array"===n.matrix?s:a(s)},"BigNumber, BigNumber":function(t,e){var i,o,u,s,c=new r.BigNumber(0),f=new r.BigNumber(1),l=c,p=f,m=f,h=c;if(!t.isInt()||!e.isInt())throw new Error("Parameters in function xgcd must be integer numbers");for(;!e.isZero();)o=t.div(e).floor(),u=t.mod(e),i=l,l=p.minus(o.times(l)),p=i,i=m,m=h.minus(o.times(m)),h=i,t=e,e=u;return s=t.lt(c)?[t.neg(),p.neg(),h.neg()]:[t,t.isZero()?0:p,h],"Array"===n.matrix?s:a(s)}});return u.toTex=void 0,u}},{"../../type/matrix/function/matrix":197,"../../utils/number":231}],91:[function(t,r,n){"use strict";var e=t("../../utils/object").clone,i=t("../../utils/number").isInteger,o=t("../../utils/array"),a=t("../../error/IndexError"),u=t("../../error/DimensionError");function s(t,r,n,e){if(e0&&p>c)throw new a(p,c+1)}else{var g=e(y).valueOf(),d=o.size(g);if(h[n]=g,c=p,p=d.length-1,n>0&&p!=c)throw new u(c+1,p+1)}}if(0==h.length)throw new SyntaxError("At least one matrix expected");for(var v=h.shift();h.length;)v=s(v,h.shift(),p,0);return m?l(v):v},"...string":function(t){return t.join("")}});return p.toTex=void 0,p}},{"../../error/DimensionError":55,"../../error/IndexError":56,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231,"../../utils/object":232}],92:[function(t,r,n){"use strict";var e=t("../../utils/array");n.name="cross",n.factory=function(r,n,i,o){var a=i(t("../../type/matrix/function/matrix")),u=i(t("../arithmetic/subtract")),s=i(t("../arithmetic/multiply")),c=o("cross",{"Matrix, Matrix":function(t,r){return a(f(t.toArray(),r.toArray()))},"Matrix, Array":function(t,r){return a(f(t.toArray(),r))},"Array, Matrix":function(t,r){return a(f(t,r.toArray()))},"Array, Array":f});return c.toTex={2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"},c;function f(t,r){var n=Math.max(e.size(t).length,e.size(r).length);t=e.squeeze(t),r=e.squeeze(r);var i=e.size(t),o=e.size(r);if(1!=i.length||1!=o.length||3!=i[0]||3!=o[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+i.join(", ")+"], B = ["+o.join(", ")+"])");var a=[u(s(t[1],r[2]),s(t[2],r[1])),u(s(t[2],r[0]),s(t[0],r[2])),u(s(t[0],r[1]),s(t[1],r[0]))];return n>1?[a]:a}}},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../arithmetic/multiply":78,"../arithmetic/subtract":87}],93:[function(t,r,n){"use strict";var e=t("../../utils/index"),i=e.object,o=e.string;n.name="det",n.factory=function(r,n,e,a){var u=e(t("../../type/matrix/function/matrix")),s=e(t("../arithmetic/add")),c=e(t("../arithmetic/subtract")),f=e(t("../arithmetic/multiply")),l=e(t("../arithmetic/unaryMinus")),p=a("det",{any:function(t){return i.clone(t)},"Array | Matrix":function(t){var n;switch((n=r.isMatrix(t)?t.size():Array.isArray(t)?(t=u(t)).size():[]).length){case 0:return i.clone(t);case 1:if(1==n[0])return i.clone(t.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+o.format(n)+")");case 2:var e=n[0],a=n[1];if(e==a)return function(t,r,n){if(1==r)return i.clone(t[0][0]);if(2==r)return c(f(t[0][0],t[1][1]),f(t[1][0],t[0][1]));for(var e=function(t){var r,n,e=new Array(t.length),i=0;for(r=1;r0?n:0,s=n<0?-n:0;switch(e.length){case 1:return function(t,n,e,i,o,a){var u=[i+o,i+a],s=r.Matrix.storage(e||"dense").diagonal(u,t,n);return null!==e?s:s.valueOf()}(t,n,o,e[0],s,a);case 2:return function(t,n,e,i,o,a){if(r.isMatrix(t)){var s=t.diagonal(n);return null!==e?e!==s.storage()?u(s,e):s:s.valueOf()}for(var c=Math.min(i[0]-o,i[1]-a),f=[],l=0;l2||e(r).length>2)throw new RangeError("Vectors with dimensions greater then 2 are not supported expected (Size x = "+JSON.stringify(t.length)+", y = "+JSON.stringify(r.length)+")");var n=[],i=[];return t.map(function(t){return r.map(function(r){return t.map(function(t){return r.map(function(r){return i.push(u(t,r))})},n.push(i=[]))})},n=[])&&n}}},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../arithmetic/multiplyScalar":79}],103:[function(t,r,n){"use strict";var e=t("../../utils/function").maxArgumentCount;function i(t,r){var n=e(r);return function e(i,o){return Array.isArray(i)?i.map(function(t,r){return e(t,o.concat(r))}):1===n?r(i):2===n?r(i,o):r(i,o,t)}(t,[])}n.name="map",n.factory=function(t,r,n,e){var o=e("map",{"Array, function":i,"Matrix, function":function(t,r){return t.map(r)}});return o.toTex=void 0,o}},{"../../utils/function":228}],104:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger,i=t("../../utils/array").resize;n.name="ones",n.factory=function(r,n,o,a){var u=o(t("../../type/matrix/function/matrix")),s=a("ones",{"":function(){return"Array"===n.matrix?c([]):c([],"default")},"...number | BigNumber | string":function(t){if("string"==typeof t[t.length-1]){var r=t.pop();return c(t,r)}return"Array"===n.matrix?c(t):c(t,"default")},Array:c,Matrix:function(t){var r=t.storage();return c(t.valueOf(),r)},"Array | Matrix, string":function(t,r){return c(t.valueOf(),r)}});return s.toTex=void 0,s;function c(t,n){var o=function(t){var n=!1;return t.forEach(function(t,e,i){r.isBigNumber(t)&&(n=!0,i[e]=t.toNumber())}),n}(t)?new r.BigNumber(1):1;if(function(t){t.forEach(function(t){if("number"!=typeof t||!e(t)||t<0)throw new Error("Parameters in function ones must be positive integers")})}(t),n){var a=u(n);return t.length>0?a.resize(t,o):a}var s=[];return t.length>0?i(s,t,o):s}}},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],105:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger;n.name="partitionSelect",n.factory=function(r,n,i,o){var a=i(t("../relational/compare"));function u(t,r){return-a(t,r)}return o("partitionSelect",{"Array | Matrix, number":function(t,r){return s(t,r,a)},"Array | Matrix, number, string":function(t,r,n){if("asc"===n)return s(t,r,a);if("desc"===n)return s(t,r,u);throw new Error('Compare string must be "asc" or "desc"')},"Array | Matrix, number, function":s});function s(t,n,i){if(!e(n)||n<0)throw new Error("k must be a non-negative integer");if(r.isMatrix(t)){if(t.size().length>1)throw new Error("Only one dimensional matrices supported");return c(t.valueOf(),n,i)}if(Array.isArray(t))return c(t,n,i)}function c(t,r,n){if(r>=t.length)throw new Error("k out of bounds");for(var e=0,i=t.length-1;e=0){var s=t[a];t[a]=t[o],t[o]=s,--a}else++o;n(t[o],u)>0&&--o,r<=o?i=o:e=o+1}return t[r]}}},{"../../utils/number":231,"../relational/compare":128}],106:[function(t,r,n){"use strict";n.name="range",n.factory=function(r,n,e,i){var o=e(t("../../type/matrix/function/matrix")),a=new r.BigNumber(0),u=new r.BigNumber(1),s=i("range",{string:f,"string, boolean":f,"number, number":function(t,r){return c(l(t,r,1))},"number, number, number":function(t,r,n){return c(l(t,r,n))},"number, number, boolean":function(t,r,n){return c(n?p(t,r,1):l(t,r,1))},"number, number, number, boolean":function(t,r,n,e){return c(e?p(t,r,n):l(t,r,n))},"BigNumber, BigNumber":function(t,r){return c(m(t,r,u))},"BigNumber, BigNumber, BigNumber":function(t,r,n){return c(m(t,r,n))},"BigNumber, BigNumber, boolean":function(t,r,n){return c(n?h(t,r,u):m(t,r,u))},"BigNumber, BigNumber, BigNumber, boolean":function(t,r,n,e){return c(e?h(t,r,n):m(t,r,n))}});return s.toTex=void 0,s;function c(t){return"Array"===n.matrix?t:o(t)}function f(t,e){var i=function(t){var r=t.split(":").map(function(t){return Number(t)});if(r.some(function(t){return isNaN(t)}))return null;switch(r.length){case 2:return{start:r[0],end:r[1],step:1};case 3:return{start:r[0],end:r[2],step:r[1]};default:return null}}(t);if(!i)throw new SyntaxError('String "'+t+'" is no valid range');return"BigNumber"===n.number?c((e?h:m)(new r.BigNumber(i.start),new r.BigNumber(i.end),new r.BigNumber(i.step))):c((e?p:l)(i.start,i.end,i.step))}function l(t,r,n){var e=[],i=t;if(n>0)for(;ir;)e.push(i),i+=n;return e}function p(t,r,n){var e=[],i=t;if(n>0)for(;i<=r;)e.push(i),i+=n;else if(n<0)for(;i>=r;)e.push(i),i+=n;return e}function m(t,r,n){var e=[],i=t;if(n.gt(a))for(;i.lt(r);)e.push(i),i=i.plus(n);else if(n.lt(a))for(;i.gt(r);)e.push(i),i=i.plus(n);return e}function h(t,r,n){var e=[],i=t;if(n.gt(a))for(;i.lte(r);)e.push(i),i=i.plus(n);else if(n.lt(a))for(;i.gte(r);)e.push(i),i=i.plus(n);return e}}},{"../../type/matrix/function/matrix":197}],107:[function(t,r,n){"use strict";t("../../error/DimensionError");var e=t("../../utils/number").isInteger,i=t("../../utils/array");n.name="reshape",n.factory=function(r,n,o,a){var u=o(t("../../type/matrix/function/matrix")),s=a("reshape",{"Matrix, Array":function(t,r){return t.reshape?t.reshape(r):u(i.reshape(t.valueOf(),r))},"Array, Array":function(t,r){return r.forEach(function(t){if(!e(t))throw new TypeError("Invalid size for dimension: "+t)}),i.reshape(t,r)}});return s.toTex=void 0,s}},{"../../error/DimensionError":55,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],108:[function(t,r,n){"use strict";var e=t("../../error/DimensionError"),i=t("../../error/ArgumentsError"),o=t("../../utils/number").isInteger,a=t("../../utils/string").format,u=t("../../utils/object").clone,s=t("../../utils/array");n.name="resize",n.factory=function(r,n,c,f){var l=c(t("../../type/matrix/function/matrix")),p=function(t,c,f){if(2!=arguments.length&&3!=arguments.length)throw new i("resize",arguments.length,2,3);if(r.isMatrix(c)&&(c=c.valueOf()),r.isBigNumber(c[0])&&(c=c.map(function(t){return r.isBigNumber(t)?t.toNumber():t})),r.isMatrix(t))return t.resize(c,f,!0);if("string"==typeof t)return function(t,r,n){if(void 0!==n){if("string"!=typeof n||1!==n.length)throw new TypeError("Single character expected as defaultValue")}else n=" ";if(1!==r.length)throw new e(r.length,1);var i=r[0];if("number"!=typeof i||!o(i))throw new TypeError("Invalid size, must contain positive integers (size: "+a(r)+")");if(t.length>i)return t.substring(0,i);if(t.lengths)for(f=s-1,a=c.length;f0)for(var f=0;ff)break}return c}throw new RangeError("Matrix must be square (size: "+i(o)+")")};return c.toTex={1:"\\mathrm{tr}\\left(${args[0]}\\right)"},c}},{"../../type/matrix/function/matrix":197,"../../utils/object":232,"../../utils/string":233,"../arithmetic/add":58}],114:[function(t,r,n){"use strict";var e=t("../../utils/object").clone,i=t("../../utils/string").format;n.name="transpose",n.factory=function(r,n,o,a){var u=t("../../utils/latex"),s=o(t("../../type/matrix/function/matrix")),c=r.DenseMatrix,f=r.SparseMatrix,l=a("transpose",{Array:function(t){return l(s(t)).valueOf()},Matrix:function(t){var r,n=t.size();switch(n.length){case 1:r=t.clone();break;case 2:var e=n[0],o=n[1];if(0===o)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+i(n)+")");switch(t.storage()){case"dense":r=p(t,e,o);break;case"sparse":r=m(t,e,o)}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+i(this._size)+")")}return r},any:function(t){return e(t)}}),p=function(t,r,n){for(var i,o=t._data,a=[],u=0;u0?a.resize(t,o):a}var s=[];return t.length>0?i(s,t,o):s}}},{"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/number":231}],116:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger;function i(t){return t.isInteger()&&t.gte(0)}n.name="combinations",n.factory=function(t,r,n,o){var a=o("combinations",{"number, number":function(t,r){var n,i,o;if(!e(t)||t<0)throw new TypeError("Positive integer value expected in function combinations");if(!e(r)||r<0)throw new TypeError("Positive integer value expected in function combinations");if(r>t)throw new TypeError("k must be less than or equal to n");for(n=Math.max(r,t-r),i=1,o=1;o<=t-n;o++)i=i*(n+o)/o;return i},"BigNumber, BigNumber":function(r,n){var e,o,a,u,s=new t.BigNumber(1);if(!i(r)||!i(n))throw new TypeError("Positive integer value expected in function combinations");if(n.gt(r))throw new TypeError("k must be less than n in function combinations");for(e=r.minus(n),n.lt(e)&&(e=n),o=s,a=s,u=r.minus(e);a.lte(u);a=a.plus(1))o=o.times(e.plus(a)).dividedBy(a);return o}});return a.toTex={2:"\\binom{${args[0]}}{${args[1]}}"},a}},{"../../utils/number":231}],117:[function(t,r,n){"use strict";var e=t("../../error/ArgumentsError"),i=t("../../utils/collection/isCollection"),o=t("../../utils/number").isNumber;n.name="distribution",n.factory=function(r,n,a,u,s){var c=a(t("../../type/matrix/function/matrix")),f=t("../../utils/array"),l=a(t("./seededRNG"));function p(t){if(!m.hasOwnProperty(t))throw new Error("Unknown distribution "+t);var n=Array.prototype.slice.call(arguments,1);return function(t){var n={random:function(t,n,a){var u,f,l;if(arguments.length>3)throw new e("random",arguments.length,0,3);if(1===arguments.length?i(t)?u=t:l=t:2===arguments.length?i(t)?(u=t,l=n):(f=t,l=n):(u=t,f=n,l=a),void 0!==f&&!o(f)||void 0!==l&&!o(l))throw new TypeError("Invalid argument in function random");if(void 0===l&&(l=1),void 0===f&&(f=0),void 0!==u){var p=m(u.valueOf(),f,l,s);return r.isMatrix(u)?c(p):p}return s(f,l)},randomInt:u({"number | Array":function(t){if(i(t)){var n=t,e=1,o=m(n.valueOf(),0,e,p);return r.isMatrix(n)?c(o):o}return p(0,e=t)},"number | Array, number":function(t,n){if(i(t)){var e=t,o=n,a=0,u=m(e.valueOf(),a,o,p);return r.isMatrix(e)?c(u):u}return p(a=t,o=n)},"Array, number, number":function(t,r,n){var e=m(t.valueOf(),r,n,p);return t&&!0===t.isMatrix?c(e):e}}),pickRandom:u({Array:function(t){return a(t)},"Array, number | Array":function(t,r){var n,e;if(Array.isArray(r))e=r;else{if(!o(r))throw new TypeError("Invalid argument in function pickRandom");n=r}return a(t,n,e)},"Array, number | Array, Array | number":function(t,r,n){var e,i;if(Array.isArray(r)?(i=r,e=n):(i=n,e=r),!Array.isArray(i)||!o(e))throw new TypeError("Invalid argument in function pickRandom");return a(t,e,i)}})},a=function(t,n,e){var i=void 0===n;if(i&&(n=1),r.isMatrix(t))t=t.valueOf();else if(!Array.isArray(t))throw new TypeError("Unsupported type of value in function pickRandom");if(f.size(t).length>1)throw new Error("Only one dimensional vectors supported");if(void 0!==e){if(e.length!=t.length)throw new Error("Weights must have the same length as possibles");for(var a=0,u=0,s=e.length;u=c)return n>1?t:t[0];for(var p,m=[];m.length1)for(var a=0,u=r.shift();a1;)t=l(),r=l(),n=1/6*Math.pow(-2*Math.log(t),.5)*Math.cos(2*Math.PI*r)+.5;return n}}};return p.toTex=void 0,p}},{"../../error/ArgumentsError":54,"../../type/matrix/function/matrix":197,"../../utils/array":214,"../../utils/collection/isCollection":222,"../../utils/number":231,"./seededRNG":127}],118:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="factorial",n.factory=function(r,n,i,o){var a=i(t("./gamma")),u=t("../../utils/latex"),s=o("factorial",{number:function(t){if(t<0)throw new Error("Value must be non-negative");return a(t+1)},BigNumber:function(t){if(t.isNegative())throw new Error("Value must be non-negative");return a(t.plus(1))},"Array | Matrix":function(t){return e(t,s)}});return s.toTex={1:"\\left(${args[0]}\\right)"+u.operators.factorial},s}},{"../../utils/collection/deepMap":221,"../../utils/latex":230,"./gamma":119}],119:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap"),i=t("../../utils/number").isInteger;var o=4.7421875,a=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];n.name="gamma",n.factory=function(r,n,u,s){var c=u(t("../arithmetic/multiply")),f=u(t("../arithmetic/pow")),l=s("gamma",{number:function(t){var r,n;if(i(t)){if(t<=0)return isFinite(t)?1/0:NaN;if(t>171)return 1/0;for(var e=t-2,u=t-1;e>1;)u*=e,e--;return 0==u&&(u=1),u}if(t<.5)return Math.PI/(Math.sin(Math.PI*t)*l(1-t));if(t>=171.35)return 1/0;if(t>85){var s=t*t,c=s*t,f=c*t,p=f*t;return Math.sqrt(2*Math.PI/t)*Math.pow(t/Math.E,t)*(1+1/(12*t)+1/(288*s)-139/(51840*c)-571/(2488320*f)+163879/(209018880*p)+5246819/(75246796800*p*t))}--t,n=a[0];for(var m=1;m1;)i=i.times(o),o--;return new r.BigNumber(i.toPrecision(r.BigNumber.precision))}(t.minus(1));if(!t.isFinite())return new r.BigNumber(t.isNegative()?NaN:1/0);throw new Error("Integer BigNumber expected")},"Array | Matrix":function(t){return e(t,l)}});return l.toTex={1:"\\Gamma\\left(${args[0]}\\right)"},l}},{"../../utils/collection/deepMap":221,"../../utils/number":231,"../arithmetic/multiply":78,"../arithmetic/pow":82}],120:[function(t,r,n){"use strict";r.exports=[t("./combinations"),t("./factorial"),t("./gamma"),t("./kldivergence"),t("./multinomial"),t("./permutations"),t("./pickRandom"),t("./random"),t("./randomInt")]},{"./combinations":116,"./factorial":118,"./gamma":119,"./kldivergence":121,"./multinomial":122,"./permutations":123,"./pickRandom":124,"./random":125,"./randomInt":126}],121:[function(t,r,n){"use strict";n.name="kldivergence",n.factory=function(r,n,e,i){var o=e(t("../../type/matrix/function/matrix")),a=e(t("../arithmetic/divide")),u=e(t("../statistics/sum")),s=e(t("../arithmetic/multiply")),c=e(t("../arithmetic/dotDivide")),f=e(t("../arithmetic/log")),l=e(t("../utils/isNumeric"));function p(t,r){var n=r.size().length,e=t.size().length;if(n>1)throw new Error("first object must be one dimensional");if(e>1)throw new Error("second object must be one dimensional");if(n!==e)throw new Error("Length of two vectors must be equal");if(0===u(t))throw new Error("Sum of elements in first object must be non zero");if(0===u(r))throw new Error("Sum of elements in second object must be non zero");var i=a(t,u(t)),o=a(r,u(r)),p=u(s(i,f(c(i,o))));return l(p)?p:Number.NaN}return i("kldivergence",{"Array, Array":function(t,r){return p(o(t),o(r))},"Matrix, Array":function(t,r){return p(t,o(r))},"Array, Matrix":function(t,r){return p(o(t),r)},"Matrix, Matrix":function(t,r){return p(t,r)}})}},{"../../type/matrix/function/matrix":197,"../arithmetic/divide":63,"../arithmetic/dotDivide":65,"../arithmetic/log":75,"../arithmetic/multiply":78,"../statistics/sum":143,"../utils/isNumeric":176}],122:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepForEach");n.name="multinomial",n.factory=function(r,n,i,o){var a=i(t("../arithmetic/add")),u=i(t("../arithmetic/multiply")),s=i(t("../arithmetic/divide")),c=i(t("../probability/factorial")),f=i(t("../utils/isInteger")),l=i(t("../utils/isPositive"));return o("multinomial",{"Array | Matrix":function(t){var r=0,n=1;return e(t,function(t){if(!f(t)||!l(t))throw new TypeError("Positive integer value expected in function multinomial");r=a(r,t),n=u(n,c(t))}),s(c(r),n)}})}},{"../../utils/collection/deepForEach":220,"../arithmetic/add":58,"../arithmetic/divide":63,"../arithmetic/multiply":78,"../probability/factorial":118,"../utils/isInteger":173,"../utils/isPositive":177}],123:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger;function i(t){return t.isInteger()&&t.gte(0)}n.name="permutations",n.factory=function(r,n,o,a){var u=a("permutations",{"number | BigNumber":o(t("./factorial")),"number, number":function(t,r){var n,i;if(!e(t)||t<0)throw new TypeError("Positive integer value expected in function permutations");if(!e(r)||r<0)throw new TypeError("Positive integer value expected in function permutations");if(r>t)throw new TypeError("second argument k must be less than or equal to first argument n");for(n=1,i=t-r+1;i<=t;i++)n*=i;return n},"BigNumber, BigNumber":function(t,n){var e,o;if(!i(t)||!i(n))throw new TypeError("Positive integer value expected in function permutations");if(n.gt(t))throw new TypeError("second argument k must be less than or equal to first argument n");for(e=new r.BigNumber(1),o=t.minus(n).plus(1);o.lte(t);o=o.plus(1))e=e.times(o);return e}});return u.toTex=void 0,u}},{"../../utils/number":231,"./factorial":118}],124:[function(t,r,n){"use strict";n.name="pickRandom",n.factory=function(r,n,e,i){var o=e(t("./distribution"))("uniform").pickRandom;return o.toTex=void 0,o}},{"./distribution":117}],125:[function(t,r,n){"use strict";n.name="random",n.factory=function(r,n,e,i){var o=e(t("./distribution"))("uniform").random;return o.toTex=void 0,o}},{"./distribution":117}],126:[function(t,r,n){"use strict";n.name="randomInt",n.factory=function(r,n,e,i){var o=e(t("./distribution"))("uniform").randomInt;return o.toTex=void 0,o}},{"./distribution":117}],127:[function(t,r,n){"use strict";var e=t("seed-random"),i=e();n.factory=function(t,r,n,o,a){var u;function s(t){u=null===t?i:e(String(t))}return s(r.randomSeed),a.on("config",function(t,r,n){void 0!==n.randomSeed&&s(t.randomSeed)}),function(){return u()}},n.math=!0},{"seed-random":481}],128:[function(t,r,n){"use strict";var e=t("../../utils/number").nearlyEqual,i=t("../../utils/bignumber/nearlyEqual");n.name="compare",n.factory=function(r,n,o,a){var u=o(t("../../type/matrix/function/matrix")),s=o(t("../../type/matrix/utils/algorithm03")),c=o(t("../../type/matrix/utils/algorithm05")),f=o(t("../../type/matrix/utils/algorithm12")),l=o(t("../../type/matrix/utils/algorithm13")),p=o(t("../../type/matrix/utils/algorithm14")),m=a("compare",{"boolean, boolean":function(t,r){return t===r?0:t>r?1:-1},"number, number":function(t,r){return t===r||e(t,r,n.epsilon)?0:t>r?1:-1},"BigNumber, BigNumber":function(t,e){return t.eq(e)||i(t,e,n.epsilon)?new r.BigNumber(0):new r.BigNumber(t.cmp(e))},"Fraction, Fraction":function(t,n){return new r.Fraction(t.compare(n))},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(t,r){if(!t.equalBase(r))throw new Error("Cannot compare units with different base");return m(t.value,r.value)},"string, string":function(t,r){return t===r?0:t>r?1:-1},"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=c(t,r,m);break;default:n=s(r,t,m,!0)}break;default:switch(r.storage()){case"sparse":n=s(t,r,m,!1);break;default:n=l(t,r,m)}}return n},"Array, Array":function(t,r){return m(u(t),u(r)).valueOf()},"Array, Matrix":function(t,r){return m(u(t),r)},"Matrix, Array":function(t,r){return m(t,u(r))},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=f(t,r,m,!1);break;default:n=p(t,r,m,!1)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=f(r,t,m,!0);break;default:n=p(r,t,m,!0)}return n},"Array, any":function(t,r){return p(u(t),r,m,!1).valueOf()},"any, Array":function(t,r){return p(u(r),t,m,!0).valueOf()}});return m.toTex=void 0,m}},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm05":204,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/bignumber/nearlyEqual":217,"../../utils/number":231}],129:[function(t,r,n){"use strict";var e=t("javascript-natural-sort");n.name="compareNatural",n.factory=function(r,n,i,o){var a=i(t("../utils/typeof")),u=(i(t("../../type/matrix/function/matrix")),i(t("./compare"))),s=u.signatures["boolean,boolean"],c=o("compareNatural",{"any, any":function(t,n){var i,o=a(t),l=a(n);if(!("number"!==o&&"BigNumber"!==o&&"Fraction"!==o||"number"!==l&&"BigNumber"!==l&&"Fraction"!==l))return"0"!==(i=u(t,n)).toString()?i>0?1:-1:e(o,l);if("Array"===o||"Matrix"===o||"Array"===l||"Matrix"===l)return 0!==(i=function t(n,e){return r.isSparseMatrix(n)&&r.isSparseMatrix(e)?f(n.toJSON().values,e.toJSON().values):r.isSparseMatrix(n)?t(n.toArray(),e):r.isSparseMatrix(e)?t(n,e.toArray()):r.isDenseMatrix(n)?t(n.toJSON().data,e):r.isDenseMatrix(e)?t(n,e.toJSON().data):Array.isArray(n)?Array.isArray(e)?f(n,e):t(n,[e]):t([n],e)}(t,n))?i:e(o,l);if(o!==l)return e(o,l);if("Complex"===o)return function(t,r){return t.re>r.re?1:t.rer.im?1:t.imr.length?1:t.lengthr},"number, number":function(t,r){return t>r&&!e(t,r,n.epsilon)},"BigNumber, BigNumber":function(t,r){return t.gt(r)&&!i(t,r,n.epsilon)},"Fraction, Fraction":function(t,r){return 1===t.compare(r)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers")},"Unit, Unit":function(t,r){if(!t.equalBase(r))throw new Error("Cannot compare units with different base");return h(t.value,r.value)},"string, string":function(t,r){return t>r},"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=c(t,r,h);break;default:n=s(r,t,h,!0)}break;default:switch(r.storage()){case"sparse":n=s(t,r,h,!1);break;default:n=l(t,r,h)}}return n},"Array, Array":function(t,r){return h(u(t),u(r)).valueOf()},"Array, Matrix":function(t,r){return h(u(t),r)},"Matrix, Array":function(t,r){return h(t,u(r))},"Matrix, any":function(t,r){var n;switch(t.storage()){case"sparse":n=f(t,r,h,!1);break;default:n=p(t,r,h,!1)}return n},"any, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=f(r,t,h,!0);break;default:n=p(r,t,h,!0)}return n},"Array, any":function(t,r){return p(u(t),r,h,!1).valueOf()},"any, Array":function(t,r){return p(u(r),t,h,!0).valueOf()}});return h.toTex={2:"\\left(${args[0]}"+m.operators.larger+"${args[1]}\\right)"},h}},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm07":206,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212,"../../utils/bignumber/nearlyEqual":217,"../../utils/latex":230,"../../utils/number":231}],132:[function(t,r,n){"use strict";var e=t("../../utils/number").nearlyEqual,i=t("../../utils/bignumber/nearlyEqual");n.name="smaller",n.factory=function(r,n,o,a){var u=o(t("../../type/matrix/function/matrix")),s=o(t("../../type/matrix/utils/algorithm03")),c=o(t("../../type/matrix/utils/algorithm07")),f=o(t("../../type/matrix/utils/algorithm12")),l=o(t("../../type/matrix/utils/algorithm13")),p=o(t("../../type/matrix/utils/algorithm14")),m=t("../../utils/latex"),h=a("smaller",{"boolean, boolean":function(t,r){return t0&&(o=t[a]);return h(o,i)}var u=f(t,(r-1)/2);return m(u)}var m=a({"number | BigNumber | Complex | Unit":function(t){return t}}),h=a({"number | BigNumber | Complex | Unit, number | BigNumber | Complex | Unit":function(t,r){return s(u(t,r),2)}});return l.toTex=void 0,l}},{"../../utils/array":214,"../../utils/collection/containsCollections":219,"../../utils/collection/reduce":224,"../arithmetic/addScalar":59,"../arithmetic/divideScalar":64,"../matrix/partitionSelect":105,"../relational/compare":128}],138:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepForEach"),i=t("../../utils/collection/reduce"),o=t("../../utils/collection/containsCollections");n.name="min",n.factory=function(r,n,a,u){var s=a(t("../relational/smaller")),c=u("min",{"Array | Matrix":l,"Array | Matrix, number | BigNumber":function(t,r){return i(t,r.valueOf(),f)},"...":function(t){if(o(t))throw new TypeError("Scalar values expected in function min");return l(t)}});return c.toTex="\\min\\left(${args}\\right)",c;function f(t,r){return s(t,r)?t:r}function l(t){var r=void 0;if(e(t,function(t){(void 0===r||s(t,r))&&(r=t)}),void 0===r)throw new Error("Cannot calculate min of an empty array");return r}}},{"../../utils/collection/containsCollections":219,"../../utils/collection/deepForEach":220,"../../utils/collection/reduce":224,"../relational/smaller":132}],139:[function(t,r,n){"use strict";var e=t("../../utils/array").flatten;n.name="mode",n.factory=function(t,r,n,i){return i("mode",{"Array | Matrix":o,"...":function(t){return o(t)}});function o(t){if(0==(t=e(t.valueOf())).length)throw new Error("Cannot calculate mode of an empty array");var r={},n=[],i=0;for(var o in t)t[o]in r||(r[t[o]]=0),r[t[o]]++,r[t[o]]==i?n.push(t[o]):r[t[o]]>i&&(i=r[t[o]],n=[t[o]]);return n}}},{"../../utils/array":214}],140:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepForEach");n.name="prod",n.factory=function(r,n,i,o){var a=i(t("../arithmetic/multiplyScalar")),u=o("prod",{"Array | Matrix":s,"Array | Matrix, number | BigNumber":function(t,r){throw new Error("prod(A, dim) is not yet supported")},"...":function(t){return s(t)}});return u.toTex=void 0,u;function s(t){var r=void 0;if(e(t,function(t){r=void 0===r?t:a(r,t)}),void 0===r)throw new Error("Cannot calculate prod of an empty array");return r}}},{"../../utils/collection/deepForEach":220,"../arithmetic/multiplyScalar":79}],141:[function(t,r,n){"use strict";var e=t("../../utils/number").isInteger,i=t("../../utils/number").isNumber,o=t("../../utils/array").flatten,a=t("../../utils/collection/isCollection");n.name="quantileSeq",n.factory=function(r,n,u,s){var c=u(t("../arithmetic/add")),f=u(t("../arithmetic/multiply")),l=u(t("../matrix/partitionSelect")),p=u(t("../relational/compare"));function m(t,r,n){var e=o(t),a=e.length;if(0===a)throw new Error("Cannot calculate quantile of an empty sequence");if(i(r)){var u;if(0==(v=(u=r*(a-1))%1)){var s=n?e[u]:l(e,u);return h(s),s}var m=Math.floor(u);if(n)g=e[m],d=e[m+1];else{d=l(e,m+1),g=e[m];for(var y=0;y0&&(g=e[y])}return h(g),h(d),c(f(g,1-v),f(d,v))}if((u=r.times(a-1)).isInteger())return u=u.toNumber(),s=n?e[u]:l(e,u),h(s),s;m=u.floor();var g,d,v=u.minus(m),x=m.toNumber();if(n)g=e[x],d=e[x+1];else for(d=l(e,x+1),g=e[x],y=0;y0&&(g=e[y]);h(g),h(d);var b=new v.constructor(1);return c(f(g,b.minus(v)),f(d,v))}var h=s({"number | BigNumber | Unit":function(t){return t}});return function(t,n,o){var u,s,c;if(arguments.length<2||arguments.length>3)throw new SyntaxError("Function quantileSeq requires two or three parameters");if(a(t)){if("boolean"==typeof(o=o||!1)){if(s=t.valueOf(),i(n)){if(n<0)throw new Error("N/prob must be non-negative");if(n<=1)return m(s,n,o);if(n>1){if(!e(n))throw new Error("N must be a positive integer");var f=n+1;u=new Array(n);for(var l=0;l4294967295)throw new Error("N must be less than or equal to 2^32-1, as that is the maximum length of an Array");for(f=new r.BigNumber(p+1),u=new Array(p),l=0;l1)throw new Error("Probability must be between 0 and 1, inclusive")}else{if(!r.isBigNumber(h))throw new TypeError("Unexpected type of argument in function quantileSeq");if(c=new h.constructor(1),h.isNegative()||h.gt(c))throw new Error("Probability must be between 0 and 1, inclusive")}u[l]=m(s,h,o)}return u}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}throw new TypeError("Unexpected type of argument in function quantileSeq")}}},{"../../utils/array":214,"../../utils/collection/isCollection":222,"../../utils/number":231,"../arithmetic/add":58,"../arithmetic/multiply":78,"../matrix/partitionSelect":105,"../relational/compare":128}],142:[function(t,r,n){"use strict";n.name="std",n.factory=function(r,n,e,i){var o=e(t("../arithmetic/sqrt")),a=e(t("../statistics/var")),u=i("std",{"Array | Matrix":s,"Array | Matrix, string":s,"...":function(t){return s(t)}});return u.toTex=void 0,u;function s(t,r){if(0==t.length)throw new SyntaxError("Function std requires one or more parameters (0 provided)");return o(a.apply(null,arguments))}}},{"../arithmetic/sqrt":85,"../statistics/var":144}],143:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepForEach");n.name="sum",n.factory=function(r,n,i,o){var a=i(t("../arithmetic/addScalar")),u=o("sum",{"Array | Matrix":function(t){return s(t)},"Array | Matrix, number | BigNumber":function(){throw new Error("sum(A, dim) is not yet supported")},"...":function(t){return s(t)}});return u.toTex=void 0,u;function s(t){var i=void 0;if(e(t,function(t){i=void 0===i?t:a(i,t)}),void 0===i)switch(n.number){case"number":return 0;case"BigNumber":return new r.BigNumber(0);case"Fraction":return new r.Fraction(0);default:return 0}return i}}},{"../../utils/collection/deepForEach":220,"../arithmetic/addScalar":59}],144:[function(t,r,n){"use strict";var e="unbiased",i=t("../../utils/collection/deepForEach");n.name="var",n.factory=function(r,n,o,a){var u=o(t("../arithmetic/addScalar")),s=o(t("../arithmetic/subtract")),c=o(t("../arithmetic/multiplyScalar")),f=o(t("../arithmetic/divideScalar")),l=a("variance",{"Array | Matrix":function(t){return p(t,e)},"Array | Matrix, string":p,"...":function(t){return p(t,e)}});return l.toTex="\\mathrm{Var}\\left(${args}\\right)",l;function p(t,n){var e=0,o=0;if(0==t.length)throw new SyntaxError("Function var requires one or more parameters (0 provided)");if(i(t,function(t){e=u(e,t),o++}),0===o)throw new Error("Cannot calculate var of an empty array");var a=f(e,o);switch(e=0,i(t,function(t){var r=s(t,a);e=u(e,c(r,r))}),n){case"uncorrected":return f(e,o);case"biased":return f(e,o+1);case"unbiased":var l=r.isBigNumber(e)?new r.BigNumber(0):0;return 1==o?l:f(e,o-1);default:throw new Error('Unknown normalization "'+n+'". Choose "unbiased" (default), "uncorrected", or "biased".')}}}},{"../../utils/collection/deepForEach":220,"../arithmetic/addScalar":59,"../arithmetic/divideScalar":64,"../arithmetic/multiplyScalar":79,"../arithmetic/subtract":87}],145:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="acos",n.factory=function(t,r,n,i){var o=i("acos",{number:function(n){return n>=-1&&n<=1||r.predictable?Math.acos(n):new t.Complex(n,0).acos()},Complex:function(t){return t.acos()},BigNumber:function(t){return t.acos()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\cos^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],146:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.acosh||function(t){return Math.log(Math.sqrt(t*t-1)+t)};n.name="acosh",n.factory=function(t,r,n,o){var a=o("acosh",{number:function(n){return n>=1||r.predictable?i(n):n<=-1?new t.Complex(Math.log(Math.sqrt(n*n-1)-n),Math.PI):new t.Complex(n,0).acosh()},Complex:function(t){return t.acosh()},BigNumber:function(t){return t.acosh()},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\cosh^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],147:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="acot",n.factory=function(t,r,n,i){var o=i("acot",{number:function(t){return Math.atan(1/t)},Complex:function(t){return t.acot()},BigNumber:function(r){return new t.BigNumber(1).div(r).atan()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\cot^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],148:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="acoth",n.factory=function(t,r,n,i){var o=i("acoth",{number:function(n){return n>=1||n<=-1||r.predictable?isFinite(n)?(Math.log((n+1)/n)+Math.log(n/(n-1)))/2:0:new t.Complex(n,0).acoth()},Complex:function(t){return t.acoth()},BigNumber:function(r){return new t.BigNumber(1).div(r).atanh()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\coth^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],149:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="acsc",n.factory=function(t,r,n,i){var o=i("acsc",{number:function(n){return n<=-1||n>=1||r.predictable?Math.asin(1/n):new t.Complex(n,0).acsc()},Complex:function(t){return t.acsc()},BigNumber:function(r){return new t.BigNumber(1).div(r).asin()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\csc^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],150:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="acsch",n.factory=function(t,r,n,i){var o=i("acsch",{number:function(t){return t=1/t,Math.log(t+Math.sqrt(t*t+1))},Complex:function(t){return t.acsch()},BigNumber:function(r){return new t.BigNumber(1).div(r).asinh()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\mathrm{csch}^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],151:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="asec",n.factory=function(t,r,n,i){var o=i("asec",{number:function(n){return n<=-1||n>=1||r.predictable?Math.acos(1/n):new t.Complex(n,0).asec()},Complex:function(t){return t.asec()},BigNumber:function(r){return new t.BigNumber(1).div(r).acos()},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\sec^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],152:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="asech",n.factory=function(r,n,i,o){o.find(i(t("./acosh")),["Complex"]);var a=o("asech",{number:function(t){if(t<=1&&t>=-1||n.predictable){t=1/t;var e=Math.sqrt(t*t-1);return t>0||n.predictable?Math.log(e+t):new r.Complex(Math.log(e-t),Math.PI)}return new r.Complex(t,0).asech()},Complex:function(t){return t.asech()},BigNumber:function(t){return new r.BigNumber(1).div(t).acosh()},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\mathrm{sech}^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221,"./acosh":146}],153:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="asin",n.factory=function(t,r,n,i){var o=i("asin",{number:function(n){return n>=-1&&n<=1||r.predictable?Math.asin(n):new t.Complex(n,0).asin()},Complex:function(t){return t.asin()},BigNumber:function(t){return t.asin()},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\sin^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],154:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="asinh",n.factory=function(t,r,n,i){var o=i("asinh",{number:Math.asinh||function(t){return Math.log(Math.sqrt(t*t+1)+t)},Complex:function(t){return t.asinh()},BigNumber:function(t){return t.asinh()},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\sinh^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],155:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="atan",n.factory=function(t,r,n,i){var o=i("atan",{number:function(t){return Math.atan(t)},Complex:function(t){return t.atan()},BigNumber:function(t){return t.atan()},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\tan^{-1}\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],156:[function(t,r,n){"use strict";n.name="atan2",n.factory=function(r,n,e,i){var o=e(t("../../type/matrix/function/matrix")),a=e(t("../../type/matrix/utils/algorithm02")),u=e(t("../../type/matrix/utils/algorithm03")),s=e(t("../../type/matrix/utils/algorithm09")),c=e(t("../../type/matrix/utils/algorithm11")),f=e(t("../../type/matrix/utils/algorithm12")),l=e(t("../../type/matrix/utils/algorithm13")),p=e(t("../../type/matrix/utils/algorithm14")),m=i("atan2",{"number, number":Math.atan2,"BigNumber, BigNumber":function(t,n){return r.BigNumber.atan2(t,n)},"Matrix, Matrix":function(t,r){var n;switch(t.storage()){case"sparse":switch(r.storage()){case"sparse":n=s(t,r,m,!1);break;default:n=a(r,t,m,!0)}break;default:switch(r.storage()){case"sparse":n=u(t,r,m,!1);break;default:n=l(t,r,m)}}return n},"Array, Array":function(t,r){return m(o(t),o(r)).valueOf()},"Array, Matrix":function(t,r){return m(o(t),r)},"Matrix, Array":function(t,r){return m(t,o(r))},"Matrix, number | BigNumber":function(t,r){var n;switch(t.storage()){case"sparse":n=c(t,r,m,!1);break;default:n=p(t,r,m,!1)}return n},"number | BigNumber, Matrix":function(t,r){var n;switch(r.storage()){case"sparse":n=f(r,t,m,!0);break;default:n=p(r,t,m,!0)}return n},"Array, number | BigNumber":function(t,r){return p(o(t),r,m,!1).valueOf()},"number | BigNumber, Array":function(t,r){return p(o(r),t,m,!0).valueOf()}});return m.toTex={2:"\\mathrm{atan2}\\left(${args}\\right)"},m}},{"../../type/matrix/function/matrix":197,"../../type/matrix/utils/algorithm02":201,"../../type/matrix/utils/algorithm03":202,"../../type/matrix/utils/algorithm09":207,"../../type/matrix/utils/algorithm11":209,"../../type/matrix/utils/algorithm12":210,"../../type/matrix/utils/algorithm13":211,"../../type/matrix/utils/algorithm14":212}],157:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.atanh||function(t){return Math.log((1+t)/(1-t))/2};n.name="atanh",n.factory=function(t,r,n,o){var a=o("atanh",{number:function(n){return n<=1&&n>=-1||r.predictable?i(n):new t.Complex(n,0).atanh()},Complex:function(t){return t.atanh()},BigNumber:function(t){return t.atanh()},"Array | Matrix":function(t){return e(t,a,!0)}});return a.toTex={1:"\\tanh^{-1}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],158:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="cos",n.factory=function(t,r,n,i){var o=i("cos",{number:Math.cos,Complex:function(t){return t.cos()},BigNumber:function(t){return t.cos()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\cos\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],159:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.cosh||function(t){return(Math.exp(t)+Math.exp(-t))/2};n.name="cosh",n.factory=function(t,r,n,o){var a=o("cosh",{number:i,Complex:function(t){return t.cosh()},BigNumber:function(t){return t.cosh()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cosh is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\cosh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],160:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="cot",n.factory=function(t,r,n,i){var o=i("cot",{number:function(t){return 1/Math.tan(t)},Complex:function(t){return t.cot()},BigNumber:function(r){return new t.BigNumber(1).div(r.tan())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cot is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\cot\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],161:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");function i(t){var r=Math.exp(2*t);return(r+1)/(r-1)}n.name="coth",n.factory=function(t,r,n,o){var a=o("coth",{number:i,Complex:function(t){return t.coth()},BigNumber:function(r){return new t.BigNumber(1).div(r.tanh())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function coth is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\coth\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],162:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="csc",n.factory=function(t,r,n,i){var o=i("csc",{number:function(t){return 1/Math.sin(t)},Complex:function(t){return t.csc()},BigNumber:function(r){return new t.BigNumber(1).div(r.sin())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csc is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\csc\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],163:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap"),i=t("../../utils/number").sign;function o(t){return 0==t?Number.POSITIVE_INFINITY:Math.abs(2/(Math.exp(t)-Math.exp(-t)))*i(t)}n.name="csch",n.factory=function(t,r,n,i){var a=i("csch",{number:o,Complex:function(t){return t.csch()},BigNumber:function(r){return new t.BigNumber(1).div(r.sinh())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function csch is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\mathrm{csch}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],164:[function(t,r,n){"use strict";r.exports=[t("./acos"),t("./acosh"),t("./acot"),t("./acoth"),t("./acsc"),t("./acsch"),t("./asec"),t("./asech"),t("./asin"),t("./asinh"),t("./atan"),t("./atan2"),t("./atanh"),t("./cos"),t("./cosh"),t("./cot"),t("./coth"),t("./csc"),t("./csch"),t("./sec"),t("./sech"),t("./sin"),t("./sinh"),t("./tan"),t("./tanh")]},{"./acos":145,"./acosh":146,"./acot":147,"./acoth":148,"./acsc":149,"./acsch":150,"./asec":151,"./asech":152,"./asin":153,"./asinh":154,"./atan":155,"./atan2":156,"./atanh":157,"./cos":158,"./cosh":159,"./cot":160,"./coth":161,"./csc":162,"./csch":163,"./sec":165,"./sech":166,"./sin":167,"./sinh":168,"./tan":169,"./tanh":170}],165:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="sec",n.factory=function(t,r,n,i){var o=i("sec",{number:function(t){return 1/Math.cos(t)},Complex:function(t){return t.sec()},BigNumber:function(r){return new t.BigNumber(1).div(r.cos())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sec is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={1:"\\sec\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],166:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");function i(t){return 2/(Math.exp(t)+Math.exp(-t))}n.name="sech",n.factory=function(t,r,n,o){var a=o("sech",{number:i,Complex:function(t){return t.sech()},BigNumber:function(r){return new t.BigNumber(1).div(r.cosh())},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sech is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a)}});return a.toTex={1:"\\mathrm{sech}\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],167:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="sin",n.factory=function(t,r,n,i){var o=i("sin",{number:Math.sin,Complex:function(t){return t.sin()},BigNumber:function(t){return t.sin()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\sin\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],168:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.sinh||function(t){return(Math.exp(t)-Math.exp(-t))/2};n.name="sinh",n.factory=function(t,r,n,o){var a=o("sinh",{number:i,Complex:function(t){return t.sinh()},BigNumber:function(t){return t.sinh()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sinh is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a,!0)}});return a.toTex={1:"\\sinh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],169:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="tan",n.factory=function(t,r,n,i){var o=i("tan",{number:Math.tan,Complex:function(t){return t.tan()},BigNumber:function(t){return t.tan()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tan is no angle");return o(r.value)},"Array | Matrix":function(t){return e(t,o,!0)}});return o.toTex={1:"\\tan\\left(${args[0]}\\right)"},o}},{"../../utils/collection/deepMap":221}],170:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");var i=Math.tanh||function(t){var r=Math.exp(2*t);return(r-1)/(r+1)};n.name="tanh",n.factory=function(t,r,n,o){var a=o("tanh",{number:i,Complex:function(t){return t.tanh()},BigNumber:function(t){return t.tanh()},Unit:function(r){if(!r.hasBase(t.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function tanh is no angle");return a(r.value)},"Array | Matrix":function(t){return e(t,a,!0)}});return a.toTex={1:"\\tanh\\left(${args[0]}\\right)"},a}},{"../../utils/collection/deepMap":221}],171:[function(t,r,n){"use strict";var e=t("../../utils/object");n.name="clone",n.factory=function(t,r,n,i){var o=i("clone",{any:e.clone});return o.toTex=void 0,o}},{"../../utils/object":232}],172:[function(t,r,n){"use strict";r.exports=[t("./clone"),t("./isInteger"),t("./isNegative"),t("./isNumeric"),t("./isPositive"),t("./isPrime"),t("./isZero"),t("./isNaN"),t("./typeof")]},{"./clone":171,"./isInteger":173,"./isNaN":174,"./isNegative":175,"./isNumeric":176,"./isPositive":177,"./isPrime":178,"./isZero":179,"./typeof":180}],173:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap"),i=t("../../utils/number");n.name="isInteger",n.factory=function(t,r,n,o){var a=o("isInteger",{number:i.isInteger,BigNumber:function(t){return t.isInt()},Fraction:function(t){return 1===t.d&&isFinite(t.n)},"Array | Matrix":function(t){return e(t,a)}});return a}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],174:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");t("../../utils/number");n.name="isNaN",n.factory=function(t,r,n,i){return i("isNaN",{number:function(t){return Number.isNaN(t)},BigNumber:function(t){return t.isNaN()},Fraction:function(t){return!1},Complex:function(t){return t.isNaN()},Unit:function(t){return Number.isNaN(t.value)},"Array | Matrix":function(t){return e(t,Number.isNaN)}})}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],175:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");t("../../utils/number");n.name="isNegative",n.factory=function(t,r,n,i){var o=i("isNegative",{number:function(t){return t<0},BigNumber:function(t){return t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s<0},Unit:function(t){return o(t.value)},"Array | Matrix":function(t){return e(t,o)}});return o}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],176:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");t("../../utils/number");n.name="isNumeric",n.factory=function(t,r,n,i){var o=i("isNumeric",{"number | BigNumber | Fraction | boolean":function(){return!0},"Complex | Unit | string":function(){return!1},"Array | Matrix":function(t){return e(t,o)}});return o}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],177:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");t("../../utils/number");n.name="isPositive",n.factory=function(t,r,n,i){var o=i("isPositive",{number:function(t){return t>0},BigNumber:function(t){return!t.isNeg()&&!t.isZero()&&!t.isNaN()},Fraction:function(t){return t.s>0&&t.n>0},Unit:function(t){return o(t.value)},"Array | Matrix":function(t){return e(t,o)}});return o}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],178:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");n.name="isPrime",n.factory=function(t,r,n,i){var o=i("isPrime",{number:function(t){if(t<2)return!1;if(2==t)return!0;if(t%2==0)return!1;for(var r=3;r*r<=t;r+=2)if(t%r==0)return!1;return!0},BigNumber:function(r){if(r.lt(2))return!1;if(r.equals(2))return!0;if(r.mod(2).isZero())return!1;for(var n=t.BigNumber(3);n.times(n).lte(r);n=n.plus(1))if(r.mod(n).isZero())return!1;return!0},"Array | Matrix":function(t){return e(t,o)}});return o}},{"../../utils/collection/deepMap":221}],179:[function(t,r,n){"use strict";var e=t("../../utils/collection/deepMap");t("../../utils/number");n.name="isZero",n.factory=function(t,r,n,i){var o=i("isZero",{number:function(t){return 0===t},BigNumber:function(t){return t.isZero()},Complex:function(t){return 0===t.re&&0===t.im},Fraction:function(t){return 1===t.d&&0===t.n},Unit:function(t){return o(t.value)},"Array | Matrix":function(t){return e(t,o)}});return o}},{"../../utils/collection/deepMap":221,"../../utils/number":231}],180:[function(t,r,n){"use strict";var e=t("../../utils/types");n.name="typeof",n.factory=function(t,r,n,i){var o=i("_typeof",{any:function(r){var n=e.type(r);if("Object"===n){if(t.isBigNumber(r))return"BigNumber";if(t.isComplex(r))return"Complex";if(t.isFraction(r))return"Fraction";if(t.isMatrix(r))return"Matrix";if(t.isUnit(r))return"Unit";if(t.isIndex(r))return"Index";if(t.isRange(r))return"Range";if(t.isChain(r))return"Chain";if(t.isHelp(r))return"Help"}return n}});return o.toTex=void 0,o}},{"../../utils/types":234}],181:[function(t,r,n){"use strict";var e=t("decimal.js/decimal.js");n.name="BigNumber",n.path="type",n.factory=function(t,r,n,i,o){var a=e.clone({precision:r.precision});return a.prototype.type="BigNumber",a.prototype.isBigNumber=!0,a.prototype.toJSON=function(){return{mathjs:"BigNumber",value:this.toString()}},a.fromJSON=function(t){return new a(t.value)},o.on("config",function(t,r){t.precision!==r.precision&&a.config({precision:t.precision})}),a},n.math=!0},{"decimal.js/decimal.js":42}],182:[function(t,r,n){"use strict";var e=t("../../../utils/collection/deepMap");n.name="bignumber",n.factory=function(t,r,n,i){var o=i("bignumber",{"":function(){return new t.BigNumber(0)},number:function(r){return new t.BigNumber(r+"")},string:function(r){return new t.BigNumber(r)},BigNumber:function(t){return t},Fraction:function(r){return new t.BigNumber(r.n).div(r.d)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={0:"0",1:"\\left(${args[0]}\\right)"},o}},{"../../../utils/collection/deepMap":221}],183:[function(t,r,n){"use strict";r.exports=[t("./BigNumber"),t("./function/bignumber")]},{"./BigNumber":181,"./function/bignumber":182}],184:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i=t("complex.js"),o=t("../../utils/number").format,a=t("../../utils/number").isNumber;n.name="Complex",n.path="type",n.factory=function(t,r,n,u,s){return i.prototype.type="Complex",i.prototype.isComplex=!0,i.prototype.toJSON=function(){return{mathjs:"Complex",re:this.re,im:this.im}},i.prototype.toPolar=function(){return{r:this.abs(),phi:this.arg()}},i.prototype.format=function(t){var r=this.im,n=this.re,e=o(this.re,t),i=o(this.im,t),u=a(t)?t:t?t.precision:null;if(null!==u){var s=Math.pow(10,-u);Math.abs(n/r)r.re?1:t.rer.im?1:t.im");var h=n.max().map(function(t){return t+1});v(t,h,o);var y=c.length;!function t(r,n,e,i,o){var a=o===i-1,u=n.dimension(o);a?u.forEach(function(t,n){m(t),r[t]=e[n[0]]}):u.forEach(function(a,u){m(a),t(r[a],n,e[u[0]],i,o+1)})}(t._data,n,e,y,0)}return t}(this,t,n,e);default:throw new SyntaxError("Wrong number of arguments")}},g.prototype.get=function(t){if(!c(t))throw new TypeError("Array expected");if(t.length!=this._size.length)throw new i(t.length,this._size.length);for(var r=0;re[o]&&(e[o]=r[o],i=!0);i&&d(t,e,n)}return g.prototype.reshape=function(t,r){var n=r?this.clone():this;return n._data=a.reshape(n._data,t),n._size=t.slice(0),n},g.prototype.clone=function(){return new g({data:u.clone(this._data),size:u.clone(this._size),datatype:this._datatype})},g.prototype.size=function(){return this._size.slice(0)},g.prototype.map=function(t){var r=this;return new g({data:function n(e,i){return c(e)?e.map(function(t,r){return n(t,i.concat(r))}):t(e,i,r)}(this._data,[]),size:u.clone(this._size),datatype:this._datatype})},g.prototype.forEach=function(t){var r=this;!function n(e,i){c(e)?e.forEach(function(t,r){n(t,i.concat(r))}):t(e,i,r)}(this._data,[])},g.prototype.toArray=function(){return u.clone(this._data)},g.prototype.valueOf=function(){return this._data},g.prototype.format=function(t){return o.format(this._data,t)},g.prototype.toString=function(){return o.format(this._data)},g.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}},g.prototype.diagonal=function(t){if(t){if(r.isBigNumber(t)&&(t=t.toNumber()),!f(t)||!l(t))throw new TypeError("The parameter k must be an integer number")}else t=0;for(var n=t>0?t:0,e=t<0?-t:0,i=this._size[0],o=this._size[1],a=Math.min(i-e,o-n),u=[],s=0;s0?e:0,m=e<0?-e:0,y=t[0],d=t[1],v=Math.min(y-m,d-s);if(c(n)){if(n.length!==v)throw new Error("Invalid value array length");u=function(t){return n[t]}}else if(r.isMatrix(n)){var x=n.size();if(1!==x.length||x[0]!==v)throw new Error("Invalid matrix length");u=function(t){return n.get([t])}}else u=function(){return n};i||(i=r.isBigNumber(u(0))?new r.BigNumber(0):0);var b=[];if(t.length>0){b=a.resize(b,t,i);for(var w=0;w0;){var i=e.right;e.left.right=e.right,e.right.left=e.left,e.left=r,e.right=r.right,r.right=e,e.right.left=e,e.parent=null,e=i,n--}return t.left.right=t.right,t.right.left=t.left,t==t.right?r=null:(r=t.right,r=p(r,this._size)),this._size--,this._minimum=r,t},s.prototype.remove=function(t){this._minimum=c(this._minimum,t,-1),this.extractMinimum()};var c=function(t,r,n){r.key=n;var e=r.parent;return e&&o(r.key,e.key)&&(f(t,r,e),l(t,e)),o(r.key,t.key)&&(t=r),t},f=function(t,r,n){r.left.right=r.right,r.right.left=r.left,n.degree--,n.child==r&&(n.child=r.right),0===n.degree&&(n.child=null),r.left=t,r.right=t.right,t.right=r,r.right.left=r,r.parent=null,r.mark=!1},l=function t(r,n){var e=n.parent;e&&(n.mark?(f(r,n,e),t(e)):n.mark=!0)},p=function(t,r){var n,e,i,s=Math.floor(Math.log(r)*u)+1,c=new Array(s),f=0,l=t;if(l)for(f++,l=l.right;l!==t;)f++,l=l.right;for(;f>0;){for(var p=l.degree,m=l.right;n=c[p];){if(a(l.key,n.key)){var h=n;n=l,l=h}i=l,(e=n).left.right=e.right,e.right.left=e.left,e.parent=i,i.child?(e.left=i.child,e.right=i.child.right,i.child.right=e,e.right.left=e):(i.child=e,e.right=e,e.left=e),i.degree++,e.mark=!1,c[p]=null,p++}c[p]=l,l=m,f--}t=null;for(var y=0;y0?this.step>0?this.start:this.start+(t-1)*this.step:void 0},o.prototype.max=function(){var t=this.size()[0];return t>0?this.step>0?this.start+(t-1)*this.step:this.start:void 0},o.prototype.forEach=function(t){var r=this.start,n=this.step,e=this.end,i=0;if(n>0)for(;re;)t(r,[i],this),r+=n,i++},o.prototype.map=function(t){var r=[];return this.forEach(function(n,e,i){r[e[0]]=t(n,e,i)}),r},o.prototype.toArray=function(){var t=[];return this.forEach(function(r,n){t[n[0]]=r}),t},o.prototype.valueOf=function(){return this.toArray()},o.prototype.format=function(t){var r=e.format(this.start,t);return 1!=this.step&&(r+=":"+e.format(this.step,t)),r+=":"+e.format(this.end,t)},o.prototype.toString=function(){return this.format()},o.prototype.toJSON=function(){return{mathjs:"Range",start:this.start,end:this.end,step:this.step}},o.fromJSON=function(t){return new o(t.start,t.end,t.step)},o}},{"../../utils/number":231}],194:[function(t,r,n){"use strict";n.name="Spa",n.path="type",n.factory=function(r,n,e){var i=e(t("../../function/arithmetic/add")),o=e(t("../../function/relational/equalScalar"));function a(){if(!(this instanceof a))throw new SyntaxError("Constructor must be called with the new operator");this._values=[],this._heap=new r.FibonacciHeap}return a.prototype.type="Spa",a.prototype.isSpa=!0,a.prototype.set=function(t,r){if(this._values[t])this._values[t].value=r;else{var n=this._heap.insert(t,r);this._values[t]=n}},a.prototype.get=function(t){var r=this._values[t];return r?r.value:0},a.prototype.accumulate=function(t,r){var n=this._values[t];n?n.value=i(n.value,r):(n=this._heap.insert(t,r),this._values[t]=n)},a.prototype.forEach=function(t,r,n){var e=this._heap,i=this._values,a=[],u=e.extractMinimum();for(u&&a.push(u);u&&u.key<=r;)u.key>=t&&(o(u.value,0)||n(u.key,u.value,this)),(u=e.extractMinimum())&&a.push(u);for(var s=0;s0){var u=0;do{t._ptr.push(t._index.length);for(var s=0;s");for(var m=n.min()[0],h=n.min()[1],y=s[0],g=s[1],d=0;da-1||o>u-1)&&(E(this,Math.max(e+1,a),Math.max(o+1,u),n),a=this._size[0],u=this._size[1]),m(e,a),m(o,u);var l=A(e,this._ptr[o],this._ptr[o+1],this._index);return lm){for(s=m;sl){if(f){var h=0;for(s=0;sr-1&&(t._values.splice(c,1),t._index.splice(c,1),v++)}t._ptr[s]=t._values.length}return t._size[0]=r,t._size[1]=n,t};v.prototype.reshape=function(t,r){if(!c(t))throw new TypeError("Array expected");if(2!==t.length)throw new Error("Sparse matrices can only be reshaped in two dimensions");if(t.forEach(function(r){if(!s.isNumber(r)||!s.isInteger(r)||r<0)throw new TypeError("Invalid size, must contain positive integers (size: "+u.format(t)+")")}),this._size[0]*this._size[1]!=t[0]*t[1])throw new Error("Reshaping sparse matrix will result in the wrong number of elements");var n=r?this.clone():this;if(this._size[0]===t[0]&&this._size[1]===t[1])return n;for(var e=[],i=0;i=r&&M<=n){if(!a)for(var A=b;A "+(this._values?u.format(this._values[c],t):"X")}return i},v.prototype.toString=function(){return u.format(this.toArray())},v.prototype.toJSON=function(){return{mathjs:"SparseMatrix",values:this._values,index:this._index,ptr:this._ptr,size:this._size,datatype:this._datatype}},v.prototype.diagonal=function(t){if(t){if(r.isBigNumber(t)&&(t=t.toNumber()),!f(t)||!l(t))throw new TypeError("The parameter k must be an integer number")}else t=0;var n=t>0?t:0,e=t<0?-t:0,i=this._size[0],o=this._size[1],a=Math.min(i-e,o-n),u=[],s=[],c=[];c[0]=0;for(var p=n;p0?e:0,h=e<0?-e:0,g=t[0],x=t[1],b=Math.min(g-h,x-m);if(c(n)){if(n.length!==b)throw new Error("Invalid value array length");s=function(t){return n[t]}}else if(r.isMatrix(n)){var w=n.size();if(1!==w.length||w[0]!==b)throw new Error("Invalid matrix length");s=function(t){return n.get([t])}}else s=function(){return n};for(var M=[],A=[],_=[],N=0;N=0&&E=s||i[f]!==r)){var p=e?e[c]:void 0;i.splice(f,0,r),e&&e.splice(f,0,p),i.splice(f<=c?c+1:c,1),e&&e.splice(f<=c?c+1:c,1)}else if(f=s||i[c]!==t)){var m=e?e[f]:void 0;i.splice(c,0,t),e&&e.splice(c,0,m),i.splice(c<=f?f+1:f,1),e&&e.splice(c<=f?f+1:f,1)}}},r.Matrix._storage.sparse=v,v},n.lazy=!1},{"../../error/DimensionError":55,"../../function/relational/equalScalar":130,"../../utils/index":229,"./Matrix":191}],196:[function(t,r,n){"use strict";n.name="index",n.factory=function(t,r,n,e){return e("index",{"...number | string | BigNumber | Range | Array | Matrix":function(r){var n=r.map(function(r){return t.isBigNumber(r)?r.toNumber():Array.isArray(r)||t.isMatrix(r)?r.map(function(r){return t.isBigNumber(r)?r.toNumber():r}):r}),e=new t.Index;return t.Index.apply(e,n),e}})}},{}],197:[function(t,r,n){"use strict";n.name="matrix",n.factory=function(t,r,n,e){var i=e("matrix",{"":function(){return o([])},string:function(t){return o([],t)},"string, string":function(t,r){return o([],t,r)},Array:function(t){return o(t)},Matrix:function(t){return o(t,t.storage())},"Array | Matrix, string":o,"Array | Matrix, string, string":o});return i.toTex={0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"},i;function o(r,n,e){return new(t.Matrix.storage(n||"default"))(r,e)}}},{}],198:[function(t,r,n){"use strict";n.name="sparse",n.factory=function(t,r,n,e){var i=t.SparseMatrix,o=e("sparse",{"":function(){return new i([])},string:function(t){return new i([],t)},"Array | Matrix":function(t){return new i(t)},"Array | Matrix, string":function(t,r){return new i(t,r)}});return o.toTex={0:"\\begin{bsparse}\\end{bsparse}",1:"\\left(${args[0]}\\right)"},o}},{}],199:[function(t,r,n){"use strict";r.exports=[t("./Matrix"),t("./DenseMatrix"),t("./SparseMatrix"),t("./Spa"),t("./FibonacciHeap"),t("./ImmutableDenseMatrix"),t("./MatrixIndex"),t("./Range"),t("./function/index"),t("./function/matrix"),t("./function/sparse")]},{"./DenseMatrix":188,"./FibonacciHeap":189,"./ImmutableDenseMatrix":190,"./Matrix":191,"./MatrixIndex":192,"./Range":193,"./Spa":194,"./SparseMatrix":195,"./function/index":196,"./function/matrix":197,"./function/sparse":198}],200:[function(t,r,n){"use strict";var e=t("../../../error/DimensionError");n.name="algorithm01",n.factory=function(t,r,n,i){var o=t.DenseMatrix;return function(t,r,n,a){var u=t._data,s=t._size,c=t._datatype,f=r._values,l=r._index,p=r._ptr,m=r._size,h=r._datatype;if(s.length!==m.length)throw new e(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");var y,g,d=s[0],v=s[1],x="string"==typeof c&&c===h?c:void 0,b=x?i.find(n,[x,x]):n,w=[];for(y=0;y0?a(g,0,h,h[0],s,l):[];return new o({data:d,size:h,datatype:u})}}},{"../../../error/DimensionError":55,"../../../utils/index":229}],212:[function(t,r,n){"use strict";var e=t("../../../utils/object").clone;n.name="algorithm14",n.factory=function(t,r,n,i){var o=t.DenseMatrix,a=function t(r,n,e,i,o,a,u){var s=[];if(n===e.length-1)for(var c=0;c0?a(p,0,f,f[0],c,r,u):[];return new o({data:m,size:e(f),datatype:s})}}},{"../../../utils/object":232}],213:[function(t,r,n){"use strict";var e=t("./../utils/collection/deepMap");n.name="number",n.factory=function(t,r,n,i){var o=i("number",{"":function(){return 0},number:function(t){return t},string:function(t){var r=Number(t);if(isNaN(r))throw new SyntaxError('String "'+t+'" is no valid number');return r},BigNumber:function(t){return t.toNumber()},Fraction:function(t){return t.valueOf()},Unit:function(t){throw new Error("Second argument with valueless unit expected")},"Unit, string | Unit":function(t,r){return t.toNumber(r)},"Array | Matrix":function(t){return e(t,o)}});return o.toTex={0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"},o}},{"./../utils/collection/deepMap":221}],214:[function(t,r,n){"use strict";var e=t("./number"),i=t("./string"),o=(t("./object"),t("./types"),t("../error/DimensionError")),a=t("../error/IndexError");n.size=function(t){for(var r=[];Array.isArray(t);)r.push(t.length),t=t[0];return r},n.validate=function(t,r){if(0==r.length){if(Array.isArray(t))throw new o(t.length,0)}else!function t(r,n,e){var i,a=r.length;if(a!=n[e])throw new o(a,n[e]);if(e")}(t,r,0)},n.validateIndex=function(t,r){if(!e.isNumber(t)||!e.isInteger(t))throw new TypeError("Index must be an integer (value: "+t+")");if(t<0||"number"==typeof r&&t>=r)throw new a(t,r)},n.UNINITIALIZED={},n.resize=function(t,r,o){if(!Array.isArray(t)||!Array.isArray(r))throw new TypeError("Array expected");if(0===r.length)throw new Error("Resizing to scalar is not supported");return r.forEach(function(t){if(!e.isNumber(t)||!e.isInteger(t)||t<0)throw new TypeError("Invalid size, must contain positive integers (size: "+i.format(r)+")")}),function t(r,e,i,o){var a;var u;var s=r.length;var c=e[i];var f=Math.min(s,c);r.length=c;if(i=u.length)throw new o(r,u.length);return i(t)?t.create(a(t.valueOf(),r,n)):a(t,r,n)}},{"../../error/IndexError":56,"../array":214,"../collection/isMatrix":223}],225:[function(t,r,n){"use strict";r.exports=function(t,r,n,e,i,o,a,u,s,c,f){var l,p,m,h,y=t._values,g=t._index,d=t._ptr,v=a._index;if(e)for(p=d[r],m=d[r+1],l=p;l>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"},n.defaultTemplate="\\mathrm{${name}}\\left(${args}\\right)";var i={deg:"^\\circ"};n.escape=function(t){return e(t,{preserveFormatting:!0})},n.toSymbol=function(t,r){return(r=void 0!==r&&r)?i.hasOwnProperty(t)?i[t]:"\\mathrm{"+n.escape(t)+"}":n.symbols.hasOwnProperty(t)?n.symbols[t]:n.escape(t)}},{"escape-latex":45}],231:[function(t,r,n){"use strict";function e(t){for(var r=[],n=0;n0?1:t<0?-1:0},n.format=function(t,r){if("function"==typeof r)return r(t);if(t===1/0)return"Infinity";if(t===-1/0)return"-Infinity";if(isNaN(t))return"NaN";var e="auto",i=void 0;switch(r&&(r.notation&&(e=r.notation),n.isNumber(r)?i=r:r.precision&&(i=r.precision)),e){case"fixed":return n.toFixed(t,i);case"exponential":return n.toExponential(t,i);case"engineering":return n.toEngineering(t,i);case"auto":return n.toPrecision(t,i,r&&r.exponential).replace(/((\.\d*?)(0+))($|e)/,function(){var t=arguments[2],r=arguments[4];return"."!==t?t+r:r});default:throw new Error('Unknown notation "'+e+'". Choose "auto", "exponential", or "fixed".')}},n.splitNumber=function(t){var r=String(t).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);if(!r)throw new SyntaxError("Invalid number "+t);var n=r[1],e=r[2],i=parseFloat(r[4]||"0"),o=e.indexOf(".");i+=-1!==o?o-1:e.length-1;var a=e.replace(".","").replace(/^0*/,function(t){return i-=t.length,""}).replace(/0*$/,"").split("").map(function(t){return parseInt(t)});return 0===a.length&&(a.push(0),i++),{sign:n,coefficients:a,exponent:i}},n.toEngineering=function(t,r){if(isNaN(t)||!isFinite(t))return String(t);var i=n.roundDigits(n.splitNumber(t),r),o=i.exponent,a=i.coefficients,u=o%3==0?o:o<0?o-3-o%3:o-o%3,s=o>=0?o:Math.abs(u);a.length-1=0;)f++;var l=a.slice(f).join(""),p=l.match(/[1-9]/)?"."+l:"",m=a.slice(0,f).join("")+p+"e"+(o>=0?"+":"")+u.toString();return i.sign+m},n.toFixed=function(t,r){if(isNaN(t)||!isFinite(t))return String(t);var i=n.splitNumber(t),o=n.roundDigits(i,i.exponent+1+(r||0)),a=o.coefficients,u=o.exponent+1,s=u+(r||0);return a.length0?"."+a.join(""):"")+"e"+(u>=0?"+":"")+u},n.toPrecision=function(t,r,i){if(isNaN(t)||!isFinite(t))return String(t);var o=i&&void 0!==i.lower?i.lower:.001,a=i&&void 0!==i.upper?i.upper:1e5,u=n.splitNumber(t),s=Math.abs(Math.pow(10,u.exponent));if(s=a)return n.toExponential(t,r);var c=r?n.roundDigits(u,r):u,f=c.coefficients,l=c.exponent;f.length0?l:0;return p<(f=e(-l).concat(f)).length-1&&f.splice(p+1,0,"."),c.sign+f.join("")},n.roundDigits=function(t,r){for(var n={sign:t.sign,coefficients:t.coefficients,exponent:t.exponent},e=n.coefficients;r<=0;)e.unshift(0),n.exponent++,r++;if(e.length>r&&e.splice(r,e.length-r)[0]>=5){var i=r-1;for(e[i]++;10===e[i];)e.pop(),0===i&&(e.unshift(0),n.exponent++,i++),e[--i]++}return n},n.digits=function(t){return t.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length},n.DBL_EPSILON=Number.EPSILON||2.220446049250313e-16,n.nearlyEqual=function(t,r,e){if(null==e)return t==r;if(t==r)return!0;if(isNaN(t)||isNaN(r))return!1;if(isFinite(t)&&isFinite(r)){var i=Math.abs(t-r);return i/g,">")}},{"./bignumber/formatter":215,"./bignumber/isBigNumber":216,"./number":231}],234:[function(t,r,n){"use strict";function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}n.type=function(t){var r=e(t);return"object"===r?null===t?"null":Array.isArray(t)?"Array":t instanceof Date?"Date":t instanceof RegExp?"RegExp":t instanceof Boolean?"boolean":t instanceof Number?"number":t instanceof String?"string":"Object":"function"===r?"Function":r}},{}],235:[function(require,module,exports){(function(global){"use strict";function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var numeric=void 0===exports?function(){}:exports;void 0!==global&&(global.numeric=numeric),numeric.version="1.2.6",numeric.bench=function(t,r){var n,e,i;for(void 0===r&&(r=15),e=.5,n=new Date;;){for(i=e*=2;i>3;i-=4)t(),t(),t(),t();for(;i>0;)t(),i--;if(new Date-n>r)break}for(i=e;i>3;i-=4)t(),t(),t(),t();for(;i>0;)t(),i--;return 1e3*(3*e-1)/(new Date-n)},numeric._myIndexOf=function(t){var r,n=this.length;for(r=0;rnumeric.largeArray)return r.push("...Large Array..."),!0;for(s=!1,r.push("["),e=0;e0&&(r.push(","),s&&r.push("\n ")),s=t(n[e]);return r.push("]"),!0}r.push("{");s=!1;for(e in n)n.hasOwnProperty(e)&&(s&&r.push(",\n"),s=!0,r.push(e),r.push(": \n"),t(n[e]));return r.push("}"),!0}(t),r.join("")},numeric.parseDate=function(t){return function t(r){if("string"==typeof r)return Date.parse(r.replace(/-/g,"/"));if(!(r instanceof Array))throw new Error("parseDate: parameter must be arrays of strings");var n,e=[];for(n=0;n0){for(o[s]=[],r=0;r>>8^i[255&(o^t[e])];return-1^o}var n,e,i,o,a,u,s,c,f,l,p=t[0].length,m=t[0][0].length,h=[137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,m>>24&255,m>>16&255,m>>8&255,255&m,p>>24&255,p>>16&255,p>>8&255,255&p,8,2,0,0,0,-1,-2,-3,-4,-5,-6,-7,-8,73,68,65,84,8,29];for(l=r(h,12,29),h[29]=l>>24&255,h[30]=l>>16&255,h[31]=l>>8&255,h[32]=255&l,n=1,e=0,s=0;s>8&255,h.push(a),h.push(u),h.push(255&~a),h.push(255&~u),0===s&&h.push(0),c=0;c255?255:a<0?0:Math.round(a)))%65521))%65521,h.push(a);h.push(0)}return f=(e<<16)+n,h.push(f>>24&255),h.push(f>>16&255),h.push(f>>8&255),h.push(255&f),o=h.length-41,h[33]=o>>24&255,h[34]=o>>16&255,h[35]=o>>8&255,h[36]=255&o,l=r(h,37),h.push(l>>24&255),h.push(l>>16&255),h.push(l>>8&255),h.push(255&l),h.push(0),h.push(0),h.push(0),h.push(0),h.push(73),h.push(69),h.push(78),h.push(68),h.push(174),h.push(66),h.push(96),h.push(130),"data:image/png;base64,"+function(t){var r,n,e,i,o,a,u,s=t.length,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f="";for(r=0;r>4),a=((15&e)<<2)+((i=t[r+2])>>6),u=63&i,r+1>=s?a=u=64:r+2>=s&&(u=64),f+=c.charAt(n>>2)+c.charAt(o)+c.charAt(a)+c.charAt(u);return f}(h)},numeric._dim=function(t){for(var r=[];"object"===_typeof(t);)r.push(t.length),t=t[0];return r},numeric.dim=function(t){var r;return"object"===_typeof(t)?"object"===_typeof(r=t[0])?"object"===_typeof(r[0])?numeric._dim(t):[t.length,r.length]:[t.length]:[]},numeric.mapreduce=function(t,r){return Function("x","accum","_s","_k",'if(typeof accum === "undefined") accum = '+r+';\nif(typeof x === "number") { var xi = x; '+t+'; return accum; }\nif(typeof _s === "undefined") _s = numeric.dim(x);\nif(typeof _k === "undefined") _k = 0;\nvar _n = _s[_k];\nvar i,xi;\nif(_k < _s.length-1) {\n for(i=_n-1;i>=0;i--) {\n accum = arguments.callee(x[i],accum,_s,_k+1);\n } return accum;\n}\nfor(i=_n-1;i>=1;i-=2) { \n xi = x[i];\n '+t+";\n xi = x[i-1];\n "+t+";\n}\nif(i === 0) {\n xi = x[i];\n "+t+"\n}\nreturn accum;")},numeric.mapreduce2=function(t,r){return Function("x","var n = x.length;\nvar i,xi;\n"+r+";\nfor(i=n-1;i!==-1;--i) { \n xi = x[i];\n "+t+";\n}\nreturn accum;")},numeric.same=function t(r,n){var e,i;if(!(r instanceof Array&&n instanceof Array))return!1;if((i=r.length)!==n.length)return!1;for(e=0;e=0;e-=2)o[e+1]=r,o[e]=r;return-1===e&&(o[0]=r),o}for(e=i-1;e>=0;e--)o[e]=numeric.rep(t,r,n+1);return o},numeric.dotMMsmall=function(t,r){var n,e,i,o,a,u,s,c,f,l,p;for(o=t.length,a=r.length,u=r[0].length,s=Array(o),n=o-1;n>=0;n--){for(c=Array(u),f=t[n],i=u-1;i>=0;i--){for(l=f[a-1]*r[a-1][i],e=a-2;e>=1;e-=2)p=e-1,l+=f[e]*r[e][i]+f[p]*r[p][i];0===e&&(l+=f[0]*r[0][i]),c[i]=l}s[n]=c}return s},numeric._getCol=function(t,r,n){var e;for(e=t.length-1;e>0;--e)n[e]=t[e][r],n[--e]=t[e][r];0===e&&(n[0]=t[0][r])},numeric.dotMMbig=function(t,r){var n,e,i,o=numeric._getCol,a=r.length,u=Array(a),s=t.length,c=r[0].length,f=new Array(s),l=numeric.dotVV;for(--a,e=--s;-1!==e;--e)f[e]=Array(c);for(e=--c;-1!==e;--e)for(o(r,e,u),i=s;-1!==i;--i)0,n=t[i],f[i][e]=l(n,u);return f},numeric.dotMV=function(t,r){var n,e=t.length,i=(r.length,Array(e)),o=numeric.dotVV;for(n=e-1;n>=0;n--)i[n]=o(t[n],r);return i},numeric.dotVM=function(t,r){var n,e,i,o,a,u,s;for(i=t.length,o=r[0].length,a=Array(o),e=o-1;e>=0;e--){for(u=t[i-1]*r[i-1][e],n=i-2;n>=1;n-=2)s=n-1,u+=t[n]*r[n][e]+t[s]*r[s][e];0===n&&(u+=t[0]*r[0][e]),a[e]=u}return a},numeric.dotVV=function(t,r){var n,e,i=t.length,o=t[i-1]*r[i-1];for(n=i-2;n>=1;n-=2)e=n-1,o+=t[n]*r[n]+t[e]*r[e];return 0===n&&(o+=t[0]*r[0]),o},numeric.dot=function(t,r){var n=numeric.dim;switch(1e3*n(t).length+n(r).length){case 2002:return r.length<10?numeric.dotMMsmall(t,r):numeric.dotMMbig(t,r);case 2001:return numeric.dotMV(t,r);case 1002:return numeric.dotVM(t,r);case 1001:return numeric.dotVV(t,r);case 1e3:return numeric.mulVS(t,r);case 1:return numeric.mulSV(t,r);case 0:return t*r;default:throw new Error("numeric.dot only works on vectors and matrices")}},numeric.diag=function(t){var r,n,e,i,o=t.length,a=Array(o);for(r=o-1;r>=0;r--){for(i=Array(o),n=r+2,e=o-1;e>=n;e-=2)i[e]=0,i[e-1]=0;for(e>r&&(i[e]=0),i[r]=t[r],e=r-1;e>=1;e-=2)i[e]=0,i[e-1]=0;0===e&&(i[0]=0),a[r]=i}return a},numeric.getDiag=function(t){var r,n=Math.min(t.length,t[0].length),e=Array(n);for(r=n-1;r>=1;--r)e[r]=t[r][r],e[--r]=t[r][r];return 0===r&&(e[0]=t[0][0]),e},numeric.identity=function(t){return numeric.diag(numeric.rep([t],1))},numeric.pointwise=function(t,r,n){void 0===n&&(n="");var e,i,o=[],a=/\[i\]$/,u="",s=!1;for(e=0;e=0;i--) ret[i] = arguments.callee("+t.join(",")+",_s,_k+1);\n return ret;\n}\n"+n+"\nfor(i=_n-1;i!==-1;--i) {\n "+r+"\n}\nreturn ret;",Function.apply(null,o)},numeric.pointwise2=function(t,r,n){void 0===n&&(n="");var e,i,o=[],a=/\[i\]$/,u="",s=!1;for(e=0;e=0;a--)t("object"===_typeof(r)?r[a]:r,"object"===_typeof(n)?n[a]:n,e,i+1,o);else o(r,n)},numeric._biforeach2=function t(r,n,e,i,o){if(i===e.length-1)return o(r,n);var a,u=e[i],s=Array(u);for(a=u-1;a>=0;--a)s[a]=t("object"===_typeof(r)?r[a]:r,"object"===_typeof(n)?n[a]:n,e,i+1,o);return s},numeric._foreach=function t(r,n,e,i){var o;if(e!==n.length-1)for(o=n[e]-1;o>=0;o--)t(r[o],n,e+1,i);else i(r)},numeric._foreach2=function t(r,n,e,i){if(e===n.length-1)return i(r);var o,a=n[e],u=Array(a);for(o=a-1;o>=0;o--)u[o]=t(r[o],n,e+1,i);return u},numeric.ops2={add:"+",sub:"-",mul:"*",div:"/",mod:"%",and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">=",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"},numeric.opseq={addeq:"+=",subeq:"-=",muleq:"*=",diveq:"/=",modeq:"%=",lshifteq:"<<=",rshifteq:">>=",rrshifteq:">>>=",bandeq:"&=",boreq:"|=",bxoreq:"^="},numeric.mathfuns=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan","isNaN","isFinite"],numeric.mathfuns2=["atan2","pow","max","min"],numeric.ops1={neg:"-",not:"!",bnot:"~",clone:""},numeric.mapreducers={any:["if(xi) return true;","var accum = false;"],all:["if(!xi) return false;","var accum = true;"],sum:["accum += xi;","var accum = 0;"],prod:["accum *= xi;","var accum = 1;"],norm2Squared:["accum += xi*xi;","var accum = 0;"],norminf:["accum = max(accum,abs(xi));","var accum = 0, max = Math.max, abs = Math.abs;"],norm1:["accum += abs(xi)","var accum = 0, abs = Math.abs;"],sup:["accum = max(accum,xi);","var accum = -Infinity, max = Math.max;"],inf:["accum = min(accum,xi);","var accum = Infinity, min = Math.min;"]},function(){var t,r;for(t=0;ty&&(h=o,y=u);for(n=p[h],p[h]=p[a],p[a]=n,i=m[h],m[h]=m[a],m[a]=i,t=n[a],u=a;u!==l;++u)n[u]/=t;for(u=l-1;-1!==u;--u)i[u]/=t;for(o=f-1;-1!==o;--o)if(o!==a){for(r=p[o],e=m[o],t=r[a],u=a+1;u!==l;++u)r[u]-=n[u]*t;for(u=l-1;u>0;--u)e[u]-=i[u]*t,e[--u]-=i[u]*t;0===u&&(e[0]-=i[0]*t)}}return m},numeric.det=function(t){var r=numeric.dim(t);if(2!==r.length||r[0]!==r[1])throw new Error("numeric: det() only works on square matrices");var n,e,i,o,a,u,s,c,f=r[0],l=1,p=numeric.clone(t);for(e=0;eMath.abs(p[i][e])&&(i=n);for(i!==e&&(s=p[i],p[i]=p[e],p[e]=s,l*=-1),o=p[e],n=e+1;n=1;r-=2){for(i=t[r],e=t[r-1],n=u-1;n>=1;--n)(o=s[n])[r]=i[n],o[r-1]=e[n],(o=s[--n])[r]=i[n],o[r-1]=e[n];0===n&&((o=s[0])[r]=i[0],o[r-1]=e[0])}if(0===r){for(e=t[0],n=u-1;n>=1;--n)s[n][0]=e[n],s[--n][0]=e[n];0===n&&(s[0][0]=e[0])}return s},numeric.negtranspose=function(t){var r,n,e,i,o,a=t.length,u=t[0].length,s=Array(u);for(n=0;n=1;r-=2){for(i=t[r],e=t[r-1],n=u-1;n>=1;--n)(o=s[n])[r]=-i[n],o[r-1]=-e[n],(o=s[--n])[r]=-i[n],o[r-1]=-e[n];0===n&&((o=s[0])[r]=-i[0],o[r-1]=-e[0])}if(0===r){for(e=t[0],n=u-1;n>=1;--n)s[n][0]=-e[n],s[--n][0]=-e[n];0===n&&(s[0][0]=-e[0])}return s},numeric._random=function t(r,n){var e,i,o=r[n],a=Array(o);if(n===r.length-1){for(i=Math.random,e=o-1;e>=1;e-=2)a[e]=i(),a[e-1]=i();return 0===e&&(a[0]=i()),a}for(e=o-1;e>=0;e--)a[e]=t(r,n+1);return a},numeric.random=function(t){return numeric._random(t,0)},numeric.norm2=function(t){return Math.sqrt(numeric.norm2Squared(t))},numeric.linspace=function(t,r,n){if(void 0===n&&(n=Math.max(Math.round(r-t)+1,1)),n<2)return 1===n?[t]:[];var e,i=Array(n);for(e=--n;e>=0;e--)i[e]=(e*r+(n-e)*t)/n;return i},numeric.getBlock=function(t,r,n){var e=numeric.dim(t);return function t(i,o){var a,u=r[o],s=n[o]-u,c=Array(s);if(o===e.length-1){for(a=s;a>=0;a--)c[a]=i[a+u];return c}for(a=s;a>=0;a--)c[a]=t(i[a+u],o+1);return c}(t,0)},numeric.setBlock=function(t,r,n,e){var i=numeric.dim(t);return function t(e,o,a){var u,s=r[a],c=n[a]-s;if(a===i.length-1)for(u=c;u>=0;u--)e[u+s]=o[u];for(u=c;u>=0;u--)t(e[u+s],o[u],a+1)}(t,e,0),t},numeric.getRange=function(t,r,n){var e,i,o,a,u=r.length,s=n.length,c=Array(u);for(e=u-1;-1!==e;--e)for(c[e]=Array(s),o=c[e],a=t[r[e]],i=s-1;-1!==i;--i)o[i]=a[n[i]];return c},numeric.blockMatrix=function(t){var r=numeric.dim(t);if(r.length<4)return numeric.blockMatrix([t]);var n,e,i,o,a,u=r[0],s=r[1];for(n=0,e=0,i=0;i=0;o--){for(i=Array(c),u=t[o],a=c-1;a>=3;--a)i[a]=u*r[a],i[--a]=u*r[a],i[--a]=u*r[a],i[--a]=u*r[a];for(;a>=0;)i[a]=u*r[a],--a;f[o]=i}return f},numeric.T=function(t,r){this.x=t,this.y=r},numeric.t=function(t,r){return new numeric.T(t,r)},numeric.Tbinop=function(t,r,n,e,i){var o;numeric.indexOf;if("string"!=typeof i)for(o in i="",numeric)numeric.hasOwnProperty(o)&&(t.indexOf(o)>=0||r.indexOf(o)>=0||n.indexOf(o)>=0||e.indexOf(o)>=0)&&o.length>1&&(i+="var "+o+" = numeric."+o+";\n");return Function(["y"],"var x = this;\nif(!(y instanceof numeric.T)) { y = new numeric.T(y); }\n"+i+"\nif(x.y) { if(y.y) { return new numeric.T("+e+");\n }\n return new numeric.T("+n+");\n}\nif(y.y) {\n return new numeric.T("+r+");\n}\nreturn new numeric.T("+t+");\n")},numeric.T.prototype.add=numeric.Tbinop("add(x.x,y.x)","add(x.x,y.x),y.y","add(x.x,y.x),x.y","add(x.x,y.x),add(x.y,y.y)"),numeric.T.prototype.sub=numeric.Tbinop("sub(x.x,y.x)","sub(x.x,y.x),neg(y.y)","sub(x.x,y.x),x.y","sub(x.x,y.x),sub(x.y,y.y)"),numeric.T.prototype.mul=numeric.Tbinop("mul(x.x,y.x)","mul(x.x,y.x),mul(x.x,y.y)","mul(x.x,y.x),mul(x.y,y.x)","sub(mul(x.x,y.x),mul(x.y,y.y)),add(mul(x.x,y.y),mul(x.y,y.x))"),numeric.T.prototype.reciprocal=function(){var t=numeric.mul,r=numeric.div;if(this.y){var n=numeric.add(t(this.x,this.x),t(this.y,this.y));return new numeric.T(r(this.x,n),r(numeric.neg(this.y),n))}return new T(r(1,this.x))},numeric.T.prototype.div=function(t){if(t instanceof numeric.T||(t=new numeric.T(t)),t.y)return this.mul(t.reciprocal());var r=numeric.div;return this.y?new numeric.T(r(this.x,t.x),r(this.y,t.x)):new numeric.T(r(this.x,t.x))},numeric.T.prototype.dot=numeric.Tbinop("dot(x.x,y.x)","dot(x.x,y.x),dot(x.x,y.y)","dot(x.x,y.x),dot(x.y,y.x)","sub(dot(x.x,y.x),dot(x.y,y.y)),add(dot(x.x,y.y),dot(x.y,y.x))"),numeric.T.prototype.transpose=function(){var t=numeric.transpose,r=this.x,n=this.y;return n?new numeric.T(t(r),t(n)):new numeric.T(t(r))},numeric.T.prototype.transjugate=function(){var t=numeric.transpose,r=this.x,n=this.y;return n?new numeric.T(t(r),numeric.negtranspose(n)):new numeric.T(t(r))},numeric.Tunop=function(t,r,n){return"string"!=typeof n&&(n=""),Function("var x = this;\n"+n+"\nif(x.y) { "+r+";\n}\n"+t+";\n")},numeric.T.prototype.exp=numeric.Tunop("return new numeric.T(ex)","return new numeric.T(mul(cos(x.y),ex),mul(sin(x.y),ex))","var ex = numeric.exp(x.x), cos = numeric.cos, sin = numeric.sin, mul = numeric.mul;"),numeric.T.prototype.conj=numeric.Tunop("return new numeric.T(x.x);","return new numeric.T(x.x,numeric.neg(x.y));"),numeric.T.prototype.neg=numeric.Tunop("return new numeric.T(neg(x.x));","return new numeric.T(neg(x.x),neg(x.y));","var neg = numeric.neg;"),numeric.T.prototype.sin=numeric.Tunop("return new numeric.T(numeric.sin(x.x))","return x.exp().sub(x.neg().exp()).div(new numeric.T(0,2));"),numeric.T.prototype.cos=numeric.Tunop("return new numeric.T(numeric.cos(x.x))","return x.exp().add(x.neg().exp()).div(2);"),numeric.T.prototype.abs=numeric.Tunop("return new numeric.T(numeric.abs(x.x));","return new numeric.T(numeric.sqrt(numeric.add(mul(x.x,x.x),mul(x.y,x.y))));","var mul = numeric.mul;"),numeric.T.prototype.log=numeric.Tunop("return new numeric.T(numeric.log(x.x));","var theta = new numeric.T(numeric.atan2(x.y,x.x)), r = x.abs();\nreturn new numeric.T(numeric.log(r.x),theta.x);"),numeric.T.prototype.norm2=numeric.Tunop("return numeric.norm2(x.x);","var f = numeric.norm2Squared;\nreturn Math.sqrt(f(x.x)+f(x.y));"),numeric.T.prototype.inv=function(){var t=this;if(void 0===t.y)return new numeric.T(numeric.inv(t.x));var r,n,e,i,o,a,u,s,c,f,l,p,m,h,y,g,d,v,x=t.x.length,b=numeric.identity(x),w=numeric.rep([x,x],0),M=numeric.clone(t.x),A=numeric.clone(t.y);for(c=0;cp&&(l=f,p=m);for(l!==c&&(v=M[c],M[c]=M[l],M[l]=v,v=A[c],A[c]=A[l],A[l]=v,v=b[c],b[c]=b[l],b[l]=v,v=w[c],w[c]=w[l],w[l]=v),r=M[c],n=A[c],o=b[c],a=w[c],h=r[c],y=n[c],f=c+1;f0;c--)for(o=b[c],a=w[c],f=c-1;f>=0;f--)for(u=b[f],s=w[f],h=M[f][c],y=A[f][c],l=x-1;l>=0;l--)g=o[l],d=a[l],u[l]-=h*g-y*d,s[l]-=h*d+y*g;return new numeric.T(b,w)},numeric.T.prototype.get=function(t){var r,n=this.x,e=this.y,i=0,o=t.length;if(e){for(;i=0?1:-1)*numeric.norm2(t);r[0]+=n;var e=numeric.norm2(r);if(0===e)throw new Error("eig: internal error");return numeric.div(r,e)},numeric.toUpperHessenberg=function(t){var r=numeric.dim(t);if(2!==r.length||r[0]!==r[1])throw new Error("numeric: toUpperHessenberg() only works on square matrices");var n,e,i,o,a,u,s,c,f,l,p=r[0],m=numeric.clone(t),h=numeric.identity(p);for(e=0;e0){for(a=numeric.house(o),u=numeric.getBlock(m,[e+1,e],[p-1,p-1]),s=numeric.tensor(a,numeric.dot(a,u)),n=e+1;n=4*s)N=.5*(c+Math.sqrt(c*c-4*s)),E=.5*(c-Math.sqrt(c*c-4*s)),f=numeric.add(numeric.sub(numeric.dot(f,f),numeric.mul(f,N+E)),numeric.diag(numeric.rep([3],N*E)));else f=numeric.add(numeric.sub(numeric.dot(f,f),numeric.mul(f,c)),numeric.diag(numeric.rep([3],s)));for(n=[f[0][0],f[1][0],f[2][0]],e=numeric.house(n),m=[t[0],t[1],t[2]],h=numeric.tensor(e,numeric.dot(e,m)),g=0;g<3;g++)for(p=t[g],y=h[g],v=0;v=0?((g=(a-(p=f<0?-.5*(f-E(l)):-.5*(f+E(l))))*(a-p)+u*u)>(d=s*s+(c-p)*(c-p))?(h=(a-p)/(g=E(g)),y=u/g):(h=s/(d=E(d)),y=(c-p)/d),i=new b([[y,-h],[h,y]]),_.setRows(n,o,i.dot(_.getRows(n,o)))):(p=-.5*f,m=.5*E(-l),(g=(a-p)*(a-p)+u*u)>(d=s*s+(c-p)*(c-p))?(h=(a-p)/(g=E(g+m*m)),y=u/g,p=0,m/=g):(h=s/(d=E(d+m*m)),y=(c-p)/d,p=m/d,m=0),i=new b([[y,-h],[h,y]],[[p,m],[m,-p]]),_.setRows(n,o,i.dot(_.getRows(n,o))))}var S=_.dot(t).dot(_.transjugate()),j=(w=t.length,numeric.T.identity(w));for(o=0;o0)for(e=o-1;e>=0;e--){var B=S.get([e,e]),T=S.get([o,o]);numeric.neq(B.x,T.x)||numeric.neq(B.y,T.y)?(p=S.getRow(e).getBlock([e],[o-1]),m=j.getRow(o).getBlock([e],[o-1]),j.set([o,e],S.get([e,o]).neg().sub(p.dot(m)).div(B.sub(T)))):j.setRow(o,j.getRow(e))}for(o=0;o=o.length;)o[o.length]=0;0!==r[e]&&o[e]++}var a=o.length,u=Array(a+1);for(u[0]=0,n=0;n=s){if(i[f]=m[c],0===c)return;++f,u=l[--c],s=p[c]}else 0===e[a=o[n[u]]]?(e[a]=1,l[c]=u,m[++c]=a,u=r[a],p[c]=s=r[a+1]):++u},numeric.ccsLPSolve=function(t,r,n,e,i,o,a){var u,s,c,f,l,p,m,h,y,g=t[0],d=t[1],v=t[2],x=(g.length,r[0]),b=r[1],w=r[2];for(s=x[i],c=x[i+1],e.length=0,u=s;uo&&(a=i,o=u);for(w(v[n])=c){if(i[l]=o[h[f]],0===f)return;++l,s=p[--f],c=m[f]}else 0===e[u=n[s]]?(e[u]=1,p[f]=s,h[++f]=u,s=r[u=o[u]],m[f]=c=r[u+1]):++s}},numeric.ccsLPSolve0=function(t,r,n,e,i,o,a,u){var s,c,f,l,p,m,h,y,g,d=t[0],v=t[1],x=t[2],b=(d.length,r[0]),w=r[1],M=r[2];for(c=b[i],f=b[i+1],e.length=0,s=c;so&&(a=i,o=u);for(w(v[M[n]])n[e]&&(n[e]=r.length),r)r.hasOwnProperty(i)&&t(r[i],n,e+1);return n},numeric.sclone=function t(r,n,e){void 0===n&&(n=0),void 0===e&&(e=numeric.sdim(r).length);var i,o=Array(r.length);if(n===e-1){for(i in r)r.hasOwnProperty(i)&&(o[i]=r[i]);return o}for(i in r)r.hasOwnProperty(i)&&(o[i]=t(r[i],n+1,e));return o},numeric.sdiag=function(t){var r,n,e=t.length,i=Array(e);for(r=e-1;r>=1;r-=2)n=r-1,i[r]=[],i[r][r]=t[r],i[n]=[],i[n][n]=t[n];return 0===r&&(i[0]=[],i[0][0]=t[r]),i},numeric.sidentity=function(t){return numeric.sdiag(numeric.rep([t],1))},numeric.stranspose=function(t){var r,n,e,i=[];t.length;for(r in t)if(t.hasOwnProperty(r))for(n in e=t[r])e.hasOwnProperty(n)&&("object"!==_typeof(i[n])&&(i[n]=[]),i[n][r]=e[n]);return i},numeric.sLUP=function(t,r){throw new Error("The function numeric.sLUP had a bug in it and has been removed. Please use the new numeric.ccsLUP function instead.")},numeric.sdotMM=function(t,r){var n,e,i,o,a,u,s,c=t.length,f=(r.length,numeric.stranspose(r)),l=f.length,p=Array(c);for(i=c-1;i>=0;i--){for(s=[],n=t[i],a=l-1;a>=0;a--){for(o in u=0,e=f[a],n)n.hasOwnProperty(o)&&o in e&&(u+=n[o]*e[o]);u&&(s[a]=u)}p[i]=s}return p},numeric.sdotMV=function(t,r){var n,e,i,o,a=t.length,u=Array(a);for(e=a-1;e>=0;e--){for(i in o=0,n=t[e])n.hasOwnProperty(i)&&r[i]&&(o+=n[i]*r[i]);o&&(u[e]=o)}return u},numeric.sdotVM=function(t,r){var n,e,i,o,a=[];for(n in t)if(t.hasOwnProperty(n))for(e in i=r[n],o=t[n],i)i.hasOwnProperty(e)&&(a[e]||(a[e]=0),a[e]+=o*i[e]);return a},numeric.sdotVV=function(t,r){var n,e=0;for(n in t)t[n]&&r[n]&&(e+=t[n]*r[n]);return e},numeric.sdot=function(t,r){var n=numeric.sdim(t).length,e=numeric.sdim(r).length;switch(1e3*n+e){case 0:return t*r;case 1001:return numeric.sdotVV(t,r);case 2001:return numeric.sdotMV(t,r);case 1002:return numeric.sdotVM(t,r);case 2002:return numeric.sdotMM(t,r);default:throw new Error("numeric.sdot not implemented for tensors of order "+n+" and "+e)}},numeric.sscatter=function(t){var r,n,e,i,o=t[0].length,a=t.length,u=[];for(n=o-1;n>=0;--n)if(t[a-1][n]){for(i=u,e=0;e=0;--o)n[o]=[];for(o=i;o>=0;--o)n[o].push(e[o]);n[i+1].push(a)}}else t(a,n,e);return e.length>i&&e.pop(),n},numeric.cLU=function(t){var r,n,e,i,o,a,u=t[0],s=t[1],c=t[2],f=u.length,l=0;for(r=0;rl&&(l=u[r]);l++;var p,m=Array(l),h=Array(l),y=numeric.rep([l],1/0),g=numeric.rep([l],-1/0);for(e=0;eg[r]&&(g[r]=n);for(r=0;rg[r+1]&&(g[r+1]=g[r]);for(r=l-1;r>=1;r--)y[r]=0;n--){for(;l[e]>n;)a[n]-=p[e]*a[l[e]],e--;a[n]/=p[e],e--}return a},numeric.cgrid=function(t,r){"number"==typeof t&&(t=[t,t]);var n,e,i,o=numeric.rep(t,-1);if("function"!=typeof r)switch(r){case"L":r=function(r,n){return r>=t[0]/2||ni&&(i=o[e]);for(i++,n=numeric.rep([i],0),e=0;e1;)i[e=a((r+n)/2)]<=t?r=e:n=e;return this._at(t,r)}o=t.length;var u,s=Array(o);for(u=o-1;-1!==u;--u)s[u]=this.at(t[u]);return s},numeric.Spline.prototype.diff=function(){var t,r,n,e=this.x,i=this.yl,o=this.yr,a=this.kl,u=this.kr,s=i.length,c=a,f=u,l=Array(s),p=Array(s),m=numeric.add,h=numeric.mul,y=numeric.div,g=numeric.sub;for(t=s-1;-1!==t;--t)r=e[t+1]-e[t],n=g(o[t+1],i[t]),l[t]=y(m(h(n,6),h(a[t],-4*r),h(u[t+1],-2*r)),r*r),p[t+1]=y(m(h(n,-6),h(a[t],2*r),h(u[t+1],4*r)),r*r);return new numeric.Spline(e,c,f,l,p)},numeric.Spline.prototype.roots=function(){function t(t){return t*t}var r=[],n=this.x,e=this.yl,i=this.yr,o=this.kl,a=this.kr;"number"==typeof e[0]&&(e=[e],i=[i],o=[o],a=[a]);var u,s,c,f,l,p,m,h,y,g,d,v,x,b,w,M,A,_,N,E,S,j,B,T=e.length,z=n.length-1,C=(r=Array(T),Math.sqrt);for(u=0;u!==T;++u){for(f=e[u],l=i[u],p=o[u],m=a[u],h=[],s=0;s!==z;s++){for(s>0&&l[s]*f[s]<0&&h.push(n[s]),M=n[s+1]-n[s],n[s],d=f[s],v=l[s+1],y=p[s]/M,x=(g=m[s+1]/M)+3*d+2*y-3*v,b=3*(g+y+2*(d-v)),(w=t(y-g+3*(d-v))+12*g*d)<=0?A=(_=x/b)>n[s]&&_n[s]&&_n[s]&&N0)S=j,_=N;else{for(var O=0;!((B=(_*j-N*S)/(_-N))<=S||B>=j);)if((E=this._at(B,s))*N>0)j=B,N=E,-1===O&&(_*=.5),O=-1;else{if(!(E*_>0))break;S=B,_=E,1===O&&(N*=.5),O=1}h.push(B),S=A[c+1],_=this._at(S,s)}else h.push(S),S=j,_=N;0===N&&h.push(j)}r[u]=h}return"number"==typeof this.yl[0]?r[0]:r},numeric.spline=function(t,r,n,e){var i,o=t.length,a=[],u=[],s=[],c=numeric.sub,f=numeric.mul,l=numeric.add;for(i=o-2;i>=0;i--)u[i]=t[i+1]-t[i],s[i]=c(r[i+1],r[i]);"string"!=typeof n&&"string"!=typeof e||(n=e="periodic");var p=[[],[],[]];switch(_typeof(n)){case"undefined":a[0]=f(3/(u[0]*u[0]),s[0]),p[0].push(0,0),p[1].push(0,1),p[2].push(2/u[0],1/u[0]);break;case"string":a[0]=l(f(3/(u[o-2]*u[o-2]),s[o-2]),f(3/(u[0]*u[0]),s[0])),p[0].push(0,0,0),p[1].push(o-2,0,1),p[2].push(1/u[o-2],2/u[o-2]+2/u[0],1/u[0]);break;default:a[0]=n,p[0].push(0),p[1].push(0),p[2].push(1)}for(i=1;i20)throw new Error("Numerical gradient fails");if(h[i]=r[i]+x,o=t(h),h[i]=r[i]-x,a=t(h),h[i]=r[i],isNaN(o)||isNaN(a))x/=16;else{if(y[i]=(o-a)/(2*x),u=r[i]-x,s=r[i],c=r[i]+x,f=(o-e)/x,l=(e-a)/x,p=m(g(y[i]),g(e),g(o),g(a),g(u),g(s),g(c),1e-8),!(d(m(g(f-y[i]),g(l-y[i]),g(f-l))/p,x/p)>.001))break;x/=16}}return y},numeric.uncmin=function(t,r,n,e,i,o,a){var u=numeric.gradient;void 0===a&&(a={}),void 0===n&&(n=1e-8),void 0===e&&(e=function(r){return u(t,r)}),void 0===i&&(i=1e3);var s,c,f=(r=numeric.clone(r)).length,l=t(r);if(isNaN(l))throw new Error("uncmin: f(x0) is a NaN!");var p=Math.max,m=numeric.norm2;n=p(n,numeric.epsilon);var h,y,g,d,v,x,b,w,M,A,_=a.Hinv||numeric.identity(f),N=numeric.dot,E=(numeric.inv,numeric.sub),S=numeric.add,j=numeric.tensor,B=numeric.div,T=numeric.mul,z=numeric.all,C=numeric.isFinite,O=numeric.neg,k=0,I="";for(y=e(r);k=.1*M*c||isNaN(s));)M*=.5,++k;if(M*A1;)u[e=i(.5*(r+n))]<=t?r=e:n=e;return this._at(t,r)},numeric.dopri=function(t,r,n,e,i,o,a){void 0===i&&(i=1e-6),void 0===o&&(o=1e3);var u,s,c,f,l,p,m,h,y,g,d,v,x,b=[t],w=[n],M=[e(t,n)],A=[],_=[.075,.225],N=[44/45,-56/15,32/9],E=[19372/6561,-25360/2187,64448/6561,-212/729],S=[9017/3168,-355/33,46732/5247,49/176,-5103/18656],j=[35/384,0,500/1113,125/192,-2187/6784,11/84],B=[.10013431883002395,0,.3918321794184259,-.02982460176594817,.05893268337240795,-.04497888809104361,.023904308236133973],T=[.2,.3,.8,8/9,1,1],z=[-71/57600,0,71/16695,-71/1920,17253/339200,-22/525,.025],C=0,O=(r-t)/10,k=0,I=numeric.add,q=numeric.mul,P=(Math.max,Math.min),F=Math.abs,D=numeric.norminf,U=Math.pow,R=numeric.any,L=numeric.lt,$=numeric.and,V=(numeric.sub,new numeric.Dopri(b,w,M,A,-1,""));for("function"==typeof a&&(d=a(t,n));tr&&(O=r-t),u=e(t+T[0]*O,I(n,q(.2*O,M[C]))),s=e(t+T[1]*O,I(I(n,q(_[0]*O,M[C])),q(_[1]*O,u))),c=e(t+T[2]*O,I(I(I(n,q(N[0]*O,M[C])),q(N[1]*O,u)),q(N[2]*O,s))),f=e(t+T[3]*O,I(I(I(I(n,q(E[0]*O,M[C])),q(E[1]*O,u)),q(E[2]*O,s)),q(E[3]*O,c))),l=e(t+T[4]*O,I(I(I(I(I(n,q(S[0]*O,M[C])),q(S[1]*O,u)),q(S[2]*O,s)),q(S[3]*O,c)),q(S[4]*O,f))),p=e(t+O,y=I(I(I(I(I(n,q(M[C],O*j[0])),q(s,O*j[2])),q(c,O*j[3])),q(f,O*j[4])),q(l,O*j[5]))),(g="number"==typeof(m=I(I(I(I(I(q(M[C],O*z[0]),q(s,O*z[2])),q(c,O*z[3])),q(f,O*z[4])),q(l,O*z[5])),q(p,O*z[6])))?F(m):D(m))>i){if(t+(O=.2*O*U(i/g,.25))===t){V.msg="Step size became too small";break}}else{if(A[C]=I(I(I(I(I(I(n,q(M[C],O*B[0])),q(s,O*B[2])),q(c,O*B[3])),q(f,O*B[4])),q(l,O*B[5])),q(p,O*B[6])),b[++C]=t+O,w[C]=y,M[C]=p,"function"==typeof a){var Z,H,X=t,Y=t+.5*O;if(v=a(Y,A[C-1]),R(x=$(L(d,0),L(0,v)))||(X=Y,d=v,v=a(Y=t+O,y),x=$(L(d,0),L(0,v))),R(x)){for(var J,G,W=0,Q=1,K=1;;){if("number"==typeof d)H=(K*v*X-Q*d*Y)/(K*v-Q*d);else for(H=Y,h=d.length-1;-1!==h;--h)d[h]<0&&v[h]>0&&(H=P(H,(K*v[h]*X-Q*d[h]*Y)/(K*v[h]-Q*d[h])));if(H<=X||H>=Y)break;G=a(H,Z=V._at(H,C-1)),R(J=$(L(d,0),L(0,G)))?(Y=H,v=G,x=J,K=1,-1===W?Q*=.5:Q=1,W=-1):(X=H,d=G,Q=1,1===W?K*=.5:K=1,W=1)}return y=V._at(.5*(t+H),C-1),V.f[C]=e(H,Z),V.x[C]=H,V.y[C]=Z,V.ymid[C-1]=y,V.events=x,V.iterations=k,V}}t+=O,n=y,d=v,O=P(.8*O*U(i/g,.25),4*O)}return V.iterations=k,V},numeric.LU=function(t,r){r=r||!1;var n,e,i,o,a,u,s,c,f,l=Math.abs,p=t.length,m=p-1,h=new Array(p);for(r||(t=numeric.clone(t)),i=0;i=0;--n){for(o=u[n],e=n+1;eI)&&(b=I),f=g(t,p(b,S)),s=h(k,j),C=d-1;-1!==C;--C)s[C][C]+=1;O=B(s,y(f,b),!0);var q=y(T,h(r,O)),P=1;for(C=v-1;-1!==C;--C)q[C]<0&&(P=_(P,-.999*q[C]));if(u=m(o,p(O,P)),!N(E(T=m(n,h(r,u)),0)))return{solution:o,message:"",iterations:c};if(o=u,b=0);if(x)return{solution:u,message:"Unbounded",iterations:c}}return{solution:o,message:"maximum iteration count exceeded",iterations:c}},numeric._solveLP=function(t,r,n,e,i){var o=t.length,a=n.length,u=(numeric.sum,numeric.log,numeric.mul,numeric.sub),s=numeric.dot,c=(numeric.div,numeric.add,numeric.rep([o],0).concat([1])),f=numeric.rep([a,1],-1),l=numeric.blockMatrix([[r,f]]),p=n,m=numeric.rep([o],0).concat(Math.max(0,numeric.sup(numeric.neg(n)))+1),h=numeric.__solveLP(c,l,p,e,i,m,!1),y=numeric.clone(h.solution);if(y.length=o,numeric.inf(u(n,s(r,y)))<0)return{solution:NaN,message:"Infeasible",iterations:h.iterations};var g=numeric.__solveLP(t,r,n,e,i-h.iterations,y,!0);return g.iterations+=h.iterations,g},numeric.solveLP=function(t,r,n,e,i,o,a){if(void 0===a&&(a=1e3),void 0===o&&(o=numeric.epsilon),void 0===e)return numeric._solveLP(t,r,n,o,a);var u,s=e.length,c=e[0].length,f=r.length,l=numeric.echelonize(e),p=numeric.rep([c],0),m=l.P,h=[];for(u=m.length-1;-1!==u;--u)p[m[u]]=1;for(u=c-1;-1!==u;--u)0===p[u]&&h.push(u);var y=numeric.getRange,g=numeric.linspace(0,s-1),d=numeric.linspace(0,f-1),v=y(e,g,h),x=y(r,d,m),b=y(r,d,h),w=numeric.dot,M=numeric.sub,A=w(x,l.I),_=M(b,w(A,v)),N=M(n,w(A,i)),E=Array(m.length),S=Array(h.length);for(u=m.length-1;-1!==u;--u)E[u]=t[m[u]];for(u=h.length-1;-1!==u;--u)S[u]=t[h[u]];var j=M(S,w(E,w(l.I,v))),B=numeric._solveLP(j,_,N,o,a),T=B.solution;if(T!=T)return B;var z=w(l.I,M(i,w(v,T))),C=Array(t.length);for(u=m.length-1;-1!==u;--u)C[m[u]]=z[u];for(u=h.length-1;-1!==u;--u)C[h[u]]=T[u];return{solution:C,message:B.message,iterations:B.iterations}},numeric.MPStoLP=function(t){t instanceof String&&t.split("\n");var r,n,e,i,o=0,a=["Initial state","NAME","ROWS","COLUMNS","RHS","BOUNDS","ENDATA"],u=t.length,s=0,c={},f=[],l=0,p={},m=0,h=[],y=[],g=[];function d(n){throw new Error("MPStoLP: "+n+"\nLine "+r+": "+t[r]+"\nCurrent state: "+a[o]+"\n")}for(r=0;r=o;)t/=2,r/=2,e>>>=1;return(t+e)/r},e},a=r.pow(n,6),i=r.pow(2,i),o=2*i,s(r.random(),t)}([],numeric.seedrandom,256,0,52),function(t){function r(t){if("object"!==_typeof(t))return t;var n,e=[],i=t.length;for(n=0;nf)h[v]=z;else if(h[v]=-Math.abs(z),z>0){for(d=1;d<=e;d+=1)a[d][g]=-a[d][g];u[g]=-u[g]}}for(g=1;g<=p;g+=1)h[N+l[g]]=0;for(S=0,T=0,g=1;g<=c;g+=1)h[N+g]=1;g-=1){for(z=h[g],x=(v=_+g*(g+3)/2)-g,d=g+1;d<=p;d+=1)z-=h[v]*h[A+d],v+=d;if(z/=h[x],h[A+g]=z,l[g]f)h[N+S]=z;else if(h[N+S]=-Math.abs(z),z>0){for(d=1;d<=e;d+=1)a[d][S]=-a[d][S];u[S]=-u[S]}return 700}for(l[p+=1]=S,v=_+(p-1)*p/2+1,g=1;g<=p-1;g+=1)h[v]=h[g],v+=1;if(p===e)h[v]=h[e];else{for(g=e;g>=p+1&&0!==h[g]&&(k=Math.max(Math.abs(h[g-1]),Math.abs(h[g])),I=Math.min(Math.abs(h[g-1]),Math.abs(h[g])),T=h[g-1]>=0?Math.abs(k*Math.sqrt(1+I*I/(k*k))):-Math.abs(k*Math.sqrt(1+I*I/(k*k))),k=h[g-1]/T,I=h[g]/T,1!==k);g-=1)if(0===k)for(h[g-1]=I*T,d=1;d<=e;d+=1)T=t[d][g-1],t[d][g-1]=t[d][g],t[d][g]=T;else for(h[g-1]=T,q=I/(1+k),d=1;d<=e;d+=1)T=k*t[d][g-1]+I*t[d][g],t[d][g]=q*(t[d][g-1]+T)-t[d][g],t[d][g-1]=T;h[v]=h[p]}return 0}function Z(){if(0===h[x=(v=_+w*(w+1)/2+1)+w])return 798;if(k=Math.max(Math.abs(h[x-1]),Math.abs(h[x])),I=Math.min(Math.abs(h[x-1]),Math.abs(h[x])),T=h[x-1]>=0?Math.abs(k*Math.sqrt(1+I*I/(k*k))):-Math.abs(k*Math.sqrt(1+I*I/(k*k))),k=h[x-1]/T,I=h[x]/T,1===k)return 798;if(0===k){for(g=w+1;g<=p;g+=1)T=h[x-1],h[x-1]=h[x],h[x]=T,x+=g;for(g=1;g<=e;g+=1)T=t[g][w],t[g][w]=t[g][w+1],t[g][w+1]=T}else{for(q=I/(1+k),g=w+1;g<=p;g+=1)T=k*h[x-1]+I*h[x],h[x]=q*(h[x-1]+T)-h[x],h[x-1]=T,x+=g;for(g=1;g<=e;g+=1)T=k*t[g][w]+I*t[g][w+1],t[g][w+1]=q*(t[g][w]+T)-t[g][w+1],t[g][w]=T}return 0}function H(){for(x=v-w,g=1;g<=w;g+=1)h[x]=h[v],v+=1,x+=1;return h[E+w]=h[E+w+1],l[w]=l[w+1],(w+=1)(r=Math.abs(r))?t*Math.sqrt(1+r*r/t/t):0==r?t:r*Math.sqrt(1+t*t/r/r)}var g=0,d=0,v=0,x=0,b=0,w=0,M=0;for(o=0;o=0&&(d=-d),v=g*d-M,c[o][o]=g-d,a=s;a=0&&(d=-d),v=g*d-M,c[o][o+1]=g-d,a=s;ax&&(x=b)}for(o=l-1;-1!=o;o+=-1){if(0!=d){for(v=d*c[o][o+1],a=s;a=49)throw"Error: no convergence.";for(x=m[s],d=y(g=(((b=m[u-1])-w)*(b+w)+((d=p[u-1])-(v=p[u]))*(d+v))/(2*v*b),1),g=g<0?((x-w)*(x+w)+v*(b/(g-d)-v))/x:((x-w)*(x+w)+v*(b/(g+d)-v))/x,i=1,M=1,o=s+1;o=0;a--)if(m[a]n&&!c?"Unexpected type of argument in function "+s+" (expected: "+u.join(" or ")+", actual: "+a+", index: "+n+")":"Too few arguments in function "+s+" (expected: "+u.join(" or ")+", index: "+n+")":"Too many arguments in function "+s+" (expected: "+n+", actual: "+r+")";var m=new TypeError(o);return m.data=p,m}function o(t){this.name=t||"refs",this.categories={}}function a(t,r){if("string"==typeof t){var n=t.trim(),e="..."===n.substr(0,3);if(e&&(n=n.substr(3)),""===n)this.types=["any"];else{this.types=n.split("|");for(var i=0;ir&&(r=e)}return r}(e));f.push("function "+p+"("+m.join(", ")+") {"),f.push(' "use strict";'),f.push(" var name = "+JSON.stringify(t||"")+";"),f.push(c.toCode(n," ",!1)),f.push("}");var h=[n.toCode(),"return "+f.join("\n")].join("\n"),y=new Function(n.name,"createError",h)(n,i);return y.signatures=function(t){for(var r={},n=0;n0},a.prototype.contains=function(t){for(var r=0;rr.params.length)return 1;if(t.params.lengtho)return 1;if(i "+i+") {"),e.push(n+" var varArgs = [];"),e.push(n+" for (var i = "+i+"; i < arguments.length; i++) {"),e.push(n+" varArgs.push(arguments[i]);"),e.push(n+" }"),e.push(this.signature.toCode(t,n+" ")),e.push(n+"}");else{for(var u=function(n,e){for(var i=[],o=0;o "+n+") {",r+" throw createError(name, arguments.length, "+n+", arguments["+n+"]);",r+"}"].join("\n");for(var e={},i=[],o=0;ou&&(o=s,u=r[s]);return o},r.exports=o},{"mathjs/core":359,"mathjs/lib/function/arithmetic":383,"mathjs/lib/function/matrix":410,"mathjs/lib/type/matrix":446,"pw-stat":480}],359:[function(t,r,n){arguments[4][49][0].apply(n,arguments)},{"./lib/core/core":360,dup:49}],360:[function(t,r,n){arguments[4][50][0].apply(n,arguments)},{"./../utils/emitter":470,"./../utils/object":475,"./function/config":361,"./function/import":362,"./typed":363,dup:50}],361:[function(t,r,n){arguments[4][51][0].apply(n,arguments)},{"../../utils/object":475,dup:51}],362:[function(t,r,n){arguments[4][52][0].apply(n,arguments)},{"../../error/ArgumentsError":364,"../../utils/object":475,dup:52}],363:[function(t,r,n){arguments[4][53][0].apply(n,arguments)},{"./../utils/bignumber/isBigNumber":463,"./../utils/collection/isMatrix":467,"./../utils/number":474,dup:53,"typed-function":479}],364:[function(t,r,n){arguments[4][54][0].apply(n,arguments)},{dup:54}],365:[function(t,r,n){arguments[4][55][0].apply(n,arguments)},{dup:55}],366:[function(t,r,n){arguments[4][56][0].apply(n,arguments)},{dup:56}],367:[function(t,r,n){arguments[4][57][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:57}],368:[function(t,r,n){arguments[4][58][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm04":450,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex.js":473,"../../utils/object":475,"./addScalar":369,dup:58}],369:[function(t,r,n){arguments[4][59][0].apply(n,arguments)},{dup:59}],370:[function(t,r,n){arguments[4][60][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/collection/deepMap":466,"../utils/isNegative":431,"./unaryMinus":398,dup:60}],371:[function(t,r,n){arguments[4][61][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:61}],372:[function(t,r,n){arguments[4][62][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:62}],373:[function(t,r,n){arguments[4][63][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm14":459,"../../utils/object":475,"../matrix/inv":411,"./divideScalar":374,"./multiply":388,dup:63}],374:[function(t,r,n){arguments[4][64][0].apply(n,arguments)},{"./multiplyScalar":389,dup:64}],375:[function(t,r,n){arguments[4][65][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./divideScalar":374,dup:65}],376:[function(t,r,n){arguments[4][66][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm09":454,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./multiplyScalar":389,dup:66}],377:[function(t,r,n){arguments[4][67][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./pow":392,dup:67}],378:[function(t,r,n){arguments[4][68][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:68}],379:[function(t,r,n){arguments[4][69][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:69}],380:[function(t,r,n){arguments[4][70][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:70}],381:[function(t,r,n){arguments[4][71][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm04":450,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/number":474,dup:71}],382:[function(t,r,n){arguments[4][72][0].apply(n,arguments)},{"../../utils/array":461,"../relational/smaller":430,"../utils/isPositive":432,"./abs":367,"./addScalar":369,"./divideScalar":374,"./multiplyScalar":389,"./sqrt":395,dup:72}],383:[function(t,r,n){arguments[4][73][0].apply(n,arguments)},{"./abs":367,"./add":368,"./addScalar":369,"./cbrt":370,"./ceil":371,"./cube":372,"./divide":373,"./dotDivide":375,"./dotMultiply":376,"./dotPow":377,"./exp":378,"./fix":379,"./floor":380,"./gcd":381,"./hypot":382,"./lcm":384,"./log":385,"./log10":386,"./mod":387,"./multiply":388,"./norm":390,"./nthRoot":391,"./pow":392,"./round":393,"./sign":394,"./sqrt":395,"./square":396,"./subtract":397,"./unaryMinus":398,"./unaryPlus":399,"./xgcd":400,dup:73}],384:[function(t,r,n){arguments[4][74][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm06":452,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/number":474,dup:74}],385:[function(t,r,n){arguments[4][75][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"./divideScalar":374,dup:75}],386:[function(t,r,n){arguments[4][76][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:76}],387:[function(t,r,n){arguments[4][77][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,dup:77}],388:[function(t,r,n){arguments[4][78][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm14":459,"../../utils/array":461,"../../utils/latex":473,"../../utils/object":475,"../relational/equalScalar":428,"./addScalar":369,"./multiplyScalar":389,dup:78}],389:[function(t,r,n){arguments[4][79][0].apply(n,arguments)},{dup:79}],390:[function(t,r,n){arguments[4][80][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../arithmetic/abs":367,"../arithmetic/add":368,"../arithmetic/multiply":388,"../arithmetic/pow":392,"../arithmetic/sqrt":395,"../matrix/trace":423,"../matrix/transpose":424,"../relational/equalScalar":428,"../relational/larger":429,"../relational/smaller":430,dup:80}],391:[function(t,r,n){arguments[4][81][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm02":448,"../../type/matrix/utils/algorithm06":452,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,dup:81}],392:[function(t,r,n){arguments[4][82][0].apply(n,arguments)},{"../../type/fraction/function/fraction":434,"../../type/matrix/function/matrix":444,"../../type/number":460,"../../utils/array":461,"../../utils/latex":473,"../../utils/number":474,"../matrix/eye":406,"./multiply":388,dup:82}],393:[function(t,r,n){arguments[4][83][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm11":456,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm14":459,"../../utils/collection/deepMap":466,"../../utils/number":474,"../matrix/zeros":425,"../relational/equalScalar":428,dup:83}],394:[function(t,r,n){arguments[4][84][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"../../utils/number":474,dup:84}],395:[function(t,r,n){arguments[4][85][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:85}],396:[function(t,r,n){arguments[4][86][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,dup:86}],397:[function(t,r,n){arguments[4][87][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm01":447,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm10":455,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/latex":473,"./addScalar":369,"./unaryMinus":398,dup:87}],398:[function(t,r,n){arguments[4][88][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"../../utils/latex":473,dup:88}],399:[function(t,r,n){arguments[4][89][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"../../utils/latex":473,dup:89}],400:[function(t,r,n){arguments[4][90][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/number":474,dup:90}],401:[function(t,r,n){arguments[4][91][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../error/IndexError":366,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,dup:91}],402:[function(t,r,n){arguments[4][92][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../arithmetic/multiply":388,"../arithmetic/subtract":397,dup:92}],403:[function(t,r,n){arguments[4][93][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/index":472,"../arithmetic/add":368,"../arithmetic/multiply":388,"../arithmetic/subtract":397,"../arithmetic/unaryMinus":398,dup:93}],404:[function(t,r,n){arguments[4][94][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,dup:94}],405:[function(t,r,n){arguments[4][95][0].apply(n,arguments)},{"../../utils/array":461,"../arithmetic/add":368,"../arithmetic/multiply":388,dup:95}],406:[function(t,r,n){arguments[4][96][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,dup:96}],407:[function(t,r,n){arguments[4][97][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/function":471,dup:97}],408:[function(t,r,n){arguments[4][98][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/object":475,dup:98}],409:[function(t,r,n){arguments[4][99][0].apply(n,arguments)},{"../../utils/array":461,"../../utils/function":471,dup:99}],410:[function(t,r,n){arguments[4][100][0].apply(n,arguments)},{"./concat":401,"./cross":402,"./det":403,"./diag":404,"./dot":405,"./eye":406,"./filter":407,"./flatten":408,"./forEach":409,"./inv":411,"./kron":412,"./map":413,"./ones":414,"./partitionSelect":415,"./range":416,"./reshape":417,"./resize":418,"./size":419,"./sort":420,"./squeeze":421,"./subset":422,"./trace":423,"./transpose":424,"./zeros":425,dup:100}],411:[function(t,r,n){arguments[4][101][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/index":472,"../arithmetic/addScalar":369,"../arithmetic/divideScalar":374,"../arithmetic/multiply":388,"../arithmetic/unaryMinus":398,"../matrix/det":403,"./eye":406,dup:101}],412:[function(t,r,n){arguments[4][102][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../arithmetic/multiplyScalar":389,dup:102}],413:[function(t,r,n){arguments[4][103][0].apply(n,arguments)},{"../../utils/function":471,dup:103}],414:[function(t,r,n){arguments[4][104][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,dup:104}],415:[function(t,r,n){arguments[4][105][0].apply(n,arguments)},{"../../utils/number":474,"../relational/compare":426,dup:105}],416:[function(t,r,n){arguments[4][106][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,dup:106}],417:[function(t,r,n){arguments[4][107][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,dup:107}],418:[function(t,r,n){arguments[4][108][0].apply(n,arguments)},{"../../error/ArgumentsError":364,"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,"../../utils/object":475,"../../utils/string":476,dup:108}],419:[function(t,r,n){arguments[4][109][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,dup:109}],420:[function(t,r,n){arguments[4][110][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../relational/compare":426,"../relational/compareNatural":427,dup:110}],421:[function(t,r,n){arguments[4][111][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/object":475,dup:111}],422:[function(t,r,n){arguments[4][112][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/customs":469,"../../utils/object":475,dup:112}],423:[function(t,r,n){arguments[4][113][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/object":475,"../../utils/string":476,"../arithmetic/add":368,dup:113}],424:[function(t,r,n){arguments[4][114][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/latex":473,"../../utils/object":475,"../../utils/string":476,dup:114}],425:[function(t,r,n){arguments[4][115][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../utils/array":461,"../../utils/number":474,dup:115}],426:[function(t,r,n){arguments[4][128][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm05":451,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/number":474,dup:128}],427:[function(t,r,n){arguments[4][129][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../utils/typeof":433,"./compare":426,dup:129,"javascript-natural-sort":48}],428:[function(t,r,n){arguments[4][130][0].apply(n,arguments)},{"../../utils/bignumber/nearlyEqual":464,"../../utils/number":474,dup:130}],429:[function(t,r,n){arguments[4][131][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/latex":473,"../../utils/number":474,dup:131}],430:[function(t,r,n){arguments[4][132][0].apply(n,arguments)},{"../../type/matrix/function/matrix":444,"../../type/matrix/utils/algorithm03":449,"../../type/matrix/utils/algorithm07":453,"../../type/matrix/utils/algorithm12":457,"../../type/matrix/utils/algorithm13":458,"../../type/matrix/utils/algorithm14":459,"../../utils/bignumber/nearlyEqual":464,"../../utils/latex":473,"../../utils/number":474,dup:132}],431:[function(t,r,n){arguments[4][175][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"../../utils/number":474,dup:175}],432:[function(t,r,n){arguments[4][177][0].apply(n,arguments)},{"../../utils/collection/deepMap":466,"../../utils/number":474,dup:177}],433:[function(t,r,n){arguments[4][180][0].apply(n,arguments)},{"../../utils/types":477,dup:180}],434:[function(t,r,n){arguments[4][187][0].apply(n,arguments)},{"../../../utils/collection/deepMap":466,dup:187}],435:[function(t,r,n){arguments[4][188][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../utils/customs":469,"../../utils/index":472,"./Matrix":438,dup:188}],436:[function(t,r,n){arguments[4][189][0].apply(n,arguments)},{"../../function/relational/larger":429,"../../function/relational/smaller":430,dup:189}],437:[function(t,r,n){arguments[4][190][0].apply(n,arguments)},{"../../function/relational/smaller":430,"../../utils/index":472,"./DenseMatrix":435,dup:190}],438:[function(t,r,n){arguments[4][191][0].apply(n,arguments)},{"../../utils/index":472,dup:191}],439:[function(t,r,n){arguments[4][192][0].apply(n,arguments)},{"../../utils/number":474,"../../utils/object":475,dup:192}],440:[function(t,r,n){arguments[4][193][0].apply(n,arguments)},{"../../utils/number":474,dup:193}],441:[function(t,r,n){arguments[4][194][0].apply(n,arguments)},{"../../function/arithmetic/add":368,"../../function/relational/equalScalar":428,dup:194}],442:[function(t,r,n){arguments[4][195][0].apply(n,arguments)},{"../../error/DimensionError":365,"../../function/relational/equalScalar":428,"../../utils/index":472,"./Matrix":438,dup:195}],443:[function(t,r,n){arguments[4][196][0].apply(n,arguments)},{dup:196}],444:[function(t,r,n){arguments[4][197][0].apply(n,arguments)},{dup:197}],445:[function(t,r,n){arguments[4][198][0].apply(n,arguments)},{dup:198}],446:[function(t,r,n){arguments[4][199][0].apply(n,arguments)},{"./DenseMatrix":435,"./FibonacciHeap":436,"./ImmutableDenseMatrix":437,"./Matrix":438,"./MatrixIndex":439,"./Range":440,"./Spa":441,"./SparseMatrix":442,"./function/index":443,"./function/matrix":444,"./function/sparse":445,dup:199}],447:[function(t,r,n){arguments[4][200][0].apply(n,arguments)},{"../../../error/DimensionError":365,dup:200}],448:[function(t,r,n){arguments[4][201][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,dup:201}],449:[function(t,r,n){arguments[4][202][0].apply(n,arguments)},{"../../../error/DimensionError":365,dup:202}],450:[function(t,r,n){arguments[4][203][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,dup:203}],451:[function(t,r,n){arguments[4][204][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,dup:204}],452:[function(t,r,n){arguments[4][205][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,"./../../../utils/collection/scatter":468,dup:205}],453:[function(t,r,n){arguments[4][206][0].apply(n,arguments)},{"../../../error/DimensionError":365,dup:206}],454:[function(t,r,n){arguments[4][207][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../function/relational/equalScalar":428,dup:207}],455:[function(t,r,n){arguments[4][208][0].apply(n,arguments)},{dup:208}],456:[function(t,r,n){arguments[4][209][0].apply(n,arguments)},{"../../../function/relational/equalScalar":428,dup:209}],457:[function(t,r,n){arguments[4][210][0].apply(n,arguments)},{dup:210}],458:[function(t,r,n){arguments[4][211][0].apply(n,arguments)},{"../../../error/DimensionError":365,"../../../utils/index":472,dup:211}],459:[function(t,r,n){arguments[4][212][0].apply(n,arguments)},{"../../../utils/object":475,dup:212}],460:[function(t,r,n){arguments[4][213][0].apply(n,arguments)},{"./../utils/collection/deepMap":466,dup:213}],461:[function(t,r,n){arguments[4][214][0].apply(n,arguments)},{"../error/DimensionError":365,"../error/IndexError":366,"./number":474,"./object":475,"./string":476,"./types":477,dup:214}],462:[function(t,r,n){arguments[4][215][0].apply(n,arguments)},{dup:215}],463:[function(t,r,n){arguments[4][216][0].apply(n,arguments)},{dup:216}],464:[function(t,r,n){arguments[4][217][0].apply(n,arguments)},{dup:217}],465:[function(t,r,n){arguments[4][218][0].apply(n,arguments)},{dup:218}],466:[function(t,r,n){arguments[4][221][0].apply(n,arguments)},{dup:221}],467:[function(t,r,n){arguments[4][223][0].apply(n,arguments)},{dup:223}],468:[function(t,r,n){arguments[4][225][0].apply(n,arguments)},{dup:225}],469:[function(t,r,n){arguments[4][226][0].apply(n,arguments)},{"./object":475,dup:226}],470:[function(t,r,n){arguments[4][227][0].apply(n,arguments)},{dup:227,"tiny-emitter":478}],471:[function(t,r,n){arguments[4][228][0].apply(n,arguments)},{dup:228}],472:[function(t,r,n){arguments[4][229][0].apply(n,arguments)},{"./array":461,"./boolean":465,"./emitter":470,"./function":471,"./number":474,"./object":475,"./string":476,"./types":477,dup:229}],473:[function(t,r,n){arguments[4][230][0].apply(n,arguments)},{dup:230,"escape-latex":45}],474:[function(t,r,n){arguments[4][231][0].apply(n,arguments)},{dup:231}],475:[function(t,r,n){arguments[4][232][0].apply(n,arguments)},{"./bignumber/isBigNumber":463,dup:232}],476:[function(t,r,n){arguments[4][233][0].apply(n,arguments)},{"./bignumber/formatter":462,"./bignumber/isBigNumber":463,"./number":474,dup:233}],477:[function(t,r,n){arguments[4][234][0].apply(n,arguments)},{dup:234}],478:[function(t,r,n){arguments[4][356][0].apply(n,arguments)},{dup:356}],479:[function(t,r,n){arguments[4][357][0].apply(n,arguments)},{dup:357}],480:[function(t,r,n){"use strict";n.cov=function(t){for(var r=t.length,n=[],e=0;e=s;)t/=2,r/=2,n>>>=1;return(t+n)/r}},r.exports.resetGlobal=function(){Math.random=f},p(Math.random(),i)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],482:[function(t,r,n){arguments[4][356][0].apply(n,arguments)},{dup:356}],483:[function(t,r,n){arguments[4][357][0].apply(n,arguments)},{dup:357}],484:[function(t,r,n){"use strict";r.exports=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531],[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]]},{}],485:[function(t,r,n){"use strict";var e=t("defaults"),i=t("./combining"),o={nul:0,control:0};function a(t,r){if("string"!=typeof t)return u(t,r);for(var n=0,e=0;e=127&&t<160?r.control:function(t){var r,n=0,e=i.length-1;if(ti[e][1])return!1;for(;e>=n;)if(r=Math.floor((n+e)/2),t>i[r][1])n=r+1;else{if(!(t=4352&&(t<=4447||9001==t||9002==t||t>=11904&&t<=42191&&12351!=t||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65040&&t<=65049||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=65504&&t<=65510||t>=131072&&t<=196605||t>=196608&&t<=262141))}r.exports=function(t){return a(t,o)},r.exports.config=function(t){return t=e(t||{},o),function(r){return a(r,t)}}},{"./combining":484,defaults:43}]},{},[1])(1)}); \ No newline at end of file diff --git a/docs/docs/api.md b/docs/docs/api.md index eaa5bb9..cf7a670 100644 --- a/docs/docs/api.md +++ b/docs/docs/api.md @@ -8,7 +8,7 @@ * [.logvar(window, [dimension])](#module_bcijs.features.logvar) * [.variance(window, [dimension])](#module_bcijs.features.variance) * [.rootMeanSquare(window, [dimension])](#module_bcijs.features.rootMeanSquare) - * [.averageBandPowers(samples, sampleRate, bands, [fftSize])](#module_bcijs.averageBandPowers) ⇒ Array.<number> + * [.bandpower(samples, sample_rate, bands, options)](#module_bcijs.bandpower) ⇒ number \| Array.<number> \| Array.<Array.<number>> * [.cspLearn(class1, class2)](#module_bcijs.cspLearn) ⇒ Object * [.cspProject(cspParams, data, [dimensions])](#module_bcijs.cspProject) ⇒ Array.<Array.<number>> * [.fastICA(signals, options)](#module_bcijs.fastICA) ⇒ Object @@ -17,9 +17,7 @@ * [.ldaLearn(class1, class2)](#module_bcijs.ldaLearn) ⇒ Object * [.ldaProject(ldaParams, point)](#module_bcijs.ldaProject) ⇒ number * [.nextpow2(num)](#module_bcijs.nextpow2) ⇒ number - * [.psd(signal, [options])](#module_bcijs.psd) ⇒ Array.<number> - * [.psdBandPower(psd, sampleRate, band, [fftSize])](#module_bcijs.psdBandPower) ⇒ number - * [.signalBandPower(samples, sampleRate, bands, [options])](#module_bcijs.signalBandPower) ⇒ number + * [.periodogram(signal, sample_rate, [options])](#module_bcijs.periodogram) ⇒ Object * [.transpose(array)](#module_bcijs.transpose) ⇒ Array * [.loadCSV(filePath)](#module_bcijs.loadCSV) ⇒ Promise * [.loadEDF(filename)](#module_bcijs.loadEDF) ⇒ Object @@ -97,24 +95,29 @@ Computes the root mean square along the specified dimension | window | Array.<number> \| Array.<Array.<number>> | | The data | | [dimension] | string | null | If 'rows' or 'columns' passed, the features are calculated along that dimension | - + -### bcijs.averageBandPowers(samples, sampleRate, bands, [fftSize]) ⇒ Array.<number> -Computes the power in each frequency band averaged across all channels +### bcijs.bandpower(samples, sample_rate, bands, options) ⇒ number \| Array.<number> \| Array.<Array.<number>> +Calculate the bandpower of a signal or multiple signals in the specified frequency bands. Uses a modified periodogram with a Hann window by default. (see: bci.periodogram()) Bandpower is calculated as the area under the PSD curve estimated using the rectangular method. Units of bandpower are the square of the input signal's units. If the input signal has units of μV, then the bandpower estimate has units μV^2. Returns absolute power by default. Relative band power (absolute power divided by total power in the signal) can be calculated by passing the option {relative: true}. You can also pass custom PSD estimates instead of directly passing the signal. This may be useful if you wish to use your own PSD estimation method of choice, such as Welch's method. In this case, pass a single PSD array or pass multiple PSDs in the same form as multiple signals (columns are channels). Then be sure to pass the option {input: 'psd'}. Example usages are provided below. **Kind**: static method of [bcijs](#module_bcijs) -**Returns**: Array.<number> - Array containing the average power across all channels in each band +**Returns**: number \| Array.<number> \| Array.<Array.<number>> - Bandpower | array of bandpowers if an array of bands is passed as input for a single signal or multiple signals are passed with a single band | array of array of powers for each band if multiple signals are passed | Param | Type | Default | Description | | --- | --- | --- | --- | -| samples | Array.<Array.<number>> | | The signals where rows are samples and columns are electrodes | -| sampleRate | number | | Sample rate of the data | -| bands | Array | | An array of frequency bands. See signalBandPower for more info on frequency bands. | -| [fftSize] | number | | The size of the fft to use. See signalBandPower for more info on fft sizes. | +| samples | Array.<number> \| Array.<Array.<number>> | | An array of samples, ex: [1,2,3,4, ...], or, in the case of multiple channels, ex (2 channels): [[1,2], [3,4], [5,6], ...] | +| sample_rate | number | | Sample rate | +| bands | string \| Array | | The frequency band provided as an array [frequencyStart, frequencyStop] or a string 'delta' (1-3 Hz), 'theta' (4-7 Hz), 'alpha' (8-12 Hz), 'beta' (13-30 Hz), or 'gamma' (31-50 Hz). | +| options | object | | | +| [options.fftSize] | number | Math.pow(2, bci.nextpow2(signal.length)) | Size of the fft to be used. Should be a power of 2. | +| [options.average] | boolean | false | Average powers across channels. Default is false. | +| [options.input] | boolean | 'samples' | Input type. Can be either 'samples' (default) or 'psd'. If you already have a PSD calculated, you can pass the estimates as an array with the input type 'psd'. You can also pass the entire PSD object if it was calculated using the bci.periodogram method, and the input type of 'psd' will be inferred. | +| [options.relative] | boolean | false | Calculate relative bandpower instead of absolute bandpower. Default is false. | +| [options.window] | number | 'hann' | Window function to apply, either 'hann' or 'rectangular'. Default is 'hann'. | **Example** ```js -let feature = bci.averageBandPowers(samples, 256, ['alpha', 'beta']); // returns [alpha_power_averaged_across_channels, beta_power_averaged_across_channels] +// Single signal example let samples = [0.23, 0.14, 0.78, ...]; let sample_rate = 256; // Hz bandpower(samples, sample_rate, 'alpha'); // returns power, ex: 1.652 bandpower(samples, sample_rate, ['alpha', 'beta']); // returns an array with the powers in the alpha and beta bands. Ex: [1.473, 0.383] // 2 channel example samples = [[0.1, 0.3], [0.4, 0.2], [0.6, 0.5], ...] bandpower(samples, sample_rate, 'alpha'); // returns an array of alpha powers for each channel, ex: [1.342, 0.342] bandpower(samples, sample_rate, ['alpha', 'beta']); // returns an array of arrays of powers in each band, ex: [[1.342, 0.342], [0.245, 1.343]]. // The first array is an array of alpha powers for channels 1 and 2 // The second array is an array of beta powers for channels 1 and 2 bandpower(samples, sample_rate, ['alpha', 'beta'], {average: true}); // Calculate average alpha across all channels and average beta across all channels // Returns a value such as [0.842, 0.794] // Note these are the average of [1.342, 0.342] and the average of [0.245, 1.343] from the previous example ``` @@ -249,56 +252,22 @@ Returns the ceil of the log2 of the absolute value of the passed number ```js nextpow2(8); // 3 nextpow2(9); // 4 nextpow2(16); // 4 nextpow2(30); // 5 nextpow2(0); // -Infinity ``` - + -### bcijs.psd(signal, [options]) ⇒ Array.<number> -Compute the power spectral density of a given signal. +### bcijs.periodogram(signal, sample_rate, [options]) ⇒ Object +Estimates the power spectral density of a real-valued input signal using the periodogram method and a rectangular window. Output units are based on that of the input signal, of the form X^2/Hz, where X is the units of the input signal. For example, if the input is an EEG signal measured in μV, then this method returns values of μV^2/Hz. **Kind**: static method of [bcijs](#module_bcijs) -**Returns**: Array.<number> - The PSD. +**Returns**: Object - Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies) | Param | Type | Default | Description | | --- | --- | --- | --- | | signal | Array.<number> | | The signal. | +| sample_rate | number | | sample rate in Hz | | [options] | Object | | | | [options.fftSize] | number | Math.pow(2, bci.nextpow2(signal.length)) | Size of the fft to be used. Should be a power of 2. | -| [options.truncate] | boolean | false | If true, only the first half of the PSD array is returned | - - - -### bcijs.psdBandPower(psd, sampleRate, band, [fftSize]) ⇒ number -Compute the average power across a given frequency band given the PSD. - -**Kind**: static method of [bcijs](#module_bcijs) -**Returns**: number - The average power in the frequency band. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| psd | Array.<number> | | Power spectral density of the signal. | -| sampleRate | number | | The sample rate of the signal. | -| band | Array.<number> \| string | | The frequency band provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. | -| [fftSize] | number | Math.pow(2, bci.nextpow2(psd.length)) | Size of the fourier transform used to compute the PSD. | - - - -### bcijs.signalBandPower(samples, sampleRate, bands, [options]) ⇒ number -Compute the average power across a given frequency band in a signal. - -**Kind**: static method of [bcijs](#module_bcijs) -**Returns**: number - The average power in the frequency band. - -| Param | Type | Default | Description | -| --- | --- | --- | --- | -| samples | Array.<number> \| Array.<Array.<number>> | | The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals. | -| sampleRate | number | | The sample rate of the signal. | -| bands | Array \| string | | The frequency band or array of bands, where a single band is provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz).
While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. | -| [options] | Object | | | -| [options.fftSize] | number | Math.pow(2, bci.nextpow2(signal.length)) | Size of the fft to be used. Should be a power of 2. | +| [options.window] | number | 'rectangular' | Window function to apply, either 'hann' or 'rectangular'. Default is 'rectangular'. | -**Example** -```js -// Example outputs are rounded // Single signal examples let sampleRate = 512; let signal = bci.generateSignal([2,16], [10,20], sampleRate, 1); // Get a single power in one band console.log(bci.signalBandPower(signal, sampleRate, 'alpha')); // returns 102.4 // Specify a custom band as an array (Ex: 8 Hz - 12 Hz) console.log(bci.signalBandPower(signal, sampleRate, [8, 12])); // returns 102.4 // Obtain multiple band powers console.log(bci.signalBandPower(signal, sampleRate, ['alpha', 'beta'])); // returns [ 102.4, 227.6 ] // Multiple band powers works with custom bands too console.log(bci.signalBandPower(signal, sampleRate, [[8, 12], [13, 30]])); // returns [ 102.4, 227.6 ] // Works with multiple signals too (example with 2 signals) let signal2 = bci.generateSignal([16, 2], [10, 20], 512, 1); let samples = bci.transpose([signal, signal2]); console.log(bci.signalBandPower(samples, sampleRate, 'alpha')); // Returns an array containing the alpha value for each signal console.log(bci.signalBandPower(samples, sampleRate, ['alpha', 'beta', 'gamma'])); // Returns a 2d array with number_of_bands rows and number_of_signals columns -``` ### bcijs.transpose(array) ⇒ Array diff --git a/docs/docs/deprecated.md b/docs/docs/deprecated.md index c4bae4e..9ea6319 100644 --- a/docs/docs/deprecated.md +++ b/docs/docs/deprecated.md @@ -20,7 +20,11 @@ * [.clear()](#module_bcijs.signal.EEGWindow+clear) * [.getPSD(size, signal)](#module_bcijs.signal.getPSD) ⇒ Array.<number> * [.getBandPower(size, psd, sampleRate, band)](#module_bcijs.signal.getBandPower) ⇒ number + * ~~[.averageBandPowers(samples, sampleRate, bands, [fftSize])](#module_bcijs.averageBandPowers) ⇒ Array.<number>~~ * ~~[.f1score(confusionMatrix)](#module_bcijs.f1score) ⇒ number~~ + * ~~[.psd(signal, [options])](#module_bcijs.psd) ⇒ Array.<number>~~ + * ~~[.psdBandPower(psd, sampleRate, band, [fftSize])](#module_bcijs.psdBandPower) ⇒ number~~ + * ~~[.signalBandPower(samples, sampleRate, bands, [options])](#module_bcijs.signalBandPower) ⇒ number~~ @@ -214,6 +218,27 @@ Compute the average power across a given frequency band given the PSD. | sampleRate | number | The sample rate of the signal. | | band | Array.<number> \| string | The frequency band provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. | + + +### ~~bcijs.averageBandPowers(samples, sampleRate, bands, [fftSize]) ⇒ Array.<number>~~ +***Deprecated*** + +Deprecated, please use bci.bandpower() for output in proper units. The functionality of this method has been replaced with the 'bandpower' method. See the docs for 'bandpower' for more information. Computes the average magnitude across each frequency band averaged across all channels Use bci.bandpower() for band power in proper units (signal units squared). + +**Kind**: static method of [bcijs](#module_bcijs) +**Returns**: Array.<number> - Array containing the average power across all channels in each band + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| samples | Array.<Array.<number>> | | The signals where rows are samples and columns are electrodes | +| sampleRate | number | | Sample rate of the data | +| bands | Array | | An array of frequency bands. See signalBandPower for more info on frequency bands. | +| [fftSize] | number | | The size of the fft to use. See signalBandPower for more info on fft sizes. | + +**Example** +```js +let feature = bci.averageBandPowers(samples, 256, ['alpha', 'beta']); // returns [alpha_power_averaged_across_channels, beta_power_averaged_across_channels] +``` ### ~~bcijs.f1score(confusionMatrix) ⇒ number~~ @@ -228,3 +253,59 @@ Calculate the f1 score of a binary classifier given its confusion matrix This m | --- | --- | --- | | confusionMatrix | Array.<Array.<number>> | a 2x2 confusion matrix | + + +### ~~bcijs.psd(signal, [options]) ⇒ Array.<number>~~ +***Deprecated*** + +The functionality of this method has been replaced with the 'periodogram' method. See the docs for 'periodogram' for more information. Computes the magnitude of each frequency bin of the FFT. Units are that of the input signal. For example, if the input signal is measured in μV, then this method returns values in μV. As a PSD (particularly for EEG data) would be expected to return units of μV^2/Hz, this method has been deprecated to avoid confusion. It has been replaced with the periodogram method, which returns units of μV^2/Hz. + +**Kind**: static method of [bcijs](#module_bcijs) +**Returns**: Array.<number> - magnitude of each frequency bin of the FFT + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| signal | Array.<number> | | The signal. | +| [options] | Object | | | +| [options.fftSize] | number | Math.pow(2, bci.nextpow2(signal.length)) | Size of the fft to be used. Should be a power of 2. | +| [options.truncate] | boolean | false | If true, only the first half of the PSD array is returned | + + + +### ~~bcijs.psdBandPower(psd, sampleRate, band, [fftSize]) ⇒ number~~ +***Deprecated*** + +Deprecated, please use bci.bandpower() for output in proper units. The functionality of this method has been replaced with the 'bandpower' method. See the docs for 'bandpower' for more information. Computes the average magnitude across each frequency band given the output of the PSD method. + +**Kind**: static method of [bcijs](#module_bcijs) +**Returns**: number - The average power in the frequency band. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| psd | Array.<number> | | Power spectral density of the signal. | +| sampleRate | number | | The sample rate of the signal. | +| band | Array.<number> \| string | | The frequency band provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. | +| [fftSize] | number | Math.pow(2, bci.nextpow2(psd.length)) | Size of the fourier transform used to compute the PSD. | + + + +### ~~bcijs.signalBandPower(samples, sampleRate, bands, [options]) ⇒ number~~ +***Deprecated*** + +Deprecated, please use bci.bandpower() for output in proper units. The functionality of this method has been replaced with the 'bandpower' method. See the docs for 'bandpower' for more information. Computes the average magnitude across each frequency band. + +**Kind**: static method of [bcijs](#module_bcijs) +**Returns**: number - The average power in the frequency band. + +| Param | Type | Default | Description | +| --- | --- | --- | --- | +| samples | Array.<number> \| Array.<Array.<number>> | | The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals. | +| sampleRate | number | | The sample rate of the signal. | +| bands | Array \| string | | The frequency band or array of bands, where a single band is provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz).
While string representations allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in future updates. | +| [options] | Object | | | +| [options.fftSize] | number | Math.pow(2, bci.nextpow2(signal.length)) | Size of the fft to be used. Should be a power of 2. | + +**Example** +```js +// Example outputs are rounded // Single signal examples let sampleRate = 512; let signal = bci.generateSignal([2,16], [10,20], sampleRate, 1); // Get a single power in one band console.log(bci.signalBandPower(signal, sampleRate, 'alpha')); // returns 102.4 // Specify a custom band as an array (Ex: 8 Hz - 12 Hz) console.log(bci.signalBandPower(signal, sampleRate, [8, 12])); // returns 102.4 // Obtain multiple band powers console.log(bci.signalBandPower(signal, sampleRate, ['alpha', 'beta'])); // returns [ 102.4, 227.6 ] // Multiple band powers works with custom bands too console.log(bci.signalBandPower(signal, sampleRate, [[8, 12], [13, 30]])); // returns [ 102.4, 227.6 ] // Works with multiple signals too (example with 2 signals) let signal2 = bci.generateSignal([16, 2], [10, 20], 512, 1); let samples = bci.transpose([signal, signal2]); console.log(bci.signalBandPower(samples, sampleRate, 'alpha')); // Returns an array containing the alpha value for each signal console.log(bci.signalBandPower(samples, sampleRate, ['alpha', 'beta', 'gamma'])); // Returns a 2d array with number_of_bands rows and number_of_signals columns +``` diff --git a/docs/docs/index.html b/docs/docs/index.html index 14f377b..d110b11 100644 --- a/docs/docs/index.html +++ b/docs/docs/index.html @@ -80,7 +80,7 @@

-

Classes

Modules

+

Classes

Modules

@@ -112,7 +112,7 @@

Classes

  • BCI.js is a library for EEG-based brain computer interface (BCI) design with JavaScript and Node.js. It allows for the creation of BCI enabled web apps or Node.js applications, with features such as:

      -
    • Signal processing and machine learning (LDA, CSP, ICA, PSD, etc.)
    • +
    • Signal processing and machine learning (Bandpower, PSD, LDA, CSP, ICA, etc.)
    • Data manipulation (MATLAB style array subscripting, data windowing, CSV file support, etc.)
    • Networking (data collection, streaming via OSC, etc.)
    @@ -122,7 +122,7 @@

    Getting Started

    npm install bcijs
     

    Browser

    -
    <script src="https://cdn.jsdelivr.net/npm/bcijs@1.6.5/dist/bci.min.js"></script>
    +
    <script src="https://cdn.jsdelivr.net/npm/bcijs@1.7.0/dist/bci.min.js"></script>
     

    Tutorials

      @@ -136,7 +136,7 @@

      Signal Processing

      // Generate 1 second of sample data let sampleRate = 512; let duration = 1; -let amplitudes = [1, 2, 4, 8]; +let amplitudes = [8, 4, 2, 1]; let frequencies = [ 1, // 1 Hz, delta range 5, // 5 Hz, theta range @@ -146,21 +146,22 @@

      Signal Processing

      let signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration); -// Compute average power in each frequency band -let fftSize = sampleRate * duration; -let bandpowers = bci.signalBandPower( +// Compute relative power in each frequency band +let bandpowers = bci.bandpower( signal, sampleRate, ['delta', 'theta', 'alpha', 'beta'], - {fftSize: fftSize} // optional, defaults to next power of 2 larger than or equal to signal length + {relative: true} ); console.log(bandpowers); /* -[ 85.33333333333366, - 128.00000000000122, - 204.80000000000047, - 113.77777777777825 ] +[ + 0.7171876695851037, + 0.22444067394892755, + 0.04489131763080717, + 0.013469490282877555 +] */

    Machine Learning

    @@ -239,7 +240,7 @@

    Data Manipulation and Feature Extraction

    Usage in the web

    BCI.js can be loaded from the jsDelivr CDN with

    -
    <script src="https://cdn.jsdelivr.net/npm/bcijs@1.6.5/dist/bci.min.js"></script>
    +
    <script src="https://cdn.jsdelivr.net/npm/bcijs@1.7.0/dist/bci.min.js"></script>
     

    You can also find bci.js and bci.min.js in the /dist directory.

    BCI.js methods are accessible via the global object bci.

    @@ -253,6 +254,7 @@

    Requiring specific methods

    BCI.js methods can be found in the lib/ directory.

    Documentation

    Documentation can be found at https://bci.js.org/docs or by viewing api.md

    +

    Deprecated methods can be found at deprecated.md

    Building

    See dev.md for info on how to modify and build BCI.js

    Reference

    @@ -277,7 +279,7 @@

    Contact


    diff --git a/docs/docs/index.js.html b/docs/docs/index.js.html index cc9e6e8..e4a3e4e 100644 --- a/docs/docs/index.js.html +++ b/docs/docs/index.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -98,13 +98,17 @@

    // This file was auto generated, changes will be overwritten
    -// Created on Sat Nov 09 2019 13:46:57 GMT-0600 (Central Standard Time)
    +// Created on Sat Apr 11 2020 09:57:09 GMT-0400 (Eastern Daylight Time)
     /** @module bcijs */
    +module.exports.averageBandPowers = require('./lib/compat/averageBandPowers.js');
     module.exports.csp = require('./lib/compat/csp.js');
     module.exports.f1score = require('./lib/compat/f1score.js');
     module.exports.lda = require('./lib/compat/lda.js');
     module.exports.network = require('./lib/compat/network.js');
    +module.exports.psd = require('./lib/compat/psd.js');
    +module.exports.psdBandPower = require('./lib/compat/psdBandPower.js');
     module.exports.signal = require('./lib/compat/signal.js');
    +module.exports.signalBandPower = require('./lib/compat/signalBandPower.js');
     module.exports.loadCSV = require('./lib/data/loadCSV.js');
     module.exports.loadEDF = require('./lib/data/loadEDF.js');
     module.exports.partition = require('./lib/data/partition.js');
    @@ -114,7 +118,7 @@ 

    module.exports.toFixed = require('./lib/data/toFixed.js'); module.exports.toTable = require('./lib/data/toTable.js'); module.exports.windowApply = require('./lib/data/windowApply.js'); -module.exports.averageBandPowers = require('./lib/math/averageBandPowers.js'); +module.exports.bandpower = require('./lib/math/bandpower.js'); module.exports.cspLearn = require('./lib/math/cspLearn.js'); module.exports.cspProject = require('./lib/math/cspProject.js'); module.exports.fastICA = require('./lib/math/fastICA.js'); @@ -124,9 +128,7 @@

    module.exports.ldaLearn = require('./lib/math/ldaLearn.js'); module.exports.ldaProject = require('./lib/math/ldaProject.js'); module.exports.nextpow2 = require('./lib/math/nextpow2.js'); -module.exports.psd = require('./lib/math/psd.js'); -module.exports.psdBandPower = require('./lib/math/psdBandPower.js'); -module.exports.signalBandPower = require('./lib/math/signalBandPower.js'); +module.exports.periodogram = require('./lib/math/periodogram.js'); module.exports.transpose = require('./lib/math/transpose.js'); module.exports.accuracy = require('./lib/metrics/accuracy.js'); module.exports.balancedAccuracy = require('./lib/metrics/balancedAccuracy.js'); @@ -156,7 +158,7 @@


    diff --git a/docs/docs/lib_data_loadCSV.js.html b/docs/docs/lib_data_loadCSV.js.html index e91d00a..296fbce 100644 --- a/docs/docs/lib_data_loadCSV.js.html +++ b/docs/docs/lib_data_loadCSV.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -135,7 +135,7 @@


    diff --git a/docs/docs/lib_data_loadEDF.js.html b/docs/docs/lib_data_loadEDF.js.html index ee9f791..abb85fe 100644 --- a/docs/docs/lib_data_loadEDF.js.html +++ b/docs/docs/lib_data_loadEDF.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -165,7 +165,7 @@


    diff --git a/docs/docs/lib_data_partition.js.html b/docs/docs/lib_data_partition.js.html index 3715d51..3e4d1da 100644 --- a/docs/docs/lib_data_partition.js.html +++ b/docs/docs/lib_data_partition.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -134,7 +134,7 @@


    diff --git a/docs/docs/lib_data_round.js.html b/docs/docs/lib_data_round.js.html index 64873c2..727aa1a 100644 --- a/docs/docs/lib_data_round.js.html +++ b/docs/docs/lib_data_round.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -130,7 +130,7 @@


    diff --git a/docs/docs/lib_data_saveCSV.js.html b/docs/docs/lib_data_saveCSV.js.html index 5f4c6b2..fcbae18 100644 --- a/docs/docs/lib_data_saveCSV.js.html +++ b/docs/docs/lib_data_saveCSV.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -129,7 +129,7 @@


    diff --git a/docs/docs/lib_data_subscript.js.html b/docs/docs/lib_data_subscript.js.html index d272afc..d26174f 100644 --- a/docs/docs/lib_data_subscript.js.html +++ b/docs/docs/lib_data_subscript.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -192,7 +192,7 @@


    diff --git a/docs/docs/lib_data_toFixed.js.html b/docs/docs/lib_data_toFixed.js.html index d56cb86..b600221 100644 --- a/docs/docs/lib_data_toFixed.js.html +++ b/docs/docs/lib_data_toFixed.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -130,7 +130,7 @@


    diff --git a/docs/docs/lib_data_toTable.js.html b/docs/docs/lib_data_toTable.js.html index 4f61891..4623f18 100644 --- a/docs/docs/lib_data_toTable.js.html +++ b/docs/docs/lib_data_toTable.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -122,7 +122,7 @@


    diff --git a/docs/docs/lib_data_windowApply.js.html b/docs/docs/lib_data_windowApply.js.html index 2fcdc7e..309deb5 100644 --- a/docs/docs/lib_data_windowApply.js.html +++ b/docs/docs/lib_data_windowApply.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -151,7 +151,7 @@


    diff --git a/docs/docs/lib_math_averageBandPowers.js.html b/docs/docs/lib_math_averageBandPowers.js.html index 8062677..82972a7 100644 --- a/docs/docs/lib_math_averageBandPowers.js.html +++ b/docs/docs/lib_math_averageBandPowers.js.html @@ -101,7 +101,15 @@

    const signalBandPower = require('./signalBandPower.js'); /** - * Computes the power in each frequency band averaged across all channels + * The functionality of this method has been replaced with the 'bandpower' method. + * See the docs for 'bandpower' for more information. + * + * Computes the average magnitude across each frequency band averaged across all channels + * Units are that of the input signal. For example, if the input signal is measured + * in μV, then this method returns values in μV. + * + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0 + * * @memberof module:bcijs * @param {number[][]} samples - The signals where rows are samples and columns are electrodes * @param {number} sampleRate - Sample rate of the data diff --git a/docs/docs/lib_math_bandpower.js.html b/docs/docs/lib_math_bandpower.js.html new file mode 100644 index 0000000..baf6daa --- /dev/null +++ b/docs/docs/lib_math_bandpower.js.html @@ -0,0 +1,346 @@ + + + + + + + + + + + lib/math/bandpower.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    + lib/math/bandpower.js +

    + + + + + +
    +
    +
    const periodogram = require('./periodogram.js');
    +const transpose = require('./transpose.js');
    +const nextpow2 = require('./nextpow2.js');
    +
    +/**
    + * Integrate area under the curve using the rectangle method
    + * @private
    + * @param {number[]} x - Array of samples
    + * @param {number} [dx=1] - Spacing between points. Default is 1.
    + * @returns area under the curve 
    + */
    +function integrate(x, dx = 1) {
    +    let sum = 0;
    +    for(let i = 0; i < x.length; i++) {
    +        sum += x[i];
    +    }
    +    return sum * dx;
    +}
    +
    +/**
    + * Given a mixed array of strings and bands, ex: ['alpha', [4,10], 'beta']
    + * Or simply a string, ex: 'alpha'
    + * Or simple a band, ex: [4,10]
    + * Reduce it to a common format of number[][].
    + * Examples:
    + * input => output
    + * ['alpha', [4, 10], 'beta'] => [[8, 12], [4, 10], [13, 30]]
    + * 'alpha' => [[8, 12]]
    + * [4, 10] => [[4, 10]] 
    + * @private
    + * @param {string|Array} bands 
    + */
    +function reduceBands(bands) { 
    +    let band_names = {
    +		// From Dan Szafir's "Pay Attention!", 2012
    +		'delta': [1, 3],
    +		'theta': [4, 7],
    +		'alpha': [8, 12],
    +		'beta': [13, 30],
    +		'gamma': [31, 50]
    +    };
    +    
    +    // If they pass only a string or only a single band
    +    // Example: 'alpha' or [4, 10]
    +    if(typeof bands === 'string' || typeof bands[0] === 'number') {
    +        bands = [bands];
    +    }
    +
    +    // For each item in the array, replace a string with its matching band
    +    return bands.map(band => {
    +        if(typeof band === 'string') {
    +            let band_as_numbers = band_names[band];
    +            if(band_as_numbers) return band_as_numbers;
    +            throw new Error('Invalid band type passed');
    +        }
    +
    +        return band;
    +    });
    +}
    +
    +/**
    + * Calculate the bandpower of a signal or multiple signals in the specified frequency bands.
    + * 
    + * Uses a modified periodogram with a Hann window by default. (see: bci.periodogram())
    + * Bandpower is calculated as the area under the PSD curve estimated using the rectangular method.
    + * 
    + * Units of bandpower are the square of the input signal's units. If the input signal has units of μV,
    + * then the bandpower estimate has units μV^2.
    + * 
    + * Returns absolute power by default. Relative band power (absolute power divided by total power in the signal)
    + * can be calculated by passing the option {relative: true}. 
    + * 
    + * You can also pass custom PSD estimates instead of directly passing the signal. This may be useful if you wish
    + * to use your own PSD estimation method of choice, such as Welch's method. In this case, pass a single PSD array
    + * or pass multiple PSDs in the same form as multiple signals (columns are channels). Then be sure to pass the option {input: 'psd'}.
    + * 
    + * Example usages are provided below.
    + * 
    + * @memberof module:bcijs
    + * @param {number[]|number[][]} samples - An array of samples, ex: [1,2,3,4, ...], or, in the case of multiple channels, ex (2 channels): [[1,2], [3,4], [5,6], ...]
    + * @param {number} sample_rate - Sample rate
    + * @param {string|Array} bands - The frequency band provided as an array [frequencyStart, frequencyStop] or a string 'delta' (1-3 Hz), 'theta' (4-7 Hz), 'alpha' (8-12 Hz), 'beta' (13-30 Hz), or 'gamma' (31-50 Hz).
    + * @param {object} options
    + * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2.
    + * @param {boolean} [options.average=false] - Average powers across channels. Default is false.
    + * @param {boolean} [options.input='samples'] - Input type. Can be either 'samples' (default) or 'psd'. If you already have a PSD calculated, you can pass the estimates as an array with the input type 'psd'. You can also pass the entire PSD object if it was calculated using the bci.periodogram method, and the input type of 'psd' will be inferred.
    + * @param {boolean} [options.relative=false] - Calculate relative bandpower instead of absolute bandpower. Default is false.
    + * @param {number} [options.window='hann'] - Window function to apply, either 'hann' or 'rectangular'. Default is 'hann'.
    + * @returns {number|number[]|number[][]} Bandpower | array of bandpowers if an array of bands is passed as input for a single signal or multiple signals are passed with a single band | array of array of powers for each band if multiple signals are passed
    + * 
    + * @example
    + * // Single signal example
    + * let samples = [0.23, 0.14, 0.78, ...];
    + * let sample_rate = 256; // Hz
    + * 
    + * bandpower(samples, sample_rate, 'alpha'); // returns power, ex: 1.652
    + * bandpower(samples, sample_rate, ['alpha', 'beta']); // returns an array with the powers in the alpha and beta bands. Ex: [1.473, 0.383]
    + * 
    + * // 2 channel example
    + * samples = [[0.1, 0.3], [0.4, 0.2], [0.6, 0.5], ...]
    + * 
    + * bandpower(samples, sample_rate, 'alpha'); // returns an array of alpha powers for each channel, ex: [1.342, 0.342]
    + * 
    + * bandpower(samples, sample_rate, ['alpha', 'beta']);
    + * // returns an array of arrays of powers in each band, ex: [[1.342, 0.342], [0.245, 1.343]].
    + * // The first array is an array of alpha powers for channels 1 and 2
    + * // The second array is an array of beta powers for channels 1 and 2
    + * 
    + * bandpower(samples, sample_rate, ['alpha', 'beta'], {average: true});
    + * // Calculate average alpha across all channels and average beta across all channels
    + * // Returns a value such as [0.842, 0.794]
    + * // Note these are the average of [1.342, 0.342] and the average of [0.245, 1.343] from the previous example
    + */
    +function bandpower(samples, sample_rate, bands, options) {
    +    // Determine signal length
    +    let signal_length = samples.length;
    +    if(samples.estimates) {
    +        signal_length = samples.estimates.length;
    +    }
    +
    +    // Handle default options
    +    let {fftSize, average, input, relative, window} = Object.assign({
    +        fftSize: Math.pow(2, nextpow2(signal_length)),
    +        average: false,
    +        input: 'samples',
    +        relative: false,
    +        window: 'hann'
    +    }, options);
    +
    +    // If they passed a PSD object, enforce the input type 'psd'
    +    if(options && options['input'] == 'samples' && !Array.isArray(samples)) {
    +        throw new Error('Expecting array of samples when input type of \'samples\' is passed');
    +    }
    +
    +    if(samples.estimates) {
    +        samples = samples.estimates;
    +        input = 'psd';
    +    }
    +
    +    // Check FFT size
    +    if(fftSize < samples.length) {
    +        throw new Error('fftSize must be greater than or equal to the length of samples');
    +    }
    +    
    +    // If matrix with muliple signals, process each signal
    +    if(Array.isArray(samples[0])) {
    +        let channels = transpose(samples);
    +        
    +        let powers = channels.map(channel => bandpower(channel, sample_rate, bands, options));
    +
    +        // Handle the 2D case (multiple channels and multiple bands)
    +        if(Array.isArray(powers[0])) {
    +            // Return to same row/col format as input (channels are columns)
    +            powers = transpose(powers);
    +
    +            // Instead of calculating, for example, alpha power at each channel, calculate the average alpha
    +            // across all channels.
    +            if(average) {
    +                for(let i = 0; i < powers.length; i++) {
    +                    let sum = 0;
    +                    for(let j = 0; j < powers[i].length; j++) {
    +                        sum += powers[i][j];
    +                    }
    +                    powers[i] = sum / powers[i].length;
    +                }
    +            }
    +        }
    +
    +        return powers;
    +    }
    +
    +    // Start by calculating the PSD
    +    let psd;
    +    if(input == 'samples') {
    +        psd = periodogram(samples, sample_rate, {fftSize: fftSize, window: window});
    +    } else if(input == 'psd') {
    +        if(Array.isArray(samples)) {
    +            psd = {estimates: samples};
    +        } else {
    +            throw new Error('Invalid PSD');
    +        }
    +    } else {
    +        throw new Error('Invalid input type');
    +    }
    +
    +    // Clean up 'bands' so it is a number[][] (array of bands where a band is [low, high])
    +    let original_bands = bands;
    +    bands = reduceBands(bands);
    +
    +    // Calculate the total power for relative power calculation if selected in options
    +    let total_power = 1;
    +    let dx = sample_rate / fftSize;
    +    if(relative) {
    +        total_power = integrate(psd.estimates, dx);
    +    }
    +
    +    // Calculate area in each band
    +    let areas = new Array(bands.lenth);
    +    
    +    for(let i = 0; i < bands.length; i++) {
    +        // Get the proper section of the periodogram
    +        let band = bands[i];
    +
    +        let low_index = Math.floor(band[0] / sample_rate * fftSize);
    +        let high_index = Math.min(Math.ceil(band[1] / sample_rate * fftSize), psd.estimates.length - 1);
    +        
    +        let psd_band = psd.estimates.slice(low_index, high_index + 1);
    +
    +        if(psd_band.length < 2) {
    +            throw new Error('Unable to calculate power in specified bands. Please increase fftSize or sample length');
    +        }
    +
    +        areas[i] = integrate(psd_band, dx) / total_power;
    +    }
    +
    +    // If they only passed a single band (not an array of bands), then the array of areas will
    +    // have a length of 1. Return the single power value, not an array.
    +    if(typeof original_bands === 'string' || typeof original_bands[0] === 'number') {
    +        return areas[0];
    +    }
    +
    +    return areas;
    +}
    +
    +module.exports = bandpower;
    +
    +
    +
    + + + + +
    + +
    + + + + + + + + + + diff --git a/docs/docs/lib_math_cspLearn.js.html b/docs/docs/lib_math_cspLearn.js.html index f626bf6..08a6685 100644 --- a/docs/docs/lib_math_cspLearn.js.html +++ b/docs/docs/lib_math_cspLearn.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -138,7 +138,7 @@


    diff --git a/docs/docs/lib_math_cspProject.js.html b/docs/docs/lib_math_cspProject.js.html index 0ffc59b..b305ed9 100644 --- a/docs/docs/lib_math_cspProject.js.html +++ b/docs/docs/lib_math_cspProject.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -155,7 +155,7 @@


    diff --git a/docs/docs/lib_math_fastICA.js.html b/docs/docs/lib_math_fastICA.js.html index 73f53c4..ba37d46 100644 --- a/docs/docs/lib_math_fastICA.js.html +++ b/docs/docs/lib_math_fastICA.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -276,7 +276,7 @@


    diff --git a/docs/docs/lib_math_features.js.html b/docs/docs/lib_math_features.js.html index 4e42e84..2956859 100644 --- a/docs/docs/lib_math_features.js.html +++ b/docs/docs/lib_math_features.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -109,7 +109,6 @@

    math.import(require('mathjs/lib/function/arithmetic')); math.import(require('mathjs/lib/function/statistics')); -const sbp = require('./signalBandPower.js'); const transpose = require('./transpose.js'); /** @@ -195,7 +194,7 @@


    diff --git a/docs/docs/lib_math_generateSignal.js.html b/docs/docs/lib_math_generateSignal.js.html index 9d30ecf..9a216dd 100644 --- a/docs/docs/lib_math_generateSignal.js.html +++ b/docs/docs/lib_math_generateSignal.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -144,7 +144,7 @@


    diff --git a/docs/docs/lib_math_ldaClassify.js.html b/docs/docs/lib_math_ldaClassify.js.html index ef84c76..5ffd306 100644 --- a/docs/docs/lib_math_ldaClassify.js.html +++ b/docs/docs/lib_math_ldaClassify.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -137,7 +137,7 @@


    diff --git a/docs/docs/lib_math_ldaLearn.js.html b/docs/docs/lib_math_ldaLearn.js.html index 9ce5983..ff0651f 100644 --- a/docs/docs/lib_math_ldaLearn.js.html +++ b/docs/docs/lib_math_ldaLearn.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -144,7 +144,7 @@


    diff --git a/docs/docs/lib_math_ldaProject.js.html b/docs/docs/lib_math_ldaProject.js.html index 44ecfeb..e580a4c 100644 --- a/docs/docs/lib_math_ldaProject.js.html +++ b/docs/docs/lib_math_ldaProject.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -125,7 +125,7 @@


    diff --git a/docs/docs/lib_math_nextpow2.js.html b/docs/docs/lib_math_nextpow2.js.html index 01674cf..3281055 100644 --- a/docs/docs/lib_math_nextpow2.js.html +++ b/docs/docs/lib_math_nextpow2.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -125,7 +125,7 @@


    diff --git a/docs/docs/lib_math_periodogram.js.html b/docs/docs/lib_math_periodogram.js.html new file mode 100644 index 0000000..a90e324 --- /dev/null +++ b/docs/docs/lib_math_periodogram.js.html @@ -0,0 +1,228 @@ + + + + + + + + + + + lib/math/periodogram.js - Documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    + lib/math/periodogram.js +

    + + + + + +
    +
    +
    const fft = require('fft.js');
    +const nextpow2 = require('./nextpow2.js');
    +
    +let fftCache = {};
    +
    +/**
    + * Apply a Hann window to a signal
    + * @private
    + */
    +function hann(signal) {
    +    let windowed = [];
    +    let L = signal.length - 1;
    +    let C = Math.PI / L;
    +
    +    let scale = 0;
    +
    +    for(let i = 0; i < signal.length; i++) {
    +        let w = Math.sin(C * i) ** 2;
    +        windowed.push(signal[i] * w);
    +        scale += w ** 2;
    +    }
    +
    +    return {signal: windowed, scale: scale};
    +}
    +
    +/** 
    + * Estimates the power spectral density of a real-valued input signal using the periodogram method and a rectangular window.
    + * Output units are based on that of the input signal, of the form X^2/Hz, where X is the units of the input signal.
    + * For example, if the input is an EEG signal measured in μV, then this method returns values of μV^2/Hz.
    + * 
    + * @memberof module:bcijs
    + * @param {number[]} signal - The signal.
    + * @param {number} sample_rate - sample rate in Hz
    + * @param {Object} [options]
    + * @param {number} [options.fftSize=Math.pow(2, bci.nextpow2(signal.length))] - Size of the fft to be used. Should be a power of 2.
    + * @param {number} [options.window='rectangular'] - Window function to apply, either 'hann' or 'rectangular'. Default is 'rectangular'.
    + * @returns {Object} Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies)
    + */
    +function periodogram(signal, sample_rate, options) {
    +	let {fftSize, window} = Object.assign({
    +        fftSize: Math.pow(2, nextpow2(signal.length)),
    +        window: 'rectangular'
    +	}, options);
    +
    +	let f;
    +	if (fftCache.hasOwnProperty(fftSize)) {
    +		f = fftCache[fftSize];
    +	} else {
    +		f = new fft(fftSize);
    +		fftCache[fftSize] = f;
    +    }
    +    
    +    // Apply window
    +    let num_samples = signal.length;
    +    let S = num_samples;
    +    if(window == 'hann') {
    +        let h = hann(signal);
    +        signal = h.signal;
    +        S = h.scale;
    +    } else if(window != 'rectangular') {
    +        throw new Error('Unknown window type');
    +    }
    +
    +    // Zero pad signal to fftSize if needed
    +	if (num_samples < fftSize) {
    +		signal = signal.concat(Array(fftSize - signal.length).fill(0));
    +	}
    +
    +    // Complex array [real, imag, real, imag, etc.]
    +    let freqs = f.createComplexArray();
    +    
    +    // Fill in complex array with the FFT values
    +	f.realTransform(freqs, signal);
    +    f.completeSpectrum(freqs);
    +    
    +    // Get the power of each FFT bin value
    +    let powers = [];
    +    let scaling_factor = 2 / (sample_rate * S);
    +	for (var i = 0; i < freqs.length - 1; i += 2) {
    +        // magnitude is sqrt(real^2 + imag^2)
    +        let magnitude = Math.sqrt(freqs[i] ** 2 + freqs[i + 1] ** 2);
    +
    +        // apply scaling
    +        let power = scaling_factor * magnitude ** 2;
    +
    +		powers.push(power);
    +    }
    +
    +    // Toss values past Nyquist
    +    powers = powers.slice(0, powers.length / 2 + 1);
    +
    +    // Don't scale DC or Nyquist by 2
    +    powers[0] /= 2;
    +    powers[powers.length - 1] /= 2;
    +    
    +    // Compute frequencies
    +    let frequencies = new Array(powers.length);
    +    for(let i = 0; i < frequencies.length; i++) {
    +        frequencies[i] = i * (sample_rate / fftSize);
    +    }
    +
    +	return {
    +        estimates: powers,
    +        frequencies: frequencies
    +    };
    +}
    +
    +module.exports = periodogram;
    +
    +
    + + + + +
    + +
    + + + + + + + + + + diff --git a/docs/docs/lib_math_psd.js.html b/docs/docs/lib_math_psd.js.html index ec4eee5..0dc76c5 100644 --- a/docs/docs/lib_math_psd.js.html +++ b/docs/docs/lib_math_psd.js.html @@ -103,7 +103,18 @@

    var fftCache = {}; /** - * Compute the power spectral density of a given signal. + * The functionality of this method has been replaced with the 'periodogram' method. + * See the docs for 'periodogram' for more information. + * + * Computes the magnitude of each frequency bin of the FFT. Units are that of the input signal. + * For example, if the input signal is measured in μV, then this method returns values in μV. + * + * As a PSD (particularly for EEG data) would be expected to return units of of μV^2/Hz, this method has + * been deprecated to avoid confusion. It has been replaced with the periodogram method, which returns units + * of μV^2/Hz. + * + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0 + * * @memberof module:bcijs * @param {number[]} signal - The signal. * @param {Object} [options] @@ -132,6 +143,7 @@

    var freqs = f.createComplexArray(); f.realTransform(freqs, signal); + f.completeSpectrum(freqs); if(truncate){ var powers = getPowers(freqs, freqs.length / 2); }else{ diff --git a/docs/docs/lib_math_psdBandPower.js.html b/docs/docs/lib_math_psdBandPower.js.html index 8e436bf..accf0e3 100644 --- a/docs/docs/lib_math_psdBandPower.js.html +++ b/docs/docs/lib_math_psdBandPower.js.html @@ -100,7 +100,17 @@

    var nextpow2 = require('./nextpow2.js');
     
     /**
    + * The functionality of this method has been replaced with the 'bandpower' method.
    + * See the docs for 'bandpower' for more information.
    + * 
    + * Computes the average magnitude across each frequency band given the output of the PSD method.
    + * Units are that of the input signal. For example, if the input signal is measured
    + * in μV, then this method returns values in μV.
    + * 
      * Compute the average power across a given frequency band given the PSD.
    + * 
    + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0
    + * 
      * @memberof module:bcijs
      * @param {number[]} psd - Power spectral density of the signal.
      * @param {number} sampleRate - The sample rate of the signal.
    diff --git a/docs/docs/lib_math_signalBandPower.js.html b/docs/docs/lib_math_signalBandPower.js.html
    index fbbaa77..f1e7939 100644
    --- a/docs/docs/lib_math_signalBandPower.js.html
    +++ b/docs/docs/lib_math_signalBandPower.js.html
    @@ -103,7 +103,15 @@ 

    const transpose = require('./transpose.js'); /** - * Compute the average power across a given frequency band in a signal. + * The functionality of this method has been replaced with the 'bandpower' method. + * See the docs for 'bandpower' for more information. + * + * Computes the average magnitude across each frequency band. + * Units are that of the input signal. For example, if the input signal is measured + * in μV, then this method returns values in μV. + * + * @deprecated Deprecated since version 1.7.0, will be removed in version 2.0.0 + * * @memberof module:bcijs * @param {number[]|number[][]} samples - The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals. * @param {number} sampleRate - The sample rate of the signal. diff --git a/docs/docs/lib_math_transpose.js.html b/docs/docs/lib_math_transpose.js.html index cbb1d67..c8a2cb1 100644 --- a/docs/docs/lib_math_transpose.js.html +++ b/docs/docs/lib_math_transpose.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -137,7 +137,7 @@


    diff --git a/docs/docs/lib_metrics_accuracy.js.html b/docs/docs/lib_metrics_accuracy.js.html index 03994c9..698a384 100644 --- a/docs/docs/lib_metrics_accuracy.js.html +++ b/docs/docs/lib_metrics_accuracy.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -132,7 +132,7 @@


    diff --git a/docs/docs/lib_metrics_balancedAccuracy.js.html b/docs/docs/lib_metrics_balancedAccuracy.js.html index ea5800f..f37cf91 100644 --- a/docs/docs/lib_metrics_balancedAccuracy.js.html +++ b/docs/docs/lib_metrics_balancedAccuracy.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -126,7 +126,7 @@


    diff --git a/docs/docs/lib_metrics_confusionMatrix.js.html b/docs/docs/lib_metrics_confusionMatrix.js.html index fdb5d79..3f8b1a6 100644 --- a/docs/docs/lib_metrics_confusionMatrix.js.html +++ b/docs/docs/lib_metrics_confusionMatrix.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -142,7 +142,7 @@


    diff --git a/docs/docs/lib_metrics_f1.js.html b/docs/docs/lib_metrics_f1.js.html index 2df76b4..72ea0dd 100644 --- a/docs/docs/lib_metrics_f1.js.html +++ b/docs/docs/lib_metrics_f1.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -130,7 +130,7 @@


    diff --git a/docs/docs/lib_metrics_mcc.js.html b/docs/docs/lib_metrics_mcc.js.html index ef86fd4..6cc5a8d 100644 --- a/docs/docs/lib_metrics_mcc.js.html +++ b/docs/docs/lib_metrics_mcc.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -129,7 +129,7 @@


    diff --git a/docs/docs/lib_metrics_precision.js.html b/docs/docs/lib_metrics_precision.js.html index 34398a1..b76c478 100644 --- a/docs/docs/lib_metrics_precision.js.html +++ b/docs/docs/lib_metrics_precision.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -124,7 +124,7 @@


    diff --git a/docs/docs/lib_metrics_recall.js.html b/docs/docs/lib_metrics_recall.js.html index 4d8493f..8f8795d 100644 --- a/docs/docs/lib_metrics_recall.js.html +++ b/docs/docs/lib_metrics_recall.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -124,7 +124,7 @@


    diff --git a/docs/docs/lib_metrics_specificity.js.html b/docs/docs/lib_metrics_specificity.js.html index bed620c..71c04f6 100644 --- a/docs/docs/lib_metrics_specificity.js.html +++ b/docs/docs/lib_metrics_specificity.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -124,7 +124,7 @@


    diff --git a/docs/docs/lib_network_oscCollect.js.html b/docs/docs/lib_network_oscCollect.js.html index beada74..7d7f6b3 100644 --- a/docs/docs/lib_network_oscCollect.js.html +++ b/docs/docs/lib_network_oscCollect.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -153,7 +153,7 @@


    diff --git a/docs/docs/lib_network_oscHeaderScan.js.html b/docs/docs/lib_network_oscHeaderScan.js.html index 5b0bfae..513ce5d 100644 --- a/docs/docs/lib_network_oscHeaderScan.js.html +++ b/docs/docs/lib_network_oscHeaderScan.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -142,7 +142,7 @@


    diff --git a/docs/docs/lib_network_oscStream.js.html b/docs/docs/lib_network_oscStream.js.html index f1521cf..e6d39d1 100644 --- a/docs/docs/lib_network_oscStream.js.html +++ b/docs/docs/lib_network_oscStream.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -162,7 +162,7 @@


    diff --git a/docs/docs/lib_network_prompt.js.html b/docs/docs/lib_network_prompt.js.html index 76f65e3..34e51fb 100644 --- a/docs/docs/lib_network_prompt.js.html +++ b/docs/docs/lib_network_prompt.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -134,7 +134,7 @@


    diff --git a/docs/docs/lib_network_wait.js.html b/docs/docs/lib_network_wait.js.html index 979bf9e..5369524 100644 --- a/docs/docs/lib_network_wait.js.html +++ b/docs/docs/lib_network_wait.js.html @@ -82,7 +82,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -117,7 +117,7 @@


    diff --git a/docs/docs/module-bcijs.features.html b/docs/docs/module-bcijs.features.html index 8dafcc5..b49372a 100644 --- a/docs/docs/module-bcijs.features.html +++ b/docs/docs/module-bcijs.features.html @@ -80,7 +80,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -369,7 +369,7 @@
    Parameters:
    @@ -584,7 +584,7 @@
    Parameters:
    @@ -799,7 +799,7 @@
    Parameters:
    @@ -844,7 +844,7 @@
    Parameters:

    diff --git a/docs/docs/module-bcijs.html b/docs/docs/module-bcijs.html index ae09371..d874a92 100644 --- a/docs/docs/module-bcijs.html +++ b/docs/docs/module-bcijs.html @@ -80,7 +80,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -328,13 +328,13 @@
    Returns:
    - + -

    - (static) averageBandPowers(samples, sampleRate, bands, fftSizeopt) → {Array.<number>} +

    + (static) balancedAccuracy(confusionMatrix) → {number}

    @@ -343,7 +343,7 @@

    -

    Computes the power in each frequency band averaged across all channels

    +

    Calculate the balanced accuracy of a classifier given its confusion matrix as defined by the confusionMatrix method

    @@ -365,12 +365,8 @@

    Parameters:
    Type - Attributes - - Default - Description @@ -380,7 +376,7 @@
    Parameters:
    - samples + confusionMatrix @@ -397,150 +393,11 @@
    Parameters:
    - - - - - - - - - - - - - - - - -

    The signals where rows are samples and columns are electrodes

    - - - - - - - - sampleRate - - - - - - - number - - - - - - - - - - - - - - - - - - - - - - - - - -

    Sample rate of the data

    - - - - - - - - bands - - - - - - - Array - - - - - - - - - - - - - - - - - - - - - - - - - -

    An array of frequency bands. See signalBandPower for more info on frequency bands.

    - - - - - - - - fftSize - - - - - - - number - - - - - - - - - - - - <optional>
    - - - - - - - - - - null - - - -

    The size of the fft to use. See signalBandPower for more info on fft sizes.

    +

    a confusion matrix

    @@ -584,7 +441,7 @@
    Parameters:
    @@ -613,7 +470,7 @@
    Returns:
    -

    Array containing the average power across all channels in each band

    +

    The balanced accuracy

    @@ -623,7 +480,7 @@
    Returns:
    - Array.<number> + number @@ -636,20 +493,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    let feature = bci.averageBandPowers(samples, 256, ['alpha', 'beta']);
    // returns [alpha_power_averaged_across_channels, beta_power_averaged_across_channels]
    - - -
    - @@ -658,13 +501,13 @@
    Example
    - + -

    - (static) balancedAccuracy(confusionMatrix) → {number} +

    + (static) bandpower(samples, sample_rate, bands, options) → {number|Array.<number>|Array.<Array.<number>>}

    @@ -673,7 +516,17 @@

    -

    Calculate the balanced accuracy of a classifier given its confusion matrix as defined by the confusionMatrix method

    +

    Calculate the bandpower of a signal or multiple signals in the specified frequency bands.

    +

    Uses a modified periodogram with a Hann window by default. (see: bci.periodogram()) +Bandpower is calculated as the area under the PSD curve estimated using the rectangular method.

    +

    Units of bandpower are the square of the input signal's units. If the input signal has units of μV, +then the bandpower estimate has units μV^2.

    +

    Returns absolute power by default. Relative band power (absolute power divided by total power in the signal) +can be calculated by passing the option {relative: true}.

    +

    You can also pass custom PSD estimates instead of directly passing the signal. This may be useful if you wish +to use your own PSD estimation method of choice, such as Welch's method. In this case, pass a single PSD array +or pass multiple PSDs in the same form as multiple signals (columns are channels). Then be sure to pass the option {input: 'psd'}.

    +

    Example usages are provided below.

    @@ -706,12 +559,18 @@

    Parameters:
    - confusionMatrix + samples + + Array.<number> + + + | + Array.<Array.<number>> @@ -727,142 +586,103 @@
    Parameters:
    -

    a confusion matrix

    +

    An array of samples, ex: [1,2,3,4, ...], or, in the case of multiple channels, ex (2 channels): [[1,2], [3,4], [5,6], ...]

    - - + + + sample_rate + + + + + + number + + + + -
    + - + - + +

    Sample rate

    + + + - + + + + bands + - + + + + + string + - + | - + + Array + - - - - - - - - - - - - - -
    Source:
    -
    - -
    - - - - - - - -
    + + + + + + +

    The frequency band provided as an array [frequencyStart, frequencyStop] or a string 'delta' (1-3 Hz), 'theta' (4-7 Hz), 'alpha' (8-12 Hz), 'beta' (13-30 Hz), or 'gamma' (31-50 Hz).

    + + + + + + + options + + + + + + object + + - - - -
    Returns:
    + + -
    -

    The balanced accuracy

    -
    - - - -
    -
    Type
    -
    - - - number - - - - - -
    -
    - - - - - - - - - - - - - - - -

    - (static) confusionMatrix(predictedClasses, actualClasses) → {Array.<Array.<number>>} -

    -
    - - - - - -
    -

    Generate a confusion matrix C where rows are actual classes and columns are predicted classes. -C = [ -[true negative, false positive], -[false negative, true positive] -].

    -

    If two classes are passed, class 0 represents the negative case, and class 1 represents the positive case. -If more than two classes are passed, an NxN confusion matrix is returned where N is the number of classes.

    -
    - - - - - - - -
    Parameters:
    - + + + +
    Properties
    + @@ -874,8 +694,12 @@
    Parameters:
    + + + + @@ -885,14 +709,14 @@
    Parameters:
    - + + + + + + @@ -914,14 +754,14 @@
    Parameters:
    - + + + + + - -
    TypeAttributesDefaultDescription
    predictedClassesfftSize - Array.<number> + number @@ -902,11 +726,27 @@
    Parameters:
    + + <optional>
    + + + + +
    + + Math.pow(2, bci.nextpow2(signal.length)) + + -

    An array of predicted classes, with class numbers starting at 0

    +

    Size of the fft to be used. Should be a power of 2.

    actualClassesaverage - Array.<number> + boolean @@ -931,171 +771,87 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + false + + -

    An array of the actual classes, with class numbers starting at 0

    +

    Average powers across channels. Default is false.

    - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Source:
    -
    - -
    - - - - - - - -
    - - - - - - - - - - - - - -
    Returns:
    - + + + input -
    -

    The confusion matrix

    -
    - - -
    -
    Type
    -
    - + + + - Array.<Array.<number>> + boolean -
    -
    - - - - - + + - + + + <optional>
    + + - - - - - - - - -

    - (static) cspLearn(class1, class2) → {Object} -

    -
    - - - - - -
    -

    Learn common spatial pattern (CSP) for two datasets. -Check out https://bci.js.org/examples/csp/ for an interactive example of how CSP works.

    -
    - - - - - - - -
    Parameters:
    - - - - - - - - - - - - + + + - + + + - - - + + - - + + + + + @@ -1117,14 +889,14 @@
    Parameters:
    - + + + + + + + + + +
    NameType + + 'samples' + + Description
    +

    Input type. Can be either 'samples' (default) or 'psd'. If you already have a PSD calculated, you can pass the estimates as an array with the input type 'psd'. You can also pass the entire PSD object if it was calculated using the bci.periodogram method, and the input type of 'psd' will be inferred.

    + +
    class1relative - Array.<Array.<number>> + boolean @@ -1105,11 +861,27 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + false + + -

    Data samples for class 1. Rows should be samples, columns should be signals.

    +

    Calculate relative bandpower instead of absolute bandpower. Default is false.

    class2window - Array.<Array.<number>> + number @@ -1134,11 +906,35 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + 'hann' + + -

    Data samples for class 2. Rows should be samples, columns should be signals.

    +

    Window function to apply, either 'hann' or 'rectangular'. Default is 'hann'.

    + +
    + @@ -1182,7 +978,7 @@
    Parameters:
    @@ -1211,7 +1007,7 @@
    Returns:
    -

    Learned CSP parameters

    +

    Bandpower | array of bandpowers if an array of bands is passed as input for a single signal or multiple signals are passed with a single band | array of array of powers for each band if multiple signals are passed

    @@ -1221,7 +1017,19 @@
    Returns:
    - Object + number + + + | + + + Array.<number> + + + | + + + Array.<Array.<number>> @@ -1235,15 +1043,15 @@
    Returns:
    - + -
    Example
    +
    Example
    -
    let cspParams = bci.cspLearn(class_a, class_b);
    +
    // Single signal example
    let samples = [0.23, 0.14, 0.78, ...];
    let sample_rate = 256; // Hz
    
    bandpower(samples, sample_rate, 'alpha'); // returns power, ex: 1.652
    bandpower(samples, sample_rate, ['alpha', 'beta']); // returns an array with the powers in the alpha and beta bands. Ex: [1.473, 0.383]
    
    // 2 channel example
    samples = [[0.1, 0.3], [0.4, 0.2], [0.6, 0.5], ...]
    
    bandpower(samples, sample_rate, 'alpha'); // returns an array of alpha powers for each channel, ex: [1.342, 0.342]
    
    bandpower(samples, sample_rate, ['alpha', 'beta']);
    // returns an array of arrays of powers in each band, ex: [[1.342, 0.342], [0.245, 1.343]].
    // The first array is an array of alpha powers for channels 1 and 2
    // The second array is an array of beta powers for channels 1 and 2
    
    bandpower(samples, sample_rate, ['alpha', 'beta'], {average: true});
    // Calculate average alpha across all channels and average beta across all channels
    // Returns a value such as [0.842, 0.794]
    // Note these are the average of [1.342, 0.342] and the average of [0.245, 1.343] from the previous example
    @@ -1256,13 +1064,13 @@
    Example
    - + -

    - (static) cspProject(cspParams, data, dimensionsopt) → {Array.<Array.<number>>} +

    + (static) confusionMatrix(predictedClasses, actualClasses) → {Array.<Array.<number>>}

    @@ -1271,8 +1079,13 @@

    -

    Projects data using common spatial pattern (CSP) and reduces to given number of dimensions. -Check out https://bci.js.org/examples/csp/ for an interactive example of how CSP works.

    +

    Generate a confusion matrix C where rows are actual classes and columns are predicted classes. +C = [ +[true negative, false positive], +[false negative, true positive] +].

    +

    If two classes are passed, class 0 represents the negative case, and class 1 represents the positive case. +If more than two classes are passed, an NxN confusion matrix is returned where N is the number of classes.

    @@ -1294,8 +1107,6 @@

    Parameters:
    Type - Attributes - @@ -1307,51 +1118,14 @@
    Parameters:
    - cspParams - - - - - - - object - - - - - - - - - - - - - - - - - - - - - -

    CSP parameters computed using the cspLearn function

    - - - - - - - - data + predictedClasses - Array.<Array.<number>> + Array.<number> @@ -1361,19 +1135,11 @@
    Parameters:
    - - - - - - - - -

    Data points to be projected. Rows should be samples, columns should be signals.

    +

    An array of predicted classes, with class numbers starting at 0

    @@ -1381,14 +1147,14 @@
    Parameters:
    - dimensions + actualClasses - number + Array.<number> @@ -1398,21 +1164,11 @@
    Parameters:
    - - - <optional>
    - - - - - - - -

    Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.

    +

    An array of the actual classes, with class numbers starting at 0

    @@ -1456,7 +1212,7 @@
    Parameters:
    @@ -1485,7 +1241,7 @@
    Returns:
    -

    Projected data. Rows are samples, columns are dimensions sorted by descending importance.

    +

    The confusion matrix

    @@ -1508,20 +1264,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    // Learn the CSP params
    let cspParams = bci.cspLearn(class_a, class_b);
    
    // Project the signals
    let class_a_csp = bci.cspProject(cspParams, class_a);
    let class_b_csp = bci.cspProject(cspParams, class_b);
    - - -
    - @@ -1530,13 +1272,13 @@
    Example
    - + -

    - (static) f1(confusionMatrix) → {number} +

    + (static) cspLearn(class1, class2) → {Object}

    @@ -1545,7 +1287,8 @@

    -

    Calculate the f1 score of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    +

    Learn common spatial pattern (CSP) for two datasets. +Check out https://bci.js.org/examples/csp/ for an interactive example of how CSP works.

    @@ -1578,7 +1321,7 @@

    Parameters:
    - confusionMatrix + class1 @@ -1599,7 +1342,36 @@
    Parameters:
    -

    a 2x2 confusion matrix

    +

    Data samples for class 1. Rows should be samples, columns should be signals.

    + + + + + + + + class2 + + + + + + + Array.<Array.<number>> + + + + + + + + + + + + + +

    Data samples for class 2. Rows should be samples, columns should be signals.

    @@ -1643,7 +1415,7 @@
    Parameters:
    @@ -1672,7 +1444,7 @@
    Returns:
    -

    The f1 score

    +

    Learned CSP parameters

    @@ -1682,7 +1454,7 @@
    Returns:
    - number + Object @@ -1695,116 +1467,55 @@
    Returns:
    - - - - - - - - - +
    + -

    - (static) fastICA(signals, options) → {Object} -

    - - - - - - -
    -

    FastICA algorithm for independent component analysis

    -
    - - - - - - - -
    Parameters:
    - - - - - - - - - - - - - - - - - - - - +
    Example
    - - - - - + - - - + - - - - - + + + + + + +

    + (static) cspProject(cspParams, data, dimensionsopt) → {Array.<Array.<number>>} +

    +
    - +
    +

    Projects data using common spatial pattern (CSP) and reduces to given number of dimensions. +Check out https://bci.js.org/examples/csp/ for an interactive example of how CSP works.

    +
    - - - @@ -2010,7 +1689,7 @@
    Properties
    @@ -2039,7 +1718,7 @@
    Returns:
    -

    An object with the following values: {source: the estimated source matrix, weights: the estimated unmixing matrix, whitening: the computed whitening matrix, iterations: number of iterations taken to converge on each weight}

    +

    Projected data. Rows are samples, columns are dimensions sorted by descending importance.

    @@ -2049,7 +1728,7 @@
    Returns:
    - Object + Array.<Array.<number>> @@ -2062,6 +1741,20 @@
    Returns:
    +
    + + + + + +
    Example
    + + +
    // Learn the CSP params
    let cspParams = bci.cspLearn(class_a, class_b);
    
    // Project the signals
    let class_a_csp = bci.cspProject(cspParams, class_a);
    let class_b_csp = bci.cspProject(cspParams, class_b);
    + + +
    + @@ -2070,13 +1763,13 @@
    Returns:
    - + -

    - (static) generateSignal(amplitudes, frequencies, sampleRate, duration) → {Array.<number>} +

    + (static) f1(confusionMatrix) → {number}

    @@ -2085,7 +1778,7 @@

    -

    Generate a signal with the given frequencies and their amplitudes.

    +

    Calculate the f1 score of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    @@ -2118,101 +1811,14 @@

    Parameters:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -2270,7 +1876,7 @@
    Parameters:
    @@ -2299,7 +1905,7 @@
    Returns:
    -

    The generated signal.

    +

    The f1 score

    @@ -2309,7 +1915,7 @@
    Returns:
    - Array.<number> + number @@ -2319,22 +1925,8 @@
    Returns:
    - - - -
    - - - - - -
    Example
    - - -
    let amplitudes = [4, 8];
    let frequencies = [10, 20]; // 10 Hz (alpha), 20 Hz (beta)
    let sampleRate = 512; // Hz
    let duration = 1; // Seconds
    
    let signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);
    - + -
    @@ -2344,13 +1936,13 @@
    Example
    - + -

    - (static) ldaClassify(ldaParams, point) → {number} +

    + (static) fastICA(signals, options) → {Object}

    @@ -2359,7 +1951,7 @@

    -

    Classify an unknown data point.

    +

    FastICA algorithm for independent component analysis

    @@ -2392,14 +1984,14 @@

    Parameters:
    - + @@ -2421,20 +2013,65 @@
    Parameters:
    - + + + + + + + @@ -2492,7 +2243,7 @@
    Parameters:
    @@ -2521,7 +2272,7 @@
    Returns:
    -

    0 if the first class, 1 if the second class

    +

    An object with the following values: {source: the estimated source matrix, weights: the estimated unmixing matrix, whitening: the computed whitening matrix, iterations: number of iterations taken to converge on each weight}

    @@ -2531,7 +2282,7 @@
    Returns:
    - number + Object @@ -2544,20 +2295,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    let features = [[1,3], [5,2]]; // Example feature vectors
    let classification = bci.ldaClassify(ldaParams, features[0]); // Outputs a number (0 or 1 depending on class)
    let classifications = bci.ldaClassify(ldaParams, features); // Outputs an array of classifications
    - - -
    - @@ -2566,13 +2303,13 @@
    Example
    - + -

    - (static) ldaLearn(class1, class2) → {Object} +

    + (static) generateSignal(amplitudes, frequencies, sampleRate, duration) → {Array.<number>}

    @@ -2581,7 +2318,7 @@

    -

    Perform linear discriminant analysis between two datasets

    +

    Generate a signal with the given frequencies and their amplitudes.

    @@ -2590,38 +2327,96 @@

    -

    Parameters:
    - +
    Parameters:
    + + +
    NameTypeDescription
    signals - - - - Array.<Array.<number>> - +
    let cspParams = bci.cspLearn(class_a, class_b);
    - + - -
    -

    The mixed signals. Each row should be a signal and each column a sample.

    - -
    options - - - - Object - + - - - - - -
    Properties
    - + + + + +
    Parameters:
    + @@ -1820,8 +1531,6 @@
    Properties
    - - @@ -1831,14 +1540,14 @@
    Properties
    - + - @@ -1876,14 +1577,14 @@
    Properties
    - + - @@ -1921,14 +1614,14 @@
    Properties
    - + - - - - - -
    DefaultDescription
    maxIterationscspParams - number + object @@ -1850,8 +1559,6 @@
    Properties
    - <optional>
    - @@ -1860,15 +1567,9 @@
    Properties
    -
    - - 1000 - - -

    Maximum number of iterations

    +

    CSP parameters computed using the cspLearn function

    debugdata - boolean + Array.<Array.<number>> @@ -1895,8 +1596,6 @@
    Properties
    - <optional>
    - @@ -1905,15 +1604,9 @@
    Properties
    -
    - - false - - -

    If true, prints out debug information while running

    +

    Data points to be projected. Rows should be samples, columns should be signals.

    fundimensions - string + number @@ -1950,23 +1643,9 @@
    Properties
    -
    - - logcosh - - -

    The functional form of the G function used in the approximation of negentropy. Can be either 'exp' or 'logcosh.

    - -
    - +

    Number of dimensions to be returned. Can range from 1 to number of signals. Defaults to number of signals.

    amplitudes - - - - Array.<number> - - - - - - - -

    The amplitudes of each frequency.

    - -
    frequencies - - - - Array.<number> - - - - - - - -

    The frequencies.

    - -
    sampleRate - - - - number - - - - - - - -

    Sample rate of the signal in Hz.

    - -
    durationconfusionMatrix - number + Array.<Array.<number>> @@ -2226,7 +1832,7 @@
    Parameters:
    -

    Duration of the signal in seconds.

    +

    a 2x2 confusion matrix

    ldaParamssignals - object + Array.<Array.<number>> @@ -2413,7 +2005,7 @@
    Parameters:
    -

    The parameters for the LDA, computed with the function ldaLearn

    +

    The mixed signals. Each row should be a signal and each column a sample.

    pointoptions - Array.<number> + Object - | + + + + + + + +
    Properties
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeAttributesDefaultDescription
    maxIterations + + - Array.<Array.<number>> + number @@ -2444,11 +2081,125 @@
    Parameters:
    + + <optional>
    + + + + + +
    + + 1000 + + -

    The data point or array of points to be classified.

    +

    Maximum number of iterations

    + +
    debug + + + + boolean + + + + + + + + + <optional>
    + + + + + +
    + + false + + +

    If true, prints out debug information while running

    + +
    fun + + + + string + + + + + + + + + <optional>
    + + + + + +
    + + logcosh + + +

    The functional form of the G function used in the approximation of negentropy. Can be either 'exp' or 'logcosh.

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameTypeDescription
    amplitudes + + + + Array.<number> + + + + + + + +

    The amplitudes of each frequency.

    + +
    frequencies + + + + Array.<number> + - - - - - - + - - + + - + - - - + + + + - - + @@ -2643,14 +2438,14 @@
    Parameters:
    - + @@ -2708,7 +2503,7 @@
    Parameters:
    @@ -2737,7 +2532,7 @@
    Returns:
    -

    Computed LDA parameters

    +

    The generated signal.

    @@ -2747,7 +2542,7 @@
    Returns:
    - Object + Array.<number> @@ -2761,15 +2556,15 @@
    Returns:
    - + -
    Example
    +
    Example
    -
    // Training set
    let class1 = [[0, 0], [1, 2], [2, 2], [1.5, 0.5]];
    let class2 = [[8, 8], [9, 10], [7, 8], [9, 9]];
    
    // Learn an LDA classifier
    let ldaParams = bci.ldaLearn(class1, class2);
    +
    let amplitudes = [4, 8];
    let frequencies = [10, 20]; // 10 Hz (alpha), 20 Hz (beta)
    let sampleRate = 512; // Hz
    let duration = 1; // Seconds
    
    let signal = bci.generateSignal(amplitudes, frequencies, sampleRate, duration);
    @@ -2782,13 +2577,13 @@
    Example
    - + -

    - (static) ldaProject(ldaParams, point) → {number} +

    + (static) ldaClassify(ldaParams, point) → {number}

    @@ -2797,7 +2592,7 @@

    -

    Predict the class of an unknown data point.

    +

    Classify an unknown data point.

    @@ -2886,7 +2681,7 @@

    Parameters:
    @@ -2930,7 +2725,7 @@
    Parameters:
    @@ -2959,7 +2754,7 @@
    Returns:
    -

    value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2

    +

    0 if the first class, 1 if the second class

    @@ -2982,6 +2777,20 @@
    Returns:
    +
    + + + + + +
    Example
    + + +
    let features = [[1,3], [5,2]]; // Example feature vectors
    let classification = bci.ldaClassify(ldaParams, features[0]); // Outputs a number (0 or 1 depending on class)
    let classifications = bci.ldaClassify(ldaParams, features); // Outputs an array of classifications
    + + +
    + @@ -2990,13 +2799,13 @@
    Returns:
    - + -

    - (static) loadCSV(filePath) → {Promise} +

    + (static) ldaLearn(class1, class2) → {Object}

    @@ -3005,8 +2814,7 @@

    -

    Loads a CSV file into an array

    -

    This method is exclusive to Node.js

    +

    Perform linear discriminant analysis between two datasets

    @@ -3039,14 +2847,14 @@

    Parameters:
    - + + + + + + + + + + + + + + + + @@ -3104,7 +2941,7 @@
    Parameters:
    @@ -3133,7 +2970,7 @@
    Returns:
    -

    A promise object which resolves to the CSV data array

    +

    Computed LDA parameters

    @@ -3143,7 +2980,7 @@
    Returns:
    - Promise + Object @@ -3156,6 +2993,20 @@
    Returns:
    +
    + + + + + +
    Example
    + + +
    // Training set
    let class1 = [[0, 0], [1, 2], [2, 2], [1.5, 0.5]];
    let class2 = [[8, 8], [9, 10], [7, 8], [9, 9]];
    
    // Learn an LDA classifier
    let ldaParams = bci.ldaLearn(class1, class2);
    + + +
    + @@ -3164,13 +3015,13 @@
    Returns:
    - + -

    - (static) loadEDF(filename) → {Object} +

    + (static) ldaProject(ldaParams, point) → {number}

    @@ -3179,8 +3030,7 @@

    -

    Load data from an EDF file

    -

    This method is exclusive to Node.js

    +

    Predict the class of an unknown data point.

    @@ -3213,14 +3063,14 @@

    Parameters:
    - + + + + + + + + + + + + + + + + @@ -3278,7 +3163,7 @@
    Parameters:
    @@ -3307,19 +3192,7 @@
    Returns:
    -

    An object with the following parameters: -
    -
    subject [string] - The name of the subject -
    recording [string] - The name of the recording -
    start_time [string] - The start time as a date time string -
    channels [Array] - An array of channel objects -
    -
    A channel object has the following parameters: -
    -
    label [string] - The label for the channel -
    sample_rate [number] - The sample rate for the channel -
    physical_dimension [string] - The units for each channel (ex: uV) -
    samples [number[]] - An array of samples from the channel

    +

    value less than 0 if predicted to be in class 1, 0 if exactly inbetween, greater than 0 if class 2

    @@ -3329,7 +3202,7 @@
    Returns:
    - Object + number @@ -3350,13 +3223,13 @@
    Returns:
    - + -

    - (static) mcc(confusionMatrix) → {number} +

    + (static) loadCSV(filePath) → {Promise}

    @@ -3365,7 +3238,8 @@

    -

    Calculate the Matthews correlation coefficient (MCC) of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    +

    Loads a CSV file into an array

    +

    This method is exclusive to Node.js

    @@ -3398,14 +3272,14 @@

    Parameters:
    - + @@ -3463,7 +3337,7 @@
    Parameters:
    @@ -3492,7 +3366,7 @@
    Returns:
    -

    The Matthews correlation coefficient

    +

    A promise object which resolves to the CSV data array

    @@ -3502,7 +3376,7 @@
    Returns:
    - number + Promise @@ -3523,13 +3397,13 @@
    Returns:
    - + - -

    - (static) nextpow2(num) → {number} + +

    + (static) loadEDF(filename) → {Object}

    @@ -3538,7 +3412,8 @@

    -

    Returns the ceil of the log2 of the absolute value of the passed number

    +

    Load data from an EDF file

    +

    This method is exclusive to Node.js

    @@ -3571,14 +3446,14 @@

    Parameters:
    - + @@ -3636,7 +3511,7 @@
    Parameters:
    @@ -3665,7 +3540,19 @@
    Returns:
    -

    The ceil of the log2 of the absolute value of the passed number

    +

    An object with the following parameters: +
    +
    subject [string] - The name of the subject +
    recording [string] - The name of the recording +
    start_time [string] - The start time as a date time string +
    channels [Array] - An array of channel objects +
    +
    A channel object has the following parameters: +
    +
    label [string] - The label for the channel +
    sample_rate [number] - The sample rate for the channel +
    physical_dimension [string] - The units for each channel (ex: uV) +
    samples [number[]] - An array of samples from the channel

    @@ -3675,7 +3562,7 @@
    Returns:
    - number + Object @@ -3688,20 +3575,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    nextpow2(8); // 3
    nextpow2(9); // 4
    nextpow2(16); // 4
    nextpow2(30); // 5
    nextpow2(0); // -Infinity
    - - -
    - @@ -3710,13 +3583,13 @@
    Example
    - + -

    - (static) oscCollect(address, port, header, samples) → {Promise} +

    + (static) mcc(confusionMatrix) → {number}

    @@ -3725,8 +3598,7 @@

    -

    Collect a set number of samples over OSC

    -

    This method is exclusive to Node.js

    +

    Calculate the Matthews correlation coefficient (MCC) of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    @@ -3759,101 +3631,14 @@

    Parameters:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -3911,7 +3696,7 @@
    Parameters:
    @@ -3940,7 +3725,7 @@
    Returns:
    -

    Resolves with collected data

    +

    The Matthews correlation coefficient

    @@ -3950,7 +3735,7 @@
    Returns:
    - Promise + number @@ -3971,13 +3756,13 @@
    Returns:
    - + -

    - (static) oscHeaderScan(address, port, duration) → {Promise} +

    + (static) nextpow2(num) → {number}

    @@ -3986,8 +3771,7 @@

    -

    Scan for OSC headers on a port and address

    -

    This method is exclusive to Node.js

    +

    Returns the ceil of the log2 of the absolute value of the passed number

    @@ -4020,43 +3804,14 @@

    Parameters:
    - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - @@ -4143,7 +3869,7 @@
    Parameters:
    @@ -4172,7 +3898,7 @@
    Returns:
    -

    Resolves with an array of found headers

    +

    The ceil of the log2 of the absolute value of the passed number

    @@ -4182,7 +3908,7 @@
    Returns:
    - Promise + number @@ -4195,6 +3921,20 @@
    Returns:
    +
    + + + + + +
    Example
    + + +
    nextpow2(8); // 3
    nextpow2(9); // 4
    nextpow2(16); // 4
    nextpow2(30); // 5
    nextpow2(0); // -Infinity
    + + +
    + @@ -4203,13 +3943,13 @@
    Returns:
    - + -

    - (static) partition(array, …divisions) → {Array.<Array>} +

    + (static) oscCollect(address, port, header, samples) → {Promise}

    @@ -4218,8 +3958,8 @@

    -

    Partitions an array into multiple arrays -Can be used to split data into training and testing sets

    +

    Collect a set number of samples over OSC

    +

    This method is exclusive to Node.js

    @@ -4239,9 +3979,7 @@

    Parameters:
    - - - + @@ -4254,14 +3992,14 @@
    Parameters:
    - + - + + + + + + + + + + number + + + + + + + + @@ -4291,14 +4050,14 @@
    Parameters:
    - + - + + + + + + + + + + + number + + + + + + + + @@ -4366,7 +4144,7 @@
    Parameters:
    @@ -4395,7 +4173,7 @@
    Returns:
    -

    Array of subarrays which are the partitons

    +

    Resolves with collected data

    @@ -4405,7 +4183,7 @@
    Returns:
    - Array.<Array> + Promise @@ -4418,20 +4196,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    partition([1, 2, 3, 4], 0.25, 0.75); // returns [[1], [2, 3, 4]]
    - - -
    - @@ -4440,13 +4204,13 @@
    Example
    - + -

    - (static) precision(confusionMatrix) → {number} +

    + (static) oscHeaderScan(address, port, duration) → {Promise}

    @@ -4455,7 +4219,8 @@

    -

    Calculate the precision of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    +

    Scan for OSC headers on a port and address

    +

    This method is exclusive to Node.js

    @@ -4488,14 +4253,14 @@

    Parameters:
    - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4553,7 +4376,7 @@
    Parameters:
    @@ -4582,7 +4405,7 @@
    Returns:
    -

    The precision (positive predictive value)

    +

    Resolves with an array of found headers

    @@ -4592,7 +4415,7 @@
    Returns:
    - number + Promise @@ -4613,13 +4436,13 @@
    Returns:
    - + -

    - (static) prompt(question) → {Promise} +

    + (static) partition(array, …divisions) → {Array.<Array>}

    @@ -4628,8 +4451,8 @@

    -

    Prompts the user for input via stdin

    -

    This method is exclusive to Node.js

    +

    Partitions an array into multiple arrays +Can be used to split data into training and testing sets

    @@ -4651,6 +4474,8 @@

    Parameters:
    + + @@ -4662,14 +4487,51 @@
    Parameters:
    - + + + + + + + + + + + + + + + + + + + + @@ -4727,7 +4599,7 @@
    Parameters:
    @@ -4756,7 +4628,7 @@
    Returns:
    -

    A promise object that resolves with the response

    +

    Array of subarrays which are the partitons

    @@ -4766,7 +4638,7 @@
    Returns:
    - Promise + Array.<Array> @@ -4776,8 +4648,22 @@
    Returns:
    - + + + +
    + + + + + +
    Example
    + + +
    partition([1, 2, 3, 4], 0.25, 0.75); // returns [[1], [2, 3, 4]]
    + +
    @@ -4787,13 +4673,13 @@
    Returns:
    - + -

    - (static) psd(signal, optionsopt) → {Array.<number>} +

    + (static) periodogram(signal, sample_rate, optionsopt) → {Object}

    @@ -4802,7 +4688,9 @@

    -

    Compute the power spectral density of a given signal.

    +

    Estimates the power spectral density of a real-valued input signal using the periodogram method and a rectangular window. +Output units are based on that of the input signal, of the form X^2/Hz, where X is the units of the input signal. +For example, if the input is an EEG signal measured in μV, then this method returns values of μV^2/Hz.

    @@ -4872,6 +4760,43 @@

    Parameters:
    +
    + + + + + + + + + + + + + + + + @@ -4980,14 +4905,14 @@
    Properties
    - + @@ -5069,7 +4994,7 @@
    Properties
    @@ -5098,7 +5023,7 @@
    Returns:
    -

    The PSD.

    +

    Object with keys 'estimates' (the psd estimates) and 'frequencies' (the corresponding frequencies)

    @@ -5108,7 +5033,7 @@
    Returns:
    - Array.<number> + Object @@ -5129,13 +5054,13 @@
    Returns:
    - + -

    - (static) psdBandPower(psd, sampleRate, band, fftSizeopt) → {number} +

    + (static) precision(confusionMatrix) → {number}

    @@ -5144,7 +5069,7 @@

    -

    Compute the average power across a given frequency band given the PSD.

    +

    Calculate the precision of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    @@ -5166,12 +5091,8 @@

    Parameters:
    - - - - @@ -5181,147 +5102,14 @@
    Parameters:
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - @@ -5395,7 +5167,7 @@
    Parameters:
    @@ -5424,7 +5196,7 @@
    Returns:
    -

    The average power in the frequency band.

    +

    The precision (positive predictive value)

    @@ -5455,13 +5227,13 @@
    Returns:
    - + -

    - (static) recall(confusionMatrix) → {number} +

    + (static) prompt(question) → {Promise}

    @@ -5470,7 +5242,8 @@

    -

    Calculate the recall of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    +

    Prompts the user for input via stdin

    +

    This method is exclusive to Node.js

    @@ -5503,14 +5276,14 @@

    Parameters:
    - + @@ -5568,7 +5341,7 @@
    Parameters:
    @@ -5597,7 +5370,7 @@
    Returns:
    -

    The recall (true positive rate)

    +

    A promise object that resolves with the response

    @@ -5607,7 +5380,7 @@
    Returns:
    - number + Promise @@ -5628,13 +5401,13 @@
    Returns:
    - + -

    - (static) round(array, places) → {Array.<number>} +

    + (static) recall(confusionMatrix) → {number}

    @@ -5643,7 +5416,7 @@

    -

    Rounds every value in an array to a set number of decimal places

    +

    Calculate the recall of a binary classifier given its confusion matrix as defined by the confusionMatrix method

    @@ -5658,61 +5431,32 @@

    Parameters:
    NameTypeDescription
    +

    The frequencies.

    + +
    class1sampleRate - Array.<Array.<number>> + number @@ -2635,7 +2430,7 @@
    Parameters:
    -

    Data set for class 1, rows are samples, columns are variables

    +

    Sample rate of the signal in Hz.

    class2duration - Array.<Array.<number>> + number @@ -2664,7 +2459,7 @@
    Parameters:
    -

    Data set for class 2, rows are samples, columns are variables

    +

    Duration of the signal in seconds.

    -

    The data point or array of points to be projected.

    +

    The data point or array of points to be classified.

    filePathclass1 - string + Array.<Array.<number>> @@ -3060,7 +2868,36 @@
    Parameters:
    -

    The path to the CSV file

    +

    Data set for class 1, rows are samples, columns are variables

    + +
    class2 + + + + Array.<Array.<number>> + + + + + + + +

    Data set for class 2, rows are samples, columns are variables

    filenameldaParams - string + object @@ -3234,7 +3084,42 @@
    Parameters:
    -

    Path to the EDF file

    +

    The parameters for the LDA, computed with the function ldaLearn

    + +
    point + + + + Array.<number> + + + | + + + Array.<Array.<number>> + + + + + + + +

    The data point or array of points to be projected.

    confusionMatrixfilePath - Array.<Array.<number>> + string @@ -3419,7 +3293,7 @@
    Parameters:
    -

    a 2x2 confusion matrix

    +

    The path to the CSV file

    numfilename - number + string @@ -3592,7 +3467,7 @@
    Parameters:
    - +

    Path to the EDF file

    address - - - - string - - - - - - - -

    OSC address

    - -
    port - - - - number - - - - - - - -

    OSC port

    - -
    header - - - - string - - - - - - - -

    OSC header, can be found by scanning with oscHeaderScan if unknown

    - -
    samplesconfusionMatrix - number + Array.<Array.<number>> @@ -3867,7 +3652,7 @@
    Parameters:
    -

    The number of samples to collect

    +

    a 2x2 confusion matrix

    address - - - - any - - - - - - - -

    OSC address

    - -
    portnum - any + number @@ -4070,36 +3825,7 @@
    Parameters:
    -

    OSC port

    - -
    duration - - - - any - - - - - - -

    Duration of scan in milliseconds

    TypeAttributes
    arrayaddress - Array + string @@ -4271,19 +4009,40 @@
    Parameters:
    - - + + + +

    OSC address

    + +
    port + - -

    The array to be partitioned

    +

    OSC port

    divisionsheader - Array.<number> + string @@ -4308,21 +4067,40 @@
    Parameters:
    - - + + +

    OSC header, can be found by scanning with oscHeaderScan if unknown

    + +
    samples + - <repeatable>
    - -
    -

    The size of each partition, each value should range from 0 to 1

    +

    The number of samples to collect

    confusionMatrixaddress - Array.<Array.<number>> + any @@ -4509,7 +4274,65 @@
    Parameters:
    -

    a 2x2 confusion matrix

    +

    OSC address

    + +
    port + + + + any + + + + + + + +

    OSC port

    + +
    duration + + + + any + + + + + + + +

    Duration of scan in milliseconds

    TypeAttributes
    questionarray - string + Array + + + + + + + + + + + + + +

    The array to be partitioned

    + +
    divisions + + + + Array.<number> @@ -4679,11 +4541,21 @@
    Parameters:
    + + + + + + <repeatable>
    + +
    -

    Question shown to user

    +

    The size of each partition, each value should range from 0 to 1

    sample_rate + + + + number + + + + + + + + + + + + + +

    sample rate in Hz

    + +
    options
    truncatewindow - boolean + number @@ -5011,13 +4936,13 @@
    Properties
    - false + 'rectangular' -

    If true, only the first half of the PSD array is returned

    +

    Window function to apply, either 'hann' or 'rectangular'. Default is 'rectangular'.

    TypeAttributesDefaultDescription
    psd - - - - Array.<number> - - - - - - - - - - - - - - - -

    Power spectral density of the signal.

    - -
    sampleRate - - - - number - - - - - - - - - - - - - - - -

    The sample rate of the signal.

    - -
    band - - - - Array.<number> - - - | - - - string - - - - - - - - - - - - - - - -

    The frequency band provided as an array [frequencyStart, frequencyStop] or a -string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz). -While string representations -allow for easier prototyping, the use of a specific band passed as an array is recommended, as band string representations may change in -future updates.

    - -
    fftSizeconfusionMatrix - number + Array.<Array.<number>> @@ -5331,27 +5119,11 @@
    Parameters:
    - - <optional>
    - - - - - -
    - - Math.pow(2, bci.nextpow2(psd.length)) - - -

    Size of the fourier transform used to compute the PSD.

    +

    a 2x2 confusion matrix

    confusionMatrixquestion - Array.<Array.<number>> + string @@ -5524,7 +5297,7 @@
    Parameters:
    -

    a 2x2 confusion matrix

    +

    Question shown to user

    - - - - - - - - - - - - - - - - - - - - - - + - - + - + - + - - + + + + - + @@ -5770,7 +5514,7 @@
    Parameters:
    @@ -5799,7 +5543,7 @@
    Returns:
    -

    The rounded array

    +

    The recall (true positive rate)

    @@ -5809,7 +5553,7 @@
    Returns:
    - Array.<number> + number @@ -5830,13 +5574,13 @@
    Returns:
    - + -

    - (static) saveCSV(array, filename) → {Promise} +

    + (static) round(array, places) → {Array.<number>}

    @@ -5845,8 +5589,7 @@

    -

    Saves an array to a CSV file

    -

    This method is exclusive to Node.js

    +

    Rounds every value in an array to a set number of decimal places

    @@ -5886,7 +5629,7 @@

    Parameters:
    - Array + Array.<number> @@ -5908,14 +5651,14 @@
    Parameters:
    - + - - @@ -6083,20 +5825,14 @@
    Parameters:
    - + - - - - - - - - - - - - - - - - - - - @@ -6163,18 +5854,12 @@
    Parameters:
    - + - - - - - - - - - - - - - - - - - - - - - - - @@ -6358,7 +5919,7 @@
    Properties
    @@ -6387,7 +5948,7 @@
    Returns:
    -

    The average power in the frequency band.

    +

    A promise object that resolves when the file has been saved. Does not currently reject on write error.

    @@ -6397,7 +5958,7 @@
    Returns:
    - number + Promise @@ -6410,20 +5971,6 @@
    Returns:
    -
    - - - - - -
    Example
    - - -
    // Example outputs are rounded
    
    // Single signal examples
    let sampleRate = 512;
    let signal = bci.generateSignal([2,16], [10,20], sampleRate, 1);
    // Get a single power in one band
    console.log(bci.signalBandPower(signal, sampleRate, 'alpha')); // returns 102.4
    // Specify a custom band as an array (Ex: 8 Hz - 12 Hz)
    console.log(bci.signalBandPower(signal, sampleRate, [8, 12])); // returns 102.4
    // Obtain multiple band powers
    console.log(bci.signalBandPower(signal, sampleRate, ['alpha', 'beta'])); // returns [ 102.4, 227.6 ]
    // Multiple band powers works with custom bands too
    console.log(bci.signalBandPower(signal, sampleRate, [[8, 12], [13, 30]])); // returns [ 102.4, 227.6 ]
    
    // Works with multiple signals too (example with 2 signals)
    let signal2 = bci.generateSignal([16, 2], [10, 20], 512, 1);
    let samples = bci.transpose([signal, signal2]);
    console.log(bci.signalBandPower(samples, sampleRate, 'alpha'));
    // Returns an array containing the alpha value for each signal
    console.log(bci.signalBandPower(samples, sampleRate, ['alpha', 'beta', 'gamma']));
    // Returns a 2d array with number_of_bands rows and number_of_signals columns
    - - -
    - @@ -7903,7 +7450,7 @@
    Examples

    diff --git a/docs/docs/module-bcijs.oscStream.html b/docs/docs/module-bcijs.oscStream.html index 97e4949..b3bcce7 100644 --- a/docs/docs/module-bcijs.oscStream.html +++ b/docs/docs/module-bcijs.oscStream.html @@ -80,7 +80,7 @@

    -

    Classes

    Modules

    +

    Classes

    Modules

    @@ -687,7 +687,7 @@


    diff --git a/docs/examples/csp/index.html b/docs/examples/csp/index.html index ab41757..d72af3a 100644 --- a/docs/examples/csp/index.html +++ b/docs/examples/csp/index.html @@ -25,7 +25,7 @@

    - + diff --git a/docs/examples/lda/index.html b/docs/examples/lda/index.html index 13dcfa8..a7d229c 100644 --- a/docs/examples/lda/index.html +++ b/docs/examples/lda/index.html @@ -24,7 +24,7 @@ - + diff --git a/docs/index.html b/docs/index.html index 7c5b30c..5ecc906 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,9 +1,9 @@ -BCI.js

    Powering brain-computer interfaces with JavaScript

    GitHub Docs

    Get Started

    Perform online and offline processing in Node.js with our NPM package, or get started directly in your browser with the jsDelivr CDN.

     
    Node.js
    npm install bcijs
    Browser
    <script src="https://cdn.jsdelivr.net/npm/bcijs@1.6.5/dist/bci.min.js"></script>

    Signal Processing

    Isolate specific brainwaves with methods such as the fast fourier transform, common spatial pattern, FastICA, and more.

    Find more examples in our GitHub repo and our docs.

    NameTypeDescription
    array - - - - Array.<number> - - - - + + NameType - - -
    Description
    placesconfusionMatrix - number + Array.<Array.<number>> @@ -5726,7 +5470,7 @@
    Parameters:
    - +

    a 2x2 confusion matrix

    filenameplaces - string + number @@ -5973,7 +5716,7 @@
    Parameters:
    @@ -6002,7 +5745,7 @@
    Returns:
    -

    A promise object that resolves when the file has been saved. Does not currently reject on write error.

    +

    The rounded array

    @@ -6012,7 +5755,7 @@
    Returns:
    - Promise + Array.<number> @@ -6033,13 +5776,13 @@
    Returns:
    - + -

    - (static) signalBandPower(samples, sampleRate, bands, optionsopt) → {number} +

    + (static) saveCSV(array, filename) → {Promise}

    @@ -6048,7 +5791,8 @@

    -

    Compute the average power across a given frequency band in a signal.

    +

    Saves an array to a CSV file

    +

    This method is exclusive to Node.js

    @@ -6070,8 +5814,6 @@

    Parameters:
    TypeAttributes
    samplesarray - Array.<number> - - - | - - - Array.<Array.<number>> + Array @@ -6106,56 +5842,11 @@
    Parameters:
    - - - - - - -

    The signal (array of numbers) or a matrix of signals, where rows are samples and columns are signals.

    - -
    sampleRate - - - - number - - - - - - - - - - - - -

    The sample rate of the signal.

    bandsfilename - - Array - - - | - string @@ -6186,135 +5871,11 @@
    Parameters:
    - - - - - - -

    The frequency band or array of bands, where a single band is provided as an array [frequencyStart, frequencyStop] or a string delta (1-3 Hz), theta (4-7 Hz), alpha (8-12 Hz), beta (13-30 Hz), or gamma (31-50 Hz).
    -While string representations allow for easier prototyping, the use of a specific band passed as an array is -recommended, as band string representations may change in future updates.

    - -
    options - - - - Object - - - - - - - - - <optional>
    - - - - - -
    - - -
    Properties
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameTypeAttributesDefaultDescription
    fftSize - - - - number - - - - - - - - - <optional>
    - - - - - -
    - - Math.pow(2, bci.nextpow2(signal.length)) - - -

    Size of the fft to be used. Should be a power of 2.

    -
    -