mathjs 10.5.0 → 10.5.1
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 +12 -0
- package/docs/datatypes/matrices.md +17 -0
- package/docs/expressions/syntax.md +4 -1
- package/docs/reference/functions/fix.md +1 -0
- package/docs/reference/functions/floor.md +4 -0
- package/docs/reference/functions/resolve.md +2 -2
- package/docs/reference/functions/simplifyConstant.md +52 -0
- package/lib/browser/math.js +5 -5
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesFix.generated.js +9 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -3
- package/lib/cjs/entry/dependenciesNumber/dependenciesCeil.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesFix.generated.js +6 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesFloor.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -3
- package/lib/cjs/entry/impureFunctionsAny.generated.js +0 -1
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +6 -7
- package/lib/cjs/entry/pureFunctionsAny.generated.js +10 -3
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +21 -15
- package/lib/cjs/expression/node/IndexNode.js +26 -61
- package/lib/cjs/factoriesNumber.js +29 -24
- package/lib/cjs/function/algebra/resolve.js +3 -3
- package/lib/cjs/function/arithmetic/ceil.js +75 -39
- package/lib/cjs/function/arithmetic/fix.js +54 -16
- package/lib/cjs/function/arithmetic/floor.js +79 -37
- package/lib/cjs/function/arithmetic/nthRoot.js +1 -3
- package/lib/cjs/function/arithmetic/round.js +27 -47
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/number/arithmetic.js +9 -27
- package/lib/cjs/type/matrix/function/sparse.js +6 -0
- package/lib/cjs/utils/lruQueue.js +1 -3
- package/lib/cjs/utils/object.js +3 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesFix.generated.js +6 -0
- package/lib/esm/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIndexNode.generated.js +0 -2
- package/lib/esm/entry/dependenciesNumber/dependenciesCeil.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesFix.generated.js +4 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesFloor.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIndexNode.generated.js +0 -2
- package/lib/esm/entry/impureFunctionsAny.generated.js +0 -1
- package/lib/esm/entry/impureFunctionsNumber.generated.js +7 -8
- package/lib/esm/entry/pureFunctionsAny.generated.js +10 -3
- package/lib/esm/entry/pureFunctionsNumber.generated.js +16 -10
- package/lib/esm/expression/node/BlockNode.js +3 -3
- package/lib/esm/expression/node/IndexNode.js +22 -59
- package/lib/esm/expression/parse.js +5 -5
- package/lib/esm/factoriesNumber.js +6 -6
- package/lib/esm/function/algebra/decomposition/qr.js +2 -2
- package/lib/esm/function/algebra/resolve.js +3 -3
- package/lib/esm/function/algebra/solver/utils/solveValidation.js +5 -5
- package/lib/esm/function/algebra/sparse/csChol.js +2 -2
- package/lib/esm/function/algebra/sparse/csLeaf.js +2 -2
- package/lib/esm/function/algebra/sparse/csLu.js +3 -3
- package/lib/esm/function/arithmetic/ceil.js +61 -24
- package/lib/esm/function/arithmetic/fix.js +51 -13
- package/lib/esm/function/arithmetic/floor.js +65 -23
- package/lib/esm/function/arithmetic/nthRoot.js +1 -3
- package/lib/esm/function/arithmetic/nthRoots.js +1 -1
- package/lib/esm/function/arithmetic/round.js +25 -43
- package/lib/esm/function/matrix/expm.js +2 -2
- package/lib/esm/function/probability/gamma.js +1 -1
- package/lib/esm/function/string/bin.js +1 -1
- package/lib/esm/function/string/hex.js +1 -1
- package/lib/esm/function/string/oct.js +1 -1
- package/lib/esm/plain/number/arithmetic.js +9 -17
- package/lib/esm/type/complex/Complex.js +2 -2
- package/lib/esm/type/matrix/DenseMatrix.js +2 -2
- package/lib/esm/type/matrix/FibonacciHeap.js +2 -2
- package/lib/esm/type/matrix/SparseMatrix.js +13 -13
- package/lib/esm/type/matrix/function/sparse.js +6 -0
- package/lib/esm/type/unit/Unit.js +7 -7
- package/lib/esm/utils/lruQueue.js +1 -2
- package/lib/esm/utils/number.js +3 -3
- package/lib/esm/utils/object.js +3 -1
- package/lib/esm/version.js +1 -1
- package/package.json +14 -3
- package/types/index.d.ts +1794 -1372
- package/types/index.ts +697 -266
package/HISTORY.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# History
|
2
2
|
|
3
|
+
# 2022-05-02 version 10.5.1
|
4
|
+
|
5
|
+
- Fix #2526, #2529: improve TypeScript definitions of function `round`, `fix`,
|
6
|
+
`floor`, `ceil`, and `nthRoot`, and improved the number only implementations
|
7
|
+
of those functions (#2531, #2539). Thanks @simlaticak and @gwhitney.
|
8
|
+
- Fix #2532: matrix index symbol `end` not working when used inside
|
9
|
+
a sub-expression.
|
10
|
+
- Fix #2524: In generating AUTHORS list, ignore a list of specific commits
|
11
|
+
(e.g., to avoid spurious duplicates in list). (#2543)
|
12
|
+
- Add type definitions of function `resolve` (#2536). Thanks @mattvague.
|
13
|
+
|
14
|
+
|
3
15
|
# 2022-04-19, version 10.5.0
|
4
16
|
|
5
17
|
- Implement #1563: function `pinv`, Moore–Penrose inverse (#2521).
|
@@ -342,6 +342,23 @@ const m1 = math.matrix([[0, 1], [0, 0]], 'sparse')
|
|
342
342
|
const m2 = math.identity(1000, 1000, 'sparse')
|
343
343
|
```
|
344
344
|
|
345
|
+
You can also coerce an array or matrix into sparse storage format with the
|
346
|
+
`sparse` function.
|
347
|
+
```js
|
348
|
+
const md = math.matrix([[0, 1], [0,0]]) // dense
|
349
|
+
const ms = math.sparse(md) // sparse
|
350
|
+
```
|
351
|
+
|
352
|
+
Caution: `sparse` called on a JavaScript array of _n_ plain numbers produces
|
353
|
+
a matrix with one column and _n_ rows -- in contrast to `matrix`, which
|
354
|
+
produces a 1-dimensional matrix object with _n_ entries, i.e., a vector
|
355
|
+
(_not_ a 1 by _n_ "row vector" nor an _n_ by 1 "column vector", but just a plain
|
356
|
+
vector of length _n_).
|
357
|
+
```js
|
358
|
+
const mv = math.matrix([0, 0, 1]) // Has size [3]
|
359
|
+
const mc = math.sparse([0, 0, 1]) // A "column vector," has size [3, 1]
|
360
|
+
```
|
361
|
+
|
345
362
|
## API
|
346
363
|
|
347
364
|
All relevant functions in math.js support Matrices and Arrays. Functions like `math.add` and `math.subtract`, `math.sqrt` handle matrices element wise. There is a set of functions specifically for creating or manipulating matrices, such as:
|
@@ -549,8 +549,11 @@ can be replaced by using indexes. Indexes are enclosed in square brackets, and
|
|
549
549
|
contain a number or a range for each of the matrix dimensions. A range can have
|
550
550
|
its start and/or end undefined. When the start is undefined, the range will start
|
551
551
|
at 1, when the end is undefined, the range will end at the end of the matrix.
|
552
|
+
|
552
553
|
There is a context variable `end` available as well to denote the end of the
|
553
|
-
matrix.
|
554
|
+
matrix. This variable cannot be used in multiple nested indices. In that case,
|
555
|
+
`end` will be resolved as the end of the innermost matrix. To solve this,
|
556
|
+
resolving of the nested index needs to be split in two separate operations.
|
554
557
|
|
555
558
|
*IMPORTANT: matrix indexes and ranges work differently from the math.js indexes
|
556
559
|
in JavaScript: They are one-based with an included upper-bound, similar to most
|
@@ -52,6 +52,10 @@ math.floor(c, 1) // returns Complex 3.2 - 2.8i
|
|
52
52
|
|
53
53
|
math.floor([3.2, 3.8, -4.7]) // returns Array [3, 3, -5]
|
54
54
|
math.floor([3.21, 3.82, -4.71], 1) // returns Array [3.2, 3.8, -4.8]
|
55
|
+
|
56
|
+
math.floor(math.tau, [2, 3]) // returns Array [6.28, 6.283]
|
57
|
+
|
58
|
+
// Note that floor(array, array) currently not implemented.
|
55
59
|
```
|
56
60
|
|
57
61
|
|
@@ -15,14 +15,14 @@ resolve(expr, scope)
|
|
15
15
|
|
16
16
|
Parameter | Type | Description
|
17
17
|
--------- | ---- | -----------
|
18
|
-
`node` | Node | The expression tree to be simplified
|
18
|
+
`node` | Node | Node[] | The expression tree (or trees) to be simplified
|
19
19
|
`scope` | Object | Scope specifying variables to be resolved
|
20
20
|
|
21
21
|
### Returns
|
22
22
|
|
23
23
|
Type | Description
|
24
24
|
---- | -----------
|
25
|
-
Node | Returns `node` with variables recursively substituted.
|
25
|
+
Node | Node[] | Returns `node` with variables recursively substituted.
|
26
26
|
|
27
27
|
|
28
28
|
### Throws
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
|
2
|
+
|
3
|
+
# Function simplifyConstant
|
4
|
+
|
5
|
+
simplifyConstant() takes a mathjs expression (either a Node representing
|
6
|
+
a parse tree or a string which it parses to produce a node), and replaces
|
7
|
+
any subexpression of it consisting entirely of constants with the computed
|
8
|
+
value of that subexpression.
|
9
|
+
|
10
|
+
|
11
|
+
## Syntax
|
12
|
+
|
13
|
+
```js
|
14
|
+
simplifyConstant(expr)
|
15
|
+
simplifyConstant(expr, options)
|
16
|
+
```
|
17
|
+
|
18
|
+
### Parameters
|
19
|
+
|
20
|
+
Parameter | Type | Description
|
21
|
+
--------- | ---- | -----------
|
22
|
+
`node` | Node | string | The expression to be simplified
|
23
|
+
`options` | Object | Simplification options, as per simplify()
|
24
|
+
|
25
|
+
### Returns
|
26
|
+
|
27
|
+
Type | Description
|
28
|
+
---- | -----------
|
29
|
+
Node | Returns expression with constant subexpressions evaluated
|
30
|
+
|
31
|
+
|
32
|
+
### Throws
|
33
|
+
|
34
|
+
Type | Description
|
35
|
+
---- | -----------
|
36
|
+
|
37
|
+
|
38
|
+
## Examples
|
39
|
+
|
40
|
+
```js
|
41
|
+
math.simplifyConstant('x + 4*3/6') // Node "x + 2"
|
42
|
+
math.simplifyConstant('z cos(0)') // Node "z 1"
|
43
|
+
math.simplifyConstant('(5.2 + 1.08)t', {exactFractions: false}) // Node "6.28 t"
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
## See also
|
48
|
+
|
49
|
+
[simplify](simplify.md),
|
50
|
+
[simplifyCore](simplifyCore.md),
|
51
|
+
[resolve](resolve.md),
|
52
|
+
[derivative](derivative.md)
|