@cortex-js/compute-engine 0.25.1 → 0.26.2

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 (153) hide show
  1. package/README.md +5 -8
  2. package/dist/compute-engine.esm.js +26338 -22472
  3. package/dist/compute-engine.js +26348 -22470
  4. package/dist/compute-engine.min.esm.js +89 -23
  5. package/dist/compute-engine.min.js +89 -23
  6. package/dist/math-json.esm.js +22 -139
  7. package/dist/math-json.js +22 -139
  8. package/dist/math-json.min.esm.js +22 -139
  9. package/dist/math-json.min.js +2 -2
  10. package/dist/types/common/ansi-codes.d.ts +30 -4
  11. package/dist/types/common/buffer.d.ts +9 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/one-of.d.ts +9 -0
  14. package/dist/types/common/signals.d.ts +1 -1
  15. package/dist/types/common/styled-text.d.ts +28 -0
  16. package/dist/types/common/suggest.d.ts +1 -0
  17. package/dist/types/common/syntax-highlighter.d.ts +40 -0
  18. package/dist/types/common/terminal.d.ts +19 -0
  19. package/dist/types/common/type/parse.d.ts +4 -0
  20. package/dist/types/common/type/primitive.d.ts +8 -0
  21. package/dist/types/common/type/serialize.d.ts +2 -0
  22. package/dist/types/common/type/subtype.d.ts +6 -0
  23. package/dist/types/common/type/types.d.ts +249 -0
  24. package/dist/types/common/type/utils.d.ts +39 -0
  25. package/dist/types/common/utils.d.ts +2 -1
  26. package/dist/types/compute-engine/assume.d.ts +13 -13
  27. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +71 -47
  28. package/dist/types/compute-engine/boxed-expression/apply.d.ts +5 -0
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +15 -0
  30. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +12 -0
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +16 -0
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +20 -0
  33. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +11 -0
  34. package/dist/types/compute-engine/boxed-expression/box.d.ts +13 -71
  35. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +31 -13
  36. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +66 -45
  37. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +42 -37
  38. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  39. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +13 -9
  40. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +34 -66
  41. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +63 -41
  42. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +44 -27
  43. package/dist/types/compute-engine/boxed-expression/cache.d.ts +6 -0
  44. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/compare.d.ts +13 -0
  46. package/dist/types/compute-engine/boxed-expression/expand.d.ts +20 -0
  47. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/factor.d.ts +7 -6
  49. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +25 -0
  50. package/dist/types/compute-engine/boxed-expression/hold.d.ts +9 -0
  51. package/dist/types/compute-engine/boxed-expression/match.d.ts +2 -4
  52. package/dist/types/compute-engine/{symbolic → boxed-expression}/negate.d.ts +4 -4
  53. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +5 -39
  54. package/dist/types/compute-engine/boxed-expression/order.d.ts +26 -14
  55. package/dist/types/compute-engine/{symbolic → boxed-expression}/polynomials.d.ts +11 -15
  56. package/dist/types/compute-engine/{symbolic → boxed-expression}/product.d.ts +18 -24
  57. package/dist/types/compute-engine/boxed-expression/public.d.ts +911 -634
  58. package/dist/types/compute-engine/boxed-expression/rules.d.ts +129 -0
  59. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
  60. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +6 -0
  61. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +6 -0
  62. package/dist/types/compute-engine/{solve.d.ts → boxed-expression/solve.d.ts} +5 -5
  63. package/dist/types/compute-engine/{symbolic → boxed-expression}/tensor-fields.d.ts +3 -3
  64. package/dist/types/compute-engine/boxed-expression/terms.d.ts +10 -0
  65. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +10 -0
  66. package/dist/types/compute-engine/boxed-expression/utils.d.ts +22 -16
  67. package/dist/types/compute-engine/boxed-expression/validate.d.ts +10 -7
  68. package/dist/types/compute-engine/collection-utils.d.ts +24 -2
  69. package/dist/types/compute-engine/compile.d.ts +3 -3
  70. package/dist/types/compute-engine/compute-engine.d.ts +132 -165
  71. package/dist/types/compute-engine/cost-function.d.ts +11 -1
  72. package/dist/types/compute-engine/function-utils.d.ts +5 -5
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  88. package/dist/types/compute-engine/latex-syntax/parse.d.ts +26 -31
  89. package/dist/types/compute-engine/latex-syntax/public.d.ts +24 -18
  90. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
  91. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +5 -8
  93. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  94. package/dist/types/compute-engine/library/arithmetic.d.ts +4 -2
  95. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  96. package/dist/types/compute-engine/library/collections.d.ts +24 -1
  97. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  98. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  99. package/dist/types/compute-engine/library/core.d.ts +1 -3
  100. package/dist/types/compute-engine/library/invisible-operator.d.ts +4 -0
  101. package/dist/types/compute-engine/library/library.d.ts +2 -4
  102. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  103. package/dist/types/compute-engine/library/logic.d.ts +5 -1
  104. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  105. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  106. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  107. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  108. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  109. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  110. package/dist/types/compute-engine/library/utils.d.ts +46 -40
  111. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +59 -0
  112. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +77 -0
  113. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +58 -0
  114. package/dist/types/compute-engine/numeric-value/public.d.ts +110 -0
  115. package/dist/types/compute-engine/numerics/bigint.d.ts +2 -0
  116. package/dist/types/compute-engine/numerics/bignum.d.ts +12 -0
  117. package/dist/types/compute-engine/numerics/expression.d.ts +4 -0
  118. package/dist/types/compute-engine/numerics/interval.d.ts +12 -0
  119. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +19 -0
  120. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +4 -14
  121. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +6 -9
  122. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric.d.ts +9 -59
  124. package/dist/types/compute-engine/numerics/primes.d.ts +3 -3
  125. package/dist/types/compute-engine/numerics/rationals.d.ts +29 -13
  126. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/special-functions.d.ts +28 -0
  128. package/dist/types/compute-engine/numerics/strings.d.ts +2 -0
  129. package/dist/types/compute-engine/public.d.ts +8 -4
  130. package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -2
  131. package/dist/types/compute-engine/symbolic/distribute.d.ts +5 -0
  132. package/dist/types/compute-engine/{simplify-rules.d.ts → symbolic/simplify-rules.d.ts} +1 -1
  133. package/dist/types/compute-engine/{symbolic → tensor}/tensors.d.ts +3 -3
  134. package/dist/types/compute-engine.d.ts +4 -2
  135. package/dist/types/math-json/identifiers.d.ts +11 -0
  136. package/dist/types/math-json/{math-json-format.d.ts → types.d.ts} +4 -9
  137. package/dist/types/math-json/utils.d.ts +15 -23
  138. package/dist/types/math-json.d.ts +3 -3
  139. package/package.json +3 -3
  140. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -48
  141. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +0 -40
  142. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +0 -56
  143. package/dist/types/compute-engine/domain-utils.d.ts +0 -19
  144. package/dist/types/compute-engine/library/arithmetic-add.d.ts +0 -21
  145. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +0 -16
  146. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +0 -16
  147. package/dist/types/compute-engine/library/arithmetic-power.d.ts +0 -11
  148. package/dist/types/compute-engine/library/domains.d.ts +0 -16
  149. package/dist/types/compute-engine/numerics/terms.d.ts +0 -17
  150. package/dist/types/compute-engine/rules.d.ts +0 -20
  151. package/dist/types/compute-engine/symbolic/expand.d.ts +0 -23
  152. package/dist/types/compute-engine/symbolic/flatten.d.ts +0 -9
  153. package/dist/types/compute-engine/symbolic/utils.d.ts +0 -22
@@ -0,0 +1,129 @@
1
+ /* 0.26.2 */
2
+ export declare const ConditionParent: {
3
+ boolean: string;
4
+ string: string;
5
+ expression: string;
6
+ numeric: string;
7
+ number: string;
8
+ symbol: string;
9
+ complex: string;
10
+ imaginary: string;
11
+ real: string;
12
+ notreal: string;
13
+ integer: string;
14
+ rational: string;
15
+ irrational: string;
16
+ notzero: string;
17
+ notone: string;
18
+ finite: string;
19
+ infinite: string;
20
+ positive: string;
21
+ negative: string;
22
+ nonnegative: string;
23
+ nonpositive: string;
24
+ even: string;
25
+ odd: string;
26
+ prime: string;
27
+ composite: string;
28
+ constant: string;
29
+ variable: string;
30
+ function: string;
31
+ operator: string;
32
+ relation: string;
33
+ equation: string;
34
+ inequality: string;
35
+ collection: string;
36
+ list: string;
37
+ set: string;
38
+ tuple: string;
39
+ single: string;
40
+ pair: string;
41
+ triple: string;
42
+ tensor: string;
43
+ vector: string;
44
+ matrix: string;
45
+ scalar: string;
46
+ unit: string;
47
+ dimension: string;
48
+ angle: string;
49
+ polynomial: string;
50
+ };
51
+ export declare const CONDITIONS: {
52
+ boolean: (x: BoxedExpression) => boolean;
53
+ string: (x: BoxedExpression) => boolean;
54
+ number: (x: BoxedExpression) => boolean;
55
+ symbol: (x: BoxedExpression) => boolean;
56
+ expression: (x: BoxedExpression) => boolean;
57
+ numeric: (x: BoxedExpression) => boolean;
58
+ integer: (x: BoxedExpression) => boolean;
59
+ rational: (x: BoxedExpression) => boolean;
60
+ irrational: (x: BoxedExpression) => boolean;
61
+ real: (x: BoxedExpression) => boolean;
62
+ notreal: (x: BoxedExpression) => boolean;
63
+ complex: (x: BoxedExpression) => boolean;
64
+ imaginary: (x: BoxedExpression) => boolean;
65
+ positive: (x: BoxedExpression) => boolean;
66
+ negative: (x: BoxedExpression) => boolean;
67
+ nonnegative: (x: BoxedExpression) => boolean;
68
+ nonpositive: (x: BoxedExpression) => boolean;
69
+ even: (x: BoxedExpression) => boolean;
70
+ odd: (x: BoxedExpression) => boolean;
71
+ prime: (x: BoxedExpression) => boolean;
72
+ composite: (x: BoxedExpression) => boolean;
73
+ notzero: (x: BoxedExpression) => boolean;
74
+ notone: (x: BoxedExpression) => boolean;
75
+ finite: (x: BoxedExpression) => boolean;
76
+ infinite: (x: BoxedExpression) => boolean;
77
+ constant: (x: BoxedExpression) => boolean;
78
+ variable: (x: BoxedExpression) => boolean;
79
+ function: (x: BoxedExpression) => boolean;
80
+ relation: (x: BoxedExpression) => boolean;
81
+ equation: (x: BoxedExpression) => boolean;
82
+ inequality: (x: BoxedExpression) => boolean;
83
+ collection: (x: BoxedExpression) => boolean;
84
+ list: (x: BoxedExpression) => boolean;
85
+ set: (x: BoxedExpression) => boolean;
86
+ tuple: (x: BoxedExpression) => boolean;
87
+ single: (x: BoxedExpression) => boolean;
88
+ pair: (x: BoxedExpression) => boolean;
89
+ triple: (x: BoxedExpression) => boolean;
90
+ scalar: (x: BoxedExpression) => boolean;
91
+ tensor: (x: BoxedExpression) => boolean;
92
+ vector: (x: BoxedExpression) => boolean;
93
+ matrix: (x: BoxedExpression) => boolean;
94
+ unit: (x: BoxedExpression) => boolean;
95
+ dimension: (x: BoxedExpression) => boolean;
96
+ angle: (x: BoxedExpression) => boolean;
97
+ polynomial: (x: BoxedExpression) => boolean;
98
+ };
99
+ export declare function checkConditions(x: BoxedExpression, conditions: string[]): boolean;
100
+ /**
101
+ * Create a boxed rule set from a collection of non-boxed rules
102
+ */
103
+ export declare function boxRules(ce: IComputeEngine, rs: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
104
+ canonical?: boolean;
105
+ }): BoxedRuleSet;
106
+ /**
107
+ * Apply a rule to an expression, assuming an incoming substitution
108
+ * @param rule the rule to apply
109
+ * @param expr the expression to apply the rule to
110
+ * @param substitution an incoming substitution
111
+ * @param options
112
+ * @returns A transformed expression, if the rule matched. `null` otherwise.
113
+ */
114
+ export declare function applyRule(rule: Readonly<BoxedRule>, expr: BoxedExpression, substitution: BoxedSubstitution, options?: Readonly<Partial<ReplaceOptions>>): RuleStep | null;
115
+ /**
116
+ * Apply the rules in the ruleset and return a modified expression
117
+ * and the set of rules that were applied.
118
+ *
119
+ * The `replace` function can be used to apply a rule to a non-canonical
120
+ * expression. @fixme: account for options.canonical
121
+ *
122
+ */
123
+ export declare function replace(expr: BoxedExpression, rules: Rule | (Rule | BoxedRule)[] | BoxedRuleSet, options?: Partial<ReplaceOptions>): RuleSteps;
124
+ /**
125
+ * For each rules in the rule set that match, return the `replace` of the rule
126
+ *
127
+ * @param rules
128
+ */
129
+ export declare function matchAnyRules(expr: BoxedExpression, rules: BoxedRuleSet, sub: BoxedSubstitution, options?: Partial<ReplaceOptions>): BoxedExpression[];
@@ -1,3 +1,3 @@
1
- /* 0.25.1 */
2
- import { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
1
+ /* 0.26.2 */
2
+ import type { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
3
3
  export declare function serializeJson(ce: IComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
@@ -0,0 +1,6 @@
1
+ /* 0.26.2 */
2
+ export declare function sgn(expr: BoxedExpression): Sign | undefined;
3
+ export declare function positiveSign(s: Sign | undefined): boolean | undefined;
4
+ export declare function nonNegativeSign(s: Sign | undefined): boolean | undefined;
5
+ export declare function negativeSign(s: Sign | undefined): boolean | undefined;
6
+ export declare function nonPositiveSign(s: Sign | undefined): boolean | undefined;
@@ -0,0 +1,6 @@
1
+ /* 0.26.2 */
2
+ type InternalSimplifyOptions = SimplifyOptions & {
3
+ useVariations: boolean;
4
+ };
5
+ export declare function simplify(expr: BoxedExpression, options?: Partial<InternalSimplifyOptions>, steps?: RuleSteps): RuleSteps;
6
+ export {};
@@ -1,5 +1,5 @@
1
- /* 0.25.1 */
2
- import { Rule } from './public';
1
+ /* 0.26.2 */
2
+ import { Rule } from '../public';
3
3
  export declare const UNIVARIATE_ROOTS: Rule[];
4
4
  /**
5
5
  * Expression is a function of a single variable (`x`) or an Equality
@@ -8,12 +8,12 @@ export declare const UNIVARIATE_ROOTS: Rule[];
8
8
  *
9
9
  */
10
10
  export declare function findUnivariateRoots(expr: BoxedExpression, x: string): ReadonlyArray<BoxedExpression>;
11
- /** Expr is an equation with a head of
11
+ /** Expr is an equation with an operator of
12
12
  * - `Equal`, `Less`, `Greater`, `LessEqual`, `GreaterEqual`
13
13
  *
14
- * Return an expression with the same head, but with the first argument
14
+ * Return an expression with the same operator, but with the first argument
15
15
  * a variable, if possible:
16
16
  * `2x < 4` => `x < 2`
17
17
  */
18
- export declare function univariateSolve(expr: BoxedExpression, x: string): ReadonlyArray<SemiBoxedExpression> | null;
18
+ export declare function univariateSolve(expr: BoxedExpression, x: string): ReadonlyArray<BoxedExpression> | null;
19
19
  export declare const HARMONIZATION_RULES: Rule[];
@@ -1,5 +1,5 @@
1
- /* 0.25.1 */
2
- import { BoxedExpression, IComputeEngine } from '../public';
1
+ /* 0.26.2 */
2
+ import type { BoxedExpression, IComputeEngine } from '../public';
3
3
  export type DataTypeMap = {
4
4
  float64: number;
5
5
  float32: number;
@@ -164,5 +164,5 @@ export declare class TensorFieldComplex implements TensorField<Complex> {
164
164
  pow(lhs: Complex, rhs: number): Complex;
165
165
  conjugate(z: Complex): Complex;
166
166
  }
167
- export declare function getSupertype(t1: TensorDataType, t2: TensorDataType): TensorDataType;
167
+ export declare function getSupertype(t1: TensorDataType | undefined, t2: TensorDataType): TensorDataType;
168
168
  export declare function getExpressionDatatype(expr: BoxedExpression): TensorDataType;
@@ -0,0 +1,10 @@
1
+ /* 0.26.2 */
2
+ export declare class Terms {
3
+ private engine;
4
+ private terms;
5
+ constructor(ce: IComputeEngine, terms: ReadonlyArray<BoxedExpression>);
6
+ private add;
7
+ private find;
8
+ N(): BoxedExpression;
9
+ asExpression(): BoxedExpression;
10
+ }
@@ -0,0 +1,10 @@
1
+ /* 0.26.2 */
2
+ export declare function Fu(exp: BoxedExpression): RuleStep | undefined;
3
+ /** Assuming x in an expression in radians, convert to current angular unit. */
4
+ export declare function radiansToAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
5
+ export declare function evalTrig(name: string, op: BoxedExpression | undefined): BoxedExpression | undefined;
6
+ export declare function processInverseFunction(ce: IComputeEngine, xs: ReadonlyArray<BoxedExpression>): BoxedExpression | undefined;
7
+ export declare function trigSign(operator: string, x: BoxedExpression): Sign | undefined;
8
+ export declare function isConstructible(x: string | BoxedExpression): boolean;
9
+ export declare function constructibleValues(operator: string, x: BoxedExpression | undefined): undefined | BoxedExpression;
10
+ export declare function canonicalAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
@@ -1,28 +1,14 @@
1
- /* 0.25.1 */
2
- import { Expression } from '../../math-json/math-json-format';
3
- import { BoxedExpression, IComputeEngine } from './public';
1
+ /* 0.26.2 */
2
+ import { Type } from '../../common/type/types';
4
3
  export declare function isBoxedExpression(x: unknown): x is BoxedExpression;
5
4
  /**
6
5
  * For any numeric result, if `bignumPreferred()` is true, calculate using
7
6
  * bignums. If `bignumPreferred()` is false, calculate using machine numbers
8
7
  */
9
8
  export declare function bignumPreferred(ce: IComputeEngine): boolean;
10
- /** When result of a numeric evaluation is a complex number,
11
- * return `NaN` if not `complexallowed()`
12
- */
13
- export declare function complexAllowed(ce: IComputeEngine): boolean;
14
9
  export declare function isLatexString(s: unknown): s is string;
15
10
  export declare function asLatexString(s: unknown): string | null;
16
11
  export declare function hashCode(s: string): number;
17
- /**
18
- * If `expr` is a number, return it as a Decimal (it might be
19
- * in the machine value range or not). Use `isInMachineRange()` to check.
20
- *
21
- * Use this instead of `machineValue()` when possible, as `machineValue` will
22
- * truncate bignums to machine numbers
23
- */
24
- export declare function bignumValue(ce: IComputeEngine, expr: Expression | null | undefined): Decimal | null;
25
- export declare function asBigint(expr: BoxedExpression): bigint | null;
26
12
  export declare function normalizedUnknownsForSolve(syms: string | Iterable<string> | BoxedExpression | Iterable<BoxedExpression> | null | undefined): string[];
27
13
  /** Return the local variables in the expression.
28
14
  *
@@ -36,4 +22,24 @@ export declare function normalizedUnknownsForSolve(syms: string | Iterable<strin
36
22
  *
37
23
  */
38
24
  export declare function isRelationalOperator(name: BoxedExpression | string): boolean;
25
+ export declare function isInequalityOperator(operator: string): boolean;
26
+ export declare function isEquationOperator(operator: string): boolean;
39
27
  export declare function isInequality(expr: BoxedExpression): boolean;
28
+ export declare function isEquation(expr: BoxedExpression): boolean;
29
+ /**
30
+ * Return a multiple of the imaginary unit, e.g.
31
+ * - 'ImaginaryUnit' -> 1
32
+ * - ['Negate', 'ImaginaryUnit'] -> -1
33
+ * - ['Negate', ['Multiply', 3, 'ImaginaryUnit']] -> -3
34
+ * - ['Multiply', 5, 'ImaginaryUnit'] -> 5
35
+ * - ['Multiply', 'ImaginaryUnit', 5] -> 5
36
+ * - ['Divide', 'ImaginaryUnit', 2] -> 0.5
37
+ *
38
+ */
39
+ export declare function getImaginaryFactor(expr: number | BoxedExpression): BoxedExpression | undefined;
40
+ export declare function normalizeFlags(flags: Partial<NumericFlags> | undefined): NumericFlags | undefined;
41
+ export declare function isSymbolDefinition(def: any): def is SymbolDefinition;
42
+ export declare function isFunctionDefinition(def: any): def is FunctionDefinition;
43
+ export declare function semiCanonical(ce: IComputeEngine, xs: ReadonlyArray<SemiBoxedExpression>): ReadonlyArray<BoxedExpression>;
44
+ export declare function canonical(ce: IComputeEngine, xs: ReadonlyArray<SemiBoxedExpression>): ReadonlyArray<BoxedExpression>;
45
+ export declare function domainToType(expr: BoxedExpression): Type;
@@ -1,5 +1,6 @@
1
- /* 0.25.1 */
2
- import { BoxedExpression } from './public';
1
+ /* 0.26.2 */
2
+ import type { IComputeEngine } from '../public';
3
+ import { Type } from '../../common/type/types';
3
4
  /**
4
5
  * Check that the number of arguments is as expected.
5
6
  *
@@ -18,23 +19,25 @@ export declare function checkArity(ce: IComputeEngine, ops: ReadonlyArray<BoxedE
18
19
  *
19
20
  * We also assume that the function is threadable.
20
21
  *
21
- * Converts the arguments to canonical, and flattens the sequence.
22
+ * The arguments are made canonical.
23
+ *
24
+ * Flattens sequence expressions.
22
25
  */
23
26
  export declare function checkNumericArgs(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, options?: number | {
24
27
  count?: number;
25
- flatten?: boolean | string;
28
+ flatten?: string;
26
29
  }): ReadonlyArray<BoxedExpression>;
27
30
  /**
28
31
  * Check that an argument is of the expected domain.
29
32
  *
30
33
  * Converts the arguments to canonical
31
34
  */
32
- export declare function checkDomain(ce: IComputeEngine, arg: BoxedExpression | undefined | null, dom: BoxedDomain | DomainLiteral | undefined): BoxedExpression;
35
+ export declare function checkType(ce: IComputeEngine, arg: BoxedExpression | undefined | null, type: Type | undefined): BoxedExpression;
36
+ export declare function checkTypes(ce: IComputeEngine, args: ReadonlyArray<BoxedExpression>, types: Type[]): ReadonlyArray<BoxedExpression>;
33
37
  /**
34
38
  * Check that the argument is pure.
35
39
  */
36
40
  export declare function checkPure(ce: IComputeEngine, arg: BoxedExpression | BoxedExpression | undefined | null): BoxedExpression;
37
- export declare function checkDomains(ce: IComputeEngine, args: ReadonlyArray<BoxedExpression>, doms: (BoxedDomain | DomainLiteral)[]): ReadonlyArray<BoxedExpression>;
38
41
  /**
39
42
  *
40
43
  * If the arguments match the parameters, return null.
@@ -43,4 +46,4 @@ export declare function checkDomains(ce: IComputeEngine, args: ReadonlyArray<Box
43
46
  * arguments.
44
47
  *
45
48
  */
46
- export declare function adjustArguments(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, hold: Hold, threadable: boolean, params: BoxedDomain[], optParams: BoxedDomain[], restParam: BoxedDomain | undefined): ReadonlyArray<BoxedExpression> | null;
49
+ export declare function validateArguments(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>, def: BoxedFunctionDefinition): ReadonlyArray<BoxedExpression> | null;
@@ -1,5 +1,13 @@
1
- /* 0.25.1 */
2
- export declare function isCollection(col: BoxedExpression): boolean;
1
+ /* 0.26.2 */
2
+ /** If a collection has fewer than this many elements, eagerly evaluate it.
3
+ *
4
+ * For example, evaluate the Union of two sets with 10 elements each will
5
+ * result in a set with 20 elements.
6
+ *
7
+ * If the sum of the sizes of the two sets is greater than `MAX_SIZE_EAGER_COLLECTION`, the result is a Union expression
8
+ *
9
+ */
10
+ export declare const MAX_SIZE_EAGER_COLLECTION = 100;
3
11
  export declare function isFiniteCollection(col: BoxedExpression): boolean;
4
12
  export declare function isIndexableCollection(col: BoxedExpression): boolean;
5
13
  export declare function isFiniteIndexableCollection(col: BoxedExpression): boolean;
@@ -37,6 +45,19 @@ export declare function each(col: BoxedExpression): Generator<BoxedExpression>;
37
45
  * @returns
38
46
  */
39
47
  export declare function length(col: BoxedExpression): number | undefined;
48
+ /**
49
+ * From an expression, create an iterator that can be used
50
+ * to enumerate values.
51
+ *
52
+ * `expr` should be a collection expression, or a string, or a symbol whose
53
+ * value is a collection expression or a string.
54
+ *
55
+ * - ["Range", 5]
56
+ * - ["List", 1, 2, 3]
57
+ * - "'hello world'"
58
+ *
59
+ */
60
+ export declare function iterator(expr: BoxedExpression): Iterator<BoxedExpression> | undefined;
40
61
  /**
41
62
  *
42
63
  * @param expr
@@ -44,3 +65,4 @@ export declare function length(col: BoxedExpression): number | undefined;
44
65
  * @returns
45
66
  */
46
67
  export declare function at(expr: BoxedExpression, index: number): BoxedExpression | undefined;
68
+ export declare function defaultCollectionHandlers(def: undefined | Partial<CollectionHandlers>): Partial<CollectionHandlers> | undefined;
@@ -1,5 +1,5 @@
1
- /* 0.25.1 */
2
- import { BoxedExpression } from './public';
1
+ /* 0.26.2 */
2
+ import type { BoxedExpression } from './public';
3
3
  export type CompiledType = boolean | number | string | object;
4
4
  type JSSource = string;
5
5
  export type CompiledOperators = Record<MathJsonIdentifier, [
@@ -22,7 +22,7 @@ export type CompileTarget = {
22
22
  * a custom scope for "global" functions. */
23
23
  export declare class ComputeEngineFunction extends Function {
24
24
  private sys;
25
- constructor(body: any);
25
+ constructor(body: string);
26
26
  }
27
27
  export declare function compileToTarget(expr: BoxedExpression, target: CompileTarget): ((_: Record<string, CompiledType>) => CompiledType) | undefined;
28
28
  export declare function compileToJavascript(expr: BoxedExpression): ((_: Record<string, CompiledType>) => CompiledType) | undefined;