@cortex-js/compute-engine 0.6.0 → 0.8.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 (91) hide show
  1. package/dist/compute-engine.esm.js +14942 -11619
  2. package/dist/compute-engine.min.esm.js +2 -2
  3. package/dist/compute-engine.min.js +2 -2
  4. package/dist/math-json.esm.js +62 -43
  5. package/dist/math-json.min.esm.js +2 -2
  6. package/dist/math-json.min.js +2 -2
  7. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  8. package/dist/types/common/signals.d.ts +1 -1
  9. package/dist/types/compute-engine/assume.d.ts +2 -2
  10. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +72 -57
  11. package/dist/types/compute-engine/boxed-expression/box.d.ts +2 -14
  12. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
  13. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +36 -19
  14. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  15. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +46 -38
  16. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +6 -4
  17. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +5 -5
  18. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  19. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +13 -10
  20. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +28 -14
  21. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  23. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/utils.d.ts +25 -8
  25. package/dist/types/compute-engine/compute-engine.d.ts +72 -49
  26. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  27. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  28. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  29. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  30. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  31. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -3
  32. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
  33. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  34. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  35. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  36. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  37. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  38. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +8 -7
  39. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +3 -3
  40. package/dist/types/compute-engine/latex-syntax/parse.d.ts +87 -62
  41. package/dist/types/compute-engine/latex-syntax/public.d.ts +65 -46
  42. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  43. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -4
  45. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  46. package/dist/types/compute-engine/library/arithmetic-add.d.ts +11 -0
  47. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +15 -0
  48. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +19 -0
  49. package/dist/types/compute-engine/{dictionary → library}/arithmetic-power.d.ts +1 -1
  50. package/dist/types/compute-engine/library/arithmetic.d.ts +2 -0
  51. package/dist/types/compute-engine/library/calculus.d.ts +2 -0
  52. package/dist/types/compute-engine/library/collections.d.ts +2 -0
  53. package/dist/types/compute-engine/library/core.d.ts +2 -0
  54. package/dist/types/compute-engine/library/domains.d.ts +15 -0
  55. package/dist/types/compute-engine/library/library.d.ts +17 -0
  56. package/dist/types/compute-engine/library/logic.d.ts +2 -0
  57. package/dist/types/compute-engine/library/polynomials.d.ts +2 -0
  58. package/dist/types/compute-engine/library/relational-operator.d.ts +2 -0
  59. package/dist/types/compute-engine/library/sets.d.ts +2 -0
  60. package/dist/types/compute-engine/library/trigonometry.d.ts +2 -0
  61. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  62. package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +5 -1
  63. package/dist/types/compute-engine/numerics/numeric.d.ts +4 -2
  64. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  65. package/dist/types/compute-engine/public.d.ts +717 -504
  66. package/dist/types/compute-engine/rules.d.ts +1 -1
  67. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  68. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  69. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  70. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  71. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  72. package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
  73. package/dist/types/compute-engine/symbolic/sum.d.ts +2 -2
  74. package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
  75. package/dist/types/compute-engine.d.ts +2 -2
  76. package/dist/types/math-json/math-json-format.d.ts +27 -23
  77. package/dist/types/math-json/utils.d.ts +22 -16
  78. package/dist/types/math-json.d.ts +3 -3
  79. package/package.json +20 -20
  80. package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +0 -11
  81. package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +0 -9
  82. package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +0 -17
  83. package/dist/types/compute-engine/dictionary/arithmetic.d.ts +0 -2
  84. package/dist/types/compute-engine/dictionary/collections.d.ts +0 -2
  85. package/dist/types/compute-engine/dictionary/core.d.ts +0 -2
  86. package/dist/types/compute-engine/dictionary/dictionary.d.ts +0 -26
  87. package/dist/types/compute-engine/dictionary/logic.d.ts +0 -2
  88. package/dist/types/compute-engine/dictionary/polynomials.d.ts +0 -2
  89. package/dist/types/compute-engine/dictionary/relational-operator.d.ts +0 -2
  90. package/dist/types/compute-engine/dictionary/sets.d.ts +0 -2
  91. package/dist/types/compute-engine/dictionary/trigonometry.d.ts +0 -2
@@ -1,4 +1,4 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  import { Expression } from '../../math-json/math-json-format';
3
3
  import type { IComputeEngine } from '../public';
4
4
  /**
@@ -18,17 +18,15 @@ export declare type LatexString = string;
18
18
  * record to define new LaTeX dictionary entries.
19
19
  */
20
20
  export declare type Delimiter = ')' | '(' | ']' | '[' | '{' /** \lbrace */ | '}' /** \rbrace */ | '<' /** \langle */ | '>' /** \rangle */ | '|' | '||' | '\\lceil' | '\\rceil' | '\\lfloor' | '\\rfloor';
21
- export declare type DictionaryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collections' | 'combinatorics' | 'core' | 'dimensions' | 'domains' | 'linear-algebra' | 'logic' | 'numeric' | 'other' | 'physics' | 'polynomials' | 'relop' | 'sets' | 'statistics' | 'symbols' | 'trigonometry' | 'units';
21
+ export declare type LibraryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collections' | 'control-structures' | 'combinatorics' | 'core' | 'dimensions' | 'domains' | 'linear-algebra' | 'logic' | 'numeric' | 'other' | 'physics' | 'polynomials' | 'relop' | 'sets' | 'statistics' | 'styling' | 'symbols' | 'trigonometry' | 'units';
22
22
  /**
23
23
  * This indicates a condition under which parsing should stop:
24
- * - a specific string of tokens has been encountered
25
24
  * - an operator of a precedence higher than specified has been encountered
26
25
  * - the last token has been reached
27
26
  * - or if a function is provided, the function returns true;
28
27
  */
29
28
  export declare type Terminator = {
30
29
  minPrec: number;
31
- tokens?: LatexToken[];
32
30
  condition?: (parser: Parser) => boolean;
33
31
  };
34
32
  /**
@@ -54,11 +52,13 @@ export declare type Terminator = {
54
52
  */
55
53
  export declare type EnvironmentParseHandler = (parser: Parser, reqArgs: Expression[], optArgs: Expression[]) => Expression | null;
56
54
  export declare type SymbolParseHandler = (parser: Parser) => Expression | null;
55
+ export declare type FunctionParseHandler = (parser: Parser) => Expression | null;
57
56
  export declare type PostfixParseHandler = (parser: Parser, lhs: Expression) => Expression | null;
58
57
  export declare type PrefixParseHandler = (parser: Parser, until: Terminator) => Expression | null;
59
58
  export declare type InfixParseHandler = (parser: Parser, until: Terminator, lhs: Expression) => Expression | null;
60
59
  export declare type MatchfixParseHandler = (parser: Parser, body: Expression) => Expression | null;
61
- export declare type ParseHandler = SymbolParseHandler | EnvironmentParseHandler | PostfixParseHandler | PrefixParseHandler | InfixParseHandler | MatchfixParseHandler;
60
+ export declare type ParseHandler = SymbolParseHandler | FunctionParseHandler | EnvironmentParseHandler | PostfixParseHandler | PrefixParseHandler | InfixParseHandler | MatchfixParseHandler;
61
+ export declare type LatexArgumentType = '{expression}' /** A required math mode expression */ | '[expression]' /** An optional math mode expression */ | '{text}' /** A required expression in text mode */ | '[text]' /** An optional expression in text mode */ | '{unit}' /** A required unit expression, e.g. `3em` */ | '[unit]' /** An optional unit expression, e.g. `3em` */ | '{glue}' /** A required glue expression, e.g. `25 mu plus 3em ` */ | '[glue]' /** An optional glue expression, e.g. `25 mu plus 3em ` */ | '{string}' /** A required text string, terminated by a non-literal token */ | '[string]' /** An optional text string, terminated by a non-literal token */ | '{color}' /** A required color expression, e.g. `red` or `#00ff00` */ | '[color]'; /** An optional color expression, e.g. `red` or `#00ff00` */
62
62
  /**
63
63
  * Maps a string of LaTeX tokens to a function or symbol and vice-versa.
64
64
  *
@@ -163,6 +163,10 @@ export declare type SymbolEntry = BaseEntry & {
163
163
  kind: 'symbol';
164
164
  /** Used for appropriate wrapping (i.e. when to surround it with parens) */
165
165
  precedence?: number;
166
+ parse: Expression | SymbolParseHandler;
167
+ };
168
+ export declare type FunctionEntry = BaseEntry & {
169
+ kind: 'function';
166
170
  /**
167
171
  * Indicate if this symbol can be followed by arguments.
168
172
  *
@@ -188,41 +192,21 @@ export declare type SymbolEntry = BaseEntry & {
188
192
  * "f x" -> `["f", "x"]`
189
193
  *
190
194
  */
191
- /**
192
- *
193
- * If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\sqrt`)
194
- * indicates the number of optional arguments expected (indicate with
195
- * square brackets).
196
- *
197
- * For example, for the `\sqrt` command, 1: `\sqrt[3]{x}`
198
- *
199
- */
200
- optionalLatexArg?: number;
201
- /**
202
- *
203
- * If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\frac`)
204
- * indicates the number of required arguments expected (indicated with
205
- * curly braces).
206
- *
207
- * For example, for the `\frac` command, 2: `\frac{1}{n}`
208
- *
209
- */
210
- requiredLatexArg?: number;
211
- parse: Expression | SymbolParseHandler;
195
+ parse: Expression | FunctionParseHandler;
212
196
  };
213
197
  /**
214
198
  * A simple LaTeX dictionary entry, for example for a command like `\pi`.
215
199
  */
216
200
  export declare type DefaultEntry = BaseEntry & {
217
201
  precedence?: number;
218
- optionalLatexArg?: number;
219
- requiredLatexArg?: number;
220
202
  parse?: Expression | SymbolParseHandler;
221
203
  };
222
- export declare type LatexDictionaryEntry = DefaultEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | EnvironmentEntry;
204
+ export declare type LatexDictionaryEntry = DefaultEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry;
223
205
  /** @internal */
224
206
  export declare function isSymbolEntry(entry: LatexDictionaryEntry): entry is SymbolEntry;
225
207
  /** @internal */
208
+ export declare function isFunctionEntry(entry: LatexDictionaryEntry): entry is FunctionEntry;
209
+ /** @internal */
226
210
  export declare function isMatchfixEntry(entry: LatexDictionaryEntry): entry is MatchfixEntry;
227
211
  /** @internal */
228
212
  export declare function isInfixEntry(entry: LatexDictionaryEntry): entry is InfixEntry;
@@ -254,7 +238,7 @@ export declare type ParseLatexOptions = {
254
238
  /**
255
239
  * If true, ignore space characters.
256
240
  *
257
- * Default: `true`
241
+ * **Default**: `true`
258
242
  *
259
243
  */
260
244
  skipSpace: boolean;
@@ -273,7 +257,7 @@ export declare type ParseLatexOptions = {
273
257
  * Otherwise, return each token making up the number (minus sign, digits,
274
258
  * decimal separator, etc...).
275
259
  *
276
- * Default: `true`
260
+ * **Default**: `true`
277
261
  */
278
262
  parseNumbers: boolean;
279
263
  /**
@@ -302,6 +286,8 @@ export declare type ParseLatexOptions = {
302
286
  * may contain a slightly different LaTeX, for example with consecutive spaces
303
287
  * replaced by one, with comments removed and with some low-level LaTeX
304
288
  * commands replaced, for example `\egroup` and `\bgroup`.
289
+ *
290
+ * **Default:** `false`
305
291
  */
306
292
  preserveLatex: boolean;
307
293
  };
@@ -330,8 +316,8 @@ export declare type SerializeLatexOptions = {
330
316
  */
331
317
  multiply: LatexString;
332
318
  /**
333
- * When an expression contains the symbol `Missing`, serialize it
334
- * with this LaTeX string
319
+ * When an expression contains the error expression `["Error", 'missing']`,
320
+ * serialize it with this LaTeX string
335
321
  */
336
322
  missingSymbol: LatexString;
337
323
  applyFunctionStyle: (expr: Expression, level: number) => 'paren' | 'leftright' | 'big' | 'none';
@@ -353,10 +339,10 @@ export declare type NumberFormattingOptions = {
353
339
  * the '.' in '3.1415'.
354
340
  *
355
341
  * Some countries use a comma rather than a dot. In this case it is
356
- * recommended to use `"{,}"` as the marker: the surrounding bracket ensure
342
+ * recommended to use `"{,}"` as the marker: the surrounding brackets ensure
357
343
  * there is no additional gap after the comma.
358
344
  *
359
- * Default: `"."`
345
+ * **Default**: `"."`
360
346
  */
361
347
  decimalMarker: LatexString;
362
348
  /**
@@ -365,10 +351,10 @@ export declare type NumberFormattingOptions = {
365
351
  *
366
352
  * If you change it to another value, be aware that this may lead to
367
353
  * unexpected results. For example, if changing it to `,` the expression
368
- * `x_{1,2}` will parse as `x` with a subscript of `1.2`, rather than `x`
369
- * with two subscripts, `1` and `2`.
354
+ * `\mathrm{Hypot}(1,2)` will parse as `["Hypot", 1.2]` rather than
355
+ * `["Hypot", 1, 2]`.
370
356
  *
371
- * Default: `"\\,"` (thin space, 3/18mu) (Resolution 7 of the 1948 CGPM)
357
+ * **Default**: `"\\,"` (thin space, 3/18mu) (Resolution 7 of the 1948 CGPM)
372
358
  */
373
359
  groupSeparator: LatexString;
374
360
  exponentProduct: LatexString;
@@ -416,7 +402,7 @@ export declare class LatexSyntax {
416
402
  * Use the value returned by this function to the `options` argument of the
417
403
  * constructor.
418
404
  */
419
- static getDictionary(domain?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
405
+ static getDictionary(domain?: LibraryCategory | 'all'): Readonly<LatexDictionary>;
420
406
  parse(latex: LatexString): Expression;
421
407
  serialize(expr: Expression): LatexString;
422
408
  }
@@ -436,7 +422,11 @@ export interface Serializer {
436
422
  level: number;
437
423
  /** Output a LaTeX string representing the expression */
438
424
  serialize: (expr: Expression | null) => string;
439
- wrapString(s: string, style: 'paren' | 'leftright' | 'big' | 'none'): string;
425
+ wrapString(s: string, style: 'paren' | 'leftright' | 'big' | 'none', fence?: string): string;
426
+ /** A string with the arguments of expr fenced appropriately and separated by
427
+ * commas.
428
+ */
429
+ wrapArguments(expr: Expression): string;
440
430
  /** Add a group fence around the expression if it is
441
431
  * an operator of precedence less than or equal to `prec`.
442
432
  */
@@ -456,7 +446,6 @@ export interface Serializer {
456
446
  }
457
447
  export declare type SerializeHandler = (serializer: Serializer, expr: Expression) => string;
458
448
  export interface Parser {
459
- readonly onError: WarningSignalHandler;
460
449
  readonly options: Required<ParseLatexOptions>;
461
450
  readonly computeEngine?: IComputeEngine;
462
451
  index: number;
@@ -478,6 +467,10 @@ export interface Parser {
478
467
  latexAfter(): string;
479
468
  /** If there are any space, advance the index until a non-space is encountered */
480
469
  skipSpace(): boolean;
470
+ addBoundary(boundary: LatexToken[]): void;
471
+ removeBoundary(): void;
472
+ matchBoundary(): boolean;
473
+ boundaryError(msg: string | [string, ...Expression[]]): Expression;
481
474
  /** If the next token is a character, return it and advance the index
482
475
  * This includes plain characters (e.g. 'a', '+'...), characters
483
476
  * defined in hex (^^ and ^^^^), the `\char` and `\unicode` command.
@@ -497,17 +490,17 @@ export interface Parser {
497
490
  match(tokens: LatexToken): boolean;
498
491
  matchAll(tokens: LatexToken | LatexToken[]): boolean;
499
492
  matchAny(tokens: LatexToken[]): LatexToken;
500
- matchWhile(tokens: LatexToken[]): LatexToken[];
493
+ matchSequence(tokens: LatexToken[]): LatexToken[];
501
494
  /** If the next token matches a `+` or `-` sign, return it and advance the index.
502
495
  * Otherwise return `''` and do not advance */
503
- matchSign(): string;
496
+ matchOptionalSign(): string;
504
497
  matchDecimalDigits(): string;
505
498
  matchSignedInteger(): string;
506
499
  matchExponent(): string;
507
500
  matchNumber(): string;
508
501
  /** Parse a tabular environment, until `\end{endName}`
509
502
  */
510
- matchTabular(endName: string): null | Expression;
503
+ matchTabular(endName: string): null | Expression[][];
511
504
  applyInvisibleOperator(terminator: Terminator, lhs: Expression | null): Expression | null;
512
505
  /** If the next tokens correspond to an optional LaTeX argument,
513
506
  * enclosed with `[` and `]` return the content of the argument
@@ -516,14 +509,21 @@ export interface Parser {
516
509
  * Otherwise, return `null`.
517
510
  */
518
511
  matchOptionalLatexArgument(): Expression | null;
512
+ /**
513
+ * Match a required LaTeX argument:
514
+ * - either enclosed in `{}`
515
+ * - or a single token.
516
+ *
517
+ * Return null if no argument was found
518
+ * Return `['Sequence']` if an empty argument `{}` was found
519
+ */
519
520
  matchRequiredLatexArgument(): Expression | null;
520
521
  /**
521
522
  * - 'enclosure' : will look for an argument inside an enclosure (an open/close fence)
522
- * - 'group': arguments follow directly the symbol, until an end of group token `<}>`
523
523
  * - 'implicit': either an expression inside a pair of `()`, or just a primary
524
524
  * (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
525
525
  */
526
- matchArguments(kind: '' | 'group' | 'implicit' | 'enclosure'): Expression[] | null;
526
+ matchArguments(kind: '' | 'implicit' | 'enclosure'): Expression[] | null;
527
527
  /** If matches the normalized open delimiter, returns the
528
528
  * expected closing delimiter.
529
529
  *
@@ -533,6 +533,17 @@ export interface Parser {
533
533
  */
534
534
  matchOpenDelimiter(openDelim: Delimiter, closeDelim: Delimiter): LatexToken[] | null;
535
535
  matchMiddleDelimiter(delimiter: '|' | ':' | LatexToken): boolean;
536
+ /**
537
+ * Match a sequence superfix/subfix operator, e.g. `^{*}`
538
+ *
539
+ * Superfix and subfix need special handling:
540
+ *
541
+ * - they act mostly like an infix operator, but they are commutative, i.e.
542
+ * `x_a^b` should be parsed identically to `x^b_a`.
543
+ *
544
+ * - furthermore, in LaTeX `x^a^b` parses the same as `x^a{}^b`.
545
+ *
546
+ */
536
547
  matchSupsub(lhs: Expression | null): Expression | null;
537
548
  /**
538
549
  *
@@ -554,6 +565,12 @@ export interface Parser {
554
565
  * If not a primary, return `null` and do not advance the index.
555
566
  */
556
567
  matchPrimary(): Expression | null;
568
+ /**
569
+ * A symbol can be:
570
+ * - a single-letter variable: `x`
571
+ * - a single LaTeX command: `\pi`
572
+ */
573
+ matchSymbol(): Expression | null;
557
574
  /**
558
575
  * Parse an expression:
559
576
  *
@@ -572,4 +589,6 @@ export interface Parser {
572
589
  * `until` is `{ minPrec:0 }` by default.
573
590
  */
574
591
  matchExpression(until?: Partial<Terminator>): Expression | null;
592
+ /** Return an error expression with the specified code and arguments */
593
+ error(code: string | [string, ...Expression[]], fromToken: number): Expression;
575
594
  }
@@ -1,4 +1,4 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  import { NumberFormattingOptions } from './public';
3
3
  export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
4
4
  export declare function serializeEngineeringNotationNumber(value: number, options: NumberFormattingOptions): string;
@@ -1,4 +1,4 @@
1
- /* 0.6.0 */
1
+ /* 0.8.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';
@@ -1,5 +1,5 @@
1
- /* 0.6.0 */
2
- import { NumberFormattingOptions, LatexString, SerializeLatexOptions } from './public';
1
+ /* 0.8.0 */
2
+ import { NumberFormattingOptions, LatexString, SerializeLatexOptions, FunctionEntry } from './public';
3
3
  import { IndexedLatexDictionary, SymbolEntry } from './dictionary/definitions';
4
4
  import { WarningSignalHandler } from '../../common/signals';
5
5
  export declare class Serializer {
@@ -19,8 +19,10 @@ export declare class Serializer {
19
19
  *
20
20
  */
21
21
  wrapShort(expr: Expression | null): string;
22
- wrapString(s: string, style: 'paren' | 'leftright' | 'big' | 'none'): string;
23
- serializeSymbol(expr: Expression, def?: SymbolEntry): string;
22
+ wrapString(s: string, style: 'paren' | 'leftright' | 'big' | 'none', fence?: string): string;
23
+ wrapArguments(expr: Expression): string;
24
+ serializeSymbol(expr: Expression, def?: SymbolEntry | FunctionEntry): string;
25
+ serializeFunction(expr: Expression, def?: FunctionEntry | SymbolEntry): string;
24
26
  serializeDictionary(dict: {
25
27
  [key: string]: Expression;
26
28
  }): string;
@@ -1,4 +1,4 @@
1
- /* 0.6.0 */
1
+ /* 0.8.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}
@@ -0,0 +1,11 @@
1
+ /* 0.8.0 */
2
+ /** The canonical form of `Add`:
3
+ * - removes `0`
4
+ * - capture complex numbers (a + ib or ai +b)
5
+ * */
6
+ export declare function canonicalAdd(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression;
7
+ export declare function domainAdd(_ce: IComputeEngine, args: BoxedDomain[]): BoxedDomain | null;
8
+ export declare function simplifyAdd(ce: IComputeEngine, args: BoxedExpression[]): BoxedExpression | undefined;
9
+ export declare function evalAdd(ce: IComputeEngine, args: BoxedExpression[], mode?: 'N' | 'eval'): BoxedExpression;
10
+ export declare function canonicalSummation(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression | undefined): BoxedExpression;
11
+ export declare function evalSummation(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression, mode: 'simplify' | 'N' | 'evaluate'): BoxedExpression | undefined;
@@ -0,0 +1,15 @@
1
+ /* 0.8.0 */
2
+ /**
3
+ * Canonical form of 'Divide' (and 'Rational')
4
+ * - remove denominator of 1
5
+ * - simplify the signs
6
+ * - factor out negate (make the numerator and denominator positive)
7
+ * - if numerator and denominator are integer literals, return a rational number
8
+ * or Rational experssion
9
+ * - if Divide, transform into Multiply/Power
10
+ */
11
+ export declare function canonicalDivide(ce: IComputeEngine, op1: BoxedExpression, op2: BoxedExpression): BoxedExpression;
12
+ /**
13
+ * Simplify form of 'Divide' (and 'Rational')
14
+ */
15
+ export declare function simplifyDivide(ce: IComputeEngine, op1: BoxedExpression, op2: BoxedExpression): BoxedExpression | undefined;
@@ -0,0 +1,19 @@
1
+ /* 0.8.0 */
2
+ /** The canonical form of `Multiply`:
3
+ * - remove `1`
4
+ * - combine literal small integers and rationals
5
+ * - any arg is literal 0 -> return 0
6
+ * - simplify signs
7
+ * - combine terms with same base
8
+ * `a a^3` -> `a^4`
9
+ * - simplify the signs:
10
+ * - i.e. `-2 \times -3` -> `2 \times 3`
11
+ * - `2 \times -x` -> `-2 \times x`
12
+ *
13
+ * The ops must be canonical, the result is canonical.
14
+ */
15
+ export declare function canonicalMultiply(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression;
16
+ export declare function simplifyMultiply(ce: IComputeEngine, ops: BoxedExpression[]): BoxedExpression | undefined;
17
+ export declare function evalMultiply(ce: IComputeEngine, ops: BoxedExpression[], mode?: 'N' | 'evaluate'): BoxedExpression | undefined;
18
+ export declare function canonicalMultiplication(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression | undefined): BoxedExpression;
19
+ export declare function evalMultiplication(ce: IComputeEngine, expr: BoxedExpression, range: BoxedExpression, mode: 'simplify' | 'evaluate' | 'N'): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  /**
3
3
  *
4
4
  * Return `null` if there is no canonicalization necessary and the result is
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const ARITHMETIC_LIBRARY: SymbolTable[];
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const CALCULUS_LIBRARY: SymbolTable[];
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const COLLECTIONS_LIBRARY: SymbolTable;
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const CORE_LIBRARY: SymbolTable[];
@@ -0,0 +1,15 @@
1
+ /* 0.8.0 */
2
+ export declare const DOMAIN_CONSTRUCTORS: string[];
3
+ export declare const DOMAIN_ALIAS: {
4
+ NumericFunction: (string | string[])[];
5
+ RealFunction: (string | string[])[];
6
+ TrigonometricFunction: string[];
7
+ LogicOperator: (string | string[])[];
8
+ Predicate: (string | string[])[];
9
+ RelationalOperator: string[];
10
+ };
11
+ export declare function isDomainLiteral(s: string | null): s is DomainLiteral;
12
+ export declare function isSubdomainLiteral(lhs: string, rhs: string): boolean;
13
+ /** Return all the domain literals that are an ancestor of `dom`
14
+ */
15
+ export declare function ancestors(dom: string): string[];
@@ -0,0 +1,17 @@
1
+ /* 0.8.0 */
2
+ import { IComputeEngine, SymbolTable } from '../public';
3
+ export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): Readonly<SymbolTable>[];
4
+ export declare const LIBRARIES: {
5
+ [category in LibraryCategory]?: Readonly<SymbolTable> | Readonly<SymbolTable>[];
6
+ };
7
+ /**
8
+ * Set the symbol table of the current context (`engine.context`) to `table`
9
+ *
10
+ * `table` can be an array of symbol tables, in order to deal with circular
11
+ * dependencies: it is possible to partition a library into multiple
12
+ * symbol tables, to control the order in which they are processed and
13
+ * avoid having expressions in the definition of an entry reference a symbol
14
+ * or function name that has not yet been added to the symbol table.
15
+ *
16
+ */
17
+ export declare function setCurrentContextSymbolTable(engine: IComputeEngine, table: SymbolTable): void;
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const LOGIC_LIBRARY: SymbolTable;
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const POLYNOMIALS_LIBRARY: SymbolTable[];
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const RELOP_LIBRARY: SymbolTable;
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const SETS_LIBRARY: SymbolTable;
@@ -0,0 +1,2 @@
1
+ /* 0.8.0 */
2
+ export declare const TRIGONOMETRY_LIBRARY: SymbolTable[];
@@ -1,3 +1,3 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  export declare function gamma(c: Complex): Complex;
3
3
  export declare function lngamma(c: Complex): Complex;
@@ -1,7 +1,11 @@
1
- /* 0.6.0 */
1
+ /* 0.8.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;
5
+ export declare function reducedRational([a, b]: [Decimal, Decimal]): [
6
+ Decimal,
7
+ Decimal
8
+ ];
5
9
  export declare function factorial(ce: IComputeEngine, n: Decimal): Decimal;
6
10
  export declare function lngamma(ce: IComputeEngine, z: Decimal): Decimal;
7
11
  export declare function gamma(ce: IComputeEngine, z: Decimal): Decimal;
@@ -1,9 +1,11 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  export declare const MACHINE_PRECISION: number;
3
3
  export declare const MACHINE_TOLERANCE_BITS = 7;
4
4
  export declare const MACHINE_TOLERANCE: number;
5
5
  export declare const NUMERIC_TOLERANCE: number;
6
- export declare const SMALL_INTEGERS = 1000000;
6
+ export declare const SMALL_INTEGER = 1000000;
7
+ export declare const MAX_ITERATION = 1000000;
8
+ export declare const MAX_SYMBOLIC_TERMS = 200;
7
9
  /**
8
10
  * Returns the smallest floating-point number greater than x.
9
11
  * Denormalized values may not be supported.
@@ -1,2 +1,2 @@
1
- /* 0.6.0 */
1
+ /* 0.8.0 */
2
2
  export declare function isPrime(n: number): boolean | undefined;