@cortex-js/compute-engine 0.29.1 → 0.30.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/dist/compute-engine.esm.js +28319 -24614
- package/dist/compute-engine.min.esm.js +70 -68
- package/dist/compute-engine.min.umd.js +131 -0
- package/dist/{compute-engine.cjs → compute-engine.umd.js} +29615 -25910
- package/dist/math-json.esm.js +22 -294
- package/dist/math-json.min.esm.js +22 -294
- package/dist/math-json.min.umd.js +4 -0
- package/dist/math-json.umd.js +141 -0
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +28 -0
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +20 -4
- package/dist/types/common/type/parse.d.ts +4 -4
- package/dist/types/common/type/primitive.d.ts +3 -2
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +91 -25
- package/dist/types/common/type/utils.d.ts +2 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +72 -73
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +19 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +42 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +48 -27
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +17 -5
- package/dist/types/compute-engine/boxed-expression/{boxed-function-definition.d.ts → boxed-operator-definition.d.ts} +12 -12
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +7 -8
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +91 -52
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +22 -25
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +46 -0
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +5 -0
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +30 -3
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +41 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +3 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +23 -23
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +2 -1
- package/dist/types/compute-engine/collection-utils.d.ts +22 -57
- package/dist/types/compute-engine/compile.d.ts +61 -10
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +46 -29
- package/dist/types/compute-engine/global-types.d.ts +1432 -893
- package/dist/types/compute-engine/index.d.ts +154 -124
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +3 -3
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +21 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +14 -12
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +51 -39
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +5 -0
- package/dist/types/compute-engine/library/arithmetic.d.ts +2 -2
- package/dist/types/compute-engine/library/calculus.d.ts +2 -2
- package/dist/types/compute-engine/library/collections.d.ts +3 -3
- package/dist/types/compute-engine/library/combinatorics.d.ts +2 -0
- package/dist/types/compute-engine/library/complex.d.ts +2 -2
- package/dist/types/compute-engine/library/control-structures.d.ts +2 -2
- package/dist/types/compute-engine/library/core.d.ts +2 -2
- package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +5 -5
- package/dist/types/compute-engine/library/linear-algebra.d.ts +2 -2
- package/dist/types/compute-engine/library/logic.d.ts +2 -2
- package/dist/types/compute-engine/library/number-theory.d.ts +2 -0
- package/dist/types/compute-engine/library/polynomials.d.ts +2 -2
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +2 -2
- package/dist/types/compute-engine/library/sets.d.ts +2 -2
- package/dist/types/compute-engine/library/statistics.d.ts +2 -2
- package/dist/types/compute-engine/library/trigonometry.d.ts +2 -2
- package/dist/types/compute-engine/library/utils.d.ts +24 -2
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +3 -4
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +3 -3
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +3 -4
- package/dist/types/compute-engine/numeric-value/types.d.ts +7 -5
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +4 -19
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +9 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +3 -0
- package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -4
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +5 -46
- package/dist/types/compute-engine/tensor/tensors.d.ts +4 -14
- package/dist/types/compute-engine/types.d.ts +1 -4
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/math-json/symbols.d.ts +11 -0
- package/dist/types/math-json/types.d.ts +19 -11
- package/dist/types/math-json/utils.d.ts +18 -9
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +13 -11
- package/dist/compute-engine.min.cjs +0 -129
- package/dist/math-json.cjs +0 -413
- package/dist/math-json.min.cjs +0 -6
- package/dist/types/common/json5.d.ts +0 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +0 -64
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +0 -21
- package/dist/types/math-json/identifiers.d.ts +0 -11
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Thoughts for future improvements:
|
|
6
|
-
* - use a MISER algorithm to improve the accuracy
|
|
7
|
-
* - use a stratified sampling to improve the accuracy
|
|
8
|
-
* - use a quasi-Monte Carlo method to improve the accuracy
|
|
9
|
-
* - use a Markov Chain Monte Carlo method to improve the accuracy
|
|
10
|
-
* - use a Metropolis-Hastings algorithm to improve the accuracy
|
|
11
|
-
* - use a Hamiltonian Monte Carlo algorithm to improve the accuracy
|
|
12
|
-
* - use a Gibbs sampling algorithm to improve the accuracy
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* See:
|
|
16
|
-
* - https://64.github.io/monte-carlo/
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export declare function monteCarloEstimate(f: (x: number) => number, a: number, b: number, n?: number): number;
|
|
1
|
+
/* 0.30.1 */
|
|
2
|
+
estimate: number;
|
|
3
|
+
error: number;
|
|
4
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
export declare const MACHINE_PRECISION_BITS = 53;
|
|
3
3
|
export declare const MACHINE_PRECISION: number;
|
|
4
4
|
export declare const DEFAULT_TOLERANCE = 1e-10;
|
|
@@ -50,3 +50,11 @@ export declare function centeredDiff8thOrder(f: (number: any) => number, x: numb
|
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
52
|
export declare function limit(f: (x: number) => number, x: number, dir?: number): number;
|
|
53
|
+
export declare function cantorEnumerateRationals(): Generator<[number, number]>;
|
|
54
|
+
export declare function cantorEnumeratePositiveRationals(): Generator<[
|
|
55
|
+
number,
|
|
56
|
+
number
|
|
57
|
+
]>;
|
|
58
|
+
export declare function cantorEnumerateComplexNumbers(): Generator<[number, number]>;
|
|
59
|
+
export declare function cantorEnumerateIntegers(): Generator<number>;
|
|
60
|
+
export declare function cantorEnumerateNaturalNumbers(): Generator<number>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
export declare function numberToString(num: number | bigint, fractionalDigits?: number | string): string;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
/**
|
|
3
3
|
*
|
|
4
|
-
* @param fn The function to differentiate, a
|
|
5
|
-
* an identifier for a function name.
|
|
4
|
+
* @param fn The function to differentiate, a function literal.
|
|
6
5
|
*
|
|
7
|
-
* @param degrees
|
|
8
6
|
* @returns a function expression representing the derivative of `fn` with
|
|
9
7
|
* respect to the variables in `degrees`.
|
|
10
8
|
*/
|
|
@@ -1,46 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { BoxedExpression, ComputeEngine, DataTypeMap, TensorDataType } from '../global-types';
|
|
1
|
+
/* 0.30.1 */
|
|
2
|
+
import { BoxedExpression, ComputeEngine, DataTypeMap, TensorDataType, TensorField } from '../global-types';
|
|
3
3
|
/** @category Tensors */
|
|
4
4
|
export declare function makeTensorField<DT extends keyof DataTypeMap>(ce: ComputeEngine, dtype: DT): TensorField<DataTypeMap[DT]>;
|
|
5
5
|
/** @category Tensors */
|
|
6
|
-
export interface TensorField<T extends number | Complex | BoxedExpression | boolean | string = number> {
|
|
7
|
-
readonly one: T;
|
|
8
|
-
readonly zero: T;
|
|
9
|
-
readonly nan: T;
|
|
10
|
-
cast(x: T, dtype: 'float64'): undefined | number;
|
|
11
|
-
cast(x: T, dtype: 'float32'): undefined | number;
|
|
12
|
-
cast(x: T, dtype: 'int32'): undefined | number;
|
|
13
|
-
cast(x: T, dtype: 'uint8'): undefined | number;
|
|
14
|
-
cast(x: T, dtype: 'complex128'): undefined | Complex;
|
|
15
|
-
cast(x: T, dtype: 'complex64'): undefined | Complex;
|
|
16
|
-
cast(x: T, dtype: 'bool'): undefined | boolean;
|
|
17
|
-
cast(x: T, dtype: 'string'): undefined | string;
|
|
18
|
-
cast(x: T, dtype: 'expression'): undefined | BoxedExpression;
|
|
19
|
-
cast(x: T[], dtype: 'float64'): undefined | number[];
|
|
20
|
-
cast(x: T[], dtype: 'float32'): undefined | number[];
|
|
21
|
-
cast(x: T[], dtype: 'int32'): undefined | number[];
|
|
22
|
-
cast(x: T[], dtype: 'uint8'): undefined | number[];
|
|
23
|
-
cast(x: T[], dtype: 'complex128'): undefined | Complex[];
|
|
24
|
-
cast(x: T[], dtype: 'complex64'): undefined | Complex[];
|
|
25
|
-
cast(x: T[], dtype: 'bool'): undefined | boolean[];
|
|
26
|
-
cast(x: T[], dtype: 'string'): undefined | string[];
|
|
27
|
-
cast(x: T[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
28
|
-
cast(x: T | T[], dtype: TensorDataType): undefined | Complex | number | boolean | string | BoxedExpression | Complex[] | number[] | boolean[] | string[] | BoxedExpression[];
|
|
29
|
-
expression(x: T): BoxedExpression;
|
|
30
|
-
isZero(x: T): boolean;
|
|
31
|
-
isOne(x: T): boolean;
|
|
32
|
-
equals(lhs: T, rhs: T): boolean;
|
|
33
|
-
add(lhs: T, rhs: T): T;
|
|
34
|
-
addn(...xs: T[]): T;
|
|
35
|
-
neg(x: T): T;
|
|
36
|
-
sub(lhs: T, rhs: T): T;
|
|
37
|
-
mul(lhs: T, rhs: T): T;
|
|
38
|
-
muln(...xs: T[]): T;
|
|
39
|
-
div(lhs: T, rhs: T): T;
|
|
40
|
-
pow(rhs: T, n: number): T;
|
|
41
|
-
conjugate(x: T): T;
|
|
42
|
-
}
|
|
43
|
-
/** @category Tensors */
|
|
44
6
|
export declare class TensorFieldNumber implements TensorField<number> {
|
|
45
7
|
private ce;
|
|
46
8
|
one: number;
|
|
@@ -54,7 +16,6 @@ export declare class TensorFieldNumber implements TensorField<number> {
|
|
|
54
16
|
cast(x: number, dtype: 'complex128'): undefined | Complex;
|
|
55
17
|
cast(x: number, dtype: 'complex64'): undefined | Complex;
|
|
56
18
|
cast(x: number, dtype: 'bool'): undefined | boolean;
|
|
57
|
-
cast(x: number, dtype: 'string'): undefined | string;
|
|
58
19
|
cast(x: number, dtype: 'expression'): undefined | BoxedExpression;
|
|
59
20
|
cast(x: number[], dtype: 'float64'): undefined | number[];
|
|
60
21
|
cast(x: number[], dtype: 'float32'): undefined | number[];
|
|
@@ -63,7 +24,6 @@ export declare class TensorFieldNumber implements TensorField<number> {
|
|
|
63
24
|
cast(x: number[], dtype: 'complex128'): undefined | Complex[];
|
|
64
25
|
cast(x: number[], dtype: 'complex64'): undefined | Complex[];
|
|
65
26
|
cast(x: number[], dtype: 'bool'): undefined | boolean[];
|
|
66
|
-
cast(x: number[], dtype: 'string'): undefined | string[];
|
|
67
27
|
cast(x: number[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
68
28
|
expression(x: number): BoxedExpression;
|
|
69
29
|
isZero(x: number): boolean;
|
|
@@ -93,7 +53,6 @@ export declare class TensorFieldExpression implements TensorField<BoxedExpressio
|
|
|
93
53
|
cast(x: BoxedExpression, dtype: 'complex128'): undefined | Complex;
|
|
94
54
|
cast(x: BoxedExpression, dtype: 'complex64'): undefined | Complex;
|
|
95
55
|
cast(x: BoxedExpression, dtype: 'bool'): undefined | boolean;
|
|
96
|
-
cast(x: BoxedExpression, dtype: 'string'): undefined | string;
|
|
97
56
|
cast(x: BoxedExpression, dtype: 'expression'): undefined | BoxedExpression;
|
|
98
57
|
cast(x: BoxedExpression[], dtype: 'float64'): undefined | number[];
|
|
99
58
|
cast(x: BoxedExpression[], dtype: 'float32'): undefined | number[];
|
|
@@ -102,7 +61,6 @@ export declare class TensorFieldExpression implements TensorField<BoxedExpressio
|
|
|
102
61
|
cast(x: BoxedExpression[], dtype: 'complex128'): undefined | Complex[];
|
|
103
62
|
cast(x: BoxedExpression[], dtype: 'complex64'): undefined | Complex[];
|
|
104
63
|
cast(x: BoxedExpression[], dtype: 'bool'): undefined | boolean[];
|
|
105
|
-
cast(x: BoxedExpression[], dtype: 'string'): undefined | string[];
|
|
106
64
|
cast(x: BoxedExpression[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
107
65
|
expression(x: BoxedExpression): BoxedExpression;
|
|
108
66
|
isZero(x: BoxedExpression): boolean;
|
|
@@ -132,7 +90,6 @@ export declare class TensorFieldComplex implements TensorField<Complex> {
|
|
|
132
90
|
cast(x: Complex, dtype: 'complex128'): undefined | Complex;
|
|
133
91
|
cast(x: Complex, dtype: 'complex64'): undefined | Complex;
|
|
134
92
|
cast(x: Complex, dtype: 'bool'): undefined | boolean;
|
|
135
|
-
cast(x: Complex, dtype: 'string'): undefined | string;
|
|
136
93
|
cast(x: Complex, dtype: 'expression'): undefined | BoxedExpression;
|
|
137
94
|
cast(x: Complex[], dtype: 'float64'): undefined | number[];
|
|
138
95
|
cast(x: Complex[], dtype: 'float32'): undefined | number[];
|
|
@@ -141,7 +98,6 @@ export declare class TensorFieldComplex implements TensorField<Complex> {
|
|
|
141
98
|
cast(x: Complex[], dtype: 'complex128'): undefined | Complex[];
|
|
142
99
|
cast(x: Complex[], dtype: 'complex64'): undefined | Complex[];
|
|
143
100
|
cast(x: Complex[], dtype: 'bool'): undefined | boolean[];
|
|
144
|
-
cast(x: Complex[], dtype: 'string'): undefined | string[];
|
|
145
101
|
cast(x: Complex[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
146
102
|
expression(z: Complex): BoxedExpression;
|
|
147
103
|
isZero(z: Complex): boolean;
|
|
@@ -163,6 +119,9 @@ export declare class TensorFieldComplex implements TensorField<Complex> {
|
|
|
163
119
|
*/
|
|
164
120
|
export declare function getSupertype(t1: TensorDataType | undefined, t2: TensorDataType): TensorDataType;
|
|
165
121
|
/**
|
|
122
|
+
* If the expression is a literal number, return the datatype of the
|
|
123
|
+
* number (or boolean). Otherwise, return the `expression`.
|
|
124
|
+
*
|
|
166
125
|
* @category Tensors
|
|
167
126
|
* @internal
|
|
168
127
|
*/
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import type { BoxedExpression, ComputeEngine, DataTypeMap, TensorData, TensorDataType } from '../global-types';
|
|
3
|
-
/** @internal */
|
|
4
|
-
export type NestedArray<T> = NestedArray_<T>[];
|
|
5
|
-
/** @internal */
|
|
6
|
-
export type NestedArray_<T> = T | NestedArray_<T>[];
|
|
1
|
+
/* 0.30.1 */
|
|
7
2
|
/** @category Tensors */
|
|
8
|
-
export declare abstract class AbstractTensor<DT extends keyof DataTypeMap> implements
|
|
3
|
+
export declare abstract class AbstractTensor<DT extends keyof DataTypeMap> implements Tensor<DT> {
|
|
9
4
|
private ce;
|
|
10
5
|
/**
|
|
11
6
|
* Return a tuple of tensors that have the same dtype.
|
|
@@ -72,6 +67,7 @@ export declare abstract class AbstractTensor<DT extends keyof DataTypeMap> imple
|
|
|
72
67
|
* The data is reused (and shared) between the two tensors.
|
|
73
68
|
*/
|
|
74
69
|
reshape(...shape: number[]): AbstractTensor<DT>;
|
|
70
|
+
slice(index: number): AbstractTensor<DT>;
|
|
75
71
|
flatten(): DataTypeMap[DT][];
|
|
76
72
|
upcast<DT extends keyof DataTypeMap>(dtype: DT): AbstractTensor<DT>;
|
|
77
73
|
/** Transpose the first and second axis */
|
|
@@ -94,10 +90,4 @@ export declare abstract class AbstractTensor<DT extends keyof DataTypeMap> imple
|
|
|
94
90
|
equals(rhs: AbstractTensor<DT>): boolean;
|
|
95
91
|
}
|
|
96
92
|
/** @category Tensors */
|
|
97
|
-
export declare function makeTensor<T extends TensorDataType>(ce: ComputeEngine, data: TensorData<T>
|
|
98
|
-
operator: string;
|
|
99
|
-
ops: BoxedExpression[];
|
|
100
|
-
dtype: T;
|
|
101
|
-
shape: number[];
|
|
102
|
-
}): AbstractTensor<T>;
|
|
103
|
-
export { TensorData };
|
|
93
|
+
export declare function makeTensor<T extends TensorDataType>(ce: ComputeEngine, data: TensorData<T>): AbstractTensor<T>;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
export * from '../math-json/types';
|
|
3
3
|
export * from '../common/type/boxed-type';
|
|
4
4
|
export * from '../common/type/types';
|
|
5
5
|
export type * from './latex-syntax/types';
|
|
6
|
-
export * from './latex-syntax/dictionary/definitions';
|
|
7
6
|
export * from './numerics/types';
|
|
8
7
|
export * from './numeric-value/types';
|
|
9
|
-
export * from './tensor/tensors';
|
|
10
|
-
export * from './tensor/tensor-fields';
|
|
11
8
|
export * from './global-types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* 0.30.1 */
|
|
2
|
+
* Return true if the string is a valid symbol.
|
|
3
|
+
*
|
|
4
|
+
* Check for symbols matching a profile of [Unicode UAX31](https://unicode.org/reports/tr31/)
|
|
5
|
+
*
|
|
6
|
+
* See https://cortexjs.io/math-json/#symbols for a full definition of the
|
|
7
|
+
* profile.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isValidSymbol(s: string): boolean;
|
|
10
|
+
export declare const EMOJIS: RegExp;
|
|
11
|
+
export declare function validateSymbol(s: unknown): 'valid' | 'not-a-string' | 'empty-string' | 'expected-nfc' | 'unexpected-mixed-emoji' | 'unexpected-bidi-marker' | 'unexpected-script' | 'invalid-first-char' | 'invalid-char';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
|
+
* The following properties can be added to any MathJSON expression
|
|
3
|
+
* to provide additional information about the expression.
|
|
4
|
+
*
|
|
5
|
+
* @category MathJSON */
|
|
2
6
|
export type MathJsonAttributes = {
|
|
3
7
|
/** A human readable string to annotate this expression, since JSON does not
|
|
4
8
|
* allow comments in its encoding */
|
|
@@ -56,7 +60,7 @@ export type MathJsonAttributes = {
|
|
|
56
60
|
sourceOffsets?: [start: number, end: number];
|
|
57
61
|
};
|
|
58
62
|
/** @category MathJSON */
|
|
59
|
-
export type
|
|
63
|
+
export type MathJsonSymbol = string;
|
|
60
64
|
/**
|
|
61
65
|
* A MathJSON numeric quantity.
|
|
62
66
|
*
|
|
@@ -69,7 +73,7 @@ export type MathJsonIdentifier = string;
|
|
|
69
73
|
* - an optional exponent part (a `e` or `E` exponent marker followed by an
|
|
70
74
|
* optional `-` minus sign, followed by a string of digits)
|
|
71
75
|
*
|
|
72
|
-
* It can also consist of the
|
|
76
|
+
* It can also consist of the string `NaN`, `-Infinity` or `+Infinity` to
|
|
73
77
|
* represent these respective values.
|
|
74
78
|
*
|
|
75
79
|
* A MathJSON number may contain more digits or an exponent with a greater
|
|
@@ -82,25 +86,29 @@ export type MathJsonIdentifier = string;
|
|
|
82
86
|
* - `123456789123456789.123(4567)e999`
|
|
83
87
|
* @category MathJSON
|
|
84
88
|
*/
|
|
85
|
-
export type
|
|
89
|
+
export type MathJsonNumberObject = {
|
|
86
90
|
num: 'NaN' | '-Infinity' | '+Infinity' | string;
|
|
87
91
|
} & MathJsonAttributes;
|
|
88
92
|
/** @category MathJSON */
|
|
89
|
-
export type
|
|
90
|
-
sym:
|
|
93
|
+
export type MathJsonSymbolObject = {
|
|
94
|
+
sym: MathJsonSymbol;
|
|
91
95
|
} & MathJsonAttributes;
|
|
92
96
|
/** @category MathJSON */
|
|
93
|
-
export type
|
|
97
|
+
export type MathJsonStringObject = {
|
|
94
98
|
str: string;
|
|
95
99
|
} & MathJsonAttributes;
|
|
96
100
|
/** @category MathJSON */
|
|
97
|
-
export type
|
|
98
|
-
fn: [
|
|
101
|
+
export type MathJsonFunctionObject = {
|
|
102
|
+
fn: [MathJsonSymbol, ...Expression[]];
|
|
103
|
+
} & MathJsonAttributes;
|
|
104
|
+
/** @category MathJSON */
|
|
105
|
+
export type MathJsonDictionaryObject = {
|
|
106
|
+
dict: Record<string, Expression>;
|
|
99
107
|
} & MathJsonAttributes;
|
|
100
108
|
/**
|
|
101
109
|
* @category MathJSON
|
|
102
110
|
*/
|
|
103
|
-
export type ExpressionObject =
|
|
111
|
+
export type ExpressionObject = MathJsonNumberObject | MathJsonStringObject | MathJsonSymbolObject | MathJsonFunctionObject | MathJsonDictionaryObject;
|
|
104
112
|
/**
|
|
105
113
|
* A MathJSON expression is a recursive data structure.
|
|
106
114
|
*
|
|
@@ -109,4 +117,4 @@ export type ExpressionObject = MathJsonNumber | MathJsonString | MathJsonSymbol
|
|
|
109
117
|
*
|
|
110
118
|
* @category MathJSON
|
|
111
119
|
*/
|
|
112
|
-
export type Expression = ExpressionObject | number |
|
|
120
|
+
export type Expression = ExpressionObject | number | MathJsonSymbol | string | readonly [MathJsonSymbol, ...Expression[]];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
export declare const MISSING: Expression;
|
|
3
|
-
export declare function isNumberExpression(expr: Expression | null): expr is number | string |
|
|
4
|
-
export declare function isNumberObject(expr: Expression | null): expr is
|
|
5
|
-
export declare function isSymbolObject(expr: Expression | null): expr is
|
|
6
|
-
export declare function isStringObject(expr: Expression | null): expr is
|
|
7
|
-
export declare function
|
|
3
|
+
export declare function isNumberExpression(expr: Expression | null): expr is number | string | MathJsonNumberObject;
|
|
4
|
+
export declare function isNumberObject(expr: Expression | null): expr is MathJsonNumberObject;
|
|
5
|
+
export declare function isSymbolObject(expr: Expression | null): expr is MathJsonSymbolObject;
|
|
6
|
+
export declare function isStringObject(expr: Expression | null): expr is MathJsonStringObject;
|
|
7
|
+
export declare function isDictionaryObject(expr: Expression | null): expr is MathJsonDictionaryObject;
|
|
8
|
+
export declare function isFunctionObject(expr: Expression | null): expr is MathJsonFunctionObject;
|
|
8
9
|
/** If expr is a string literal, return it.
|
|
9
10
|
*
|
|
10
11
|
* A string literal is a JSON string that begins and ends with
|
|
@@ -13,14 +14,14 @@ export declare function isFunctionObject(expr: Expression | null): expr is MathJ
|
|
|
13
14
|
export declare function stringValue(expr: Expression | null | undefined): string | null;
|
|
14
15
|
export declare function stripText(expr: Expression | null | undefined): Expression | null;
|
|
15
16
|
/**
|
|
16
|
-
* The operator of a function is
|
|
17
|
+
* The operator of a function is symbol.
|
|
17
18
|
*
|
|
18
19
|
* Return an empty string if the expression is not a function.
|
|
19
20
|
*
|
|
20
21
|
* Examples:
|
|
21
22
|
* * `["Negate", 5]` -> `"Negate"`
|
|
22
23
|
*/
|
|
23
|
-
export declare function operator(expr: Expression | null | undefined):
|
|
24
|
+
export declare function operator(expr: Expression | null | undefined): MathJsonSymbol;
|
|
24
25
|
/**
|
|
25
26
|
* Return the arguments of a function, or an empty array if not a function
|
|
26
27
|
* or no arguments.
|
|
@@ -31,7 +32,7 @@ export declare function operand(expr: Expression | null, n: 1 | 2 | 3): Expressi
|
|
|
31
32
|
export declare function nops(expr: Expression | null | undefined): number;
|
|
32
33
|
export declare function unhold(expr: Expression | null): Expression | null;
|
|
33
34
|
export declare function symbol(expr: Expression | null | undefined): string | null;
|
|
34
|
-
export declare function dictionaryFromExpression(expr: Expression | null): null |
|
|
35
|
+
export declare function dictionaryFromExpression(expr: Expression | null): null | MathJsonDictionaryObject;
|
|
35
36
|
export declare function dictionaryFromEntries(dict: Record<string, Expression>): Expression;
|
|
36
37
|
/**
|
|
37
38
|
* CAUTION: `machineValue()` will return a truncated value if the number
|
|
@@ -51,6 +52,9 @@ export declare function machineValue(expr: Expression | null | undefined): numbe
|
|
|
51
52
|
* The denominator is always > 0.
|
|
52
53
|
*/
|
|
53
54
|
export declare function rationalValue(expr: Expression | undefined | null): [number, number] | null;
|
|
55
|
+
/**
|
|
56
|
+
* Apply a substitution to an expression.
|
|
57
|
+
*/
|
|
54
58
|
export declare function subs(expr: Expression, s: {
|
|
55
59
|
[symbol: string]: Expression;
|
|
56
60
|
}): Expression;
|
|
@@ -70,3 +74,8 @@ export declare function isEmptySequence(expr: Expression | null | undefined): ex
|
|
|
70
74
|
export declare function missingIfEmpty(expr: Expression | null | undefined): Expression;
|
|
71
75
|
/** The number of leaves (atomic expressions) in the expression */
|
|
72
76
|
export declare function countLeaves(expr: Expression | null): number;
|
|
77
|
+
/** True if the string matches the expected pattern for a number */
|
|
78
|
+
export declare function matchesNumber(s: string): boolean;
|
|
79
|
+
/** True if the string matches the expected pattern for a symbol */
|
|
80
|
+
export declare function matchesSymbol(s: string): boolean;
|
|
81
|
+
export declare function matchesString(s: string): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.30.1 */
|
|
2
2
|
export { isSymbolObject, isStringObject, isFunctionObject, stringValue, operator, operand, symbol, mapArgs, dictionaryFromExpression, } from './math-json/utils';
|
|
3
|
-
export declare const version = "0.
|
|
3
|
+
export declare const version = "0.30.1";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.30.1",
|
|
3
3
|
"scripts": {
|
|
4
4
|
"doc": "bash ./scripts/doc.sh",
|
|
5
5
|
"build": "bash ./scripts/build.sh",
|
|
@@ -43,13 +43,15 @@
|
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
45
45
|
"types": "./dist/types/compute-engine.d.ts",
|
|
46
|
-
"
|
|
46
|
+
"browser": "./dist/compute-engine.min.umd.js",
|
|
47
47
|
"import": "./dist/compute-engine.min.esm.js",
|
|
48
|
-
"
|
|
48
|
+
"require": "./dist/compute-engine.min.umd.js",
|
|
49
|
+
"default": "./dist/compute-engine.min.esm.js"
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
|
-
"main": "./dist/compute-engine.min.
|
|
52
|
+
"main": "./dist/compute-engine.min.umd.js",
|
|
52
53
|
"module": "./dist/compute-engine.min.esm.js",
|
|
54
|
+
"browser": "./dist/compute-engine.min.umd.js",
|
|
53
55
|
"types": "./dist/types/compute-engine.d.ts",
|
|
54
56
|
"engines": {
|
|
55
57
|
"npm": ">=10.5.0",
|
|
@@ -59,14 +61,14 @@
|
|
|
59
61
|
"@cortex-js/prettier-config": "^1.2.0",
|
|
60
62
|
"@jest/console": "^29.7.0",
|
|
61
63
|
"@types/jest": "^29.5.5",
|
|
62
|
-
"@types/node": "^
|
|
64
|
+
"@types/node": "^24.0.13",
|
|
63
65
|
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
|
64
66
|
"@typescript-eslint/parser": "^7.14.1",
|
|
65
67
|
"@typescript-eslint/typescript-estree": "^7.14.1",
|
|
66
68
|
"chalk": "^5.3.0",
|
|
67
69
|
"check-node-version": "^4.2.1",
|
|
68
70
|
"concat-md": "^0.5.1",
|
|
69
|
-
"esbuild": "^0.
|
|
71
|
+
"esbuild": "^0.25.6",
|
|
70
72
|
"eslint": "^8.56.0",
|
|
71
73
|
"eslint-config-prettier": "^9.0.0",
|
|
72
74
|
"eslint-plugin-import": "^2.28.1",
|
|
@@ -74,21 +76,21 @@
|
|
|
74
76
|
"eslint-plugin-prettier": "^5.0.0",
|
|
75
77
|
"jest": "^29.7.0",
|
|
76
78
|
"jest-silent-reporter": "^0.6.0",
|
|
77
|
-
"open": "^10.1.
|
|
78
|
-
"prettier": "^3.
|
|
79
|
+
"open": "^10.1.2",
|
|
80
|
+
"prettier": "^3.6.2",
|
|
79
81
|
"prettier-2": "npm:prettier@^2",
|
|
80
82
|
"serve-http": "^1.0.7",
|
|
81
|
-
"ts-jest": "^29.
|
|
83
|
+
"ts-jest": "^29.4.0",
|
|
82
84
|
"ts-node": "^10.9.1",
|
|
83
85
|
"typedoc": "^0.27.6",
|
|
84
86
|
"typedoc-plugin-markdown": "^4.4.1",
|
|
85
87
|
"typedoc-plugin-no-inherit": "^1.5.0",
|
|
86
|
-
"typescript": "^5.
|
|
88
|
+
"typescript": "^5.8.3",
|
|
87
89
|
"update-notifier": "^7.0.0"
|
|
88
90
|
},
|
|
89
91
|
"prettier": "@cortex-js/prettier-config",
|
|
90
92
|
"dependencies": {
|
|
91
93
|
"complex-esm": "^2.1.1-esm1",
|
|
92
|
-
"decimal.js": "^10.
|
|
94
|
+
"decimal.js": "^10.6.0"
|
|
93
95
|
}
|
|
94
96
|
}
|