@cortex-js/compute-engine 0.18.1 → 0.19.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 (101) hide show
  1. package/dist/compute-engine.esm.js +3016 -2607
  2. package/dist/compute-engine.js +3016 -2607
  3. package/dist/compute-engine.min.esm.js +16 -16
  4. package/dist/compute-engine.min.js +16 -16
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.js +2 -2
  7. package/dist/math-json.min.esm.js +2 -2
  8. package/dist/math-json.min.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +1 -1
  12. package/dist/types/common/utils.d.ts +1 -1
  13. package/dist/types/compute-engine/assume.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +7 -5
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -6
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +3 -17
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -2
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +9 -3
  25. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +2 -2
  28. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/validate.d.ts +4 -2
  30. package/dist/types/compute-engine/collection-utils.d.ts +46 -0
  31. package/dist/types/compute-engine/compile.d.ts +2 -2
  32. package/dist/types/compute-engine/compute-engine.d.ts +6 -1
  33. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  34. package/dist/types/compute-engine/domain-utils.d.ts +13 -2
  35. package/dist/types/compute-engine/function-utils.d.ts +1 -22
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  39. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  40. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  41. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  42. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +5 -5
  49. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  51. package/dist/types/compute-engine/latex-syntax/parse.d.ts +22 -46
  52. package/dist/types/compute-engine/latex-syntax/public.d.ts +8 -8
  53. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
  55. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
  56. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  57. package/dist/types/compute-engine/library/arithmetic-add.d.ts +2 -2
  58. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
  59. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +2 -2
  60. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
  61. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  62. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  63. package/dist/types/compute-engine/library/collections.d.ts +2 -1
  64. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  65. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  66. package/dist/types/compute-engine/library/core.d.ts +1 -1
  67. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  68. package/dist/types/compute-engine/library/library.d.ts +1 -1
  69. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  70. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  71. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  72. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  73. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  74. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  75. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  76. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  77. package/dist/types/compute-engine/library/utils.d.ts +29 -2
  78. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  79. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  80. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  81. package/dist/types/compute-engine/numerics/numeric.d.ts +4 -4
  82. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  83. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  84. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  85. package/dist/types/compute-engine/public.d.ts +37 -30
  86. package/dist/types/compute-engine/rules.d.ts +1 -1
  87. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  88. package/dist/types/compute-engine/solve.d.ts +1 -1
  89. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  90. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  91. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  92. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  93. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  94. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  95. package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
  96. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  97. package/dist/types/compute-engine.d.ts +2 -2
  98. package/dist/types/math-json/math-json-format.d.ts +1 -1
  99. package/dist/types/math-json/utils.d.ts +1 -1
  100. package/dist/types/math-json.d.ts +2 -2
  101. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
3
3
  import { IComputeEngine } from '../public';
4
4
  import { Expression } from '../../math-json/math-json-format';
@@ -94,38 +94,18 @@ export declare class _Parser implements Parser {
94
94
  matchAll(tokens: LatexToken[]): boolean;
95
95
  matchAny(tokens: LatexToken[]): LatexToken;
96
96
  matchChar(): string | null;
97
- /** If the next token matches the open delimiter, set a boundary with
97
+ /**
98
+ *
99
+ * If the next token matches the open delimiter, set a boundary with
98
100
  * the close token and return true.
99
101
  *
100
- * Note this method handles generic delimiters, i.e. '(' will math both
101
- * '(', '\left(', '\bigl(', etc...
102
- *
103
- * Note that the definitions for matchfix may need to include synonyms
104
- * for example:
105
- *
106
- * {
107
- * openDelimiter: '(',
108
- * closeDelimiter: ')'
109
- * }
110
- *
111
- * and
112
- *
113
- * {
114
- * openDelimiter: '\\lparen',
115
- * closeDelimiter: '\\rparen'
116
- * }
117
- *
118
- * For:
119
- * - '[': '\\lbrack' and '\\['
120
- * - ']': '\\rbrack' and '\\]'
121
- * - '{': '\\lbrace' and '\\}'
122
- * - '}': '\\rbrace' and '\\}'
123
- * - '<': '\\langle'
124
- * - '>': '\\rangle'
125
- * - '|': '\\vert'
126
- * - '||': '\\Vert'
127
- * - '|': '\\lvert' and '\\rvert'
128
- * - '||': '\\lVert' and '\\rVert'
102
+ * Note this method handles "shorthand" delimiters, i.e. '(' will match both
103
+ * `(` and `\lparen`. If a shorthand is used for the open delimiter, the
104
+ * corresponding shorthand will be used for the close delimiter.
105
+ * See DELIMITER_SHORTHAND.
106
+ *
107
+ * It also handles prefixes like `\left` and `\bigl`.
108
+ *
129
109
  */
130
110
  private matchDelimiter;
131
111
  parseGroup(): Expression | null;
@@ -192,16 +172,6 @@ export declare class _Parser implements Parser {
192
172
  * @internal
193
173
  */
194
174
  private matchOpenDelimiter;
195
- /** For error handling, when there is potentially a mismatched delimiter.
196
- * Return a LaTeX fragment of the expected closing delimiter
197
- *
198
- * @internal
199
- */
200
- matchEnclosureOpen(): string | null;
201
- /**
202
- * Used for error handling
203
- * @internal */
204
- matchEnclosureClose(): string | null;
205
175
  /**
206
176
  * An enclosure is an opening matchfix operator, an optional expression,
207
177
  * optionally followed multiple times by a separator and another expression,
@@ -263,12 +233,18 @@ export declare class _Parser implements Parser {
263
233
  */
264
234
  private applyInvisibleOperator;
265
235
  /**
266
- * This is an error handling method. We've encountered a LaTeX command
267
- * but were not able to match it to any entry in the LaTeX dictionary,
268
- * or ran into it in an unexpected context (postfix operator lacking an
269
- * argument, for example)
236
+ * This method can be invoked when we know we're in an error situation.
237
+ *
238
+ * In general, if a context does not apply, we return `null` to give
239
+ * the chance to some other option to be considered. However, in some cases
240
+ * we know we've exhausted all posibilities, and in this case this method
241
+ * will return an error expression as informative as possible.
242
+ *
243
+ * We've encountered a LaTeX command or symbol but were not able to match it
244
+ * to any entry in the LaTeX dictionary, or ran into it in an unexpected
245
+ * context (postfix operator lacking an argument, for example)
270
246
  */
271
- private parseUnexpectedLatexCommand;
247
+ parseSyntaxError(): Expression;
272
248
  /**
273
249
  * <primary> :=
274
250
  * (<number> | <symbol> | <environment> | <matchfix-expr>)
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
3
  import type { IComputeEngine } from '../public';
4
4
  /**
@@ -124,7 +124,7 @@ export type LatexArgumentType = '{expression}' /** A required math mode expressi
124
124
  * being the `identifierTrigger`.
125
125
  *
126
126
  *
127
- * `matchfix` operators use `openDelimiter` and `closeDelimiter` instead.
127
+ * `matchfix` operators use `openTrigger` and `closeTrigger` instead.
128
128
  *
129
129
  */
130
130
  export type Trigger = {
@@ -167,11 +167,11 @@ export type ExpressionEntry = BaseEntry & Trigger & {
167
167
  export type MatchfixEntry = BaseEntry & {
168
168
  kind: 'matchfix';
169
169
  /**
170
- * If `kind` is `'matchfix'`: the `closeDelimiter` and `openDelimiter`
171
- * property are required
170
+ * If `kind` is `'matchfix'`: the `openTrigger` and `closeTrigger`
171
+ * properties are required.
172
172
  */
173
- openTrigger?: Delimiter | LatexToken[];
174
- closeTrigger?: Delimiter | LatexToken[];
173
+ openTrigger: Delimiter | LatexToken[];
174
+ closeTrigger: Delimiter | LatexToken[];
175
175
  /** When invoked, the parser is pointing after the close delimiter.
176
176
  * The argument of the handler is the body, i.e. the content between
177
177
  * the open delimiter and the close delimiter.
@@ -383,7 +383,7 @@ export type SerializeLatexOptions = {
383
383
  applyFunctionStyle: (expr: Expression, level: number) => 'paren' | 'leftright' | 'big' | 'none';
384
384
  groupStyle: (expr: Expression, level: number) => 'paren' | 'leftright' | 'big' | 'none';
385
385
  rootStyle: (expr: Expression, level: number) => 'radical' | 'quotient' | 'solidus';
386
- fractionStyle: (expr: Expression, level: number) => 'quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
386
+ fractionStyle: (expr: Expression, level: number) => 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
387
387
  logicStyle: (expr: Expression, level: number) => 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
388
388
  powerStyle: (expr: Expression, level: number) => 'root' | 'solidus' | 'quotient';
389
389
  numericSetStyle: (expr: Expression, level: number) => 'compact' | 'regular' | 'interval' | 'set-builder';
@@ -503,7 +503,7 @@ export interface Serializer {
503
503
  applyFunctionStyle: (expr: Expression, level: number) => 'paren' | 'leftright' | 'big' | 'none';
504
504
  groupStyle: (expr: Expression, level: number) => 'paren' | 'leftright' | 'big' | 'none';
505
505
  rootStyle: (expr: Expression, level: number) => 'radical' | 'quotient' | 'solidus';
506
- fractionStyle: (expr: Expression, level: number) => 'quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
506
+ fractionStyle: (expr: Expression, level: number) => 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
507
507
  logicStyle: (expr: Expression, level: number) => 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
508
508
  powerStyle: (expr: Expression, level: number) => 'root' | 'solidus' | 'quotient';
509
509
  numericSetStyle: (expr: Expression, level: number) => 'compact' | 'regular' | 'interval' | 'set-builder';
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { NumberFormattingOptions } from './public';
3
3
  export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
4
4
  /**
@@ -1,8 +1,8 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function getApplyFunctionStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
3
3
  export declare function getGroupStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
4
4
  export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
5
- export declare function getFractionStyle(expr: Expression, level: number): 'quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
5
+ export declare function getFractionStyle(expr: Expression, level: number): 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
6
6
  export declare function getLogicStyle(_expr: Expression, _level: number): 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
7
7
  export declare function getPowerStyle(_expr: Expression, _level: number): 'root' | 'solidus' | 'quotient';
8
8
  export declare function getNumericSetStyle(_expr: Expression, _level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { WarningSignalHandler } from '../../common/signals';
3
3
  import { NumberFormattingOptions, LatexString, SerializeLatexOptions } from './public';
4
4
  import { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
@@ -37,7 +37,7 @@ export declare class Serializer {
37
37
  applyFunctionStyle(expr: Expression, level: number): 'paren' | 'leftright' | 'big' | 'none';
38
38
  groupStyle(expr: Expression, level: number): 'paren' | 'leftright' | 'big' | 'none';
39
39
  rootStyle(expr: Expression, level: number): 'radical' | 'quotient' | 'solidus';
40
- fractionStyle(expr: Expression, level: number): 'quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
40
+ fractionStyle(expr: Expression, level: number): 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
41
41
  logicStyle(expr: Expression, level: number): 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
42
42
  powerStyle(expr: Expression, level: number): 'root' | 'solidus' | 'quotient';
43
43
  numericSetStyle(expr: Expression, level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  * ## Reference
3
3
  * TeX source code:
4
4
  * {@link http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web | Tex.web}
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /** The canonical form of `Add`:
3
3
  * - removes `0`
4
4
  * - capture complex numbers (a + ib or ai +b)
@@ -8,4 +8,4 @@ export declare function domainAdd(_ce: IComputeEngine, args: (undefined | BoxedD
8
8
  export declare function simplifyAdd(ce: IComputeEngine, args: BoxedExpression[]): BoxedExpression;
9
9
  export declare function evalAdd(ce: IComputeEngine, ops: BoxedExpression[], mode?: 'N' | 'evaluate'): BoxedExpression;
10
10
  export declare function canonicalSummation(ce: IComputeEngine, body: BoxedExpression, range: BoxedExpression | undefined): BoxedExpression;
11
- export declare function evalSummation(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression, mode: 'simplify' | 'N' | 'evaluate'): BoxedExpression | undefined;
11
+ export declare function evalSummation(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression | undefined, mode: 'simplify' | 'N' | 'evaluate'): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Canonical form of 'Divide' (and 'Rational')
4
4
  * - remove denominator of 1
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /** The canonical form of `Multiply`:
3
3
  * - remove `1`
4
4
  * - combine literal integers and rationals
@@ -15,4 +15,4 @@ export declare function canonicalMultiply(ce: IComputeEngine, ops: BoxedExpressi
15
15
  export declare function simplifyMultiply(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression;
16
16
  export declare function evalMultiply(ce: IComputeEngine, ops: BoxedExpression[], mode?: 'N' | 'evaluate'): BoxedExpression | undefined;
17
17
  export declare function canonicalProduct(ce: IComputeEngine, body: BoxedExpression | undefined, range: BoxedExpression | undefined): BoxedExpression;
18
- export declare function evalMultiplication(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression, mode: 'simplify' | 'evaluate' | 'N'): BoxedExpression | undefined;
18
+ export declare function evalMultiplication(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression | undefined, mode: 'simplify' | 'evaluate' | 'N'): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  *
4
4
  */
@@ -1,3 +1,3 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export type CanonicalArithmeticFunctions = 'Add' | 'Negate' | 'Sqrt' | 'Multiply' | 'Divide' | 'Power' | 'Ln';
3
3
  export declare const ARITHMETIC_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,3 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
+ export declare const DEFAULT_LINSPACE_COUNT = 50;
2
3
  export declare const COLLECTIONS_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const CORE_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const DOMAIN_CONSTRUCTORS: string[];
3
3
  export declare const DOMAIN_ALIAS: {
4
4
  Functions: (string | string[])[];
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { FunctionDefinition, IComputeEngine, IdentifierDefinitions, SymbolDefinition } from '../public';
3
3
  export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
4
4
  export declare const LIBRARIES: {
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const LOGIC_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function randomExpression(level?: number): Expression;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const RELOP_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const SETS_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,29 @@
1
- /* 0.18.1 */
2
- export declare function normalizeLimits(range: BoxedExpression): [index: string, lower: number, upper: number, isFinite: boolean];
1
+ /* 0.19.0 */
2
+ /**
3
+ * Assume the caller has setup a scope. The index
4
+ * variable will be declared in that scope.
5
+ *
6
+ * @param limits
7
+ *
8
+ */
9
+ export declare function canonicalLimits(limits: BoxedExpression | undefined): BoxedExpression | undefined;
10
+ /**
11
+ * Limits is an expression describing an index variable
12
+ * and a range of values for that variable.
13
+ *
14
+ * This can take several valid forms:
15
+ * - a symbol, e.g. `n`, the upper and lower bounds are assumed ot be infinity
16
+ * - a tuple, e.g. `["Pair", "n", 1]` or `["Tuple", "n", 1, 10]` with one or two bounds
17
+ *
18
+ * The result is a normalized version that includes the
19
+ * index, the lower and upper bounds of the range, and
20
+ * a flag indicating whether the range is finite.
21
+ * @param limits
22
+ * @returns
23
+ */
24
+ export declare function normalizeLimits(limits: BoxedExpression | undefined): [
25
+ index: string | undefined,
26
+ lower: number,
27
+ upper: number,
28
+ isFinite: boolean
29
+ ];
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function bigint(a: Decimal | number | bigint | string): bigint;
3
3
  export declare function gcd(a: bigint, b: bigint): bigint;
4
4
  export declare function lcm(a: bigint, b: bigint): bigint;
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { IComputeEngine } from '../public';
3
3
  export declare function gcd(a: Decimal, b: Decimal): Decimal;
4
4
  export declare function lcm(a: Decimal, b: Decimal): Decimal;
@@ -1,3 +1,3 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function gamma(c: Complex): Complex;
3
3
  export declare function gammaln(c: Complex): Complex;
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { BoxedExpression } from '../public';
4
4
  export declare const MACHINE_PRECISION_BITS = 53;
@@ -34,9 +34,9 @@ export declare function factorial2(n: number): number;
34
34
  export declare function gammaln(z: number): number;
35
35
  export declare function gamma(z: number): number;
36
36
  export declare function fromDigits(s: string, base?: number): [value: number, rest: string];
37
- export declare function asFloat(expr: BoxedExpression): number | null;
38
- export declare function asBignum(expr: BoxedExpression): Decimal | null;
39
- export declare function asSmallInteger(expr: BoxedExpression): number | null;
37
+ export declare function asFloat(expr: BoxedExpression | undefined): number | null;
38
+ export declare function asBignum(expr: BoxedExpression | undefined): Decimal | null;
39
+ export declare function asSmallInteger(expr: BoxedExpression | undefined): number | null;
40
40
  export declare function chop(n: number, tolerance: number): number;
41
41
  export declare function chop(n: Decimal, tolerance: number): 0 | Decimal;
42
42
  export declare function chop(n: Complex, tolerance: number): 0 | Complex;
@@ -1,2 +1,2 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function isPrime(n: number): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function isRational(x: any | null): x is Rational;
3
3
  export declare function isMachineRational(x: any | null): x is [number, number];
4
4
  export declare function isBigRational(x: any | null): x is [bigint, bigint];
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
 
3
3
  Translated from https://github.com/JuliaMath/Richardson.jl/blob/master/src/Richardson.jl
4
4
 
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  * The most important classes are {@link ComputeEngine} and
3
3
  * {@link BoxedExpression}.
4
4
  *
@@ -130,7 +130,7 @@ export type DomainCompatibility = 'covariant' | 'contravariant' | 'bivariant' |
130
130
  /** A domain constructor is the head of a domain expression. */
131
131
  export type DomainConstructor = 'FunctionOf' | 'ListOf' | 'DictionaryOf' | 'TupleOf' | 'Intersection' | 'Union' | 'OptArg' | 'VarArg' | 'Covariant' | 'Contravariant' | 'Bivariant' | 'Invariant';
132
132
  export type DomainLiteral = 'Anything' | 'Values' | 'Domains' | 'Void' | 'NothingDomain' | 'Booleans' | 'Strings' | 'Symbols' | 'Collections' | 'Lists' | 'Dictionaries' | 'Sequences' | 'Tuples' | 'Sets' | 'Functions' | 'Predicates' | 'LogicOperators' | 'RelationalOperators' | 'NumericFunctions' | 'RealFunctions' | 'Numbers' | 'ComplexNumbers' | 'ExtendedRealNumbers' | 'ImaginaryNumbers' | 'Integers' | 'Rationals' | 'PositiveNumbers' | 'PositiveIntegers' | 'NegativeNumbers' | 'NegativeIntegers' | 'NonNegativeNumbers' | 'NonNegativeIntegers' | 'NonPositiveNumbers' | 'NonPositiveIntegers' | 'ExtendedComplexNumbers' | 'TranscendentalNumbers' | 'AlgebraicNumbers' | 'RationalNumbers' | 'RealNumbers';
133
- export type DomainExpression<T = SemiBoxedExpression> = DomainLiteral | ['Union', ...(DomainExpression<T> | BoxedExpression)[]] | ['Intersection', ...(DomainExpression<T> | BoxedExpression)[]] | ['ListOf', DomainExpression<T>] | ['DictionaryOf', DomainExpression<T>] | ['TupleOf', ...DomainExpression<T>[]] | ['OptArg', ...DomainExpression<T>[]] | ['VarArg', DomainExpression<T>] | ['Covariant', DomainExpression<T>] | ['Contravariant', DomainExpression<T>] | ['Bivariant', DomainExpression<T>] | ['Invariant', DomainExpression<T>] | ['FunctionOf', ...DomainExpression<T>[]];
133
+ export type DomainExpression<T = SemiBoxedExpression> = DomainLiteral | ['Union', ...DomainExpression<T>[]] | ['Intersection', ...DomainExpression<T>[]] | ['ListOf', DomainExpression<T>] | ['DictionaryOf', DomainExpression<T>] | ['TupleOf', ...DomainExpression<T>[]] | ['OptArg', ...DomainExpression<T>[]] | ['VarArg', DomainExpression<T>] | ['Covariant', DomainExpression<T>] | ['Contravariant', DomainExpression<T>] | ['Bivariant', DomainExpression<T>] | ['Invariant', DomainExpression<T>] | ['FunctionOf', ...DomainExpression<T>[]];
134
134
  export interface BoxedDomain extends BoxedExpression {
135
135
  get canonical(): BoxedDomain;
136
136
  get json(): Expression;
@@ -140,10 +140,7 @@ export interface BoxedDomain extends BoxedExpression {
140
140
  isCompatible(dom: BoxedDomain | DomainLiteral, kind?: DomainCompatibility): boolean;
141
141
  get base(): DomainLiteral;
142
142
  get ctor(): DomainConstructor | null;
143
- get params(): BoxedDomain[];
144
- get optParams(): BoxedDomain[];
145
- get restParam(): BoxedDomain | null;
146
- get result(): BoxedDomain | null;
143
+ get params(): DomainExpression[];
147
144
  readonly isNumeric: boolean;
148
145
  readonly isFunction: boolean;
149
146
  }
@@ -215,15 +212,15 @@ export interface BoxedExpression {
215
212
  /** From `Object.valueOf()`, return a primitive value for the expression.
216
213
  *
217
214
  * If the expression is a machine number, or bignum or rational that can be
218
- * converted to a machine number, return a `number`.
215
+ * converted to a machine number, return a JavaScript `number`.
219
216
  *
220
217
  * If the expression is a symbol, return the name of the symbol as a `string`.
221
218
  *
222
- * Otherwise return a LaTeX representation of the expression.
219
+ * Otherwise return a JavaScript primitive representation of the expression.
223
220
  *
224
221
  * @category Primitive Methods
225
222
  */
226
- valueOf(): number | string | boolean;
223
+ valueOf(): number | any[] | string | boolean;
227
224
  /** From `Object.toString()`, return a string representation of the
228
225
  * expression. This string is suitable to be output to the console
229
226
  * for debugging, for example. To get a LaTeX representation of the
@@ -342,11 +339,8 @@ export interface BoxedExpression {
342
339
  readonly unknowns: string[];
343
340
  /**
344
341
  *
345
- * All the identifiers (symbols and functions) in the expression that are a
346
- * free variable.
347
- *
348
- * A free variable is an identifier that is used in a function but is not a
349
- * local variable or a parameter of that function.
342
+ * All the identifiers (symbols and functions) in the expression that are
343
+ * not a local variable or a parameter of that function.
350
344
  *
351
345
  */
352
346
  readonly freeVariables: string[];
@@ -838,15 +832,12 @@ export interface BoxedExpression {
838
832
  }): ((args: Record<string, any>) => any | undefined) | undefined;
839
833
  solve(vars: Iterable<string>): null | BoxedExpression[];
840
834
  /**
841
- * Synonym for `evaluate()`. If the expression is pure, the value may be
842
- * cached.
835
+ * Return a JavaScript primitive representing the value of this expression.
843
836
  *
844
- * It returns `undefined` for expressions that are not pure or that may
845
- * not be evaluated.
837
+ * Equivalent to `expr.N().valueOf()`.
846
838
  *
847
- * **Note**: If non-canonical, return the value of its canonical counterpart
848
839
  */
849
- get value(): BoxedExpression | undefined;
840
+ get value(): number | boolean | string | number[] | undefined;
850
841
  /**
851
842
  * Only the value of variables can be changed (symbols that are not
852
843
  * constants).
@@ -856,7 +847,13 @@ export interface BoxedExpression {
856
847
  * **Note**: If non-canonical, does nothing.
857
848
  *
858
849
  */
859
- set value(value: BoxedExpression | number | undefined);
850
+ set value(value: boolean | string | Decimal | Complex | {
851
+ re: number;
852
+ im: number;
853
+ } | {
854
+ num: number;
855
+ denom: number;
856
+ } | number[] | BoxedExpression | number | undefined);
860
857
  /**
861
858
  *
862
859
  * The domain of the value of this expression.
@@ -1191,14 +1188,19 @@ export type FunctionDefinitionFlags = {
1191
1188
  *
1192
1189
  */
1193
1190
  export type FunctionSignature = {
1194
- /** The domain of this signature, a domain compatible with the `Function`
1195
- * domain) */
1196
- domain?: BoxedDomain | DomainExpression;
1197
- /** The minimum and maximum values of the result of the function */
1198
- /** An optional handler to determine the codomain of the function.
1199
- * If not provided, the codomain of the function is determined from `domain`
1191
+ /** The domain of this signature, a domain compatible with the `Functions`
1192
+ * domain).
1193
+ *
1194
+ * @deprecated Use params, optParams, restParam and result instead
1195
+ */
1196
+ domain?: DomainExpression;
1197
+ params?: DomainExpression[];
1198
+ optParams?: DomainExpression[];
1199
+ restParam?: DomainExpression;
1200
+ /** The domain of the result of the function. Either a domain
1201
+ * expression, or a function that returns a boxed domain.
1200
1202
  */
1201
- codomain?: (ce: IComputeEngine, args: BoxedDomain[]) => BoxedDomain | null | undefined;
1203
+ result?: DomainExpression | ((ce: IComputeEngine, args: BoxedDomain[]) => BoxedDomain | null | undefined);
1202
1204
  /**
1203
1205
  * Return the canonical form of the expression with the arguments `args`.
1204
1206
  *
@@ -1345,8 +1347,11 @@ export type FunctionSignature = {
1345
1347
  compile?: (expr: BoxedExpression) => CompiledExpression;
1346
1348
  };
1347
1349
  export type BoxedFunctionSignature = {
1348
- domain: BoxedDomain;
1349
- codomain?: BoxedDomain | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedDomain | null | undefined);
1350
+ inferredSignature: boolean;
1351
+ params: BoxedDomain[];
1352
+ optParams: BoxedDomain[];
1353
+ restParam?: BoxedDomain;
1354
+ result: BoxedDomain | ((ce: IComputeEngine, args: BoxedExpression[]) => BoxedDomain | null | undefined);
1350
1355
  canonical?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | null;
1351
1356
  simplify?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
1352
1357
  evaluate?: (ce: IComputeEngine, args: BoxedExpression[]) => BoxedExpression | undefined;
@@ -1959,6 +1964,8 @@ export interface IComputeEngine {
1959
1964
  forget(symbol?: string | string[]): void;
1960
1965
  get assumptions(): ExpressionMapInterface<boolean>;
1961
1966
  ask(pattern: SemiBoxedExpression): BoxedSubstitution[];
1967
+ /** Using the current assumptions, answer a query. */
1968
+ verify(query: SemiBoxedExpression): boolean;
1962
1969
  /** @internal */
1963
1970
  shouldContinueExecution(): boolean;
1964
1971
  /** @internal */
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Go through all the rules in the rule set, and for all the rules that match
4
4
  * return the rhs of the rule applied to `expr`.
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * A set of simplification rules.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare const UNIVARIATE_ROOTS: Rule[];
3
3
  /**
4
4
  * Expression is a function of a single variable (`x`) or an Equality
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  *
4
4
  * @param fn The function to differentiate, a `["Function"]` expression or
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  export declare function distribute(expr: BoxedExpression[]): BoxedExpression;
3
3
  /** Use the multinomial theorem (https://en.wikipedia.org/wiki/Multinomial_theorem) to expand the expression.
4
4
  * The expression must be a power of a sum of terms.
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Flatten the arguments.
4
4
  * If `expr` was canonical, the result it canonical.
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Distribute `Negate` (multiply by -1) if expr is a number literal, an
4
4
  * addition or multiplication or another `Negate`.
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Coefficient of a univariate (single variable) polynomial.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.18.1 */
1
+ /* 0.19.0 */
2
2
  /**
3
3
  * Group terms in a product by common term.
4
4
  *