mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
Publish mathjs@7.0.2
This commit is contained in:
parent
ed17dba976
commit
49867b4bdf
12
download.md
12
download.md
@ -29,7 +29,7 @@ Math.js can be downloaded or linked from various content delivery networks:
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>unpkg</td>
|
||||
<td><a href="https://unpkg.com/mathjs@7.0.1/">https://unpkg.com/mathjs@7.0.1/</a></td>
|
||||
<td><a href="https://unpkg.com/mathjs@7.0.2/">https://unpkg.com/mathjs@7.0.2/</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>cdnjs</td>
|
||||
@ -51,18 +51,18 @@ Here some direct download links from [unpkg](https://unpkg.com):
|
||||
<table class="download">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@7.0.1/dist/math.js">
|
||||
Development (version 7.0.1)
|
||||
<a href="https://unpkg.com/mathjs@7.0.2/dist/math.js">
|
||||
Development (version 7.0.2)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<span id="development-size">1822 kB</span>, uncompressed with comments
|
||||
<span id="development-size">1823 kB</span>, uncompressed with comments
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://unpkg.com/mathjs@7.0.1/dist/math.min.js">
|
||||
Production (version 7.0.1)
|
||||
<a href="https://unpkg.com/mathjs@7.0.2/dist/math.min.js">
|
||||
Production (version 7.0.2)
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
19
examples/advanced/custom_evaluate_using_factories.js
Normal file
19
examples/advanced/custom_evaluate_using_factories.js
Normal file
@ -0,0 +1,19 @@
|
||||
const { create, evaluateDependencies, factory } = require('../..')
|
||||
|
||||
// custom implementations of all functions you want to support
|
||||
const add = (a, b) => a + b
|
||||
const subtract = (a, b) => a - b
|
||||
const multiply = (a, b) => a * b
|
||||
const divide = (a, b) => a / b
|
||||
|
||||
// create factories for the functions, and create an evaluate function with those
|
||||
// these functions will also be used by the classes like Unit.
|
||||
const { evaluate } = create({
|
||||
evaluateDependencies,
|
||||
createAdd: factory('add', [], () => add),
|
||||
createSubtract: factory('subtract', [], () => subtract),
|
||||
createMultiply: factory('multiply', [], () => multiply),
|
||||
createDivide: factory('divide', [], () => divide)
|
||||
})
|
||||
|
||||
console.log(evaluate('2 + 3 * 4')) // 14
|
||||
33
examples/advanced/custom_evaluate_using_factories.js.md
Normal file
33
examples/advanced/custom_evaluate_using_factories.js.md
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Custom evaluate using factories
|
||||
|
||||
File: [custom_evaluate_using_factories.js](custom_evaluate_using_factories.js)
|
||||
|
||||
```js
|
||||
const { create, evaluateDependencies, factory } = require('../..')
|
||||
|
||||
// custom implementations of all functions you want to support
|
||||
const add = (a, b) => a + b
|
||||
const subtract = (a, b) => a - b
|
||||
const multiply = (a, b) => a * b
|
||||
const divide = (a, b) => a / b
|
||||
|
||||
// create factories for the functions, and create an evaluate function with those
|
||||
// these functions will also be used by the classes like Unit.
|
||||
const { evaluate } = create({
|
||||
evaluateDependencies,
|
||||
createAdd: factory('add', [], () => add),
|
||||
createSubtract: factory('subtract', [], () => subtract),
|
||||
createMultiply: factory('multiply', [], () => multiply),
|
||||
createDivide: factory('divide', [], () => divide)
|
||||
})
|
||||
|
||||
console.log(evaluate('2 + 3 * 4')) // 14
|
||||
|
||||
```
|
||||
|
||||
<!-- Note: This file is automatically generated. Changes made in this file will be overridden. -->
|
||||
|
||||
18
examples/advanced/custom_evaluate_using_import.js
Normal file
18
examples/advanced/custom_evaluate_using_import.js
Normal file
@ -0,0 +1,18 @@
|
||||
const { create, evaluateDependencies } = require('../..')
|
||||
|
||||
// custom implementations of all functions you want to support
|
||||
const add = (a, b) => a + b
|
||||
const subtract = (a, b) => a - b
|
||||
const multiply = (a, b) => a * b
|
||||
const divide = (a, b) => a / b
|
||||
|
||||
// create a mathjs instance with hardly any functions
|
||||
// there are some functions created which are used internally by evaluate though,
|
||||
// for example by the Unit class which has dependencies on addScalar, subtract,
|
||||
// multiplyScalar, etc.
|
||||
const math = create(evaluateDependencies)
|
||||
|
||||
// import your own functions
|
||||
math.import({ add, subtract, multiply, divide }, { override: true })
|
||||
|
||||
console.log(math.evaluate('2 + 3 * 4')) // 14
|
||||
32
examples/advanced/custom_evaluate_using_import.js.md
Normal file
32
examples/advanced/custom_evaluate_using_import.js.md
Normal file
@ -0,0 +1,32 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# Custom evaluate using import
|
||||
|
||||
File: [custom_evaluate_using_import.js](custom_evaluate_using_import.js)
|
||||
|
||||
```js
|
||||
const { create, evaluateDependencies } = require('../..')
|
||||
|
||||
// custom implementations of all functions you want to support
|
||||
const add = (a, b) => a + b
|
||||
const subtract = (a, b) => a - b
|
||||
const multiply = (a, b) => a * b
|
||||
const divide = (a, b) => a / b
|
||||
|
||||
// create a mathjs instance with hardly any functions
|
||||
// there are some functions created which are used internally by evaluate though,
|
||||
// for example by the Unit class which has dependencies on addScalar, subtract,
|
||||
// multiplyScalar, etc.
|
||||
const math = create(evaluateDependencies)
|
||||
|
||||
// import your own functions
|
||||
math.import({ add, subtract, multiply, divide }, { override: true })
|
||||
|
||||
console.log(math.evaluate('2 + 3 * 4')) // 14
|
||||
|
||||
```
|
||||
|
||||
<!-- Note: This file is automatically generated. Changes made in this file will be overridden. -->
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ File: [angle_configuration.html](angle_configuration.html) (click for a live dem
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ File: [basic_usage.html](basic_usage.html) (click for a live demo)
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | basic usage</title>
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -13,7 +13,7 @@ File: [currency_conversion.html](currency_conversion.html) (click for a live dem
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | currency conversion</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body,
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ File: [custom_separators.html](custom_separators.html) (click for a live demo)
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ File: [plot.html](plot.html) (click for a live demo)
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | plot</title>
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<script src="https://cdn.plot.ly/plotly-1.35.2.min.js"></script>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -13,7 +13,7 @@ File: [pretty_printing_with_mathjax.html](pretty_printing_with_mathjax.html) (cl
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | pretty printing with MathJax</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/MathJax.js?config=TeX-AMS-MML_HTMLorMML.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -13,7 +13,7 @@ File: [printing_html.html](printing_html.html) (click for a live demo)
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | printing HTML</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<script>
|
||||
// load math.js using require.js
|
||||
require(['https://unpkg.com/mathjs@7.0.1/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@7.0.2/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.evaluate('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -18,7 +18,7 @@ File: [requirejs_loading.html](requirejs_loading.html) (click for a live demo)
|
||||
|
||||
<script>
|
||||
// load math.js using require.js
|
||||
require(['https://unpkg.com/mathjs@7.0.1/dist/math.min.js'], function (math) {
|
||||
require(['https://unpkg.com/mathjs@7.0.2/dist/math.min.js'], function (math) {
|
||||
// evaluate some expression
|
||||
const result = math.evaluate('1.2 * (2 + 4.5)')
|
||||
document.write(result)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -13,7 +13,7 @@ File: [rocket_trajectory_optimization.html](rocket_trajectory_optimization.html)
|
||||
<meta charset="utf-8">
|
||||
<title>math.js | rocket trajectory optimization</title>
|
||||
|
||||
<script src="https://unpkg.com/mathjs@7.0.1/dist/math.min.js"></script>
|
||||
<script src="https://unpkg.com/mathjs@7.0.2/dist/math.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -92,7 +92,7 @@ File: [webworkers.html](webworkers.html) (click for a live demo)
|
||||
File: [worker.js](worker.js)
|
||||
|
||||
```js
|
||||
importScripts('https://unpkg.com/mathjs@7.0.1/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@7.0.2/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
importScripts('https://unpkg.com/mathjs@7.0.1/dist/math.min.js')
|
||||
importScripts('https://unpkg.com/mathjs@7.0.2/dist/math.min.js')
|
||||
|
||||
// create a parser
|
||||
const parser = self.math.parser()
|
||||
|
||||
@ -36,6 +36,8 @@ layout: default
|
||||
- [Convert fraction to bignumber](advanced\convert_fraction_to_bignumber.js.html)
|
||||
- [Custom argument parsing](advanced\custom_argument_parsing.js.html)
|
||||
- [Custom datatype](advanced\custom_datatype.js.html)
|
||||
- [Custom evaluate using factories](advanced\custom_evaluate_using_factories.js.html)
|
||||
- [Custom evaluate using import](advanced\custom_evaluate_using_import.js.html)
|
||||
- [Custom loading](advanced\custom_loading.js.html)
|
||||
- [Custom relational functions](advanced\custom_relational_functions.js.html)
|
||||
- [Expression trees](advanced\expression_trees.js.html)
|
||||
|
||||
@ -4,6 +4,14 @@ layout: default
|
||||
|
||||
<h1 id="history">History <a href="#history" title="Permalink">#</a></h1>
|
||||
|
||||
<h1 id="20200624-version-702">2020-06-24, version 7.0.2 <a href="#20200624-version-702" title="Permalink">#</a></h1>
|
||||
|
||||
- Fix <a href="https://github.com/josdejong/mathjs/issues/1882">#1882</a>: have `DenseMatrix.resize` and `SparseMatrix.resize` accept
|
||||
`DenseMatrix` and `SparseMatrix` as inputs too, not only `Array`.
|
||||
- Fix functions `sum`, `prod`, `min`, and `max` not throwing a conversion error
|
||||
when passing a single string, like `sum("abc")`.
|
||||
|
||||
|
||||
<h1 id="20200530-version-701">2020-05-30, version 7.0.1 <a href="#20200530-version-701" title="Permalink">#</a></h1>
|
||||
|
||||
- Fix <a href="https://github.com/josdejong/mathjs/issues/1844">#1844</a>: clarify the documentation of function `eigs`. Thanks <a href="https://github.com/Lazersmoke">@Lazersmoke</a>.
|
||||
|
||||
135
js/lib/math.js
135
js/lib/math.js
@ -6,8 +6,8 @@
|
||||
* It features real and complex numbers, units, matrices, a large set of
|
||||
* mathematical functions, and a flexible expression parser.
|
||||
*
|
||||
* @version 7.0.1
|
||||
* @date 2020-05-30
|
||||
* @version 7.0.2
|
||||
* @date 2020-06-24
|
||||
*
|
||||
* @license
|
||||
* Copyright (C) 2013-2020 Jos de Jong <wjosdejong@gmail.com>
|
||||
@ -13795,7 +13795,7 @@ var createDenseMatrixClass = /* #__PURE__ */Object(factory["a" /* factory */])(D
|
||||
* `copy=true`, otherwise return the matrix itself (resize in place).
|
||||
*
|
||||
* @memberof DenseMatrix
|
||||
* @param {number[]} size The new size the matrix should have.
|
||||
* @param {number[] || Matrix} size The new size the matrix should have.
|
||||
* @param {*} [defaultValue=0] Default value, filled in on new entries.
|
||||
* If not provided, the matrix elements will
|
||||
* be filled with zeros.
|
||||
@ -13807,14 +13807,18 @@ var createDenseMatrixClass = /* #__PURE__ */Object(factory["a" /* factory */])(D
|
||||
|
||||
DenseMatrix.prototype.resize = function (size, defaultValue, copy) {
|
||||
// validate arguments
|
||||
if (!Object(is["b" /* isArray */])(size)) {
|
||||
throw new TypeError('Array expected');
|
||||
} // matrix to resize
|
||||
if (!Object(is["i" /* isCollection */])(size)) {
|
||||
throw new TypeError('Array or Matrix expected');
|
||||
} // SparseMatrix input is always 2d, flatten this into 1d if it's indeed a vector
|
||||
|
||||
|
||||
var sizeArray = size.valueOf().map(function (value) {
|
||||
return Array.isArray(value) && value.length === 1 ? value[0] : value;
|
||||
}); // matrix to resize
|
||||
|
||||
var m = copy ? this.clone() : this; // resize matrix
|
||||
|
||||
return _resize(m, size, defaultValue);
|
||||
return _resize(m, sizeArray, defaultValue);
|
||||
};
|
||||
|
||||
function _resize(matrix, size, defaultValue) {
|
||||
@ -15721,7 +15725,7 @@ var createSparseMatrixClass = /* #__PURE__ */Object(factory["a" /* factory */])(
|
||||
* `copy=true`, otherwise return the matrix itself (resize in place).
|
||||
*
|
||||
* @memberof SparseMatrix
|
||||
* @param {number[]} size The new size the matrix should have.
|
||||
* @param {number[] | Matrix} size The new size the matrix should have.
|
||||
* @param {*} [defaultValue=0] Default value, filled in on new entries.
|
||||
* If not provided, the matrix elements will
|
||||
* be filled with zeros.
|
||||
@ -15733,24 +15737,29 @@ var createSparseMatrixClass = /* #__PURE__ */Object(factory["a" /* factory */])(
|
||||
|
||||
SparseMatrix.prototype.resize = function (size, defaultValue, copy) {
|
||||
// validate arguments
|
||||
if (!Object(is["b" /* isArray */])(size)) {
|
||||
throw new TypeError('Array expected');
|
||||
}
|
||||
if (!Object(is["i" /* isCollection */])(size)) {
|
||||
throw new TypeError('Array or Matrix expected');
|
||||
} // SparseMatrix input is always 2d, flatten this into 1d if it's indeed a vector
|
||||
|
||||
if (size.length !== 2) {
|
||||
|
||||
var sizeArray = size.valueOf().map(function (value) {
|
||||
return Array.isArray(value) && value.length === 1 ? value[0] : value;
|
||||
});
|
||||
|
||||
if (sizeArray.length !== 2) {
|
||||
throw new Error('Only two dimensions matrix are supported');
|
||||
} // check sizes
|
||||
|
||||
|
||||
size.forEach(function (value) {
|
||||
sizeArray.forEach(function (value) {
|
||||
if (!Object(is["y" /* isNumber */])(value) || !Object(utils_number["i" /* isInteger */])(value) || value < 0) {
|
||||
throw new TypeError('Invalid size, must contain positive integers ' + '(size: ' + Object(utils_string["d" /* format */])(size) + ')');
|
||||
throw new TypeError('Invalid size, must contain positive integers ' + '(size: ' + Object(utils_string["d" /* format */])(sizeArray) + ')');
|
||||
}
|
||||
}); // matrix to resize
|
||||
|
||||
var m = copy ? this.clone() : this; // resize matrix
|
||||
|
||||
return _resize(m, size[0], size[1], defaultValue);
|
||||
return _resize(m, sizeArray[0], sizeArray[1], defaultValue);
|
||||
};
|
||||
|
||||
function _resize(matrix, rows, columns, defaultValue) {
|
||||
@ -26484,10 +26493,12 @@ function improveErrorMessage(err, fnName, value) {
|
||||
|
||||
|
||||
var prod_name = 'prod';
|
||||
var prod_dependencies = ['typed', 'multiply'];
|
||||
var prod_dependencies = ['typed', 'config', 'multiplyScalar', 'numeric'];
|
||||
var createProd = /* #__PURE__ */Object(factory["a" /* factory */])(prod_name, prod_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
multiply = _ref.multiply;
|
||||
config = _ref.config,
|
||||
multiplyScalar = _ref.multiplyScalar,
|
||||
numeric = _ref.numeric;
|
||||
|
||||
/**
|
||||
* Compute the product of a matrix or a list with values.
|
||||
@ -26538,11 +26549,15 @@ var createProd = /* #__PURE__ */Object(factory["a" /* factory */])(prod_name, pr
|
||||
var prod;
|
||||
deepForEach(array, function (value) {
|
||||
try {
|
||||
prod = prod === undefined ? value : multiply(prod, value);
|
||||
prod = prod === undefined ? value : multiplyScalar(prod, value);
|
||||
} catch (err) {
|
||||
throw improveErrorMessage(err, 'prod', value);
|
||||
}
|
||||
});
|
||||
}); // make sure returning numeric value: parse a string into a numeric value
|
||||
|
||||
if (typeof prod === 'string') {
|
||||
prod = numeric(prod, config.number);
|
||||
}
|
||||
|
||||
if (prod === undefined) {
|
||||
throw new Error('Cannot calculate prod of an empty array');
|
||||
@ -27149,8 +27164,8 @@ var createPow = /* #__PURE__ */Object(factory["a" /* factory */])(pow_name, pow_
|
||||
return (yFrac.n % 2 === 0 ? 1 : -1) * Math.pow(-x, y);
|
||||
}
|
||||
}
|
||||
} catch (ex) {} // fraction() throws an error if y is Infinity, etc.
|
||||
// Unable to express y as a fraction, so continue on
|
||||
} catch (ex) {// fraction() throws an error if y is Infinity, etc.
|
||||
} // Unable to express y as a fraction, so continue on
|
||||
|
||||
} // **for predictable mode** x^Infinity === NaN if x < -1
|
||||
// N.B. this behavour is different from `Math.pow` which gives
|
||||
@ -31010,9 +31025,11 @@ var createSort = /* #__PURE__ */Object(factory["a" /* factory */])(sort_name, so
|
||||
|
||||
|
||||
var max_name = 'max';
|
||||
var max_dependencies = ['typed', 'larger'];
|
||||
var max_dependencies = ['typed', 'config', 'numeric', 'larger'];
|
||||
var createMax = /* #__PURE__ */Object(factory["a" /* factory */])(max_name, max_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
numeric = _ref.numeric,
|
||||
larger = _ref.larger;
|
||||
|
||||
/**
|
||||
@ -31101,6 +31118,11 @@ var createMax = /* #__PURE__ */Object(factory["a" /* factory */])(max_name, max_
|
||||
|
||||
if (res === undefined) {
|
||||
throw new Error('Cannot calculate max of an empty array');
|
||||
} // make sure returning numeric value: parse a string into a numeric value
|
||||
|
||||
|
||||
if (typeof res === 'string') {
|
||||
res = numeric(res, config.number);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -31111,9 +31133,11 @@ var createMax = /* #__PURE__ */Object(factory["a" /* factory */])(max_name, max_
|
||||
|
||||
|
||||
var min_name = 'min';
|
||||
var min_dependencies = ['typed', 'smaller'];
|
||||
var min_dependencies = ['typed', 'config', 'numeric', 'smaller'];
|
||||
var createMin = /* #__PURE__ */Object(factory["a" /* factory */])(min_name, min_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
numeric = _ref.numeric,
|
||||
smaller = _ref.smaller;
|
||||
|
||||
/**
|
||||
@ -31202,6 +31226,11 @@ var createMin = /* #__PURE__ */Object(factory["a" /* factory */])(min_name, min_
|
||||
|
||||
if (min === undefined) {
|
||||
throw new Error('Cannot calculate min of an empty array');
|
||||
} // make sure returning numeric value: parse a string into a numeric value
|
||||
|
||||
|
||||
if (typeof min === 'string') {
|
||||
min = numeric(min, config.number);
|
||||
}
|
||||
|
||||
return min;
|
||||
@ -41960,15 +41989,15 @@ var ConstantNode_createConstantNode = /* #__PURE__ */Object(factory["a" /* facto
|
||||
*/
|
||||
|
||||
|
||||
ConstantNode.prototype.forEach = function (callback) {} // nothing to do, we don't have childs
|
||||
|
||||
ConstantNode.prototype.forEach = function (callback) {// nothing to do, we don't have childs
|
||||
};
|
||||
/**
|
||||
* Create a new ConstantNode having it's childs be the results of calling
|
||||
* the provided callback function for each of the childs of the original node.
|
||||
* @param {function(child: Node, path: string, parent: Node) : Node} callback
|
||||
* @returns {ConstantNode} Returns a clone of the node
|
||||
*/
|
||||
;
|
||||
|
||||
|
||||
ConstantNode.prototype.map = function (callback) {
|
||||
return this.clone();
|
||||
@ -44260,15 +44289,15 @@ var createSymbolNode = /* #__PURE__ */Object(factory["a" /* factory */])(SymbolN
|
||||
*/
|
||||
|
||||
|
||||
SymbolNode.prototype.forEach = function (callback) {} // nothing to do, we don't have childs
|
||||
|
||||
SymbolNode.prototype.forEach = function (callback) {// nothing to do, we don't have childs
|
||||
};
|
||||
/**
|
||||
* Create a new SymbolNode having it's childs be the results of calling
|
||||
* the provided callback function for each of the childs of the original node.
|
||||
* @param {function(child: Node, path: string, parent: Node) : Node} callback
|
||||
* @returns {SymbolNode} Returns a clone of the node
|
||||
*/
|
||||
;
|
||||
|
||||
|
||||
SymbolNode.prototype.map = function (callback) {
|
||||
return this.clone();
|
||||
@ -54256,15 +54285,13 @@ var createIntersect = /* #__PURE__ */Object(factory["a" /* factory */])(intersec
|
||||
|
||||
|
||||
|
||||
|
||||
var sum_name = 'sum';
|
||||
var sum_dependencies = ['typed', 'config', 'add', '?bignumber', '?fraction'];
|
||||
var sum_dependencies = ['typed', 'config', 'add', 'numeric'];
|
||||
var createSum = /* #__PURE__ */Object(factory["a" /* factory */])(sum_name, sum_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
add = _ref.add,
|
||||
bignumber = _ref.bignumber,
|
||||
fraction = _ref.fraction;
|
||||
numeric = _ref.numeric;
|
||||
|
||||
/**
|
||||
* Compute the sum of a matrix or a list with values.
|
||||
@ -54305,7 +54332,7 @@ var createSum = /* #__PURE__ */Object(factory["a" /* factory */])(sum_name, sum_
|
||||
});
|
||||
/**
|
||||
* Recursively calculate the sum of an n-dimensional array
|
||||
* @param {Array} array
|
||||
* @param {Array | Matrix} array
|
||||
* @return {number} sum
|
||||
* @private
|
||||
*/
|
||||
@ -54318,22 +54345,14 @@ var createSum = /* #__PURE__ */Object(factory["a" /* factory */])(sum_name, sum_
|
||||
} catch (err) {
|
||||
throw improveErrorMessage(err, 'sum', value);
|
||||
}
|
||||
});
|
||||
}); // make sure returning numeric value: parse a string into a numeric value
|
||||
|
||||
if (sum === undefined) {
|
||||
switch (config.number) {
|
||||
case 'number':
|
||||
return 0;
|
||||
sum = numeric(0, config.number);
|
||||
}
|
||||
|
||||
case 'BigNumber':
|
||||
return bignumber ? bignumber(0) : noBignumber();
|
||||
|
||||
case 'Fraction':
|
||||
return fraction ? fraction(0) : noFraction();
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (typeof sum === 'string') {
|
||||
sum = numeric(sum, config.number);
|
||||
}
|
||||
|
||||
return sum;
|
||||
@ -59524,7 +59543,7 @@ var createReplacer = /* #__PURE__ */Object(factory["a" /* factory */])(replacer_
|
||||
};
|
||||
});
|
||||
// CONCATENATED MODULE: ./src/version.js
|
||||
var version = '7.0.1'; // Note: This file is automatically generated when building math.js.
|
||||
var version = '7.0.2'; // Note: This file is automatically generated when building math.js.
|
||||
// Changes made in this file will be overwritten.
|
||||
// CONCATENATED MODULE: ./src/plain/number/constants.js
|
||||
var constants_pi = Math.PI;
|
||||
@ -60135,12 +60154,16 @@ function map_transform_map(array, callback, orig) {
|
||||
|
||||
|
||||
var max_transform_name = 'max';
|
||||
var max_transform_dependencies = ['typed', 'larger'];
|
||||
var max_transform_dependencies = ['typed', 'config', 'numeric', 'larger'];
|
||||
var createMaxTransform = /* #__PURE__ */Object(factory["a" /* factory */])(max_transform_name, max_transform_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
numeric = _ref.numeric,
|
||||
larger = _ref.larger;
|
||||
var max = createMax({
|
||||
typed: typed,
|
||||
config: config,
|
||||
numeric: numeric,
|
||||
larger: larger
|
||||
});
|
||||
/**
|
||||
@ -60227,12 +60250,16 @@ var createMeanTransform = /* #__PURE__ */Object(factory["a" /* factory */])(mean
|
||||
|
||||
|
||||
var min_transform_name = 'min';
|
||||
var min_transform_dependencies = ['typed', 'smaller'];
|
||||
var min_transform_dependencies = ['typed', 'config', 'numeric', 'smaller'];
|
||||
var createMinTransform = /* #__PURE__ */Object(factory["a" /* factory */])(min_transform_name, min_transform_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
numeric = _ref.numeric,
|
||||
smaller = _ref.smaller;
|
||||
var min = createMin({
|
||||
typed: typed,
|
||||
config: config,
|
||||
numeric: numeric,
|
||||
smaller: smaller
|
||||
});
|
||||
/**
|
||||
@ -60499,19 +60526,17 @@ var createStdTransform = /* #__PURE__ */Object(factory["a" /* factory */])(std_t
|
||||
*/
|
||||
|
||||
var sum_transform_name = 'sum';
|
||||
var sum_transform_dependencies = ['typed', 'config', 'add', '?bignumber', '?fraction'];
|
||||
var sum_transform_dependencies = ['typed', 'config', 'add', 'numeric'];
|
||||
var createSumTransform = /* #__PURE__ */Object(factory["a" /* factory */])(sum_transform_name, sum_transform_dependencies, function (_ref) {
|
||||
var typed = _ref.typed,
|
||||
config = _ref.config,
|
||||
add = _ref.add,
|
||||
bignumber = _ref.bignumber,
|
||||
fraction = _ref.fraction;
|
||||
numeric = _ref.numeric;
|
||||
var sum = createSum({
|
||||
typed: typed,
|
||||
config: config,
|
||||
add: add,
|
||||
bignumber: bignumber,
|
||||
fraction: fraction
|
||||
numeric: numeric
|
||||
});
|
||||
return typed(sum_transform_name, {
|
||||
'...any': function any(args) {
|
||||
|
||||
6
js/lib/math.min.js
vendored
6
js/lib/math.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
6
package-lock.json
generated
6
package-lock.json
generated
@ -2319,9 +2319,9 @@
|
||||
}
|
||||
},
|
||||
"mathjs": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-7.0.1.tgz",
|
||||
"integrity": "sha512-ikFnvtvui8EA1KC+RsF7Sse34WA7EGsKnwwv7/lTRx04t25JtWpVWrs0ZcNKxygZVrOIpU9MRgbvXEFYFV3pOQ==",
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-7.0.2.tgz",
|
||||
"integrity": "sha512-+/HTkdie4Sek66mjcclk2cgTyVgFfykutk5PGspbtZHUBbS3lOeiM8/Ax7P6nQlz1KoellFAU/kGO4q7Yv1sZA==",
|
||||
"requires": {
|
||||
"complex.js": "^2.0.11",
|
||||
"decimal.js": "^10.2.0",
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"url": "https://github.com/josdejong/mathjs.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"mathjs": "7.0.1"
|
||||
"mathjs": "7.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fancy-log": "1.3.3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user