@cortex-js/compute-engine 0.21.0 → 0.22.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 +6 -3
- package/dist/compute-engine.esm.js +6311 -4602
- package/dist/compute-engine.js +6311 -4602
- package/dist/compute-engine.min.esm.js +10 -10
- package/dist/compute-engine.min.js +10 -10
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +4 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
- 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 +11 -3
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +2 -1
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +69 -0
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -0
- 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 +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +7 -6
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/{definitions-inequalities.d.ts → 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/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/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 +3 -3
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/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 +2 -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/linear-algebra.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/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 +5 -5
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +64 -30
- package/dist/types/compute-engine/rules.d.ts +9 -13
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +2 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +168 -0
- package/dist/types/compute-engine/symbolic/tensors.d.ts +103 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
import { FunctionDefinition, IComputeEngine, IdentifierDefinitions, SymbolDefinition } from '../public';
|
|
3
3
|
export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
|
|
4
4
|
export declare const LIBRARIES: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const LOGIC_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare function randomExpression(level?: number): Expression;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const RELOP_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const SETS_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Assume the caller has setup a scope. The index
|
|
4
4
|
* variable will be declared in that scope.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param indexingSet
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function canonicalIndexingSet(indexingSet: BoxedExpression | undefined): BoxedExpression | undefined;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* IndexingSet is an expression describing an index variable
|
|
12
12
|
* and a range of values for that variable.
|
|
13
13
|
*
|
|
14
14
|
* This can take several valid forms:
|
|
@@ -21,7 +21,7 @@ export declare function canonicalLimits(limits: BoxedExpression | undefined): Bo
|
|
|
21
21
|
* @param limits
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function normalizeIndexingSet(limits: BoxedExpression | undefined): [
|
|
25
25
|
index: string | undefined,
|
|
26
26
|
lower: number,
|
|
27
27
|
upper: number,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
* The most important classes are {@link ComputeEngine} and
|
|
3
3
|
* {@link BoxedExpression}.
|
|
4
4
|
*
|
|
@@ -91,40 +91,39 @@ export type BoxedSubstitution = Substitution<BoxedExpression>;
|
|
|
91
91
|
* `"$\frac{\pi}{2}$"`.
|
|
92
92
|
*/
|
|
93
93
|
export type LatexString = string;
|
|
94
|
+
export type PatternReplaceFunction = (expr: BoxedExpression, wildcards: BoxedSubstitution) => BoxedExpression;
|
|
95
|
+
export type PatternConditionFunction = (wildcards: BoxedSubstitution, ce: IComputeEngine) => boolean;
|
|
94
96
|
/**
|
|
95
|
-
* A rule describes how to modify an expressions that matches a `
|
|
96
|
-
* into a new
|
|
97
|
+
* A rule describes how to modify an expressions that matches a pattern `match`
|
|
98
|
+
* into a new expression `replace`.
|
|
97
99
|
*
|
|
98
100
|
* `x-1` \( \to \) `1-x`
|
|
99
101
|
* `(x+1)(x-1)` \( \to \) `x^2-1
|
|
100
102
|
*
|
|
101
|
-
* The `
|
|
103
|
+
* The `match` pattern can be expressed as a LaTeX string or a MathJSON expression.
|
|
102
104
|
*
|
|
103
|
-
* Unbound variables (`x`, but not `Pi`) are matched structurally with a
|
|
104
|
-
* a target expression, then the expression is rewritten as the `rhs`, with
|
|
105
|
-
* the corresponding unbound variables in the `rhs` replaced by their values
|
|
106
|
-
* in the `lhs.
|
|
107
105
|
*
|
|
108
|
-
*
|
|
106
|
+
* Anonymous wildcards (`_`) will match any
|
|
107
|
+
* expression. Named wildcards (`_x`, `_a`, etc...) will match any expression
|
|
108
|
+
* and bind the expression to the wildcard name.
|
|
109
109
|
*
|
|
110
|
-
* In addition
|
|
111
|
-
*
|
|
112
|
-
* - `___1` (`___a`, etc...) match a sequence of zero or more expressions
|
|
110
|
+
* In addition the sequence wildcard (`__1`, `__a`, etc...) will match a sequence
|
|
111
|
+
* of one or more expressions, and bind the sequence to the wildcard name.
|
|
113
112
|
*/
|
|
114
|
-
export type Rule =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
priority: number
|
|
126
|
-
|
|
127
|
-
|
|
113
|
+
export type Rule = {
|
|
114
|
+
match: LatexString | SemiBoxedExpression | Pattern;
|
|
115
|
+
replace: LatexString | SemiBoxedExpression | PatternReplaceFunction;
|
|
116
|
+
condition?: LatexString | PatternConditionFunction;
|
|
117
|
+
priority?: number;
|
|
118
|
+
id?: string;
|
|
119
|
+
};
|
|
120
|
+
export type BoxedRule = {
|
|
121
|
+
match: Pattern;
|
|
122
|
+
replace: BoxedExpression | PatternReplaceFunction;
|
|
123
|
+
condition: undefined | PatternConditionFunction;
|
|
124
|
+
priority: number;
|
|
125
|
+
id?: string;
|
|
126
|
+
};
|
|
128
127
|
export type BoxedRuleSet = Set<BoxedRule>;
|
|
129
128
|
export type DomainCompatibility = 'covariant' | 'contravariant' | 'bivariant' | 'invariant';
|
|
130
129
|
/** A domain constructor is the head of a domain expression. */
|
|
@@ -189,6 +188,7 @@ export type JsonSerializationOptions = {
|
|
|
189
188
|
*/
|
|
190
189
|
precision: 'auto' | 'max' | number;
|
|
191
190
|
};
|
|
191
|
+
export type CanonicalForm = 'InvisibleOperator' | 'Number' | 'Multiply' | 'Add' | 'Power' | 'Divide' | 'Flatten' | 'Order';
|
|
192
192
|
/**
|
|
193
193
|
* ## THEORY OF OPERATIONS
|
|
194
194
|
*
|
|
@@ -233,6 +233,12 @@ export interface BoxedExpression {
|
|
|
233
233
|
* @category Primitive Methods
|
|
234
234
|
*/
|
|
235
235
|
toString(): string;
|
|
236
|
+
/**
|
|
237
|
+
* Output to the console a string representation of the expression.
|
|
238
|
+
*
|
|
239
|
+
* @category Primitive Methods
|
|
240
|
+
*/
|
|
241
|
+
print(): void;
|
|
236
242
|
/** Similar to`expr.valueOf()` but includes a hint.
|
|
237
243
|
* @category Primitive Methods
|
|
238
244
|
*/
|
|
@@ -590,10 +596,22 @@ export interface BoxedExpression {
|
|
|
590
596
|
* Note it is possible for `numericValue` to be `null`, and for `isNotZero`
|
|
591
597
|
* to be true. For example, when a symbol has been defined with an assumption.
|
|
592
598
|
*
|
|
599
|
+
* Conversely, `isNumber` may be true even if `numericValue` is `null`,
|
|
600
|
+
* example the symbol `Pi` return true for `isNumber` but `numericValue` is
|
|
601
|
+
* `null`. It's value can be accessed with `.value.numericValue`
|
|
602
|
+
*
|
|
593
603
|
* @category Numeric Expression
|
|
594
604
|
*
|
|
595
605
|
*/
|
|
596
606
|
readonly numericValue: number | Decimal | Complex | Rational | null;
|
|
607
|
+
/** The shape describes the axis of the expression.
|
|
608
|
+
* When the expression is a scalar (number), the shape is `[]`.
|
|
609
|
+
* When the expression is a vector, the shape is `[n]`.
|
|
610
|
+
* When the expression is a matrix, the shape is `[n, m]`.
|
|
611
|
+
*/
|
|
612
|
+
readonly shape: number[];
|
|
613
|
+
/** Return 0 for a scalar, 1 for a vector, 2 for a matrix, > 2 for a multidimensional matrix. It's the length of `expr.shape` */
|
|
614
|
+
readonly rank: number;
|
|
597
615
|
/**
|
|
598
616
|
* Return the following, depending on the value of this expression:
|
|
599
617
|
*
|
|
@@ -976,6 +994,14 @@ export interface BoxedExpression {
|
|
|
976
994
|
* of an existing `BoxedExpression` while avoiding unboxing and reboxing.
|
|
977
995
|
*/
|
|
978
996
|
export type SemiBoxedExpression = number | string | Decimal | Complex | MathJsonNumber | MathJsonString | MathJsonSymbol | MathJsonFunction | MathJsonDictionary | SemiBoxedExpression[] | BoxedExpression;
|
|
997
|
+
/**
|
|
998
|
+
* Control how a pattern is matched to an expression.
|
|
999
|
+
*
|
|
1000
|
+
* - `substitution`: if present, assumes these values for the named wildcards, and ensure that subsequent occurence of the same wildcard have the same value.
|
|
1001
|
+
* - `recursive`: if true, match recursively, otherwise match only the top level.
|
|
1002
|
+
* - `numericTolerance`: if present, the tolerance for numeric comparison.
|
|
1003
|
+
* - `exact`: if true, only match expressions that are structurally identical. If false, match expressions that are structurally identical or equivalent. For example, when false, `["Add", '_a', 2]` matches `2`, with a value of `_a` of `0`. If true, the expression does not match.
|
|
1004
|
+
*/
|
|
979
1005
|
export type PatternMatchOptions = {
|
|
980
1006
|
substitution?: BoxedSubstitution;
|
|
981
1007
|
recursive?: boolean;
|
|
@@ -1631,7 +1657,7 @@ export interface IComputeEngine {
|
|
|
1631
1657
|
lookupSymbol(name: string, wikidata?: string, scope?: RuntimeScope): undefined | BoxedSymbolDefinition;
|
|
1632
1658
|
lookupFunction(head: string | BoxedExpression, scope?: RuntimeScope | null): undefined | BoxedFunctionDefinition;
|
|
1633
1659
|
box(expr: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression, options?: {
|
|
1634
|
-
canonical?: boolean;
|
|
1660
|
+
canonical?: boolean | CanonicalForm | CanonicalForm[];
|
|
1635
1661
|
}): BoxedExpression;
|
|
1636
1662
|
canonical(xs: SemiBoxedExpression[]): BoxedExpression[];
|
|
1637
1663
|
number(value: number | bigint | string | MathJsonNumber | Decimal | Complex | Rational, options?: {
|
|
@@ -1644,6 +1670,13 @@ export interface IComputeEngine {
|
|
|
1644
1670
|
}): BoxedExpression;
|
|
1645
1671
|
string(s: string, metadata?: Metadata): BoxedExpression;
|
|
1646
1672
|
domain(domain: BoxedDomain | DomainExpression, metadata?: Metadata): BoxedDomain;
|
|
1673
|
+
/**
|
|
1674
|
+
* Create a boxed function expression.
|
|
1675
|
+
*
|
|
1676
|
+
* @param head
|
|
1677
|
+
* @param ops
|
|
1678
|
+
* @param options
|
|
1679
|
+
*/
|
|
1647
1680
|
fn(head: string | SemiBoxedExpression, ops: SemiBoxedExpression[], options?: {
|
|
1648
1681
|
canonical: boolean;
|
|
1649
1682
|
}): BoxedExpression;
|
|
@@ -1671,18 +1704,19 @@ export interface IComputeEngine {
|
|
|
1671
1704
|
neg(expr: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
1672
1705
|
div(num: BoxedExpression, denom: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
1673
1706
|
pair(first: BoxedExpression, second: BoxedExpression, metadata?: Metadata): BoxedExpression;
|
|
1707
|
+
tuple(elements: number[], metadata?: Metadata): BoxedExpression;
|
|
1674
1708
|
tuple(elements: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
1675
1709
|
array(elements: ArrayValue[] | ArrayValue[][], metadata?: Metadata): BoxedExpression;
|
|
1676
1710
|
rules(rules: Rule[]): BoxedRuleSet;
|
|
1677
1711
|
pattern(expr: LatexString | SemiBoxedExpression): Pattern;
|
|
1678
1712
|
parse(s: LatexString | string, options?: {
|
|
1679
|
-
canonical?: boolean;
|
|
1713
|
+
canonical?: boolean | CanonicalForm | CanonicalForm[];
|
|
1680
1714
|
}): BoxedExpression;
|
|
1681
1715
|
parse(s: null, options?: {
|
|
1682
|
-
canonical?: boolean;
|
|
1716
|
+
canonical?: boolean | CanonicalForm | CanonicalForm[];
|
|
1683
1717
|
}): null;
|
|
1684
1718
|
parse(s: LatexString | string | null, options?: {
|
|
1685
|
-
canonical?: boolean;
|
|
1719
|
+
canonical?: boolean | CanonicalForm | CanonicalForm[];
|
|
1686
1720
|
}): null | BoxedExpression;
|
|
1687
1721
|
serialize(expr: SemiBoxedExpression, options?: {
|
|
1688
1722
|
canonical?: boolean;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* For each rules in the rule set that match, return the `replace` of the rule
|
|
4
|
+
*
|
|
5
5
|
* @param rules
|
|
6
6
|
*/
|
|
7
7
|
export declare function matchRules(expr: BoxedExpression, rules: BoxedRuleSet, sub: BoxedSubstitution): BoxedExpression[];
|
|
8
|
+
/**
|
|
9
|
+
* Create a boxed rule set from a non-boxed rule set
|
|
10
|
+
* @param ce
|
|
11
|
+
* @param rs
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
8
14
|
export declare function boxRules(ce: IComputeEngine, rs: Iterable<Rule>): BoxedRuleSet;
|
|
9
15
|
/**
|
|
10
16
|
* Apply the rules in the ruleset and return a modified expression.
|
|
@@ -12,13 +18,3 @@ export declare function boxRules(ce: IComputeEngine, rs: Iterable<Rule>): BoxedR
|
|
|
12
18
|
* If no rule applied, return `null`.
|
|
13
19
|
*/
|
|
14
20
|
export declare function replace(expr: BoxedExpression, ruleSet: BoxedRuleSet, options?: ReplaceOptions): BoxedExpression | null;
|
|
15
|
-
/**
|
|
16
|
-
* Substitute some symbols with an expression.
|
|
17
|
-
*
|
|
18
|
-
* This is applied recursively to all subexpressions.
|
|
19
|
-
*
|
|
20
|
-
* While `replace()` applies a rule which may include expressions in
|
|
21
|
-
* its `lhs` to an expression, `substitute` is a specialized version
|
|
22
|
-
* that only apply rules that have a `lhs` made of a symbol.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getWildcardName(s: string): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare const UNIVARIATE_ROOTS: Rule[];
|
|
3
3
|
/**
|
|
4
4
|
* Expression is a function of a single variable (`x`) or an Equality
|
|
@@ -15,3 +15,4 @@ export declare function findUnivariateRoots(expr: BoxedExpression, x: string): B
|
|
|
15
15
|
* `2x < 4` => `x < 2`
|
|
16
16
|
*/
|
|
17
17
|
export declare function univariateSolve(expr: BoxedExpression, x: string): SemiBoxedExpression[] | null;
|
|
18
|
+
export declare const HARMONIZATION_RULES: Rule[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
export declare function distribute(expr: BoxedExpression[]): BoxedExpression;
|
|
3
3
|
/** Use the multinomial theorem (https://en.wikipedia.org/wiki/Multinomial_theorem) to expand the expression.
|
|
4
4
|
* The expression must be a power of a sum of terms.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.22.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Flatten the arguments.
|
|
4
4
|
*/
|
|
5
5
|
export declare function flattenOps(ops: BoxedExpression[], head: string): BoxedExpression[];
|
|
6
6
|
export declare function flattenSequence(xs: BoxedExpression[]): BoxedExpression[];
|
|
7
|
+
export declare function flattenDelimiter(ce: IComputeEngine, body: undefined | BoxedExpression): BoxedExpression;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/* 0.22.0 */
|
|
2
|
+
import { BoxedExpression, IComputeEngine } from '../public';
|
|
3
|
+
export type DataTypeMap = {
|
|
4
|
+
float64: number;
|
|
5
|
+
float32: number;
|
|
6
|
+
int32: number;
|
|
7
|
+
uint8: number;
|
|
8
|
+
complex128: Complex;
|
|
9
|
+
complex64: Complex;
|
|
10
|
+
bool: boolean;
|
|
11
|
+
string: string;
|
|
12
|
+
expression: BoxedExpression;
|
|
13
|
+
};
|
|
14
|
+
export type TensorDataType = keyof DataTypeMap;
|
|
15
|
+
export declare function makeTensorField<DT extends keyof DataTypeMap>(ce: IComputeEngine, dtype: DT): TensorField<DataTypeMap[DT]>;
|
|
16
|
+
export interface TensorField<T extends number | Complex | BoxedExpression | boolean | string = number> {
|
|
17
|
+
readonly one: T;
|
|
18
|
+
readonly zero: T;
|
|
19
|
+
readonly nan: T;
|
|
20
|
+
cast(x: T, dtype: 'float64'): undefined | number;
|
|
21
|
+
cast(x: T, dtype: 'float32'): undefined | number;
|
|
22
|
+
cast(x: T, dtype: 'int32'): undefined | number;
|
|
23
|
+
cast(x: T, dtype: 'uint8'): undefined | number;
|
|
24
|
+
cast(x: T, dtype: 'complex128'): undefined | Complex;
|
|
25
|
+
cast(x: T, dtype: 'complex64'): undefined | Complex;
|
|
26
|
+
cast(x: T, dtype: 'bool'): undefined | boolean;
|
|
27
|
+
cast(x: T, dtype: 'string'): undefined | string;
|
|
28
|
+
cast(x: T, dtype: 'expression'): undefined | BoxedExpression;
|
|
29
|
+
cast(x: T[], dtype: 'float64'): undefined | number[];
|
|
30
|
+
cast(x: T[], dtype: 'float32'): undefined | number[];
|
|
31
|
+
cast(x: T[], dtype: 'int32'): undefined | number[];
|
|
32
|
+
cast(x: T[], dtype: 'uint8'): undefined | number[];
|
|
33
|
+
cast(x: T[], dtype: 'complex128'): undefined | Complex[];
|
|
34
|
+
cast(x: T[], dtype: 'complex64'): undefined | Complex[];
|
|
35
|
+
cast(x: T[], dtype: 'bool'): undefined | boolean[];
|
|
36
|
+
cast(x: T[], dtype: 'string'): undefined | string[];
|
|
37
|
+
cast(x: T[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
38
|
+
cast(x: T | T[], dtype: TensorDataType): undefined | Complex | number | boolean | string | BoxedExpression | Complex[] | number[] | boolean[] | string[] | BoxedExpression[];
|
|
39
|
+
expression(x: T): BoxedExpression;
|
|
40
|
+
isZero(x: T): boolean;
|
|
41
|
+
isOne(x: T): boolean;
|
|
42
|
+
equals(lhs: T, rhs: T): boolean;
|
|
43
|
+
add(lhs: T, rhs: T): T;
|
|
44
|
+
addn(...xs: T[]): T;
|
|
45
|
+
neg(x: T): T;
|
|
46
|
+
sub(lhs: T, rhs: T): T;
|
|
47
|
+
mul(lhs: T, rhs: T): T;
|
|
48
|
+
muln(...xs: T[]): T;
|
|
49
|
+
div(lhs: T, rhs: T): T;
|
|
50
|
+
pow(rhs: T, n: number): T;
|
|
51
|
+
conjugate(x: T): T;
|
|
52
|
+
}
|
|
53
|
+
export declare class TensorFieldNumber implements TensorField<number> {
|
|
54
|
+
private ce;
|
|
55
|
+
one: number;
|
|
56
|
+
zero: number;
|
|
57
|
+
nan: number;
|
|
58
|
+
constructor(ce: IComputeEngine);
|
|
59
|
+
cast(x: number, dtype: 'float64'): undefined | number;
|
|
60
|
+
cast(x: number, dtype: 'float32'): undefined | number;
|
|
61
|
+
cast(x: number, dtype: 'int32'): undefined | number;
|
|
62
|
+
cast(x: number, dtype: 'uint8'): undefined | number;
|
|
63
|
+
cast(x: number, dtype: 'complex128'): undefined | Complex;
|
|
64
|
+
cast(x: number, dtype: 'complex64'): undefined | Complex;
|
|
65
|
+
cast(x: number, dtype: 'bool'): undefined | boolean;
|
|
66
|
+
cast(x: number, dtype: 'string'): undefined | string;
|
|
67
|
+
cast(x: number, dtype: 'expression'): undefined | BoxedExpression;
|
|
68
|
+
cast(x: number[], dtype: 'float64'): undefined | number[];
|
|
69
|
+
cast(x: number[], dtype: 'float32'): undefined | number[];
|
|
70
|
+
cast(x: number[], dtype: 'int32'): undefined | number[];
|
|
71
|
+
cast(x: number[], dtype: 'uint8'): undefined | number[];
|
|
72
|
+
cast(x: number[], dtype: 'complex128'): undefined | Complex[];
|
|
73
|
+
cast(x: number[], dtype: 'complex64'): undefined | Complex[];
|
|
74
|
+
cast(x: number[], dtype: 'bool'): undefined | boolean[];
|
|
75
|
+
cast(x: number[], dtype: 'string'): undefined | string[];
|
|
76
|
+
cast(x: number[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
77
|
+
expression(x: number): BoxedExpression;
|
|
78
|
+
isZero(x: number): boolean;
|
|
79
|
+
isOne(x: number): boolean;
|
|
80
|
+
equals(lhs: number, rhs: number): boolean;
|
|
81
|
+
add(lhs: number, rhs: number): number;
|
|
82
|
+
addn(...xs: number[]): number;
|
|
83
|
+
neg(x: number): number;
|
|
84
|
+
sub(lhs: number, rhs: number): number;
|
|
85
|
+
mul(lhs: number, rhs: number): number;
|
|
86
|
+
muln(...xs: number[]): number;
|
|
87
|
+
div(lhs: number, rhs: number): number;
|
|
88
|
+
pow(lhs: number, rhs: number): number;
|
|
89
|
+
conjugate(x: number): number;
|
|
90
|
+
}
|
|
91
|
+
export declare class TensorFieldExpression implements TensorField<BoxedExpression> {
|
|
92
|
+
one: BoxedExpression;
|
|
93
|
+
zero: BoxedExpression;
|
|
94
|
+
nan: BoxedExpression;
|
|
95
|
+
private ce;
|
|
96
|
+
constructor(ce: IComputeEngine);
|
|
97
|
+
cast(x: BoxedExpression, dtype: 'float64'): undefined | number;
|
|
98
|
+
cast(x: BoxedExpression, dtype: 'float32'): undefined | number;
|
|
99
|
+
cast(x: BoxedExpression, dtype: 'int32'): undefined | number;
|
|
100
|
+
cast(x: BoxedExpression, dtype: 'uint8'): undefined | number;
|
|
101
|
+
cast(x: BoxedExpression, dtype: 'complex128'): undefined | Complex;
|
|
102
|
+
cast(x: BoxedExpression, dtype: 'complex64'): undefined | Complex;
|
|
103
|
+
cast(x: BoxedExpression, dtype: 'bool'): undefined | boolean;
|
|
104
|
+
cast(x: BoxedExpression, dtype: 'string'): undefined | string;
|
|
105
|
+
cast(x: BoxedExpression, dtype: 'expression'): undefined | BoxedExpression;
|
|
106
|
+
cast(x: BoxedExpression[], dtype: 'float64'): undefined | number[];
|
|
107
|
+
cast(x: BoxedExpression[], dtype: 'float32'): undefined | number[];
|
|
108
|
+
cast(x: BoxedExpression[], dtype: 'int32'): undefined | number[];
|
|
109
|
+
cast(x: BoxedExpression[], dtype: 'uint8'): undefined | number[];
|
|
110
|
+
cast(x: BoxedExpression[], dtype: 'complex128'): undefined | Complex[];
|
|
111
|
+
cast(x: BoxedExpression[], dtype: 'complex64'): undefined | Complex[];
|
|
112
|
+
cast(x: BoxedExpression[], dtype: 'bool'): undefined | boolean[];
|
|
113
|
+
cast(x: BoxedExpression[], dtype: 'string'): undefined | string[];
|
|
114
|
+
cast(x: BoxedExpression[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
115
|
+
expression(x: BoxedExpression): BoxedExpression;
|
|
116
|
+
isZero(x: BoxedExpression): boolean;
|
|
117
|
+
isOne(x: BoxedExpression): boolean;
|
|
118
|
+
equals(lhs: BoxedExpression, rhs: BoxedExpression): boolean;
|
|
119
|
+
add(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
|
|
120
|
+
addn(...xs: BoxedExpression[]): BoxedExpression;
|
|
121
|
+
neg(x: BoxedExpression): BoxedExpression;
|
|
122
|
+
sub(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
|
|
123
|
+
mul(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
|
|
124
|
+
muln(...xs: BoxedExpression[]): BoxedExpression;
|
|
125
|
+
div(lhs: BoxedExpression, rhs: BoxedExpression): BoxedExpression;
|
|
126
|
+
pow(lhs: BoxedExpression, rhs: number): BoxedExpression;
|
|
127
|
+
conjugate(x: BoxedExpression): BoxedExpression;
|
|
128
|
+
}
|
|
129
|
+
export declare class TensorFieldComplex implements TensorField<Complex> {
|
|
130
|
+
one: Complex;
|
|
131
|
+
zero: Complex;
|
|
132
|
+
nan: Complex;
|
|
133
|
+
private ce;
|
|
134
|
+
constructor(ce: IComputeEngine);
|
|
135
|
+
cast(x: Complex, dtype: 'float64'): undefined | number;
|
|
136
|
+
cast(x: Complex, dtype: 'float32'): undefined | number;
|
|
137
|
+
cast(x: Complex, dtype: 'int32'): undefined | number;
|
|
138
|
+
cast(x: Complex, dtype: 'uint8'): undefined | number;
|
|
139
|
+
cast(x: Complex, dtype: 'complex128'): undefined | Complex;
|
|
140
|
+
cast(x: Complex, dtype: 'complex64'): undefined | Complex;
|
|
141
|
+
cast(x: Complex, dtype: 'bool'): undefined | boolean;
|
|
142
|
+
cast(x: Complex, dtype: 'string'): undefined | string;
|
|
143
|
+
cast(x: Complex, dtype: 'expression'): undefined | BoxedExpression;
|
|
144
|
+
cast(x: Complex[], dtype: 'float64'): undefined | number[];
|
|
145
|
+
cast(x: Complex[], dtype: 'float32'): undefined | number[];
|
|
146
|
+
cast(x: Complex[], dtype: 'int32'): undefined | number[];
|
|
147
|
+
cast(x: Complex[], dtype: 'uint8'): undefined | number[];
|
|
148
|
+
cast(x: Complex[], dtype: 'complex128'): undefined | Complex[];
|
|
149
|
+
cast(x: Complex[], dtype: 'complex64'): undefined | Complex[];
|
|
150
|
+
cast(x: Complex[], dtype: 'bool'): undefined | boolean[];
|
|
151
|
+
cast(x: Complex[], dtype: 'string'): undefined | string[];
|
|
152
|
+
cast(x: Complex[], dtype: 'expression'): undefined | BoxedExpression[];
|
|
153
|
+
expression(z: Complex): BoxedExpression;
|
|
154
|
+
isZero(z: Complex): boolean;
|
|
155
|
+
isOne(z: Complex): boolean;
|
|
156
|
+
equals(lhs: Complex, rhs: Complex): boolean;
|
|
157
|
+
add(lhs: Complex, rhs: Complex): Complex;
|
|
158
|
+
addn(...xs: Complex[]): Complex;
|
|
159
|
+
neg(z: Complex): Complex;
|
|
160
|
+
sub(lhs: Complex, rhs: Complex): Complex;
|
|
161
|
+
mul(lhs: Complex, rhs: Complex): Complex;
|
|
162
|
+
muln(...xs: Complex[]): Complex;
|
|
163
|
+
div(lhs: Complex, rhs: Complex): Complex;
|
|
164
|
+
pow(lhs: Complex, rhs: number): Complex;
|
|
165
|
+
conjugate(z: Complex): Complex;
|
|
166
|
+
}
|
|
167
|
+
export declare function getSupertype(t1: TensorDataType, t2: TensorDataType): TensorDataType;
|
|
168
|
+
export declare function getExpressionDatatype(expr: BoxedExpression): TensorDataType;
|