mathjs 11.4.0 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +11 -0
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/reshape.js +1 -1
- package/lib/cjs/function/algebra/simplify.js +58 -5
- package/lib/cjs/function/matrix/reshape.js +1 -1
- package/lib/cjs/function/string/format.js +24 -24
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/reshape.js +1 -1
- package/lib/esm/function/algebra/simplify.js +58 -5
- package/lib/esm/function/matrix/reshape.js +1 -1
- package/lib/esm/function/string/format.js +24 -24
- package/lib/esm/version.js +1 -1
- package/package.json +10 -10
- package/types/index.d.ts +5 -1
@@ -9,7 +9,7 @@ var reshapeDocs = {
|
|
9
9
|
category: 'Matrix',
|
10
10
|
syntax: ['reshape(x, sizes)'],
|
11
11
|
description: 'Reshape a multi dimensional array to fit the specified dimensions.',
|
12
|
-
examples: ['reshape([1, 2, 3, 4, 5, 6], [2, 3])', 'reshape([[1, 2], [3, 4]], [1, 4])', 'reshape([[1, 2], [3, 4]], [4])'],
|
12
|
+
examples: ['reshape([1, 2, 3, 4, 5, 6], [2, 3])', 'reshape([[1, 2], [3, 4]], [1, 4])', 'reshape([[1, 2], [3, 4]], [4])', 'reshape([1, 2, 3, 4], [-1, 2])'],
|
13
13
|
seealso: ['size', 'squeeze', 'resize']
|
14
14
|
};
|
15
15
|
exports.reshapeDocs = reshapeDocs;
|
@@ -421,9 +421,17 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
421
421
|
}, {
|
422
422
|
l: 'n3^(-n4)*n1 + n3^n5 * n2',
|
423
423
|
r: 'n3^(-n4)*(n1 + n3^(n4+n5)*n2)'
|
424
|
-
},
|
424
|
+
},
|
425
|
+
// noncommutative additional cases (term collection & factoring)
|
426
|
+
{
|
425
427
|
s: 'n*vd + vd -> (n+1)*vd',
|
426
|
-
|
428
|
+
assuming: {
|
429
|
+
multiply: {
|
430
|
+
commutative: false
|
431
|
+
}
|
432
|
+
}
|
433
|
+
}, {
|
434
|
+
s: 'vd + n*vd -> (1+n)*vd',
|
427
435
|
assuming: {
|
428
436
|
multiply: {
|
429
437
|
commutative: false
|
@@ -436,6 +444,16 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
436
444
|
commutative: false
|
437
445
|
}
|
438
446
|
}
|
447
|
+
}, {
|
448
|
+
s: 'n^n1 * n -> n^(n1+1)',
|
449
|
+
assuming: {
|
450
|
+
divide: {
|
451
|
+
total: true
|
452
|
+
},
|
453
|
+
multiply: {
|
454
|
+
commutative: false
|
455
|
+
}
|
456
|
+
}
|
439
457
|
}, {
|
440
458
|
s: 'n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)',
|
441
459
|
assuming: {
|
@@ -460,6 +478,13 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
460
478
|
commutative: false
|
461
479
|
}
|
462
480
|
}
|
481
|
+
}, {
|
482
|
+
s: 'cd + cd*n -> cd*(1+n)',
|
483
|
+
assuming: {
|
484
|
+
multiply: {
|
485
|
+
commutative: false
|
486
|
+
}
|
487
|
+
}
|
463
488
|
}, simplifyConstant,
|
464
489
|
// Second: before returning expressions to "standard form"
|
465
490
|
|
@@ -616,15 +641,33 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
616
641
|
newRule.evaluate = parse(ruleObject.evaluate);
|
617
642
|
}
|
618
643
|
if (isAssociative(newRule.l, context)) {
|
644
|
+
var nonCommutative = !isCommutative(newRule.l, context);
|
645
|
+
var leftExpandsym;
|
646
|
+
// Gen. the LHS placeholder used in this NC-context specific expansion rules
|
647
|
+
if (nonCommutative) leftExpandsym = _getExpandPlaceholderSymbol();
|
619
648
|
var makeNode = createMakeNodeFunction(newRule.l);
|
620
649
|
var expandsym = _getExpandPlaceholderSymbol();
|
621
650
|
newRule.expanded = {};
|
622
|
-
newRule.expanded.l = makeNode([newRule.l
|
651
|
+
newRule.expanded.l = makeNode([newRule.l, expandsym]);
|
623
652
|
// Push the expandsym into the deepest possible branch.
|
624
653
|
// This helps to match the newRule against nodes returned from getSplits() later on.
|
625
654
|
flatten(newRule.expanded.l, context);
|
626
655
|
unflattenr(newRule.expanded.l, context);
|
627
656
|
newRule.expanded.r = makeNode([newRule.r, expandsym]);
|
657
|
+
|
658
|
+
// In and for a non-commutative context, attempting with yet additional expansion rules makes
|
659
|
+
// way for more matches cases of multi-arg expressions; such that associative rules (such as
|
660
|
+
// 'n*n -> n^2') can be applied to exprs. such as 'a * b * b' and 'a * b * b * a'.
|
661
|
+
if (nonCommutative) {
|
662
|
+
// 'Non-commutative' 1: LHS (placeholder) only
|
663
|
+
newRule.expandedNC1 = {};
|
664
|
+
newRule.expandedNC1.l = makeNode([leftExpandsym, newRule.l]);
|
665
|
+
newRule.expandedNC1.r = makeNode([leftExpandsym, newRule.r]);
|
666
|
+
// 'Non-commutative' 2: farmost LHS and RHS placeholders
|
667
|
+
newRule.expandedNC2 = {};
|
668
|
+
newRule.expandedNC2.l = makeNode([leftExpandsym, newRule.expanded.l]);
|
669
|
+
newRule.expandedNC2.r = makeNode([leftExpandsym, newRule.expanded.r]);
|
670
|
+
}
|
628
671
|
}
|
629
672
|
return newRule;
|
630
673
|
}
|
@@ -830,6 +873,16 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
830
873
|
repl = rule.expanded.r;
|
831
874
|
matches = _ruleMatch(rule.expanded.l, res, mergedContext)[0];
|
832
875
|
}
|
876
|
+
// Additional, non-commutative context expansion-rules
|
877
|
+
if (!matches && rule.expandedNC1) {
|
878
|
+
repl = rule.expandedNC1.r;
|
879
|
+
matches = _ruleMatch(rule.expandedNC1.l, res, mergedContext)[0];
|
880
|
+
if (!matches) {
|
881
|
+
// Existence of NC1 implies NC2
|
882
|
+
repl = rule.expandedNC2.r;
|
883
|
+
matches = _ruleMatch(rule.expandedNC2.l, res, mergedContext)[0];
|
884
|
+
}
|
885
|
+
}
|
833
886
|
if (matches) {
|
834
887
|
// const before = res.toString({parenthesis: 'all'})
|
835
888
|
|
@@ -1047,8 +1100,8 @@ var createSimplify = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
1047
1100
|
res = mergeChildMatches(childMatches);
|
1048
1101
|
} else if (node.args.length >= 2 && rule.args.length === 2) {
|
1049
1102
|
// node is flattened, rule is not
|
1050
|
-
// Associative operators/functions can be split in different ways so we check if the rule
|
1051
|
-
// them and return their union.
|
1103
|
+
// Associative operators/functions can be split in different ways so we check if the rule
|
1104
|
+
// matches for each of them and return their union.
|
1052
1105
|
var splits = getSplits(node, context);
|
1053
1106
|
var splitMatches = [];
|
1054
1107
|
for (var _i3 = 0; _i3 < splits.length; _i3++) {
|
@@ -53,7 +53,7 @@ var createReshape = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
|
|
53
53
|
*/
|
54
54
|
return typed(name, {
|
55
55
|
'Matrix, Array': function MatrixArray(x, sizes) {
|
56
|
-
return x.reshape(sizes);
|
56
|
+
return x.reshape(sizes, true);
|
57
57
|
},
|
58
58
|
'Array, Array': function ArrayArray(x, sizes) {
|
59
59
|
sizes.forEach(function (size) {
|
@@ -28,53 +28,53 @@ var createFormat = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
|
|
28
28
|
* An object with formatting options. Available options:
|
29
29
|
* - `notation: string`
|
30
30
|
* Number notation. Choose from:
|
31
|
-
* - 'fixed'
|
31
|
+
* - `'fixed'`
|
32
32
|
* Always use regular number notation.
|
33
|
-
* For example '123.40' and '14000000'
|
34
|
-
* - 'exponential'
|
33
|
+
* For example `'123.40'` and `'14000000'`
|
34
|
+
* - `'exponential'`
|
35
35
|
* Always use exponential notation.
|
36
|
-
* For example '1.234e+2' and '1.4e+7'
|
37
|
-
* - 'engineering'
|
36
|
+
* For example `'1.234e+2'` and `'1.4e+7'`
|
37
|
+
* - `'engineering'`
|
38
38
|
* Always use engineering notation: always have exponential notation,
|
39
|
-
* and select the exponent to be a multiple of 3
|
40
|
-
* For example '123.4e+0' and '14.0e+6'
|
41
|
-
* - 'auto' (default)
|
39
|
+
* and select the exponent to be a multiple of `3`.
|
40
|
+
* For example `'123.4e+0'` and `'14.0e+6'`
|
41
|
+
* - `'auto'` (default)
|
42
42
|
* Regular number notation for numbers having an absolute value between
|
43
43
|
* `lower` and `upper` bounds, and uses exponential notation elsewhere.
|
44
44
|
* Lower bound is included, upper bound is excluded.
|
45
|
-
* For example '123.4' and '1.4e7'
|
46
|
-
* - 'bin'
|
45
|
+
* For example `'123.4'` and `'1.4e7'`.
|
46
|
+
* - `'bin'`, `'oct'`, or `'hex'`
|
47
47
|
* Format the number using binary, octal, or hexadecimal notation.
|
48
|
-
* For example '0b1101' and '0x10fe'
|
48
|
+
* For example `'0b1101'` and `'0x10fe'`.
|
49
49
|
* - `wordSize: number`
|
50
50
|
* The word size in bits to use for formatting in binary, octal, or
|
51
|
-
* hexadecimal notation. To be used only with 'bin'
|
52
|
-
* values for
|
51
|
+
* hexadecimal notation. To be used only with `'bin'`, `'oct'`, or `'hex'`
|
52
|
+
* values for `notation` option. When this option is defined the value
|
53
53
|
* is formatted as a signed twos complement integer of the given word
|
54
54
|
* size and the size suffix is appended to the output.
|
55
|
-
* For example format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'
|
55
|
+
* For example `format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'`.
|
56
56
|
* Default value is undefined.
|
57
57
|
* - `precision: number`
|
58
58
|
* Limit the number of digits of the formatted value.
|
59
|
-
* For regular numbers, must be a number between 0 and 16
|
59
|
+
* For regular numbers, must be a number between `0` and `16`.
|
60
60
|
* For bignumbers, the maximum depends on the configured precision,
|
61
61
|
* see function `config()`.
|
62
|
-
* In case of notations 'exponential'
|
63
|
-
* defines the total number of significant digits returned.
|
64
|
-
* In case of notation 'fixed'
|
62
|
+
* In case of notations `'exponential'`, `'engineering'`, and `'auto'`,
|
63
|
+
* `precision` defines the total number of significant digits returned.
|
64
|
+
* In case of notation `'fixed'`, `precision` defines the number of
|
65
65
|
* significant digits after the decimal point.
|
66
66
|
* `precision` is undefined by default.
|
67
67
|
* - `lowerExp: number`
|
68
68
|
* Exponent determining the lower boundary for formatting a value with
|
69
|
-
* an exponent when `notation='auto`. Default value is `-3`.
|
69
|
+
* an exponent when `notation='auto'`. Default value is `-3`.
|
70
70
|
* - `upperExp: number`
|
71
71
|
* Exponent determining the upper boundary for formatting a value with
|
72
|
-
* an exponent when `notation='auto`. Default value is `5`.
|
73
|
-
* - `fraction: string`. Available values: 'ratio' (default) or 'decimal'
|
74
|
-
* For example `format(fraction(1, 3))` will output '1/3' when 'ratio'
|
75
|
-
* configured, and will output `0.(3)` when 'decimal' is configured.
|
72
|
+
* an exponent when `notation='auto'`. Default value is `5`.
|
73
|
+
* - `fraction: string`. Available values: `'ratio'` (default) or `'decimal'`.
|
74
|
+
* For example `format(fraction(1, 3))` will output `'1/3'` when `'ratio'`
|
75
|
+
* is configured, and will output `'0.(3)'` when `'decimal'` is configured.
|
76
76
|
* - `truncate: number`. Specifies the maximum allowed length of the
|
77
|
-
* returned string. If it
|
77
|
+
* returned string. If it had been longer, the excess characters
|
78
78
|
* are deleted and replaced with `'...'`.
|
79
79
|
* - `callback: function`
|
80
80
|
* A custom formatting function, invoked for all numeric elements in `value`,
|
package/lib/cjs/header.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 11.
|
10
|
-
* @date 2022-
|
9
|
+
* @version 11.5.0
|
10
|
+
* @date 2022-12-05
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
package/lib/cjs/version.js
CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.version = void 0;
|
7
|
-
var version = '11.
|
7
|
+
var version = '11.5.0';
|
8
8
|
// Note: This file is automatically generated when building math.js.
|
9
9
|
// Changes made in this file will be overwritten.
|
10
10
|
exports.version = version;
|
@@ -3,6 +3,6 @@ export var reshapeDocs = {
|
|
3
3
|
category: 'Matrix',
|
4
4
|
syntax: ['reshape(x, sizes)'],
|
5
5
|
description: 'Reshape a multi dimensional array to fit the specified dimensions.',
|
6
|
-
examples: ['reshape([1, 2, 3, 4, 5, 6], [2, 3])', 'reshape([[1, 2], [3, 4]], [1, 4])', 'reshape([[1, 2], [3, 4]], [4])'],
|
6
|
+
examples: ['reshape([1, 2, 3, 4, 5, 6], [2, 3])', 'reshape([[1, 2], [3, 4]], [1, 4])', 'reshape([[1, 2], [3, 4]], [4])', 'reshape([1, 2, 3, 4], [-1, 2])'],
|
7
7
|
seealso: ['size', 'squeeze', 'resize']
|
8
8
|
};
|
@@ -412,9 +412,17 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
412
412
|
}, {
|
413
413
|
l: 'n3^(-n4)*n1 + n3^n5 * n2',
|
414
414
|
r: 'n3^(-n4)*(n1 + n3^(n4+n5)*n2)'
|
415
|
-
},
|
415
|
+
},
|
416
|
+
// noncommutative additional cases (term collection & factoring)
|
417
|
+
{
|
416
418
|
s: 'n*vd + vd -> (n+1)*vd',
|
417
|
-
|
419
|
+
assuming: {
|
420
|
+
multiply: {
|
421
|
+
commutative: false
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}, {
|
425
|
+
s: 'vd + n*vd -> (1+n)*vd',
|
418
426
|
assuming: {
|
419
427
|
multiply: {
|
420
428
|
commutative: false
|
@@ -427,6 +435,16 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
427
435
|
commutative: false
|
428
436
|
}
|
429
437
|
}
|
438
|
+
}, {
|
439
|
+
s: 'n^n1 * n -> n^(n1+1)',
|
440
|
+
assuming: {
|
441
|
+
divide: {
|
442
|
+
total: true
|
443
|
+
},
|
444
|
+
multiply: {
|
445
|
+
commutative: false
|
446
|
+
}
|
447
|
+
}
|
430
448
|
}, {
|
431
449
|
s: 'n1*n3^(-n4) + n2 * n3 -> (n1 + n2*n3^(n4 + 1))*n3^(-n4)',
|
432
450
|
assuming: {
|
@@ -451,6 +469,13 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
451
469
|
commutative: false
|
452
470
|
}
|
453
471
|
}
|
472
|
+
}, {
|
473
|
+
s: 'cd + cd*n -> cd*(1+n)',
|
474
|
+
assuming: {
|
475
|
+
multiply: {
|
476
|
+
commutative: false
|
477
|
+
}
|
478
|
+
}
|
454
479
|
}, simplifyConstant,
|
455
480
|
// Second: before returning expressions to "standard form"
|
456
481
|
|
@@ -606,15 +631,33 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
606
631
|
newRule.evaluate = parse(ruleObject.evaluate);
|
607
632
|
}
|
608
633
|
if (isAssociative(newRule.l, context)) {
|
634
|
+
var nonCommutative = !isCommutative(newRule.l, context);
|
635
|
+
var leftExpandsym;
|
636
|
+
// Gen. the LHS placeholder used in this NC-context specific expansion rules
|
637
|
+
if (nonCommutative) leftExpandsym = _getExpandPlaceholderSymbol();
|
609
638
|
var makeNode = createMakeNodeFunction(newRule.l);
|
610
639
|
var expandsym = _getExpandPlaceholderSymbol();
|
611
640
|
newRule.expanded = {};
|
612
|
-
newRule.expanded.l = makeNode([newRule.l
|
641
|
+
newRule.expanded.l = makeNode([newRule.l, expandsym]);
|
613
642
|
// Push the expandsym into the deepest possible branch.
|
614
643
|
// This helps to match the newRule against nodes returned from getSplits() later on.
|
615
644
|
flatten(newRule.expanded.l, context);
|
616
645
|
unflattenr(newRule.expanded.l, context);
|
617
646
|
newRule.expanded.r = makeNode([newRule.r, expandsym]);
|
647
|
+
|
648
|
+
// In and for a non-commutative context, attempting with yet additional expansion rules makes
|
649
|
+
// way for more matches cases of multi-arg expressions; such that associative rules (such as
|
650
|
+
// 'n*n -> n^2') can be applied to exprs. such as 'a * b * b' and 'a * b * b * a'.
|
651
|
+
if (nonCommutative) {
|
652
|
+
// 'Non-commutative' 1: LHS (placeholder) only
|
653
|
+
newRule.expandedNC1 = {};
|
654
|
+
newRule.expandedNC1.l = makeNode([leftExpandsym, newRule.l]);
|
655
|
+
newRule.expandedNC1.r = makeNode([leftExpandsym, newRule.r]);
|
656
|
+
// 'Non-commutative' 2: farmost LHS and RHS placeholders
|
657
|
+
newRule.expandedNC2 = {};
|
658
|
+
newRule.expandedNC2.l = makeNode([leftExpandsym, newRule.expanded.l]);
|
659
|
+
newRule.expandedNC2.r = makeNode([leftExpandsym, newRule.expanded.r]);
|
660
|
+
}
|
618
661
|
}
|
619
662
|
return newRule;
|
620
663
|
}
|
@@ -820,6 +863,16 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
820
863
|
repl = rule.expanded.r;
|
821
864
|
matches = _ruleMatch(rule.expanded.l, res, mergedContext)[0];
|
822
865
|
}
|
866
|
+
// Additional, non-commutative context expansion-rules
|
867
|
+
if (!matches && rule.expandedNC1) {
|
868
|
+
repl = rule.expandedNC1.r;
|
869
|
+
matches = _ruleMatch(rule.expandedNC1.l, res, mergedContext)[0];
|
870
|
+
if (!matches) {
|
871
|
+
// Existence of NC1 implies NC2
|
872
|
+
repl = rule.expandedNC2.r;
|
873
|
+
matches = _ruleMatch(rule.expandedNC2.l, res, mergedContext)[0];
|
874
|
+
}
|
875
|
+
}
|
823
876
|
if (matches) {
|
824
877
|
// const before = res.toString({parenthesis: 'all'})
|
825
878
|
|
@@ -1037,8 +1090,8 @@ export var createSimplify = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
1037
1090
|
res = mergeChildMatches(childMatches);
|
1038
1091
|
} else if (node.args.length >= 2 && rule.args.length === 2) {
|
1039
1092
|
// node is flattened, rule is not
|
1040
|
-
// Associative operators/functions can be split in different ways so we check if the rule
|
1041
|
-
// them and return their union.
|
1093
|
+
// Associative operators/functions can be split in different ways so we check if the rule
|
1094
|
+
// matches for each of them and return their union.
|
1042
1095
|
var splits = getSplits(node, context);
|
1043
1096
|
var splitMatches = [];
|
1044
1097
|
for (var _i2 = 0; _i2 < splits.length; _i2++) {
|
@@ -49,7 +49,7 @@ export var createReshape = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
49
49
|
*/
|
50
50
|
return typed(name, {
|
51
51
|
'Matrix, Array': function MatrixArray(x, sizes) {
|
52
|
-
return x.reshape(sizes);
|
52
|
+
return x.reshape(sizes, true);
|
53
53
|
},
|
54
54
|
'Array, Array': function ArrayArray(x, sizes) {
|
55
55
|
sizes.forEach(function (size) {
|
@@ -24,53 +24,53 @@ export var createFormat = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
24
24
|
* An object with formatting options. Available options:
|
25
25
|
* - `notation: string`
|
26
26
|
* Number notation. Choose from:
|
27
|
-
* - 'fixed'
|
27
|
+
* - `'fixed'`
|
28
28
|
* Always use regular number notation.
|
29
|
-
* For example '123.40' and '14000000'
|
30
|
-
* - 'exponential'
|
29
|
+
* For example `'123.40'` and `'14000000'`
|
30
|
+
* - `'exponential'`
|
31
31
|
* Always use exponential notation.
|
32
|
-
* For example '1.234e+2' and '1.4e+7'
|
33
|
-
* - 'engineering'
|
32
|
+
* For example `'1.234e+2'` and `'1.4e+7'`
|
33
|
+
* - `'engineering'`
|
34
34
|
* Always use engineering notation: always have exponential notation,
|
35
|
-
* and select the exponent to be a multiple of 3
|
36
|
-
* For example '123.4e+0' and '14.0e+6'
|
37
|
-
* - 'auto' (default)
|
35
|
+
* and select the exponent to be a multiple of `3`.
|
36
|
+
* For example `'123.4e+0'` and `'14.0e+6'`
|
37
|
+
* - `'auto'` (default)
|
38
38
|
* Regular number notation for numbers having an absolute value between
|
39
39
|
* `lower` and `upper` bounds, and uses exponential notation elsewhere.
|
40
40
|
* Lower bound is included, upper bound is excluded.
|
41
|
-
* For example '123.4' and '1.4e7'
|
42
|
-
* - 'bin'
|
41
|
+
* For example `'123.4'` and `'1.4e7'`.
|
42
|
+
* - `'bin'`, `'oct'`, or `'hex'`
|
43
43
|
* Format the number using binary, octal, or hexadecimal notation.
|
44
|
-
* For example '0b1101' and '0x10fe'
|
44
|
+
* For example `'0b1101'` and `'0x10fe'`.
|
45
45
|
* - `wordSize: number`
|
46
46
|
* The word size in bits to use for formatting in binary, octal, or
|
47
|
-
* hexadecimal notation. To be used only with 'bin'
|
48
|
-
* values for
|
47
|
+
* hexadecimal notation. To be used only with `'bin'`, `'oct'`, or `'hex'`
|
48
|
+
* values for `notation` option. When this option is defined the value
|
49
49
|
* is formatted as a signed twos complement integer of the given word
|
50
50
|
* size and the size suffix is appended to the output.
|
51
|
-
* For example format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'
|
51
|
+
* For example `format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'`.
|
52
52
|
* Default value is undefined.
|
53
53
|
* - `precision: number`
|
54
54
|
* Limit the number of digits of the formatted value.
|
55
|
-
* For regular numbers, must be a number between 0 and 16
|
55
|
+
* For regular numbers, must be a number between `0` and `16`.
|
56
56
|
* For bignumbers, the maximum depends on the configured precision,
|
57
57
|
* see function `config()`.
|
58
|
-
* In case of notations 'exponential'
|
59
|
-
* defines the total number of significant digits returned.
|
60
|
-
* In case of notation 'fixed'
|
58
|
+
* In case of notations `'exponential'`, `'engineering'`, and `'auto'`,
|
59
|
+
* `precision` defines the total number of significant digits returned.
|
60
|
+
* In case of notation `'fixed'`, `precision` defines the number of
|
61
61
|
* significant digits after the decimal point.
|
62
62
|
* `precision` is undefined by default.
|
63
63
|
* - `lowerExp: number`
|
64
64
|
* Exponent determining the lower boundary for formatting a value with
|
65
|
-
* an exponent when `notation='auto`. Default value is `-3`.
|
65
|
+
* an exponent when `notation='auto'`. Default value is `-3`.
|
66
66
|
* - `upperExp: number`
|
67
67
|
* Exponent determining the upper boundary for formatting a value with
|
68
|
-
* an exponent when `notation='auto`. Default value is `5`.
|
69
|
-
* - `fraction: string`. Available values: 'ratio' (default) or 'decimal'
|
70
|
-
* For example `format(fraction(1, 3))` will output '1/3' when 'ratio'
|
71
|
-
* configured, and will output `0.(3)` when 'decimal' is configured.
|
68
|
+
* an exponent when `notation='auto'`. Default value is `5`.
|
69
|
+
* - `fraction: string`. Available values: `'ratio'` (default) or `'decimal'`.
|
70
|
+
* For example `format(fraction(1, 3))` will output `'1/3'` when `'ratio'`
|
71
|
+
* is configured, and will output `'0.(3)'` when `'decimal'` is configured.
|
72
72
|
* - `truncate: number`. Specifies the maximum allowed length of the
|
73
|
-
* returned string. If it
|
73
|
+
* returned string. If it had been longer, the excess characters
|
74
74
|
* are deleted and replaced with `'...'`.
|
75
75
|
* - `callback: function`
|
76
76
|
* A custom formatting function, invoked for all numeric elements in `value`,
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "11.
|
3
|
+
"version": "11.5.0",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -25,9 +25,9 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.20.
|
28
|
+
"@babel/runtime": "^7.20.6",
|
29
29
|
"complex.js": "^2.1.1",
|
30
|
-
"decimal.js": "^10.4.
|
30
|
+
"decimal.js": "^10.4.3",
|
31
31
|
"escape-latex": "^1.2.0",
|
32
32
|
"fraction.js": "^4.2.0",
|
33
33
|
"javascript-natural-sort": "^0.7.1",
|
@@ -36,15 +36,15 @@
|
|
36
36
|
"typed-function": "^4.1.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.20.
|
39
|
+
"@babel/core": "7.20.5",
|
40
40
|
"@babel/plugin-transform-object-assign": "7.18.6",
|
41
41
|
"@babel/plugin-transform-runtime": "7.19.6",
|
42
42
|
"@babel/preset-env": "7.20.2",
|
43
43
|
"@babel/register": "7.18.9",
|
44
44
|
"@types/assert": "1.5.6",
|
45
|
-
"@types/mocha": "10.0.
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.
|
47
|
-
"@typescript-eslint/parser": "5.
|
45
|
+
"@types/mocha": "10.0.1",
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.45.0",
|
47
|
+
"@typescript-eslint/parser": "5.45.0",
|
48
48
|
"assert": "2.0.0",
|
49
49
|
"babel-loader": "9.1.0",
|
50
50
|
"benchmark": "2.1.4",
|
@@ -52,12 +52,12 @@
|
|
52
52
|
"core-js": "3.26.1",
|
53
53
|
"del": "6.1.1",
|
54
54
|
"dtslint": "4.2.1",
|
55
|
-
"eslint": "8.
|
55
|
+
"eslint": "8.29.0",
|
56
56
|
"eslint-config-prettier": "8.5.0",
|
57
57
|
"eslint-config-standard": "17.0.0",
|
58
58
|
"eslint-plugin-import": "2.26.0",
|
59
59
|
"eslint-plugin-mocha": "10.1.0",
|
60
|
-
"eslint-plugin-n": "15.
|
60
|
+
"eslint-plugin-n": "15.6.0",
|
61
61
|
"eslint-plugin-prettier": "4.2.1",
|
62
62
|
"eslint-plugin-promise": "6.1.1",
|
63
63
|
"expect-type": "0.15.0",
|
@@ -87,7 +87,7 @@
|
|
87
87
|
"numericjs": "1.2.6",
|
88
88
|
"nyc": "15.1.0",
|
89
89
|
"pad-right": "0.2.2",
|
90
|
-
"prettier": "2.
|
90
|
+
"prettier": "2.8.0",
|
91
91
|
"process": "0.11.10",
|
92
92
|
"sylvester": "0.0.21",
|
93
93
|
"ts-node": "10.9.1",
|
package/types/index.d.ts
CHANGED
@@ -1297,9 +1297,13 @@ declare namespace math {
|
|
1297
1297
|
multiply<T extends Matrix>(x: T, y: MathType): Matrix
|
1298
1298
|
multiply<T extends Matrix>(x: MathType, y: T): Matrix
|
1299
1299
|
|
1300
|
+
multiply<T extends MathNumericType[]>(x: T, y: T[]): T
|
1301
|
+
multiply<T extends MathNumericType[]>(x: T[], y: T): T
|
1302
|
+
|
1303
|
+
multiply<T extends MathArray>(x: T, y: T): T
|
1304
|
+
|
1300
1305
|
multiply(x: Unit, y: Unit): Unit
|
1301
1306
|
multiply(x: number, y: number): number
|
1302
|
-
multiply(x: MathArray, y: MathArray): MathArray
|
1303
1307
|
multiply(x: MathType, y: MathType): MathType
|
1304
1308
|
|
1305
1309
|
/**
|