@cortex-js/compute-engine 0.31.0 → 0.32.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.
Files changed (149) hide show
  1. package/package.json +1 -1
  2. package/dist/compute-engine.esm.js +0 -41311
  3. package/dist/compute-engine.min.esm.js +0 -125
  4. package/dist/compute-engine.min.umd.js +0 -127
  5. package/dist/compute-engine.umd.js +0 -41336
  6. package/dist/math-json.esm.js +0 -130
  7. package/dist/math-json.min.esm.js +0 -130
  8. package/dist/math-json.min.umd.js +0 -4
  9. package/dist/math-json.umd.js +0 -155
  10. package/dist/types/common/ansi-codes.d.ts +0 -41
  11. package/dist/types/common/configuration-change.d.ts +0 -28
  12. package/dist/types/common/fuzzy-string-match.d.ts +0 -2
  13. package/dist/types/common/grapheme-splitter.d.ts +0 -15
  14. package/dist/types/common/interruptible.d.ts +0 -20
  15. package/dist/types/common/one-of.d.ts +0 -10
  16. package/dist/types/common/signals.d.ts +0 -96
  17. package/dist/types/common/type/ast-nodes.d.ts +0 -146
  18. package/dist/types/common/type/boxed-type.d.ts +0 -30
  19. package/dist/types/common/type/lexer.d.ts +0 -51
  20. package/dist/types/common/type/parse.d.ts +0 -211
  21. package/dist/types/common/type/parser.d.ts +0 -45
  22. package/dist/types/common/type/primitive.d.ts +0 -10
  23. package/dist/types/common/type/serialize.d.ts +0 -2
  24. package/dist/types/common/type/subtype.d.ts +0 -6
  25. package/dist/types/common/type/type-builder.d.ts +0 -32
  26. package/dist/types/common/type/types.d.ts +0 -300
  27. package/dist/types/common/type/utils.d.ts +0 -36
  28. package/dist/types/common/utils.d.ts +0 -23
  29. package/dist/types/compute-engine/assume.d.ts +0 -26
  30. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +0 -165
  31. package/dist/types/compute-engine/boxed-expression/apply.d.ts +0 -5
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +0 -16
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +0 -27
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +0 -38
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +0 -11
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +0 -47
  37. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -44
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +0 -136
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +0 -103
  40. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +0 -53
  41. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +0 -107
  42. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +0 -27
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +0 -170
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +0 -83
  45. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +0 -46
  46. package/dist/types/compute-engine/boxed-expression/cache.d.ts +0 -7
  47. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +0 -5
  48. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +0 -2
  49. package/dist/types/compute-engine/boxed-expression/compare.d.ts +0 -13
  50. package/dist/types/compute-engine/boxed-expression/expand.d.ts +0 -20
  51. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +0 -12
  52. package/dist/types/compute-engine/boxed-expression/factor.d.ts +0 -10
  53. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +0 -25
  54. package/dist/types/compute-engine/boxed-expression/hold.d.ts +0 -10
  55. package/dist/types/compute-engine/boxed-expression/match.d.ts +0 -19
  56. package/dist/types/compute-engine/boxed-expression/negate.d.ts +0 -11
  57. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +0 -34
  58. package/dist/types/compute-engine/boxed-expression/order.d.ts +0 -71
  59. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +0 -105
  60. package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
  61. package/dist/types/compute-engine/boxed-expression/rules.d.ts +0 -129
  62. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +0 -3
  63. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +0 -46
  64. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +0 -6
  65. package/dist/types/compute-engine/boxed-expression/solve.d.ts +0 -20
  66. package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
  67. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +0 -9
  68. package/dist/types/compute-engine/boxed-expression/utils.d.ts +0 -64
  69. package/dist/types/compute-engine/boxed-expression/validate.d.ts +0 -58
  70. package/dist/types/compute-engine/collection-utils.d.ts +0 -35
  71. package/dist/types/compute-engine/compilation/base-compiler.d.ts +0 -31
  72. package/dist/types/compute-engine/compilation/javascript-target.d.ts +0 -68
  73. package/dist/types/compute-engine/compilation/types.d.ts +0 -83
  74. package/dist/types/compute-engine/cost-function.d.ts +0 -13
  75. package/dist/types/compute-engine/function-utils.d.ts +0 -120
  76. package/dist/types/compute-engine/global-types.d.ts +0 -2930
  77. package/dist/types/compute-engine/index.d.ts +0 -660
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +0 -2
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +0 -2
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +0 -2
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +0 -2
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +0 -27
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +0 -2
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +0 -2
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +0 -2
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +0 -2
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +0 -2
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +0 -2
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +0 -3
  90. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +0 -2
  91. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +0 -88
  92. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +0 -21
  93. package/dist/types/compute-engine/latex-syntax/parse.d.ts +0 -303
  94. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +0 -29
  95. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +0 -10
  96. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +0 -37
  97. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +0 -18
  98. package/dist/types/compute-engine/latex-syntax/types.d.ts +0 -845
  99. package/dist/types/compute-engine/latex-syntax/utils.d.ts +0 -5
  100. package/dist/types/compute-engine/library/arithmetic.d.ts +0 -4
  101. package/dist/types/compute-engine/library/calculus.d.ts +0 -2
  102. package/dist/types/compute-engine/library/collections.d.ts +0 -27
  103. package/dist/types/compute-engine/library/combinatorics.d.ts +0 -2
  104. package/dist/types/compute-engine/library/complex.d.ts +0 -2
  105. package/dist/types/compute-engine/library/control-structures.d.ts +0 -2
  106. package/dist/types/compute-engine/library/core.d.ts +0 -2
  107. package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
  108. package/dist/types/compute-engine/library/library.d.ts +0 -17
  109. package/dist/types/compute-engine/library/linear-algebra.d.ts +0 -2
  110. package/dist/types/compute-engine/library/logic.d.ts +0 -6
  111. package/dist/types/compute-engine/library/number-theory.d.ts +0 -2
  112. package/dist/types/compute-engine/library/polynomials.d.ts +0 -2
  113. package/dist/types/compute-engine/library/random-expression.d.ts +0 -2
  114. package/dist/types/compute-engine/library/relational-operator.d.ts +0 -2
  115. package/dist/types/compute-engine/library/sets.d.ts +0 -2
  116. package/dist/types/compute-engine/library/statistics.d.ts +0 -2
  117. package/dist/types/compute-engine/library/trigonometry.d.ts +0 -2
  118. package/dist/types/compute-engine/library/utils.d.ts +0 -77
  119. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +0 -57
  120. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +0 -75
  121. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +0 -56
  122. package/dist/types/compute-engine/numeric-value/types.d.ts +0 -116
  123. package/dist/types/compute-engine/numerics/bigint.d.ts +0 -2
  124. package/dist/types/compute-engine/numerics/expression.d.ts +0 -4
  125. package/dist/types/compute-engine/numerics/interval.d.ts +0 -12
  126. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +0 -4
  127. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +0 -18
  128. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +0 -9
  129. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +0 -3
  130. package/dist/types/compute-engine/numerics/numeric.d.ts +0 -60
  131. package/dist/types/compute-engine/numerics/primes.d.ts +0 -7
  132. package/dist/types/compute-engine/numerics/rationals.d.ts +0 -43
  133. package/dist/types/compute-engine/numerics/richardson.d.ts +0 -80
  134. package/dist/types/compute-engine/numerics/special-functions.d.ts +0 -28
  135. package/dist/types/compute-engine/numerics/statistics.d.ts +0 -24
  136. package/dist/types/compute-engine/numerics/strings.d.ts +0 -2
  137. package/dist/types/compute-engine/numerics/types.d.ts +0 -30
  138. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +0 -3
  139. package/dist/types/compute-engine/symbolic/derivative.d.ts +0 -18
  140. package/dist/types/compute-engine/symbolic/distribute.d.ts +0 -5
  141. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +0 -27
  142. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +0 -128
  143. package/dist/types/compute-engine/tensor/tensors.d.ts +0 -93
  144. package/dist/types/compute-engine/types.d.ts +0 -8
  145. package/dist/types/compute-engine.d.ts +0 -3
  146. package/dist/types/math-json/symbols.d.ts +0 -11
  147. package/dist/types/math-json/types.d.ts +0 -122
  148. package/dist/types/math-json/utils.d.ts +0 -87
  149. package/dist/types/math-json.d.ts +0 -3
@@ -1,47 +0,0 @@
1
- /* 0.31.0 */
2
- import { MathJsonSymbol } from '../../math-json/types';
3
- import { NumericValue } from '../numeric-value/types';
4
- /**
5
- * Given a name and a set of arguments, return a boxed function expression.
6
- *
7
- * If available, preserve LaTeX and wikidata metadata in the boxed expression.
8
- *
9
- * Note that `boxFunction()` should only be called from `ce.function()`
10
- */
11
- export declare function boxFunction(ce: ComputeEngine, name: MathJsonSymbol, ops: readonly SemiBoxedExpression[], options?: {
12
- metadata?: Metadata;
13
- canonical?: CanonicalOptions;
14
- structural?: boolean;
15
- scope?: Scope;
16
- }): BoxedExpression;
17
- /**
18
- * Notes about the boxed form:
19
- *
20
- * [1] Expression with an operator of `Number`, `String`, `Symbol` and `Dictionary`
21
- * are converted to the corresponding atomic expression.
22
- *
23
- * [2] Expressions with an operator of `Complex` are converted to a (complex) number
24
- * or a `Add`/`Multiply` expression.
25
- *
26
- * The precedence of `Complex` (for serialization) is sometimes the
27
- * precedence of `Add` (when re and im != 0), sometimes the precedence of
28
- * `Multiply` (when im or re === 0). Using a number or an explicit
29
- * `Add`/`Multiply` expression avoids this ambiguity.
30
- *
31
- * [3] An expression with a `Rational` operator is converted to a rational
32
- * number if possible, to a `Divide` otherwise.
33
- *
34
- * [4] A `Negate` function applied to a number literal is converted to a number.
35
- *
36
- * Note that `Negate` is only distributed over addition. In practice, having
37
- * `Negate` factored on multiply/divide is more useful to detect patterns.
38
- *
39
- * Note that this function should only be called from `ce.box()`
40
- *
41
- */
42
- export declare function box(ce: ComputeEngine, expr: null | undefined | NumericValue | SemiBoxedExpression, options?: {
43
- canonical?: CanonicalOptions;
44
- structural?: boolean;
45
- scope?: Scope;
46
- }): BoxedExpression;
47
- export declare function semiCanonical(ce: ComputeEngine, xs: ReadonlyArray<SemiBoxedExpression>, scope?: Scope): ReadonlyArray<BoxedExpression>;
@@ -1,44 +0,0 @@
1
- /* 0.31.0 */
2
- import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- import { DictionaryValue, Expression } from '../../math-json/types';
5
- /**
6
- * BoxedDictionary
7
- *
8
- */
9
- export declare class BoxedDictionary extends _BoxedExpression implements DictionaryInterface {
10
- [Symbol.toStringTag]: string;
11
- private readonly _keyValues;
12
- private _type;
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?: {
15
- metadata?: Metadata;
16
- canonical?: boolean;
17
- });
18
- private _initFromRecord;
19
- private _initFromExpression;
20
- get json(): Expression;
21
- toMathJson(options: Readonly<JsonSerializationOptions>): Expression;
22
- get hash(): number;
23
- get operator(): string;
24
- get type(): BoxedType;
25
- get isPure(): boolean;
26
- get isCanonical(): boolean;
27
- set isCanonical(_va: boolean);
28
- get value(): BoxedExpression | undefined;
29
- get complexity(): number;
30
- get isCollection(): boolean;
31
- get isIndexedCollection(): boolean;
32
- get isLazyCollection(): boolean;
33
- contains(_rhs: BoxedExpression): boolean | undefined;
34
- get count(): number | undefined;
35
- get isEmptyCollection(): boolean;
36
- get isFiniteCollection(): boolean;
37
- each(): Generator<BoxedExpression>;
38
- get(key: string): BoxedExpression | undefined;
39
- has(key: string): boolean;
40
- get keys(): string[];
41
- get entries(): [string, BoxedExpression][];
42
- get values(): BoxedExpression[];
43
- match(pattern: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
44
- }
@@ -1,136 +0,0 @@
1
- /* 0.31.0 */
2
- import type { SimplifyOptions, ReplaceOptions, PatternMatchOptions, BoxedExpression, BoxedBaseDefinition, BoxedOperatorDefinition, BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution, Scope, BoxedValueDefinition } from '../global-types';
3
- import { Type } from '../../common/type/types';
4
- import { BoxedType } from '../../common/type/boxed-type';
5
- import { NumericValue } from '../numeric-value/types';
6
- import { _BoxedExpression } from './abstract-boxed-expression';
7
- /**
8
- * A boxed function expression represent an expression composed of an operator
9
- * (the name of the function) and a list of arguments. For example:
10
- * `["Add", 1, 2]` is a function expression with the operator "Add" and two
11
- * arguments 1 and 2.
12
- *
13
- * If canonical, it has a definition associated with it, based on the operator.
14
- *
15
- * The definition contains its signature and its evaluation handler.
16
- *
17
- */
18
- export declare class BoxedFunction extends _BoxedExpression {
19
- private readonly _operator;
20
- private readonly _ops;
21
- private _def;
22
- /** @todo: wrong. If the function is scoped (has its own lexical scope), the captured eval context. This includes the lexical scope for this expression
23
- */
24
- private _capturedContext;
25
- /** If the operator is scoped, the local scope associated with
26
- * the function expression
27
- */
28
- private _localScope;
29
- private _isPure;
30
- private _isStructural;
31
- private _hash;
32
- private _value;
33
- private _valueN;
34
- private _sgn;
35
- private _type;
36
- constructor(ce: ComputeEngine, operator: string, ops: ReadonlyArray<BoxedExpression>, options?: {
37
- metadata?: Metadata;
38
- canonical?: boolean;
39
- structural?: boolean;
40
- scope?: Scope;
41
- });
42
- get hash(): number;
43
- /**
44
- * For function expressions, `infer()` infers the result type of the function
45
- * based on the provided type and inference mode.
46
- */
47
- infer(t: Type, inferenceMode?: 'narrow' | 'widen'): boolean;
48
- bind(): void;
49
- reset(): void;
50
- get value(): BoxedExpression | undefined;
51
- get isCanonical(): boolean;
52
- get isPure(): boolean;
53
- get isConstant(): boolean;
54
- get constantValue(): number | boolean | string | object | undefined;
55
- get json(): Expression;
56
- get operator(): string;
57
- get ops(): ReadonlyArray<BoxedExpression>;
58
- get nops(): number;
59
- get op1(): BoxedExpression;
60
- get op2(): BoxedExpression;
61
- get op3(): BoxedExpression;
62
- get isScoped(): boolean;
63
- get localScope(): Scope | undefined;
64
- get isValid(): boolean;
65
- /** Note: if the expression is not canonical, this will return a canonical
66
- * version of the expression in the current lexical scope.
67
- */
68
- get canonical(): BoxedExpression;
69
- get structural(): BoxedExpression;
70
- get isStructural(): boolean;
71
- toNumericValue(): [NumericValue, BoxedExpression];
72
- /**
73
- * Note: the result is bound to the current scope, not the scope of the
74
- * original expression.
75
- * <!-- This may or may not be desirable -->
76
- */
77
- subs(sub: Substitution, options?: {
78
- canonical?: CanonicalOptions;
79
- }): BoxedExpression;
80
- replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): BoxedExpression | null;
81
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
82
- has(v: string | string[]): boolean;
83
- get sgn(): Sign | undefined;
84
- get isNaN(): boolean | undefined;
85
- get isInfinity(): boolean | undefined;
86
- get isFinite(): boolean | undefined;
87
- get isOne(): boolean | undefined;
88
- get isNegativeOne(): boolean | undefined;
89
- get isPositive(): boolean | undefined;
90
- get isNonNegative(): boolean | undefined;
91
- get isNegative(): boolean | undefined;
92
- get isNonPositive(): boolean | undefined;
93
- get numerator(): BoxedExpression;
94
- get denominator(): BoxedExpression;
95
- get numeratorDenominator(): [BoxedExpression, BoxedExpression];
96
- neg(): BoxedExpression;
97
- inv(): BoxedExpression;
98
- abs(): BoxedExpression;
99
- add(rhs: number | BoxedExpression): BoxedExpression;
100
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
101
- div(rhs: number | BoxedExpression): BoxedExpression;
102
- pow(exp: number | BoxedExpression): BoxedExpression;
103
- root(exp: number | BoxedExpression): BoxedExpression;
104
- sqrt(): BoxedExpression;
105
- ln(semiBase?: number | BoxedExpression): BoxedExpression;
106
- get complexity(): number | undefined;
107
- get baseDefinition(): BoxedBaseDefinition | undefined;
108
- get operatorDefinition(): BoxedOperatorDefinition | undefined;
109
- get valueDefinition(): BoxedValueDefinition | undefined;
110
- get isNumber(): boolean | undefined;
111
- get isInteger(): boolean | undefined;
112
- get isRational(): boolean | undefined;
113
- get isReal(): boolean | undefined;
114
- get isFunctionExpression(): boolean;
115
- /** The type of the value of the function */
116
- get type(): BoxedType;
117
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
118
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
119
- evaluateAsync(options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
120
- N(): BoxedExpression;
121
- solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
122
- get isCollection(): boolean;
123
- get isIndexedCollection(): boolean;
124
- get isLazyCollection(): boolean;
125
- contains(rhs: BoxedExpression): boolean | undefined;
126
- get count(): number | undefined;
127
- get isEmptyCollection(): boolean | undefined;
128
- get isFiniteCollection(): boolean | undefined;
129
- each(): Generator<BoxedExpression>;
130
- at(index: number): BoxedExpression | undefined;
131
- get(index: BoxedExpression | string): BoxedExpression | undefined;
132
- indexWhere(predicate: (element: BoxedExpression) => boolean): number | undefined;
133
- subsetOf(rhs: BoxedExpression, strict: boolean): boolean;
134
- _computeValue(options?: Partial<EvaluateOptions>): () => BoxedExpression;
135
- _computeValueAsync(options?: Partial<EvaluateOptions>): () => Promise<BoxedExpression>;
136
- }
@@ -1,103 +0,0 @@
1
- /* 0.31.0 */
2
- import { Decimal } from 'decimal.js';
3
- import type { Expression, MathJsonNumberObject } from '../../math-json';
4
- import type { Rational, SmallInteger } from '../numerics/types';
5
- import { ExactNumericValueData, NumericValue, NumericValueData } from '../numeric-value/types';
6
- import { _BoxedExpression } from './abstract-boxed-expression';
7
- import { BoxedType } from '../../common/type/boxed-type';
8
- import type { BoxedRuleSet, BoxedSubstitution, CanonicalOptions, EvaluateOptions, ComputeEngine, Metadata, Rule, Sign, Substitution, BoxedExpression, PatternMatchOptions, ReplaceOptions, SimplifyOptions } from '../global-types';
9
- /**
10
- * BoxedNumber
11
- *
12
- */
13
- export declare class BoxedNumber extends _BoxedExpression {
14
- protected readonly _value: SmallInteger | NumericValue;
15
- private _hash;
16
- /**
17
- * By the time the constructor is called, the `value` should have been
18
- * screened for cases where it's a well-known value (0, NaN, +Infinity,
19
- * etc...) or non-normal (complex number with im = 0, rational with
20
- * denom = 1, etc...).
21
- *
22
- * This is done in `ce.number()`. In general, use `ce.number()` rather
23
- * than calling this constructor directly.
24
- *
25
- * We may store as a machine number if a Decimal is passed that is in machine
26
- * range
27
- */
28
- constructor(ce: ComputeEngine, value: SmallInteger | NumericValueData | ExactNumericValueData | NumericValue, options?: {
29
- metadata?: Metadata;
30
- });
31
- get hash(): number;
32
- get json(): Expression;
33
- get operator(): string;
34
- get isPure(): boolean;
35
- get isCanonical(): boolean;
36
- set isCanonical(val: boolean);
37
- get complexity(): number;
38
- /**
39
- *
40
- * Return a JavaScript number when possible (most cases); else return a
41
- * string representation of the number (ComplexInfinity and complex numbers
42
- * for example).
43
- *
44
- * When a JavaScript number is returned, it may have fewer digits than the
45
- * original number, but it will be a close approximation.
46
- *
47
- * @returns {number | string} The value of the number.
48
- */
49
- valueOf(): number | string;
50
- get numericValue(): number | NumericValue;
51
- get isNumberLiteral(): boolean;
52
- get re(): number;
53
- get im(): number;
54
- get bignumRe(): Decimal | undefined;
55
- get bignumIm(): Decimal | undefined;
56
- neg(): BoxedExpression;
57
- inv(): BoxedExpression;
58
- abs(): BoxedExpression;
59
- add(rhs: number | BoxedExpression): BoxedExpression;
60
- mul(rhs: NumericValue | number | BoxedExpression): BoxedExpression;
61
- div(rhs: number | BoxedExpression): BoxedExpression;
62
- pow(exp: number | BoxedExpression): BoxedExpression;
63
- root(exp: number | BoxedExpression): BoxedExpression;
64
- sqrt(): BoxedExpression;
65
- ln(semiBase?: number | BoxedExpression): BoxedExpression;
66
- get value(): BoxedExpression;
67
- get type(): BoxedType;
68
- get sgn(): Sign | undefined;
69
- get numerator(): BoxedExpression;
70
- get denominator(): BoxedExpression;
71
- get numeratorDenominator(): [BoxedExpression, BoxedExpression];
72
- subs(sub: Substitution, options?: {
73
- canonical?: CanonicalOptions;
74
- }): BoxedExpression;
75
- replace(rules: BoxedRuleSet | Rule | Rule[], options?: Partial<ReplaceOptions>): BoxedExpression | null;
76
- match(pattern: BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
77
- /** x > 0, same as `isGreater(0)` */
78
- get isPositive(): boolean | undefined;
79
- /** x >= 0, same as `isGreaterEqual(0)` */
80
- get isNonNegative(): boolean | undefined;
81
- /** x < 0, same as `isLess(0)` */
82
- get isNegative(): boolean | undefined;
83
- /** x <= 0, same as `isLessEqual(0)` */
84
- get isNonPositive(): boolean | undefined;
85
- get isOdd(): boolean | undefined;
86
- get isEven(): boolean | undefined;
87
- get isInfinity(): boolean;
88
- get isNaN(): boolean;
89
- get isFinite(): boolean;
90
- get isNumber(): true;
91
- get isInteger(): boolean;
92
- get isRational(): boolean;
93
- get isReal(): boolean;
94
- is(other: BoxedExpression | number | bigint | boolean): boolean;
95
- get canonical(): BoxedExpression;
96
- get isStructural(): boolean;
97
- get structural(): BoxedExpression;
98
- toNumericValue(): [NumericValue, BoxedExpression];
99
- simplify(options?: Partial<SimplifyOptions>): BoxedExpression;
100
- evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
101
- N(): BoxedExpression;
102
- }
103
- export declare function canonicalNumber(ce: ComputeEngine, value: number | bigint | string | Decimal | Complex | Rational | NumericValue | MathJsonNumberObject): number | NumericValue;
@@ -1,53 +0,0 @@
1
- /* 0.31.0 */
2
- import { BoxedType } from '../../common/type/boxed-type';
3
- import type { OperatorDefinition, BoxedExpression, BoxedOperatorDefinition, CollectionHandlers, CompiledExpression, EvaluateOptions, ComputeEngine, Sign } from '../global-types';
4
- export declare class _BoxedOperatorDefinition implements BoxedOperatorDefinition {
5
- engine: ComputeEngine;
6
- name: string;
7
- description?: string | string[];
8
- url?: string;
9
- wikidata?: string;
10
- broadcastable: boolean;
11
- associative: boolean;
12
- commutative: boolean;
13
- commutativeOrder: ((a: BoxedExpression, b: BoxedExpression) => number) | undefined;
14
- idempotent: boolean;
15
- involution: boolean;
16
- pure: boolean;
17
- complexity: number;
18
- lazy: boolean;
19
- scoped: boolean;
20
- signature: BoxedType;
21
- inferredSignature: boolean;
22
- type?: (ops: ReadonlyArray<BoxedExpression>, options: {
23
- engine: ComputeEngine;
24
- }) => BoxedType | Type | TypeString | undefined;
25
- sgn?: (ops: ReadonlyArray<BoxedExpression>, options: {
26
- engine: ComputeEngine;
27
- }) => Sign | undefined;
28
- eq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
29
- neq?: (a: BoxedExpression, b: BoxedExpression) => boolean | undefined;
30
- even?: (ops: ReadonlyArray<BoxedExpression>, options: {
31
- engine: ComputeEngine;
32
- }) => boolean | undefined;
33
- canonical?: (ops: ReadonlyArray<BoxedExpression>, options: {
34
- engine: ComputeEngine;
35
- }) => BoxedExpression | null;
36
- evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
37
- engine: ComputeEngine;
38
- }) => BoxedExpression | undefined;
39
- evaluateAsync?: (ops: ReadonlyArray<BoxedExpression>, options?: Partial<EvaluateOptions> & {
40
- engine?: ComputeEngine;
41
- }) => Promise<BoxedExpression | undefined>;
42
- evalDimension?: (ops: ReadonlyArray<BoxedExpression>, options: {
43
- engine: ComputeEngine;
44
- }) => BoxedExpression;
45
- compile?: (expr: BoxedExpression) => CompiledExpression;
46
- collection?: CollectionHandlers;
47
- constructor(ce: ComputeEngine, name: string, def: OperatorDefinition);
48
- /** For debugging */
49
- toJSON(): any;
50
- infer(sig: Type): void;
51
- update(def: OperatorDefinition): void;
52
- onConfigurationChange(): void;
53
- }
@@ -1,107 +0,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';
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
- */
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
- */
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,27 +0,0 @@
1
- /* 0.31.0 */
2
- import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- /**
5
- * BoxedString
6
- *
7
- */
8
- export declare class BoxedString extends _BoxedExpression {
9
- [Symbol.toStringTag]: string;
10
- private readonly _string;
11
- private _utf8Buffer?;
12
- private _unicodeScalarValues?;
13
- constructor(ce: ComputeEngine, expr: string, metadata?: Metadata);
14
- get json(): string;
15
- get hash(): number;
16
- get operator(): string;
17
- get isPure(): boolean;
18
- get isCanonical(): boolean;
19
- set isCanonical(_va: boolean);
20
- get value(): BoxedExpression;
21
- get type(): BoxedType;
22
- get complexity(): number;
23
- get string(): string;
24
- get buffer(): Uint8Array;
25
- get unicodeScalars(): number[];
26
- match(pattern: BoxedExpression, _options?: PatternMatchOptions): BoxedSubstitution | null;
27
- }