mathjs 11.3.3 → 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 +25 -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/entry/dependenciesAny/dependenciesLyap.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesPolynomialRoot.generated.js +42 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSchur.generated.js +30 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSylvester.generated.js +46 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +28 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +21 -17
- package/lib/cjs/entry/pureFunctionsAny.generated.js +100 -48
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +8 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/polynomialRoot.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/lyap.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/reshape.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/schur.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/sylvester.js +15 -0
- package/lib/cjs/factoriesAny.js +28 -0
- package/lib/cjs/function/algebra/decomposition/schur.js +75 -0
- package/lib/cjs/function/algebra/lyap.js +57 -0
- package/lib/cjs/function/algebra/polynomialRoot.js +139 -0
- package/lib/cjs/function/algebra/simplify/wildcards.js +38 -0
- package/lib/cjs/function/algebra/simplify.js +161 -48
- package/lib/cjs/function/algebra/simplifyConstant.js +29 -12
- package/lib/cjs/function/algebra/sylvester.js +127 -0
- package/lib/cjs/function/matrix/forEach.js +1 -1
- 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/entry/dependenciesAny/dependenciesLyap.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesPolynomialRoot.generated.js +34 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSchur.generated.js +22 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSylvester.generated.js +38 -0
- package/lib/esm/entry/dependenciesAny.generated.js +4 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +22 -18
- package/lib/esm/entry/pureFunctionsAny.generated.js +87 -39
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/polynomialRoot.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/lyap.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/reshape.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/schur.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/sylvester.js +8 -0
- package/lib/esm/factoriesAny.js +4 -0
- package/lib/esm/function/algebra/decomposition/schur.js +70 -0
- package/lib/esm/function/algebra/lyap.js +52 -0
- package/lib/esm/function/algebra/polynomialRoot.js +122 -0
- package/lib/esm/function/algebra/simplify/wildcards.js +20 -0
- package/lib/esm/function/algebra/simplify.js +162 -49
- package/lib/esm/function/algebra/simplifyConstant.js +29 -12
- package/lib/esm/function/algebra/sylvester.js +118 -0
- package/lib/esm/function/matrix/forEach.js +1 -1
- 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 +14 -14
- package/types/index.d.ts +88 -6
@@ -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,28 +36,28 @@
|
|
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",
|
51
51
|
"codecov": "3.8.3",
|
52
|
-
"core-js": "3.26.
|
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",
|
@@ -78,7 +78,7 @@
|
|
78
78
|
"math-expression-evaluator": "1.4.0",
|
79
79
|
"mkdirp": "1.0.4",
|
80
80
|
"mocha": "10.1.0",
|
81
|
-
"mocha-junit-reporter": "2.
|
81
|
+
"mocha-junit-reporter": "2.2.0",
|
82
82
|
"ndarray": "1.0.19",
|
83
83
|
"ndarray-determinant": "1.0.0",
|
84
84
|
"ndarray-gemm": "1.0.0",
|
@@ -87,12 +87,12 @@
|
|
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",
|
94
|
-
"typescript": "4.
|
95
|
-
"webpack": "5.
|
94
|
+
"typescript": "4.9.3",
|
95
|
+
"webpack": "5.75.0",
|
96
96
|
"zeros": "1.0.0"
|
97
97
|
},
|
98
98
|
"type": "module",
|
package/types/index.d.ts
CHANGED
@@ -465,6 +465,11 @@ declare namespace math {
|
|
465
465
|
R: MathCollection
|
466
466
|
}
|
467
467
|
|
468
|
+
interface SchurDecomposition {
|
469
|
+
U: MathCollection
|
470
|
+
T: MathCollection
|
471
|
+
}
|
472
|
+
|
468
473
|
interface FractionDefinition {
|
469
474
|
a: number
|
470
475
|
b: number
|
@@ -894,6 +899,22 @@ declare namespace math {
|
|
894
899
|
threshold?: number
|
895
900
|
): MathArray
|
896
901
|
|
902
|
+
/* Finds the roots of a polynomial of degree three or less. Coefficients are given constant first
|
903
|
+
* followed by linear and higher powers in order; coefficients beyond the degree of the polynomial
|
904
|
+
* need not be specified.
|
905
|
+
* @param {number|Complex} constantCoeff
|
906
|
+
* @param {number|Complex} linearCoeff
|
907
|
+
* @param {number|Complex} quadraticCoeff
|
908
|
+
* @param {number|Complex} cubicCoeff
|
909
|
+
* @returns {Array<number|Complex>} array of roots of specified polynomial
|
910
|
+
*/
|
911
|
+
polynomialRoot(
|
912
|
+
constantCoeff: number | Complex,
|
913
|
+
linearCoeff: number | Complex,
|
914
|
+
quadraticCoeff?: number | Complex,
|
915
|
+
cubicCoeff?: number | Complex
|
916
|
+
): (number | Complex)[]
|
917
|
+
|
897
918
|
/**
|
898
919
|
* Calculate the Matrix QR decomposition. Matrix A is decomposed in two
|
899
920
|
* matrices (Q, R) where Q is an orthogonal matrix and R is an upper
|
@@ -1276,9 +1297,13 @@ declare namespace math {
|
|
1276
1297
|
multiply<T extends Matrix>(x: T, y: MathType): Matrix
|
1277
1298
|
multiply<T extends Matrix>(x: MathType, y: T): Matrix
|
1278
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
|
+
|
1279
1305
|
multiply(x: Unit, y: Unit): Unit
|
1280
1306
|
multiply(x: number, y: number): number
|
1281
|
-
multiply(x: MathArray, y: MathArray): MathArray
|
1282
1307
|
multiply(x: MathType, y: MathType): MathType
|
1283
1308
|
|
1284
1309
|
/**
|
@@ -1807,6 +1832,41 @@ declare namespace math {
|
|
1807
1832
|
*/
|
1808
1833
|
expm(x: Matrix): Matrix
|
1809
1834
|
|
1835
|
+
/**
|
1836
|
+
* Solves the real-valued Sylvester equation AX-XB=C for X, where A, B and C are
|
1837
|
+
* matrices of appropriate dimensions, being A and B squared. The method used is
|
1838
|
+
* the Bartels-Stewart algorithm.
|
1839
|
+
* https://en.wikipedia.org/wiki/Sylvester_equation
|
1840
|
+
* @param A Matrix A
|
1841
|
+
* @param B Matrix B
|
1842
|
+
* @param C Matrix C
|
1843
|
+
* @returns Matrix X, solving the Sylvester equation
|
1844
|
+
*/
|
1845
|
+
sylvester(
|
1846
|
+
A: Matrix | MathArray,
|
1847
|
+
B: Matrix | MathArray,
|
1848
|
+
C: Matrix | MathArray
|
1849
|
+
): Matrix | MathArray
|
1850
|
+
|
1851
|
+
/**
|
1852
|
+
* Performs a real Schur decomposition of the real matrix A = UTU' where U is orthogonal
|
1853
|
+
* and T is upper quasi-triangular.
|
1854
|
+
* https://en.wikipedia.org/wiki/Schur_decomposition
|
1855
|
+
* @param A Matrix A
|
1856
|
+
* @returns Object containing both matrix U and T of the Schur Decomposition A=UTU'
|
1857
|
+
*/
|
1858
|
+
schur(A: Matrix | MathArray): SchurDecomposition
|
1859
|
+
|
1860
|
+
/**
|
1861
|
+
* Solves the Continuous-time Lyapunov equation AP+PA'=Q for P, where Q is a positive semidefinite
|
1862
|
+
* matrix.
|
1863
|
+
* https://en.wikipedia.org/wiki/Lyapunov_equation
|
1864
|
+
* @param A Matrix A
|
1865
|
+
* @param Q Matrix Q
|
1866
|
+
* @returns Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
|
1867
|
+
*/
|
1868
|
+
lyap(A: Matrix | MathArray, Q: Matrix | MathArray): Matrix | MathArray
|
1869
|
+
|
1810
1870
|
/**
|
1811
1871
|
* Create a 2-dimensional identity matrix with size m x n or n x n. The
|
1812
1872
|
* matrix has ones on the diagonal and zeros elsewhere.
|
@@ -3572,6 +3632,9 @@ declare namespace math {
|
|
3572
3632
|
invDependencies: FactoryFunctionMap
|
3573
3633
|
expmDependencies: FactoryFunctionMap
|
3574
3634
|
sqrtmDependencies: FactoryFunctionMap
|
3635
|
+
sylvesterDependencies: FactoryFunctionMap
|
3636
|
+
schurDependencies: FactoryFunctionMap
|
3637
|
+
lyapDependencies: FactoryFunctionMap
|
3575
3638
|
divideDependencies: FactoryFunctionMap
|
3576
3639
|
distanceDependencies: FactoryFunctionMap
|
3577
3640
|
intersectDependencies: FactoryFunctionMap
|
@@ -3977,8 +4040,8 @@ declare namespace math {
|
|
3977
4040
|
*/
|
3978
4041
|
forEach(
|
3979
4042
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
3980
|
-
callback: (node: MathNode, path: string, parent: MathNode) =>
|
3981
|
-
):
|
4043
|
+
callback: (node: MathNode, path: string, parent: MathNode) => void
|
4044
|
+
): void
|
3982
4045
|
|
3983
4046
|
/**
|
3984
4047
|
* Transform a node. Creates a new MathNode having it’s child's be the
|
@@ -4071,8 +4134,7 @@ declare namespace math {
|
|
4071
4134
|
*/
|
4072
4135
|
traverse(
|
4073
4136
|
callback: (node: MathNode, path: string, parent: MathNode) => void
|
4074
|
-
|
4075
|
-
): any
|
4137
|
+
): void
|
4076
4138
|
}
|
4077
4139
|
|
4078
4140
|
interface Parser {
|
@@ -5273,6 +5335,26 @@ declare namespace math {
|
|
5273
5335
|
|
5274
5336
|
expm(this: MathJsChain<Matrix>): MathJsChain<Matrix>
|
5275
5337
|
|
5338
|
+
/**
|
5339
|
+
* Performs a real Schur decomposition of the real matrix A = UTU' where U is orthogonal
|
5340
|
+
* and T is upper quasi-triangular.
|
5341
|
+
* https://en.wikipedia.org/wiki/Schur_decomposition
|
5342
|
+
* @returns Object containing both matrix U and T of the Schur Decomposition A=UTU'
|
5343
|
+
*/
|
5344
|
+
schur(this: MathJsChain<Matrix | MathArray>): SchurDecomposition
|
5345
|
+
|
5346
|
+
/**
|
5347
|
+
* Solves the Continuous-time Lyapunov equation AP+PA'=Q for P, where Q is a positive semidefinite
|
5348
|
+
* matrix.
|
5349
|
+
* https://en.wikipedia.org/wiki/Lyapunov_equation
|
5350
|
+
* @param Q Matrix Q
|
5351
|
+
* @returns Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
|
5352
|
+
*/
|
5353
|
+
lyap(
|
5354
|
+
this: MathJsChain<Matrix | MathArray>,
|
5355
|
+
Q: Matrix | MathArray
|
5356
|
+
): MathJsChain<Matrix | MathArray>
|
5357
|
+
|
5276
5358
|
/**
|
5277
5359
|
* Create a 2-dimensional identity matrix with size m x n or n x n. The
|
5278
5360
|
* matrix has ones on the diagonal and zeros elsewhere.
|
@@ -5323,7 +5405,7 @@ declare namespace math {
|
|
5323
5405
|
this: MathJsChain<T>,
|
5324
5406
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
5325
5407
|
callback: (value: any, index: any, matrix: T) => void
|
5326
|
-
):
|
5408
|
+
): void
|
5327
5409
|
|
5328
5410
|
/**
|
5329
5411
|
* Calculate the inverse of a square matrix.
|