@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
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { Expression, JSSource } from '../global-types';
|
|
3
|
+
import type { CompileTarget, CompilationResult } from './types';
|
|
4
|
+
type CompileExpressionOptions = {
|
|
5
|
+
to?: string;
|
|
6
|
+
target?: CompileTarget<Expression>;
|
|
7
|
+
operators?: Partial<Record<MathJsonSymbol, [op: string, prec: number]>> | ((op: MathJsonSymbol) => [op: string, prec: number] | undefined);
|
|
8
|
+
functions?: Record<MathJsonSymbol, JSSource | ((...args: unknown[]) => unknown)>;
|
|
9
|
+
vars?: Record<MathJsonSymbol, JSSource>;
|
|
10
|
+
imports?: unknown[];
|
|
11
|
+
preamble?: string;
|
|
12
|
+
fallback?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compile a boxed expression.
|
|
16
|
+
*
|
|
17
|
+
* Returns a `CompilationResult` with the generated source code and,
|
|
18
|
+
* for JS-executable targets, a `run` function.
|
|
19
|
+
*
|
|
20
|
+
* If the expression cannot be compiled, falls back to interpretation
|
|
21
|
+
* (success: false, run: applicableN1) unless `options.fallback` is false,
|
|
22
|
+
* in which case it throws.
|
|
23
|
+
*/
|
|
24
|
+
export declare function compile(expr: Expression, options?: CompileExpressionOptions): CompilationResult;
|
|
25
|
+
export {};
|
|
@@ -1,63 +1,34 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import type {
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { CompiledFunctions } from './types';
|
|
3
|
+
import { GPUShaderTarget } from './gpu-target';
|
|
3
4
|
/**
|
|
4
|
-
* GLSL
|
|
5
|
+
* GLSL (OpenGL Shading Language) compilation target.
|
|
6
|
+
*
|
|
7
|
+
* Extends the shared GPU base class with GLSL-specific function names,
|
|
8
|
+
* C-style function declarations, and `#version`-based shader structure.
|
|
5
9
|
*/
|
|
6
|
-
export declare class GLSLTarget
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Compile to GLSL source code (not executable)
|
|
12
|
-
*
|
|
13
|
-
* GLSL doesn't run in JavaScript, so this returns source code as a string
|
|
14
|
-
* rather than an executable function.
|
|
15
|
-
*/
|
|
16
|
-
compileToExecutable(expr: BoxedExpression, options?: CompilationOptions): CompiledExecutable;
|
|
17
|
-
/**
|
|
18
|
-
* Compile an expression to GLSL source code
|
|
19
|
-
*
|
|
20
|
-
* Returns the GLSL code as a string.
|
|
21
|
-
*/
|
|
22
|
-
compile(expr: BoxedExpression, options?: CompilationOptions): string;
|
|
23
|
-
/**
|
|
24
|
-
* Create a complete GLSL function from an expression
|
|
25
|
-
*
|
|
26
|
-
* @param expr - The expression to compile
|
|
27
|
-
* @param functionName - Name of the GLSL function
|
|
28
|
-
* @param returnType - GLSL return type (e.g., 'float', 'vec3')
|
|
29
|
-
* @param parameters - Parameter declarations (e.g., [['x', 'float'], ['y', 'vec3']])
|
|
30
|
-
*/
|
|
31
|
-
compileFunction(expr: BoxedExpression, functionName: string, returnType: string, parameters: Array<[name: string, type: string]>): string;
|
|
32
|
-
/**
|
|
33
|
-
* Create a complete GLSL shader from expressions
|
|
34
|
-
*
|
|
35
|
-
* @param options - Shader compilation options
|
|
36
|
-
*/
|
|
10
|
+
export declare class GLSLTarget extends GPUShaderTarget {
|
|
11
|
+
protected readonly languageId = "glsl";
|
|
12
|
+
protected getLanguageSpecificFunctions(): CompiledFunctions<Expression>;
|
|
13
|
+
compileFunction(expr: Expression, functionName: string, returnType: string, parameters: Array<[name: string, type: string]>): string;
|
|
37
14
|
compileShader(options: {
|
|
38
|
-
/** Shader type: 'vertex' or 'fragment' */
|
|
39
15
|
type: 'vertex' | 'fragment';
|
|
40
|
-
/** GLSL version (e.g., '300 es', '330', '450') */
|
|
41
16
|
version?: string;
|
|
42
|
-
/** Input variables (attributes or varyings) */
|
|
43
17
|
inputs?: Array<{
|
|
44
18
|
name: string;
|
|
45
19
|
type: string;
|
|
46
20
|
}>;
|
|
47
|
-
/** Output variables */
|
|
48
21
|
outputs?: Array<{
|
|
49
22
|
name: string;
|
|
50
23
|
type: string;
|
|
51
24
|
}>;
|
|
52
|
-
/** Uniform variables */
|
|
53
25
|
uniforms?: Array<{
|
|
54
26
|
name: string;
|
|
55
27
|
type: string;
|
|
56
28
|
}>;
|
|
57
|
-
/** Main function body expressions */
|
|
58
29
|
body: Array<{
|
|
59
30
|
variable: string;
|
|
60
|
-
expression:
|
|
31
|
+
expression: Expression;
|
|
61
32
|
}>;
|
|
62
33
|
}): string;
|
|
63
34
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* GPU shader operators shared by GLSL and WGSL.
|
|
5
|
+
*
|
|
6
|
+
* Both languages use identical C-style operators for arithmetic,
|
|
7
|
+
* comparison, and logical operations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GPU_OPERATORS: CompiledOperators;
|
|
10
|
+
/**
|
|
11
|
+
* GPU shader functions shared by GLSL and WGSL.
|
|
12
|
+
*
|
|
13
|
+
* Both languages share identical built-in math functions. Language-specific
|
|
14
|
+
* functions (inversesqrt naming, mod, vector constructors) are provided
|
|
15
|
+
* by subclass overrides.
|
|
16
|
+
*/
|
|
17
|
+
export declare const GPU_FUNCTIONS: CompiledFunctions<Expression>;
|
|
18
|
+
/**
|
|
19
|
+
* Abstract base class for GPU shader compilation targets.
|
|
20
|
+
*
|
|
21
|
+
* Provides shared operators, math functions, constants, and number formatting
|
|
22
|
+
* for both GLSL and WGSL. Subclasses implement language-specific details:
|
|
23
|
+
* function naming differences, vector constructors, function declaration
|
|
24
|
+
* syntax, and shader structure.
|
|
25
|
+
*/
|
|
26
|
+
export declare abstract class GPUShaderTarget implements LanguageTarget<Expression> {
|
|
27
|
+
/** Language identifier (e.g., 'glsl', 'wgsl') */
|
|
28
|
+
protected abstract readonly languageId: string;
|
|
29
|
+
/**
|
|
30
|
+
* Return language-specific function overrides.
|
|
31
|
+
*
|
|
32
|
+
* These are merged on top of the shared GPU_FUNCTIONS, allowing
|
|
33
|
+
* subclasses to override specific entries (e.g., `Inversesqrt`, `Mod`, `List`).
|
|
34
|
+
*/
|
|
35
|
+
protected abstract getLanguageSpecificFunctions(): CompiledFunctions<Expression>;
|
|
36
|
+
/**
|
|
37
|
+
* Create a complete function declaration in the target language.
|
|
38
|
+
*/
|
|
39
|
+
abstract compileFunction(expr: Expression, functionName: string, returnType: string, parameters: Array<[name: string, type: string]>): string;
|
|
40
|
+
/**
|
|
41
|
+
* Create a complete shader program in the target language.
|
|
42
|
+
*/
|
|
43
|
+
abstract compileShader(options: Record<string, unknown>): string;
|
|
44
|
+
getOperators(): CompiledOperators;
|
|
45
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
46
|
+
getConstants(): Record<string, string>;
|
|
47
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
48
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
49
|
+
compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
|
|
50
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
* GLSL interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to GLSL code using interval arithmetic
|
|
@@ -9,26 +9,26 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module compilation/interval-glsl-target
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
13
|
-
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions,
|
|
12
|
+
import type { Expression } from '../global-types';
|
|
13
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
14
14
|
/**
|
|
15
15
|
* GLSL interval arithmetic target implementation.
|
|
16
16
|
*/
|
|
17
|
-
export declare class IntervalGLSLTarget implements LanguageTarget {
|
|
17
|
+
export declare class IntervalGLSLTarget implements LanguageTarget<Expression> {
|
|
18
18
|
getOperators(): CompiledOperators;
|
|
19
|
-
getFunctions(): CompiledFunctions
|
|
19
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
20
20
|
/**
|
|
21
21
|
* Get the GLSL interval library code.
|
|
22
22
|
*
|
|
23
23
|
* This should be included in shaders that use interval arithmetic.
|
|
24
24
|
*/
|
|
25
25
|
getLibrary(): string;
|
|
26
|
-
createTarget(options?: Partial<CompileTarget
|
|
27
|
-
|
|
26
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
27
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
28
28
|
/**
|
|
29
|
-
* Compile an expression to GLSL interval code.
|
|
29
|
+
* Compile an expression to GLSL interval code string.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
|
|
32
32
|
/**
|
|
33
33
|
* Create a complete GLSL interval function from an expression.
|
|
34
34
|
*
|
|
@@ -36,14 +36,14 @@ export declare class IntervalGLSLTarget implements LanguageTarget {
|
|
|
36
36
|
* @param functionName - Name of the GLSL function
|
|
37
37
|
* @param parameters - Parameter names (each becomes a vec2 interval input)
|
|
38
38
|
*/
|
|
39
|
-
compileFunction(expr:
|
|
39
|
+
compileFunction(expr: Expression, functionName: string, parameters: string[]): string;
|
|
40
40
|
/**
|
|
41
41
|
* Create a complete GLSL fragment shader for interval function plotting.
|
|
42
42
|
*
|
|
43
43
|
* @param expr - The expression to compile
|
|
44
44
|
* @param options - Shader options
|
|
45
45
|
*/
|
|
46
|
-
compileShaderFunction(expr:
|
|
46
|
+
compileShaderFunction(expr: Expression, options?: {
|
|
47
47
|
functionName?: string;
|
|
48
48
|
version?: string;
|
|
49
49
|
parameters?: string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
* JavaScript interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to JavaScript code using interval arithmetic
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module compilation/interval-javascript-target
|
|
8
8
|
*/
|
|
9
|
-
import type {
|
|
10
|
-
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions,
|
|
9
|
+
import type { Expression } from '../global-types';
|
|
10
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
11
11
|
/**
|
|
12
12
|
* JavaScript function that wraps compiled interval arithmetic code.
|
|
13
13
|
*
|
|
@@ -97,9 +97,9 @@ export declare class ComputeEngineIntervalFunction extends Function {
|
|
|
97
97
|
/**
|
|
98
98
|
* Interval arithmetic JavaScript target implementation.
|
|
99
99
|
*/
|
|
100
|
-
export declare class IntervalJavaScriptTarget implements LanguageTarget {
|
|
100
|
+
export declare class IntervalJavaScriptTarget implements LanguageTarget<Expression> {
|
|
101
101
|
getOperators(): CompiledOperators;
|
|
102
|
-
getFunctions(): CompiledFunctions
|
|
103
|
-
createTarget(options?: Partial<CompileTarget
|
|
104
|
-
|
|
102
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
103
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
104
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
105
105
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
* WGSL interval arithmetic compilation target
|
|
3
|
+
*
|
|
4
|
+
* Compiles mathematical expressions to WGSL code using interval arithmetic
|
|
5
|
+
* for reliable function evaluation in WebGPU shaders.
|
|
6
|
+
*
|
|
7
|
+
* Intervals are represented as vec2f(lo, hi).
|
|
8
|
+
* Status flags use f32 constants for shader compatibility.
|
|
9
|
+
*
|
|
10
|
+
* Since WGSL does not support function overloading, internal vec2f-parameter
|
|
11
|
+
* implementations use a `_v` suffix (e.g., `ia_add_v`), while the public
|
|
12
|
+
* IntervalResult wrappers keep the base name (e.g., `ia_add`).
|
|
13
|
+
*
|
|
14
|
+
* @module compilation/interval-wgsl-target
|
|
15
|
+
*/
|
|
16
|
+
import type { Expression } from '../global-types';
|
|
17
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
18
|
+
/**
|
|
19
|
+
* WGSL interval arithmetic target implementation.
|
|
20
|
+
*/
|
|
21
|
+
export declare class IntervalWGSLTarget implements LanguageTarget<Expression> {
|
|
22
|
+
getOperators(): CompiledOperators;
|
|
23
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
24
|
+
/**
|
|
25
|
+
* Get the WGSL interval library code.
|
|
26
|
+
*
|
|
27
|
+
* This should be included in shaders that use interval arithmetic.
|
|
28
|
+
*/
|
|
29
|
+
getLibrary(): string;
|
|
30
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
31
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
32
|
+
/**
|
|
33
|
+
* Compile an expression to WGSL interval code string.
|
|
34
|
+
*/
|
|
35
|
+
compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
|
|
36
|
+
/**
|
|
37
|
+
* Create a complete WGSL interval function from an expression.
|
|
38
|
+
*
|
|
39
|
+
* @param expr - The expression to compile
|
|
40
|
+
* @param functionName - Name of the WGSL function
|
|
41
|
+
* @param parameters - Parameter names (each becomes a vec2f interval input)
|
|
42
|
+
*/
|
|
43
|
+
compileFunction(expr: Expression, functionName: string, parameters: string[]): string;
|
|
44
|
+
/**
|
|
45
|
+
* Create a complete WGSL compute shader for interval function evaluation.
|
|
46
|
+
*
|
|
47
|
+
* @param expr - The expression to compile
|
|
48
|
+
* @param options - Shader options
|
|
49
|
+
*/
|
|
50
|
+
compileShaderFunction(expr: Expression, options?: {
|
|
51
|
+
functionName?: string;
|
|
52
|
+
parameters?: string[];
|
|
53
|
+
}): string;
|
|
54
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
import { chop, factorial, gcd, lcm, limit } from '../numerics/numeric';
|
|
3
3
|
import { gamma, gammaln } from '../numerics/special-functions';
|
|
4
4
|
import { interquartileRange, kurtosis, mean, median, mode, populationStandardDeviation, populationVariance, quartiles, skewness, standardDeviation, variance } from '../numerics/statistics';
|
|
5
|
-
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions,
|
|
5
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* JavaScript-specific function extension that provides system functions
|
|
8
8
|
*/
|
|
@@ -60,9 +60,9 @@ export declare class ComputeEngineFunctionLiteral extends Function {
|
|
|
60
60
|
/**
|
|
61
61
|
* JavaScript language target implementation
|
|
62
62
|
*/
|
|
63
|
-
export declare class JavaScriptTarget implements LanguageTarget {
|
|
63
|
+
export declare class JavaScriptTarget implements LanguageTarget<Expression> {
|
|
64
64
|
getOperators(): CompiledOperators;
|
|
65
|
-
getFunctions(): CompiledFunctions
|
|
66
|
-
createTarget(options?: Partial<CompileTarget
|
|
67
|
-
|
|
65
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
66
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
67
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
68
68
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Python/NumPy language target implementation
|
|
5
|
+
*
|
|
6
|
+
* Generates Python code that uses NumPy for mathematical operations.
|
|
7
|
+
* The generated code is compatible with NumPy arrays and supports
|
|
8
|
+
* vectorized operations.
|
|
9
|
+
*/
|
|
10
|
+
export declare class PythonTarget implements LanguageTarget<Expression> {
|
|
11
|
+
/** Whether to include 'import numpy as np' in generated code */
|
|
12
|
+
private includeImports;
|
|
13
|
+
/** Whether to use scipy.special for advanced functions */
|
|
14
|
+
private useScipy;
|
|
15
|
+
constructor(options?: {
|
|
16
|
+
includeImports?: boolean;
|
|
17
|
+
useScipy?: boolean;
|
|
18
|
+
});
|
|
19
|
+
getOperators(): CompiledOperators;
|
|
20
|
+
getFunctions(): CompiledFunctions<Expression>;
|
|
21
|
+
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
22
|
+
/**
|
|
23
|
+
* Compile to Python source code (not executable in JavaScript)
|
|
24
|
+
*
|
|
25
|
+
* Returns Python code as a string. To execute it, use Python runtime.
|
|
26
|
+
*/
|
|
27
|
+
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult;
|
|
28
|
+
/**
|
|
29
|
+
* Compile an expression to Python source code
|
|
30
|
+
*
|
|
31
|
+
* Returns the Python code as a string.
|
|
32
|
+
*/
|
|
33
|
+
compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
|
|
34
|
+
/**
|
|
35
|
+
* Create a complete Python function from an expression
|
|
36
|
+
*
|
|
37
|
+
* @param expr - The expression to compile
|
|
38
|
+
* @param functionName - Name of the Python function
|
|
39
|
+
* @param parameters - Parameter names (e.g., ['x', 'y', 'z'])
|
|
40
|
+
* @param docstring - Optional docstring for the function
|
|
41
|
+
*/
|
|
42
|
+
compileFunction(expr: Expression, functionName: string, parameters: string[], docstring?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Create a vectorized NumPy function from an expression
|
|
45
|
+
*
|
|
46
|
+
* The generated function will work with both scalar values and NumPy arrays.
|
|
47
|
+
*
|
|
48
|
+
* @param expr - The expression to compile
|
|
49
|
+
* @param functionName - Name of the Python function
|
|
50
|
+
* @param parameters - Parameter names
|
|
51
|
+
* @param docstring - Optional docstring
|
|
52
|
+
*/
|
|
53
|
+
compileVectorized(expr: Expression, functionName: string, parameters: string[], docstring?: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Create a lambda function from an expression
|
|
56
|
+
*
|
|
57
|
+
* @param expr - The expression to compile
|
|
58
|
+
* @param parameters - Parameter names
|
|
59
|
+
*/
|
|
60
|
+
compileLambda(expr: Expression, parameters: string[]): string;
|
|
61
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import type { BoxedExpression } from '../global-types';
|
|
1
|
+
/* 0.50.0 */
|
|
3
2
|
/**
|
|
4
3
|
* Source code in the target language
|
|
5
4
|
*/
|
|
@@ -7,7 +6,7 @@ export type TargetSource = string;
|
|
|
7
6
|
/**
|
|
8
7
|
* A compiled function that can be executed
|
|
9
8
|
*/
|
|
10
|
-
export type CompiledFunction = string | ((args: ReadonlyArray<
|
|
9
|
+
export type CompiledFunction<Expr = unknown> = string | ((args: ReadonlyArray<Expr>, compile: (expr: Expr) => TargetSource, target: CompileTarget<Expr>) => TargetSource);
|
|
11
10
|
/**
|
|
12
11
|
* Mapping of operators to their target language representation and precedence
|
|
13
12
|
*/
|
|
@@ -18,17 +17,17 @@ export type CompiledOperators = Record<MathJsonSymbol, [
|
|
|
18
17
|
/**
|
|
19
18
|
* Mapping of function names to their target language implementation
|
|
20
19
|
*/
|
|
21
|
-
export type CompiledFunctions = {
|
|
22
|
-
[id: MathJsonSymbol]: CompiledFunction
|
|
20
|
+
export type CompiledFunctions<Expr = unknown> = {
|
|
21
|
+
[id: MathJsonSymbol]: CompiledFunction<Expr>;
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
24
|
* Target language compilation configuration
|
|
26
25
|
*/
|
|
27
|
-
export interface CompileTarget {
|
|
26
|
+
export interface CompileTarget<Expr = unknown> {
|
|
28
27
|
/** Get operator representation for the target language */
|
|
29
28
|
operators?: (op: MathJsonSymbol) => [op: string, prec: number] | undefined;
|
|
30
29
|
/** Get function implementation for the target language */
|
|
31
|
-
functions?: (id: MathJsonSymbol) => CompiledFunction | undefined;
|
|
30
|
+
functions?: (id: MathJsonSymbol) => CompiledFunction<Expr> | undefined;
|
|
32
31
|
/** Get variable representation for the target language */
|
|
33
32
|
var: (id: MathJsonSymbol) => string | undefined;
|
|
34
33
|
/** Format string literals for the target language */
|
|
@@ -47,26 +46,30 @@ export interface CompileTarget {
|
|
|
47
46
|
/**
|
|
48
47
|
* Base interface for language-specific compilation targets
|
|
49
48
|
*/
|
|
50
|
-
export interface LanguageTarget {
|
|
49
|
+
export interface LanguageTarget<Expr = unknown> {
|
|
51
50
|
/** Get the default operators for this language */
|
|
52
51
|
getOperators(): CompiledOperators;
|
|
53
52
|
/** Get the default functions for this language */
|
|
54
|
-
getFunctions(): CompiledFunctions
|
|
53
|
+
getFunctions(): CompiledFunctions<Expr>;
|
|
55
54
|
/** Create a CompileTarget for this language */
|
|
56
|
-
createTarget(options?: Partial<CompileTarget
|
|
57
|
-
/** Compile an expression to
|
|
58
|
-
|
|
55
|
+
createTarget(options?: Partial<CompileTarget<Expr>>): CompileTarget<Expr>;
|
|
56
|
+
/** Compile an expression to this language */
|
|
57
|
+
compile(expr: Expr, options?: CompilationOptions<Expr>): CompilationResult;
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
61
60
|
* Options for compilation
|
|
62
61
|
*/
|
|
63
|
-
export interface CompilationOptions {
|
|
62
|
+
export interface CompilationOptions<Expr = unknown> {
|
|
64
63
|
/**
|
|
65
64
|
* Target language for compilation.
|
|
66
65
|
*
|
|
67
66
|
* Built-in targets:
|
|
68
67
|
* - `'javascript'` (default) - Compile to JavaScript
|
|
69
68
|
* - `'glsl'` - Compile to GLSL (OpenGL Shading Language)
|
|
69
|
+
* - `'wgsl'` - Compile to WGSL (WebGPU Shading Language)
|
|
70
|
+
* - `'interval-js'` - Compile to JavaScript with interval arithmetic
|
|
71
|
+
* - `'interval-glsl'` - Compile to GLSL with interval arithmetic
|
|
72
|
+
* - `'interval-wgsl'` - Compile to WGSL with interval arithmetic
|
|
70
73
|
*
|
|
71
74
|
* Custom targets can be registered using `ce.registerCompilationTarget()`.
|
|
72
75
|
*
|
|
@@ -99,7 +102,7 @@ export interface CompilationOptions {
|
|
|
99
102
|
* const code = expr.compile({ target: customTarget });
|
|
100
103
|
* ```
|
|
101
104
|
*/
|
|
102
|
-
target?: CompileTarget
|
|
105
|
+
target?: CompileTarget<Expr>;
|
|
103
106
|
/**
|
|
104
107
|
* Custom operator mappings. Can be:
|
|
105
108
|
* - A partial object mapping operator names to [operator, precedence] tuples
|
|
@@ -128,13 +131,15 @@ export interface CompilationOptions {
|
|
|
128
131
|
preamble?: string;
|
|
129
132
|
}
|
|
130
133
|
/**
|
|
131
|
-
*
|
|
134
|
+
* Result of compiling an expression
|
|
132
135
|
*/
|
|
133
|
-
export interface
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
|
|
136
|
+
export interface CompilationResult {
|
|
137
|
+
/** Target language name */
|
|
138
|
+
target: string;
|
|
139
|
+
/** Whether compilation succeeded (vs falling back to interpretation) */
|
|
140
|
+
success: boolean;
|
|
141
|
+
/** Generated source code */
|
|
142
|
+
code: string;
|
|
143
|
+
/** Executable function (present for JS-executable targets only) */
|
|
144
|
+
run?: (...args: number[]) => number;
|
|
140
145
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { CompiledFunctions } from './types';
|
|
3
|
+
import { GPUShaderTarget } from './gpu-target';
|
|
4
|
+
/**
|
|
5
|
+
* WGSL (WebGPU Shading Language) compilation target.
|
|
6
|
+
*
|
|
7
|
+
* Extends the shared GPU base class with WGSL-specific function names,
|
|
8
|
+
* `fn` declaration syntax, and `@vertex`/`@fragment`/`@compute` shader
|
|
9
|
+
* structure with struct-based I/O.
|
|
10
|
+
*/
|
|
11
|
+
export declare class WGSLTarget extends GPUShaderTarget {
|
|
12
|
+
protected readonly languageId = "wgsl";
|
|
13
|
+
protected getLanguageSpecificFunctions(): CompiledFunctions<Expression>;
|
|
14
|
+
compileFunction(expr: Expression, functionName: string, returnType: string, parameters: Array<[name: string, type: string]>): string;
|
|
15
|
+
compileShader(options: {
|
|
16
|
+
type: 'vertex' | 'fragment' | 'compute';
|
|
17
|
+
inputs?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
location?: number;
|
|
21
|
+
builtin?: string;
|
|
22
|
+
}>;
|
|
23
|
+
outputs?: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
location?: number;
|
|
27
|
+
builtin?: string;
|
|
28
|
+
}>;
|
|
29
|
+
uniforms?: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
group?: number;
|
|
33
|
+
binding?: number;
|
|
34
|
+
}>;
|
|
35
|
+
workgroupSize?: [number, number?, number?];
|
|
36
|
+
body: Array<{
|
|
37
|
+
variable: string;
|
|
38
|
+
expression: Expression;
|
|
39
|
+
}>;
|
|
40
|
+
}): string;
|
|
41
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.50.0 */
|
|
2
2
|
/**
|
|
3
3
|
* The default cost function, used to determine if a new expression is simpler
|
|
4
4
|
* than the old one.
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
* to the `simplify` function.
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
|
-
export declare function costFunction(expr:
|
|
12
|
-
export declare function leafCount(expr:
|
|
11
|
+
export declare function costFunction(expr: Expression): number;
|
|
12
|
+
export declare function leafCount(expr: Expression): number;
|
|
13
13
|
export declare const DEFAULT_COST_FUNCTION: typeof costFunction;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { MathJsonSymbol } from '../math-json/types';
|
|
3
|
+
export declare function ask(ce: IComputeEngine, pattern: Expression): BoxedSubstitution[];
|
|
4
|
+
export declare function verify(ce: IComputeEngine, query: Expression): boolean | undefined;
|
|
5
|
+
export declare function assumeFn(ce: IComputeEngine, predicate: Expression): AssumeResult;
|
|
6
|
+
export declare function forget(ce: IComputeEngine, symbol: undefined | MathJsonSymbol | MathJsonSymbol[]): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
export type CommonSymbolTable = {
|
|
3
|
+
[symbol: string]: null | Expression;
|
|
4
|
+
};
|
|
5
|
+
export declare function initializeCommonSymbols(engine: ComputeEngine, commonSymbols: CommonSymbolTable): void;
|
|
6
|
+
export declare function resetCommonSymbols(commonSymbols: CommonSymbolTable): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import type { LanguageTarget } from './compilation/types';
|
|
3
|
+
/**
|
|
4
|
+
* Internal registry for compilation targets.
|
|
5
|
+
*
|
|
6
|
+
* Keeps compilation target registration concerns out of ComputeEngine.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class CompilationTargetRegistry {
|
|
11
|
+
private readonly _targets;
|
|
12
|
+
register(name: string, target: LanguageTarget<Expression>): void;
|
|
13
|
+
get(name: string): LanguageTarget<Expression> | undefined;
|
|
14
|
+
list(): string[];
|
|
15
|
+
unregister(name: string): void;
|
|
16
|
+
registerDefaults(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
type ResetHooks = {
|
|
3
|
+
refreshNumericConstants: () => void;
|
|
4
|
+
resetCommonSymbols: () => void;
|
|
5
|
+
purgeCaches: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare class EngineConfigurationLifecycle {
|
|
8
|
+
private _generation;
|
|
9
|
+
private _tracker;
|
|
10
|
+
get generation(): number;
|
|
11
|
+
set generation(value: number);
|
|
12
|
+
reset(hooks: ResetHooks): void;
|
|
13
|
+
listen(listener: ConfigurationChangeListener): () => void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* 0.50.0 */
|
|
2
|
+
import { BoxedType } from '../common/type/boxed-type';
|
|
3
|
+
import type { MathJsonSymbol } from '../math-json/types';
|
|
4
|
+
import type { ValueDefinition, OperatorDefinition, AssignValue, Expression, BoxedDefinition, SymbolDefinition, IComputeEngine, Scope } from './global-types';
|
|
5
|
+
export declare function lookupDefinition(ce: IComputeEngine, id: MathJsonSymbol): undefined | BoxedDefinition;
|
|
6
|
+
export declare function declareSymbolValue(ce: IComputeEngine, name: MathJsonSymbol, def: Partial<ValueDefinition>, scope?: Scope): BoxedDefinition;
|
|
7
|
+
export declare function declareSymbolOperator(ce: IComputeEngine, name: string, def: OperatorDefinition, scope?: Scope): BoxedDefinition;
|
|
8
|
+
export declare function getSymbolValue(ce: IComputeEngine, id: MathJsonSymbol): Expression | undefined;
|
|
9
|
+
export declare function setSymbolValue(ce: IComputeEngine, id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
10
|
+
export declare function setCurrentContextValue(ce: IComputeEngine, id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
11
|
+
export declare function declareType(ce: IComputeEngine, name: string, type: BoxedType | Type | TypeString, { alias }?: {
|
|
12
|
+
alias?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function declareFn(ce: IComputeEngine, arg1: string | {
|
|
15
|
+
[id: string]: Type | TypeString | Partial<SymbolDefinition>;
|
|
16
|
+
}, arg2?: Type | TypeString | Partial<SymbolDefinition>, scope?: Scope): IComputeEngine;
|
|
17
|
+
export declare function assignFn(ce: IComputeEngine, arg1: string | {
|
|
18
|
+
[id: string]: AssignValue;
|
|
19
|
+
}, arg2?: AssignValue): IComputeEngine;
|