@cortex-js/compute-engine 0.28.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 (148) hide show
  1. package/dist/{compute-engine.js → compute-engine.cjs} +22662 -23286
  2. package/dist/compute-engine.esm.js +22672 -23296
  3. package/dist/compute-engine.min.cjs +129 -0
  4. package/dist/compute-engine.min.esm.js +47 -63
  5. package/dist/{math-json.js → math-json.cjs} +2 -2
  6. package/dist/math-json.esm.js +2 -2
  7. package/dist/{math-json.min.js → math-json.min.cjs} +2 -2
  8. package/dist/math-json.min.esm.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  11. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  12. package/dist/types/common/interruptible.d.ts +1 -1
  13. package/dist/types/common/json5.d.ts +1 -1
  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 +2 -1
  17. package/dist/types/common/type/parse.d.ts +1 -1
  18. package/dist/types/common/type/primitive.d.ts +1 -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 +102 -107
  22. package/dist/types/common/type/utils.d.ts +1 -1
  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 +11 -14
  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 +3 -3
  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 +12 -13
  33. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +4 -7
  34. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +6 -8
  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 +2 -3
  37. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +2 -2
  38. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +6 -7
  39. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +5 -8
  40. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -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 +1 -1
  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 +8 -9
  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} +835 -807
  68. package/dist/types/compute-engine/{compute-engine.d.ts → index.d.ts} +7 -10
  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} +3 -1
  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 +2 -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 +1 -1
  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 -6
  133. package/dist/types/math-json/identifiers.d.ts +1 -1
  134. package/dist/types/math-json/types.d.ts +4 -2
  135. package/dist/types/math-json/utils.d.ts +1 -1
  136. package/dist/types/math-json.d.ts +2 -2
  137. package/package.json +7 -7
  138. package/dist/compute-engine.min.js +0 -145
  139. package/dist/types/common/buffer.d.ts +0 -9
  140. package/dist/types/common/styled-text.d.ts +0 -28
  141. package/dist/types/common/syntax-highlighter.d.ts +0 -40
  142. package/dist/types/common/terminal.d.ts +0 -19
  143. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +0 -12
  144. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +0 -16
  145. package/dist/types/compute-engine/debug.d.ts +0 -3
  146. package/dist/types/compute-engine/numerics/bignum.d.ts +0 -12
  147. package/dist/types/compute-engine/private.d.ts +0 -29
  148. package/dist/types/compute-engine/public.d.ts +0 -42
@@ -1,9 +0,0 @@
1
- /* 0.28.0 */
2
- s: string;
3
- pos: number;
4
- constructor(s: string, pos?: number);
5
- atEnd(): boolean;
6
- peek(): string;
7
- consume(): string;
8
- match(s: string): boolean;
9
- }
@@ -1,28 +0,0 @@
1
- /* 0.28.0 */
2
- fg?: string;
3
- bg?: string;
4
- weight?: 'bold' | 'normal' | 'thin';
5
- italic?: boolean;
6
- mono?: boolean;
7
- content: string;
8
- };
9
- /** A paragraph block has a blank line before and after
10
- * and is wrapped to the width of the terminal.
11
- *
12
- * A 'block' is rendered as is, with no wrapping, but possibly
13
- * with an indent. Used for code blocks, tables.
14
- *
15
- * A `blockquote` is a block with a vertical bar on the left,
16
- * and is wrapped to the available width.
17
- *
18
- * A `note`, `warning` or `error` is an admonition block with a
19
- * colored background or border (blue, orange or red).
20
- *
21
- */
22
- export type StyledBlock = {
23
- tag: 'paragraph' | 'block';
24
- spans: StyledSpan[];
25
- } | {
26
- tag: 'blockquote' | 'note' | 'warning' | 'error';
27
- blocks: StyledBlock[];
28
- };
@@ -1,40 +0,0 @@
1
- /* 0.28.0 */
2
- import { StyledBlock, StyledSpan } from './styled-text';
3
- export type CodeTag =
4
- /** Plain text in default foreground/background color */
5
- 'default'
6
- /** A literal such as a number, string or regex */
7
- | 'literal'
8
- /** A comment */
9
- | 'comment'
10
- /** A language keyword: if, while, export */
11
- | 'keyword'
12
- /** An operator such as =, >=, +, etc... */
13
- | 'operator'
14
- /** A punctuation such as `;`, `,`, `:` */
15
- | 'punctuation'
16
- /** An identifier such as "foo" or "bar" */
17
- | 'identifier'
18
- /** A type such as `boolean` or `number` */
19
- | 'type';
20
- export type CodeSpan = {
21
- tag: CodeTag;
22
- content: string;
23
- };
24
- export type SyntaxGrammar = {
25
- comment?: (buf: Buffer) => undefined | CodeSpan;
26
- number?: (buf: Buffer) => undefined | CodeSpan;
27
- string?: (buf: Buffer) => undefined | CodeSpan;
28
- regex?: (buf: Buffer) => undefined | CodeSpan;
29
- identifier?: (buf: Buffer) => undefined | CodeSpan;
30
- keyword?: (buf: Buffer) => undefined | CodeSpan;
31
- };
32
- export declare function parseCode(text: string, grammar?: SyntaxGrammar, pos?: number): CodeSpan[];
33
- /** Return a style span of the input code */
34
- export declare function highlightCodeSpan(code: string, grammar?: SyntaxGrammar): StyledSpan[];
35
- /** Return a style block of the input code, including a
36
- * gutter with line numbers and an optional highlighted line
37
- */
38
- export declare function highlightCodeBlock(code: string, lineStart?: number | undefined, markIndicator?: string, grammar?: SyntaxGrammar): StyledBlock;
39
- export declare function mark(line: StyledSpan[], mark: string): StyledSpan[];
40
- /** JS sample */
@@ -1,19 +0,0 @@
1
- /* 0.28.0 */
2
- declare abstract class Terminal {
3
- width: number | undefined;
4
- indent: number;
5
- constructor(options?: {
6
- indent?: number;
7
- width?: number;
8
- });
9
- renderBlock(block: StyledBlock): string;
10
- abstract renderSpan(span: StyledSpan): string;
11
- renderSpans(s: StyledSpan[]): string;
12
- display(s: StyledSpan[] | StyledBlock): void;
13
- }
14
- export declare const terminal: Terminal;
15
- /** Word-wrap a string that contains ANSI escape sequences.
16
- * ANSI escape sequences do not add to the string length.
17
- */
18
- export declare const wrapAnsiString: (string: string, width: number | undefined) => string[];
19
- export {};
@@ -1,12 +0,0 @@
1
- /* 0.28.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 expression
9
- * - evaluate number literals
10
- */
11
- export declare function canonicalDivide(op1: BoxedExpression, op2: BoxedExpression): BoxedExpression;
12
- export declare function div(num: BoxedExpression, denom: number | BoxedExpression): BoxedExpression;
@@ -1,16 +0,0 @@
1
- /* 0.28.0 */
2
- /**
3
- * The canonical form of `Multiply`:
4
- * - removes `1` anb `-1`
5
- * - simplifies the signs:
6
- * - i.e. `-y \times -x` -> `x \times y`
7
- * - `2 \times -x` -> `-2 \times x`
8
- * - arguments are sorted
9
- * - complex numbers promoted (['Multiply', 2, 'ImaginaryUnit'] -> 2i)
10
- * - Numeric values are promoted (['Multiply', 2, 'Sqrt', 3] -> 2√3)
11
- *
12
- * The input ops may not be canonical, the result is canonical.
13
- */
14
- export declare function canonicalMultiply(ce: IComputeEngine, ops: ReadonlyArray<BoxedExpression>): BoxedExpression;
15
- export declare function mul(...xs: ReadonlyArray<BoxedExpression>): BoxedExpression;
16
- export declare function mulN(...xs: ReadonlyArray<BoxedExpression>): BoxedExpression;
@@ -1,3 +0,0 @@
1
- /* 0.28.0 */
2
- /** Return a string representing the stack trace from context */
3
- export declare function trace(_context: RuntimeScope): string;
@@ -1,12 +0,0 @@
1
- /* 0.28.0 */
2
- export type BigNum = Decimal;
3
- export interface IBigNum {
4
- readonly _BIGNUM_NAN: BigNum;
5
- readonly _BIGNUM_ZERO: BigNum;
6
- readonly _BIGNUM_ONE: BigNum;
7
- readonly _BIGNUM_TWO: BigNum;
8
- readonly _BIGNUM_HALF: BigNum;
9
- readonly _BIGNUM_PI: BigNum;
10
- readonly _BIGNUM_NEGATIVE_ONE: BigNum;
11
- bignum(value: string | number | bigint | BigNum): BigNum;
12
- }
@@ -1,29 +0,0 @@
1
- /* 0.28.0 */
2
- import './compute-engine';
3
- import './debug';
4
- import './boxed-expression/expression-map';
5
- import './boxed-expression/abstract-boxed-expression';
6
- import './boxed-expression/boxed-function';
7
- import './boxed-expression/boxed-number';
8
- import './boxed-expression/boxed-patterns';
9
- import './boxed-expression/boxed-string';
10
- import './boxed-expression/order';
11
- import './boxed-expression/utils';
12
- import './boxed-expression/serialize';
13
- import './boxed-expression/rules';
14
- import './symbolic/simplify-rules';
15
- import './boxed-expression/solve';
16
- export * from './assume';
17
- export * from './boxed-expression/expression-map';
18
- export * from './boxed-expression/abstract-boxed-expression';
19
- export * from './boxed-expression/boxed-function';
20
- export * from './boxed-expression/boxed-number';
21
- export * from './boxed-expression/boxed-patterns';
22
- export * from './boxed-expression/boxed-string';
23
- export * from './boxed-expression/order';
24
- export * from './boxed-expression/utils';
25
- export * from './compute-engine';
26
- export * from './debug';
27
- export * from './boxed-expression/rules';
28
- export * from './symbolic/simplify-rules';
29
- export * from './boxed-expression/solve';
@@ -1,42 +0,0 @@
1
- /* 0.28.0 */
2
- *
3
- * The Compute Engine is a symbolic computation engine that can be used to
4
- * manipulate and evaluate mathematical expressions.
5
- *
6
- * Use an instance of {@linkcode ComputeEngine} to create boxed expressions
7
- * with {@linkcode ComputeEngine.parse} and {@linkcode ComputeEngine.box}.
8
- *
9
- * Use a {@linkcode BoxedExpression} object to manipulate and evaluate
10
- * mathematical expressions.
11
- *
12
- * @module "compute-engine"
13
- *
14
- */
15
- import type { OneOf } from '../common/one-of';
16
- import type { FunctionDefinition, SemiBoxedExpression, SymbolDefinition } from './boxed-expression/public';
17
- export * from './boxed-expression/public';
18
- /**
19
- * A table mapping identifiers to their definition.
20
- *
21
- * Identifiers should be valid MathJSON identifiers. In addition, the
22
- * following rules are recommended:
23
- *
24
- * - Use only latin letters, digits and `-`: `/[a-zA-Z0-9-]+/`
25
- * - The first character should be a letter: `/^[a-zA-Z]/`
26
- * - Functions and symbols exported from a library should start with an uppercase letter `/^[A-Z]/`
27
- *
28
- * @category Definitions
29
- *
30
- */
31
- export type IdentifierDefinition = OneOf<[
32
- SymbolDefinition,
33
- FunctionDefinition,
34
- SemiBoxedExpression
35
- ]>;
36
- /**
37
- * @category Definitions
38
- *
39
- */
40
- export type IdentifierDefinitions = Readonly<{
41
- [id: string]: IdentifierDefinition;
42
- }>;