mathjs 10.3.0 → 10.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. package/HISTORY.md +14 -0
  2. package/docs/reference/functions/cumsum.md +57 -0
  3. package/docs/reference/functions/format.md +1 -1
  4. package/docs/reference/functions/sum.md +2 -1
  5. package/docs/reference/functions.md +1 -0
  6. package/lib/browser/math.js +4 -4
  7. package/lib/browser/math.js.map +1 -1
  8. package/lib/cjs/entry/dependenciesAny/dependenciesCumSum.generated.js +26 -0
  9. package/lib/cjs/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +26 -0
  10. package/lib/cjs/entry/dependenciesAny.generated.js +16 -0
  11. package/lib/cjs/entry/dependenciesNumber/dependenciesCumSum.generated.js +26 -0
  12. package/lib/cjs/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +26 -0
  13. package/lib/cjs/entry/dependenciesNumber.generated.js +16 -0
  14. package/lib/cjs/entry/impureFunctionsAny.generated.js +6 -0
  15. package/lib/cjs/entry/impureFunctionsNumber.generated.js +6 -0
  16. package/lib/cjs/entry/pureFunctionsAny.generated.js +9 -3
  17. package/lib/cjs/entry/pureFunctionsNumber.generated.js +8 -2
  18. package/lib/cjs/expression/embeddedDocs/construction/fraction.js +3 -3
  19. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +3 -0
  20. package/lib/cjs/expression/embeddedDocs/function/statistics/cumsum.js +15 -0
  21. package/lib/cjs/expression/transform/cumsum.transform.js +57 -0
  22. package/lib/cjs/expression/transform/sum.transform.js +1 -1
  23. package/lib/cjs/factoriesAny.js +16 -0
  24. package/lib/cjs/factoriesNumber.js +17 -1
  25. package/lib/cjs/function/algebra/simplifyCore.js +2 -2
  26. package/lib/cjs/function/statistics/cumsum.js +151 -0
  27. package/lib/cjs/function/statistics/sum.js +1 -1
  28. package/lib/cjs/function/string/format.js +1 -1
  29. package/lib/cjs/header.js +2 -2
  30. package/lib/cjs/type/fraction/function/fraction.js +20 -8
  31. package/lib/cjs/utils/collection.js +3 -27
  32. package/lib/cjs/utils/switch.js +31 -0
  33. package/lib/cjs/version.js +1 -1
  34. package/lib/esm/entry/dependenciesAny/dependenciesCumSum.generated.js +14 -0
  35. package/lib/esm/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +14 -0
  36. package/lib/esm/entry/dependenciesAny.generated.js +2 -0
  37. package/lib/esm/entry/dependenciesNumber/dependenciesCumSum.generated.js +14 -0
  38. package/lib/esm/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +14 -0
  39. package/lib/esm/entry/dependenciesNumber.generated.js +2 -0
  40. package/lib/esm/entry/impureFunctionsAny.generated.js +8 -2
  41. package/lib/esm/entry/impureFunctionsNumber.generated.js +8 -2
  42. package/lib/esm/entry/pureFunctionsAny.generated.js +6 -1
  43. package/lib/esm/entry/pureFunctionsNumber.generated.js +6 -1
  44. package/lib/esm/expression/embeddedDocs/construction/fraction.js +3 -3
  45. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -0
  46. package/lib/esm/expression/embeddedDocs/function/statistics/cumsum.js +8 -0
  47. package/lib/esm/expression/transform/cumsum.transform.js +48 -0
  48. package/lib/esm/expression/transform/sum.transform.js +1 -1
  49. package/lib/esm/factoriesAny.js +2 -0
  50. package/lib/esm/factoriesNumber.js +2 -0
  51. package/lib/esm/function/algebra/simplifyCore.js +2 -2
  52. package/lib/esm/function/statistics/cumsum.js +139 -0
  53. package/lib/esm/function/statistics/sum.js +1 -1
  54. package/lib/esm/function/string/format.js +1 -1
  55. package/lib/esm/type/fraction/function/fraction.js +20 -8
  56. package/lib/esm/utils/collection.js +1 -26
  57. package/lib/esm/utils/switch.js +24 -0
  58. package/lib/esm/version.js +1 -1
  59. package/package.json +2 -2
  60. package/types/index.d.ts +107 -7
package/HISTORY.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # History
2
2
 
3
+ # 2022-03-07, version 10.4.0
4
+
5
+ - Fix #2461: make sure `simplifyCore` recurses over all binary nodes (#2462).
6
+ Thanks @gwhitney.
7
+ - Fix #2429: fix the TypeScript definitions of functions `std` and `variance`
8
+ (#2455). Thanks @NattapongSiri.
9
+ - Fix #1633: implement a `cumsum` function generating cumulative sums of a list
10
+ of values or a matrix. (#1870). Thanks @hjonasson.
11
+ - Upgrade to the latest version of `Fraction.js`, having more strict input,
12
+ only accepting an integer numerator and denominator. See #2427.
13
+ - Fix typo in documentation example for `format`. (#2468) Thanks @abranhe.
14
+ - Write unit tests for all jsdoc examples. See #2452. Thanks @gwhitney.
15
+
16
+
3
17
  # 2021-03-02, version 10.3.0
4
18
 
5
19
  - Fix #1260: implement function `symbolicEqual` (#2424). Thanks @gwhitney.
@@ -0,0 +1,57 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function cumsum
4
+
5
+ Compute the cumulative sum of a matrix or a list with values.
6
+ In case of a (multi dimensional) array or matrix, the cumulative sums
7
+ along a specified dimension (defaulting to the first) will be calculated.
8
+
9
+
10
+ ## Syntax
11
+
12
+ ```js
13
+ math.cumsum(a, b, c, ...)
14
+ math.cumsum(A)
15
+ ```
16
+
17
+ ### Parameters
18
+
19
+ Parameter | Type | Description
20
+ --------- | ---- | -----------
21
+ `args` | ... * | A single matrix or or multiple scalar values
22
+
23
+ ### Returns
24
+
25
+ Type | Description
26
+ ---- | -----------
27
+ * | The cumulative sum of all values
28
+
29
+
30
+ ### Throws
31
+
32
+ Type | Description
33
+ ---- | -----------
34
+
35
+
36
+ ## Examples
37
+
38
+ ```js
39
+ math.cumsum(2, 1, 4, 3) // returns [2, 3, 7, 10]
40
+ math.cumsum([2, 1, 4, 3]) // returns [2, 3, 7, 10]
41
+ math.cumsum([[1, 2], [3, 4]]) // returns [[1, 2], [4, 6]]
42
+ math.cumsum([[1, 2], [3, 4]], 0) // returns [[1, 2], [4, 6]]
43
+ math.cumsum([[1, 2], [3, 4]], 1) // returns [[1, 3], [3, 7]]
44
+ math.cumsum([[2, 5], [4, 3], [1, 7]]) // returns [[2, 5], [6, 8], [7, 15]]
45
+ ```
46
+
47
+
48
+ ## See also
49
+
50
+ [mean](mean.md),
51
+ [median](median.md),
52
+ [min](min.md),
53
+ [max](max.md),
54
+ [prod](prod.md),
55
+ [std](std.md),
56
+ [variance](variance.md),
57
+ [sum](sum.md)
@@ -115,7 +115,7 @@ function formatCurrency(value) {
115
115
  // you could also use math.format inside the callback:
116
116
  // return '$' + math.format(value, {notation: 'fixed', precision: 2})
117
117
  }
118
- math.format([2.1, 3, 0.016], formatCurrency} // returns '[$2.10, $3.00, $0.02]'
118
+ math.format([2.1, 3, 0.016], formatCurrency) // returns '[$2.10, $3.00, $0.02]'
119
119
  ```
120
120
 
121
121
 
@@ -50,4 +50,5 @@ math.sum([[2, 5], [4, 3], [1, 7]]) // returns 22
50
50
  [max](max.md),
51
51
  [prod](prod.md),
52
52
  [std](std.md),
53
- [variance](variance.md)
53
+ [variance](variance.md),
54
+ [cumsum](cumsum.md)
@@ -215,6 +215,7 @@ Function | Description
215
215
 
216
216
  Function | Description
217
217
  ---- | -----------
218
+ [math.cumsum(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/cumsum.md) | Compute the cumulative sum of a matrix or a list with values.
218
219
  [math.mad(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mad.md) | Compute the median absolute deviation of a matrix or a list with values.
219
220
  [math.max(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/max.md) | Compute the maximum value of a matrix or a list with values.
220
221
  [math.mean(a,&nbsp;b,&nbsp;c,&nbsp;...)](functions/mean.md) | Compute the mean value of matrix or a list with values.