@cortex-js/compute-engine 0.25.0 → 0.26.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 +27153 -25341
- package/dist/compute-engine.js +27124 -25300
- package/dist/compute-engine.min.esm.js +88 -23
- package/dist/compute-engine.min.js +88 -23
- package/dist/math-json.esm.js +42 -196
- package/dist/math-json.js +42 -196
- package/dist/math-json.min.esm.js +42 -196
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +30 -4
- package/dist/types/common/buffer.d.ts +9 -0
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +9 -0
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/styled-text.d.ts +28 -0
- package/dist/types/common/suggest.d.ts +1 -0
- package/dist/types/common/syntax-highlighter.d.ts +40 -0
- package/dist/types/common/terminal.d.ts +19 -0
- package/dist/types/common/type/parse.d.ts +4 -0
- package/dist/types/common/type/primitive.d.ts +8 -0
- package/dist/types/common/type/serialize.d.ts +2 -0
- package/dist/types/common/type/subtype.d.ts +6 -0
- package/dist/types/common/type/types.d.ts +249 -0
- package/dist/types/common/type/utils.d.ts +39 -0
- package/dist/types/common/utils.d.ts +2 -1
- package/dist/types/compute-engine/assume.d.ts +13 -13
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +71 -47
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +5 -0
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +16 -0
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +20 -0
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +11 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +13 -71
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +31 -13
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +66 -45
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +41 -37
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +13 -9
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +34 -66
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +63 -41
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +44 -27
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +6 -0
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +13 -0
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +20 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -6
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +25 -0
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +9 -0
- package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -4
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +10 -0
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +5 -39
- package/dist/types/compute-engine/boxed-expression/order.d.ts +26 -14
- package/dist/types/compute-engine/{symbolic → boxed-expression}/polynomials.d.ts +11 -15
- package/dist/types/compute-engine/{symbolic → boxed-expression}/product.d.ts +18 -24
- package/dist/types/compute-engine/boxed-expression/public.d.ts +947 -656
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +129 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +6 -0
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +6 -0
- package/dist/types/compute-engine/{solve.d.ts → boxed-expression/solve.d.ts} +5 -5
- package/dist/types/compute-engine/{symbolic → boxed-expression}/tensor-fields.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +10 -0
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +10 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +22 -16
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -7
- package/dist/types/compute-engine/collection-utils.d.ts +24 -2
- package/dist/types/compute-engine/compile.d.ts +3 -3
- package/dist/types/compute-engine/compute-engine.d.ts +133 -165
- package/dist/types/compute-engine/cost-function.d.ts +11 -1
- package/dist/types/compute-engine/function-utils.d.ts +5 -5
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +25 -30
- package/dist/types/compute-engine/latex-syntax/public.d.ts +22 -18
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +5 -8
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +4 -2
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +24 -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 -3
- package/dist/types/compute-engine/library/invisible-operator.d.ts +4 -0
- package/dist/types/compute-engine/library/library.d.ts +2 -4
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +5 -1
- package/dist/types/compute-engine/library/polynomials.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/utils.d.ts +46 -40
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +59 -0
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +77 -0
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +58 -0
- package/dist/types/compute-engine/numeric-value/public.d.ts +110 -0
- package/dist/types/compute-engine/numerics/bigint.d.ts +2 -0
- package/dist/types/compute-engine/numerics/bignum.d.ts +12 -0
- package/dist/types/compute-engine/numerics/expression.d.ts +4 -0
- package/dist/types/compute-engine/numerics/interval.d.ts +12 -0
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +19 -0
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +4 -14
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +6 -9
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +9 -59
- package/dist/types/compute-engine/numerics/primes.d.ts +3 -3
- package/dist/types/compute-engine/numerics/rationals.d.ts +29 -13
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +28 -0
- package/dist/types/compute-engine/numerics/strings.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +8 -4
- package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -2
- package/dist/types/compute-engine/symbolic/distribute.d.ts +5 -0
- package/dist/types/compute-engine/{simplify-rules.d.ts → symbolic/simplify-rules.d.ts} +1 -1
- package/dist/types/compute-engine/{symbolic → tensor}/tensors.d.ts +3 -3
- package/dist/types/compute-engine.d.ts +4 -2
- package/dist/types/math-json/identifiers.d.ts +11 -0
- package/dist/types/math-json/{math-json-format.d.ts → types.d.ts} +4 -9
- package/dist/types/math-json/utils.d.ts +15 -23
- package/dist/types/math-json.d.ts +3 -3
- package/package.json +11 -11
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -48
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +0 -40
- package/dist/types/compute-engine/domain-utils.d.ts +0 -19
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +0 -21
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +0 -17
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +0 -16
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +0 -11
- package/dist/types/compute-engine/library/domains.d.ts +0 -16
- package/dist/types/compute-engine/numerics/terms.d.ts +0 -17
- package/dist/types/compute-engine/rules.d.ts +0 -20
- package/dist/types/compute-engine/symbolic/expand.d.ts +0 -23
- package/dist/types/compute-engine/symbolic/flatten.d.ts +0 -9
- package/dist/types/compute-engine/symbolic/negate.d.ts +0 -11
- package/dist/types/compute-engine/symbolic/utils.d.ts +0 -22
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
import type { Expression } from '../../math-json/types';
|
|
3
|
+
import type { Type, TypeString } from '../../common/type/types';
|
|
4
|
+
import type { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, BoxedSubstitution, Rule, CanonicalOptions, BoxedRule, Sign } from './public';
|
|
5
|
+
import { NumericValue } from '../numeric-value/public';
|
|
4
6
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
5
|
-
import {
|
|
7
|
+
import { BigNum } from '../numerics/bignum';
|
|
8
|
+
import type { OneOf } from '../../common/one-of';
|
|
6
9
|
/**
|
|
7
10
|
* BoxedSymbol
|
|
8
11
|
*
|
|
@@ -24,16 +27,23 @@ export declare class BoxedSymbol extends _BoxedExpression {
|
|
|
24
27
|
protected _id: string;
|
|
25
28
|
private _hash;
|
|
26
29
|
private _def;
|
|
30
|
+
private _isStructural;
|
|
27
31
|
constructor(ce: IComputeEngine, name: string, options?: {
|
|
28
32
|
metadata?: Metadata;
|
|
29
33
|
canonical?: CanonicalOptions;
|
|
30
|
-
|
|
34
|
+
structural?: boolean;
|
|
35
|
+
def?: OneOf<[BoxedSymbolDefinition, BoxedFunctionDefinition]>;
|
|
31
36
|
});
|
|
32
37
|
get json(): Expression;
|
|
33
38
|
get hash(): number;
|
|
34
39
|
get isPure(): boolean;
|
|
40
|
+
get isStructural(): boolean;
|
|
41
|
+
get structural(): BoxedExpression;
|
|
35
42
|
get scope(): RuntimeScope | null;
|
|
36
43
|
get isConstant(): boolean;
|
|
44
|
+
private _lookupDef;
|
|
45
|
+
/** This method returns the definition associated with the value of this symbol, or associated with the symbol if it has no value. This is the definition to use with most operations on the symbol. Indeed, "x[2]" is accessing the second element of **the value** of "x".*/
|
|
46
|
+
private _getDef;
|
|
37
47
|
/**
|
|
38
48
|
* Associate a definition with this symbol
|
|
39
49
|
*/
|
|
@@ -41,49 +51,53 @@ export declare class BoxedSymbol extends _BoxedExpression {
|
|
|
41
51
|
reset(): void;
|
|
42
52
|
get isCanonical(): boolean;
|
|
43
53
|
set isCanonical(val: boolean);
|
|
54
|
+
is(rhs: any): boolean;
|
|
44
55
|
get canonical(): BoxedExpression;
|
|
56
|
+
toNumericValue(): [NumericValue, BoxedExpression];
|
|
57
|
+
neg(): BoxedExpression;
|
|
58
|
+
inv(): BoxedExpression;
|
|
59
|
+
abs(): BoxedExpression;
|
|
60
|
+
add(rhs: number | BoxedExpression): BoxedExpression;
|
|
61
|
+
mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
|
|
62
|
+
div(rhs: number | BoxedExpression): BoxedExpression;
|
|
63
|
+
pow(exp: number | BoxedExpression): BoxedExpression;
|
|
64
|
+
root(n: number | BoxedExpression): BoxedExpression;
|
|
65
|
+
sqrt(): BoxedExpression;
|
|
66
|
+
ln(semiBase?: number | BoxedExpression): BoxedExpression;
|
|
45
67
|
solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
|
|
46
68
|
get complexity(): number;
|
|
47
|
-
get
|
|
69
|
+
get operator(): string;
|
|
48
70
|
get symbol(): string;
|
|
49
71
|
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
50
72
|
get symbolDefinition(): BoxedSymbolDefinition | undefined;
|
|
51
73
|
get functionDefinition(): BoxedFunctionDefinition | undefined;
|
|
52
74
|
/**
|
|
53
75
|
* Subsequence inferences will narrow the domain of the symbol.
|
|
54
|
-
* f
|
|
55
|
-
* g(x) => x:real
|
|
56
|
-
* f(x) => x:integer narrowed from integer to real
|
|
76
|
+
* f: integer -> real, g: real -> real
|
|
77
|
+
* g(x) => x: real
|
|
78
|
+
* f(x) => x: integer narrowed from integer to real
|
|
57
79
|
*/
|
|
58
|
-
infer(
|
|
59
|
-
get value(): number | boolean | string |
|
|
60
|
-
set value(value: boolean | string | Decimal |
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
infer(t: Type): boolean;
|
|
81
|
+
get value(): number | boolean | string | object | undefined;
|
|
82
|
+
set value(value: boolean | string | Decimal | number[] | OneOf<[
|
|
83
|
+
{
|
|
84
|
+
re: number;
|
|
85
|
+
im: number;
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
num: number;
|
|
89
|
+
denom: number;
|
|
90
|
+
},
|
|
91
|
+
BoxedExpression
|
|
92
|
+
]> | number | object | undefined);
|
|
93
|
+
get type(): Type;
|
|
94
|
+
set type(t: Type | TypeString);
|
|
95
|
+
get sgn(): Sign | undefined;
|
|
70
96
|
has(x: string | string[]): boolean;
|
|
71
|
-
|
|
72
|
-
match(pattern: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression | BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
73
|
-
isEqual(rhs: BoxedExpression): boolean;
|
|
74
|
-
isLess(rhs: BoxedExpression): boolean | undefined;
|
|
75
|
-
isLessEqual(rhs: BoxedExpression): boolean | undefined;
|
|
76
|
-
isGreater(rhs: BoxedExpression): boolean | undefined;
|
|
77
|
-
isGreaterEqual(rhs: BoxedExpression): boolean | undefined;
|
|
97
|
+
match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
78
98
|
get isFunction(): boolean | undefined;
|
|
79
|
-
get isZero(): boolean | undefined;
|
|
80
|
-
get isNotZero(): boolean | undefined;
|
|
81
|
-
get isOne(): boolean | undefined;
|
|
82
|
-
get isNegativeOne(): boolean | undefined;
|
|
83
99
|
get isOdd(): boolean | undefined;
|
|
84
100
|
get isEven(): boolean | undefined;
|
|
85
|
-
get isPrime(): boolean | undefined;
|
|
86
|
-
get isComposite(): boolean | undefined;
|
|
87
101
|
get isInfinity(): boolean | undefined;
|
|
88
102
|
get isNaN(): boolean | undefined;
|
|
89
103
|
get isPositive(): boolean | undefined;
|
|
@@ -93,17 +107,25 @@ export declare class BoxedSymbol extends _BoxedExpression {
|
|
|
93
107
|
get isNumber(): boolean | undefined;
|
|
94
108
|
get isInteger(): boolean | undefined;
|
|
95
109
|
get isRational(): boolean | undefined;
|
|
96
|
-
get isAlgebraic(): boolean | undefined;
|
|
97
110
|
get isReal(): boolean | undefined;
|
|
98
|
-
get
|
|
99
|
-
get
|
|
100
|
-
get
|
|
101
|
-
|
|
111
|
+
get re(): number;
|
|
112
|
+
get im(): number;
|
|
113
|
+
get bignumRe(): BigNum | undefined;
|
|
114
|
+
get bignumIm(): BigNum | undefined;
|
|
115
|
+
simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
|
|
102
116
|
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
103
|
-
N(
|
|
104
|
-
replace(rules:
|
|
117
|
+
N(): BoxedExpression;
|
|
118
|
+
replace(rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): BoxedExpression | null;
|
|
105
119
|
subs(sub: Substitution, options?: {
|
|
106
120
|
canonical?: CanonicalOptions;
|
|
107
121
|
}): BoxedExpression;
|
|
122
|
+
get isCollection(): boolean;
|
|
123
|
+
contains(rhs: BoxedExpression): boolean;
|
|
124
|
+
get size(): number;
|
|
125
|
+
each(start?: number, count?: number): Iterator<BoxedExpression, undefined>;
|
|
126
|
+
at(index: number): BoxedExpression | undefined;
|
|
127
|
+
get(index: BoxedExpression | string): BoxedExpression | undefined;
|
|
128
|
+
indexOf(expr: BoxedExpression): number;
|
|
129
|
+
subsetOf(rhs: BoxedExpression, strict: boolean): boolean;
|
|
108
130
|
}
|
|
109
131
|
export declare function makeCanonicalSymbol(ce: IComputeEngine, name: string): BoxedExpression;
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DataTypeMap, TensorDataType } from '../symbolic/tensor-fields';
|
|
6
|
-
import { AbstractTensor, TensorData } from '../symbolic/tensors';
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
import type { BoxedExpression, IComputeEngine, EvaluateOptions, SimplifyOptions, Metadata, BoxedSubstitution, PatternMatchOptions, BoxedBaseDefinition, BoxedFunctionDefinition } from '../public';
|
|
3
|
+
import { TensorDataType } from './tensor-fields';
|
|
4
|
+
import { NumericValue } from '../numeric-value/public';
|
|
7
5
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
6
|
+
import { AbstractTensor, TensorData } from '../tensor/tensors';
|
|
7
|
+
import { Type } from '../../common/type/types';
|
|
8
8
|
/**
|
|
9
|
-
* A boxed tensor represents an expression that can be
|
|
10
|
-
*
|
|
11
|
-
* or multi-dimensional array.
|
|
9
|
+
* A boxed tensor represents an expression that can be represented by a tensor.
|
|
10
|
+
* This could be a vector, matrix or multi-dimensional array.
|
|
12
11
|
*
|
|
13
|
-
* The object can be created either from a tensor or from
|
|
14
|
-
*
|
|
12
|
+
* The object can be created either from a tensor or from an expression that
|
|
13
|
+
* can be represented as a tensor.
|
|
15
14
|
*
|
|
16
|
-
* The counterpart (expression if input is tensor, or tensor
|
|
15
|
+
* The structural counterpart (expression if input is tensor, or tensor
|
|
17
16
|
* if input is expression) is created lazily.
|
|
18
17
|
*
|
|
19
18
|
* @noInheritDoc
|
|
20
19
|
*
|
|
21
20
|
*/
|
|
22
21
|
export declare class BoxedTensor extends _BoxedExpression {
|
|
22
|
+
readonly options?: {
|
|
23
|
+
metadata?: Metadata;
|
|
24
|
+
canonical?: boolean;
|
|
25
|
+
};
|
|
23
26
|
private _tensor;
|
|
24
|
-
private readonly
|
|
27
|
+
private readonly _operator?;
|
|
25
28
|
private readonly _ops?;
|
|
26
29
|
private _expression;
|
|
27
30
|
constructor(ce: IComputeEngine, input: {
|
|
28
|
-
|
|
31
|
+
op?: string;
|
|
29
32
|
ops: ReadonlyArray<BoxedExpression>;
|
|
30
33
|
} | AbstractTensor<'expression'>, options?: {
|
|
31
34
|
metadata?: Metadata;
|
|
32
35
|
canonical?: boolean;
|
|
33
36
|
});
|
|
34
|
-
get
|
|
37
|
+
get structural(): BoxedExpression;
|
|
35
38
|
/** Create the tensor on demand */
|
|
36
39
|
get tensor(): AbstractTensor<'expression'>;
|
|
37
40
|
get baseDefinition(): BoxedBaseDefinition | undefined;
|
|
@@ -45,28 +48,42 @@ export declare class BoxedTensor extends _BoxedExpression {
|
|
|
45
48
|
get isPure(): boolean;
|
|
46
49
|
get isValid(): boolean;
|
|
47
50
|
get complexity(): number;
|
|
48
|
-
get
|
|
51
|
+
get operator(): string;
|
|
49
52
|
get nops(): number;
|
|
50
53
|
get ops(): ReadonlyArray<BoxedExpression>;
|
|
51
54
|
get op1(): BoxedExpression;
|
|
52
55
|
get op2(): BoxedExpression;
|
|
53
56
|
get op3(): BoxedExpression;
|
|
57
|
+
neg(): BoxedExpression;
|
|
58
|
+
inv(): BoxedExpression;
|
|
59
|
+
abs(): BoxedExpression;
|
|
60
|
+
add(rhs: number | BoxedExpression): BoxedExpression;
|
|
61
|
+
sub(rhs: BoxedExpression): BoxedExpression;
|
|
62
|
+
mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
|
|
63
|
+
div(rhs: number | BoxedExpression): BoxedExpression;
|
|
64
|
+
pow(exp: number | BoxedExpression): BoxedExpression;
|
|
65
|
+
root(exp: number | BoxedExpression): BoxedExpression;
|
|
66
|
+
sqrt(): BoxedExpression;
|
|
54
67
|
get shape(): number[];
|
|
55
68
|
get rank(): number;
|
|
56
|
-
get
|
|
69
|
+
get type(): Type;
|
|
57
70
|
get json(): Expression;
|
|
58
|
-
/** Structural equality */
|
|
59
|
-
isSame(rhs: BoxedExpression): boolean;
|
|
60
71
|
/** Mathematical equality */
|
|
61
|
-
isEqual(rhs: BoxedExpression): boolean;
|
|
62
|
-
|
|
72
|
+
isEqual(rhs: number | BoxedExpression): boolean | undefined;
|
|
73
|
+
get isCollection(): boolean;
|
|
74
|
+
contains(rhs: BoxedExpression): boolean;
|
|
75
|
+
get size(): number;
|
|
76
|
+
each(start?: number, count?: number): Iterator<BoxedExpression, undefined>;
|
|
77
|
+
at(_index: number): BoxedExpression | undefined;
|
|
78
|
+
indexOf(_expr: BoxedExpression): number;
|
|
79
|
+
match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
63
80
|
evaluate(options?: EvaluateOptions): BoxedExpression;
|
|
64
|
-
simplify(options?: SimplifyOptions): BoxedExpression;
|
|
65
|
-
N(
|
|
81
|
+
simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
|
|
82
|
+
N(): BoxedExpression;
|
|
66
83
|
}
|
|
67
84
|
export declare function isBoxedTensor(val: unknown): val is BoxedTensor;
|
|
68
|
-
export declare function expressionTensorInfo(
|
|
85
|
+
export declare function expressionTensorInfo(operator: string, rows: ReadonlyArray<BoxedExpression>): {
|
|
69
86
|
shape: number[];
|
|
70
|
-
dtype:
|
|
71
|
-
};
|
|
72
|
-
export declare function expressionAsTensor<T extends TensorDataType>(
|
|
87
|
+
dtype: TensorDataType | undefined;
|
|
88
|
+
} | undefined;
|
|
89
|
+
export declare function expressionAsTensor<T extends TensorDataType = 'expression'>(operator: string, rows: ReadonlyArray<BoxedExpression>): TensorData<T> | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.26.0 */
|
|
2
2
|
export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions): BoxedExpression;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
/**
|
|
3
|
+
* Structural equality of boxed expressions.
|
|
4
|
+
*/
|
|
5
|
+
export declare function same(a: BoxedExpression, b: BoxedExpression): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Mathematically equality of two boxed expressions.
|
|
8
|
+
*
|
|
9
|
+
* In general, it is impossible to always prove equality
|
|
10
|
+
* ([Richardson's theorem](https://en.wikipedia.org/wiki/Richardson%27s_theorem)) but this works often...
|
|
11
|
+
*/
|
|
12
|
+
export declare function eq(a: BoxedExpression, b: number | BoxedExpression): boolean | undefined;
|
|
13
|
+
export declare function cmp(a: BoxedExpression, b: number | BoxedExpression): '<' | '=' | '>' | '>=' | '<=' | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
export declare function expandProducts(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
|
|
3
|
+
export declare function choose(n: number, k: number): number;
|
|
4
|
+
/** Attempt to transform the expression (h, ops) into a sum */
|
|
5
|
+
export declare function expandFunction(ce: IComputeEngine, h: string, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
|
|
6
|
+
/** Apply the distributive law if the expression is a product of sums.
|
|
7
|
+
* For example, a(b + c) = ab + ac
|
|
8
|
+
* Expand the expression if it is a power of a sum.
|
|
9
|
+
* Expand the terms of the expression if it is a sum or negate.
|
|
10
|
+
* If the expression is a fraction, expand the numerator.
|
|
11
|
+
* If the exression is a relational operator, expand the operands.
|
|
12
|
+
* Return null if the expression cannot be expanded.
|
|
13
|
+
*/
|
|
14
|
+
export declare function expand(expr: BoxedExpression | undefined): BoxedExpression | null;
|
|
15
|
+
/**
|
|
16
|
+
* Recursive expand of all terms in the expression.
|
|
17
|
+
*
|
|
18
|
+
* `expand()` only expands the top level of the expression.
|
|
19
|
+
*/
|
|
20
|
+
export declare function expandAll(expr: BoxedExpression): BoxedExpression | null;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import
|
|
3
|
-
import { Rational } from '../numerics/rationals';
|
|
4
|
-
import { BoxedExpression } from './public';
|
|
5
|
-
export declare function applyCoefficient(value: number | Decimal | Complex | Rational | null, coef: Rational): number | Decimal | Complex | Rational | null;
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
import { NumericValue } from '../numeric-value/public';
|
|
6
3
|
/** Combine rational expressions into a single fraction */
|
|
7
4
|
export declare function together(op: BoxedExpression): BoxedExpression;
|
|
8
5
|
/**
|
|
9
|
-
* Return
|
|
6
|
+
* Return an expression factored as a product.
|
|
7
|
+
* - 2x + 4 -> 2(x + 2)
|
|
8
|
+
* - 2x < 4 -> x < 2
|
|
9
|
+
* - (2x) * (2y) -> 4xy
|
|
10
10
|
*/
|
|
11
11
|
export declare function factor(expr: BoxedExpression): BoxedExpression;
|
|
12
|
+
export declare function getPiTerm(expr: BoxedExpression): [k: NumericValue, t: NumericValue];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Make all the arguments canonical.
|
|
5
|
+
*
|
|
6
|
+
* "Lift" Sequence expressions to the top level.
|
|
7
|
+
* e.g. `["Add", 1, ["Sequence", 2, 3]]` -> `["Add", 1, 2, 3]`
|
|
8
|
+
*
|
|
9
|
+
* Additionally, if an operator is provided, also lift nested expressions
|
|
10
|
+
* with the same operator.
|
|
11
|
+
* e.g. `["f", a, ["f", b, c]]` -> `["f", a, b, c]`
|
|
12
|
+
*
|
|
13
|
+
* Note: *not* recursive
|
|
14
|
+
*/
|
|
15
|
+
export declare function flatten<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator?: string): T;
|
|
16
|
+
/**
|
|
17
|
+
* Flatten the arguments.
|
|
18
|
+
* @fixme replace with just flatten.
|
|
19
|
+
* @fixme consider adding flatternSort()
|
|
20
|
+
*/
|
|
21
|
+
export declare function flattenOps<T extends ReadonlyArray<BoxedExpression> | BoxedExpression[]>(ops: T, operator: string): T;
|
|
22
|
+
/**
|
|
23
|
+
* @todo: this function should probably not be recursive. As it, it is semi-recursive.
|
|
24
|
+
*/
|
|
25
|
+
export declare function flattenSequence(xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
/** Apply the function `f` to each operand of the expression `expr`,
|
|
3
|
+
* account for the 'hold' property of the function definition:
|
|
4
|
+
*
|
|
5
|
+
* Account for `Hold`, `ReleaseHold`, `Sequence`, `Symbol` and `Nothing`.
|
|
6
|
+
*
|
|
7
|
+
* If `f` returns `null`, the element is not added to the result
|
|
8
|
+
*/
|
|
9
|
+
export declare function holdMap(expr: BoxedExpression, f: (x: BoxedExpression) => BoxedExpression | null): ReadonlyArray<BoxedExpression>;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import Decimal from 'decimal.js';
|
|
3
|
-
import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpression } from './public';
|
|
1
|
+
/* 0.26.0 */
|
|
4
2
|
/**
|
|
5
3
|
* The function attempts to match a subject expression to a
|
|
6
4
|
* [pattern](/compute-engine/guides/patterns-and-rules/).
|
|
@@ -11,4 +9,4 @@ import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpre
|
|
|
11
9
|
* If the expression does not match the pattern, it returns `null`.
|
|
12
10
|
*
|
|
13
11
|
*/
|
|
14
|
-
export declare function match(subject: BoxedExpression, pattern:
|
|
12
|
+
export declare function match(subject: BoxedExpression, pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
/**
|
|
3
|
+
* Distribute `Negate` (multiply by -1) if expr is a number literal, an
|
|
4
|
+
* addition or multiplication or another `Negate`.
|
|
5
|
+
*
|
|
6
|
+
* It is important to do all these to handle cases like
|
|
7
|
+
* `-3x` -> ["Negate, ["Multiply", 3, "x"]] -> ["Multiply, -3, x]
|
|
8
|
+
*/
|
|
9
|
+
export declare function negate(expr: BoxedExpression): BoxedExpression;
|
|
10
|
+
export declare function negateProduct(ce: IComputeEngine, args: ReadonlyArray<BoxedExpression>): BoxedExpression;
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { Rational } from '../numerics/rationals';
|
|
3
|
-
import { BoxedExpression } from './public';
|
|
4
|
-
/**
|
|
5
|
-
* Attempt to factor a numeric coefficient `c` and a `rest` out of a
|
|
6
|
-
* canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
|
|
7
|
-
*
|
|
8
|
-
* Attempts to make `rest` a positive value (i.e. pulls out negative sign).
|
|
9
|
-
*
|
|
10
|
-
* For example:
|
|
11
|
-
*
|
|
12
|
-
* ['Multiply', 2, 'x', 3, 'a']
|
|
13
|
-
* -> [6, ['Multiply', 'x', 'a']]
|
|
14
|
-
*
|
|
15
|
-
* ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
|
|
16
|
-
* -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
|
|
17
|
-
*/
|
|
18
|
-
export declare function asCoefficient(expr: BoxedExpression): [coef: Rational, rest: BoxedExpression];
|
|
1
|
+
/* 0.26.0 */
|
|
2
|
+
import type { Rational } from '../numerics/rationals';
|
|
3
|
+
import type { BoxedExpression } from './public';
|
|
19
4
|
export declare function asRational(expr: BoxedExpression): Rational | undefined;
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function div(lhs: Rational, rhs: Rational): Rational;
|
|
22
|
-
/**
|
|
23
|
-
* Add a literal numeric value to a rational.
|
|
24
|
-
* If the rational is a bigint, this is a hint to do the calculation in bigint
|
|
25
|
-
* (no need to check `bignumPreferred()`).
|
|
26
|
-
* @param lhs
|
|
27
|
-
* @param rhs
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
export declare function add(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
|
|
31
|
-
export declare function mul(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
|
|
32
|
-
export declare function asFloat(expr: BoxedExpression | undefined): number | null;
|
|
5
|
+
export declare function asBigint(expr: BoxedExpression | undefined): bigint | null;
|
|
33
6
|
export declare function asBignum(expr: BoxedExpression | undefined): Decimal | null;
|
|
34
|
-
export declare function
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param lhs
|
|
38
|
-
* @param rhs
|
|
39
|
-
* @returns the sign (-1, 0, 1) of the difference between `lhs` and `rhs`
|
|
40
|
-
*/
|
|
41
|
-
export declare function signDiff(lhs: BoxedExpression, rhs: BoxedExpression, tolerance?: number): -1 | 0 | 1 | undefined;
|
|
7
|
+
export declare function asSmallInteger(expr: number | BoxedExpression | undefined): number | null;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.26.0 */
|
|
2
2
|
export type Order = 'lex' | 'dexlex' | 'grevlex' | 'elim';
|
|
3
3
|
export declare const DEFAULT_COMPLEXITY = 100000;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* The sorting order of arguments of the Add function uses a modified degrevlex:
|
|
6
|
+
* - Sort by total degree (sum of degree)
|
|
7
|
+
* - Sort by max degree.
|
|
8
|
+
* - Sort reverse lexicographically
|
|
9
|
+
* - Sort by rank
|
|
10
|
+
*
|
|
11
|
+
*
|
|
12
|
+
* E.g.
|
|
13
|
+
* - 2x^2 + 3x + 1
|
|
14
|
+
* - 2x^2y^3 + 5x^3y
|
|
7
15
|
*/
|
|
8
|
-
export declare function
|
|
16
|
+
export declare function addOrder(a: BoxedExpression, b: BoxedExpression): number;
|
|
17
|
+
export declare function equalOrder(a: BoxedExpression, b: BoxedExpression): number;
|
|
18
|
+
declare const RANKS: readonly ["integer", "rational", "radical", "real", "complex", "constant", "symbol", "multiply", "divide", "add", "trig", "fn", "power", "string", "other"];
|
|
19
|
+
export type Rank = (typeof RANKS)[number];
|
|
9
20
|
/**
|
|
10
21
|
* Given two expressions `a` and `b`, return:
|
|
11
22
|
* - `-1` if `a` should be ordered before `b`
|
|
@@ -15,7 +26,7 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
|
|
|
15
26
|
* The default order is as follow:
|
|
16
27
|
*
|
|
17
28
|
* 1/ Literal numeric values (rational, machine numbers and Decimal numbers),
|
|
18
|
-
* ordered by
|
|
29
|
+
* ordered by their numeric value (smaller numbers before larger numbers)
|
|
19
30
|
*
|
|
20
31
|
* 2/ Literal complex numbers, ordered by their real parts. In case of a tie,
|
|
21
32
|
* ordered by the absolute value of their imaginary parts. In case of a tie,
|
|
@@ -26,7 +37,7 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
|
|
|
26
37
|
* 4/ Addition, ordered as a polynom, with higher degree terms first
|
|
27
38
|
*
|
|
28
39
|
* 5/ Other functions, ordered by their `complexity` property. In case
|
|
29
|
-
* of a tie, ordered by the
|
|
40
|
+
* of a tie, ordered by the operator of the expression as a string. In case of a
|
|
30
41
|
* tie, by the leaf count of each expression. In case of a tie, by the order
|
|
31
42
|
* of each argument, left to right.
|
|
32
43
|
*
|
|
@@ -35,9 +46,8 @@ export declare function sortAdd(ops: ReadonlyArray<BoxedExpression>): ReadonlyAr
|
|
|
35
46
|
* example "E" < "e" < "È" and "11" < "2". This ordering is not suitable to
|
|
36
47
|
* collate natural language strings.
|
|
37
48
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
49
|
+
* See https://reference.wolfram.com/language/ref/Sort.html for a
|
|
50
|
+
* description of the ordering of expressions in Mathematica.
|
|
41
51
|
*
|
|
42
52
|
*/
|
|
43
53
|
export declare function order(a: BoxedExpression, b: BoxedExpression): number;
|
|
@@ -47,13 +57,15 @@ export declare function order(a: BoxedExpression, b: BoxedExpression): number;
|
|
|
47
57
|
export declare function canonicalOrder(expr: BoxedExpression, { recursive }: {
|
|
48
58
|
recursive?: boolean;
|
|
49
59
|
}): BoxedExpression;
|
|
60
|
+
export declare function sortOperands(operator: string, xs: ReadonlyArray<BoxedExpression>): ReadonlyArray<BoxedExpression>;
|
|
50
61
|
/**
|
|
51
62
|
* Sort the terms of a polynomial expression (`Add` expression) according
|
|
52
63
|
* to the deglex polynomial ordering
|
|
53
64
|
*
|
|
54
65
|
*/
|
|
55
|
-
export declare function polynomialOrder(expr: BoxedExpression):
|
|
56
|
-
export declare function lexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>):
|
|
57
|
-
export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>):
|
|
58
|
-
export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>):
|
|
59
|
-
export declare function eliminationOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>):
|
|
66
|
+
export declare function polynomialOrder(expr: BoxedExpression): BoxedExpression;
|
|
67
|
+
export declare function lexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
|
|
68
|
+
export declare function degreeLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
|
|
69
|
+
export declare function degreeReverseLexicographicOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
|
|
70
|
+
export declare function eliminationOrder(expr: BoxedExpression, vars?: ReadonlyArray<string>): BoxedExpression;
|
|
71
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.26.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Coefficient of a univariate (single variable) polynomial.
|
|
4
4
|
*
|
|
@@ -22,31 +22,27 @@ export type MultivariateCoefficients = (null | (null | BoxedExpression)[])[];
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function coefficients(poly: BoxedExpression, vars: string): UnivariateCoefficients | null;
|
|
24
24
|
export declare function coefficients(poly: BoxedExpression, vars: string[]): MultivariateCoefficients | null;
|
|
25
|
-
/**
|
|
26
|
-
* Return a polynomial expression of `vars` with coefficient
|
|
27
|
-
* of powers `coefs`.
|
|
28
|
-
*
|
|
29
|
-
* `poly === polynomial(coefficients(poly), getVars(poly))`
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
export declare function polynomial(coefs: UnivariateCoefficients, vars: string): SemiBoxedExpression;
|
|
33
|
-
export declare function polynomial(coefs: MultivariateCoefficients, vars: string[]): SemiBoxedExpression;
|
|
34
25
|
/**
|
|
35
26
|
* The total degree of an expression is the sum of the
|
|
36
|
-
*
|
|
27
|
+
* positive integer degrees of the factors in the expression:
|
|
37
28
|
*
|
|
38
|
-
* `3√2x^5y^3` ->
|
|
29
|
+
* `3√2x^5y^3` -> 5 + 3 = 8
|
|
39
30
|
*/
|
|
40
31
|
export declare function totalDegree(expr: BoxedExpression): number;
|
|
41
32
|
/**
|
|
42
|
-
* The max degree of
|
|
43
|
-
* in the factors of the expression
|
|
33
|
+
* The max degree of a polynomial is the largest positive integer degree
|
|
34
|
+
* in the factors (monomials) of the expression
|
|
44
35
|
*
|
|
45
36
|
* `3√2x^5y^3` -> 5
|
|
46
37
|
*
|
|
47
38
|
*/
|
|
48
39
|
export declare function maxDegree(expr: BoxedExpression): number;
|
|
49
40
|
/**
|
|
50
|
-
* Return a lexicographic key of the expression
|
|
41
|
+
* Return a lexicographic key of the expression, for example
|
|
42
|
+
* `xy^2` -> `x y`
|
|
43
|
+
* `x\frac{1}{y}` -> `x y`
|
|
44
|
+
* `2xy + y^2` -> `x y y`
|
|
45
|
+
*
|
|
51
46
|
*/
|
|
52
47
|
export declare function lex(expr: BoxedExpression): string;
|
|
48
|
+
export declare function revlex(expr: BoxedExpression): string;
|