@cortex-js/compute-engine 0.27.0 → 0.29.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 (151) hide show
  1. package/dist/{compute-engine.js → compute-engine.cjs} +24718 -24251
  2. package/dist/compute-engine.esm.js +24718 -24251
  3. package/dist/compute-engine.min.cjs +129 -0
  4. package/dist/compute-engine.min.esm.js +55 -68
  5. package/dist/math-json.cjs +413 -0
  6. package/dist/math-json.esm.js +287 -7
  7. package/dist/math-json.min.cjs +6 -0
  8. package/dist/math-json.min.esm.js +287 -7
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/fuzzy-string-match.d.ts +2 -0
  11. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  12. package/dist/types/common/interruptible.d.ts +2 -2
  13. package/dist/types/common/json5.d.ts +3 -0
  14. package/dist/types/common/one-of.d.ts +2 -1
  15. package/dist/types/common/signals.d.ts +1 -2
  16. package/dist/types/common/type/boxed-type.d.ts +14 -0
  17. package/dist/types/common/type/parse.d.ts +1 -1
  18. package/dist/types/common/type/primitive.d.ts +2 -1
  19. package/dist/types/common/type/serialize.d.ts +1 -1
  20. package/dist/types/common/type/subtype.d.ts +1 -1
  21. package/dist/types/common/type/types.d.ts +121 -136
  22. package/dist/types/common/type/utils.d.ts +3 -7
  23. package/dist/types/common/utils.d.ts +1 -1
  24. package/dist/types/compute-engine/assume.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +17 -18
  26. package/dist/types/compute-engine/boxed-expression/apply.d.ts +2 -2
  27. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +5 -4
  28. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +27 -0
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +2 -2
  30. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/box.d.ts +5 -5
  32. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +20 -14
  33. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +14 -13
  34. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +8 -10
  35. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  36. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +4 -5
  37. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +6 -5
  38. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +11 -11
  39. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +7 -10
  40. package/dist/types/compute-engine/boxed-expression/cache.d.ts +2 -1
  41. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/expand.d.ts +3 -3
  44. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -3
  46. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -2
  48. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/negate.d.ts +2 -2
  50. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +3 -3
  51. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/product.d.ts +5 -5
  54. package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -2
  55. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
  56. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -2
  59. package/dist/types/compute-engine/boxed-expression/terms.d.ts +2 -2
  60. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +2 -9
  61. package/dist/types/compute-engine/boxed-expression/utils.d.ts +13 -4
  62. package/dist/types/compute-engine/boxed-expression/validate.d.ts +9 -10
  63. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  64. package/dist/types/compute-engine/compile.d.ts +2 -4
  65. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  66. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  67. package/dist/types/compute-engine/{boxed-expression/public.d.ts → global-types.d.ts} +887 -849
  68. package/dist/types/compute-engine/{compute-engine.d.ts → index.d.ts} +29 -19
  69. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  70. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  71. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  72. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +2 -2
  83. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  84. package/dist/types/compute-engine/latex-syntax/parse.d.ts +2 -2
  85. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
  86. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
  87. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
  88. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/{public.d.ts → types.d.ts} +13 -6
  90. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -2
  91. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  92. package/dist/types/compute-engine/library/collections.d.ts +3 -2
  93. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  94. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  95. package/dist/types/compute-engine/library/core.d.ts +1 -1
  96. package/dist/types/compute-engine/library/invisible-operator.d.ts +2 -2
  97. package/dist/types/compute-engine/library/library.d.ts +3 -3
  98. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  99. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  100. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  101. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  102. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  103. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  104. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  105. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  106. package/dist/types/compute-engine/library/utils.d.ts +3 -5
  107. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +3 -4
  108. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +3 -5
  109. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +3 -4
  110. package/dist/types/compute-engine/numeric-value/{public.d.ts → types.d.ts} +9 -5
  111. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  112. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  113. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  114. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  115. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  116. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  117. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/numeric.d.ts +2 -7
  119. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -5
  121. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/special-functions.d.ts +4 -4
  123. package/dist/types/compute-engine/numerics/statistics.d.ts +2 -2
  124. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  125. package/dist/types/compute-engine/numerics/types.d.ts +30 -0
  126. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  127. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  128. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  129. package/dist/types/compute-engine/{boxed-expression → tensor}/tensor-fields.d.ts +19 -18
  130. package/dist/types/compute-engine/tensor/tensors.d.ts +9 -12
  131. package/dist/types/compute-engine/types.d.ts +11 -0
  132. package/dist/types/compute-engine.d.ts +3 -5
  133. package/dist/types/math-json/identifiers.d.ts +1 -1
  134. package/dist/types/math-json/types.d.ts +9 -7
  135. package/dist/types/math-json/utils.d.ts +3 -3
  136. package/dist/types/math-json.d.ts +3 -3
  137. package/package.json +9 -9
  138. package/dist/compute-engine.min.js +0 -142
  139. package/dist/math-json.js +0 -133
  140. package/dist/math-json.min.js +0 -4
  141. package/dist/types/common/buffer.d.ts +0 -9
  142. package/dist/types/common/styled-text.d.ts +0 -28
  143. package/dist/types/common/suggest.d.ts +0 -1
  144. package/dist/types/common/syntax-highlighter.d.ts +0 -40
  145. package/dist/types/common/terminal.d.ts +0 -19
  146. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +0 -12
  147. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +0 -16
  148. package/dist/types/compute-engine/debug.d.ts +0 -3
  149. package/dist/types/compute-engine/numerics/bignum.d.ts +0 -12
  150. package/dist/types/compute-engine/private.d.ts +0 -29
  151. package/dist/types/compute-engine/public.d.ts +0 -42
@@ -1,16 +1,16 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression, MathJsonIdentifier, MathJsonNumber } from '../math-json/types';
4
- import type { LibraryCategory, LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/public';
5
- import { AssumeResult, BoxedFunctionDefinition, BoxedSymbolDefinition, IComputeEngine, IdentifierDefinitions, ExpressionMapInterface, RuntimeScope, Scope, SymbolDefinition, BoxedRuleSet, Rule, ComputeEngineStats, Metadata, FunctionDefinition, BoxedSubstitution, AssignValue, AngularUnit, CanonicalOptions } from './public';
6
- import { Rational } from './numerics/rationals';
4
+ import { SymbolDefinition, FunctionDefinition, AngularUnit, AssignValue, AssumeResult, BoxedExpression, BoxedFunctionDefinition, BoxedRule, BoxedRuleSet, BoxedSubstitution, BoxedSymbolDefinition, CanonicalOptions, ComputeEngineStats, EvaluateOptions, ExpressionMapInterface, IdentifierDefinitions, Metadata, Rule, RuntimeScope, Scope, SemiBoxedExpression, ComputeEngine as IComputeEngine } from './global-types';
5
+ import type { BigNum, Rational } from './numerics/types';
7
6
  import { type IndexedLatexDictionary } from './latex-syntax/dictionary/definitions';
8
- import { BoxedExpression, BoxedRule, EvaluateOptions, SemiBoxedExpression } from './boxed-expression/public';
9
7
  import './boxed-expression/serialize';
10
- import { ExactNumericValueData, NumericValue, NumericValueData } from './numeric-value/public';
8
+ import { ExactNumericValueData, NumericValue, NumericValueData } from './numeric-value/types';
9
+ import type { LatexDictionaryEntry, LatexString, LibraryCategory, ParseLatexOptions } from './latex-syntax/types';
10
+ import type { OneOf } from '../common/one-of';
11
11
  import { Type, TypeString } from '../common/type/types';
12
- import { OneOf } from '../common/one-of';
13
- import { BigNum } from './numerics/bignum';
12
+ import { BoxedType } from '../common/type/boxed-type';
13
+ export * from './global-types';
14
14
  /**
15
15
  *
16
16
  * To use the Compute Engine, create a `ComputeEngine` instance:
@@ -195,9 +195,8 @@ export declare class ComputeEngine implements IComputeEngine {
195
195
  *
196
196
  * The order of the dictionaries matter: the definitions from the later ones
197
197
  * override the definitions from earlier ones. The first dictionary should
198
- * be the `'core'` dictionary which include some basic definitions such
199
- * as domains (`Booleans`, `Numbers`, etc...) that are used by later
200
- * dictionaries.
198
+ * be the `'core'` dictionary which include basic definitions that are used
199
+ * by later dictionaries.
201
200
  *
202
201
  *
203
202
  * @param options.precision Specific how many digits of precision
@@ -212,6 +211,7 @@ export declare class ComputeEngine implements IComputeEngine {
212
211
  precision?: number | 'machine';
213
212
  tolerance?: number | 'auto';
214
213
  });
214
+ toString(): string;
215
215
  get latexDictionary(): Readonly<LatexDictionaryEntry[]>;
216
216
  set latexDictionary(dic: Readonly<LatexDictionaryEntry[]>);
217
217
  get indexedLatexDictionary(): IndexedLatexDictionary;
@@ -231,30 +231,39 @@ export declare class ComputeEngine implements IComputeEngine {
231
231
  get stats(): ComputeEngineStats;
232
232
  get precision(): number;
233
233
  /** The precision, or number of significant digits, of numeric
234
- * calculations when the numeric mode is `"auto"` or `"bignum"`.
234
+ * calculations.
235
235
  *
236
236
  * To make calculations using more digits, at the cost of expanded memory
237
237
  * usage and slower computations, set the `precision` higher.
238
238
  *
239
- * If the numeric mode is not `"auto"` or `"bignum"`, it is set to `"auto"`.
240
- *
241
239
  * Trigonometric operations are accurate for precision up to 1,000.
242
240
  *
243
241
  */
244
242
  set precision(p: number | 'machine' | 'auto');
245
243
  /**
246
- * The unit used for angles in trigonometric functions.
244
+ * The unit used for unitless angles in trigonometric functions.
245
+ *
246
+ * - `rad`: radian, $2\pi$ radians is a full circle
247
+ * - `deg`: degree, 360 degrees is a full circle
248
+ * - `grad`: gradians, 400 gradians is a full circle
249
+ * - `turn`: turn, 1 turn is a full circle
247
250
  *
248
251
  * Default is `"rad"` (radians).
249
252
  */
250
253
  get angularUnit(): AngularUnit;
251
254
  set angularUnit(u: AngularUnit);
252
- /** @experimental */
253
255
  get timeLimit(): number;
254
- /** @experimental */
256
+ set timeLimit(t: number);
257
+ private _timeLimit;
258
+ /** The time after which the time limit has been exceeded */
259
+ _deadline: number | undefined;
260
+ get _timeRemaining(): number;
255
261
  get iterationLimit(): number;
256
- /** @experimental */
262
+ set iterationLimit(t: number);
263
+ private _iterationLimit;
257
264
  get recursionLimit(): number;
265
+ set recursionLimit(t: number);
266
+ private _recursionLimit;
258
267
  get tolerance(): number;
259
268
  /**
260
269
  * Values smaller than the tolerance are considered to be zero for the
@@ -524,7 +533,7 @@ export declare class ComputeEngine implements IComputeEngine {
524
533
  * The result is canonical.
525
534
  */
526
535
  error(message: string | string[], where?: string): BoxedExpression;
527
- typeError(expected: Type, actual: undefined | Type, where?: string): BoxedExpression;
536
+ typeError(expected: Type, actual: undefined | Type | BoxedType, where?: string): BoxedExpression;
528
537
  /**
529
538
  * Add a `["Hold"]` wrapper to `expr`.
530
539
  */
@@ -535,6 +544,7 @@ export declare class ComputeEngine implements IComputeEngine {
535
544
  */
536
545
  tuple(...elements: ReadonlyArray<number>): BoxedExpression;
537
546
  tuple(...elements: ReadonlyArray<BoxedExpression>): BoxedExpression;
547
+ type(type: Type | TypeString | BoxedType): BoxedType;
538
548
  string(s: string, metadata?: Metadata): BoxedExpression;
539
549
  /** Return a boxed symbol */
540
550
  symbol(name: string, options?: {
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_COMPLEX: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_CORE: LatexDictionary;
3
3
  export declare const DELIMITERS_SHORTHAND: {
4
4
  '(': string;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionaryEntry[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_STATISTICS: LatexDictionary;
@@ -1,3 +1,3 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const SYMBOLS: [string, string, number][];
3
3
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../public';
1
+ /* 0.29.0 */
2
+ import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../types';
3
3
  export type CommonEntry = {
4
4
  /** Note: a name is required if a serialize handler is provided */
5
5
  name?: string;
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { Parser } from './public';
1
+ /* 0.29.0 */
2
+ import { Parser } from './types';
3
3
  /** For error handling, if we have a identifier prefix, assume
4
4
  * the identifier is invalid (it would have been captured by
5
5
  * `matchIdentifier()` otherwise) and return an error expression */
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable, SymbolType } from './public';
1
+ /* 0.29.0 */
2
+ import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable, SymbolType } from './types';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
4
4
  /**
5
5
  * ## THEORY OF OPERATIONS
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { NumberSerializationFormat } from './public';
1
+ /* 0.29.0 */
2
+ import { NumberSerializationFormat } from './types';
3
3
  /**
4
4
  * @param expr - A number, can be represented as a string
5
5
  * (particularly useful for arbitrary precision numbers) or a number (-12.45)
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { DelimiterScale } from './public';
1
+ /* 0.29.0 */
2
+ import { DelimiterScale } from './types';
3
3
  export declare function getApplyFunctionStyle(_expr: Expression, _level: number): DelimiterScale;
4
4
  export declare function getGroupStyle(_expr: Expression, _level: number): DelimiterScale;
5
5
  export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { LatexString, SerializeLatexOptions, DelimiterScale } from './public';
1
+ /* 0.29.0 */
2
+ import { LatexString, SerializeLatexOptions, DelimiterScale } from './types';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
4
4
  export declare class Serializer {
5
5
  options: Readonly<SerializeLatexOptions>;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.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,5 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
+ import type { Expression, MathJsonIdentifier } from '../../math-json/types';
2
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
3
4
  export type SymbolType = 'symbol' | 'function' | 'unknown';
4
5
  export type SymbolTable = {
@@ -100,6 +101,8 @@ export declare const MULTIPLICATION_PRECEDENCE: Precedence;
100
101
  /** @hidden */
101
102
  export declare const DIVISION_PRECEDENCE: Precedence;
102
103
  /** @hidden */
104
+ export declare const INVISIBLE_OP_PRECEDENCE: Precedence;
105
+ /** @hidden */
103
106
  export declare const EXPONENTIATION_PRECEDENCE: Precedence;
104
107
  /** @hidden */
105
108
  export declare const POSTFIX_PRECEDENCE: Precedence;
@@ -220,14 +223,14 @@ export type BaseEntry = {
220
223
  * @category Latex Parsing and Serialization
221
224
  */
222
225
  export type DefaultEntry = BaseEntry & Trigger & {
223
- parse: Expression | ExpressionParseHandler;
226
+ parse?: Expression | ExpressionParseHandler;
224
227
  };
225
228
  /**
226
229
  * @category Latex Parsing and Serialization
227
230
  */
228
231
  export type ExpressionEntry = BaseEntry & Trigger & {
229
232
  kind: 'expression';
230
- parse: Expression | ExpressionParseHandler;
233
+ parse?: Expression | ExpressionParseHandler;
231
234
  precedence?: Precedence;
232
235
  };
233
236
  /**
@@ -341,7 +344,9 @@ export type FunctionEntry = BaseEntry & Trigger & {
341
344
  * @category Latex Parsing and Serialization
342
345
  *
343
346
  */
344
- export type LatexDictionaryEntry = DefaultEntry | ExpressionEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry;
347
+ export type LatexDictionaryEntry = OneOf<[
348
+ ExpressionEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry | DefaultEntry
349
+ ]>;
345
350
  /** @internal */
346
351
  export declare function isExpressionEntry(entry: LatexDictionaryEntry): entry is ExpressionEntry;
347
352
  /** @internal */
@@ -370,6 +375,7 @@ export declare function isEnvironmentEntry(entry: LatexDictionaryEntry): entry i
370
375
  export type LatexDictionary = ReadonlyArray<Partial<LatexDictionaryEntry>>;
371
376
  /**
372
377
  * These options control how numbers are parsed and serialized.
378
+ * @category Serialization
373
379
  */
374
380
  export type NumberFormat = {
375
381
  positiveInfinity: LatexString;
@@ -427,6 +433,7 @@ export type NumberFormat = {
427
433
  truncationMarker: LatexString;
428
434
  repeatingDecimal: 'auto' | 'vinculum' | 'dots' | 'parentheses' | 'arc' | 'none';
429
435
  };
436
+ /** @category Serialization */
430
437
  export type NumberSerializationFormat = NumberFormat & {
431
438
  /**
432
439
  * The maximum number of significant digits in serialized numbers.
@@ -475,7 +482,7 @@ export type ParseLatexOptions = NumberFormat & {
475
482
  * This handler is invoked when the parser encounters an identifier
476
483
  * that has not yet been declared.
477
484
  *
478
- * The `identifier` argument is a (valid identifier)[/math-json/#identifiers].
485
+ * The `identifier` argument is a [valid identifier](/math-json/#identifiers).
479
486
  *
480
487
  * The handler can return:
481
488
  *
@@ -575,7 +582,7 @@ export interface Parser {
575
582
  */
576
583
  matchChar(): string | null;
577
584
  /**
578
- * Parse an expression in aLaTeX group enclosed in curly brackets `{}`.
585
+ * Parse an expression in a LaTeX group enclosed in curly brackets `{}`.
579
586
  * These are often used as arguments to LaTeX commands, for example
580
587
  * `\frac{1}{2}`.
581
588
  *
@@ -1,5 +1,4 @@
1
- /* 0.27.0 */
2
- import { BoxedExpression } from '../boxed-expression/public';
1
+ /* 0.29.0 */
3
2
  export type CanonicalArithmeticOperators = 'Add' | 'Negate' | 'Multiply' | 'Divide' | 'Power' | 'Sqrt' | 'Root' | 'Ln';
4
3
  export declare const ARITHMETIC_LIBRARY: IdentifierDefinitions[];
5
4
  export declare function isPrime(expr: BoxedExpression): boolean | undefined;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFAULT_LINSPACE_COUNT = 50;
3
3
  export declare const COLLECTIONS_LIBRARY: IdentifierDefinitions;
4
4
  /**
@@ -22,5 +22,6 @@ export declare function rangeLast(r: [lower: number, upper: number, step: number
22
22
  * is returned. Otherwise, the result of the function is used as the new accumulator.
23
23
  * If the iteration completes, the final accumulator is returned.
24
24
  */
25
- export declare function reduceCollection<T>(collection: BoxedExpression, fn: (acc: T, next: BoxedExpression) => T | null, initial: T): T | undefined;
25
+ export declare function reduceCollection<T>(collection: BoxedExpression, fn: (acc: T, next: BoxedExpression) => T | null, initial: T): Generator<T | undefined>;
26
26
  export declare function fromRange(start: number, end: number): number[];
27
+ export declare function canonicalDictionary(engine: ComputeEngine, dict: BoxedExpression): BoxedExpression;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const CORE_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function canonicalInvisibleOperator(ops: ReadonlyArray<BoxedExpression>, { engine: ce }: {
3
- engine: IComputeEngine;
3
+ engine: ComputeEngine;
4
4
  }): BoxedExpression | null;
@@ -1,5 +1,5 @@
1
- /* 0.27.0 */
2
- import { IComputeEngine, IdentifierDefinitions } from '../public';
1
+ /* 0.29.0 */
2
+ import type { IdentifierDefinitions, ComputeEngine } from '../global-types';
3
3
  export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
4
4
  export declare const LIBRARIES: {
5
5
  [category in LibraryCategory]?: IdentifierDefinitions | IdentifierDefinitions[];
@@ -14,4 +14,4 @@ export declare const LIBRARIES: {
14
14
  * or function name that has not yet been added to the symbol table.
15
15
  *
16
16
  */
17
- export declare function setIdentifierDefinitions(engine: IComputeEngine, table: IdentifierDefinitions): void;
17
+ export declare function setIdentifierDefinitions(engine: ComputeEngine, table: IdentifierDefinitions): void;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const LOGIC_LIBRARY: IdentifierDefinitions;
3
3
  export declare function simplifyLogicFunction(x: BoxedExpression): {
4
4
  value: BoxedExpression;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function randomExpression(level?: number): Expression;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const RELOP_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const SETS_LIBRARY: IdentifierDefinitions;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export type IndexingSet = {
3
3
  index: string | undefined;
4
4
  lower: number;
@@ -23,7 +23,7 @@ export type IndexingSet = {
23
23
  */
24
24
  export declare function normalizeIndexingSet(indexingSet: BoxedExpression): IndexingSet;
25
25
  export declare function normalizeIndexingSets(ops: ReadonlyArray<BoxedExpression>): IndexingSet[];
26
- export declare function indexingSetCartestianProduct(indexingSets: IndexingSet[]): number[][];
26
+ export declare function indexingSetCartesianProduct(indexingSets: IndexingSet[]): number[][];
27
27
  /**
28
28
  * Calculates the cartesian product of two arrays.
29
29
  * ```ts
@@ -49,9 +49,7 @@ export declare function canonicalBigop(operator: string, body: BoxedExpression,
49
49
  * - ['Operator', collection]
50
50
  *
51
51
  * `fn()` is the processing done on each element
52
- */
53
- /**
54
52
  * Apply the function `fn` to the body of a big operator, according to the
55
53
  * indexing sets.
56
54
  */
57
- export declare function reduceBigOp<T>(body: BoxedExpression, indexes: ReadonlyArray<BoxedExpression>, fn: (acc: T, x: BoxedExpression) => T | null, initial: T): T | undefined;
55
+ export declare function reduceBigOp<T>(body: BoxedExpression, indexes: ReadonlyArray<BoxedExpression>, fn: (acc: T, x: BoxedExpression) => T | null, initial: T): Generator<T | undefined>;
@@ -1,10 +1,9 @@
1
- /* 0.27.0 */
2
- import { NumericValue, NumericValueData } from './public';
1
+ /* 0.29.0 */
2
+ import { BigNumFactory, NumericValue, NumericValueData } from './types';
3
3
  import { ExactNumericValue } from './exact-numeric-value';
4
4
  import { Expression } from '../../math-json/types';
5
- import { SmallInteger } from '../numerics/numeric';
5
+ import { SmallInteger } from '../numerics/types';
6
6
  import { NumericType } from '../../common/type/types';
7
- export type BigNumFactory = (value: Decimal.Value) => Decimal;
8
7
  export declare class BigNumericValue extends NumericValue {
9
8
  __brand: 'BigNumericValue';
10
9
  decimal: Decimal;
@@ -1,9 +1,7 @@
1
- /* 0.27.0 */
2
- import { SmallInteger } from '../numerics/numeric';
3
- import { Rational } from '../numerics/rationals';
4
- import { ExactNumericValueData, NumericValue, NumericValueFactory } from './public';
1
+ /* 0.29.0 */
2
+ import { Rational, SmallInteger } from '../numerics/types';
3
+ import { BigNumFactory, ExactNumericValueData, NumericValue, NumericValueFactory } from './types';
5
4
  import { Expression } from '../../math-json/types';
6
- import { BigNumFactory } from './big-numeric-value';
7
5
  import { NumericType } from '../../common/type/types';
8
6
  /**
9
7
  * An ExactNumericValue is the sum of a Gaussian imaginary and the product of
@@ -1,9 +1,8 @@
1
- /* 0.27.0 */
2
- import { NumericValue, NumericValueData } from './public';
1
+ /* 0.29.0 */
2
+ import { BigNumFactory, NumericValue, NumericValueData } from './types';
3
3
  import type { Expression } from '../../math-json/types';
4
- import { SmallInteger } from '../numerics/numeric';
4
+ import type { SmallInteger } from '../numerics/types';
5
5
  import { NumericType } from '../../common/type/types';
6
- import { BigNumFactory } from './big-numeric-value';
7
6
  export declare class MachineNumericValue extends NumericValue {
8
7
  __brand: 'MachineNumericValue';
9
8
  decimal: number;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  *
3
3
  * ## THEORY OF OPERATIONS
4
4
  *
@@ -23,20 +23,24 @@
23
23
  * A float numeric value is never converted to an exact one.
24
24
  *
25
25
  */
26
- import Decimal from 'decimal.js';
27
- import { SmallInteger } from '../numerics/numeric';
28
- import { Rational } from '../numerics/rationals';
26
+ import { Decimal } from 'decimal.js';
27
+ import type { Rational, SmallInteger } from '../numerics/types';
29
28
  import { NumericType } from '../../common/type/types';
30
- /** The value is equal to `(decimal * rational * sqrt(radical)) + im * i` */
29
+ export type BigNumFactory = (value: Decimal.Value) => Decimal;
30
+ /** The value is equal to `(decimal * rational * sqrt(radical)) + im * i`
31
+ * @category Numerics */
31
32
  export type ExactNumericValueData = {
32
33
  rational?: Rational;
33
34
  radical?: number;
34
35
  };
36
+ /** @category Numerics */
35
37
  export type NumericValueData = {
36
38
  re?: Decimal | number;
37
39
  im?: number;
38
40
  };
41
+ /** @category Numerics */
39
42
  export type NumericValueFactory = (data: number | Decimal | NumericValueData) => NumericValue;
43
+ /** @category Numerics */
40
44
  export declare abstract class NumericValue {
41
45
  abstract get type(): NumericType;
42
46
  /** True if numeric value is the product of a rational and the square root of an integer.
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function bigint(a: Decimal | number | bigint | string): bigint | null;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function bigintValue(expr: Expression | null | undefined): bigint | null;
3
3
  /** Output a shorthand if possible */
4
4
  export declare function numberToExpression(num: number | bigint, fractionalDigits?: string | number): Expression;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  /** An interval is a continuous set of real numbers */
3
3
  export type Interval = {
4
4
  start: number;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  * Return a numerical approximation of the integral
3
3
  * of the function `f` from `a` to `b` using Monte Carlo integration.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function lcm(a: bigint, b: bigint): bigint;
3
3
  /** Return `[factor, root]` such that
4
4
  * pow(n, 1/exponent) = factor * pow(root, 1/exponent)
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function gcd(a: BigNum, b: BigNum): BigNum;
3
3
  export declare function lcm(a: BigNum, b: BigNum): BigNum;
4
4
  export declare function factorial2(ce: IBigNum, n: BigNum): BigNum;
@@ -1,3 +1,3 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function gamma(c: Complex): Complex;
3
3
  export declare function gammaln(c: Complex): Complex;
@@ -1,10 +1,8 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const MACHINE_PRECISION_BITS = 53;
3
3
  export declare const MACHINE_PRECISION: number;
4
4
  export declare const DEFAULT_TOLERANCE = 1e-10;
5
5
  export declare const SMALL_INTEGER = 1000000;
6
- type IsInteger<N extends number> = `${N}` extends `${string}.${string}` ? never : `${N}` extends `-${string}.${string}` ? never : number;
7
- export type SmallInteger = IsInteger<number>;
8
6
  /** The largest number of digits of a bigint */
9
7
  export declare const MAX_BIGINT_DIGITS = 1024;
10
8
  export declare const MAX_ITERATION = 1000000;
@@ -33,9 +31,7 @@ export declare function chop(n: number, tolerance?: number): 0 | number;
33
31
  * The formula for the 8th-order centered difference approximation for the
34
32
  * first derivative is given by:
35
33
  *
36
- * \[
37
- * f'(x) \approx \frac{1}{280h} \left[ -f(x-4h) + \frac{4}{3}f(x-3h) - \frac{1}{5}f(x-2h) + \frac{8}{5}f(x-h) - \frac{8}{5}f(x+h) + \frac{1}{5}f(x+2h) - \frac{4}{3}f(x+3h) + f(x+4h) \right]
38
- * \]
34
+ * $$ f'(x) \approx \frac{1}{280h} \left[ -f(x-4h) + \frac{4}{3}f(x-3h) - \frac{1}{5}f(x-2h) + \frac{8}{5}f(x-h) - \frac{8}{5}f(x+h) + \frac{1}{5}f(x+2h) - \frac{4}{3}f(x+3h) + f(x+4h) \right]$$
39
35
  *
40
36
  * Note: Mathematica uses an 8th order approximation for the first derivative
41
37
  *
@@ -54,4 +50,3 @@ export declare function centeredDiff8thOrder(f: (number: any) => number, x: numb
54
50
  * @returns
55
51
  */
56
52
  export declare function limit(f: (x: number) => number, x: number, dir?: number): number;
57
- export {};
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare function primeFactors(n: number): {
3
3
  [factor: number]: number;
4
4
  };