@cortex-js/compute-engine 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/compute-engine.esm.js +16755 -10484
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +148 -12472
- package/dist/math-json.min.esm.js +2 -7
- package/dist/math-json.min.js +2 -7
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +90 -0
- package/dist/types/compute-engine/assume.d.ts +21 -6
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +95 -0
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +53 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
- package/dist/types/compute-engine/compute-engine.d.ts +284 -99
- package/dist/types/compute-engine/cost-function.d.ts +3 -0
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
- package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
- package/dist/types/compute-engine/domain-utils.d.ts +30 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
- package/dist/types/compute-engine/latex-syntax/public.d.ts +576 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +4 -5
- package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +41 -0
- package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
- package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
- package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +1416 -447
- package/dist/types/compute-engine/rules.d.ts +16 -6
- package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
- package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
- package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
- package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
- package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
- package/dist/types/compute-engine.d.ts +3 -5
- package/dist/types/math-json/math-json-format.d.ts +101 -0
- package/dist/types/math-json/utils.d.ts +97 -0
- package/dist/types/math-json.d.ts +4 -3
- package/package.json +29 -28
- package/dist/compute-engine.js +0 -17296
- package/dist/cortex.esm.js +0 -20989
- package/dist/cortex.js +0 -21011
- package/dist/cortex.min.esm.js +0 -7
- package/dist/cortex.min.js +0 -7
- package/dist/math-json.js +0 -12517
- package/dist/types/common/debug.d.ts +0 -28
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
- package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
- package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
- package/dist/types/compute-engine/domains.d.ts +0 -4
- package/dist/types/compute-engine/evaluate.d.ts +0 -13
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
- package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
- package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
- package/dist/types/compute-engine/numeric.d.ts +0 -21
- package/dist/types/compute-engine/numerical-eval.d.ts +0 -5
- package/dist/types/compute-engine/order.d.ts +0 -18
- package/dist/types/compute-engine/patterns.d.ts +0 -22
- package/dist/types/compute-engine/predicates.d.ts +0 -42
- package/dist/types/compute-engine/simplify.d.ts +0 -6
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/cortex/formatter.d.ts +0 -165
- package/dist/types/cortex/parse-cortex.d.ts +0 -5
- package/dist/types/cortex/reserved-words.d.ts +0 -1
- package/dist/types/cortex/serialize-cortex.d.ts +0 -14
- package/dist/types/cortex.d.ts +0 -8
- package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
- package/dist/types/latex-syntax/definitions.d.ts +0 -40
- package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
- package/dist/types/latex-syntax/parse.d.ts +0 -138
- package/dist/types/latex-syntax/public.d.ts +0 -456
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/point-free-parser/characters.d.ts +0 -25
- package/dist/types/point-free-parser/combinators.d.ts +0 -46
- package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
- package/dist/types/point-free-parser/grammar.d.ts +0 -12
- package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
- package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
- package/dist/types/point-free-parser/parsers.d.ts +0 -130
- package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
- package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
- package/dist/types/public.d.ts +0 -163
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine, Metadata } from '../public';
|
|
3
|
+
export declare class Domain extends BoxedSymbol {
|
|
4
|
+
constructor(ce: IComputeEngine, dom: string, metadata?: Metadata);
|
|
5
|
+
get head(): string;
|
|
6
|
+
get domain(): BoxedExpression;
|
|
7
|
+
isSubsetOf(dom: BoxedExpression | string): boolean;
|
|
8
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
+
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOption } from '../public';
|
|
4
|
+
/**
|
|
5
|
+
* BoxedFunction
|
|
6
|
+
*/
|
|
7
|
+
export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
8
|
+
private _head;
|
|
9
|
+
private _ops;
|
|
10
|
+
private _def;
|
|
11
|
+
private _isCanonical;
|
|
12
|
+
private _isPure;
|
|
13
|
+
/** The cached values of applying the tail to the head.
|
|
14
|
+
* If the function is not pure, it is never cached.
|
|
15
|
+
*/
|
|
16
|
+
private _value;
|
|
17
|
+
private _numericValue;
|
|
18
|
+
private _hash;
|
|
19
|
+
constructor(ce: IComputeEngine, head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata);
|
|
20
|
+
get hash(): number;
|
|
21
|
+
_purge(): undefined;
|
|
22
|
+
get wikidata(): string;
|
|
23
|
+
get description(): string[];
|
|
24
|
+
get url(): string;
|
|
25
|
+
get complexity(): number;
|
|
26
|
+
get head(): string | BoxedExpression;
|
|
27
|
+
get value(): BoxedExpression | undefined;
|
|
28
|
+
get numericValue(): BoxedExpression | undefined;
|
|
29
|
+
get isPure(): boolean;
|
|
30
|
+
get isLiteral(): boolean;
|
|
31
|
+
get ops(): BoxedExpression[];
|
|
32
|
+
get nops(): number;
|
|
33
|
+
get op1(): BoxedExpression;
|
|
34
|
+
get op2(): BoxedExpression;
|
|
35
|
+
get op3(): BoxedExpression;
|
|
36
|
+
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
37
|
+
_repairDefinition(): void;
|
|
38
|
+
/** Domain of the value of the function */
|
|
39
|
+
get domain(): BoxedExpression;
|
|
40
|
+
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
41
|
+
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
42
|
+
isGreater(rhs: BoxedExpression): boolean | undefined;
|
|
43
|
+
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
44
|
+
get isZero(): boolean | undefined;
|
|
45
|
+
get isNotZero(): boolean | undefined;
|
|
46
|
+
get isOne(): boolean | undefined;
|
|
47
|
+
get isNegativeOne(): boolean | undefined;
|
|
48
|
+
get isPositive(): boolean | undefined;
|
|
49
|
+
get isNonPositive(): boolean | undefined;
|
|
50
|
+
get isNegative(): boolean | undefined;
|
|
51
|
+
get isNonNegative(): boolean | undefined;
|
|
52
|
+
get isNumber(): boolean | undefined;
|
|
53
|
+
get isInteger(): boolean | undefined;
|
|
54
|
+
get isRational(): boolean | undefined;
|
|
55
|
+
get isAlgebraic(): boolean | undefined;
|
|
56
|
+
get isReal(): boolean | undefined;
|
|
57
|
+
get isExtendedReal(): boolean | undefined;
|
|
58
|
+
get isComplex(): boolean | undefined;
|
|
59
|
+
get isImaginary(): boolean | undefined;
|
|
60
|
+
get json(): Expression;
|
|
61
|
+
has(x: string | string[]): boolean;
|
|
62
|
+
/** `isSame` is structural/symbolic equality */
|
|
63
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
64
|
+
match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
65
|
+
/** `isEqual` is mathematical equality */
|
|
66
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
67
|
+
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
68
|
+
map<T = BoxedExpression>(fn: (x: BoxedExpression) => T): IterableIterator<T>;
|
|
69
|
+
get isCanonical(): boolean;
|
|
70
|
+
set isCanonical(val: boolean);
|
|
71
|
+
get canonical(): BoxedExpression;
|
|
72
|
+
apply(fn: (x: BoxedExpression) => SemiBoxedExpression, head?: string): BoxedExpression;
|
|
73
|
+
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
74
|
+
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
75
|
+
N(options?: NOptions): BoxedExpression;
|
|
76
|
+
solve(_vars: Iterable<string>): null | BoxedExpression[];
|
|
77
|
+
replace(rules: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
|
|
78
|
+
subs(sub: Substitution): BoxedExpression;
|
|
79
|
+
}
|
|
80
|
+
export declare function lambda(fn: BoxedExpression, args: BoxedExpression[]): BoxedExpression;
|
|
81
|
+
export declare function ungroup(expr: BoxedExpression): BoxedExpression;
|
|
82
|
+
/** Apply the function `f` to elements of `xs`, except to the elements
|
|
83
|
+
* described by `skip`:
|
|
84
|
+
* - `all`: don't apply f to any elements
|
|
85
|
+
* - `none`: apply `f` to all elements
|
|
86
|
+
* - `first`: apply `f` to all elements except the first
|
|
87
|
+
* - `rest`: apply `f` to the first element, skip the others
|
|
88
|
+
* - 'last': apply `f` to all elements except the last
|
|
89
|
+
* - 'most': apply `f` to the last elements, skip the others
|
|
90
|
+
*
|
|
91
|
+
* Account for `Hold`, `ReleaseHold` and `Nothing`.
|
|
92
|
+
*
|
|
93
|
+
* If `f` returns `null`, the element is not added to the result
|
|
94
|
+
*/
|
|
95
|
+
export declare function holdMap(xs: BoxedExpression[], skip: 'all' | 'none' | 'first' | 'rest' | 'last' | 'most', f: (BoxedExpression: any) => BoxedExpression | null): BoxedExpression[];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { Complex } from 'complex.js';
|
|
3
|
+
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
+
import { BoxedExpression, IComputeEngine, Metadata, NOptions, PatternMatchOption, SimplifyOptions, Substitution } from '../public';
|
|
5
|
+
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
6
|
+
/**
|
|
7
|
+
* BoxedNumber
|
|
8
|
+
*/
|
|
9
|
+
export declare class BoxedNumber extends AbstractBoxedExpression {
|
|
10
|
+
protected readonly _value: number | Decimal | Complex | [numer: number, denom: number];
|
|
11
|
+
private _domain;
|
|
12
|
+
private _head;
|
|
13
|
+
private _hash;
|
|
14
|
+
protected _isCanonical: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 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, etc...)
|
|
18
|
+
* or non-normal (complex number with im = 0, rational with denom = 1, etc...)
|
|
19
|
+
* This is done in `ce.boxNumber()`. In general, use `ce.boxNumber()` rather
|
|
20
|
+
* than calling the constructor directly.
|
|
21
|
+
*/
|
|
22
|
+
constructor(ce: IComputeEngine, value: string | number | Decimal | Complex | [numer: number, denom: number], metadata?: Metadata);
|
|
23
|
+
get hash(): number;
|
|
24
|
+
get head(): string;
|
|
25
|
+
get isPure(): boolean;
|
|
26
|
+
get isLiteral(): boolean;
|
|
27
|
+
get isCanonical(): boolean;
|
|
28
|
+
set isCanonical(val: boolean);
|
|
29
|
+
get numericValue(): BoxedExpression | undefined;
|
|
30
|
+
get machineValue(): number | null;
|
|
31
|
+
get decimalValue(): Decimal | null;
|
|
32
|
+
get complexValue(): Complex | null;
|
|
33
|
+
get rationalValue(): [numer: number, denom: number] | [null, null];
|
|
34
|
+
get asFloat(): number | null;
|
|
35
|
+
get asSmallInteger(): number | null;
|
|
36
|
+
get asRational(): [number, number] | [null, null];
|
|
37
|
+
get domain(): BoxedExpression;
|
|
38
|
+
get json(): Expression;
|
|
39
|
+
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
40
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
41
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
42
|
+
match(rhs: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
43
|
+
/** Compare this with another BoxedNumber.
|
|
44
|
+
* `rhs` must be a BoxedNumber. Use `isEqualWithTolerance(rhs.numericValue)`
|
|
45
|
+
* if necessary.
|
|
46
|
+
*/
|
|
47
|
+
isEqualWithTolerance(rhs: BoxedExpression, tolerance: number): boolean;
|
|
48
|
+
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
49
|
+
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
50
|
+
isGreater(rhs: BoxedExpression): boolean | undefined;
|
|
51
|
+
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
52
|
+
/** x > 0, same as `isGreater(0)` */
|
|
53
|
+
get isPositive(): boolean | undefined;
|
|
54
|
+
/** x >= 0, same as `isGreaterEqual(0)` */
|
|
55
|
+
get isNonNegative(): boolean | undefined;
|
|
56
|
+
/** x < 0, same as `isLess(0)` */
|
|
57
|
+
get isNegative(): boolean | undefined;
|
|
58
|
+
/** x <= 0, same as `isLessEqual(0)` */
|
|
59
|
+
get isNonPositive(): boolean | undefined;
|
|
60
|
+
get isZero(): boolean;
|
|
61
|
+
get isNotZero(): boolean;
|
|
62
|
+
get isOne(): boolean;
|
|
63
|
+
get isNegativeOne(): boolean;
|
|
64
|
+
get isOdd(): boolean | undefined;
|
|
65
|
+
get isEven(): boolean | undefined;
|
|
66
|
+
get isPrime(): boolean | undefined;
|
|
67
|
+
get isComposite(): boolean | undefined;
|
|
68
|
+
get isInfinity(): boolean;
|
|
69
|
+
get isNaN(): boolean;
|
|
70
|
+
get isFinite(): boolean;
|
|
71
|
+
get isNumber(): true;
|
|
72
|
+
get isInteger(): boolean;
|
|
73
|
+
get isRational(): boolean;
|
|
74
|
+
get isAlgebraic(): boolean | undefined;
|
|
75
|
+
get isReal(): boolean;
|
|
76
|
+
get isExtendedReal(): boolean;
|
|
77
|
+
get isComplex(): boolean | undefined;
|
|
78
|
+
get isImaginary(): boolean | undefined;
|
|
79
|
+
get isExtendedComplex(): boolean | undefined;
|
|
80
|
+
get canonical(): BoxedExpression;
|
|
81
|
+
simplify(_options?: SimplifyOptions): BoxedExpression;
|
|
82
|
+
N(_options?: NOptions): BoxedExpression;
|
|
83
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
+
import { BoxedExpression, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOption, SemiBoxedExpression, Substitution } from '../public';
|
|
4
|
+
export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
|
|
5
|
+
_pattern: BoxedExpression;
|
|
6
|
+
_canonicalPattern: BoxedExpression | undefined;
|
|
7
|
+
constructor(ce: IComputeEngine, pattern: LatexString | SemiBoxedExpression, metadata?: Metadata);
|
|
8
|
+
get hash(): number;
|
|
9
|
+
_purge(): undefined;
|
|
10
|
+
get json(): Expression;
|
|
11
|
+
get head(): string | BoxedExpression;
|
|
12
|
+
get domain(): BoxedExpression;
|
|
13
|
+
get isCanonical(): boolean;
|
|
14
|
+
set isCanonical(_val: boolean);
|
|
15
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
16
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
17
|
+
match(expr: BoxedExpression, options?: PatternMatchOption): Substitution | null;
|
|
18
|
+
test(expr: BoxedExpression, options?: PatternMatchOption): boolean;
|
|
19
|
+
count(exprs: Iterable<BoxedExpression>, options?: PatternMatchOption): number;
|
|
20
|
+
subs(sub: Substitution): BoxedPattern;
|
|
21
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
+
import { BoxedExpression, IComputeEngine, Metadata, PatternMatchOption, Substitution } from '../public';
|
|
4
|
+
/**
|
|
5
|
+
* BoxedString
|
|
6
|
+
*/
|
|
7
|
+
export declare class BoxedString extends AbstractBoxedExpression {
|
|
8
|
+
private readonly _string;
|
|
9
|
+
constructor(ce: IComputeEngine, expr: string, metadata?: Metadata);
|
|
10
|
+
get hash(): number;
|
|
11
|
+
get json(): Expression;
|
|
12
|
+
get head(): string;
|
|
13
|
+
get isPure(): boolean;
|
|
14
|
+
get isLiteral(): boolean;
|
|
15
|
+
get isCanonical(): boolean;
|
|
16
|
+
set isCanonical(_va: boolean);
|
|
17
|
+
get domain(): BoxedExpression;
|
|
18
|
+
get complexity(): number;
|
|
19
|
+
get string(): string;
|
|
20
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
21
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
22
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
|
|
23
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
export declare function domainToFlags(dom: BoxedExpression | undefined | null): Partial<SymbolFlags>;
|
|
3
|
+
export declare class BoxedSymbolDefinitionImpl implements BoxedSymbolDefinition {
|
|
4
|
+
private _engine;
|
|
5
|
+
private _value;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
wikidata?: string;
|
|
8
|
+
description?: string | string[];
|
|
9
|
+
readonly scope: RuntimeScope | undefined;
|
|
10
|
+
private _domain;
|
|
11
|
+
private _number;
|
|
12
|
+
private _integer;
|
|
13
|
+
private _rational;
|
|
14
|
+
private _algebraic;
|
|
15
|
+
private _real;
|
|
16
|
+
private _extendedReal;
|
|
17
|
+
private _complex;
|
|
18
|
+
private _extendedComplex;
|
|
19
|
+
private _imaginary;
|
|
20
|
+
private _positive;
|
|
21
|
+
private _nonPositive;
|
|
22
|
+
private _negative;
|
|
23
|
+
private _nonNegative;
|
|
24
|
+
private _zero;
|
|
25
|
+
private _notZero;
|
|
26
|
+
private _one;
|
|
27
|
+
private _negativeOne;
|
|
28
|
+
private _infinity;
|
|
29
|
+
private _NaN;
|
|
30
|
+
private _finite;
|
|
31
|
+
private _even;
|
|
32
|
+
private _odd;
|
|
33
|
+
private _prime;
|
|
34
|
+
private _composite;
|
|
35
|
+
private _at;
|
|
36
|
+
at?: (index: string | number) => undefined | BoxedExpression;
|
|
37
|
+
readonly constant: boolean;
|
|
38
|
+
readonly hold: boolean;
|
|
39
|
+
private _def;
|
|
40
|
+
prototype?: BoxedFunctionDefinition;
|
|
41
|
+
self?: any;
|
|
42
|
+
constructor(ce: IComputeEngine, def: SymbolDefinition);
|
|
43
|
+
_purge(): undefined;
|
|
44
|
+
get value(): BoxedExpression | undefined;
|
|
45
|
+
set value(val: BoxedExpression | number | undefined);
|
|
46
|
+
get domain(): BoxedExpression | undefined;
|
|
47
|
+
set domain(domain: BoxedExpression | undefined | string);
|
|
48
|
+
updateFlags(flags: Partial<SymbolFlags>): void;
|
|
49
|
+
setProps(props: Omit<Partial<BoxedSymbolDefinition>, 'domain' | 'value'>): void;
|
|
50
|
+
get number(): boolean | undefined;
|
|
51
|
+
set number(val: boolean | undefined);
|
|
52
|
+
get integer(): boolean | undefined;
|
|
53
|
+
set integer(val: boolean | undefined);
|
|
54
|
+
get rational(): boolean | undefined;
|
|
55
|
+
set rational(val: boolean | undefined);
|
|
56
|
+
get algebraic(): boolean | undefined;
|
|
57
|
+
set algebraic(val: boolean | undefined);
|
|
58
|
+
get real(): boolean | undefined;
|
|
59
|
+
set real(val: boolean | undefined);
|
|
60
|
+
get extendedReal(): boolean | undefined;
|
|
61
|
+
set extendedReal(val: boolean | undefined);
|
|
62
|
+
get complex(): boolean | undefined;
|
|
63
|
+
set complex(val: boolean | undefined);
|
|
64
|
+
get extendedComplex(): boolean | undefined;
|
|
65
|
+
set extendedComplex(val: boolean | undefined);
|
|
66
|
+
get imaginary(): boolean | undefined;
|
|
67
|
+
set imaginary(val: boolean | undefined);
|
|
68
|
+
get positive(): boolean | undefined;
|
|
69
|
+
set positive(val: boolean | undefined);
|
|
70
|
+
get nonPositive(): boolean | undefined;
|
|
71
|
+
set nonPositive(val: boolean | undefined);
|
|
72
|
+
get negative(): boolean | undefined;
|
|
73
|
+
set negative(val: boolean | undefined);
|
|
74
|
+
get nonNegative(): boolean | undefined;
|
|
75
|
+
set nonNegative(val: boolean | undefined);
|
|
76
|
+
get zero(): boolean | undefined;
|
|
77
|
+
set zero(val: boolean | undefined);
|
|
78
|
+
get notZero(): boolean | undefined;
|
|
79
|
+
set notZero(val: boolean | undefined);
|
|
80
|
+
get one(): boolean | undefined;
|
|
81
|
+
set one(val: boolean | undefined);
|
|
82
|
+
get negativeOne(): boolean | undefined;
|
|
83
|
+
set negativeOne(val: boolean | undefined);
|
|
84
|
+
get infinity(): boolean | undefined;
|
|
85
|
+
set infinity(val: boolean | undefined);
|
|
86
|
+
get finite(): boolean | undefined;
|
|
87
|
+
set finite(val: boolean | undefined);
|
|
88
|
+
get NaN(): boolean | undefined;
|
|
89
|
+
set NaN(val: boolean | undefined);
|
|
90
|
+
get even(): boolean | undefined;
|
|
91
|
+
set even(val: boolean | undefined);
|
|
92
|
+
get odd(): boolean | undefined;
|
|
93
|
+
set odd(val: boolean | undefined);
|
|
94
|
+
get prime(): boolean | undefined;
|
|
95
|
+
set prime(val: boolean | undefined);
|
|
96
|
+
get composite(): boolean | undefined;
|
|
97
|
+
set composite(val: boolean | undefined);
|
|
98
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
|
+
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOption } from '../public';
|
|
4
|
+
/**
|
|
5
|
+
* BoxedSymbol
|
|
6
|
+
*
|
|
7
|
+
* A boxed symbol is a reference to a BoxedSymbolDefinition.
|
|
8
|
+
* The BoxedSymbolDefinition "owns" all the information
|
|
9
|
+
* about the symbol, its value, domain and various attributes.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BoxedSymbol extends AbstractBoxedExpression {
|
|
12
|
+
protected _name: string;
|
|
13
|
+
private _hash;
|
|
14
|
+
private _def;
|
|
15
|
+
constructor(ce: IComputeEngine, name: string, metadata?: Metadata);
|
|
16
|
+
get hash(): number;
|
|
17
|
+
_purge(): undefined;
|
|
18
|
+
get isPure(): boolean;
|
|
19
|
+
get isCanonical(): boolean;
|
|
20
|
+
set isCanonical(_va: boolean);
|
|
21
|
+
get wikidata(): string;
|
|
22
|
+
get description(): string[];
|
|
23
|
+
get url(): string;
|
|
24
|
+
get complexity(): number;
|
|
25
|
+
get head(): string;
|
|
26
|
+
get symbol(): string;
|
|
27
|
+
get isMissing(): boolean;
|
|
28
|
+
get isLiteral(): boolean;
|
|
29
|
+
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
30
|
+
_repairDefinition(): void;
|
|
31
|
+
get value(): BoxedExpression | undefined;
|
|
32
|
+
set value(value: BoxedExpression | number | undefined);
|
|
33
|
+
get numericValue(): BoxedExpression | undefined;
|
|
34
|
+
get domain(): BoxedExpression;
|
|
35
|
+
set domain(d: BoxedExpression);
|
|
36
|
+
get json(): Expression;
|
|
37
|
+
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
38
|
+
has(x: string | string[]): boolean;
|
|
39
|
+
isSame(rhs: BoxedExpression): boolean;
|
|
40
|
+
match(rhs: BoxedExpression, _options?: PatternMatchOption): Substitution | null;
|
|
41
|
+
isEqual(rhs: BoxedExpression): boolean;
|
|
42
|
+
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
43
|
+
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
44
|
+
isGreater(rhs: BoxedExpression): boolean | undefined;
|
|
45
|
+
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
46
|
+
get isZero(): boolean | undefined;
|
|
47
|
+
get isNotZero(): boolean | undefined;
|
|
48
|
+
get isOne(): boolean | undefined;
|
|
49
|
+
get isNegativeOne(): boolean | undefined;
|
|
50
|
+
get isOdd(): boolean | undefined;
|
|
51
|
+
get isEven(): boolean | undefined;
|
|
52
|
+
get isPrime(): boolean | undefined;
|
|
53
|
+
get isComposite(): boolean | undefined;
|
|
54
|
+
get isInfinity(): boolean | undefined;
|
|
55
|
+
get isNaN(): boolean | undefined;
|
|
56
|
+
get isPositive(): boolean | undefined;
|
|
57
|
+
get isNonPositive(): boolean | undefined;
|
|
58
|
+
get isNegative(): boolean | undefined;
|
|
59
|
+
get isNonNegative(): boolean | undefined;
|
|
60
|
+
get isNumber(): boolean | undefined;
|
|
61
|
+
get isInteger(): boolean | undefined;
|
|
62
|
+
get isRational(): boolean | undefined;
|
|
63
|
+
get isAlgebraic(): boolean | undefined;
|
|
64
|
+
get isReal(): boolean | undefined;
|
|
65
|
+
get isExtendedReal(): boolean | undefined;
|
|
66
|
+
get isComplex(): boolean | undefined;
|
|
67
|
+
get isImaginary(): boolean | undefined;
|
|
68
|
+
get canonical(): BoxedExpression;
|
|
69
|
+
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
70
|
+
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
71
|
+
N(options?: NOptions): BoxedExpression;
|
|
72
|
+
replace(rules: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
|
|
73
|
+
subs(sub: Substitution): BoxedExpression;
|
|
74
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
export declare class ExpressionMap<U> implements ExpressionMapInterface<U> {
|
|
3
|
+
readonly _items: Map<BoxedExpression, U>;
|
|
4
|
+
constructor(source?: ExpressionMapInterface<U> | readonly (readonly [BoxedExpression, U])[]);
|
|
5
|
+
has(expr: BoxedExpression): boolean;
|
|
6
|
+
get(expr: BoxedExpression): U | undefined;
|
|
7
|
+
clear(): void;
|
|
8
|
+
set(expr: BoxedExpression, value: U): void;
|
|
9
|
+
delete(expr: BoxedExpression): void;
|
|
10
|
+
[Symbol.iterator](): IterableIterator<[BoxedExpression, U]>;
|
|
11
|
+
entries(): IterableIterator<[BoxedExpression, U]>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
export declare type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
|
|
3
|
+
export declare const DEFAULT_COMPLEXITY = 100000;
|
|
4
|
+
/**
|
|
5
|
+
* Sort by higher total degree (sum of degree), if tied, sort by max degree,
|
|
6
|
+
* if tied,
|
|
7
|
+
*/
|
|
8
|
+
export declare function sortAdd(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression[];
|
|
9
|
+
/**
|
|
10
|
+
* Given two expressions `a` and `b`, return:
|
|
11
|
+
* - `-1` if `a` should be ordered before `b`
|
|
12
|
+
* - `+1` if `b` should be ordered before `a`
|
|
13
|
+
* - `0` if they have the same order (they are structurally equal)
|
|
14
|
+
*
|
|
15
|
+
* The default order is as follow:
|
|
16
|
+
*
|
|
17
|
+
* 1/ Literal numeric values (rational, machine numbers and Decimal numbers),
|
|
18
|
+
* ordered by they numeric value (smaller numbers before larger numbers)
|
|
19
|
+
*
|
|
20
|
+
* 2/ Literal complex numbers, ordered by their real parts. In case of a tie,
|
|
21
|
+
* ordered by the absolute value of their imaginary parts. In case of a tie,
|
|
22
|
+
* ordered by the value of their imaginary parts.
|
|
23
|
+
*
|
|
24
|
+
* 3/ Symbols, ordered by their name as strings
|
|
25
|
+
*
|
|
26
|
+
* 4/ Addition, ordered as a polynom, with higher degree terms first
|
|
27
|
+
*
|
|
28
|
+
* 5/ Other functions, ordered by their `complexity` property. In case
|
|
29
|
+
* of a tie, ordered by the head of the expression as a string. In case of a
|
|
30
|
+
* tie, by the leaf count of each expression. In case of a tie, by the order
|
|
31
|
+
* of each argument, left to right.
|
|
32
|
+
*
|
|
33
|
+
* 6/ Strings, ordered by comparing their Unicode code point values. While this
|
|
34
|
+
* sort order is quick to calculate, it can produce unexpected results, for
|
|
35
|
+
* example "E" < "e" < "È" and "11" < "2". This ordering is not suitable to
|
|
36
|
+
* collate natural language strings.
|
|
37
|
+
*
|
|
38
|
+
* 7/ Dictionaries, ordered by the number of keys. If there is a tie, by the
|
|
39
|
+
* sum of the complexities of the values of the dictionary
|
|
40
|
+
*
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
export declare function order(a: BoxedExpression, b: BoxedExpression): number;
|
|
44
|
+
/**
|
|
45
|
+
* Sort the terms of a polynomial expression (`Add` expression) according
|
|
46
|
+
* to the deglex polynomial ordering
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
export declare function polynomialOrder(expr: BoxedExpression): SemiBoxedExpression;
|
|
50
|
+
export declare function lexicographicOrder(expr: BoxedExpression, vars?: string[]): SemiBoxedExpression;
|
|
51
|
+
export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: string[]): SemiBoxedExpression;
|
|
52
|
+
export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: string[]): SemiBoxedExpression;
|
|
53
|
+
export declare function eliminationOrder(expr: BoxedExpression, vars?: string[]): SemiBoxedExpression;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
import Decimal from 'decimal.js';
|
|
3
|
+
import { Expression } from '../../math-json/math-json-format';
|
|
4
|
+
import { BoxedExpression, IComputeEngine, Metadata } from '../public';
|
|
5
|
+
/**
|
|
6
|
+
* The canonical version of `serializeJsonFunction()` applies
|
|
7
|
+
* additional transformations to "reverse" some of the effects
|
|
8
|
+
* of canonicalization (or boxing), for example it uses `Divide`
|
|
9
|
+
* instead of `Multiply`/`Power` when applicable.
|
|
10
|
+
*/
|
|
11
|
+
export declare function serializeJsonCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, args: BoxedExpression[], metadata?: Metadata): Expression;
|
|
12
|
+
export declare function serializeJsonFunction(ce: IComputeEngine, head: string | BoxedExpression, args: BoxedExpression[], metadata?: Metadata): Expression;
|
|
13
|
+
export declare function serializeJsonString(ce: IComputeEngine, s: string): Expression;
|
|
14
|
+
export declare function serializeJsonSymbol(ce: IComputeEngine, sym: string, metadata?: Metadata): Expression;
|
|
15
|
+
export declare function serializeJsonNumber(ce: IComputeEngine, value: number | Decimal | Complex | [number, number], metadata?: Metadata): Expression;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* 0.5.0 */
|
|
2
|
+
export declare function isLatexString(s: any): s is string;
|
|
3
|
+
export declare function latexString(s: any): string | null;
|
|
4
|
+
/**
|
|
5
|
+
* Return a multiple of the imaginary unit, e.g.
|
|
6
|
+
* - 'ImaginaryUnit'
|
|
7
|
+
* - ['Negate', 'ImaginaryUnit']
|
|
8
|
+
* - ['Negate', ['Multiply', 3, 'ImaginaryUnit']]
|
|
9
|
+
* - ['Multiply', 5, 'ImaginaryUnit']
|
|
10
|
+
* - ['Multiply', 'ImaginaryUnit', 5]
|
|
11
|
+
*/
|
|
12
|
+
export declare function getImaginaryCoef(expr: BoxedExpression): number;
|
|
13
|
+
/**
|
|
14
|
+
* Return the free symbols in the expression, recursively.
|
|
15
|
+
* A variable, or free symbol,is a symbol that is not bound to a value.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getVars(expr: BoxedExpression): string[];
|
|
18
|
+
/**
|
|
19
|
+
* For any numeric result, or when boxing numbers,
|
|
20
|
+
* if `ce.useDecimal` is true, create them as Decimal number
|
|
21
|
+
* if `ce.useDecimal` is false, create them as machine number
|
|
22
|
+
*/
|
|
23
|
+
export declare function useDecimal(ce: IComputeEngine): boolean;
|
|
24
|
+
/** If result of a numeric evaluation is a complex number,
|
|
25
|
+
* return `NaN` if `ce.useComplex` is false
|
|
26
|
+
*/
|
|
27
|
+
export declare function complexAllowed(ce: IComputeEngine): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Assert that `expr` is in fact canonical.
|
|
30
|
+
*
|
|
31
|
+
* Called for example from within a `canonical` handler.
|
|
32
|
+
*
|
|
33
|
+
* To make an expression whose canonical status is unknown, canonical, call
|
|
34
|
+
* `expr.canonical`.
|
|
35
|
+
*/
|
|
36
|
+
export declare function asCanonical(expr: BoxedExpression): BoxedExpression;
|
|
37
|
+
export declare function hashCode(s: string): number;
|