@cortex-js/compute-engine 0.52.1 → 0.53.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/dist/compute-engine.esm.js +822 -3509
- package/dist/compute-engine.min.esm.js +94 -2343
- package/dist/compute-engine.min.umd.js +94 -2343
- package/dist/compute-engine.umd.js +772 -3459
- 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 +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 +6 -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 +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +2 -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 +9 -10
- 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 +8 -4
- 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 +2 -2
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +3 -3
- 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 +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/stochastic-equal.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 +1 -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 +13 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +3 -9
- 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 -2
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +2 -2
- 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 -4
- 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 +3 -3
- package/dist/types/compute-engine/function-utils.d.ts +34 -15
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +5 -26
- 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-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/fractals.d.ts +2 -0
- 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 +6 -7
- package/dist/types/compute-engine/types-engine.d.ts +1 -9
- package/dist/types/compute-engine/types-evaluation.d.ts +2 -2
- package/dist/types/compute-engine/types-expression.d.ts +50 -6
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +5 -8
- 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 +1 -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 +18 -18
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +0 -51
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +0 -54
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
import type { OneOf } from '../common/one-of';
|
|
3
3
|
import type { MathJsonSymbol, MathJsonNumberObject } from '../math-json';
|
|
4
4
|
import type { Type, TypeString, TypeResolver } from '../common/type/types';
|
|
@@ -219,16 +219,8 @@ export interface IComputeEngine extends IBigNum {
|
|
|
219
219
|
* Use `ce.assign(id, value)` instead.
|
|
220
220
|
* @internal */
|
|
221
221
|
_setSymbolValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
222
|
-
/**
|
|
223
|
-
* Set a value directly in the current context's values map.
|
|
224
|
-
* Used for assumptions so values are properly scoped.
|
|
225
|
-
* @internal */
|
|
226
|
-
_setCurrentContextValue(id: MathJsonSymbol, value: Expression | boolean | number | undefined): void;
|
|
227
222
|
/** A list of the function calls to the current evaluation context */
|
|
228
223
|
trace: ReadonlyArray<string>;
|
|
229
|
-
lookupContext(id: MathJsonSymbol): undefined | EvalContext;
|
|
230
|
-
/** @internal */
|
|
231
|
-
_swapContext(context: EvalContext): void;
|
|
232
224
|
lookupDefinition(id: MathJsonSymbol): undefined | BoxedDefinition;
|
|
233
225
|
assign(ids: {
|
|
234
226
|
[id: MathJsonSymbol]: AssignValue;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
import type { IComputeEngine as ComputeEngine } from './types-engine';
|
|
3
3
|
import type { Expression, ExpressionInput } from './types-expression';
|
|
4
4
|
import type { Assumption as KernelAssumption, AssumeResult, AssignValue as KernelAssignValue, BoxedRule as KernelBoxedRule, BoxedRuleSet as KernelBoxedRuleSet, EvaluateOptions as KernelEvaluateOptions, EvalContext as KernelEvalContext, ExpressionMapInterface as KernelExpressionMapInterface, Rule as KernelRule, RuleConditionFunction as KernelRuleConditionFunction, RuleFunction as KernelRuleFunction, RuleReplaceFunction as KernelRuleReplaceFunction, RuleStep as KernelRuleStep, RuleSteps as KernelRuleSteps, Scope as KernelScope } from './types-kernel-evaluation';
|
|
@@ -10,7 +10,7 @@ export type { AssumeResult };
|
|
|
10
10
|
*
|
|
11
11
|
* @category Boxed Expression
|
|
12
12
|
*/
|
|
13
|
-
export type EvaluateOptions = KernelEvaluateOptions
|
|
13
|
+
export type EvaluateOptions = KernelEvaluateOptions;
|
|
14
14
|
/**
|
|
15
15
|
* Map-like interface keyed by boxed expressions.
|
|
16
16
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
import type { OneOf } from '../common/one-of';
|
|
3
3
|
import type { MathJsonExpression, MathJsonNumberObject, MathJsonStringObject, MathJsonSymbolObject, MathJsonFunctionObject, MathJsonSymbol, MathJsonDictionaryObject } from '../math-json';
|
|
4
4
|
import type { Type, TypeString } from '../common/type/types';
|
|
@@ -47,7 +47,7 @@ interface BoxedBaseDefinition extends Partial<BaseDefinition> {
|
|
|
47
47
|
}
|
|
48
48
|
interface BoxedValueDefinition extends BoxedBaseDefinition {
|
|
49
49
|
holdUntil: 'never' | 'evaluate' | 'N';
|
|
50
|
-
|
|
50
|
+
value: Expression | undefined;
|
|
51
51
|
eq?: (a: Expression) => boolean | undefined;
|
|
52
52
|
neq?: (a: Expression) => boolean | undefined;
|
|
53
53
|
cmp?: (a: Expression) => '=' | '>' | '<' | undefined;
|
|
@@ -103,7 +103,7 @@ type BoxedDefinition = {
|
|
|
103
103
|
operator: BoxedOperatorDefinition;
|
|
104
104
|
};
|
|
105
105
|
type Scope = KernelScope<BoxedDefinition>;
|
|
106
|
-
type EvaluateOptions = KernelEvaluateOptions
|
|
106
|
+
type EvaluateOptions = KernelEvaluateOptions;
|
|
107
107
|
type Rule = KernelRule<Expression, ExpressionInput, ExpressionComputeEngine>;
|
|
108
108
|
type BoxedRule = KernelBoxedRule<Expression, ExpressionComputeEngine>;
|
|
109
109
|
type BoxedRuleSet = KernelBoxedRuleSet<Expression, ExpressionComputeEngine>;
|
|
@@ -868,6 +868,44 @@ export interface Expression {
|
|
|
868
868
|
* Return this expression expressed as a numerator and denominator.
|
|
869
869
|
*/
|
|
870
870
|
get numeratorDenominator(): [Expression, Expression];
|
|
871
|
+
/**
|
|
872
|
+
* Return the value of this expression as a pair of integer numerator and
|
|
873
|
+
* denominator, or `null` if the expression is not a rational number.
|
|
874
|
+
*
|
|
875
|
+
* - For a `BoxedNumber` with an exact rational value, extracts from the
|
|
876
|
+
* numeric representation.
|
|
877
|
+
* - For an integer, returns `[n, 1]`.
|
|
878
|
+
* - For a `Divide` or `Rational` function with integer operands, returns
|
|
879
|
+
* `[num, den]`.
|
|
880
|
+
* - For everything else, returns `null`.
|
|
881
|
+
*
|
|
882
|
+
* The returned rational is always in lowest terms.
|
|
883
|
+
*
|
|
884
|
+
* ```typescript
|
|
885
|
+
* ce.parse('\\frac{6}{4}').toRational() // [3, 2]
|
|
886
|
+
* ce.parse('7').toRational() // [7, 1]
|
|
887
|
+
* ce.parse('x + 1').toRational() // null
|
|
888
|
+
* ce.number(1.5).toRational() // null (machine float)
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
toRational(): [number, number] | null;
|
|
892
|
+
/**
|
|
893
|
+
* Return the multiplicative factors of this expression as a flat array.
|
|
894
|
+
*
|
|
895
|
+
* This is a structural decomposition — it does not perform algebraic
|
|
896
|
+
* factoring (use `ce.function('Factor', [expr])` for that).
|
|
897
|
+
*
|
|
898
|
+
* - `Multiply(a, b, c)` returns `[a, b, c]`
|
|
899
|
+
* - `Negate(x)` returns `[-1, ...x.factors()]`
|
|
900
|
+
* - Anything else returns `[expr]`
|
|
901
|
+
*
|
|
902
|
+
* ```typescript
|
|
903
|
+
* ce.parse('2xyz').factors() // [2, x, y, z]
|
|
904
|
+
* ce.parse('-3x').factors() // [-1, 3, x]
|
|
905
|
+
* ce.parse('x + 1').factors() // [x + 1]
|
|
906
|
+
* ```
|
|
907
|
+
*/
|
|
908
|
+
factors(): ReadonlyArray<Expression>;
|
|
871
909
|
/**
|
|
872
910
|
* The name of the operator of the expression.
|
|
873
911
|
*
|
|
@@ -1000,14 +1038,15 @@ export interface Expression {
|
|
|
1000
1038
|
isSame(rhs: Expression | number | bigint | boolean | string): boolean;
|
|
1001
1039
|
/**
|
|
1002
1040
|
* Smart equality check: structural first, then numeric evaluation fallback.
|
|
1041
|
+
* Symmetric: `a.is(b)` always equals `b.is(a)`.
|
|
1003
1042
|
*
|
|
1004
1043
|
* First tries an exact structural check (same as `isSame()`). If that fails
|
|
1005
1044
|
* and the expression is constant (no free variables), evaluates numerically
|
|
1006
1045
|
* and compares within `engine.tolerance`.
|
|
1007
1046
|
*
|
|
1008
|
-
* For literal numbers (`
|
|
1009
|
-
* no tolerance is applied. Tolerance only
|
|
1010
|
-
* require evaluation (e.g., `\\sin(\\pi)`).
|
|
1047
|
+
* For literal numbers compared to primitives (`number`, `bigint`), behaves
|
|
1048
|
+
* identically to `isSame()` — no tolerance is applied. Tolerance only
|
|
1049
|
+
* applies to expressions that require evaluation (e.g., `\\sin(\\pi)`).
|
|
1011
1050
|
*
|
|
1012
1051
|
* ```typescript
|
|
1013
1052
|
* ce.parse('\\cos(\\frac{\\pi}{2})').is(0) // true — evaluates, within tolerance
|
|
@@ -1016,6 +1055,11 @@ export interface Expression {
|
|
|
1016
1055
|
* ce.parse('\\pi').is(3.14, 0.01) // true — within custom tolerance
|
|
1017
1056
|
* ```
|
|
1018
1057
|
*
|
|
1058
|
+
* After the structural check, attempts to expand both sides (distributing
|
|
1059
|
+
* products, applying the multinomial theorem, etc.) and re-checks
|
|
1060
|
+
* structural equality. This catches equivalences like `(x+1)^2` vs
|
|
1061
|
+
* `x^2+2x+1` even when the expression has free variables.
|
|
1062
|
+
*
|
|
1019
1063
|
* @param tolerance - If provided, overrides `engine.tolerance` for the
|
|
1020
1064
|
* numeric comparison. Has no effect when the comparison is structural
|
|
1021
1065
|
* (i.e., when `isSame()` succeeds or the expression has free variables).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
import type { TypeReference } from '../common/type/types';
|
|
3
3
|
import type { BoxedType } from '../common/type/boxed-type';
|
|
4
4
|
import type { LatexString } from './latex-syntax/types';
|
|
@@ -43,7 +43,7 @@ export type AssumeResult = 'internal-error' | 'not-a-predicate' | 'contradiction
|
|
|
43
43
|
*
|
|
44
44
|
* @category Boxed Expression
|
|
45
45
|
*/
|
|
46
|
-
export type EvaluateOptions
|
|
46
|
+
export type EvaluateOptions = {
|
|
47
47
|
/**
|
|
48
48
|
* If `true`, the evaluation returns a numeric approximation of the expression,
|
|
49
49
|
* when possible.
|
|
@@ -69,10 +69,6 @@ export type EvaluateOptions<Expr = unknown> = {
|
|
|
69
69
|
materialization: boolean | number | [number, number];
|
|
70
70
|
/** Cancellation signal for long-running evaluations. */
|
|
71
71
|
signal: AbortSignal;
|
|
72
|
-
/**
|
|
73
|
-
* Temporary named argument bindings used while evaluating this expression.
|
|
74
|
-
*/
|
|
75
|
-
withArguments: Record<MathJsonSymbol, Expr>;
|
|
76
72
|
};
|
|
77
73
|
/**
|
|
78
74
|
* Given an expression and set of wildcards, return a replacement expression.
|
|
@@ -146,7 +142,7 @@ export type BoxedRuleSet<Expr = unknown, CE = unknown> = {
|
|
|
146
142
|
*
|
|
147
143
|
* @category Compute Engine
|
|
148
144
|
*/
|
|
149
|
-
export type AssignValue<Expr = unknown, SemiExpr = unknown, CE = unknown> = boolean | number | bigint | SemiExpr | ((args: ReadonlyArray<Expr>, options: EvaluateOptions
|
|
145
|
+
export type AssignValue<Expr = unknown, SemiExpr = unknown, CE = unknown> = boolean | number | bigint | SemiExpr | ((args: ReadonlyArray<Expr>, options: EvaluateOptions & {
|
|
150
146
|
engine: CE;
|
|
151
147
|
}) => Expr) | undefined;
|
|
152
148
|
/** @category Definitions */
|
|
@@ -154,11 +150,12 @@ export type Scope<Binding = unknown> = {
|
|
|
154
150
|
parent: Scope<Binding> | null;
|
|
155
151
|
bindings: Map<string, Binding>;
|
|
156
152
|
types?: Record<string, TypeReference>;
|
|
153
|
+
/** When true, auto-declarations during canonicalization are promoted to parent scope. */
|
|
154
|
+
noAutoDeclare?: boolean;
|
|
157
155
|
};
|
|
158
156
|
/** @category Compute Engine */
|
|
159
157
|
export type EvalContext<Expr = unknown, Binding = unknown> = {
|
|
160
158
|
lexicalScope: Scope<Binding>;
|
|
161
159
|
assumptions: ExpressionMapInterface<boolean, Expr>;
|
|
162
|
-
values: Record<string, Expr | undefined>;
|
|
163
160
|
name: undefined | string;
|
|
164
161
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
import type { BoxedSubstitution as KernelBoxedSubstitution, CanonicalForm, CanonicalOptions, FormOption, Hold, JsonSerializationOptions, Metadata, PatternMatchOptions as KernelPatternMatchOptions, ReplaceOptions, Substitution as KernelSubstitution } from './types-kernel-serialization';
|
|
3
3
|
export type { Hold, JsonSerializationOptions, ReplaceOptions, CanonicalForm, CanonicalOptions, FormOption, Metadata, };
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
export type { MathJsonExpression, MathJsonAttributes, MathJsonNumberObject, MathJsonSymbolObject, MathJsonStringObject, MathJsonFunctionObject, DictionaryValue, MathJsonDictionaryObject, ExpressionObject, MathJsonSymbol, } from '../math-json/types';
|
|
3
3
|
export * from '../common/type/boxed-type';
|
|
4
4
|
export * from '../common/type/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
export { ComputeEngine } from './compute-engine/index';
|
|
3
3
|
export type * from './compute-engine/types';
|
|
4
4
|
export type { CompileTarget, CompiledOperators, CompiledFunctions, CompilationOptions, CompilationResult, ExecutableTarget, ComplexResult, CompiledRunner, ExpressionRunner, LambdaRunner, LanguageTarget, TargetSource, CompiledFunction, } from './compute-engine/compilation/types';
|
|
@@ -8,8 +8,6 @@ export { GLSLTarget } from './compute-engine/compilation/glsl-target';
|
|
|
8
8
|
export { WGSLTarget } from './compute-engine/compilation/wgsl-target';
|
|
9
9
|
export { PythonTarget } from './compute-engine/compilation/python-target';
|
|
10
10
|
export { IntervalJavaScriptTarget } from './compute-engine/compilation/interval-javascript-target';
|
|
11
|
-
export { IntervalGLSLTarget } from './compute-engine/compilation/interval-glsl-target';
|
|
12
|
-
export { IntervalWGSLTarget } from './compute-engine/compilation/interval-wgsl-target';
|
|
13
11
|
export { BaseCompiler } from './compute-engine/compilation/base-compiler';
|
|
14
12
|
export type { Interval, IntervalResult, BoolInterval, } from './compute-engine/interval/types';
|
|
15
13
|
export { parse, simplify, evaluate, N, declare, assign, expand, expandAll, factor, solve, compile, getDefaultEngine, } from './compute-engine/free-functions';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
export declare const MISSING: MathJsonExpression;
|
|
3
3
|
export declare function isNumberExpression(expr: MathJsonExpression | null): expr is number | string | MathJsonNumberObject;
|
|
4
4
|
export declare function isNumberObject(expr: MathJsonExpression | null): expr is MathJsonNumberObject;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.53.0 */
|
|
2
2
|
export { isSymbolObject, isStringObject, isFunctionObject, stringValue, operator, operand, symbol, mapArgs, dictionaryFromExpression, } from './math-json/utils';
|
|
3
|
-
export declare const version = "0.
|
|
3
|
+
export declare const version = "0.53.0";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.53.0",
|
|
3
3
|
"scripts": {
|
|
4
4
|
"doc": "bash ./scripts/doc.sh",
|
|
5
5
|
"build": "bash ./scripts/build.sh",
|
|
@@ -69,33 +69,33 @@
|
|
|
69
69
|
"@cortex-js/prettier-config": "^1.2.0",
|
|
70
70
|
"@jest/console": "^29.7.0",
|
|
71
71
|
"@types/jest": "^29.5.5",
|
|
72
|
-
"@types/node": "^
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
74
|
-
"@typescript-eslint/parser": "^
|
|
75
|
-
"@typescript-eslint/typescript-estree": "^
|
|
76
|
-
"chalk": "^5.
|
|
72
|
+
"@types/node": "^25.3.0",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
74
|
+
"@typescript-eslint/parser": "^8.56.0",
|
|
75
|
+
"@typescript-eslint/typescript-estree": "^8.56.0",
|
|
76
|
+
"chalk": "^5.6.2",
|
|
77
77
|
"check-node-version": "^4.2.1",
|
|
78
78
|
"concat-md": "^0.5.1",
|
|
79
|
-
"esbuild": "^0.
|
|
79
|
+
"esbuild": "^0.27.3",
|
|
80
80
|
"eslint": "^8.56.0",
|
|
81
|
-
"eslint-config-prettier": "^
|
|
82
|
-
"eslint-plugin-import": "^2.
|
|
83
|
-
"eslint-plugin-no-unsanitized": "^4.
|
|
84
|
-
"eslint-plugin-prettier": "^5.
|
|
81
|
+
"eslint-config-prettier": "^10.1.8",
|
|
82
|
+
"eslint-plugin-import": "^2.32.0",
|
|
83
|
+
"eslint-plugin-no-unsanitized": "^4.1.5",
|
|
84
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
85
85
|
"jest": "^29.7.0",
|
|
86
86
|
"jest-silent-reporter": "^0.6.0",
|
|
87
87
|
"madge": "^8.0.0",
|
|
88
|
-
"open": "^
|
|
89
|
-
"prettier": "^3.
|
|
88
|
+
"open": "^11.0.0",
|
|
89
|
+
"prettier": "^3.8.1",
|
|
90
90
|
"prettier-2": "npm:prettier@^2.8.8",
|
|
91
91
|
"serve-http": "^1.0.7",
|
|
92
|
-
"ts-jest": "^29.4.
|
|
92
|
+
"ts-jest": "^29.4.6",
|
|
93
93
|
"ts-node": "^10.9.2",
|
|
94
|
-
"typedoc": "^0.28.
|
|
95
|
-
"typedoc-plugin-markdown": "^4.
|
|
94
|
+
"typedoc": "^0.28.17",
|
|
95
|
+
"typedoc-plugin-markdown": "^4.10.0",
|
|
96
96
|
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
97
|
-
"typescript": "^5.
|
|
98
|
-
"update-notifier": "^7.
|
|
97
|
+
"typescript": "^5.9.3",
|
|
98
|
+
"update-notifier": "^7.3.1"
|
|
99
99
|
},
|
|
100
100
|
"prettier": "@cortex-js/prettier-config",
|
|
101
101
|
"dependencies": {
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* 0.52.1 */
|
|
2
|
-
* GLSL interval arithmetic compilation target
|
|
3
|
-
*
|
|
4
|
-
* Compiles mathematical expressions to GLSL code using interval arithmetic
|
|
5
|
-
* for reliable function evaluation in shaders.
|
|
6
|
-
*
|
|
7
|
-
* Intervals are represented as vec2(lo, hi).
|
|
8
|
-
* Status flags use float constants for shader compatibility.
|
|
9
|
-
*
|
|
10
|
-
* @module compilation/interval-glsl-target
|
|
11
|
-
*/
|
|
12
|
-
import type { Expression } from '../global-types';
|
|
13
|
-
import type { CompileTarget, CompiledOperators, CompiledFunctions, LanguageTarget, CompilationOptions, CompilationResult } from './types';
|
|
14
|
-
/**
|
|
15
|
-
* GLSL interval arithmetic target implementation.
|
|
16
|
-
*/
|
|
17
|
-
export declare class IntervalGLSLTarget implements LanguageTarget<Expression> {
|
|
18
|
-
getOperators(): CompiledOperators;
|
|
19
|
-
getFunctions(): CompiledFunctions<Expression>;
|
|
20
|
-
/**
|
|
21
|
-
* Get the GLSL interval library code.
|
|
22
|
-
*
|
|
23
|
-
* This should be included in shaders that use interval arithmetic.
|
|
24
|
-
*/
|
|
25
|
-
getLibrary(): string;
|
|
26
|
-
createTarget(options?: Partial<CompileTarget<Expression>>): CompileTarget<Expression>;
|
|
27
|
-
compile(expr: Expression, options?: CompilationOptions<Expression>): CompilationResult<'interval-glsl'>;
|
|
28
|
-
/**
|
|
29
|
-
* Compile an expression to GLSL interval code string.
|
|
30
|
-
*/
|
|
31
|
-
compileToSource(expr: Expression, _options?: CompilationOptions<Expression>): string;
|
|
32
|
-
/**
|
|
33
|
-
* Create a complete GLSL interval function from an expression.
|
|
34
|
-
*
|
|
35
|
-
* @param expr - The expression to compile
|
|
36
|
-
* @param functionName - Name of the GLSL function
|
|
37
|
-
* @param parameters - Parameter names (each becomes a vec2 interval input)
|
|
38
|
-
*/
|
|
39
|
-
compileFunction(expr: Expression, functionName: string, parameters: string[]): string;
|
|
40
|
-
/**
|
|
41
|
-
* Create a complete GLSL fragment shader for interval function plotting.
|
|
42
|
-
*
|
|
43
|
-
* @param expr - The expression to compile
|
|
44
|
-
* @param options - Shader options
|
|
45
|
-
*/
|
|
46
|
-
compileShaderFunction(expr: Expression, options?: {
|
|
47
|
-
functionName?: string;
|
|
48
|
-
version?: string;
|
|
49
|
-
parameters?: string[];
|
|
50
|
-
}): string;
|
|
51
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* 0.52.1 */
|
|
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<'interval-wgsl'>;
|
|
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
|
-
}
|