@cortex-js/compute-engine 0.8.0 → 0.10.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 +8491 -7432
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +41 -88
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -5
- package/dist/types/common/utils.d.ts +1 -0
- package/dist/types/compute-engine/assume.d.ts +6 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +10 -15
- package/dist/types/compute-engine/boxed-expression/box.d.ts +74 -16
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +10 -5
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +16 -15
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +20 -20
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +8 -7
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +2 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +18 -13
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +7 -7
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +18 -0
- package/dist/types/compute-engine/compute-engine.d.ts +65 -33
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +2 -8
- 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-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.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-sets.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 +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +25 -9
- package/dist/types/compute-engine/latex-syntax/public.d.ts +14 -6
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
- 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/library/arithmetic-add.d.ts +3 -3
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +5 -6
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +3 -2
- 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/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.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/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/numerics/{numeric-decimal.d.ts → numeric-bignum.d.ts} +10 -6
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +10 -6
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +56 -0
- package/dist/types/compute-engine/public.d.ts +205 -254
- package/dist/types/compute-engine/rules.d.ts +7 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +2 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +30 -12
- package/dist/types/compute-engine/symbolic/sum.d.ts +13 -7
- package/dist/types/compute-engine/symbolic/utils.d.ts +7 -29
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +2 -2
- package/dist/types/math-json/utils.d.ts +11 -41
- package/dist/types/math-json.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
-
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions,
|
|
4
|
+
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution } from '../public';
|
|
5
5
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
6
6
|
/**
|
|
7
7
|
* BoxedNumber
|
|
8
8
|
*/
|
|
9
9
|
export declare class BoxedNumber extends AbstractBoxedExpression {
|
|
10
|
-
protected readonly _value: number | Decimal | Complex |
|
|
10
|
+
protected readonly _value: number | Decimal | Complex | Rational;
|
|
11
11
|
private _domain;
|
|
12
|
-
private _head;
|
|
13
12
|
private _hash;
|
|
14
13
|
protected _isCanonical: boolean;
|
|
15
14
|
/**
|
|
16
15
|
* By the time the constructor is called, the `value` should have been
|
|
17
|
-
* screened for cases where it's a well-known value (0, NaN, +Infinity,
|
|
18
|
-
* or non-normal (complex number with im = 0, rational with
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* screened for cases where it's a well-known value (0, NaN, +Infinity,
|
|
17
|
+
* etc...) or non-normal (complex number with im = 0, rational with
|
|
18
|
+
* denom = 1, etc...).
|
|
19
|
+
*
|
|
20
|
+
* This is done in `ce.number()`. In general, use `ce.number()` rather
|
|
21
|
+
* than calling this constructor directly.
|
|
22
|
+
*
|
|
23
|
+
* We may store as a machine number if a Decimal is passed that is in machine
|
|
24
|
+
* range
|
|
21
25
|
*/
|
|
22
|
-
constructor(ce: IComputeEngine, value:
|
|
26
|
+
constructor(ce: IComputeEngine, value: number | Decimal | Complex | Rational, options?: {
|
|
27
|
+
metadata?: Metadata;
|
|
28
|
+
canonical?: boolean;
|
|
29
|
+
});
|
|
23
30
|
get hash(): number;
|
|
24
31
|
get head(): string;
|
|
25
32
|
get isPure(): boolean;
|
|
26
|
-
get
|
|
33
|
+
get isExact(): boolean;
|
|
27
34
|
get isCanonical(): boolean;
|
|
28
35
|
set isCanonical(val: boolean);
|
|
29
36
|
get complexity(): number;
|
|
30
37
|
get value(): BoxedExpression;
|
|
31
|
-
get numericValue():
|
|
32
|
-
get machineValue(): number | null;
|
|
33
|
-
get decimalValue(): Decimal | null;
|
|
34
|
-
get complexValue(): Complex | null;
|
|
35
|
-
get rationalValue(): [numer: number, denom: number] | [null, null];
|
|
36
|
-
get asFloat(): number | null;
|
|
37
|
-
get asSmallInteger(): number | null;
|
|
38
|
-
get asRational(): [number, number] | [null, null];
|
|
38
|
+
get numericValue(): number | Decimal | Complex | Rational | null;
|
|
39
39
|
get domain(): BoxedDomain;
|
|
40
40
|
get json(): Expression;
|
|
41
41
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
42
42
|
isSame(rhs: BoxedExpression): boolean;
|
|
43
43
|
isEqual(rhs: BoxedExpression): boolean;
|
|
44
|
-
match(rhs: BoxedExpression, options?:
|
|
44
|
+
match(rhs: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
45
45
|
/** Compare this with another BoxedNumber.
|
|
46
|
-
* `rhs` must be a BoxedNumber. Use `isEqualWithTolerance(rhs.
|
|
46
|
+
* `rhs` must be a BoxedNumber. Use `isEqualWithTolerance(rhs.N())`
|
|
47
47
|
* if necessary.
|
|
48
48
|
*/
|
|
49
49
|
isEqualWithTolerance(rhs: BoxedExpression, tolerance: number): boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
-
import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern,
|
|
3
|
+
import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOptions, SemiBoxedExpression, Substitution } from '../public';
|
|
4
4
|
export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
|
|
5
5
|
_pattern: BoxedExpression;
|
|
6
|
-
_canonicalPattern: BoxedExpression | undefined;
|
|
7
6
|
constructor(ce: IComputeEngine, pattern: LatexString | SemiBoxedExpression, metadata?: Metadata);
|
|
8
7
|
get hash(): number;
|
|
9
8
|
unbind(): void;
|
|
@@ -14,8 +13,10 @@ export declare class BoxedPattern extends AbstractBoxedExpression implements Pat
|
|
|
14
13
|
set isCanonical(_val: boolean);
|
|
15
14
|
isSame(rhs: BoxedExpression): boolean;
|
|
16
15
|
isEqual(rhs: BoxedExpression): boolean;
|
|
17
|
-
match(expr: BoxedExpression, options?:
|
|
18
|
-
test(expr: BoxedExpression, options?:
|
|
19
|
-
count(exprs: Iterable<BoxedExpression>, options?:
|
|
20
|
-
subs(sub: Substitution
|
|
16
|
+
match(expr: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
17
|
+
test(expr: BoxedExpression, options?: PatternMatchOptions): boolean;
|
|
18
|
+
count(exprs: Iterable<BoxedExpression>, options?: PatternMatchOptions): number;
|
|
19
|
+
subs(sub: Substitution, options?: {
|
|
20
|
+
canonical: boolean;
|
|
21
|
+
}): BoxedExpression;
|
|
21
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
-
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata,
|
|
3
|
+
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedString
|
|
6
6
|
*/
|
|
@@ -11,7 +11,6 @@ export declare class BoxedString extends AbstractBoxedExpression {
|
|
|
11
11
|
get json(): Expression;
|
|
12
12
|
get head(): string;
|
|
13
13
|
get isPure(): boolean;
|
|
14
|
-
get isLiteral(): boolean;
|
|
15
14
|
get isCanonical(): boolean;
|
|
16
15
|
set isCanonical(_va: boolean);
|
|
17
16
|
get domain(): BoxedDomain;
|
|
@@ -19,5 +18,5 @@ export declare class BoxedString extends AbstractBoxedExpression {
|
|
|
19
18
|
get string(): string;
|
|
20
19
|
isEqual(rhs: BoxedExpression): boolean;
|
|
21
20
|
isSame(rhs: BoxedExpression): boolean;
|
|
22
|
-
match(rhs: BoxedExpression, _options?:
|
|
21
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
23
22
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare function domainToFlags(dom: BoxedDomain | undefined | null): Partial<SymbolFlags>;
|
|
3
3
|
export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
private _def;
|
|
6
6
|
private _value;
|
|
7
7
|
private _domain;
|
|
8
|
-
private _inferedDomain;
|
|
9
8
|
private _engine;
|
|
10
9
|
readonly scope: RuntimeScope | undefined;
|
|
11
10
|
wikidata?: string;
|
|
@@ -45,7 +44,7 @@ export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition
|
|
|
45
44
|
unbind(): void;
|
|
46
45
|
bind(): void;
|
|
47
46
|
get value(): BoxedExpression | undefined;
|
|
48
|
-
set value(val:
|
|
47
|
+
set value(val: SemiBoxedExpression | number | undefined);
|
|
49
48
|
get domain(): BoxedDomain | undefined;
|
|
50
49
|
set domain(domain: BoxedDomain | DomainExpression | undefined);
|
|
51
50
|
updateFlags(flags: Partial<SymbolFlags>): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
-
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata,
|
|
3
|
+
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedSymbol
|
|
6
6
|
*
|
|
@@ -19,15 +19,20 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
19
19
|
protected _name: string;
|
|
20
20
|
private _hash;
|
|
21
21
|
private _def;
|
|
22
|
-
constructor(ce: IComputeEngine, name: string,
|
|
22
|
+
constructor(ce: IComputeEngine, name: string, options?: {
|
|
23
|
+
metadata?: Metadata;
|
|
24
|
+
canonical?: boolean;
|
|
25
|
+
});
|
|
23
26
|
get hash(): number;
|
|
24
|
-
unbind():
|
|
27
|
+
unbind(): void;
|
|
25
28
|
get isPure(): boolean;
|
|
29
|
+
get json(): Expression;
|
|
30
|
+
get scope(): RuntimeScope | null;
|
|
26
31
|
/** A free variable either has no definition, or it has a definition, but no value */
|
|
27
32
|
get isFree(): boolean;
|
|
28
33
|
get isConstant(): boolean;
|
|
29
34
|
get isCanonical(): boolean;
|
|
30
|
-
set isCanonical(
|
|
35
|
+
set isCanonical(val: boolean);
|
|
31
36
|
get canonical(): BoxedExpression;
|
|
32
37
|
get wikidata(): string | undefined;
|
|
33
38
|
get description(): string[] | undefined;
|
|
@@ -36,22 +41,19 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
36
41
|
get head(): string;
|
|
37
42
|
get symbol(): string;
|
|
38
43
|
get isNothing(): boolean;
|
|
39
|
-
get isLiteral(): boolean;
|
|
40
44
|
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
41
45
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
42
46
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
43
47
|
bind(scope: RuntimeScope | null): void;
|
|
44
|
-
get value(): BoxedExpression;
|
|
48
|
+
get value(): BoxedExpression | undefined;
|
|
45
49
|
set value(value: BoxedExpression | number | undefined);
|
|
46
|
-
get numericValue(): BoxedExpression | undefined;
|
|
47
50
|
get domain(): BoxedDomain;
|
|
48
|
-
set domain(
|
|
51
|
+
set domain(inDomain: BoxedExpression | DomainExpression | BoxedDomain);
|
|
49
52
|
get explicitDomain(): BoxedDomain | undefined;
|
|
50
|
-
get json(): Expression;
|
|
51
53
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
52
54
|
has(x: string | string[]): boolean;
|
|
53
55
|
isSame(rhs: BoxedExpression): boolean;
|
|
54
|
-
match(rhs: BoxedExpression, _options?:
|
|
56
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
55
57
|
isEqual(rhs: BoxedExpression): boolean;
|
|
56
58
|
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
57
59
|
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
@@ -81,8 +83,11 @@ export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
|
81
83
|
get isComplex(): boolean | undefined;
|
|
82
84
|
get isImaginary(): boolean | undefined;
|
|
83
85
|
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
84
|
-
evaluate(
|
|
86
|
+
evaluate(_options?: EvaluateOptions): BoxedExpression;
|
|
85
87
|
N(options?: NOptions): BoxedExpression;
|
|
86
88
|
replace(rules: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
|
|
87
|
-
subs(sub: Substitution
|
|
89
|
+
subs(sub: Substitution, options?: {
|
|
90
|
+
canonical: boolean;
|
|
91
|
+
}): BoxedExpression;
|
|
88
92
|
}
|
|
93
|
+
export declare function makeCanonicalSymbol(ce: IComputeEngine, name: string): BoxedExpression;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import Decimal from 'decimal.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
-
import { BoxedExpression, IComputeEngine, Metadata } from '../public';
|
|
4
|
+
import { BoxedExpression, IComputeEngine, Metadata, Rational } from '../public';
|
|
5
5
|
/**
|
|
6
6
|
* The canonical version of `serializeJsonFunction()` applies
|
|
7
7
|
* additional transformations to "reverse" some of the effects
|
|
@@ -12,4 +12,4 @@ export declare function serializeJsonCanonicalFunction(ce: IComputeEngine, head:
|
|
|
12
12
|
export declare function serializeJsonFunction(ce: IComputeEngine, head: string | BoxedExpression, args: BoxedExpression[], metadata?: Metadata): Expression;
|
|
13
13
|
export declare function serializeJsonString(ce: IComputeEngine, s: string): Expression;
|
|
14
14
|
export declare function serializeJsonSymbol(ce: IComputeEngine, sym: string, metadata?: Metadata): Expression;
|
|
15
|
-
export declare function serializeJsonNumber(ce: IComputeEngine, value: number | Decimal | Complex |
|
|
15
|
+
export declare function serializeJsonNumber(ce: IComputeEngine, value: number | Decimal | Complex | Rational, metadata?: Metadata): Expression;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
3
|
import { BoxedExpression, IComputeEngine } from '../public';
|
|
4
4
|
export declare function isLatexString(s: unknown): s is string;
|
|
@@ -20,11 +20,10 @@ export declare function getVars(expr: BoxedExpression): string[];
|
|
|
20
20
|
export declare function getSymbols(expr: BoxedExpression, set: Set<string>): Set<string>;
|
|
21
21
|
export declare function getSubexpressions(expr: BoxedExpression, head: string): BoxedExpression[];
|
|
22
22
|
/**
|
|
23
|
-
* For any numeric result,
|
|
24
|
-
*
|
|
25
|
-
* if `preferDecimal` is false, create them as machine number
|
|
23
|
+
* For any numeric result, if `bignumPreferred()` is true, calculate using
|
|
24
|
+
* bignums. If `bignumPreferred()` is false, calculate using machine numbers
|
|
26
25
|
*/
|
|
27
|
-
export declare function
|
|
26
|
+
export declare function bignumPreferred(ce: IComputeEngine): boolean;
|
|
28
27
|
/** When result of a numeric evaluation is a complex number,
|
|
29
28
|
* return `NaN` if not `complexallowed()`
|
|
30
29
|
*/
|
|
@@ -49,6 +48,7 @@ export declare function getListLike(expr: BoxedExpression): BoxedExpression[];
|
|
|
49
48
|
* If `expr` is a number, return it as a Decimal (it might be
|
|
50
49
|
* in the machine value range or not). Use `isInMachineRange()` to check.
|
|
51
50
|
*
|
|
52
|
-
* Use this instead of `machineValue()` when possible, as `machineValue` will
|
|
51
|
+
* Use this instead of `machineValue()` when possible, as `machineValue` will
|
|
52
|
+
* truncate bignums to machine numbers
|
|
53
53
|
*/
|
|
54
|
-
export declare function
|
|
54
|
+
export declare function bignumValue(ce: IComputeEngine, expr: Expression | null | undefined): Decimal | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* 0.10.0 */
|
|
2
|
+
export declare function validateArgumentCount(ce: IComputeEngine, ops: BoxedExpression[], count: number): BoxedExpression[];
|
|
3
|
+
/**
|
|
4
|
+
* Validation of arguments is normally done by checking the signature of the
|
|
5
|
+
* function vs the arguments of the expression. However, we have a fastpath
|
|
6
|
+
* for some common operations (add, multiply, power, neg, etc...) that bypasses
|
|
7
|
+
* the regular checks. This is its replacements. Since all those fastpath
|
|
8
|
+
* functions are numeric (i.e. have numeric arguments and return a numeric
|
|
9
|
+
* value), we do a simple numeric check of all arguments, and verify we have
|
|
10
|
+
* the number of expected arguments.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateNumericArgs(ce: IComputeEngine, ops: SemiBoxedExpression[], count?: number): BoxedExpression[];
|
|
13
|
+
/** Return `null` if the `ops` match the sig. Otherwise, return an array
|
|
14
|
+
* of expressions indicating the mismatched arguments.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export declare function validateSignature(sig: BoxedDomain, ops: BoxedExpression[], codomain?: BoxedExpression): BoxedExpression[] | null;
|
|
18
|
+
export declare function validateArgument(ce: IComputeEngine, arg: BoxedExpression | undefined, expect: DomainExpression<BoxedExpression> | undefined): BoxedExpression;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression, MathJsonNumber } from '../math-json/math-json-format';
|
|
4
4
|
import { SignalMessage, WarningSignal } from '../common/signals';
|
|
5
5
|
import type { LibraryCategory, LatexDictionary, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
6
|
-
import { AssumeResult, BoxedExpression, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, SymbolTable, ExpressionMapInterface, NumericMode as NumericMode, Pattern, RuntimeScope, Scope, SemiBoxedExpression,
|
|
6
|
+
import { AssumeResult, BoxedExpression, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, SymbolTable, ExpressionMapInterface, NumericMode as NumericMode, Pattern, RuntimeScope, Scope, SemiBoxedExpression, SymbolDefinition, BoxedRuleSet, Rule, JsonSerializationOptions, ComputeEngineStats, Metadata, BoxedDomain, DomainExpression, FunctionDefinition, Rational, BoxedSubstitution } from './public';
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
* To use the CortexJS Compute Engine, create a `ComputeEngine` instance.
|
|
@@ -29,8 +29,6 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
29
29
|
/** @internal */
|
|
30
30
|
readonly _ONE: BoxedExpression;
|
|
31
31
|
/** @internal */
|
|
32
|
-
readonly _TWO: BoxedExpression;
|
|
33
|
-
/** @internal */
|
|
34
32
|
readonly _HALF: BoxedExpression;
|
|
35
33
|
/** @internal */
|
|
36
34
|
readonly _NEGATIVE_ONE: BoxedExpression;
|
|
@@ -45,19 +43,19 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
45
43
|
/** @internal */
|
|
46
44
|
readonly _COMPLEX_INFINITY: BoxedExpression;
|
|
47
45
|
/** @internal */
|
|
48
|
-
|
|
46
|
+
_BIGNUM_NAN: Decimal;
|
|
49
47
|
/** @internal */
|
|
50
|
-
|
|
48
|
+
_BIGNUM_ZERO: Decimal;
|
|
51
49
|
/** @internal */
|
|
52
|
-
|
|
50
|
+
_BIGNUM_ONE: Decimal;
|
|
53
51
|
/** @internal */
|
|
54
|
-
|
|
52
|
+
_BIGNUM_TWO: Decimal;
|
|
55
53
|
/** @internal */
|
|
56
|
-
|
|
54
|
+
_BIGNUM_HALF: Decimal;
|
|
57
55
|
/** @internal */
|
|
58
|
-
|
|
56
|
+
_BIGNUM_PI: Decimal;
|
|
59
57
|
/** @internal */
|
|
60
|
-
|
|
58
|
+
_BIGNUM_NEGATIVE_ONE: Decimal;
|
|
61
59
|
/** @internal */
|
|
62
60
|
private _precision;
|
|
63
61
|
/** @internal */
|
|
@@ -67,7 +65,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
67
65
|
/** @internal */
|
|
68
66
|
private _tolerance;
|
|
69
67
|
/** @internal */
|
|
70
|
-
private
|
|
68
|
+
private _bignumTolerance;
|
|
71
69
|
/** @internal */
|
|
72
70
|
private _cache;
|
|
73
71
|
/** @internal */
|
|
@@ -76,6 +74,14 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
76
74
|
private _cost?;
|
|
77
75
|
/** @internal */
|
|
78
76
|
private _jsonSerializationOptions;
|
|
77
|
+
/**
|
|
78
|
+
* During certain operations (serializing to LaTeX, constructing error
|
|
79
|
+
* messages) we need to use a "raw" JSON serialization without any customization. Setting the `_useRawJsonSerializationOptions` will bypass
|
|
80
|
+
* the `_jsonSerializationOptions` and use `_rawJsonSerializationOptions`
|
|
81
|
+
* instead
|
|
82
|
+
* @internal */
|
|
83
|
+
private _useRawJsonSerializationOptions;
|
|
84
|
+
private _rawJsonSerializationOptions;
|
|
79
85
|
/** The domain of unknown symbols. If `null` unknown symbols do not have a
|
|
80
86
|
* definition automatically associated with them.
|
|
81
87
|
*
|
|
@@ -102,6 +108,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
102
108
|
*
|
|
103
109
|
*/
|
|
104
110
|
context: RuntimeScope | null;
|
|
111
|
+
strict: boolean;
|
|
105
112
|
/** Absolute time beyond which evaluation should not proceed.
|
|
106
113
|
* @internal
|
|
107
114
|
*/
|
|
@@ -127,9 +134,10 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
127
134
|
* be the `'core'` dictionary which include some basic definitions such
|
|
128
135
|
* as domains (`Boolean`, `Number`, etc...) that are used by later dictionaries.
|
|
129
136
|
*
|
|
130
|
-
* @param options.numericMode The default mode is `auto`. Use `machine`
|
|
131
|
-
*
|
|
132
|
-
*
|
|
137
|
+
* @param options.numericMode The default mode is `"auto"`. Use `"machine"`
|
|
138
|
+
* to perform numeric calculations using 64-bit floats. Use `"bignum"` to
|
|
139
|
+
* perform calculations using arbitrary precision floating point numbers.
|
|
140
|
+
* Use `"auto"` or `"complex"` to allow calculations on complex numbers.
|
|
133
141
|
*
|
|
134
142
|
* @param options.numericPrecision Specific how many digits of precision for the
|
|
135
143
|
* numeric calculations. Default is 100.
|
|
@@ -163,13 +171,15 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
163
171
|
_unregister(_expr: BoxedExpression): void;
|
|
164
172
|
get stats(): ComputeEngineStats;
|
|
165
173
|
/** @internal */
|
|
166
|
-
|
|
167
|
-
/** The precision, or number of significant digits,
|
|
168
|
-
*
|
|
174
|
+
_bignum: Decimal.Constructor;
|
|
175
|
+
/** The precision, or number of significant digits, of numeric
|
|
176
|
+
* calculations when the numeric mode is `"auto"` or `"bignum"`.
|
|
169
177
|
*
|
|
170
|
-
* To
|
|
178
|
+
* To make calculations using more digits, at the cost of expanded memory
|
|
171
179
|
* usage and slower computations, set the `precision` higher.
|
|
172
180
|
*
|
|
181
|
+
* If the numeric mode is not `"auto"` or `"bignum"`, it is set to `"auto"`.
|
|
182
|
+
*
|
|
173
183
|
* Trigonometric operations are accurate for precision up to 1,000.
|
|
174
184
|
*
|
|
175
185
|
*/
|
|
@@ -201,7 +211,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
201
211
|
get tolerance(): number;
|
|
202
212
|
set tolerance(val: number);
|
|
203
213
|
/** @internal */
|
|
204
|
-
|
|
214
|
+
bignum(a: Decimal.Value): Decimal;
|
|
205
215
|
/** @internal */
|
|
206
216
|
complex(a: number | Complex, b?: number): Complex;
|
|
207
217
|
/** Replace a number that is close to 0 with the exact integer 0.
|
|
@@ -230,7 +240,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
230
240
|
* of the argument or the codomain. However, it is useful during parsing
|
|
231
241
|
* to differentiate between symbols that might represent a function application, e.g. `f` vs `x`.
|
|
232
242
|
*/
|
|
233
|
-
lookupFunction(head: string, scope?: RuntimeScope): undefined | BoxedFunctionDefinition;
|
|
243
|
+
lookupFunction(head: string | BoxedExpression, scope?: RuntimeScope | null): undefined | BoxedFunctionDefinition;
|
|
234
244
|
/**
|
|
235
245
|
* Add (or replace) a definition for a symbol in the current scope.
|
|
236
246
|
*/
|
|
@@ -252,6 +262,12 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
252
262
|
/** Remove the topmost scope from the scope stack.
|
|
253
263
|
*/
|
|
254
264
|
popScope(): void;
|
|
265
|
+
set(identifiers: {
|
|
266
|
+
[identifier: string]: SemiBoxedExpression | null;
|
|
267
|
+
}): void;
|
|
268
|
+
let(identifiers: {
|
|
269
|
+
[identifier: string]: SymbolDefinition | FunctionDefinition;
|
|
270
|
+
}): void;
|
|
255
271
|
get assumptions(): ExpressionMapInterface<boolean>;
|
|
256
272
|
/**
|
|
257
273
|
* Return false if the execution should stop.
|
|
@@ -280,35 +296,51 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
280
296
|
signal(sig: WarningSignal): void;
|
|
281
297
|
/** @internal */
|
|
282
298
|
cache<T>(cacheName: string, build: () => T, purge: (T: any) => T | undefined): T;
|
|
283
|
-
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression
|
|
299
|
+
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression, options?: {
|
|
300
|
+
canonical?: boolean;
|
|
301
|
+
}): BoxedExpression;
|
|
284
302
|
fn(head: string, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
285
303
|
/** @internal */
|
|
286
304
|
_fn(head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
287
305
|
error(message: ['invalid-domain', ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedDomain;
|
|
288
306
|
error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
|
|
307
|
+
hold(expr: SemiBoxedExpression): BoxedExpression;
|
|
289
308
|
add(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
290
|
-
mul(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
291
|
-
power(base: BoxedExpression, exponent: number | [number, number] | BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
292
|
-
inverse(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
293
309
|
negate(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
310
|
+
mul(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
294
311
|
divide(num: BoxedExpression, denom: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
312
|
+
sqrt(base: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
313
|
+
power(base: BoxedExpression, exponent: number | Rational | BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
314
|
+
inverse(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
295
315
|
pair(first: BoxedExpression, second: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
296
316
|
tuple(elements: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
297
317
|
string(s: string, metadata?: Metadata): BoxedExpression;
|
|
298
|
-
symbol(name: string,
|
|
318
|
+
symbol(name: string, options?: {
|
|
319
|
+
metadata?: Metadata;
|
|
320
|
+
canonical?: boolean;
|
|
321
|
+
}): BoxedExpression;
|
|
299
322
|
domain(domain: BoxedExpression | DomainExpression | BoxedDomain, metadata?: Metadata): BoxedDomain;
|
|
300
|
-
|
|
301
|
-
|
|
323
|
+
number(value: number | string | MathJsonNumber | Decimal | Complex | Rational, options?: {
|
|
324
|
+
canonical?: boolean;
|
|
325
|
+
metadata?: Metadata;
|
|
326
|
+
}): BoxedExpression;
|
|
302
327
|
rules(rules: Rule[]): BoxedRuleSet;
|
|
303
328
|
pattern(expr: LatexString | SemiBoxedExpression): Pattern;
|
|
304
|
-
parse(latex: LatexString | string
|
|
305
|
-
|
|
306
|
-
|
|
329
|
+
parse(latex: LatexString | string, options?: {
|
|
330
|
+
canonical?: boolean;
|
|
331
|
+
}): BoxedExpression;
|
|
332
|
+
parse(s: null, options?: {
|
|
333
|
+
canonical?: boolean;
|
|
334
|
+
}): null;
|
|
335
|
+
parse(latex: LatexString | string | null, options?: {
|
|
336
|
+
canonical?: boolean;
|
|
337
|
+
}): null | BoxedExpression;
|
|
307
338
|
serialize(x: Expression | BoxedExpression): string;
|
|
308
339
|
get latexOptions(): NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
309
340
|
set latexOptions(opts: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>);
|
|
310
|
-
get jsonSerializationOptions(): JsonSerializationOptions
|
|
341
|
+
get jsonSerializationOptions(): Readonly<JsonSerializationOptions>;
|
|
311
342
|
set jsonSerializationOptions(val: Partial<JsonSerializationOptions>);
|
|
343
|
+
rawJson(expr: BoxedExpression): Expression;
|
|
312
344
|
/**
|
|
313
345
|
* Return a list of all the assumptions that match a pattern.
|
|
314
346
|
*
|
|
@@ -318,7 +350,7 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
318
350
|
* // -> [{'val': 0}]
|
|
319
351
|
* ```
|
|
320
352
|
*/
|
|
321
|
-
ask(pattern: LatexString | SemiBoxedExpression):
|
|
353
|
+
ask(pattern: LatexString | SemiBoxedExpression): BoxedSubstitution[];
|
|
322
354
|
infer(symbol: BoxedExpression | string, _domain: BoxedDomain | DomainExpression): AssumeResult;
|
|
323
355
|
assume(symbol: LatexString | SemiBoxedExpression, domainValue: BoxedDomain | DomainExpression | Expression | BoxedExpression): AssumeResult;
|
|
324
356
|
assume(predicate: LatexString | SemiBoxedExpression): AssumeResult;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
3
|
import { BoxedExpression } from './public';
|
|
4
4
|
/** Quickly determine the numeric domain of a number or constant
|
|
5
5
|
* For the symbols, this is a hard-coded optimization that doesn't rely on the
|
|
6
6
|
* dictionaries. The regular path is in `internalDomain()`
|
|
7
7
|
*/
|
|
8
|
-
export declare function inferNumericDomain(value: number | Decimal | Complex | [numer: number, denom: number]): string;
|
|
8
|
+
export declare function inferNumericDomain(value: number | Decimal | Complex | [numer: number, denom: number] | [numer: Decimal, denom: Decimal]): string;
|
|
9
9
|
/**
|
|
10
10
|
* Simple description of a numeric domain as a base domain, a min and
|
|
11
11
|
* max value, possibly open ends, and some excluded values.
|
|
@@ -22,9 +22,3 @@ export declare type NumericDomainInfo = {
|
|
|
22
22
|
*/
|
|
23
23
|
multiple?: [period: number, domain: BoxedExpression, phase: number];
|
|
24
24
|
};
|
|
25
|
-
/**
|
|
26
|
-
* Return an efficient data structure describing a numeric domain,
|
|
27
|
-
* an `Interval` or `Range`
|
|
28
|
-
* @todo could also check for `Multiple`
|
|
29
|
-
*/
|
|
30
|
-
export declare function inferNumericDomainInfo(expr: BoxedExpression): NumericDomainInfo | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_CALCULUS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_CORE: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_INEQUALITIES: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_LOGIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_OTHERS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_SETS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.10.0 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|