@cortex-js/compute-engine 0.35.6 → 0.50.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/README.md +121 -5
- package/dist/compute-engine.esm.js +50435 -44944
- package/dist/compute-engine.min.esm.js +1072 -69
- package/dist/compute-engine.min.umd.js +1072 -69
- package/dist/compute-engine.umd.js +50540 -45049
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- 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/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +8 -1
- package/dist/types/common/type/primitive.d.ts +2 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- 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/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +3 -2
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +4 -22
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +63 -76
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -6
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +72 -6
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +5 -8
- package/dist/types/compute-engine/boxed-expression/box.d.ts +63 -8
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +13 -12
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +44 -43
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +31 -30
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +18 -18
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +5 -37
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +5 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +34 -33
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +34 -33
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +6 -0
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +4 -5
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +9 -9
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +4 -13
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +4 -0
- package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/order.d.ts +14 -14
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +41 -0
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +18 -0
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +12 -35
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +51 -51
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +8 -8
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +3 -11
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +31 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +13 -13
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -10
- package/dist/types/compute-engine/collection-utils.d.ts +4 -4
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +3 -3
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +25 -0
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +12 -41
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +50 -0
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +11 -11
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +7 -7
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +54 -0
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +6 -6
- package/dist/types/compute-engine/compilation/python-target.d.ts +61 -0
- package/dist/types/compute-engine/compilation/types.d.ts +27 -22
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +41 -0
- package/dist/types/compute-engine/cost-function.d.ts +3 -3
- package/dist/types/compute-engine/engine-assumptions.d.ts +6 -0
- package/dist/types/compute-engine/engine-cache.d.ts +6 -0
- package/dist/types/compute-engine/engine-common-symbols.d.ts +6 -0
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +17 -0
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +15 -0
- package/dist/types/compute-engine/engine-declarations.d.ts +19 -0
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +44 -0
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +9 -0
- package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +13 -0
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +6 -0
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +34 -0
- package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +7 -0
- package/dist/types/compute-engine/engine-runtime-state.d.ts +19 -0
- package/dist/types/compute-engine/engine-scope.d.ts +13 -0
- package/dist/types/compute-engine/engine-sequences.d.ts +14 -0
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +15 -0
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +28 -0
- package/dist/types/compute-engine/engine-type-resolver.d.ts +12 -0
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +13 -0
- package/dist/types/compute-engine/free-functions.d.ts +20 -0
- package/dist/types/compute-engine/function-utils.d.ts +10 -10
- package/dist/types/compute-engine/global-types.d.ts +5 -3301
- package/dist/types/compute-engine/index.d.ts +155 -112
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- 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 +4 -80
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +83 -0
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +28 -0
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +23 -33
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +8 -8
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +15 -15
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +73 -53
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -2
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +4 -4
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +19 -6
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +19 -32
- package/dist/types/compute-engine/library/logic.d.ts +1 -5
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +2 -2
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/type-handlers.d.ts +4 -0
- package/dist/types/compute-engine/library/utils.d.ts +12 -12
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +5 -5
- package/dist/types/compute-engine/numeric-value/types.d.ts +2 -3
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +3 -3
- package/dist/types/compute-engine/numerics/interval.d.ts +2 -2
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +4 -4
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +120 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -2
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +3 -1
- package/dist/types/compute-engine/oeis.d.ts +3 -3
- package/dist/types/compute-engine/sequence.d.ts +13 -13
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/derivative.d.ts +3 -3
- package/dist/types/compute-engine/symbolic/distribute.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +6 -6
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +46 -46
- package/dist/types/compute-engine/symbolic/fu.d.ts +4 -4
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +54 -0
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +4 -4
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +5 -0
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +65 -4
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +2 -2
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +42 -42
- package/dist/types/compute-engine/tensor/tensors.d.ts +4 -4
- package/dist/types/compute-engine/types-definitions.d.ts +900 -0
- package/dist/types/compute-engine/types-engine.d.ts +375 -0
- package/dist/types/compute-engine/types-evaluation.d.ts +67 -0
- package/dist/types/compute-engine/types-expression.d.ts +1655 -0
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +164 -0
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +147 -0
- package/dist/types/compute-engine/types-serialization.d.ts +23 -0
- package/dist/types/compute-engine/types.d.ts +2 -2
- package/dist/types/compute-engine.d.ts +16 -3
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +3 -3
- package/dist/types/math-json/utils.d.ts +31 -31
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +8 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
- package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
- package/dist/types/compute-engine/library/logic-utils.d.ts +0 -54
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import type { Rational } from '../numerics/types';
|
|
3
|
-
export declare function asRadical(expr:
|
|
3
|
+
export declare function asRadical(expr: Expression): Rational | null;
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* Produce the canonical form of the operands of a Power expression, returning either the operation
|
|
@@ -19,8 +19,8 @@ export declare function asRadical(expr: BoxedExpression): Rational | null;
|
|
|
19
19
|
* @param b
|
|
20
20
|
* @returns
|
|
21
21
|
*/
|
|
22
|
-
export declare function canonicalPower(a:
|
|
23
|
-
export declare function canonicalRoot(a:
|
|
22
|
+
export declare function canonicalPower(a: Expression, b: Expression): Expression;
|
|
23
|
+
export declare function canonicalRoot(a: Expression, b: Expression | number): Expression;
|
|
24
24
|
/**
|
|
25
25
|
* The power function.
|
|
26
26
|
*
|
|
@@ -30,9 +30,9 @@ export declare function canonicalRoot(a: BoxedExpression, b: BoxedExpression | n
|
|
|
30
30
|
* See https://docs.sympy.org/latest/modules/core.html#sympy.core.power.Pow
|
|
31
31
|
*
|
|
32
32
|
*/
|
|
33
|
-
export declare function pow(x:
|
|
33
|
+
export declare function pow(x: Expression, exp: number | Expression, { numericApproximation }: {
|
|
34
34
|
numericApproximation: boolean;
|
|
35
|
-
}):
|
|
36
|
-
export declare function root(a:
|
|
35
|
+
}): Expression;
|
|
36
|
+
export declare function root(a: Expression, b: Expression, { numericApproximation }: {
|
|
37
37
|
numericApproximation: boolean;
|
|
38
|
-
}):
|
|
38
|
+
}): Expression;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
export type AsciiMathSerializer = (expr:
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
export type AsciiMathSerializer = (expr: Expression, precedence?: number) => string;
|
|
3
3
|
export type AsciiMathOptions = {
|
|
4
4
|
symbols: Record<string, string>;
|
|
5
|
-
operators: Record<string, [
|
|
6
|
-
|
|
7
|
-
number
|
|
8
|
-
]>;
|
|
9
|
-
functions: Record<string, string | ((expr: BoxedExpression, serialize: AsciiMathSerializer) => string)>;
|
|
5
|
+
operators: Record<string, [string | ((expr: Expression) => string), number]>;
|
|
6
|
+
functions: Record<string, string | ((expr: Expression, serialize: AsciiMathSerializer) => string)>;
|
|
10
7
|
};
|
|
11
|
-
export declare function toAsciiMath(expr:
|
|
8
|
+
export declare function toAsciiMath(expr: Expression, options?: Partial<AsciiMathOptions>, precedence?: number): string;
|
|
@@ -1,6 +1,61 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { FormOption } from '../types-serialization';
|
|
3
|
+
import type { MathJsonSymbol } from '../../math-json/types';
|
|
3
4
|
import { NumericValue } from '../numeric-value/types';
|
|
5
|
+
/**
|
|
6
|
+
* ### THEORY OF OPERATIONS
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* 1/ The result of boxing is canonical by default.
|
|
10
|
+
*
|
|
11
|
+
* This is the most common need (i.e. to evaluate an expression you need it
|
|
12
|
+
* in canonical form). Creating a boxed expression which is canonical from the
|
|
13
|
+
* start avoid going through an intermediary step with a non-canonical
|
|
14
|
+
* expression.
|
|
15
|
+
*
|
|
16
|
+
* 2/ When boxing (and canonicalizing), if the function is "scoped", a new
|
|
17
|
+
* scope is created before the canonicalization, so that any declaration
|
|
18
|
+
* are done within that scope. Example of scoped functions include `Block`
|
|
19
|
+
* and `Sum`.
|
|
20
|
+
*
|
|
21
|
+
* 3/ When implementing an `evaluate()`:
|
|
22
|
+
* - if `bignumPreferred()` all operations should be done in bignum,
|
|
23
|
+
* otherwise, they should all be done in machine numbers.
|
|
24
|
+
* - if a rational is encountered, preserve it
|
|
25
|
+
* - if a `Sqrt` of a rational is encountered, preserve it
|
|
26
|
+
* - if a `hold` constant is encountered, preserve it
|
|
27
|
+
* - if `numericApproximation` is false and one of the arguments is not exact,
|
|
28
|
+
* return an approximation
|
|
29
|
+
* - if `numericApproximation` is true, always return an approximation
|
|
30
|
+
*
|
|
31
|
+
* NUMERIC APPROXIMATION = FALSE
|
|
32
|
+
* - 2 + 5 -> 7
|
|
33
|
+
* - 2 + 5/7 -> 19/7
|
|
34
|
+
* - 2 + √2 -> 2 + √2
|
|
35
|
+
* - 2 + √(5/7) -> 2 + √(5/7)
|
|
36
|
+
* - 5/7 + 9/11 -> 118/77
|
|
37
|
+
* - 5/7 + √2 -> 5/7 + √2
|
|
38
|
+
* - 10/14 + √(18/9) -> 5/7 + √2
|
|
39
|
+
* - √2 + √5 -> √2 + √5
|
|
40
|
+
* - √2 + √2 -> 2√2
|
|
41
|
+
* - sin(2) -> sin(2)
|
|
42
|
+
* - sin(pi/3) -> √3/2
|
|
43
|
+
* - 2 + 2.1 -> 2 + 2.1
|
|
44
|
+
*
|
|
45
|
+
* NUMERIC APPROXIMATION = TRUE
|
|
46
|
+
* - 2 + 2.1 -> 4.1
|
|
47
|
+
* - 2 + √2.1 -> 3.44914
|
|
48
|
+
* - 5/7 + √2.1 -> 2.16342
|
|
49
|
+
* - sin(2) + √2.1 -> 2.35844
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Translate a public `FormOption` to the internal
|
|
53
|
+
* `{ canonical, structural }` representation.
|
|
54
|
+
*/
|
|
55
|
+
export declare function formToInternal(form?: FormOption): {
|
|
56
|
+
canonical: CanonicalOptions;
|
|
57
|
+
structural: boolean;
|
|
58
|
+
};
|
|
4
59
|
/**
|
|
5
60
|
* Given a name and a set of arguments, return a boxed function expression.
|
|
6
61
|
*
|
|
@@ -8,16 +63,16 @@ import { NumericValue } from '../numeric-value/types';
|
|
|
8
63
|
*
|
|
9
64
|
* Note that `boxFunction()` should only be called from `ce.function()`
|
|
10
65
|
*/
|
|
11
|
-
export declare function boxFunction(ce: ComputeEngine, name: MathJsonSymbol, ops: readonly
|
|
66
|
+
export declare function boxFunction(ce: ComputeEngine, name: MathJsonSymbol, ops: readonly ExpressionInput[], options?: {
|
|
12
67
|
metadata?: Metadata;
|
|
13
68
|
canonical?: CanonicalOptions;
|
|
14
69
|
structural?: boolean;
|
|
15
70
|
scope?: Scope;
|
|
16
|
-
}):
|
|
71
|
+
}): Expression;
|
|
17
72
|
/**
|
|
18
73
|
* Notes about the boxed form:
|
|
19
74
|
*
|
|
20
|
-
* [1]
|
|
75
|
+
* [1] MathJsonExpression with an operator of `Number`, `String`, `Symbol` and `Dictionary`
|
|
21
76
|
* are converted to the corresponding atomic expression.
|
|
22
77
|
*
|
|
23
78
|
* [2] Expressions with an operator of `Complex` are converted to a (complex) number
|
|
@@ -39,9 +94,9 @@ export declare function boxFunction(ce: ComputeEngine, name: MathJsonSymbol, ops
|
|
|
39
94
|
* Note that this function should only be called from `ce.box()`
|
|
40
95
|
*
|
|
41
96
|
*/
|
|
42
|
-
export declare function box(ce: ComputeEngine, expr: null | undefined | NumericValue |
|
|
97
|
+
export declare function box(ce: ComputeEngine, expr: null | undefined | NumericValue | ExpressionInput, options?: {
|
|
43
98
|
canonical?: CanonicalOptions;
|
|
44
99
|
structural?: boolean;
|
|
45
100
|
scope?: Scope;
|
|
46
|
-
}):
|
|
47
|
-
export declare function semiCanonical(ce: ComputeEngine, xs: ReadonlyArray<
|
|
101
|
+
}): Expression;
|
|
102
|
+
export declare function semiCanonical(ce: ComputeEngine, xs: ReadonlyArray<ExpressionInput>, scope?: Scope): ReadonlyArray<Expression>;
|
|
@@ -1,44 +1,45 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
4
|
-
import { DictionaryValue,
|
|
4
|
+
import { DictionaryValue, MathJsonExpression } from '../../math-json/types';
|
|
5
5
|
/**
|
|
6
6
|
* BoxedDictionary
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
export declare class BoxedDictionary extends _BoxedExpression implements DictionaryInterface {
|
|
10
|
+
readonly _kind = "dictionary";
|
|
10
11
|
[Symbol.toStringTag]: string;
|
|
11
12
|
private readonly _keyValues;
|
|
12
13
|
private _type;
|
|
13
14
|
/** The input to the constructor is either a ["Dictionary", ["KeyValuePair", ..., ...], ...] expression or a record of key-value pairs */
|
|
14
|
-
constructor(ce: ComputeEngine, keyValues: Record<string, DictionaryValue> |
|
|
15
|
+
constructor(ce: ComputeEngine, keyValues: Record<string, DictionaryValue> | Expression, options?: {
|
|
15
16
|
metadata?: Metadata;
|
|
16
17
|
canonical?: boolean;
|
|
17
18
|
});
|
|
18
19
|
private _initFromRecord;
|
|
19
20
|
private _initFromExpression;
|
|
20
|
-
get json():
|
|
21
|
-
toMathJson(options: Readonly<JsonSerializationOptions>):
|
|
21
|
+
get json(): MathJsonExpression;
|
|
22
|
+
toMathJson(options: Readonly<JsonSerializationOptions>): MathJsonExpression;
|
|
22
23
|
get hash(): number;
|
|
23
24
|
get operator(): string;
|
|
24
25
|
get type(): BoxedType;
|
|
25
26
|
get isPure(): boolean;
|
|
26
27
|
get isCanonical(): boolean;
|
|
27
28
|
set isCanonical(_va: boolean);
|
|
28
|
-
get value():
|
|
29
|
+
get value(): Expression | undefined;
|
|
29
30
|
get complexity(): number;
|
|
30
31
|
get isCollection(): boolean;
|
|
31
32
|
get isIndexedCollection(): boolean;
|
|
32
33
|
get isLazyCollection(): boolean;
|
|
33
|
-
contains(_rhs:
|
|
34
|
+
contains(_rhs: Expression): boolean | undefined;
|
|
34
35
|
get count(): number | undefined;
|
|
35
36
|
get isEmptyCollection(): boolean;
|
|
36
37
|
get isFiniteCollection(): boolean;
|
|
37
|
-
each(): Generator<
|
|
38
|
-
get(key: string):
|
|
38
|
+
each(): Generator<Expression>;
|
|
39
|
+
get(key: string): Expression | undefined;
|
|
39
40
|
has(key: string): boolean;
|
|
40
41
|
get keys(): string[];
|
|
41
|
-
get entries(): [string,
|
|
42
|
-
get values():
|
|
43
|
-
match(pattern:
|
|
42
|
+
get entries(): [string, Expression][];
|
|
43
|
+
get values(): Expression[];
|
|
44
|
+
match(pattern: Expression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
44
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import type { SimplifyOptions, ReplaceOptions, PatternMatchOptions,
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { SimplifyOptions, ReplaceOptions, PatternMatchOptions, Expression, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, IComputeEngine as ComputeEngine, Metadata, Rule, Sign, Substitution, Scope, BoxedValueDefinition, FunctionInterface } from '../global-types';
|
|
3
3
|
import { Type } from '../../common/type/types';
|
|
4
4
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
5
5
|
import { NumericValue } from '../numeric-value/types';
|
|
@@ -15,7 +15,8 @@ import { _BoxedExpression } from './abstract-boxed-expression';
|
|
|
15
15
|
* The definition contains its signature and its evaluation handler.
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export declare class BoxedFunction extends _BoxedExpression {
|
|
18
|
+
export declare class BoxedFunction extends _BoxedExpression implements FunctionInterface {
|
|
19
|
+
readonly _kind = "function";
|
|
19
20
|
private readonly _operator;
|
|
20
21
|
private readonly _ops;
|
|
21
22
|
private _def;
|
|
@@ -33,7 +34,7 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
33
34
|
private _valueN;
|
|
34
35
|
private _sgn;
|
|
35
36
|
private _type;
|
|
36
|
-
constructor(ce: ComputeEngine, operator: string, ops: ReadonlyArray<
|
|
37
|
+
constructor(ce: ComputeEngine, operator: string, ops: ReadonlyArray<Expression>, options?: {
|
|
37
38
|
metadata?: Metadata;
|
|
38
39
|
canonical?: boolean;
|
|
39
40
|
structural?: boolean;
|
|
@@ -47,28 +48,28 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
47
48
|
infer(t: Type, inferenceMode?: 'narrow' | 'widen'): boolean;
|
|
48
49
|
bind(): void;
|
|
49
50
|
reset(): void;
|
|
50
|
-
get value():
|
|
51
|
+
get value(): Expression | undefined;
|
|
51
52
|
get isCanonical(): boolean;
|
|
52
53
|
get isPure(): boolean;
|
|
53
54
|
get isConstant(): boolean;
|
|
54
55
|
get constantValue(): number | boolean | string | object | undefined;
|
|
55
|
-
get json():
|
|
56
|
+
get json(): MathJsonExpression;
|
|
56
57
|
get operator(): string;
|
|
57
|
-
get ops(): ReadonlyArray<
|
|
58
|
+
get ops(): ReadonlyArray<Expression>;
|
|
58
59
|
get nops(): number;
|
|
59
|
-
get op1():
|
|
60
|
-
get op2():
|
|
61
|
-
get op3():
|
|
60
|
+
get op1(): Expression;
|
|
61
|
+
get op2(): Expression;
|
|
62
|
+
get op3(): Expression;
|
|
62
63
|
get isScoped(): boolean;
|
|
63
64
|
get localScope(): Scope | undefined;
|
|
64
65
|
get isValid(): boolean;
|
|
65
66
|
/** Note: if the expression is not canonical, this will return a canonical
|
|
66
67
|
* version of the expression in the current lexical scope.
|
|
67
68
|
*/
|
|
68
|
-
get canonical():
|
|
69
|
-
get structural():
|
|
69
|
+
get canonical(): Expression;
|
|
70
|
+
get structural(): Expression;
|
|
70
71
|
get isStructural(): boolean;
|
|
71
|
-
toNumericValue(): [NumericValue,
|
|
72
|
+
toNumericValue(): [NumericValue, Expression];
|
|
72
73
|
/**
|
|
73
74
|
* Note: the result is bound to the current scope, not the scope of the
|
|
74
75
|
* original expression.
|
|
@@ -76,9 +77,9 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
76
77
|
*/
|
|
77
78
|
subs(sub: Substitution, options?: {
|
|
78
79
|
canonical?: CanonicalOptions;
|
|
79
|
-
}):
|
|
80
|
-
replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>):
|
|
81
|
-
match(pattern:
|
|
80
|
+
}): Expression;
|
|
81
|
+
replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): Expression | null;
|
|
82
|
+
match(pattern: Expression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
82
83
|
has(v: string | string[]): boolean;
|
|
83
84
|
get sgn(): Sign | undefined;
|
|
84
85
|
get isNaN(): boolean | undefined;
|
|
@@ -90,19 +91,19 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
90
91
|
get isNonNegative(): boolean | undefined;
|
|
91
92
|
get isNegative(): boolean | undefined;
|
|
92
93
|
get isNonPositive(): boolean | undefined;
|
|
93
|
-
get numerator():
|
|
94
|
-
get denominator():
|
|
95
|
-
get numeratorDenominator(): [
|
|
96
|
-
neg():
|
|
97
|
-
inv():
|
|
98
|
-
abs():
|
|
99
|
-
add(rhs: number |
|
|
100
|
-
mul(rhs: NumericValue | number |
|
|
101
|
-
div(rhs: number |
|
|
102
|
-
pow(exp: number |
|
|
103
|
-
root(exp: number |
|
|
104
|
-
sqrt():
|
|
105
|
-
ln(semiBase?: number |
|
|
94
|
+
get numerator(): Expression;
|
|
95
|
+
get denominator(): Expression;
|
|
96
|
+
get numeratorDenominator(): [Expression, Expression];
|
|
97
|
+
neg(): Expression;
|
|
98
|
+
inv(): Expression;
|
|
99
|
+
abs(): Expression;
|
|
100
|
+
add(rhs: number | Expression): Expression;
|
|
101
|
+
mul(rhs: NumericValue | number | Expression): Expression;
|
|
102
|
+
div(rhs: number | Expression): Expression;
|
|
103
|
+
pow(exp: number | Expression): Expression;
|
|
104
|
+
root(exp: number | Expression): Expression;
|
|
105
|
+
sqrt(): Expression;
|
|
106
|
+
ln(semiBase?: number | Expression): Expression;
|
|
106
107
|
get complexity(): number | undefined;
|
|
107
108
|
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
108
109
|
get operatorDefinition(): BoxedOperatorDefinition | undefined;
|
|
@@ -111,30 +112,30 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
111
112
|
get isInteger(): boolean | undefined;
|
|
112
113
|
get isRational(): boolean | undefined;
|
|
113
114
|
get isReal(): boolean | undefined;
|
|
114
|
-
get isFunctionExpression():
|
|
115
|
+
get isFunctionExpression(): true;
|
|
115
116
|
/** The type of the value of the function */
|
|
116
117
|
get type(): BoxedType;
|
|
117
118
|
/** The shape of the tensor (dimensions), derived from the type */
|
|
118
119
|
get shape(): number[];
|
|
119
120
|
/** The rank of the tensor (number of dimensions), derived from the type */
|
|
120
121
|
get rank(): number;
|
|
121
|
-
simplify(options?: Partial<SimplifyOptions>):
|
|
122
|
-
evaluate(options?: Partial<EvaluateOptions>):
|
|
123
|
-
evaluateAsync(options?: Partial<EvaluateOptions>): Promise<
|
|
124
|
-
N():
|
|
125
|
-
solve(vars?: Iterable<string> | string |
|
|
122
|
+
simplify(options?: Partial<SimplifyOptions>): Expression;
|
|
123
|
+
evaluate(options?: Partial<EvaluateOptions>): Expression;
|
|
124
|
+
evaluateAsync(options?: Partial<EvaluateOptions>): Promise<Expression>;
|
|
125
|
+
N(): Expression;
|
|
126
|
+
solve(vars?: Iterable<string> | string | Expression | Iterable<Expression>): null | ReadonlyArray<Expression> | Record<string, Expression> | Array<Record<string, Expression>>;
|
|
126
127
|
get isCollection(): boolean;
|
|
127
128
|
get isIndexedCollection(): boolean;
|
|
128
129
|
get isLazyCollection(): boolean;
|
|
129
|
-
contains(rhs:
|
|
130
|
+
contains(rhs: Expression): boolean | undefined;
|
|
130
131
|
get count(): number | undefined;
|
|
131
132
|
get isEmptyCollection(): boolean | undefined;
|
|
132
133
|
get isFiniteCollection(): boolean | undefined;
|
|
133
|
-
each(): Generator<
|
|
134
|
-
at(index: number):
|
|
135
|
-
get(index:
|
|
136
|
-
indexWhere(predicate: (element:
|
|
137
|
-
subsetOf(rhs:
|
|
138
|
-
_computeValue(options?: Partial<EvaluateOptions>): () =>
|
|
139
|
-
_computeValueAsync(options?: Partial<EvaluateOptions>): () => Promise<
|
|
134
|
+
each(): Generator<Expression>;
|
|
135
|
+
at(index: number): Expression | undefined;
|
|
136
|
+
get(index: Expression | string): Expression | undefined;
|
|
137
|
+
indexWhere(predicate: (element: Expression) => boolean): number | undefined;
|
|
138
|
+
subsetOf(rhs: Expression, strict: boolean): boolean;
|
|
139
|
+
_computeValue(options?: Partial<EvaluateOptions>): () => Expression;
|
|
140
|
+
_computeValueAsync(options?: Partial<EvaluateOptions>): () => Promise<Expression>;
|
|
140
141
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MathJsonExpression, MathJsonNumberObject } from '../../math-json';
|
|
4
4
|
import type { Rational, SmallInteger } from '../numerics/types';
|
|
5
5
|
import { ExactNumericValueData, NumericValue, NumericValueData } from '../numeric-value/types';
|
|
6
6
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
7
7
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
8
|
-
import type { BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution,
|
|
8
|
+
import type { BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, IComputeEngine as ComputeEngine, Metadata, Rule, Sign, Substitution, Expression, PatternMatchOptions, ReplaceOptions, SimplifyOptions, NumberLiteralInterface } from '../global-types';
|
|
9
9
|
/**
|
|
10
10
|
* BoxedNumber
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
export declare class BoxedNumber extends _BoxedExpression {
|
|
13
|
+
export declare class BoxedNumber extends _BoxedExpression implements NumberLiteralInterface {
|
|
14
|
+
readonly _kind = "number";
|
|
14
15
|
protected readonly _value: SmallInteger | NumericValue;
|
|
15
16
|
private _hash;
|
|
16
17
|
/**
|
|
@@ -29,7 +30,7 @@ export declare class BoxedNumber extends _BoxedExpression {
|
|
|
29
30
|
metadata?: Metadata;
|
|
30
31
|
});
|
|
31
32
|
get hash(): number;
|
|
32
|
-
get json():
|
|
33
|
+
get json(): MathJsonExpression;
|
|
33
34
|
get operator(): string;
|
|
34
35
|
get isPure(): boolean;
|
|
35
36
|
get isCanonical(): boolean;
|
|
@@ -48,32 +49,32 @@ export declare class BoxedNumber extends _BoxedExpression {
|
|
|
48
49
|
*/
|
|
49
50
|
valueOf(): number | string;
|
|
50
51
|
get numericValue(): number | NumericValue;
|
|
51
|
-
get isNumberLiteral():
|
|
52
|
+
get isNumberLiteral(): true;
|
|
52
53
|
get re(): number;
|
|
53
54
|
get im(): number;
|
|
54
55
|
get bignumRe(): Decimal | undefined;
|
|
55
56
|
get bignumIm(): Decimal | undefined;
|
|
56
|
-
neg():
|
|
57
|
-
inv():
|
|
58
|
-
abs():
|
|
59
|
-
add(rhs: number |
|
|
60
|
-
mul(rhs: NumericValue | number |
|
|
61
|
-
div(rhs: number |
|
|
62
|
-
pow(exp: number |
|
|
63
|
-
root(exp: number |
|
|
64
|
-
sqrt():
|
|
65
|
-
ln(semiBase?: number |
|
|
66
|
-
get value():
|
|
57
|
+
neg(): Expression;
|
|
58
|
+
inv(): Expression;
|
|
59
|
+
abs(): Expression;
|
|
60
|
+
add(rhs: number | Expression): Expression;
|
|
61
|
+
mul(rhs: NumericValue | number | Expression): Expression;
|
|
62
|
+
div(rhs: number | Expression): Expression;
|
|
63
|
+
pow(exp: number | Expression): Expression;
|
|
64
|
+
root(exp: number | Expression): Expression;
|
|
65
|
+
sqrt(): Expression;
|
|
66
|
+
ln(semiBase?: number | Expression): Expression;
|
|
67
|
+
get value(): Expression;
|
|
67
68
|
get type(): BoxedType;
|
|
68
69
|
get sgn(): Sign | undefined;
|
|
69
|
-
get numerator():
|
|
70
|
-
get denominator():
|
|
71
|
-
get numeratorDenominator(): [
|
|
70
|
+
get numerator(): Expression;
|
|
71
|
+
get denominator(): Expression;
|
|
72
|
+
get numeratorDenominator(): [Expression, Expression];
|
|
72
73
|
subs(sub: Substitution, options?: {
|
|
73
74
|
canonical?: CanonicalOptions;
|
|
74
|
-
}):
|
|
75
|
-
replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>):
|
|
76
|
-
match(pattern:
|
|
75
|
+
}): Expression;
|
|
76
|
+
replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): Expression | null;
|
|
77
|
+
match(pattern: Expression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
77
78
|
/** x > 0, same as `isGreater(0)` */
|
|
78
79
|
get isPositive(): boolean | undefined;
|
|
79
80
|
/** x >= 0, same as `isGreaterEqual(0)` */
|
|
@@ -91,13 +92,13 @@ export declare class BoxedNumber extends _BoxedExpression {
|
|
|
91
92
|
get isInteger(): boolean;
|
|
92
93
|
get isRational(): boolean;
|
|
93
94
|
get isReal(): boolean;
|
|
94
|
-
is(other:
|
|
95
|
-
get canonical():
|
|
95
|
+
is(other: Expression | number | bigint | boolean): boolean;
|
|
96
|
+
get canonical(): Expression;
|
|
96
97
|
get isStructural(): boolean;
|
|
97
|
-
get structural():
|
|
98
|
-
toNumericValue(): [NumericValue,
|
|
99
|
-
simplify(options?: Partial<SimplifyOptions>):
|
|
100
|
-
evaluate(options?: Partial<EvaluateOptions>):
|
|
101
|
-
N():
|
|
98
|
+
get structural(): Expression;
|
|
99
|
+
toNumericValue(): [NumericValue, Expression];
|
|
100
|
+
simplify(options?: Partial<SimplifyOptions>): Expression;
|
|
101
|
+
evaluate(options?: Partial<EvaluateOptions>): Expression;
|
|
102
|
+
N(): Expression;
|
|
102
103
|
}
|
|
103
104
|
export declare function canonicalNumber(ce: ComputeEngine, value: number | bigint | string | Decimal | Complex | Rational | NumericValue | MathJsonNumberObject): number | NumericValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
3
|
-
import type { OperatorDefinition,
|
|
3
|
+
import type { OperatorDefinition, Expression, BoxedOperatorDefinition, CollectionHandlers, CompiledExpression, EvaluateOptions, IComputeEngine as ComputeEngine, Sign } from '../global-types';
|
|
4
4
|
export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition {
|
|
5
5
|
engine: ComputeEngine;
|
|
6
6
|
name: string;
|
|
@@ -10,7 +10,7 @@ export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition
|
|
|
10
10
|
broadcastable: boolean;
|
|
11
11
|
associative: boolean;
|
|
12
12
|
commutative: boolean;
|
|
13
|
-
commutativeOrder: ((a:
|
|
13
|
+
commutativeOrder: ((a: Expression, b: Expression) => number) | undefined;
|
|
14
14
|
idempotent: boolean;
|
|
15
15
|
involution: boolean;
|
|
16
16
|
pure: boolean;
|
|
@@ -19,34 +19,34 @@ export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition
|
|
|
19
19
|
scoped: boolean;
|
|
20
20
|
signature: BoxedType;
|
|
21
21
|
inferredSignature: boolean;
|
|
22
|
-
type?: (ops: ReadonlyArray<
|
|
22
|
+
type?: (ops: ReadonlyArray<Expression>, options: {
|
|
23
23
|
engine: ComputeEngine;
|
|
24
24
|
}) => BoxedType | Type | TypeString | undefined;
|
|
25
|
-
sgn?: (ops: ReadonlyArray<
|
|
25
|
+
sgn?: (ops: ReadonlyArray<Expression>, options: {
|
|
26
26
|
engine: ComputeEngine;
|
|
27
27
|
}) => Sign | undefined;
|
|
28
|
-
eq?: (a:
|
|
29
|
-
neq?: (a:
|
|
30
|
-
even?: (ops: ReadonlyArray<
|
|
28
|
+
eq?: (a: Expression, b: Expression) => boolean | undefined;
|
|
29
|
+
neq?: (a: Expression, b: Expression) => boolean | undefined;
|
|
30
|
+
even?: (ops: ReadonlyArray<Expression>, options: {
|
|
31
31
|
engine: ComputeEngine;
|
|
32
32
|
}) => boolean | undefined;
|
|
33
|
-
canonical?: (ops: ReadonlyArray<
|
|
33
|
+
canonical?: (ops: ReadonlyArray<Expression>, options: {
|
|
34
34
|
engine: ComputeEngine;
|
|
35
|
-
}) =>
|
|
36
|
-
evaluate?: (ops: ReadonlyArray<
|
|
35
|
+
}) => Expression | null;
|
|
36
|
+
evaluate?: (ops: ReadonlyArray<Expression>, options: Partial<EvaluateOptions> & {
|
|
37
37
|
engine: ComputeEngine;
|
|
38
|
-
}) =>
|
|
39
|
-
evaluateAsync?: (ops: ReadonlyArray<
|
|
38
|
+
}) => Expression | undefined;
|
|
39
|
+
evaluateAsync?: (ops: ReadonlyArray<Expression>, options?: Partial<EvaluateOptions> & {
|
|
40
40
|
engine?: ComputeEngine;
|
|
41
|
-
}) => Promise<
|
|
42
|
-
evalDimension?: (ops: ReadonlyArray<
|
|
41
|
+
}) => Promise<Expression | undefined>;
|
|
42
|
+
evalDimension?: (ops: ReadonlyArray<Expression>, options: {
|
|
43
43
|
engine: ComputeEngine;
|
|
44
|
-
}) =>
|
|
45
|
-
compile?: (expr:
|
|
44
|
+
}) => Expression;
|
|
45
|
+
compile?: (expr: Expression) => CompiledExpression;
|
|
46
46
|
collection?: CollectionHandlers;
|
|
47
47
|
constructor(ce: ComputeEngine, name: string, def: OperatorDefinition);
|
|
48
48
|
/** For debugging */
|
|
49
|
-
toJSON():
|
|
49
|
+
toJSON(): Record<string, unknown>;
|
|
50
50
|
infer(sig: Type): void;
|
|
51
51
|
update(def: OperatorDefinition): void;
|
|
52
52
|
onConfigurationChange(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
* # Pattern Matching Wildcards
|
|
3
3
|
*
|
|
4
4
|
* Patterns can contain wildcards that match parts of expressions. There are
|
|
@@ -53,41 +53,9 @@
|
|
|
53
53
|
*
|
|
54
54
|
* @module boxed-patterns
|
|
55
55
|
*/
|
|
56
|
-
import type {
|
|
57
|
-
import
|
|
58
|
-
|
|
59
|
-
* Check if an expression is a wildcard (universal, sequence, or optional sequence).
|
|
60
|
-
*
|
|
61
|
-
* @param expr - The expression to check
|
|
62
|
-
* @returns `true` if the expression is any type of wildcard
|
|
63
|
-
*/
|
|
64
|
-
export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
|
|
65
|
-
/**
|
|
66
|
-
* Get the string representation of a wildcard expression.
|
|
67
|
-
*
|
|
68
|
-
* Returns the wildcard symbol including its name (if any):
|
|
69
|
-
* - `'_'` for anonymous universal wildcard
|
|
70
|
-
* - `'_a'` for named universal wildcard
|
|
71
|
-
* - `'__'` for anonymous sequence wildcard
|
|
72
|
-
* - `'__args'` for named sequence wildcard
|
|
73
|
-
* - `'___'` for anonymous optional sequence wildcard
|
|
74
|
-
* - `'___rest'` for named optional sequence wildcard
|
|
75
|
-
*
|
|
76
|
-
* @param expr - The expression to get the wildcard name from
|
|
77
|
-
* @returns The wildcard string, or `null` if not a wildcard
|
|
78
|
-
*/
|
|
79
|
-
export declare function wildcardName(expr: BoxedExpression): string | null;
|
|
80
|
-
/**
|
|
81
|
-
* Determine the type of wildcard.
|
|
82
|
-
*
|
|
83
|
-
* @param expr - A BoxedExpression or wildcard symbol string
|
|
84
|
-
* @returns
|
|
85
|
-
* - `'Wildcard'` - Universal wildcard (`_` or `_name`), matches exactly one element
|
|
86
|
-
* - `'Sequence'` - Sequence wildcard (`__` or `__name`), matches one or more elements
|
|
87
|
-
* - `'OptionalSequence'` - Optional sequence (`___` or `___name`), matches zero or more elements
|
|
88
|
-
* - `null` - Not a wildcard
|
|
89
|
-
*/
|
|
90
|
-
export declare function wildcardType(expr: BoxedExpression | string): 'Wildcard' | 'Sequence' | 'OptionalSequence' | null;
|
|
56
|
+
import type { Expression } from '../global-types';
|
|
57
|
+
import { isWildcard, wildcardName, wildcardType } from './pattern-utils';
|
|
58
|
+
export { isWildcard, wildcardName, wildcardType };
|
|
91
59
|
/**
|
|
92
60
|
* Validate a pattern for invalid wildcard combinations.
|
|
93
61
|
*
|
|
@@ -104,4 +72,4 @@ export declare function wildcardType(expr: BoxedExpression | string): 'Wildcard'
|
|
|
104
72
|
* @param pattern - The pattern to validate
|
|
105
73
|
* @throws Error if the pattern contains invalid wildcard combinations
|
|
106
74
|
*/
|
|
107
|
-
export declare function validatePattern(pattern:
|
|
75
|
+
export declare function validatePattern(pattern: Expression): void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedString
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export declare class BoxedString extends _BoxedExpression {
|
|
8
|
+
export declare class BoxedString extends _BoxedExpression implements StringInterface {
|
|
9
|
+
readonly _kind = "string";
|
|
9
10
|
[Symbol.toStringTag]: string;
|
|
10
11
|
private readonly _string;
|
|
11
12
|
private _utf8Buffer?;
|
|
@@ -17,11 +18,11 @@ export declare class BoxedString extends _BoxedExpression {
|
|
|
17
18
|
get isPure(): boolean;
|
|
18
19
|
get isCanonical(): boolean;
|
|
19
20
|
set isCanonical(_va: boolean);
|
|
20
|
-
get value():
|
|
21
|
+
get value(): Expression;
|
|
21
22
|
get type(): BoxedType;
|
|
22
23
|
get complexity(): number;
|
|
23
24
|
get string(): string;
|
|
24
25
|
get buffer(): Uint8Array;
|
|
25
26
|
get unicodeScalars(): number[];
|
|
26
|
-
match(pattern:
|
|
27
|
+
match(pattern: Expression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
27
28
|
}
|