mathjs 5.9.0 → 5.10.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mathjs might be problematic. Click here for more details.
- package/HISTORY.md +26 -1
- package/dist/math.js +52 -30
- package/dist/math.min.js +5 -5
- package/dist/math.min.map +1 -1
- package/docs/reference/functions/column.md +3 -3
- package/docs/reference/functions/row.md +3 -3
- package/docs/reference/functions.md +2 -2
- package/lib/expression/embeddedDocs/function/matrix/column.js +2 -2
- package/lib/expression/embeddedDocs/function/matrix/row.js +2 -2
- package/lib/function/matrix/column.js +3 -3
- package/lib/function/matrix/row.js +3 -3
- package/lib/header.js +2 -3
- package/lib/utils/bignumber/formatter.js +8 -3
- package/lib/utils/number.js +8 -3
- package/lib/version.js +1 -1
- package/package.json +17 -15
- package/src/expression/embeddedDocs/function/matrix/column.js +4 -2
- package/src/expression/embeddedDocs/function/matrix/row.js +4 -2
- package/src/function/matrix/column.js +3 -3
- package/src/function/matrix/row.js +3 -3
- package/src/utils/bignumber/formatter.js +7 -4
- package/src/utils/number.js +10 -3
- package/src/version.js +1 -1
package/HISTORY.md
CHANGED
@@ -1,7 +1,32 @@
|
|
1
1
|
# History
|
2
2
|
|
3
3
|
|
4
|
-
#
|
4
|
+
# 2019-05-18, version 5.10.3
|
5
|
+
|
6
|
+
- Fixed dependency `del` being a dependency instead of devDependency.
|
7
|
+
|
8
|
+
|
9
|
+
# 2019-05-18, version 5.10.2
|
10
|
+
|
11
|
+
- Fix #1515, #1516, #1517: broken package due to a naming conflict in
|
12
|
+
the build folder of a util file `typeOf.js` and `typeof.js`.
|
13
|
+
Solved by properly cleaning all build folders before building.
|
14
|
+
|
15
|
+
|
16
|
+
# 2019-05-17, version 5.10.1
|
17
|
+
|
18
|
+
- Fix #1512: format using notation `engineering` can give wrong results
|
19
|
+
when the value has less significant digits than the number of digits in
|
20
|
+
the output.
|
21
|
+
|
22
|
+
|
23
|
+
# 2019-05-08, version 5.10.0
|
24
|
+
|
25
|
+
- Fix `lib/header.js` not having filled in date and version. Thanks @kevjin.
|
26
|
+
- Upgraded dependency `decimal.js@10.2.0`, fixing an issue on node.js 12.
|
27
|
+
|
28
|
+
|
29
|
+
# 2019-04-08, version 5.9.0
|
5
30
|
|
6
31
|
- Implemented functions `row` and `column` (see #1413). Thanks @SzechuanSage.
|
7
32
|
- Fixed #1459: `engineering` notation of function `format` not available
|
package/dist/math.js
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
* It features real and complex numbers, units, matrices, a large set of
|
7
7
|
* mathematical functions, and a flexible expression parser.
|
8
8
|
*
|
9
|
-
* @version 5.
|
10
|
-
* @date 2019-
|
9
|
+
* @version 5.10.3
|
10
|
+
* @date 2019-05-18
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2019 Jos de Jong <wjosdejong@gmail.com>
|
@@ -1062,20 +1062,25 @@ exports.toEngineering = function (value, precision) {
|
|
1062
1062
|
|
1063
1063
|
if (exports.isNumber(precision)) {
|
1064
1064
|
// add zeroes to give correct sig figs
|
1065
|
-
|
1065
|
+
while (precision > c.length || e - newExp + 1 > c.length) {
|
1066
|
+
c.push(0);
|
1067
|
+
}
|
1066
1068
|
} else {
|
1067
1069
|
// concatenate coefficients with necessary zeros
|
1068
1070
|
var significandsDiff = e >= 0 ? e : Math.abs(newExp); // add zeros if necessary (for ex: 1e+8)
|
1069
1071
|
|
1070
|
-
|
1072
|
+
while (c.length - 1 < significandsDiff) {
|
1073
|
+
c.push(0);
|
1074
|
+
}
|
1071
1075
|
} // find difference in exponents
|
1072
1076
|
|
1073
1077
|
|
1074
1078
|
var expDiff = Math.abs(e - newExp);
|
1075
1079
|
var decimalIdx = 1; // push decimal index over by expDiff times
|
1076
1080
|
|
1077
|
-
while (
|
1081
|
+
while (expDiff > 0) {
|
1078
1082
|
decimalIdx++;
|
1083
|
+
expDiff--;
|
1079
1084
|
} // if all coefficient values are zero after the decimal point and precision is unset, don't add a decimal value.
|
1080
1085
|
// otherwise concat with the rest of the coefficients
|
1081
1086
|
|
@@ -24762,17 +24767,17 @@ function factory(type, config, load, typed) {
|
|
24762
24767
|
var matrix = load(__webpack_require__(0));
|
24763
24768
|
var range = load(__webpack_require__(77));
|
24764
24769
|
/**
|
24765
|
-
* Return column
|
24770
|
+
* Return a column from a Matrix.
|
24766
24771
|
*
|
24767
24772
|
* Syntax:
|
24768
24773
|
*
|
24769
|
-
* math.column(value, index)
|
24774
|
+
* math.column(value, index)
|
24770
24775
|
*
|
24771
24776
|
* Example:
|
24772
24777
|
*
|
24773
24778
|
* // get a column
|
24774
24779
|
* const d = [[1, 2], [3, 4]]
|
24775
|
-
* math.column(d, 1)
|
24780
|
+
* math.column(d, 1) // returns [2, 4]
|
24776
24781
|
*
|
24777
24782
|
* See also:
|
24778
24783
|
*
|
@@ -25039,17 +25044,17 @@ function factory(type, config, load, typed) {
|
|
25039
25044
|
var matrix = load(__webpack_require__(0));
|
25040
25045
|
var range = load(__webpack_require__(77));
|
25041
25046
|
/**
|
25042
|
-
* Return row
|
25047
|
+
* Return a row from a Matrix.
|
25043
25048
|
*
|
25044
25049
|
* Syntax:
|
25045
25050
|
*
|
25046
|
-
* math.row(value, index)
|
25051
|
+
* math.row(value, index)
|
25047
25052
|
*
|
25048
25053
|
* Example:
|
25049
25054
|
*
|
25050
25055
|
* // get a row
|
25051
25056
|
* const d = [[1, 2], [3, 4]]
|
25052
|
-
* math.row(d, 1)
|
25057
|
+
* math.row(d, 1) // returns [3, 4]
|
25053
25058
|
*
|
25054
25059
|
* See also:
|
25055
25060
|
*
|
@@ -26593,7 +26598,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
26593
26598
|
|
26594
26599
|
|
26595
26600
|
/*
|
26596
|
-
* decimal.js v10.
|
26601
|
+
* decimal.js v10.2.0
|
26597
26602
|
* An arbitrary-precision Decimal type for JavaScript.
|
26598
26603
|
* https://github.com/MikeMcl/decimal.js
|
26599
26604
|
* Copyright (c) 2019 Michael Mclaughlin <M8ch88l@gmail.com>
|
@@ -26907,7 +26912,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
26907
26912
|
external = false;
|
26908
26913
|
|
26909
26914
|
// Initial estimate.
|
26910
|
-
s = x.s *
|
26915
|
+
s = x.s * mathpow(x.s * x, 1 / 3);
|
26911
26916
|
|
26912
26917
|
// Math.cbrt underflow/overflow?
|
26913
26918
|
// Pass x to Math.pow as integer, then adjust the exponent of the result.
|
@@ -26917,7 +26922,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
26917
26922
|
|
26918
26923
|
// Adjust n exponent so it is a multiple of 3 away from x exponent.
|
26919
26924
|
if (s = (e - n.length + 1) % 3) n += (s == 1 || s == -2 ? '0' : '00');
|
26920
|
-
s =
|
26925
|
+
s = mathpow(n, 1 / 3);
|
26921
26926
|
|
26922
26927
|
// Rarely, e may be one less than the result exponent value.
|
26923
26928
|
e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
|
@@ -27136,7 +27141,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
27136
27141
|
// TODO? Estimation reused from cosine() and may not be optimal here.
|
27137
27142
|
if (len < 32) {
|
27138
27143
|
k = Math.ceil(len / 3);
|
27139
|
-
n =
|
27144
|
+
n = (1 / tinyPow(4, k)).toString();
|
27140
27145
|
} else {
|
27141
27146
|
k = 16;
|
27142
27147
|
n = '2.3283064365386962890625e-10';
|
@@ -27216,8 +27221,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
27216
27221
|
k = 1.4 * Math.sqrt(len);
|
27217
27222
|
k = k > 16 ? 16 : k | 0;
|
27218
27223
|
|
27219
|
-
x = x.times(
|
27220
|
-
|
27224
|
+
x = x.times(1 / tinyPow(5, k));
|
27221
27225
|
x = taylorSeries(Ctor, 2, x, x, true);
|
27222
27226
|
|
27223
27227
|
// Reverse argument reduction
|
@@ -29228,7 +29232,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
29228
29232
|
// Estimate the optimum number of times to use the argument reduction.
|
29229
29233
|
if (len < 32) {
|
29230
29234
|
k = Math.ceil(len / 3);
|
29231
|
-
y =
|
29235
|
+
y = (1 / tinyPow(4, k)).toString();
|
29232
29236
|
} else {
|
29233
29237
|
k = 16;
|
29234
29238
|
y = '2.3283064365386962890625e-10';
|
@@ -30239,7 +30243,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
30239
30243
|
if (isFloat) x = divide(x, divisor, len * 4);
|
30240
30244
|
|
30241
30245
|
// Multiply by the binary exponent part if present.
|
30242
|
-
if (p) x = x.times(Math.abs(p) < 54 ?
|
30246
|
+
if (p) x = x.times(Math.abs(p) < 54 ? mathpow(2, p) : Decimal.pow(2, p));
|
30243
30247
|
external = true;
|
30244
30248
|
|
30245
30249
|
return x;
|
@@ -30265,8 +30269,7 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
30265
30269
|
k = 1.4 * Math.sqrt(len);
|
30266
30270
|
k = k > 16 ? 16 : k | 0;
|
30267
30271
|
|
30268
|
-
|
30269
|
-
x = x.times(Math.pow(5, -k));
|
30272
|
+
x = x.times(1 / tinyPow(5, k));
|
30270
30273
|
x = taylorSeries(Ctor, 2, x, x);
|
30271
30274
|
|
30272
30275
|
// Reverse argument reduction
|
@@ -30319,6 +30322,14 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
30319
30322
|
}
|
30320
30323
|
|
30321
30324
|
|
30325
|
+
// Exponent e must be positive and non-zero.
|
30326
|
+
function tinyPow(b, e) {
|
30327
|
+
var n = b;
|
30328
|
+
while (--e) n *= b;
|
30329
|
+
return n;
|
30330
|
+
}
|
30331
|
+
|
30332
|
+
|
30322
30333
|
// Return the absolute value of `x` reduced to less than or equal to half pi.
|
30323
30334
|
function toLessThanHalfPi(Ctor, x) {
|
30324
30335
|
var t,
|
@@ -30925,10 +30936,12 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
30925
30936
|
}
|
30926
30937
|
|
30927
30938
|
// Minus sign?
|
30928
|
-
if (v.charCodeAt(0) === 45) {
|
30939
|
+
if ((i = v.charCodeAt(0)) === 45) {
|
30929
30940
|
v = v.slice(1);
|
30930
30941
|
x.s = -1;
|
30931
30942
|
} else {
|
30943
|
+
// Plus sign?
|
30944
|
+
if (i === 43) v = v.slice(1);
|
30932
30945
|
x.s = 1;
|
30933
30946
|
}
|
30934
30947
|
|
@@ -31045,6 +31058,8 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
31045
31058
|
*
|
31046
31059
|
* hypot(a, b, ...) = sqrt(a^2 + b^2 + ...)
|
31047
31060
|
*
|
31061
|
+
* arguments {number|string|Decimal}
|
31062
|
+
*
|
31048
31063
|
*/
|
31049
31064
|
function hypot() {
|
31050
31065
|
var i, n,
|
@@ -31319,6 +31334,8 @@ var __WEBPACK_AMD_DEFINE_RESULT__;;(function (globalScope) {
|
|
31319
31334
|
* -0 if x is -0,
|
31320
31335
|
* NaN otherwise
|
31321
31336
|
*
|
31337
|
+
* x {number|string|Decimal}
|
31338
|
+
*
|
31322
31339
|
*/
|
31323
31340
|
function sign(x) {
|
31324
31341
|
x = new this(x);
|
@@ -34123,9 +34140,14 @@ exports.toEngineering = function (value, precision) {
|
|
34123
34140
|
var e = value.e;
|
34124
34141
|
var newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3; // find difference in exponents, and calculate the value without exponent
|
34125
34142
|
|
34126
|
-
var
|
34127
|
-
var
|
34128
|
-
|
34143
|
+
var valueWithoutExp = value.mul(Math.pow(10, -newExp));
|
34144
|
+
var valueStr = valueWithoutExp.toPrecision(precision);
|
34145
|
+
|
34146
|
+
if (valueStr.indexOf('e') !== -1) {
|
34147
|
+
valueStr = valueWithoutExp.toString();
|
34148
|
+
}
|
34149
|
+
|
34150
|
+
return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();
|
34129
34151
|
};
|
34130
34152
|
/**
|
34131
34153
|
* Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
|
@@ -43728,7 +43750,7 @@ exports.math = true; // request access to the math namespace
|
|
43728
43750
|
/* 201 */
|
43729
43751
|
/***/ (function(module, exports) {
|
43730
43752
|
|
43731
|
-
module.exports = '5.
|
43753
|
+
module.exports = '5.10.3'; // Note: This file is automatically generated when building math.js.
|
43732
43754
|
// Changes made in this file will be overwritten.
|
43733
43755
|
|
43734
43756
|
/***/ }),
|
@@ -59625,8 +59647,8 @@ module.exports = {
|
|
59625
59647
|
'name': 'column',
|
59626
59648
|
'category': 'Matrix',
|
59627
59649
|
'syntax': ['column(x, index)'],
|
59628
|
-
'description': 'Return a column from a matrix or array.
|
59629
|
-
'examples': ['
|
59650
|
+
'description': 'Return a column from a matrix or array.',
|
59651
|
+
'examples': ['A = [[1, 2], [3, 4]]', 'column(A, 1)', 'column(A, 2)'],
|
59630
59652
|
'seealso': ['row']
|
59631
59653
|
};
|
59632
59654
|
|
@@ -59885,8 +59907,8 @@ module.exports = {
|
|
59885
59907
|
'name': 'row',
|
59886
59908
|
'category': 'Matrix',
|
59887
59909
|
'syntax': ['row(x, index)'],
|
59888
|
-
'description': 'Return a row from a matrix or array.
|
59889
|
-
'examples': ['
|
59910
|
+
'description': 'Return a row from a matrix or array.',
|
59911
|
+
'examples': ['A = [[1, 2], [3, 4]]', 'row(A, 1)', 'row(A, 2)'],
|
59890
59912
|
'seealso': ['column']
|
59891
59913
|
};
|
59892
59914
|
|