@cortex-js/compute-engine 0.51.1 → 0.52.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/README.md +2 -4
- package/dist/compute-engine.esm.js +9746 -8490
- package/dist/compute-engine.min.esm.js +326 -103
- package/dist/compute-engine.min.umd.js +326 -103
- package/dist/compute-engine.umd.js +10474 -9218
- 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 +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -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 +11 -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 +2 -30
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +7 -5
- 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 +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +4 -2
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +3 -2
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +4 -3
- package/dist/types/compute-engine/boxed-expression/constants.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 +1 -1
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +9 -3
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +18 -0
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +14 -7
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +10 -4
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +2 -2
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +2 -2
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +13 -2
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +2 -2
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +2 -2
- package/dist/types/compute-engine/compilation/python-target.d.ts +2 -2
- package/dist/types/compute-engine/compilation/types.d.ts +89 -21
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.d.ts +9 -2
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +2 -2
- package/dist/types/compute-engine/interval/elementary.d.ts +50 -1
- package/dist/types/compute-engine/interval/index.d.ts +13 -3
- 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-units.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/colors.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- 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/quantity-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- 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 +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 +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/numerics/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +1 -1
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +54 -17
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +4 -3
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +2 -1
- package/dist/types/color/categorical.d.ts +0 -16
- package/dist/types/color/contrast.d.ts +0 -16
- package/dist/types/color/conversion.d.ts +0 -13
- package/dist/types/color/diverging-palettes.d.ts +0 -15
- package/dist/types/color/index.d.ts +0 -4
- package/dist/types/color/manipulation.d.ts +0 -95
- package/dist/types/color/palette.d.ts +0 -68
- package/dist/types/color/sequential.d.ts +0 -21
- package/dist/types/color/types.d.ts +0 -19
- package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* 0.52.1 */
|
|
2
|
+
type ComplexResult = {
|
|
3
|
+
re: number;
|
|
4
|
+
im: number;
|
|
5
|
+
};
|
|
6
|
+
type CompileFn = (expr: Expression) => {
|
|
7
|
+
run?: ((vars: Record<string, number>) => number | ComplexResult) | undefined;
|
|
8
|
+
};
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function _setCompile(fn: CompileFn): void;
|
|
11
|
+
/**
|
|
12
|
+
* Stochastic equality check: evaluate both expressions at random sample points
|
|
13
|
+
* and compare results (both real and imaginary parts). Returns `true` if they
|
|
14
|
+
* agree at all informative points, `false` if they disagree, or `undefined`
|
|
15
|
+
* if no informative points were found.
|
|
16
|
+
*/
|
|
17
|
+
export declare function stochasticEqual(a: Expression, b: Expression): boolean | undefined;
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
/** Assuming x in an expression in radians, convert to current angular unit. */
|
|
3
3
|
export declare function radiansToAngle(x: Expression | undefined): Expression | undefined;
|
|
4
4
|
export declare function evalTrig(name: string, op: Expression | undefined): Expression | undefined;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
|
+
import type { NumericValue } from '../numeric-value/types';
|
|
2
3
|
/** Preferred guard for runtime expressions. */
|
|
3
4
|
export declare function isExpression(x: unknown): x is Expression;
|
|
4
5
|
export declare function isNumber(expr: Expression | null | undefined): expr is Expression & NumberLiteralInterface;
|
|
5
|
-
export declare function isSymbol(expr: Expression | null | undefined): expr is Expression & SymbolInterface;
|
|
6
|
-
export declare function isFunction(expr: Expression | null | undefined): expr is Expression & FunctionInterface;
|
|
6
|
+
export declare function isSymbol(expr: Expression | null | undefined, name?: string): expr is Expression & SymbolInterface;
|
|
7
|
+
export declare function isFunction(expr: Expression | null | undefined, operator?: string): expr is Expression & FunctionInterface;
|
|
7
8
|
export declare function isString(expr: Expression | null | undefined): expr is Expression & StringInterface;
|
|
8
9
|
export declare function isTensor(expr: Expression | null | undefined): expr is Expression & TensorInterface;
|
|
9
10
|
/** @deprecated Use `isExpression()` instead. */
|
|
@@ -11,9 +12,9 @@ export declare function isBoxedExpression(x: unknown): x is Expression;
|
|
|
11
12
|
/** @deprecated Use `isNumber()` instead. */
|
|
12
13
|
export declare function isBoxedNumber(expr: Expression | null | undefined): expr is Expression & NumberLiteralInterface;
|
|
13
14
|
/** @deprecated Use `isSymbol()` instead. */
|
|
14
|
-
export declare function isBoxedSymbol(expr: Expression | null | undefined): expr is Expression & SymbolInterface;
|
|
15
|
+
export declare function isBoxedSymbol(expr: Expression | null | undefined, name?: string): expr is Expression & SymbolInterface;
|
|
15
16
|
/** @deprecated Use `isFunction()` instead. */
|
|
16
|
-
export declare function isBoxedFunction(expr: Expression | null | undefined): expr is Expression & FunctionInterface;
|
|
17
|
+
export declare function isBoxedFunction(expr: Expression | null | undefined, operator?: string): expr is Expression & FunctionInterface;
|
|
17
18
|
/** @deprecated Use `isString()` instead. */
|
|
18
19
|
export declare function isBoxedString(expr: Expression | null | undefined): expr is Expression & StringInterface;
|
|
19
20
|
/** @deprecated Use `isTensor()` instead. */
|
|
@@ -21,11 +22,17 @@ export declare function isBoxedTensor(expr: Expression | null | undefined): expr
|
|
|
21
22
|
export declare function isDictionary(expr: Expression | null | undefined): expr is Expression & DictionaryInterface;
|
|
22
23
|
export declare function isCollection(expr: Expression | null | undefined): expr is Expression & CollectionInterface;
|
|
23
24
|
export declare function isIndexedCollection(expr: Expression | null | undefined): expr is Expression & IndexedCollectionInterface;
|
|
25
|
+
/**
|
|
26
|
+
* Return the numeric value if `expr` is a number literal, otherwise `undefined`.
|
|
27
|
+
*
|
|
28
|
+
* Convenience helper that combines `isNumber()` with `.numericValue` access.
|
|
29
|
+
*/
|
|
30
|
+
export declare function numericValue(expr: Expression | null | undefined): number | NumericValue | undefined;
|
|
24
31
|
/**
|
|
25
32
|
* Get the symbol name if `expr` is a symbol expression, otherwise `undefined`.
|
|
26
33
|
*
|
|
27
34
|
* Convenience helper that combines `isSymbol()` with `.symbol` access
|
|
28
|
-
* so callers can write `sym(expr) === 'Pi'` instead of
|
|
29
|
-
* `isSymbol(expr
|
|
35
|
+
* so callers can write `sym(expr) === 'Pi'` instead of
|
|
36
|
+
* `isSymbol(expr, 'Pi')`.
|
|
30
37
|
*/
|
|
31
38
|
export declare function sym(expr: Expression | null | undefined): string | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { Expression, JSSource } from '../global-types';
|
|
3
3
|
import type { CompileTarget, CompilationResult } from './types';
|
|
4
|
-
type CompileExpressionOptions = {
|
|
5
|
-
to?:
|
|
4
|
+
type CompileExpressionOptions<T extends string = string> = {
|
|
5
|
+
to?: T;
|
|
6
6
|
target?: CompileTarget<Expression>;
|
|
7
7
|
operators?: Partial<Record<MathJsonSymbol, [op: string, prec: number]>> | ((op: MathJsonSymbol) => [op: string, prec: number] | undefined);
|
|
8
8
|
functions?: Record<MathJsonSymbol, JSSource | ((...args: unknown[]) => unknown)>;
|
|
@@ -10,6 +10,7 @@ type CompileExpressionOptions = {
|
|
|
10
10
|
imports?: unknown[];
|
|
11
11
|
preamble?: string;
|
|
12
12
|
fallback?: boolean;
|
|
13
|
+
realOnly?: boolean;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Compile a boxed expression.
|
|
@@ -17,9 +18,14 @@ type CompileExpressionOptions = {
|
|
|
17
18
|
* Returns a `CompilationResult` with the generated source code and,
|
|
18
19
|
* for JS-executable targets, a `run` function.
|
|
19
20
|
*
|
|
21
|
+
* When `realOnly` is true, the return type of `run` is narrowed to `number`.
|
|
22
|
+
*
|
|
20
23
|
* If the expression cannot be compiled, falls back to interpretation
|
|
21
24
|
* (success: false, run: applicableN1) unless `options.fallback` is false,
|
|
22
25
|
* in which case it throws.
|
|
23
26
|
*/
|
|
24
|
-
export declare function compile(expr: Expression, options
|
|
27
|
+
export declare function compile<T extends string = 'javascript'>(expr: Expression, options: CompileExpressionOptions<T> & {
|
|
28
|
+
realOnly: true;
|
|
29
|
+
}): CompilationResult<T, number>;
|
|
30
|
+
export declare function compile<T extends string = 'javascript'>(expr: Expression, options?: CompileExpressionOptions<T>): CompilationResult<T>;
|
|
25
31
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* GPU shader operators shared by GLSL and WGSL.
|
|
@@ -35,7 +35,7 @@ export declare function compileGPUMatrix(args: ReadonlyArray<Expression>, compil
|
|
|
35
35
|
* Uses reflection formula for z < 0.5 and Lanczos for z >= 0.5.
|
|
36
36
|
* Valid for both GLSL and WGSL (uses standard math builtins).
|
|
37
37
|
*/
|
|
38
|
-
export declare const GPU_GAMMA_PREAMBLE = "\nfloat _gpu_gamma(float z) {\n const float PI = 3.14159265358979;\n
|
|
38
|
+
export declare const GPU_GAMMA_PREAMBLE = "\nfloat _gpu_gamma(float z) {\n const float PI = 3.14159265358979;\n // For z < 0.5, use reflection formula with inlined Lanczos (non-recursive)\n float w = z;\n if (z < 0.5) w = 1.0 - z;\n w -= 1.0;\n float x = 0.99999999999980993;\n x += 676.5203681218851 / (w + 1.0);\n x += -1259.1392167224028 / (w + 2.0);\n x += 771.32342877765313 / (w + 3.0);\n x += -176.61502916214059 / (w + 4.0);\n x += 12.507343278686905 / (w + 5.0);\n x += -0.13857109526572012 / (w + 6.0);\n x += 9.9843695780195716e-6 / (w + 7.0);\n x += 1.5056327351493116e-7 / (w + 8.0);\n float t = w + 7.5;\n float g = sqrt(2.0 * PI) * pow(t, w + 0.5) * exp(-t) * x;\n if (z < 0.5) return PI / (sin(PI * z) * g);\n return g;\n}\n\nfloat _gpu_gammaln(float z) {\n // Stirling asymptotic expansion for ln(Gamma(z)), z > 0\n float z3 = z * z * z;\n return z * log(z) - z - 0.5 * log(z)\n + 0.5 * log(2.0 * 3.14159265358979)\n + 1.0 / (12.0 * z)\n - 1.0 / (360.0 * z3)\n + 1.0 / (1260.0 * z3 * z * z);\n}\n";
|
|
39
39
|
/**
|
|
40
40
|
* GPU error function using Abramowitz & Stegun approximation.
|
|
41
41
|
* Maximum error: |epsilon(x)| <= 1.5e-7.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
* GLSL interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to GLSL code using interval arithmetic
|
|
@@ -24,7 +24,7 @@ export declare class IntervalGLSLTarget implements LanguageTarget<Expression> {
|
|
|
24
24
|
*/
|
|
25
25
|
getLibrary(): string;
|
|
26
26
|
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
27
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult
|
|
27
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-glsl'>;
|
|
28
28
|
/**
|
|
29
29
|
* Compile an expression to GLSL interval code string.
|
|
30
30
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
* JavaScript interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to JavaScript code using interval arithmetic
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Expression } from '../global-types';
|
|
10
10
|
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
11
|
+
import type { Interval, IntervalResult } from '../interval/types';
|
|
11
12
|
/**
|
|
12
13
|
* JavaScript function that wraps compiled interval arithmetic code.
|
|
13
14
|
*
|
|
@@ -58,6 +59,16 @@ export declare class ComputeEngineIntervalFunction extends Function {
|
|
|
58
59
|
sign: typeof import("../interval").sign;
|
|
59
60
|
gamma: typeof import("../interval").gamma;
|
|
60
61
|
gammaln: typeof import("../interval").gammaln;
|
|
62
|
+
factorial: typeof import("../interval").factorial;
|
|
63
|
+
factorial2: typeof import("../interval").factorial2;
|
|
64
|
+
binomial: typeof import("../interval/elementary").binomial;
|
|
65
|
+
gcd: typeof import("../interval/elementary").gcd;
|
|
66
|
+
lcm: typeof import("../interval/elementary").lcm;
|
|
67
|
+
chop: typeof import("../interval/elementary").chop;
|
|
68
|
+
erf: typeof import("../interval/elementary").erf;
|
|
69
|
+
erfc: typeof import("../interval/elementary").erfc;
|
|
70
|
+
exp2: typeof import("../interval/elementary").exp2;
|
|
71
|
+
hypot: typeof import("../interval/elementary").hypot;
|
|
61
72
|
sin: typeof import("../interval").sin;
|
|
62
73
|
cos: typeof import("../interval").cos;
|
|
63
74
|
tan: typeof import("../interval").tan;
|
|
@@ -107,5 +118,5 @@ export declare class IntervalJavaScriptTarget implements LanguageTarget<Expressi
|
|
|
107
118
|
getOperators(): CompiledOperators;
|
|
108
119
|
getFunctions(): CompiledFunctions<Expression>;
|
|
109
120
|
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
110
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult
|
|
121
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-js', IntervalResult | Interval>;
|
|
111
122
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
* WGSL interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to WGSL code using interval arithmetic
|
|
@@ -28,7 +28,7 @@ export declare class IntervalWGSLTarget implements LanguageTarget<Expression> {
|
|
|
28
28
|
*/
|
|
29
29
|
getLibrary(): string;
|
|
30
30
|
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
31
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult
|
|
31
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-wgsl'>;
|
|
32
32
|
/**
|
|
33
33
|
* Compile an expression to WGSL interval code string.
|
|
34
34
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import { chop, factorial, factorial2, gcd, lcm, limit } from '../numerics/numeric';
|
|
3
3
|
import { gamma, gammaln, erf, erfc, erfInv, beta, digamma, trigamma, polygamma, zeta, lambertW, besselJ, besselY, besselI, besselK, airyAi, airyBi, fresnelS, fresnelC, sinc } from '../numerics/special-functions';
|
|
4
4
|
import { choose } from '../boxed-expression/expand';
|
|
@@ -347,7 +347,7 @@ export declare class JavaScriptTarget implements LanguageTarget<Expression> {
|
|
|
347
347
|
getOperators(): CompiledOperators;
|
|
348
348
|
getFunctions(): CompiledFunctions<Expression>;
|
|
349
349
|
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
350
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult
|
|
350
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'javascript'>;
|
|
351
351
|
}
|
|
352
352
|
/**
|
|
353
353
|
* Compute the nth Fibonacci number using iterative doubling.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Python/NumPy language target implementation
|
|
@@ -24,7 +24,7 @@ export declare class PythonTarget implements LanguageTarget<Expression> {
|
|
|
24
24
|
*
|
|
25
25
|
* Returns Python code as a string. To execute it, use Python runtime.
|
|
26
26
|
*/
|
|
27
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult
|
|
27
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'python'>;
|
|
28
28
|
/**
|
|
29
29
|
* Compile an expression to Python source code
|
|
30
30
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
/**
|
|
3
3
|
* Source code in the target language
|
|
4
4
|
*/
|
|
@@ -57,7 +57,7 @@ export interface LanguageTarget<Expr = unknown> {
|
|
|
57
57
|
/** Create a CompileTarget for this language */
|
|
58
58
|
createTarget(options?: Partial<CompileTarget<Expr>>): CompileTarget<Expr>;
|
|
59
59
|
/** Compile an expression to this language */
|
|
60
|
-
compile(expr: Expr, options?: CompilationOptions<Expr>): CompilationResult
|
|
60
|
+
compile(expr: Expr, options?: CompilationOptions<Expr>): CompilationResult<string, unknown>;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* Options for compilation
|
|
@@ -143,11 +143,85 @@ export interface CompilationOptions<Expr = unknown> {
|
|
|
143
143
|
realOnly?: boolean;
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
|
-
*
|
|
146
|
+
* Built-in targets that produce an executable `run` function.
|
|
147
147
|
*/
|
|
148
|
-
export
|
|
148
|
+
export type ExecutableTarget = 'javascript' | 'interval-js';
|
|
149
|
+
/**
|
|
150
|
+
* Result of a complex number computation: `{ re, im }`.
|
|
151
|
+
*/
|
|
152
|
+
export type ComplexResult = {
|
|
153
|
+
re: number;
|
|
154
|
+
im: number;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Runner for compiled expressions — called with a variables object.
|
|
158
|
+
*
|
|
159
|
+
* ```typescript
|
|
160
|
+
* result.run({ x: 0.5, y: 1.0 })
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export type ExpressionRunner<R = number | ComplexResult> = (vars: Record<string, number>) => R;
|
|
164
|
+
/**
|
|
165
|
+
* Runner for compiled lambda (`Function`) expressions — called with
|
|
166
|
+
* positional arguments.
|
|
167
|
+
*
|
|
168
|
+
* ```typescript
|
|
169
|
+
* result.run(0.5, 1.0)
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export type LambdaRunner<R = number | ComplexResult> = (...args: number[]) => R;
|
|
173
|
+
/**
|
|
174
|
+
* Overloaded callable that accepts both calling conventions.
|
|
175
|
+
*
|
|
176
|
+
* Supports two calling styles:
|
|
177
|
+
* - **Expression**: `run({ x: 0.5 })` — pass a variables object
|
|
178
|
+
* - **Lambda**: `run(0.5, 1.0)` — pass positional arguments
|
|
179
|
+
*
|
|
180
|
+
* Check `calling` on the `CompilationResult` to know which convention
|
|
181
|
+
* the compiled expression actually uses.
|
|
182
|
+
*/
|
|
183
|
+
export interface CompiledRunner<R = number | ComplexResult> {
|
|
184
|
+
/** Call with a variables object (for compiled expressions) */
|
|
185
|
+
(vars: Record<string, number>): R;
|
|
186
|
+
/** Call with positional arguments (for compiled lambda expressions) */
|
|
187
|
+
(...args: number[]): R;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Result of compiling an expression.
|
|
191
|
+
*
|
|
192
|
+
* Two type parameters control the shape:
|
|
193
|
+
* - `T` — the target name. For executable targets (`'javascript'` |
|
|
194
|
+
* `'interval-js'`), `run` and `calling` are guaranteed present.
|
|
195
|
+
* - `R` — the return type of `run`. Defaults to `number | ComplexResult`.
|
|
196
|
+
* Pass `number` when `realOnly: true`.
|
|
197
|
+
*
|
|
198
|
+
* The `calling` field indicates which convention `run` uses:
|
|
199
|
+
* - `'expression'` — call with a vars object: `run({ x: 0.5 })`
|
|
200
|
+
* - `'lambda'` — call with positional args: `run(0.5, 1.0)`
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // run is guaranteed, may return complex
|
|
205
|
+
* const js = compile(expr);
|
|
206
|
+
* js.run({ x: 0.5 });
|
|
207
|
+
*
|
|
208
|
+
* // run is guaranteed, returns number only
|
|
209
|
+
* const real = compile(expr, { realOnly: true });
|
|
210
|
+
* real.run({ x: 0.5 }); // number
|
|
211
|
+
*
|
|
212
|
+
* // check calling convention
|
|
213
|
+
* if (result.calling === 'lambda') {
|
|
214
|
+
* result.run(0.5, 1.0);
|
|
215
|
+
* }
|
|
216
|
+
*
|
|
217
|
+
* // no run (source-only target)
|
|
218
|
+
* const py = compile(expr, { to: 'python' });
|
|
219
|
+
* py.code; // string
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
export type CompilationResult<T extends string = string, R = number | ComplexResult> = {
|
|
149
223
|
/** Target language name */
|
|
150
|
-
target:
|
|
224
|
+
target: T;
|
|
151
225
|
/** Whether compilation succeeded (vs falling back to interpretation) */
|
|
152
226
|
success: boolean;
|
|
153
227
|
/** Generated source code */
|
|
@@ -164,20 +238,14 @@ export interface CompilationResult {
|
|
|
164
238
|
*/
|
|
165
239
|
preamble?: string;
|
|
166
240
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
* ```typescript
|
|
171
|
-
* result.run({ x: 0.5 })
|
|
172
|
-
* ```
|
|
173
|
-
*
|
|
174
|
-
* For `Function` (lambda) expressions, call with positional arguments:
|
|
175
|
-
* ```typescript
|
|
176
|
-
* result.run(0.5)
|
|
177
|
-
* ```
|
|
241
|
+
* How `run` should be called (present only for executable targets).
|
|
242
|
+
* - `'expression'` — call with a vars object: `run({ x: 0.5 })`
|
|
243
|
+
* - `'lambda'` — call with positional args: `run(0.5, 1.0)`
|
|
178
244
|
*/
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
245
|
+
calling?: 'expression' | 'lambda';
|
|
246
|
+
/** Executable function (present for JS-executable targets only). */
|
|
247
|
+
run?: CompiledRunner<R>;
|
|
248
|
+
} & (T extends ExecutableTarget ? {
|
|
249
|
+
calling: 'expression' | 'lambda';
|
|
250
|
+
run: CompiledRunner<R>;
|
|
251
|
+
} : {});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { MathJsonSymbol } from '../math-json/types';
|
|
3
3
|
export declare function ask(ce: IComputeEngine, pattern: Expression): BoxedSubstitution[];
|
|
4
4
|
export declare function verify(ce: IComputeEngine, query: Expression): boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import { BoxedType } from '../common/type/boxed-type';
|
|
3
3
|
import type { MathJsonSymbol } from '../math-json/types';
|
|
4
4
|
import type { ValueDefinition, OperatorDefinition, AssignValue, Expression, BoxedDefinition, SymbolDefinition, IComputeEngine, Scope } from './global-types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { LatexDictionaryEntry, LibraryCategory } from './latex-syntax/types';
|
|
3
3
|
export declare function resolveBootstrapLibraries(libraries?: readonly (string | LibraryDefinition)[]): LibraryDefinition[];
|
|
4
4
|
export declare function loadLibraryDefinitions(engine: ComputeEngine, libraries: readonly LibraryDefinition[]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
export declare function declareSequence(ce: IComputeEngine, name: string, def: SequenceDefinition): IComputeEngine;
|
|
3
3
|
export declare function getSequenceStatus(ce: IComputeEngine, name: string): SequenceStatus;
|
|
4
4
|
export declare function getSequence(ce: IComputeEngine, name: string): SequenceInfo | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
import type { Type, TypeString } from '../common/type/types';
|
|
3
3
|
import type { LatexString } from './latex-syntax/types';
|
|
4
4
|
import { compile as compileExpr } from './compilation/compile-expression';
|
|
5
|
+
import type { CompilationResult } from './compilation/types';
|
|
5
6
|
/** @internal Called by index.ts to register the ComputeEngine class,
|
|
6
7
|
* avoiding a circular dependency (index.ts re-exports this file). */
|
|
7
8
|
export declare function _setComputeEngineClass(cls: new () => IComputeEngine): void;
|
|
@@ -23,4 +24,10 @@ export declare function expand(expr: LatexString | ExpressionInput): Expression
|
|
|
23
24
|
export declare function solve(expr: LatexString | ExpressionInput, vars?: string | Iterable<string> | Expression | Iterable<Expression>): null | ReadonlyArray<Expression> | Record<string, Expression> | Array<Record<string, Expression>>;
|
|
24
25
|
export declare function expandAll(expr: LatexString | ExpressionInput): Expression | null;
|
|
25
26
|
export declare function factor(expr: LatexString | ExpressionInput): Expression;
|
|
26
|
-
export declare function compile(expr: LatexString | ExpressionInput, options
|
|
27
|
+
export declare function compile<T extends string = 'javascript'>(expr: LatexString | ExpressionInput, options: Parameters<typeof compileExpr>[1] & {
|
|
28
|
+
to?: T;
|
|
29
|
+
realOnly: true;
|
|
30
|
+
}): CompilationResult<T, number>;
|
|
31
|
+
export declare function compile<T extends string = 'javascript'>(expr: LatexString | ExpressionInput, options?: Parameters<typeof compileExpr>[1] & {
|
|
32
|
+
to?: T;
|
|
33
|
+
}): CompilationResult<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.52.1 */
|
|
2
2
|
export type * from './types-serialization';
|
|
3
3
|
export type { ValueDefinition, SequenceDefinition, SequenceStatus, SequenceInfo, OEISSequenceInfo, OEISOptions, OperatorDefinition, BaseDefinition, SimplifyOptions, SymbolDefinition, SymbolDefinitions, LibraryDefinition, AngularUnit, Sign, BaseCollectionHandlers, IndexedCollectionHandlers, CollectionHandlers, TaggedValueDefinition, TaggedOperatorDefinition, BoxedDefinition, BoxedBaseDefinition, BoxedValueDefinition, OperatorDefinitionFlags, BoxedOperatorDefinition, } from './types-definitions';
|
|
4
4
|
export type * from './types-evaluation';
|