mathjs 7.2.0 → 7.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. package/HISTORY.md +34 -0
  2. package/dist/math.js +3421 -2476
  3. package/dist/math.min.js +5 -5
  4. package/dist/math.min.map +1 -1
  5. package/docs/expressions/syntax.md +30 -4
  6. package/docs/reference/functions/bin.md +38 -0
  7. package/docs/reference/functions/ceil.md +10 -1
  8. package/docs/reference/functions/fix.md +10 -2
  9. package/docs/reference/functions/floor.md +12 -3
  10. package/docs/reference/functions/hex.md +38 -0
  11. package/docs/reference/functions/lsolve.md +2 -1
  12. package/docs/reference/functions/lsolveAll.md +45 -0
  13. package/docs/reference/functions/oct.md +38 -0
  14. package/docs/reference/functions/rotationMatrix.md +51 -0
  15. package/docs/reference/functions/round.md +6 -2
  16. package/docs/reference/functions/usolve.md +2 -1
  17. package/docs/reference/functions/usolveAll.md +45 -0
  18. package/docs/reference/functions.md +8 -2
  19. package/es/entry/dependenciesAny/dependenciesBin.generated.js +10 -0
  20. package/es/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
  21. package/es/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
  22. package/es/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
  23. package/es/entry/dependenciesAny/dependenciesHex.generated.js +10 -0
  24. package/es/entry/dependenciesAny/dependenciesLsolveAll.generated.js +22 -0
  25. package/es/entry/dependenciesAny/dependenciesOct.generated.js +10 -0
  26. package/es/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +30 -0
  27. package/es/entry/dependenciesAny/dependenciesUsolveAll.generated.js +22 -0
  28. package/es/entry/dependenciesAny.generated.js +6 -0
  29. package/es/entry/impureFunctionsAny.generated.js +63 -57
  30. package/es/entry/pureFunctionsAny.generated.js +323 -277
  31. package/es/expression/embeddedDocs/embeddedDocs.js +12 -0
  32. package/es/expression/embeddedDocs/function/algebra/lsolve.js +2 -2
  33. package/es/expression/embeddedDocs/function/algebra/lsolveAll.js +8 -0
  34. package/es/expression/embeddedDocs/function/algebra/usolve.js +2 -2
  35. package/es/expression/embeddedDocs/function/algebra/usolveAll.js +8 -0
  36. package/es/expression/embeddedDocs/function/matrix/rotationMatrix.js +8 -0
  37. package/es/expression/embeddedDocs/function/utils/bin.js +8 -0
  38. package/es/expression/embeddedDocs/function/utils/hex.js +8 -0
  39. package/es/expression/embeddedDocs/function/utils/oct.js +8 -0
  40. package/es/expression/parse.js +28 -1
  41. package/es/factoriesAny.js +6 -0
  42. package/es/function/algebra/solver/lsolve.js +42 -69
  43. package/es/function/algebra/solver/lsolveAll.js +213 -0
  44. package/es/function/algebra/solver/lusolve.js +12 -27
  45. package/es/function/algebra/solver/usolve.js +41 -64
  46. package/es/function/algebra/solver/usolveAll.js +213 -0
  47. package/es/function/algebra/solver/utils/solveValidation.js +66 -107
  48. package/es/function/arithmetic/ceil.js +88 -4
  49. package/es/function/arithmetic/fix.js +43 -6
  50. package/es/function/arithmetic/floor.js +90 -6
  51. package/es/function/arithmetic/mod.js +10 -1
  52. package/es/function/arithmetic/round.js +6 -2
  53. package/es/function/matrix/rotationMatrix.js +175 -0
  54. package/es/function/matrix/sqrtm.js +4 -0
  55. package/es/function/probability/pickRandom.js +2 -6
  56. package/es/function/statistics/variance.js +4 -4
  57. package/es/function/string/baseUtils.js +36 -0
  58. package/es/function/string/bin.js +23 -0
  59. package/es/function/string/hex.js +23 -0
  60. package/es/function/string/oct.js +23 -0
  61. package/es/type/bignumber/BigNumber.js +4 -1
  62. package/es/type/number.js +10 -0
  63. package/es/utils/object.js +3 -1
  64. package/es/version.js +1 -1
  65. package/examples/advanced/web_server/math_worker.js +1 -1
  66. package/lib/entry/dependenciesAny/dependenciesBin.generated.js +20 -0
  67. package/lib/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
  68. package/lib/entry/dependenciesAny/dependenciesFix.generated.js +3 -0
  69. package/lib/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
  70. package/lib/entry/dependenciesAny/dependenciesHex.generated.js +20 -0
  71. package/lib/entry/dependenciesAny/dependenciesLsolveAll.generated.js +38 -0
  72. package/lib/entry/dependenciesAny/dependenciesOct.generated.js +20 -0
  73. package/lib/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +50 -0
  74. package/lib/entry/dependenciesAny/dependenciesUsolveAll.generated.js +38 -0
  75. package/lib/entry/dependenciesAny.generated.js +48 -0
  76. package/lib/entry/impureFunctionsAny.generated.js +65 -59
  77. package/lib/entry/pureFunctionsAny.generated.js +373 -321
  78. package/lib/expression/embeddedDocs/embeddedDocs.js +18 -0
  79. package/lib/expression/embeddedDocs/function/algebra/lsolve.js +2 -2
  80. package/lib/expression/embeddedDocs/function/algebra/lsolveAll.js +15 -0
  81. package/lib/expression/embeddedDocs/function/algebra/usolve.js +2 -2
  82. package/lib/expression/embeddedDocs/function/algebra/usolveAll.js +15 -0
  83. package/lib/expression/embeddedDocs/function/matrix/rotationMatrix.js +15 -0
  84. package/lib/expression/embeddedDocs/function/utils/bin.js +15 -0
  85. package/lib/expression/embeddedDocs/function/utils/hex.js +15 -0
  86. package/lib/expression/embeddedDocs/function/utils/oct.js +15 -0
  87. package/lib/expression/parse.js +28 -1
  88. package/lib/factoriesAny.js +48 -0
  89. package/lib/function/algebra/solver/lsolve.js +42 -69
  90. package/lib/function/algebra/solver/lsolveAll.js +223 -0
  91. package/lib/function/algebra/solver/lusolve.js +12 -27
  92. package/lib/function/algebra/solver/usolve.js +41 -64
  93. package/lib/function/algebra/solver/usolveAll.js +223 -0
  94. package/lib/function/algebra/solver/utils/solveValidation.js +65 -106
  95. package/lib/function/arithmetic/ceil.js +91 -4
  96. package/lib/function/arithmetic/fix.js +44 -6
  97. package/lib/function/arithmetic/floor.js +93 -6
  98. package/lib/function/arithmetic/mod.js +10 -1
  99. package/lib/function/arithmetic/round.js +6 -2
  100. package/lib/function/matrix/rotationMatrix.js +185 -0
  101. package/lib/function/matrix/sqrtm.js +4 -0
  102. package/lib/function/probability/pickRandom.js +3 -7
  103. package/lib/function/statistics/variance.js +4 -4
  104. package/lib/function/string/baseUtils.js +45 -0
  105. package/lib/function/string/bin.js +31 -0
  106. package/lib/function/string/hex.js +31 -0
  107. package/lib/function/string/oct.js +31 -0
  108. package/lib/header.js +2 -2
  109. package/lib/type/bignumber/BigNumber.js +3 -1
  110. package/lib/type/number.js +10 -0
  111. package/lib/utils/object.js +3 -1
  112. package/lib/version.js +1 -1
  113. package/package.json +12 -12
  114. package/src/entry/dependenciesAny/dependenciesBin.generated.js +11 -0
  115. package/src/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
  116. package/src/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
  117. package/src/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
  118. package/src/entry/dependenciesAny/dependenciesHex.generated.js +11 -0
  119. package/src/entry/dependenciesAny/dependenciesLsolveAll.generated.js +23 -0
  120. package/src/entry/dependenciesAny/dependenciesOct.generated.js +11 -0
  121. package/src/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +31 -0
  122. package/src/entry/dependenciesAny/dependenciesUsolveAll.generated.js +23 -0
  123. package/src/entry/dependenciesAny.generated.js +6 -0
  124. package/src/entry/impureFunctionsAny.generated.js +104 -92
  125. package/src/entry/pureFunctionsAny.generated.js +94 -82
  126. package/src/expression/embeddedDocs/embeddedDocs.js +12 -0
  127. package/src/expression/embeddedDocs/function/algebra/lsolve.js +2 -2
  128. package/src/expression/embeddedDocs/function/algebra/lsolveAll.js +17 -0
  129. package/src/expression/embeddedDocs/function/algebra/usolve.js +2 -2
  130. package/src/expression/embeddedDocs/function/algebra/usolveAll.js +15 -0
  131. package/src/expression/embeddedDocs/function/matrix/rotationMatrix.js +19 -0
  132. package/src/expression/embeddedDocs/function/utils/bin.js +12 -0
  133. package/src/expression/embeddedDocs/function/utils/hex.js +12 -0
  134. package/src/expression/embeddedDocs/function/utils/oct.js +12 -0
  135. package/src/expression/parse.js +25 -0
  136. package/src/factoriesAny.js +6 -0
  137. package/src/function/algebra/solver/lsolve.js +52 -58
  138. package/src/function/algebra/solver/lsolveAll.js +197 -0
  139. package/src/function/algebra/solver/lusolve.js +9 -19
  140. package/src/function/algebra/solver/usolve.js +52 -55
  141. package/src/function/algebra/solver/usolveAll.js +199 -0
  142. package/src/function/algebra/solver/utils/solveValidation.js +78 -86
  143. package/src/function/arithmetic/ceil.js +63 -3
  144. package/src/function/arithmetic/fix.js +45 -6
  145. package/src/function/arithmetic/floor.js +65 -5
  146. package/src/function/arithmetic/mod.js +8 -1
  147. package/src/function/arithmetic/round.js +6 -2
  148. package/src/function/matrix/rotationMatrix.js +185 -0
  149. package/src/function/matrix/sqrtm.js +4 -0
  150. package/src/function/probability/pickRandom.js +2 -6
  151. package/src/function/statistics/variance.js +4 -4
  152. package/src/function/string/baseUtils.js +29 -0
  153. package/src/function/string/bin.js +23 -0
  154. package/src/function/string/hex.js +23 -0
  155. package/src/function/string/oct.js +24 -0
  156. package/src/type/bignumber/BigNumber.js +2 -1
  157. package/src/type/number.js +9 -1
  158. package/src/utils/object.js +3 -1
  159. package/src/version.js +1 -1
@@ -283,6 +283,32 @@ const ans = math.evaluate('0.1 + 0.2') // 0.30000000000000004
283
283
  math.format(ans, {precision: 14}) // "0.3"
284
284
  ```
285
285
 
286
+ Numbers can be expressed as binary, octal, and hexadecimal literals:
287
+
288
+ ```js
289
+ math.evaluate('0b11') // 3
290
+ math.evaluate('0o77') // 63
291
+ math.evaluate('0xff') // 255
292
+ ```
293
+
294
+ Non-decimal literals are parsed as 32 bit signed integers:
295
+
296
+ ```js
297
+ math.evaluate('0xffffffff') // -1
298
+ math.evaluate('0xfffffffff') // SyntaxError: String "0xfffffffff" is out of range
299
+ ```
300
+
301
+ Numbers can be formatted as binary, octal, and hex strings using the functions
302
+ `bin`, `oct`, and `hex`:
303
+
304
+ ```js
305
+ math.evaluate('bin(3)') // '0b11'
306
+ math.evaluate('oct(63)') // '0o77'
307
+ math.evaluate('hex(255)') // '0xff'
308
+ math.evaluate('hex(-1)') // '0xffffffff'
309
+ math.evaluate('hex(2.3)') // Error: Value must be an integer
310
+ math.evaluate('hex(2^35)') // Error: Value must be in range [-2^31, 2^31-1]
311
+ ```
286
312
 
287
313
  ### BigNumbers
288
314
 
@@ -397,7 +423,7 @@ using function `string`.
397
423
 
398
424
  When setting the value of a character in a string, the character that has been
399
425
  set is returned. Likewise, when a range of characters is set, that range of
400
- characters is returned.
426
+ characters is returned.
401
427
 
402
428
 
403
429
  ```js
@@ -499,7 +525,7 @@ parser.evaluate('c[end - 1 : -1 : 2]') // Matrix, [8, 7, 6]
499
525
  ## Objects
500
526
 
501
527
  Objects in math.js work the same as in languages like JavaScript and Python.
502
- An object is enclosed by square brackets `{`, `}`, and contains a set of
528
+ An object is enclosed by square brackets `{`, `}`, and contains a set of
503
529
  comma separated key/value pairs. Keys and values are separated by a colon `:`.
504
530
  Keys can be a symbol like `prop` or a string like `"prop"`.
505
531
 
@@ -514,7 +540,7 @@ Objects can contain objects:
514
540
  math.evaluate('{a: 2, b: {c: 3, d: 4}}') // {a: 2, b: {c: 3, d: 4}}
515
541
  ```
516
542
 
517
- Object properties can be retrieved or replaced using dot notation or bracket
543
+ Object properties can be retrieved or replaced using dot notation or bracket
518
544
  notation. Unlike JavaScript, when setting a property value, the whole object
519
545
  is returned, not the property value
520
546
 
@@ -590,7 +616,7 @@ The behavior of implicit multiplication can be summarized by these operator prec
590
616
 
591
617
  Implicit multiplication is tricky as there can appear to be ambiguity in how an expression will be evaluated. Experience has shown that the above rules most closely match user intent when entering expressions that could be interpreted different ways. It's also possible that these rules could be tweaked in future major releases. Use implicit multiplication carefully. If you don't like the uncertainty introduced by implicit multiplication, use explicit `*` operators and parentheses to ensure your expression is evaluated the way you intend.
592
618
 
593
- Here are some more examples using implicit multiplication:
619
+ Here are some more examples using implicit multiplication:
594
620
 
595
621
  Expression | Evaluated as | Result
596
622
  --------------- | ------------------- | ------------------
@@ -0,0 +1,38 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function bin
4
+
5
+ Format a number as binary.
6
+
7
+
8
+ ## Syntax
9
+
10
+ ```js
11
+ math.bin(value)
12
+ ```
13
+
14
+ ### Parameters
15
+
16
+ Parameter | Type | Description
17
+ --------- | ---- | -----------
18
+ `value` | number | Value to be stringified
19
+
20
+ ### Returns
21
+
22
+ Type | Description
23
+ ---- | -----------
24
+ string | The formatted value
25
+
26
+
27
+ ## Examples
28
+
29
+ ```js
30
+ //the following outputs "0b10"
31
+ math.bin(2)
32
+ ```
33
+
34
+
35
+ ## See also
36
+
37
+ [oct](oct.md),
38
+ [hex](hex.md)
@@ -11,6 +11,7 @@ For matrices, the function is evaluated element wise.
11
11
 
12
12
  ```js
13
13
  math.ceil(x)
14
+ math.ceil(x, n)
14
15
  ```
15
16
 
16
17
  ### Parameters
@@ -18,6 +19,7 @@ math.ceil(x)
18
19
  Parameter | Type | Description
19
20
  --------- | ---- | -----------
20
21
  `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Number to be rounded
22
+ `n` | number &#124; BigNumber &#124; Array | Number of decimals Default value: 0.
21
23
 
22
24
  ### Returns
23
25
 
@@ -34,10 +36,17 @@ math.ceil(3.8) // returns number 4
34
36
  math.ceil(-4.2) // returns number -4
35
37
  math.ceil(-4.7) // returns number -4
36
38
 
37
- const c = math.complex(3.2, -2.7)
39
+ math.ceil(3.212, 2) // returns number 3.22
40
+ math.ceil(3.288, 2) // returns number 3.29
41
+ math.ceil(-4.212, 2) // returns number -4.21
42
+ math.ceil(-4.782, 2) // returns number -4.78
43
+
44
+ const c = math.complex(3.24, -2.71)
38
45
  math.ceil(c) // returns Complex 4 - 2i
46
+ math.ceil(c, 1) // returns Complex 3.3 - 2.7i
39
47
 
40
48
  math.ceil([3.2, 3.8, -4.7]) // returns Array [4, 4, -4]
49
+ math.ceil([3.21, 3.82, -4.71], 1) // returns Array [3.3, 3.9, -4.7]
41
50
  ```
42
51
 
43
52
 
@@ -17,6 +17,7 @@ math.fix(x)
17
17
  Parameter | Type | Description
18
18
  --------- | ---- | -----------
19
19
  `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Number to be rounded
20
+ `n` | number &#124; BigNumber &#124; Array | Number of decimals Default value: 0.
20
21
 
21
22
  ### Returns
22
23
 
@@ -33,10 +34,17 @@ math.fix(3.8) // returns number 3
33
34
  math.fix(-4.2) // returns number -4
34
35
  math.fix(-4.7) // returns number -4
35
36
 
36
- const c = math.complex(3.2, -2.7)
37
+ math.fix(3.12, 1) // returns number 3.1
38
+ math.fix(3.18, 1) // returns number 3.1
39
+ math.fix(-4.12, 1) // returns number -4.1
40
+ math.fix(-4.17, 1) // returns number -4.1
41
+
42
+ const c = math.complex(3.22, -2.78)
37
43
  math.fix(c) // returns Complex 3 - 2i
44
+ math.fix(c, 1) // returns Complex 3.2 - 2.7i
38
45
 
39
- math.fix([3.2, 3.8, -4.7]) // returns Array [3, 3, -4]
46
+ math.fix([3.2, 3.8, -4.7]) // returns Array [3, 3, -4]
47
+ math.fix([3.2, 3.8, -4.7], 1) // returns Array [3.2, 3.8, -4.7]
40
48
  ```
41
49
 
42
50
 
@@ -10,6 +10,7 @@ For matrices, the function is evaluated element wise.
10
10
 
11
11
  ```js
12
12
  math.floor(x)
13
+ math.floor(x, n)
13
14
  ```
14
15
 
15
16
  ### Parameters
@@ -17,6 +18,7 @@ math.floor(x)
17
18
  Parameter | Type | Description
18
19
  --------- | ---- | -----------
19
20
  `x` | number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matrix | Number to be rounded
21
+ `n` | number &#124; BigNumber &#124; Array | Number of decimals Default value: 0.
20
22
 
21
23
  ### Returns
22
24
 
@@ -33,10 +35,17 @@ math.floor(3.8) // returns number 3
33
35
  math.floor(-4.2) // returns number -5
34
36
  math.floor(-4.7) // returns number -5
35
37
 
36
- const c = math.complex(3.2, -2.7)
37
- math.floor(c) // returns Complex 3 - 3i
38
+ math.floor(3.212, 2) // returns number 3.21
39
+ math.floor(3.288, 2) // returns number 3.28
40
+ math.floor(-4.212, 2) // returns number -4.22
41
+ math.floor(-4.782, 2) // returns number -4.79
38
42
 
39
- math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
43
+ const c = math.complex(3.24, -2.71)
44
+ math.floor(c) // returns Complex 3 - 3i
45
+ math.floor(c, 1) // returns Complex 3.2 - 2.8i
46
+
47
+ math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
48
+ math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
40
49
  ```
41
50
 
42
51
 
@@ -0,0 +1,38 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function hex
4
+
5
+ Format a number as hexadecimal.
6
+
7
+
8
+ ## Syntax
9
+
10
+ ```js
11
+ math.hex(value)
12
+ ```
13
+
14
+ ### Parameters
15
+
16
+ Parameter | Type | Description
17
+ --------- | ---- | -----------
18
+ `value` | number | Value to be stringified
19
+
20
+ ### Returns
21
+
22
+ Type | Description
23
+ ---- | -----------
24
+ string | The formatted value
25
+
26
+
27
+ ## Examples
28
+
29
+ ```js
30
+ //the following outputs "0xF0"
31
+ math.hex(240)
32
+ ```
33
+
34
+
35
+ ## See also
36
+
37
+ [oct](oct.md),
38
+ [bin](bin.md)
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Function lsolve
4
4
 
5
- Solves the linear equation system by forwards substitution. Matrix must be a lower triangular matrix.
5
+ Finds one solution of a linear equation system by forwards substitution. Matrix must be a lower triangular matrix. Throws an error if there's no solution.
6
6
 
7
7
  `L * x = b`
8
8
 
@@ -38,6 +38,7 @@ const x = lsolve(a, b) // [[-5.5], [20]]
38
38
 
39
39
  ## See also
40
40
 
41
+ [lsolveAll](lsolveAll.md),
41
42
  [lup](lup.md),
42
43
  [slu](slu.md),
43
44
  [usolve](usolve.md),
@@ -0,0 +1,45 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function lsolveAll
4
+
5
+ Finds all solutions of a linear equation system by forwards substitution. Matrix must be a lower triangular matrix.
6
+
7
+ `L * x = b`
8
+
9
+
10
+ ## Syntax
11
+
12
+ ```js
13
+ math.lsolve(L, b)
14
+ ```
15
+
16
+ ### Parameters
17
+
18
+ Parameter | Type | Description
19
+ --------- | ---- | -----------
20
+ `L` | Matrix, Array | A N x N matrix or array (L)
21
+ `b` | Matrix, Array | A column vector with the b values
22
+
23
+ ### Returns
24
+
25
+ Type | Description
26
+ ---- | -----------
27
+ DenseMatrix[] &#124; Array[] | An array of affine-independent column vectors (x) that solve the linear system
28
+
29
+
30
+ ## Examples
31
+
32
+ ```js
33
+ const a = [[-2, 3], [2, 1]]
34
+ const b = [11, 9]
35
+ const x = lsolve(a, b) // [ [[-5.5], [20]] ]
36
+ ```
37
+
38
+
39
+ ## See also
40
+
41
+ [lsolve](lsolve.md),
42
+ [lup](lup.md),
43
+ [slu](slu.md),
44
+ [usolve](usolve.md),
45
+ [lusolve](lusolve.md)
@@ -0,0 +1,38 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function oct
4
+
5
+ Format a number as octal.
6
+
7
+
8
+ ## Syntax
9
+
10
+ ```js
11
+ math.oct(value)
12
+ ```
13
+
14
+ ### Parameters
15
+
16
+ Parameter | Type | Description
17
+ --------- | ---- | -----------
18
+ `value` | number | Value to be stringified
19
+
20
+ ### Returns
21
+
22
+ Type | Description
23
+ ---- | -----------
24
+ string | The formatted value
25
+
26
+
27
+ ## Examples
28
+
29
+ ```js
30
+ //the following outputs "0o70"
31
+ math.oct(56)
32
+ ```
33
+
34
+
35
+ ## See also
36
+
37
+ [bin](bin.md),
38
+ [hex](hex.md)
@@ -0,0 +1,51 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function rotationMatrix
4
+
5
+ Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
6
+ Create a 2-dimensional counter-clockwise rotation matrix (3x3) by a given angle (expressed in radians) around a given axis (1x3).
7
+
8
+
9
+ ## Syntax
10
+
11
+ ```js
12
+ math.rotationMatrix(theta)
13
+ math.rotationMatrix(theta, format)
14
+ math.rotationMatrix(theta, [v])
15
+ math.rotationMatrix(theta, [v], format)
16
+ ```
17
+
18
+ ### Parameters
19
+
20
+ Parameter | Type | Description
21
+ --------- | ---- | -----------
22
+ `theta` | number &#124; BigNumber &#124; Complex &#124; Unit | Rotation angle
23
+ `v` | Array &#124; Matrix | Rotation axis
24
+ `format` | string | Result Matrix storage format
25
+
26
+ ### Returns
27
+
28
+ Type | Description
29
+ ---- | -----------
30
+ Array &#124; Matrix | Rotation matrix
31
+
32
+
33
+ ## Examples
34
+
35
+ ```js
36
+ math.rotationMatrix(math.pi / 2) // returns [[0, -1], [1, 0]]
37
+ math.rotationMatrix(math.bignumber(45)) // returns [[ bignumber(1 / sqrt(2)), - bignumber(1 / sqrt(2))], [ bignumber(1 / sqrt(2)), bignumber(1 / sqrt(2))]]
38
+ math.rotationMatrix(math.complex(1 + i)) // returns [[cos(1 + i), -sin(1 + i)], [sin(1 + i), cos(1 + i)]]
39
+ math.rotationMatrix(math.unit('1rad')) // returns [[cos(1), -sin(1)], [sin(1), cos(1)]]
40
+
41
+ math.rotationMatrix(math.pi / 2, [0, 1, 0]) // returns [[0, 0, 1], [0, 1, 0], [-1, 0, 0]]
42
+ math.rotationMatrix(math.pi / 2, matrix([0, 1, 0])) // returns matrix([[0, 0, 1], [0, 1, 0], [-1, 0, 0]])
43
+
44
+ ```
45
+
46
+
47
+ ## See also
48
+
49
+ [matrix](matrix.md),
50
+ [cos](cos.md),
51
+ [sin](sin.md)
@@ -30,10 +30,14 @@ number &#124; BigNumber &#124; Fraction &#124; Complex &#124; Array &#124; Matri
30
30
  ## Examples
31
31
 
32
32
  ```js
33
- math.round(3.2) // returns number 3
34
- math.round(3.8) // returns number 4
33
+ math.round(3.22) // returns number 3
34
+ math.round(3.82) // returns number 4
35
35
  math.round(-4.2) // returns number -4
36
36
  math.round(-4.7) // returns number -5
37
+ math.round(3.22, 1) // returns number 3.2
38
+ math.round(3.88, 1) // returns number 3.8
39
+ math.round(-4.21, 1) // returns number -4.2
40
+ math.round(-4.71, 1) // returns number -4.7
37
41
  math.round(math.pi, 3) // returns number 3.142
38
42
  math.round(123.45678, 2) // returns number 123.46
39
43
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Function usolve
4
4
 
5
- Solves the linear equation system by backward substitution. Matrix must be an upper triangular matrix.
5
+ Finds one solution of a linear equation system by backward substitution. Matrix must be an upper triangular matrix. Throws an error if there's no solution.
6
6
 
7
7
  `U * x = b`
8
8
 
@@ -38,6 +38,7 @@ const x = usolve(a, b) // [[8], [9]]
38
38
 
39
39
  ## See also
40
40
 
41
+ [usolveAll](usolveAll.md),
41
42
  [lup](lup.md),
42
43
  [slu](slu.md),
43
44
  [usolve](usolve.md),
@@ -0,0 +1,45 @@
1
+ <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
2
+
3
+ # Function usolveAll
4
+
5
+ Finds all solutions of a linear equation system by backward substitution. Matrix must be an upper triangular matrix.
6
+
7
+ `U * x = b`
8
+
9
+
10
+ ## Syntax
11
+
12
+ ```js
13
+ math.usolve(U, b)
14
+ ```
15
+
16
+ ### Parameters
17
+
18
+ Parameter | Type | Description
19
+ --------- | ---- | -----------
20
+ `U` | Matrix, Array | A N x N matrix or array (U)
21
+ `b` | Matrix, Array | A column vector with the b values
22
+
23
+ ### Returns
24
+
25
+ Type | Description
26
+ ---- | -----------
27
+ DenseMatrix[] &#124; Array[] | An array of affine-independent column vectors (x) that solve the linear system
28
+
29
+
30
+ ## Examples
31
+
32
+ ```js
33
+ const a = [[-2, 3], [2, 1]]
34
+ const b = [11, 9]
35
+ const x = usolve(a, b) // [ [[8], [9]] ]
36
+ ```
37
+
38
+
39
+ ## See also
40
+
41
+ [usolve](usolve.md),
42
+ [lup](lup.md),
43
+ [slu](slu.md),
44
+ [usolve](usolve.md),
45
+ [lusolve](lusolve.md)
@@ -41,14 +41,16 @@ Function | Description
41
41
  Function | Description
42
42
  ---- | -----------
43
43
  [derivative(expr,&nbsp;variable)](functions/derivative.md) | Takes the derivative of an expression expressed in parser Nodes.
44
- [math.lsolve(L,&nbsp;b)](functions/lsolve.md) | Solves the linear equation system by forwards substitution.
44
+ [math.lsolve(L,&nbsp;b)](functions/lsolve.md) | Finds one solution of a linear equation system by forwards substitution.
45
+ [math.lsolve(L,&nbsp;b)](functions/lsolveAll.md) | Finds all solutions of a linear equation system by forwards substitution.
45
46
  [math.lup(A)](functions/lup.md) | Calculate the Matrix LU decomposition with partial pivoting.
46
47
  [math.lusolve(A,&nbsp;b)](functions/lusolve.md) | Solves the linear system `A * x = b` where `A` is an [n x n] matrix and `b` is a [n] column vector.
47
48
  [math.qr(A)](functions/qr.md) | Calculate the Matrix QR decomposition.
48
49
  [rationalize(expr)](functions/rationalize.md) | Transform a rationalizable expression in a rational fraction.
49
50
  [simplify(expr)](functions/simplify.md) | Simplify an expression tree.
50
51
  [math.slu(A,&nbsp;order,&nbsp;threshold)](functions/slu.md) | Calculate the Sparse Matrix LU decomposition with full pivoting.
51
- [math.usolve(U,&nbsp;b)](functions/usolve.md) | Solves the linear equation system by backward substitution.
52
+ [math.usolve(U,&nbsp;b)](functions/usolve.md) | Finds one solution of a linear equation system by backward substitution.
53
+ [math.usolve(U,&nbsp;b)](functions/usolveAll.md) | Finds all solutions of a linear equation system by backward substitution.
52
54
 
53
55
  ## Arithmetic functions
54
56
 
@@ -163,6 +165,7 @@ Function | Description
163
165
  [math.range(start,&nbsp;end&nbsp;[,&nbsp;step])](functions/range.md) | Create an array from a range.
164
166
  [math.reshape(x,&nbsp;sizes)](functions/reshape.md) | Reshape a multi dimensional array to fit the specified dimensions.
165
167
  [math.resize(x,&nbsp;size&nbsp;[,&nbsp;defaultValue])](functions/resize.md) | Resize a matrix.
168
+ [math.rotationMatrix(theta)](functions/rotationMatrix.md) | Create a 2-dimensional counter-clockwise rotation matrix (2x2) for a given angle (expressed in radians).
166
169
  [math.row(value,&nbsp;index)](functions/row.md) | Return a row from a Matrix.
167
170
  [math.size(x)](functions/size.md) | Calculate the size of a matrix or scalar.
168
171
  [math.sort(x)](functions/sort.md) | Sort the items in a matrix.
@@ -245,7 +248,10 @@ Function | Description
245
248
 
246
249
  Function | Description
247
250
  ---- | -----------
251
+ [math.bin(value)](functions/bin.md) | Format a number as binary.
248
252
  [math.format(value&nbsp;[,&nbsp;precision])](functions/format.md) | Format a value of any type into a string.
253
+ [math.hex(value)](functions/hex.md) | Format a number as hexadecimal.
254
+ [math.oct(value)](functions/oct.md) | Format a number as octal.
249
255
  [math.print(template, values [, precision])](functions/print.md) | Interpolate values into a string template.
250
256
 
251
257
  ## Trigonometry functions
@@ -0,0 +1,10 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED
3
+ * DON'T MAKE CHANGES HERE
4
+ */
5
+ import { typedDependencies } from './dependenciesTyped.generated';
6
+ import { createBin } from '../../factoriesAny.js';
7
+ export var binDependencies = {
8
+ typedDependencies: typedDependencies,
9
+ createBin: createBin
10
+ };
@@ -2,10 +2,14 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { equalScalarDependencies } from './dependenciesEqualScalar.generated';
6
+ import { matrixDependencies } from './dependenciesMatrix.generated';
5
7
  import { roundDependencies } from './dependenciesRound.generated';
6
8
  import { typedDependencies } from './dependenciesTyped.generated';
7
9
  import { createCeil } from '../../factoriesAny.js';
8
10
  export var ceilDependencies = {
11
+ equalScalarDependencies: equalScalarDependencies,
12
+ matrixDependencies: matrixDependencies,
9
13
  roundDependencies: roundDependencies,
10
14
  typedDependencies: typedDependencies,
11
15
  createCeil: createCeil
@@ -5,12 +5,14 @@
5
5
  import { ComplexDependencies } from './dependenciesComplexClass.generated';
6
6
  import { ceilDependencies } from './dependenciesCeil.generated';
7
7
  import { floorDependencies } from './dependenciesFloor.generated';
8
+ import { matrixDependencies } from './dependenciesMatrix.generated';
8
9
  import { typedDependencies } from './dependenciesTyped.generated';
9
10
  import { createFix } from '../../factoriesAny.js';
10
11
  export var fixDependencies = {
11
12
  ComplexDependencies: ComplexDependencies,
12
13
  ceilDependencies: ceilDependencies,
13
14
  floorDependencies: floorDependencies,
15
+ matrixDependencies: matrixDependencies,
14
16
  typedDependencies: typedDependencies,
15
17
  createFix: createFix
16
18
  };
@@ -2,10 +2,14 @@
2
2
  * THIS FILE IS AUTO-GENERATED
3
3
  * DON'T MAKE CHANGES HERE
4
4
  */
5
+ import { equalScalarDependencies } from './dependenciesEqualScalar.generated';
6
+ import { matrixDependencies } from './dependenciesMatrix.generated';
5
7
  import { roundDependencies } from './dependenciesRound.generated';
6
8
  import { typedDependencies } from './dependenciesTyped.generated';
7
9
  import { createFloor } from '../../factoriesAny.js';
8
10
  export var floorDependencies = {
11
+ equalScalarDependencies: equalScalarDependencies,
12
+ matrixDependencies: matrixDependencies,
9
13
  roundDependencies: roundDependencies,
10
14
  typedDependencies: typedDependencies,
11
15
  createFloor: createFloor
@@ -0,0 +1,10 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED
3
+ * DON'T MAKE CHANGES HERE
4
+ */
5
+ import { typedDependencies } from './dependenciesTyped.generated';
6
+ import { createHex } from '../../factoriesAny.js';
7
+ export var hexDependencies = {
8
+ typedDependencies: typedDependencies,
9
+ createHex: createHex
10
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED
3
+ * DON'T MAKE CHANGES HERE
4
+ */
5
+ import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated';
6
+ import { divideScalarDependencies } from './dependenciesDivideScalar.generated';
7
+ import { equalScalarDependencies } from './dependenciesEqualScalar.generated';
8
+ import { matrixDependencies } from './dependenciesMatrix.generated';
9
+ import { multiplyScalarDependencies } from './dependenciesMultiplyScalar.generated';
10
+ import { subtractDependencies } from './dependenciesSubtract.generated';
11
+ import { typedDependencies } from './dependenciesTyped.generated';
12
+ import { createLsolveAll } from '../../factoriesAny.js';
13
+ export var lsolveAllDependencies = {
14
+ DenseMatrixDependencies: DenseMatrixDependencies,
15
+ divideScalarDependencies: divideScalarDependencies,
16
+ equalScalarDependencies: equalScalarDependencies,
17
+ matrixDependencies: matrixDependencies,
18
+ multiplyScalarDependencies: multiplyScalarDependencies,
19
+ subtractDependencies: subtractDependencies,
20
+ typedDependencies: typedDependencies,
21
+ createLsolveAll: createLsolveAll
22
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED
3
+ * DON'T MAKE CHANGES HERE
4
+ */
5
+ import { typedDependencies } from './dependenciesTyped.generated';
6
+ import { createOct } from '../../factoriesAny.js';
7
+ export var octDependencies = {
8
+ typedDependencies: typedDependencies,
9
+ createOct: createOct
10
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * THIS FILE IS AUTO-GENERATED
3
+ * DON'T MAKE CHANGES HERE
4
+ */
5
+ import { BigNumberDependencies } from './dependenciesBigNumberClass.generated';
6
+ import { DenseMatrixDependencies } from './dependenciesDenseMatrixClass.generated';
7
+ import { SparseMatrixDependencies } from './dependenciesSparseMatrixClass.generated';
8
+ import { addScalarDependencies } from './dependenciesAddScalar.generated';
9
+ import { cosDependencies } from './dependenciesCos.generated';
10
+ import { matrixDependencies } from './dependenciesMatrix.generated';
11
+ import { multiplyScalarDependencies } from './dependenciesMultiplyScalar.generated';
12
+ import { normDependencies } from './dependenciesNorm.generated';
13
+ import { sinDependencies } from './dependenciesSin.generated';
14
+ import { typedDependencies } from './dependenciesTyped.generated';
15
+ import { unaryMinusDependencies } from './dependenciesUnaryMinus.generated';
16
+ import { createRotationMatrix } from '../../factoriesAny.js';
17
+ export var rotationMatrixDependencies = {
18
+ BigNumberDependencies: BigNumberDependencies,
19
+ DenseMatrixDependencies: DenseMatrixDependencies,
20
+ SparseMatrixDependencies: SparseMatrixDependencies,
21
+ addScalarDependencies: addScalarDependencies,
22
+ cosDependencies: cosDependencies,
23
+ matrixDependencies: matrixDependencies,
24
+ multiplyScalarDependencies: multiplyScalarDependencies,
25
+ normDependencies: normDependencies,
26
+ sinDependencies: sinDependencies,
27
+ typedDependencies: typedDependencies,
28
+ unaryMinusDependencies: unaryMinusDependencies,
29
+ createRotationMatrix: createRotationMatrix
30
+ };