mathjs 11.4.0 → 11.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. package/HISTORY.md +29 -0
  2. package/NOTICE +1 -1
  3. package/README.md +2 -2
  4. package/bin/cli.js +1 -1
  5. package/lib/browser/math.js +1 -1
  6. package/lib/browser/math.js.LICENSE.txt +3 -3
  7. package/lib/browser/math.js.map +1 -1
  8. package/lib/cjs/expression/embeddedDocs/function/arithmetic/invmod.js +1 -1
  9. package/lib/cjs/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
  10. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromColumns.js +1 -1
  11. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromFunction.js +1 -1
  12. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromRows.js +1 -1
  13. package/lib/cjs/expression/embeddedDocs/function/matrix/reshape.js +1 -1
  14. package/lib/cjs/expression/embeddedDocs/function/matrix/rotate.js +1 -1
  15. package/lib/cjs/expression/embeddedDocs/function/probability/lgamma.js +1 -1
  16. package/lib/cjs/expression/embeddedDocs/function/statistics/max.js +1 -1
  17. package/lib/cjs/expression/embeddedDocs/function/statistics/mean.js +1 -1
  18. package/lib/cjs/expression/embeddedDocs/function/statistics/min.js +1 -1
  19. package/lib/cjs/expression/embeddedDocs/function/statistics/std.js +1 -1
  20. package/lib/cjs/expression/embeddedDocs/function/statistics/sum.js +1 -1
  21. package/lib/cjs/expression/embeddedDocs/function/statistics/variance.js +1 -1
  22. package/lib/cjs/function/algebra/simplify.js +58 -5
  23. package/lib/cjs/function/matrix/reshape.js +1 -1
  24. package/lib/cjs/function/statistics/max.js +2 -2
  25. package/lib/cjs/function/statistics/mean.js +2 -2
  26. package/lib/cjs/function/statistics/min.js +2 -2
  27. package/lib/cjs/function/statistics/mode.js +1 -1
  28. package/lib/cjs/function/statistics/prod.js +1 -1
  29. package/lib/cjs/function/statistics/quantileSeq.js +1 -1
  30. package/lib/cjs/function/statistics/sum.js +3 -2
  31. package/lib/cjs/function/statistics/variance.js +1 -1
  32. package/lib/cjs/function/string/format.js +24 -24
  33. package/lib/cjs/header.js +3 -3
  34. package/lib/cjs/version.js +1 -1
  35. package/lib/esm/expression/embeddedDocs/function/arithmetic/invmod.js +1 -1
  36. package/lib/esm/expression/embeddedDocs/function/arithmetic/pow.js +1 -1
  37. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromColumns.js +1 -1
  38. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromFunction.js +1 -1
  39. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromRows.js +1 -1
  40. package/lib/esm/expression/embeddedDocs/function/matrix/reshape.js +1 -1
  41. package/lib/esm/expression/embeddedDocs/function/matrix/rotate.js +1 -1
  42. package/lib/esm/expression/embeddedDocs/function/probability/lgamma.js +1 -1
  43. package/lib/esm/expression/embeddedDocs/function/statistics/max.js +1 -1
  44. package/lib/esm/expression/embeddedDocs/function/statistics/mean.js +1 -1
  45. package/lib/esm/expression/embeddedDocs/function/statistics/min.js +1 -1
  46. package/lib/esm/expression/embeddedDocs/function/statistics/std.js +1 -1
  47. package/lib/esm/expression/embeddedDocs/function/statistics/sum.js +1 -1
  48. package/lib/esm/expression/embeddedDocs/function/statistics/variance.js +1 -1
  49. package/lib/esm/function/algebra/simplify.js +58 -5
  50. package/lib/esm/function/matrix/reshape.js +1 -1
  51. package/lib/esm/function/statistics/max.js +2 -2
  52. package/lib/esm/function/statistics/mean.js +2 -2
  53. package/lib/esm/function/statistics/min.js +2 -2
  54. package/lib/esm/function/statistics/mode.js +1 -1
  55. package/lib/esm/function/statistics/prod.js +1 -1
  56. package/lib/esm/function/statistics/quantileSeq.js +1 -1
  57. package/lib/esm/function/statistics/sum.js +3 -2
  58. package/lib/esm/function/statistics/variance.js +1 -1
  59. package/lib/esm/function/string/format.js +24 -24
  60. package/lib/esm/header.js +1 -1
  61. package/lib/esm/version.js +1 -1
  62. package/package.json +21 -23
  63. package/types/index.d.ts +71 -10
@@ -1,7 +1,7 @@
1
1
  export var sumDocs = {
2
2
  name: 'sum',
3
3
  category: 'Statistics',
4
- syntax: ['sum(a, b, c, ...)', 'sum(A)'],
4
+ syntax: ['sum(a, b, c, ...)', 'sum(A)', 'sum(A, dimension)'],
5
5
  description: 'Compute the sum of all values.',
6
6
  examples: ['sum(2, 3, 4, 1)', 'sum([2, 3, 4, 1])', 'sum([2, 5; 4, 3])'],
7
7
  seealso: ['max', 'mean', 'median', 'min', 'prod', 'std', 'sum', 'variance']
@@ -1,7 +1,7 @@
1
1
  export var varianceDocs = {
2
2
  name: 'variance',
3
3
  category: 'Statistics',
4
- syntax: ['variance(a, b, c, ...)', 'variance(A)', 'variance(A, normalization)'],
4
+ syntax: ['variance(a, b, c, ...)', 'variance(A)', 'variance(A, dimension)', 'variance(A, normalization)', 'variance(A, dimension, normalization)'],
5
5
  description: 'Compute the variance of all values. Optional parameter normalization can be "unbiased" (default), "uncorrected", or "biased".',
6
6
  examples: ['variance(2, 4, 6)', 'variance([2, 4, 6, 8])', 'variance([2, 4, 6, 8], "uncorrected")', 'variance([2, 4, 6, 8], "biased")', 'variance([1, 2, 3; 4, 5, 6])'],
7
7
  seealso: ['max', 'mean', 'min', 'median', 'min', 'prod', 'std', 'sum']
@@ -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
- // noncommutative additional cases
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.clone(), expandsym]);
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 matches each
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) {
@@ -12,7 +12,7 @@ export var createMax = /* #__PURE__ */factory(name, dependencies, _ref => {
12
12
  } = _ref;
13
13
  /**
14
14
  * Compute the maximum value of a matrix or a list with values.
15
- * In case of a multi dimensional array, the maximum of the flattened array
15
+ * In case of a multidimensional array, the maximum of the flattened array
16
16
  * will be calculated. When `dim` is provided, the maximum over the selected
17
17
  * dimension will be calculated. Parameter `dim` is zero-based.
18
18
  *
@@ -20,7 +20,7 @@ export var createMax = /* #__PURE__ */factory(name, dependencies, _ref => {
20
20
  *
21
21
  * math.max(a, b, c, ...)
22
22
  * math.max(A)
23
- * math.max(A, dim)
23
+ * math.max(A, dimension)
24
24
  *
25
25
  * Examples:
26
26
  *
@@ -12,7 +12,7 @@ export var createMean = /* #__PURE__ */factory(name, dependencies, _ref => {
12
12
  } = _ref;
13
13
  /**
14
14
  * Compute the mean value of matrix or a list with values.
15
- * In case of a multi dimensional array, the mean of the flattened array
15
+ * In case of a multidimensional array, the mean of the flattened array
16
16
  * will be calculated. When `dim` is provided, the maximum over the selected
17
17
  * dimension will be calculated. Parameter `dim` is zero-based.
18
18
  *
@@ -20,7 +20,7 @@ export var createMean = /* #__PURE__ */factory(name, dependencies, _ref => {
20
20
  *
21
21
  * math.mean(a, b, c, ...)
22
22
  * math.mean(A)
23
- * math.mean(A, dim)
23
+ * math.mean(A, dimension)
24
24
  *
25
25
  * Examples:
26
26
  *
@@ -12,7 +12,7 @@ export var createMin = /* #__PURE__ */factory(name, dependencies, _ref => {
12
12
  } = _ref;
13
13
  /**
14
14
  * Compute the minimum value of a matrix or a list of values.
15
- * In case of a multi dimensional array, the minimum of the flattened array
15
+ * In case of a multidimensional array, the minimum of the flattened array
16
16
  * will be calculated. When `dim` is provided, the minimum over the selected
17
17
  * dimension will be calculated. Parameter `dim` is zero-based.
18
18
  *
@@ -20,7 +20,7 @@ export var createMin = /* #__PURE__ */factory(name, dependencies, _ref => {
20
20
  *
21
21
  * math.min(a, b, c, ...)
22
22
  * math.min(A)
23
- * math.min(A, dim)
23
+ * math.min(A, dimension)
24
24
  *
25
25
  * Examples:
26
26
  *
@@ -10,7 +10,7 @@ export var createMode = /* #__PURE__ */factory(name, dependencies, _ref => {
10
10
  } = _ref;
11
11
  /**
12
12
  * Computes the mode of a set of numbers or a list with values(numbers or characters).
13
- * If there are more than one modes, it returns a list of those values.
13
+ * If there are multiple modes, it returns a list of those values.
14
14
  *
15
15
  * Syntax:
16
16
  *
@@ -12,7 +12,7 @@ export var createProd = /* #__PURE__ */factory(name, dependencies, _ref => {
12
12
  } = _ref;
13
13
  /**
14
14
  * Compute the product of a matrix or a list with values.
15
- * In case of a (multi dimensional) array or matrix, the sum of all
15
+ * In case of a multidimensional array or matrix, the sum of all
16
16
  * elements will be calculated.
17
17
  *
18
18
  * Syntax:
@@ -18,7 +18,7 @@ export var createQuantileSeq = /* #__PURE__ */factory(name, dependencies, _ref =
18
18
  * Supported types of sequence values are: Number, BigNumber, Unit
19
19
  * Supported types of probability are: Number, BigNumber
20
20
  *
21
- * In case of a (multi dimensional) array or matrix, the prob order quantile
21
+ * In case of a multidimensional array or matrix, the prob order quantile
22
22
  * of all elements will be calculated.
23
23
  *
24
24
  * Syntax:
@@ -12,13 +12,14 @@ export var createSum = /* #__PURE__ */factory(name, dependencies, _ref => {
12
12
  } = _ref;
13
13
  /**
14
14
  * Compute the sum of a matrix or a list with values.
15
- * In case of a (multi dimensional) array or matrix, the sum of all
15
+ * In case of a multidimensional array or matrix, the sum of all
16
16
  * elements will be calculated.
17
17
  *
18
18
  * Syntax:
19
19
  *
20
20
  * math.sum(a, b, c, ...)
21
21
  * math.sum(A)
22
+ * math.sum(A, dimension)
22
23
  *
23
24
  * Examples:
24
25
  *
@@ -30,7 +31,7 @@ export var createSum = /* #__PURE__ */factory(name, dependencies, _ref => {
30
31
  *
31
32
  * mean, median, min, max, prod, std, variance, cumsum
32
33
  *
33
- * @param {... *} args A single matrix or or multiple scalar values
34
+ * @param {... *} args A single matrix or multiple scalar values
34
35
  * @return {*} The sum of all values
35
36
  */
36
37
  return typed(name, {
@@ -17,7 +17,7 @@ export var createVariance = /* #__PURE__ */factory(name, dependencies, _ref => {
17
17
  } = _ref;
18
18
  /**
19
19
  * Compute the variance of a matrix or a list with values.
20
- * In case of a (multi dimensional) array or matrix, the variance over all
20
+ * In case of a multidimensional array or matrix, the variance over all
21
21
  * elements will be calculated.
22
22
  *
23
23
  * Additionally, it is possible to compute the variance along the rows
@@ -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', 'oct, or 'hex'
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', 'oct', or 'hex'
48
- * values for 'notation' option. When this option is defined the value
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', 'engineering', and 'auto', `precision`
59
- * defines the total number of significant digits returned.
60
- * In case of notation 'fixed', `precision` defines the number of
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' is
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 would have been longer, the excess characters
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/header.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * @date @@date
11
11
  *
12
12
  * @license
13
- * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
13
+ * Copyright (C) 2013-2023 Jos de Jong <wjosdejong@gmail.com>
14
14
  *
15
15
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
16
16
  * use this file except in compliance with the License. You may obtain a copy
@@ -1,3 +1,3 @@
1
- export var version = '11.4.0';
1
+ export var version = '11.5.1';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "11.4.0",
3
+ "version": "11.5.1",
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.1",
28
+ "@babel/runtime": "^7.20.13",
29
29
  "complex.js": "^2.1.1",
30
- "decimal.js": "^10.4.2",
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,48 +36,47 @@
36
36
  "typed-function": "^4.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.20.2",
39
+ "@babel/core": "7.20.12",
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.0",
46
- "@typescript-eslint/eslint-plugin": "5.43.0",
47
- "@typescript-eslint/parser": "5.43.0",
45
+ "@types/mocha": "10.0.1",
46
+ "@typescript-eslint/eslint-plugin": "5.50.0",
47
+ "@typescript-eslint/parser": "5.50.0",
48
48
  "assert": "2.0.0",
49
- "babel-loader": "9.1.0",
49
+ "babel-loader": "9.1.2",
50
50
  "benchmark": "2.1.4",
51
+ "c8": "7.12.0",
51
52
  "codecov": "3.8.3",
52
- "core-js": "3.26.1",
53
+ "core-js": "3.27.2",
53
54
  "del": "6.1.1",
54
55
  "dtslint": "4.2.1",
55
- "eslint": "8.27.0",
56
- "eslint-config-prettier": "8.5.0",
56
+ "eslint": "8.33.0",
57
+ "eslint-config-prettier": "8.6.0",
57
58
  "eslint-config-standard": "17.0.0",
58
- "eslint-plugin-import": "2.26.0",
59
+ "eslint-plugin-import": "2.27.5",
59
60
  "eslint-plugin-mocha": "10.1.0",
60
- "eslint-plugin-n": "15.5.1",
61
+ "eslint-plugin-n": "15.6.1",
61
62
  "eslint-plugin-prettier": "4.2.1",
62
63
  "eslint-plugin-promise": "6.1.1",
63
64
  "expect-type": "0.15.0",
64
65
  "expr-eval": "2.0.2",
65
66
  "fancy-log": "2.0.0",
66
- "glob": "8.0.3",
67
+ "glob": "8.1.0",
67
68
  "gulp": "4.0.2",
68
69
  "gulp-babel": "8.0.0",
69
70
  "handlebars": "4.7.7",
70
- "istanbul": "0.4.5",
71
- "jsep": "1.3.7",
71
+ "jsep": "1.3.8",
72
72
  "karma": "6.4.1",
73
73
  "karma-browserstack-launcher": "1.6.0",
74
74
  "karma-firefox-launcher": "2.1.2",
75
75
  "karma-mocha": "2.0.1",
76
76
  "karma-mocha-reporter": "2.2.5",
77
77
  "karma-webpack": "5.0.0",
78
- "math-expression-evaluator": "1.4.0",
79
- "mkdirp": "1.0.4",
80
- "mocha": "10.1.0",
78
+ "mkdirp": "2.1.3",
79
+ "mocha": "10.2.0",
81
80
  "mocha-junit-reporter": "2.2.0",
82
81
  "ndarray": "1.0.19",
83
82
  "ndarray-determinant": "1.0.0",
@@ -85,13 +84,12 @@
85
84
  "ndarray-ops": "1.2.2",
86
85
  "ndarray-pack": "1.2.1",
87
86
  "numericjs": "1.2.6",
88
- "nyc": "15.1.0",
89
87
  "pad-right": "0.2.2",
90
- "prettier": "2.7.1",
88
+ "prettier": "2.8.3",
91
89
  "process": "0.11.10",
92
90
  "sylvester": "0.0.21",
93
91
  "ts-node": "10.9.1",
94
- "typescript": "4.9.3",
92
+ "typescript": "4.9.5",
95
93
  "webpack": "5.75.0",
96
94
  "zeros": "1.0.0"
97
95
  },
@@ -163,7 +161,7 @@
163
161
  "test:browser": "karma start test/browser-test-config/local-karma.js",
164
162
  "test:browserstack": "karma start test/browser-test-config/browserstack-karma.js",
165
163
  "test:types": " tsc -p ./tsconfig.json && node --loader ts-node/esm ./test/typescript-tests/testTypes.ts",
166
- "coverage": "nyc --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
164
+ "coverage": "c8 --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
167
165
  "prepublishOnly": "npm run test:all && npm run lint",
168
166
  "update-authors": "node ./tools/update-authors.js"
169
167
  },
package/types/index.d.ts CHANGED
@@ -622,7 +622,7 @@ declare namespace math {
622
622
  * complex number
623
623
  * @returns Returns a complex value
624
624
  */
625
- complex(arg?: Complex | string | PolarCoordinates): Complex
625
+ complex(arg?: MathNumericType | string | PolarCoordinates): Complex
626
626
  complex(arg?: MathCollection): MathCollection
627
627
  /**
628
628
  * @param re Argument specifying the real part of the complex number
@@ -899,6 +899,8 @@ declare namespace math {
899
899
  threshold?: number
900
900
  ): MathArray
901
901
 
902
+ lusolve(A: LUDecomposition, b: Matrix | MathArray): Matrix
903
+
902
904
  /* Finds the roots of a polynomial of degree three or less. Coefficients are given constant first
903
905
  * followed by linear and higher powers in order; coefficients beyond the degree of the polynomial
904
906
  * need not be specified.
@@ -1147,7 +1149,11 @@ declare namespace math {
1147
1149
  * @param y Denominator
1148
1150
  * @returns Quotient, x ./ y
1149
1151
  */
1150
- dotDivide(x: MathType, y: MathType): MathType
1152
+ dotDivide<T extends MathCollection>(x: T, y: MathType): T
1153
+ dotDivide<T extends MathCollection>(x: MathType, y: T): T
1154
+ dotDivide(x: Unit, y: MathType): Unit
1155
+ dotDivide(x: MathType, y: Unit): Unit
1156
+ dotDivide(x: MathNumericType, y: MathNumericType): MathNumericType
1151
1157
 
1152
1158
  /**
1153
1159
  * Multiply two matrices element wise. The function accepts both
@@ -1156,7 +1162,11 @@ declare namespace math {
1156
1162
  * @param y Right hand value
1157
1163
  * @returns Multiplication of x and y
1158
1164
  */
1159
- dotMultiply(x: MathType, y: MathType): MathType
1165
+ dotMultiply<T extends MathCollection>(x: T, y: MathType): T
1166
+ dotMultiply<T extends MathCollection>(x: MathType, y: T): T
1167
+ dotMultiply(x: Unit, y: MathType): Unit
1168
+ dotMultiply(x: MathType, y: Unit): Unit
1169
+ dotMultiply(x: MathNumericType, y: MathNumericType): MathNumericType
1160
1170
 
1161
1171
  /**
1162
1172
  * Calculates the power of x to y element wise.
@@ -1164,7 +1174,7 @@ declare namespace math {
1164
1174
  * @param y The exponent
1165
1175
  * @returns The value of x to the power y
1166
1176
  */
1167
- dotPow(x: MathType, y: MathType): MathType
1177
+ dotPow<T extends MathType>(x: T, y: MathType): T
1168
1178
 
1169
1179
  /**
1170
1180
  * Calculate the exponent of a value. For matrices, the function is
@@ -1297,9 +1307,13 @@ declare namespace math {
1297
1307
  multiply<T extends Matrix>(x: T, y: MathType): Matrix
1298
1308
  multiply<T extends Matrix>(x: MathType, y: T): Matrix
1299
1309
 
1310
+ multiply<T extends MathNumericType[]>(x: T, y: T[]): T
1311
+ multiply<T extends MathNumericType[]>(x: T[], y: T): T
1312
+
1313
+ multiply<T extends MathArray>(x: T, y: T): T
1314
+
1300
1315
  multiply(x: Unit, y: Unit): Unit
1301
1316
  multiply(x: number, y: number): number
1302
- multiply(x: MathArray, y: MathArray): MathArray
1303
1317
  multiply(x: MathType, y: MathType): MathType
1304
1318
 
1305
1319
  /**
@@ -2068,6 +2082,19 @@ declare namespace math {
2068
2082
  defaultValue?: number | string
2069
2083
  ): T
2070
2084
 
2085
+ /**
2086
+ * Return a Rotation Matrix for a given angle in radians
2087
+ * @param {number | BigNumber | Complex | Unit} theta Rotation angle
2088
+ * @param {Array | Matrix} [v] Rotation axis
2089
+ * @param {string} [format] Result Matrix storage format. Default value: 'dense'.
2090
+ * @return {Matrix} Rotation Matrix
2091
+ */
2092
+ rotationMatrix<T extends MathCollection>(
2093
+ theta?: number | BigNumber | Complex | Unit,
2094
+ axis?: T,
2095
+ format?: 'sparse' | 'dense'
2096
+ ): T
2097
+
2071
2098
  /**
2072
2099
  * Return a row from a Matrix.
2073
2100
  * @param value An array or matrix
@@ -3767,12 +3794,12 @@ declare namespace math {
3767
3794
  size(): number[]
3768
3795
  map(
3769
3796
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3770
- callback: (a: any, b: number, c: Matrix) => any,
3797
+ callback: (a: any, b: number[], c: Matrix) => any,
3771
3798
  skipZeros?: boolean
3772
3799
  ): Matrix
3773
3800
  forEach(
3774
3801
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3775
- callback: (a: any, b: number, c: Matrix) => void,
3802
+ callback: (a: any, b: number[], c: Matrix) => void,
3776
3803
  skipZeros?: boolean
3777
3804
  ): void
3778
3805
  toArray(): MathArray
@@ -4500,6 +4527,11 @@ declare namespace math {
4500
4527
  threshold?: number
4501
4528
  ): MathJsChain<MathArray>
4502
4529
 
4530
+ lusolve(
4531
+ this: MathJsChain<LUDecomposition>,
4532
+ b: Matrix | MathArray
4533
+ ): MathJsChain<Matrix>
4534
+
4503
4535
  /**
4504
4536
  * Calculate the Matrix QR decomposition. Matrix A is decomposed in two
4505
4537
  * matrices (Q, R) where Q is an orthogonal matrix and R is an upper
@@ -4720,20 +4752,49 @@ declare namespace math {
4720
4752
  * and scalar values.
4721
4753
  * @param y Denominator
4722
4754
  */
4723
- dotDivide(this: MathJsChain<MathType>, y: MathType): MathJsChain<MathType>
4755
+ dotDivide<T extends MathCollection>(
4756
+ this: MathJsChain<T>,
4757
+ y: MathType
4758
+ ): MathJsChain<T>
4759
+ dotDivide<T extends MathCollection>(
4760
+ this: MathJsChain<MathType>,
4761
+ y: T
4762
+ ): MathJsChain<T>
4763
+ dotDivide(this: MathJsChain<Unit>, y: MathType): MathJsChain<Unit>
4764
+ dotDivide(this: MathJsChain<MathType>, y: Unit): MathJsChain<Unit>
4765
+ dotDivide(
4766
+ this: MathJsChain<MathNumericType>,
4767
+ y: MathNumericType
4768
+ ): MathJsChain<MathNumericType>
4724
4769
 
4725
4770
  /**
4726
4771
  * Multiply two matrices element wise. The function accepts both
4727
4772
  * matrices and scalar values.
4728
4773
  * @param y Right hand value
4729
4774
  */
4730
- dotMultiply(this: MathJsChain<MathType>, y: MathType): MathJsChain<MathType>
4775
+ dotMultiply<T extends MathCollection>(
4776
+ this: MathJsChain<T>,
4777
+ y: MathType
4778
+ ): MathJsChain<T>
4779
+ dotMultiply<T extends MathCollection>(
4780
+ this: MathJsChain<MathType>,
4781
+ y: T
4782
+ ): MathJsChain<T>
4783
+ dotMultiply(this: MathJsChain<Unit>, y: MathType): MathJsChain<Unit>
4784
+ dotMultiply(this: MathJsChain<MathType>, y: Unit): MathJsChain<Unit>
4785
+ dotMultiply(
4786
+ this: MathJsChain<MathNumericType>,
4787
+ y: MathNumericType
4788
+ ): MathJsChain<MathNumericType>
4731
4789
 
4732
4790
  /**
4733
4791
  * Calculates the power of x to y element wise.
4734
4792
  * @param y The exponent
4735
4793
  */
4736
- dotPow(this: MathJsChain<MathType>, y: MathType): MathJsChain<MathType>
4794
+ dotPow<T extends MathType>(
4795
+ this: MathJsChain<T>,
4796
+ y: MathType
4797
+ ): MathJsChain<T>
4737
4798
 
4738
4799
  /**
4739
4800
  * Calculate the exponent of a value. For matrices, the function is