@cortex-js/compute-engine 0.30.2 → 0.31.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 +9837 -7504
- package/dist/compute-engine.min.esm.js +49 -53
- package/dist/compute-engine.min.umd.js +49 -53
- package/dist/compute-engine.umd.js +9837 -7504
- package/dist/math-json.esm.js +19 -5
- package/dist/math-json.min.esm.js +19 -5
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +19 -5
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +146 -0
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +51 -0
- package/dist/types/common/type/parse.d.ts +208 -1
- package/dist/types/common/type/parser.d.ts +45 -0
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +32 -0
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +1 -1
- package/dist/types/common/utils.d.ts +22 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +4 -4
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +7 -5
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +104 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +8 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +58 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +11 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +31 -0
- package/dist/types/compute-engine/{compile.d.ts → compilation/javascript-target.d.ts} +20 -32
- package/dist/types/compute-engine/compilation/types.d.ts +83 -0
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +75 -17
- package/dist/types/compute-engine/index.d.ts +4 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/invisible-operator.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/number-theory.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 +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +4 -2
- package/dist/types/math-json/utils.d.ts +7 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +10 -10
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* 0.31.0 */
|
|
2
|
+
import { TypeNode } from './ast-nodes';
|
|
3
|
+
import { TypeResolver } from './types';
|
|
4
|
+
export declare class Parser {
|
|
5
|
+
private lexer;
|
|
6
|
+
private typeResolver;
|
|
7
|
+
private current;
|
|
8
|
+
constructor(input: string, options?: {
|
|
9
|
+
typeResolver?: TypeResolver;
|
|
10
|
+
});
|
|
11
|
+
error(message: string, suggestion?: string): never;
|
|
12
|
+
errorAtToken(token: Token, message: string, suggestion?: string): never;
|
|
13
|
+
private advance;
|
|
14
|
+
private match;
|
|
15
|
+
private expect;
|
|
16
|
+
private createNode;
|
|
17
|
+
parseType(): TypeNode;
|
|
18
|
+
private checkForNakedFunctionSignature;
|
|
19
|
+
private parseUnionType;
|
|
20
|
+
private parseIntersectionType;
|
|
21
|
+
private parsePrimaryType;
|
|
22
|
+
private parseFunctionSignature;
|
|
23
|
+
private parseArgument;
|
|
24
|
+
private parseNamedElement;
|
|
25
|
+
private parseListType;
|
|
26
|
+
private parseListTypeImpl;
|
|
27
|
+
private parseVectorType;
|
|
28
|
+
private parseMatrixType;
|
|
29
|
+
private parseTensorType;
|
|
30
|
+
private parseDimensions;
|
|
31
|
+
private parseDimension;
|
|
32
|
+
private parseDimensionWithX;
|
|
33
|
+
private parseTupleType;
|
|
34
|
+
private parseRecordType;
|
|
35
|
+
private parseRecordEntry;
|
|
36
|
+
private parseDictionaryType;
|
|
37
|
+
private parseSetType;
|
|
38
|
+
private parseCollectionType;
|
|
39
|
+
private parseExpressionType;
|
|
40
|
+
private parseSymbolType;
|
|
41
|
+
private parseNumericType;
|
|
42
|
+
private parsePrimitiveType;
|
|
43
|
+
private parseValue;
|
|
44
|
+
private parseTypeReference;
|
|
45
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
export declare function typeToString(type: Type, precedence?: number): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* 0.31.0 */
|
|
2
|
+
import { Type, TypeResolver } from './types';
|
|
3
|
+
export declare class TypeBuilder implements ASTVisitor<Type> {
|
|
4
|
+
private typeResolver;
|
|
5
|
+
constructor(typeResolver?: TypeResolver);
|
|
6
|
+
buildType(node: TypeNode): Type;
|
|
7
|
+
visitFunctionSignature(node: FunctionSignatureNode): Type;
|
|
8
|
+
visitUnionType(node: UnionTypeNode): Type;
|
|
9
|
+
visitIntersectionType(node: IntersectionTypeNode): Type;
|
|
10
|
+
visitNegationType(node: NegationTypeNode): Type;
|
|
11
|
+
visitGroupType(node: GroupTypeNode): Type;
|
|
12
|
+
visitListType(node: ListTypeNode): Type;
|
|
13
|
+
visitVectorType(node: VectorTypeNode): Type;
|
|
14
|
+
visitMatrixType(node: MatrixTypeNode): Type;
|
|
15
|
+
visitTensorType(node: TensorTypeNode): Type;
|
|
16
|
+
visitTupleType(node: TupleTypeNode): Type;
|
|
17
|
+
visitRecordType(node: RecordTypeNode): Type;
|
|
18
|
+
visitDictionaryType(node: DictionaryTypeNode): Type;
|
|
19
|
+
visitSetType(node: SetTypeNode): Type;
|
|
20
|
+
visitCollectionType(node: CollectionTypeNode): Type;
|
|
21
|
+
visitExpressionType(node: ExpressionTypeNode): Type;
|
|
22
|
+
visitSymbolType(node: SymbolTypeNode): Type;
|
|
23
|
+
visitNumericType(node: NumericTypeNode): Type;
|
|
24
|
+
visitPrimitiveType(node: PrimitiveTypeNode): Type;
|
|
25
|
+
visitTypeReference(node: TypeReferenceNode): Type;
|
|
26
|
+
visitValue(node: ValueNode): Type;
|
|
27
|
+
private buildNamedElement;
|
|
28
|
+
private buildDimension;
|
|
29
|
+
private buildValue;
|
|
30
|
+
private isAnyType;
|
|
31
|
+
}
|
|
32
|
+
export declare function buildTypeFromAST(node: TypeNode, typeResolver?: TypeResolver): Type;
|
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
|
+
*
|
|
3
|
+
* <!--
|
|
4
|
+
* !@consider?
|
|
5
|
+
* - In terms of BoxedExpressions - optimizations which are always desirable to take place are
|
|
6
|
+
* possible...
|
|
7
|
+
* ^Perhaps then, a wrapper BoxedExpr. utility for specifying these permutations via 'condition'
|
|
8
|
+
* would be apt...?
|
|
9
|
+
*
|
|
10
|
+
* - ^If wishing to take adv. of this, the 'condition' callback would likely benefit from a second parameter typed as a collection
|
|
11
|
+
* ('Set' if enforcing unique) with all hitherto (arbitrary representations) of generated
|
|
12
|
+
* permutations.
|
|
13
|
+
* (See commented snippets within function signature below.)
|
|
14
|
+
* -->
|
|
15
|
+
*
|
|
16
|
+
* @export
|
|
17
|
+
* @template T
|
|
18
|
+
* @param xs
|
|
19
|
+
* @param [condition]
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function permutations<T>(xs: ReadonlyArray<T>, condition?: (xs: ReadonlyArray<T>) => boolean): ReadonlyArray<ReadonlyArray<T>>;
|
|
2
23
|
export declare function hidePrivateProperties(obj: any): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import type { Expression, MathJsonSymbol } from '../../math-json/types';
|
|
3
3
|
import type { Type, TypeString } from '../../common/type/types';
|
|
4
4
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
@@ -140,7 +140,7 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
|
|
|
140
140
|
evaluateAsync(_options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
|
|
141
141
|
N(): BoxedExpression;
|
|
142
142
|
compile(options?: {
|
|
143
|
-
to?: 'javascript';
|
|
143
|
+
to?: 'javascript' | 'wgsl' | 'python' | 'webassembly';
|
|
144
144
|
functions?: Record<MathJsonSymbol, string | ((...any: any[]) => any)>;
|
|
145
145
|
vars?: Record<MathJsonSymbol, string>;
|
|
146
146
|
imports?: ((...any: any[]) => any)[];
|
|
@@ -152,9 +152,9 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
|
|
|
152
152
|
get isCollection(): boolean;
|
|
153
153
|
get isIndexedCollection(): boolean;
|
|
154
154
|
get isLazyCollection(): boolean;
|
|
155
|
-
|
|
155
|
+
contains(_rhs: BoxedExpression): boolean | undefined;
|
|
156
156
|
subsetOf(_target: BoxedExpression, _strict: boolean): boolean | undefined;
|
|
157
|
-
get
|
|
157
|
+
get count(): number | undefined;
|
|
158
158
|
get isEmptyCollection(): boolean | undefined;
|
|
159
159
|
get isFiniteCollection(): boolean | undefined;
|
|
160
160
|
each(): Generator<BoxedExpression>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import { Decimal } from 'decimal.js';
|
|
3
3
|
import type { BoxedExpression } from '../global-types';
|
|
4
4
|
export declare function apply(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import { _BoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
4
|
-
import { Expression } from '../../math-json/types';
|
|
4
|
+
import { DictionaryValue, Expression } from '../../math-json/types';
|
|
5
5
|
/**
|
|
6
6
|
* BoxedDictionary
|
|
7
7
|
*
|
|
@@ -10,13 +10,15 @@ export declare class BoxedDictionary extends _BoxedExpression implements Diction
|
|
|
10
10
|
[Symbol.toStringTag]: string;
|
|
11
11
|
private readonly _keyValues;
|
|
12
12
|
private _type;
|
|
13
|
-
constructor
|
|
13
|
+
/** The input to the constructor is either a ["Dictionary", ["KeyValuePair", ..., ...], ...] expression or a record of key-value pairs */
|
|
14
|
+
constructor(ce: ComputeEngine, keyValues: Record<string, DictionaryValue> | BoxedExpression, options?: {
|
|
14
15
|
metadata?: Metadata;
|
|
15
16
|
canonical?: boolean;
|
|
16
17
|
});
|
|
17
18
|
private _initFromRecord;
|
|
18
19
|
private _initFromExpression;
|
|
19
20
|
get json(): Expression;
|
|
21
|
+
toMathJson(options: Readonly<JsonSerializationOptions>): Expression;
|
|
20
22
|
get hash(): number;
|
|
21
23
|
get operator(): string;
|
|
22
24
|
get type(): BoxedType;
|
|
@@ -28,8 +30,8 @@ export declare class BoxedDictionary extends _BoxedExpression implements Diction
|
|
|
28
30
|
get isCollection(): boolean;
|
|
29
31
|
get isIndexedCollection(): boolean;
|
|
30
32
|
get isLazyCollection(): boolean;
|
|
31
|
-
|
|
32
|
-
get
|
|
33
|
+
contains(_rhs: BoxedExpression): boolean | undefined;
|
|
34
|
+
get count(): number | undefined;
|
|
33
35
|
get isEmptyCollection(): boolean;
|
|
34
36
|
get isFiniteCollection(): boolean;
|
|
35
37
|
each(): Generator<BoxedExpression>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import type { SimplifyOptions, ReplaceOptions, PatternMatchOptions, BoxedExpression, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution, Scope, BoxedValueDefinition } from '../global-types';
|
|
3
3
|
import { Type } from '../../common/type/types';
|
|
4
4
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
@@ -122,8 +122,8 @@ export declare class BoxedFunction extends _BoxedExpression {
|
|
|
122
122
|
get isCollection(): boolean;
|
|
123
123
|
get isIndexedCollection(): boolean;
|
|
124
124
|
get isLazyCollection(): boolean;
|
|
125
|
-
|
|
126
|
-
get
|
|
125
|
+
contains(rhs: BoxedExpression): boolean | undefined;
|
|
126
|
+
get count(): number | undefined;
|
|
127
127
|
get isEmptyCollection(): boolean | undefined;
|
|
128
128
|
get isFiniteCollection(): boolean | undefined;
|
|
129
129
|
each(): Generator<BoxedExpression>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
3
3
|
import type { OperatorDefinition, BoxedExpression, BoxedOperatorDefinition, CollectionHandlers, CompiledExpression, EvaluateOptions, ComputeEngine, Sign } from '../global-types';
|
|
4
4
|
export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition {
|
|
@@ -1,4 +1,107 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
|
+
* # Pattern Matching Wildcards
|
|
3
|
+
*
|
|
4
|
+
* Patterns can contain wildcards that match parts of expressions. There are
|
|
5
|
+
* three types of wildcards:
|
|
6
|
+
*
|
|
7
|
+
* ## Universal Wildcard (`_` or `_name`)
|
|
8
|
+
* Matches exactly **one** expression element.
|
|
9
|
+
*
|
|
10
|
+
* - `_` - Anonymous wildcard (matches one element, not captured)
|
|
11
|
+
* - `_a`, `_x`, `_foo` - Named wildcard (matches one element, captured in substitution)
|
|
12
|
+
*
|
|
13
|
+
* **Examples:**
|
|
14
|
+
* - Pattern `['Add', '_a', 1]` matches `['Add', 'x', 1]` with `{_a: 'x'}`
|
|
15
|
+
* - Pattern `['Add', '_', '_']` matches any binary Add expression
|
|
16
|
+
*
|
|
17
|
+
* ## Sequence Wildcard (`__` or `__name`)
|
|
18
|
+
* Matches **one or more** expression elements.
|
|
19
|
+
*
|
|
20
|
+
* - `__` - Anonymous sequence (matches 1+ elements, not captured)
|
|
21
|
+
* - `__a`, `__args` - Named sequence (matches 1+ elements, captured as array)
|
|
22
|
+
*
|
|
23
|
+
* **Examples:**
|
|
24
|
+
* - Pattern `['Add', '__a']` matches `['Add', 1, 2, 3]` with `{__a: [1, 2, 3]}`
|
|
25
|
+
* - Pattern `['f', '__args']` captures all arguments of function f
|
|
26
|
+
*
|
|
27
|
+
* ## Optional Sequence Wildcard (`___` or `___name`)
|
|
28
|
+
* Matches **zero or more** expression elements.
|
|
29
|
+
*
|
|
30
|
+
* - `___` - Anonymous optional sequence (matches 0+ elements, not captured)
|
|
31
|
+
* - `___a`, `___rest` - Named optional sequence (matches 0+ elements, captured)
|
|
32
|
+
*
|
|
33
|
+
* **Examples:**
|
|
34
|
+
* - Pattern `['Add', 1, '___rest']` matches `['Add', 1]` with `{___rest: []}`
|
|
35
|
+
* - Pattern `['Add', 1, '___rest']` matches `['Add', 1, 2, 3]` with `{___rest: [2, 3]}`
|
|
36
|
+
*
|
|
37
|
+
* ## Validation Rules
|
|
38
|
+
*
|
|
39
|
+
* Consecutive multi-element wildcards (`__` or `___`) are **invalid** because
|
|
40
|
+
* there's no way to determine where one ends and the next begins:
|
|
41
|
+
*
|
|
42
|
+
* - **Invalid:** `['Add', '__a', '__b']` - How to split elements between `__a` and `__b`?
|
|
43
|
+
* - **Invalid:** `['Add', '___a', '___b']` - Same ambiguity
|
|
44
|
+
* - **Invalid:** `['Add', '__a', '___b']` - Same ambiguity
|
|
45
|
+
*
|
|
46
|
+
* However, multi-element wildcards followed by universal wildcards are **valid**
|
|
47
|
+
* because the single-element wildcard provides an anchor point:
|
|
48
|
+
*
|
|
49
|
+
* - **Valid:** `['Add', '__a', '_b']` - `_b` matches last element, `__a` gets the rest
|
|
50
|
+
* - **Valid:** `['Add', '___a', '_b', '___c']` - `_b` anchors the middle
|
|
51
|
+
*
|
|
52
|
+
* Use `validatePattern()` to check patterns for these invalid combinations.
|
|
53
|
+
*
|
|
54
|
+
* @module boxed-patterns
|
|
55
|
+
*/
|
|
56
|
+
import type { BoxedSymbol } from './boxed-symbol';
|
|
2
57
|
import type { BoxedExpression } from '../global-types';
|
|
58
|
+
/**
|
|
59
|
+
* Check if an expression is a wildcard (universal, sequence, or optional sequence).
|
|
60
|
+
*
|
|
61
|
+
* @param expr - The expression to check
|
|
62
|
+
* @returns `true` if the expression is any type of wildcard
|
|
63
|
+
*/
|
|
3
64
|
export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
|
|
65
|
+
/**
|
|
66
|
+
* Get the string representation of a wildcard expression.
|
|
67
|
+
*
|
|
68
|
+
* Returns the wildcard symbol including its name (if any):
|
|
69
|
+
* - `'_'` for anonymous universal wildcard
|
|
70
|
+
* - `'_a'` for named universal wildcard
|
|
71
|
+
* - `'__'` for anonymous sequence wildcard
|
|
72
|
+
* - `'__args'` for named sequence wildcard
|
|
73
|
+
* - `'___'` for anonymous optional sequence wildcard
|
|
74
|
+
* - `'___rest'` for named optional sequence wildcard
|
|
75
|
+
*
|
|
76
|
+
* @param expr - The expression to get the wildcard name from
|
|
77
|
+
* @returns The wildcard string, or `null` if not a wildcard
|
|
78
|
+
*/
|
|
4
79
|
export declare function wildcardName(expr: BoxedExpression): string | null;
|
|
80
|
+
/**
|
|
81
|
+
* Determine the type of wildcard.
|
|
82
|
+
*
|
|
83
|
+
* @param expr - A BoxedExpression or wildcard symbol string
|
|
84
|
+
* @returns
|
|
85
|
+
* - `'Wildcard'` - Universal wildcard (`_` or `_name`), matches exactly one element
|
|
86
|
+
* - `'Sequence'` - Sequence wildcard (`__` or `__name`), matches one or more elements
|
|
87
|
+
* - `'OptionalSequence'` - Optional sequence (`___` or `___name`), matches zero or more elements
|
|
88
|
+
* - `null` - Not a wildcard
|
|
89
|
+
*/
|
|
90
|
+
export declare function wildcardType(expr: BoxedExpression | string): 'Wildcard' | 'Sequence' | 'OptionalSequence' | null;
|
|
91
|
+
/**
|
|
92
|
+
* Validate a pattern for invalid wildcard combinations.
|
|
93
|
+
*
|
|
94
|
+
* Throws an error if the pattern contains consecutive multi-element wildcards:
|
|
95
|
+
* - Sequence (`__`) followed by Sequence (`__`) or OptionalSequence (`___`)
|
|
96
|
+
* - OptionalSequence (`___`) followed by Sequence (`__`) or OptionalSequence (`___`)
|
|
97
|
+
*
|
|
98
|
+
* These patterns are ambiguous because there's no delimiter to determine where
|
|
99
|
+
* one sequence ends and the next begins.
|
|
100
|
+
*
|
|
101
|
+
* Sequence or OptionalSequence followed by universal Wildcard (`_`) is allowed
|
|
102
|
+
* because the single-element wildcard provides an anchor point.
|
|
103
|
+
*
|
|
104
|
+
* @param pattern - The pattern to validate
|
|
105
|
+
* @throws Error if the pattern contains invalid wildcard combinations
|
|
106
|
+
*/
|
|
107
|
+
export declare function validatePattern(pattern: BoxedExpression): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import type { Type, TypeString } from '../../common/type/types';
|
|
3
3
|
import type { OneOf } from '../../common/one-of';
|
|
4
4
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
@@ -158,8 +158,8 @@ export declare class BoxedSymbol extends _BoxedExpression {
|
|
|
158
158
|
get isCollection(): boolean;
|
|
159
159
|
get isIndexedCollection(): boolean;
|
|
160
160
|
get isLazyCollection(): boolean;
|
|
161
|
-
|
|
162
|
-
get
|
|
161
|
+
contains(rhs: BoxedExpression): boolean | undefined;
|
|
162
|
+
get count(): number;
|
|
163
163
|
get isEmptyCollection(): boolean;
|
|
164
164
|
get isFiniteCollection(): boolean | undefined;
|
|
165
165
|
each(): Generator<BoxedExpression>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
import type { ComputeEngine, TensorDataType, Metadata, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedSubstitution, EvaluateOptions, BoxedExpression, SimplifyOptions, PatternMatchOptions, Tensor } from '../global-types';
|
|
3
3
|
import { BoxedType } from '../../common/type/boxed-type';
|
|
4
4
|
import { NumericValue } from '../numeric-value/types';
|
|
@@ -67,8 +67,8 @@ export declare class BoxedTensor<T extends TensorDataType> extends _BoxedExpress
|
|
|
67
67
|
isEqual(rhs: number | BoxedExpression): boolean | undefined;
|
|
68
68
|
get isCollection(): boolean;
|
|
69
69
|
get isIndexedCollection(): boolean;
|
|
70
|
-
|
|
71
|
-
get
|
|
70
|
+
contains(other: BoxedExpression): boolean | undefined;
|
|
71
|
+
get count(): number;
|
|
72
72
|
each(): Generator<BoxedExpression>;
|
|
73
73
|
at(index: number): BoxedExpression | undefined;
|
|
74
74
|
match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions, scope?: Scope): BoxedExpression;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
export declare function expandProducts(ce: ComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression | null;
|
|
3
3
|
export declare function choose(n: number, k: number): number;
|
|
4
4
|
/** Attempt to transform the expression (h, ops) into a sum */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
/**
|
|
3
3
|
* The function attempts to match a subject expression to a
|
|
4
4
|
* [pattern](/compute-engine/guides/patterns-and-rules/).
|
|
@@ -8,5 +8,12 @@
|
|
|
8
8
|
*
|
|
9
9
|
* If the expression does not match the pattern, it returns `null`.
|
|
10
10
|
*
|
|
11
|
+
* <!--
|
|
12
|
+
* @consider?
|
|
13
|
+
* - pattern 'validation' (not quite the right term in this context) here? In a similar way to the
|
|
14
|
+
* check/condition supplied in 'matchPermutation()'? (i.e. inspect for redundant sequences of
|
|
15
|
+
* wildcard combinations).
|
|
16
|
+
* -->
|
|
17
|
+
*
|
|
11
18
|
*/
|
|
12
19
|
export declare function match(subject: BoxedExpression, pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
/**
|
|
3
3
|
* Coefficient of a univariate (single variable) polynomial.
|
|
4
4
|
*
|
|
@@ -46,3 +46,60 @@ export declare function maxDegree(expr: BoxedExpression): number;
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function lex(expr: BoxedExpression): string;
|
|
48
48
|
export declare function revlex(expr: BoxedExpression): string;
|
|
49
|
+
/**
|
|
50
|
+
* Get the degree of a polynomial in a specific variable.
|
|
51
|
+
* Returns -1 if the expression is not a polynomial in the variable.
|
|
52
|
+
*
|
|
53
|
+
* Examples:
|
|
54
|
+
* - `polynomialDegree(x^3 + 2x + 1, 'x')` → 3
|
|
55
|
+
* - `polynomialDegree(x*y + y^2, 'x')` → 1
|
|
56
|
+
* - `polynomialDegree(sin(x), 'x')` → -1 (not a polynomial)
|
|
57
|
+
*/
|
|
58
|
+
export declare function polynomialDegree(expr: BoxedExpression, variable: string): number;
|
|
59
|
+
/**
|
|
60
|
+
* Extract coefficients of a univariate polynomial.
|
|
61
|
+
* Returns an array where index i contains the coefficient of x^i.
|
|
62
|
+
* Returns null if the expression is not a polynomial in the variable.
|
|
63
|
+
*
|
|
64
|
+
* Examples:
|
|
65
|
+
* - `getPolynomialCoefficients(x^3 + 2x + 1, 'x')` → [1, 2, 0, 1]
|
|
66
|
+
* - `getPolynomialCoefficients(3x^2 - x + 5, 'x')` → [5, -1, 3]
|
|
67
|
+
*/
|
|
68
|
+
export declare function getPolynomialCoefficients(expr: BoxedExpression, variable: string): BoxedExpression[] | null;
|
|
69
|
+
/**
|
|
70
|
+
* Construct a polynomial expression from its coefficients.
|
|
71
|
+
* coeffs[i] is the coefficient of x^i.
|
|
72
|
+
*
|
|
73
|
+
* Examples:
|
|
74
|
+
* - `fromCoefficients([1, 2, 0, 1], 'x')` → x^3 + 2x + 1
|
|
75
|
+
* - `fromCoefficients([5, -1, 3], 'x')` → 3x^2 - x + 5
|
|
76
|
+
*/
|
|
77
|
+
export declare function fromCoefficients(coeffs: BoxedExpression[], variable: string): BoxedExpression;
|
|
78
|
+
/**
|
|
79
|
+
* Polynomial long division.
|
|
80
|
+
* Returns [quotient, remainder] such that dividend = divisor * quotient + remainder.
|
|
81
|
+
* Returns null if inputs are not valid polynomials or divisor is zero.
|
|
82
|
+
*
|
|
83
|
+
* Examples:
|
|
84
|
+
* - `polynomialDivide(x^3-1, x-1, 'x')` → [x^2+x+1, 0]
|
|
85
|
+
* - `polynomialDivide(x^3+2x+1, x+1, 'x')` → [x^2-x+3, -2]
|
|
86
|
+
*/
|
|
87
|
+
export declare function polynomialDivide(dividend: BoxedExpression, divisor: BoxedExpression, variable: string): [BoxedExpression, BoxedExpression] | null;
|
|
88
|
+
/**
|
|
89
|
+
* Compute the GCD of two polynomials using the Euclidean algorithm.
|
|
90
|
+
* Returns a monic polynomial (leading coefficient = 1).
|
|
91
|
+
*
|
|
92
|
+
* Examples:
|
|
93
|
+
* - `polynomialGCD(x^2-1, x-1, 'x')` → x-1
|
|
94
|
+
* - `polynomialGCD(x^3-1, x^2-1, 'x')` → x-1
|
|
95
|
+
*/
|
|
96
|
+
export declare function polynomialGCD(a: BoxedExpression, b: BoxedExpression, variable: string): BoxedExpression;
|
|
97
|
+
/**
|
|
98
|
+
* Cancel common polynomial factors in a rational expression (Divide).
|
|
99
|
+
* Returns the simplified expression.
|
|
100
|
+
*
|
|
101
|
+
* Examples:
|
|
102
|
+
* - `cancelCommonFactors((x^2-1)/(x-1), 'x')` → x+1
|
|
103
|
+
* - `cancelCommonFactors((x+1)/(x^2+3x+2), 'x')` → 1/(x+2)
|
|
104
|
+
*/
|
|
105
|
+
export declare function cancelCommonFactors(expr: BoxedExpression, variable: string): BoxedExpression;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.31.0 */
|
|
2
2
|
export declare const ConditionParent: {
|
|
3
3
|
boolean: string;
|
|
4
4
|
string: string;
|
|
@@ -117,7 +117,7 @@ export declare function applyRule(rule: Readonly<BoxedRule>, expr: BoxedExpressi
|
|
|
117
117
|
* and the set of rules that were applied.
|
|
118
118
|
*
|
|
119
119
|
* The `replace` function can be used to apply a rule to a non-canonical
|
|
120
|
-
* expression.
|
|
120
|
+
* expression.
|
|
121
121
|
*
|
|
122
122
|
*/
|
|
123
123
|
export declare function replace(expr: BoxedExpression, rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): RuleSteps;
|