@cortex-js/compute-engine 0.50.2 → 0.51.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compute-engine.esm.js +7900 -267
- package/dist/compute-engine.min.esm.js +490 -65
- package/dist/compute-engine.min.umd.js +490 -65
- package/dist/compute-engine.umd.js +7900 -267
- 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/color/categorical.d.ts +16 -0
- package/dist/types/color/contrast.d.ts +16 -0
- package/dist/types/color/conversion.d.ts +13 -0
- package/dist/types/color/diverging-palettes.d.ts +15 -0
- package/dist/types/color/index.d.ts +4 -0
- package/dist/types/color/manipulation.d.ts +95 -0
- package/dist/types/color/palette.d.ts +68 -0
- package/dist/types/color/sequential.d.ts +21 -0
- package/dist/types/color/types.d.ts +19 -0
- 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 +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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/product.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 +1 -1
- 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/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
- 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 +37 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +40 -1
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +7 -1
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +291 -3
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +30 -3
- 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 +15 -9
- 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 +2 -2
- 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 +26 -1
- package/dist/types/compute-engine/interval/index.d.ts +11 -5
- package/dist/types/compute-engine/interval/trigonometric.d.ts +16 -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 +23 -0
- 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 +22 -0
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +59 -2
- 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 +2 -0
- 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 +37 -0
- 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 +8 -0
- package/dist/types/compute-engine/library/units.d.ts +9 -0
- 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 +15 -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 +128 -0
- 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 +4 -2
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +33 -0
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
2
2
|
export declare function canonicalForm(expr: Expression, forms: CanonicalOptions, scope?: Scope): Expression;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
2
2
|
export declare function choose(n: number, k: number): number;
|
|
3
3
|
/** Attempt to transform the expression (h, ops) into a sum */
|
|
4
4
|
export declare function expandFunction(ce: ComputeEngine, h: string, ops: ReadonlyArray<Expression>): Expression | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
2
2
|
export declare function isPrime(expr: Expression): boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.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,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
2
2
|
import type { CompileTarget, TargetSource } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Base compiler class containing language-agnostic compilation logic
|
|
@@ -16,10 +16,46 @@ export declare class BaseCompiler {
|
|
|
16
16
|
* Compile a block expression
|
|
17
17
|
*/
|
|
18
18
|
private static compileBlock;
|
|
19
|
+
/**
|
|
20
|
+
* Compile a Loop expression with Element(index, Range(lo, hi)) indexing.
|
|
21
|
+
* Generates: (() => { for (let i = lo; i <= hi; i++) { body } })()
|
|
22
|
+
*
|
|
23
|
+
* The loop counter is always a raw number. For targets that wrap numeric
|
|
24
|
+
* values (e.g. interval-js wraps with `_IA.point()`), references to the
|
|
25
|
+
* loop index inside the body are wrapped via `target.number`.
|
|
26
|
+
*/
|
|
27
|
+
private static compileForLoop;
|
|
28
|
+
/**
|
|
29
|
+
* Compile a loop body expression as statements (not wrapped in IIFE).
|
|
30
|
+
* Handles Break, Continue, Return as statements, and If as if-else when
|
|
31
|
+
* branches contain control flow.
|
|
32
|
+
*/
|
|
33
|
+
private static compileLoopBody;
|
|
34
|
+
/**
|
|
35
|
+
* Create a target that compiles conditions as plain JS booleans.
|
|
36
|
+
* Used inside `compileLoopBody` so that `if (cond)` gets a real boolean,
|
|
37
|
+
* not an interval result object (which would always be truthy).
|
|
38
|
+
*
|
|
39
|
+
* Overrides comparison and logical operators to use plain JS, and
|
|
40
|
+
* numeric values/variables to use raw numbers (the loop counter is
|
|
41
|
+
* already a plain number).
|
|
42
|
+
*/
|
|
43
|
+
private static scalarConditionTarget;
|
|
19
44
|
/**
|
|
20
45
|
* Compile loop constructs (Sum/Product)
|
|
21
46
|
*/
|
|
22
47
|
private static compileLoop;
|
|
48
|
+
/**
|
|
49
|
+
* Determine at compile time whether an expression produces a complex value.
|
|
50
|
+
*
|
|
51
|
+
* Rules:
|
|
52
|
+
* - Numbers: complex if im !== 0
|
|
53
|
+
* - Symbols: ImaginaryUnit is complex; others use expr.isReal
|
|
54
|
+
* (undefined is treated as real -- assume-real policy)
|
|
55
|
+
* - Functions: Abs, Arg, Re, Im always return real.
|
|
56
|
+
* All others: complex if any operand is complex.
|
|
57
|
+
*/
|
|
58
|
+
static isComplexValued(expr: Expression): boolean;
|
|
23
59
|
/**
|
|
24
60
|
* Generate a temporary variable name
|
|
25
61
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.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.
|
|
@@ -13,8 +13,47 @@ export declare const GPU_OPERATORS: CompiledOperators;
|
|
|
13
13
|
* Both languages share identical built-in math functions. Language-specific
|
|
14
14
|
* functions (inversesqrt naming, mod, vector constructors) are provided
|
|
15
15
|
* by subclass overrides.
|
|
16
|
+
*
|
|
17
|
+
* Complex numbers are represented as vec2(re, im). Functions that can
|
|
18
|
+
* operate on complex values check `BaseCompiler.isComplexValued()` and
|
|
19
|
+
* dispatch to `_gpu_c*` helper functions from the complex preamble.
|
|
16
20
|
*/
|
|
17
21
|
export declare const GPU_FUNCTIONS: CompiledFunctions<Expression>;
|
|
22
|
+
/**
|
|
23
|
+
* Compile a Matrix expression to GPU-native types when possible.
|
|
24
|
+
*
|
|
25
|
+
* Handles two optimizations:
|
|
26
|
+
* - Column vectors (Nx1): flatten to vecN instead of nested single-element arrays
|
|
27
|
+
* - Square matrices (NxN, N=2,3,4): use native matN types with column-major transposition
|
|
28
|
+
*
|
|
29
|
+
* Falls back to compiling the nested List structure for other shapes.
|
|
30
|
+
*/
|
|
31
|
+
export declare function compileGPUMatrix(args: ReadonlyArray<Expression>, compile: (expr: Expression) => string, vecFn: (n: number) => string, matFn: (n: number) => string, arrayFn: (n: number) => string): string;
|
|
32
|
+
/**
|
|
33
|
+
* GPU gamma function using Lanczos approximation (g=7, n=9 coefficients).
|
|
34
|
+
*
|
|
35
|
+
* Uses reflection formula for z < 0.5 and Lanczos for z >= 0.5.
|
|
36
|
+
* Valid for both GLSL and WGSL (uses standard math builtins).
|
|
37
|
+
*/
|
|
38
|
+
export declare const GPU_GAMMA_PREAMBLE = "\nfloat _gpu_gamma(float z) {\n const float PI = 3.14159265358979;\n if (z < 0.5) {\n return PI / (sin(PI * z) * _gpu_gamma(1.0 - z));\n }\n z -= 1.0;\n float x = 0.99999999999980993;\n x += 676.5203681218851 / (z + 1.0);\n x += -1259.1392167224028 / (z + 2.0);\n x += 771.32342877765313 / (z + 3.0);\n x += -176.61502916214059 / (z + 4.0);\n x += 12.507343278686905 / (z + 5.0);\n x += -0.13857109526572012 / (z + 6.0);\n x += 9.9843695780195716e-6 / (z + 7.0);\n x += 1.5056327351493116e-7 / (z + 8.0);\n float t = z + 7.5;\n return sqrt(2.0 * PI) * pow(t, z + 0.5) * exp(-t) * x;\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
|
+
/**
|
|
40
|
+
* GPU error function using Abramowitz & Stegun approximation.
|
|
41
|
+
* Maximum error: |epsilon(x)| <= 1.5e-7.
|
|
42
|
+
*/
|
|
43
|
+
export declare const GPU_ERF_PREAMBLE = "\nfloat _gpu_erf(float x) {\n float ax = abs(x);\n float t = 1.0 / (1.0 + 0.3275911 * ax);\n float y = ((((1.061405429 * t - 1.453152027) * t + 1.421413741) * t - 0.284496736) * t + 0.254829592) * t;\n float result = 1.0 - y * exp(-ax * ax);\n return x < 0.0 ? -result : result;\n}\n\nfloat _gpu_erfinv(float x) {\n float pi = 3.14159265358979;\n float x2 = x * x;\n float x3 = x * x2;\n float x5 = x3 * x2;\n float x7 = x5 * x2;\n float x9 = x7 * x2;\n return sqrt(pi) * 0.5 * (x + (pi / 12.0) * x3 + (7.0 * pi * pi / 480.0) * x5 + (127.0 * pi * pi * pi / 40320.0) * x7 + (4369.0 * pi * pi * pi * pi / 5806080.0) * x9);\n}\n";
|
|
44
|
+
/**
|
|
45
|
+
* GPU color space conversion preamble (GLSL syntax).
|
|
46
|
+
*
|
|
47
|
+
* Provides sRGB ↔ OKLab ↔ OKLCh conversions, color mixing in OKLCh
|
|
48
|
+
* with shorter-arc hue interpolation, and APCA contrast calculation.
|
|
49
|
+
*
|
|
50
|
+
* WGSL targets must adapt syntax (vec3f, atan2→atan2, etc.).
|
|
51
|
+
*/
|
|
52
|
+
export declare const GPU_COLOR_PREAMBLE_GLSL = "\nfloat _gpu_srgb_to_linear(float c) {\n if (c <= 0.04045) return c / 12.92;\n return pow((c + 0.055) / 1.055, 2.4);\n}\n\nfloat _gpu_linear_to_srgb(float c) {\n if (c <= 0.0031308) return 12.92 * c;\n return 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\n\nvec3 _gpu_srgb_to_oklab(vec3 rgb) {\n float r = _gpu_srgb_to_linear(rgb.x);\n float g = _gpu_srgb_to_linear(rgb.y);\n float b = _gpu_srgb_to_linear(rgb.z);\n float l_ = pow(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b, 1.0 / 3.0);\n float m_ = pow(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b, 1.0 / 3.0);\n float s_ = pow(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b, 1.0 / 3.0);\n return vec3(\n 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,\n 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,\n 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_\n );\n}\n\nvec3 _gpu_oklab_to_srgb(vec3 lab) {\n float l_ = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;\n float m_ = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;\n float s_ = lab.x - 0.0894841775 * lab.y - 1.291485548 * lab.z;\n float l = l_ * l_ * l_;\n float m = m_ * m_ * m_;\n float s = s_ * s_ * s_;\n float r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;\n float g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;\n float b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;\n return clamp(vec3(_gpu_linear_to_srgb(r), _gpu_linear_to_srgb(g), _gpu_linear_to_srgb(b)), 0.0, 1.0);\n}\n\nvec3 _gpu_oklab_to_oklch(vec3 lab) {\n float C = length(lab.yz);\n float H = atan(lab.z, lab.y);\n return vec3(lab.x, C, H);\n}\n\nvec3 _gpu_oklch_to_oklab(vec3 lch) {\n return vec3(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n}\n\nvec3 _gpu_color_mix(vec3 rgb1, vec3 rgb2, float t) {\n vec3 lch1 = _gpu_oklab_to_oklch(_gpu_srgb_to_oklab(rgb1));\n vec3 lch2 = _gpu_oklab_to_oklch(_gpu_srgb_to_oklab(rgb2));\n float L = mix(lch1.x, lch2.x, t);\n float C = mix(lch1.y, lch2.y, t);\n float dh = lch2.z - lch1.z;\n const float PI = 3.14159265359;\n if (dh > PI) dh -= 2.0 * PI;\n if (dh < -PI) dh += 2.0 * PI;\n float H = lch1.z + dh * t;\n return _gpu_oklab_to_srgb(_gpu_oklch_to_oklab(vec3(L, C, H)));\n}\n\nfloat _gpu_apca(vec3 bg, vec3 fg) {\n float bgR = _gpu_srgb_to_linear(bg.x);\n float bgG = _gpu_srgb_to_linear(bg.y);\n float bgB = _gpu_srgb_to_linear(bg.z);\n float fgR = _gpu_srgb_to_linear(fg.x);\n float fgG = _gpu_srgb_to_linear(fg.y);\n float fgB = _gpu_srgb_to_linear(fg.z);\n float bgY = 0.2126729 * bgR + 0.7151522 * bgG + 0.0721750 * bgB;\n float fgY = 0.2126729 * fgR + 0.7151522 * fgG + 0.0721750 * fgB;\n float bgC = pow(bgY, 0.56);\n float fgC = pow(fgY, 0.57);\n float contrast = (bgC > fgC)\n ? (bgC - fgC) * 1.14\n : (bgC - fgC) * 1.14;\n return contrast * 100.0;\n}\n";
|
|
53
|
+
/**
|
|
54
|
+
* GPU color space conversion preamble (WGSL syntax).
|
|
55
|
+
*/
|
|
56
|
+
export declare const GPU_COLOR_PREAMBLE_WGSL = "\nfn _gpu_srgb_to_linear(c: f32) -> f32 {\n if (c <= 0.04045) { return c / 12.92; }\n return pow((c + 0.055) / 1.055, 2.4);\n}\n\nfn _gpu_linear_to_srgb(c: f32) -> f32 {\n if (c <= 0.0031308) { return 12.92 * c; }\n return 1.055 * pow(c, 1.0 / 2.4) - 0.055;\n}\n\nfn _gpu_srgb_to_oklab(rgb: vec3f) -> vec3f {\n let r = _gpu_srgb_to_linear(rgb.x);\n let g = _gpu_srgb_to_linear(rgb.y);\n let b = _gpu_srgb_to_linear(rgb.z);\n let l_ = pow(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b, 1.0 / 3.0);\n let m_ = pow(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b, 1.0 / 3.0);\n let s_ = pow(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b, 1.0 / 3.0);\n return vec3f(\n 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_,\n 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_,\n 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_\n );\n}\n\nfn _gpu_oklab_to_srgb(lab: vec3f) -> vec3f {\n let l_ = lab.x + 0.3963377774 * lab.y + 0.2158037573 * lab.z;\n let m_ = lab.x - 0.1055613458 * lab.y - 0.0638541728 * lab.z;\n let s_ = lab.x - 0.0894841775 * lab.y - 1.291485548 * lab.z;\n let l = l_ * l_ * l_;\n let m = m_ * m_ * m_;\n let s = s_ * s_ * s_;\n let r = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;\n let g = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;\n let b = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;\n return clamp(vec3f(_gpu_linear_to_srgb(r), _gpu_linear_to_srgb(g), _gpu_linear_to_srgb(b)), vec3f(0.0), vec3f(1.0));\n}\n\nfn _gpu_oklab_to_oklch(lab: vec3f) -> vec3f {\n let C = length(lab.yz);\n let H = atan2(lab.z, lab.y);\n return vec3f(lab.x, C, H);\n}\n\nfn _gpu_oklch_to_oklab(lch: vec3f) -> vec3f {\n return vec3f(lch.x, lch.y * cos(lch.z), lch.y * sin(lch.z));\n}\n\nfn _gpu_color_mix(rgb1: vec3f, rgb2: vec3f, t: f32) -> vec3f {\n let lch1 = _gpu_oklab_to_oklch(_gpu_srgb_to_oklab(rgb1));\n let lch2 = _gpu_oklab_to_oklch(_gpu_srgb_to_oklab(rgb2));\n let L = mix(lch1.x, lch2.x, t);\n let C = mix(lch1.y, lch2.y, t);\n let PI = 3.14159265359;\n var dh = lch2.z - lch1.z;\n if (dh > PI) { dh -= 2.0 * PI; }\n if (dh < -PI) { dh += 2.0 * PI; }\n let H = lch1.z + dh * t;\n return _gpu_oklab_to_srgb(_gpu_oklch_to_oklab(vec3f(L, C, H)));\n}\n\nfn _gpu_apca(bg: vec3f, fg: vec3f) -> f32 {\n let bgR = _gpu_srgb_to_linear(bg.x);\n let bgG = _gpu_srgb_to_linear(bg.y);\n let bgB = _gpu_srgb_to_linear(bg.z);\n let fgR = _gpu_srgb_to_linear(fg.x);\n let fgG = _gpu_srgb_to_linear(fg.y);\n let fgB = _gpu_srgb_to_linear(fg.z);\n let bgY = 0.2126729 * bgR + 0.7151522 * bgG + 0.0721750 * bgB;\n let fgY = 0.2126729 * fgR + 0.7151522 * fgG + 0.0721750 * fgB;\n let bgC = pow(bgY, 0.56);\n let fgC = pow(fgY, 0.57);\n let contrast = (bgC - fgC) * 1.14;\n return contrast * 100.0;\n}\n";
|
|
18
57
|
/**
|
|
19
58
|
* Abstract base class for GPU shader compilation targets.
|
|
20
59
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.51.1 */
|
|
2
2
|
* JavaScript interval arithmetic compilation target
|
|
3
3
|
*
|
|
4
4
|
* Compiles mathematical expressions to JavaScript code using interval arithmetic
|
|
@@ -54,7 +54,10 @@ export declare class ComputeEngineIntervalFunction extends Function {
|
|
|
54
54
|
max: typeof import("../interval").max;
|
|
55
55
|
mod: typeof import("../interval").mod;
|
|
56
56
|
remainder: typeof import("../interval").remainder;
|
|
57
|
+
heaviside: typeof import("../interval").heaviside;
|
|
57
58
|
sign: typeof import("../interval").sign;
|
|
59
|
+
gamma: typeof import("../interval").gamma;
|
|
60
|
+
gammaln: typeof import("../interval").gammaln;
|
|
58
61
|
sin: typeof import("../interval").sin;
|
|
59
62
|
cos: typeof import("../interval").cos;
|
|
60
63
|
tan: typeof import("../interval").tan;
|
|
@@ -80,6 +83,9 @@ export declare class ComputeEngineIntervalFunction extends Function {
|
|
|
80
83
|
acoth: typeof import("../interval").acoth;
|
|
81
84
|
acsch: typeof import("../interval").acsch;
|
|
82
85
|
asech: typeof import("../interval").asech;
|
|
86
|
+
sinc: typeof import("../interval").sinc;
|
|
87
|
+
fresnelS: typeof import("../interval").fresnelS;
|
|
88
|
+
fresnelC: typeof import("../interval").fresnelC;
|
|
83
89
|
less: typeof import("../interval").less;
|
|
84
90
|
lessEqual: typeof import("../interval").lessEqual;
|
|
85
91
|
greater: typeof import("../interval").greater;
|