@cortex-js/compute-engine 0.24.1 → 0.25.1

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 (112) hide show
  1. package/dist/compute-engine.esm.js +24046 -25451
  2. package/dist/compute-engine.js +23987 -25392
  3. package/dist/compute-engine.min.esm.js +13 -13
  4. package/dist/compute-engine.min.js +13 -13
  5. package/dist/math-json.esm.js +43 -77
  6. package/dist/math-json.js +43 -77
  7. package/dist/math-json.min.esm.js +43 -77
  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 +31 -19
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +9 -9
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +9 -10
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +5 -4
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -15
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
  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 +7 -8
  25. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +6 -7
  26. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
  27. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +56 -0
  28. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/factor.d.ts +11 -0
  30. package/dist/types/compute-engine/boxed-expression/match.d.ts +14 -0
  31. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +41 -0
  32. package/dist/types/compute-engine/boxed-expression/order.d.ts +6 -6
  33. package/dist/types/compute-engine/boxed-expression/public.d.ts +1983 -0
  34. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -15
  35. package/dist/types/compute-engine/boxed-expression/utils.d.ts +5 -2
  36. package/dist/types/compute-engine/boxed-expression/validate.d.ts +7 -6
  37. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  38. package/dist/types/compute-engine/compile.d.ts +2 -2
  39. package/dist/types/compute-engine/compute-engine.d.ts +86 -62
  40. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  41. package/dist/types/compute-engine/domain-utils.d.ts +3 -2
  42. package/dist/types/compute-engine/function-utils.d.ts +2 -2
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -3
  52. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +5 -4
  57. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  58. package/dist/types/compute-engine/latex-syntax/parse.d.ts +71 -29
  59. package/dist/types/compute-engine/latex-syntax/public.d.ts +264 -252
  60. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +9 -3
  61. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  62. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -11
  63. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +3 -2
  64. package/dist/types/compute-engine/library/arithmetic-add.d.ts +5 -5
  65. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +2 -2
  66. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +5 -5
  67. package/dist/types/compute-engine/library/arithmetic-power.d.ts +2 -1
  68. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  69. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  70. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  71. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  72. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  73. package/dist/types/compute-engine/library/core.d.ts +3 -2
  74. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  75. package/dist/types/compute-engine/library/library.d.ts +1 -1
  76. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  78. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  79. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  80. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -2
  81. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  82. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  83. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  84. package/dist/types/compute-engine/library/utils.d.ts +2 -2
  85. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +7 -1
  86. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  87. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  88. package/dist/types/compute-engine/numerics/numeric.d.ts +7 -17
  89. package/dist/types/compute-engine/numerics/primes.d.ts +6 -1
  90. package/dist/types/compute-engine/numerics/rationals.d.ts +4 -13
  91. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  92. package/dist/types/compute-engine/numerics/terms.d.ts +7 -4
  93. package/dist/types/compute-engine/public.d.ts +3 -1841
  94. package/dist/types/compute-engine/rules.d.ts +1 -1
  95. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  96. package/dist/types/compute-engine/solve.d.ts +4 -3
  97. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  98. package/dist/types/compute-engine/symbolic/expand.d.ts +2 -2
  99. package/dist/types/compute-engine/symbolic/flatten.d.ts +6 -4
  100. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  101. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  102. package/dist/types/compute-engine/symbolic/product.d.ts +4 -3
  103. package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
  104. package/dist/types/compute-engine/symbolic/tensors.d.ts +1 -1
  105. package/dist/types/compute-engine/symbolic/utils.d.ts +5 -10
  106. package/dist/types/compute-engine.d.ts +2 -2
  107. package/dist/types/math-json/math-json-format.d.ts +3 -3
  108. package/dist/types/math-json/utils.d.ts +4 -6
  109. package/dist/types/math-json.d.ts +2 -2
  110. package/package.json +10 -10
  111. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +0 -28
  112. package/dist/types/compute-engine/numerics/factor.d.ts +0 -27
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.24.1 */
1
+ /** MathJSON 0.25.1 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson=(()=>{var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},R=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!k.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return n};var _=n=>R(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>J,getDictionary:()=>y,getStringValue:()=>m,head:()=>o,headName:()=>I,isDictionaryObject:()=>M,isFunctionObject:()=>u,isStringObject:()=>S,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>A,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function S(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function M(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function N(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||O.test(n)?!0:N(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var F="\\u{FE0F}",V="\\u{20E3}",L="\\u{200D}",P="\\p{RI}\\p{RI}",w="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${F}${V}?|${w})`,C="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${C}${b}*|\\p{Emoji}${b}+|${P})`,j=`(?:${h})(${L}${h})*`,G=new RegExp(`(?:${j})+`,"u"),O=new RegExp(`^(?:${j})+$`,"u");function q(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":O.test(n)?"valid":/\p{XIDC}/u.test(n)&&G.test(n)?"unexpected-mixed-emoji":N(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function o(n){return Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${q(n[0])}`),null):n[0]:n==null?null:u(n)?n.fn[0]:null}function I(n){let t=o(n);return typeof t=="string"?t:""}function H(n){return Array.isArray(n)?n.slice(1):n==null?null:u(n)?n.fn.slice(1):null}function s(n,t){return Array.isArray(n)?n[t]??null:n==null?null:u(n)?n.fn[t]??null:null}function K(n){return s(n,1)}function Z(n){return s(n,2)}function E(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function A(n){if(typeof n=="string")return/^[+-]?[0-9\.]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"?null:n;if(n==null)return null;let t=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=o(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(K(n));return e?[e,Z(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(o(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let l=p(s(n,r));l&&(i[l[0]]=l[1])}return i}return null}function J(n,t){let e=o(n);if(e!==null)return[t(e),...(H(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),l={};for(let g of r)l[g]=t(i[g]);return{dict:l}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.24.1";return _(z);})();
3
+ var MathJson=(()=>{var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},F=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!k.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return n};var R=n=>F(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>A,getDictionary:()=>y,getStringValue:()=>m,head:()=>l,headName:()=>j,isDictionaryObject:()=>S,isFunctionObject:()=>u,isStringObject:()=>M,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>O,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function M(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function S(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function I(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||N.test(n)?!0:I(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var _="\\u{FE0F}",V="\\u{20E3}",L="\\u{200D}",P="\\p{RI}\\p{RI}",w="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${_}${V}?|${w})`,C="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${C}${b}*|\\p{Emoji}${b}+|${P})`,J=`(?:${h})(${L}${h})*`,G=new RegExp(`(?:${J})+`,"u"),N=new RegExp(`^(?:${J})+$`,"u");function q(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":N.test(n)?"valid":/\p{XIDC}/u.test(n)&&G.test(n)?"unexpected-mixed-emoji":I(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function l(n){return Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${q(n[0])}`),null):n[0]:n==null?null:u(n)?n.fn[0]:null}function j(n){let t=l(n);return typeof t=="string"?t:""}function H(n){return Array.isArray(n)?n.slice(1):n==null?null:u(n)?n.fn.slice(1):null}function s(n,t){return Array.isArray(n)?n[t]??null:n==null?null:u(n)?n.fn[t]??null:null}function K(n){return s(n,1)}function Z(n){return s(n,2)}function E(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function O(n){if(typeof n=="string")return/^[+-]?[0-9\.]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"?null:n;if(n==null)return null;let t=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(K(n));return e?[e,Z(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let o=p(s(n,r));o&&(i[o[0]]=o[1])}return i}return null}function A(n,t){let e=l(n);if(e!==null)return[t(e),...(H(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),o={};for(let g of r)o[g]=t(i[g]);return{dict:o}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.25.1";return R(z);})();
4
4
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  export declare const BLACK = "\u001B[30;1m${s}";
3
3
  export declare const GREY = "\u001B[30;1m${s}";
4
4
  export declare const GREEN = "\u001B[32;1m";
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  /** @category Error Handling */
3
3
  export type RuntimeSignalCode = 'timeout' | 'out-of-memory' | 'recursion-depth-exceeded' | 'iteration-limit-exceeded';
4
4
  /** @category Error Handling */
@@ -1 +1 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,7 +1,10 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution, Rule, SemiBoxedExpression } from '../public';
4
+ import { LatexString } from '../public';
5
+ import { Rational } from '../numerics/rationals';
6
+ import { BoxedBaseDefinition, BoxedDomain, BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSubstitution, BoxedSymbolDefinition, CanonicalOptions, DomainCompatibility, DomainLiteral, EvaluateOptions, IComputeEngine, JsonSerializationOptions, Metadata, NOptions, PatternMatchOptions, Rule, RuntimeScope, SemiBoxedExpression, SimplifyOptions, Substitution } from './public';
7
+ import { SerializeLatexOptions } from '../latex-syntax/public';
5
8
  /**
6
9
  * _BoxedExpression
7
10
  */
@@ -18,22 +21,28 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
18
21
  /** Verbatim LaTeX, obtained from a source, i.e. from parsing,
19
22
  * not generated synthetically
20
23
  */
21
- protected _latex?: string;
24
+ verbatimLatex?: string;
22
25
  constructor(ce: IComputeEngine, metadata?: Metadata);
23
26
  /**
24
27
  *
25
28
  * `Object.valueOf()`: return a JavaScript primitive value for the expression
26
29
  *
30
+ * Primitive values are: boolean, number, bigint, string, null, undefined
31
+ *
27
32
  */
28
- valueOf(): number | any[] | string | boolean;
33
+ valueOf(): number | Object | string | boolean;
29
34
  /** Object.toString() */
30
35
  toString(): string;
31
36
  print(): void;
32
37
  [Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
33
- /** Called by `JSON.stringify()` when serializing to json */
38
+ /** Called by `JSON.stringify()` when serializing to json.
39
+ *
40
+ * Note: this is a standard method of JavaScript objects.
41
+ *
42
+ */
34
43
  toJSON(): Expression;
35
- /** @internal */
36
- get rawJson(): Expression;
44
+ toMathJson(options?: Readonly<Partial<JsonSerializationOptions>>): Expression;
45
+ toLatex(options?: Partial<SerializeLatexOptions>): LatexString;
37
46
  get scope(): RuntimeScope | null;
38
47
  /** Object.is() */
39
48
  is(rhs: any): boolean;
@@ -41,15 +50,14 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
41
50
  get latex(): LatexString;
42
51
  set latex(val: LatexString);
43
52
  get symbol(): string | null;
44
- get isNothing(): boolean;
45
53
  get string(): string | null;
46
- getSubexpressions(head: string): BoxedExpression[];
47
- get subexpressions(): BoxedExpression[];
48
- get symbols(): string[];
49
- get unknowns(): string[];
50
- get freeVariables(): string[];
51
- get errors(): BoxedExpression[];
52
- get ops(): null | BoxedExpression[];
54
+ getSubexpressions(head: string): ReadonlyArray<BoxedExpression>;
55
+ get subexpressions(): ReadonlyArray<BoxedExpression>;
56
+ get symbols(): ReadonlyArray<string>;
57
+ get unknowns(): ReadonlyArray<string>;
58
+ get freeVariables(): ReadonlyArray<string>;
59
+ get errors(): ReadonlyArray<BoxedExpression>;
60
+ get ops(): null | ReadonlyArray<BoxedExpression>;
53
61
  get nops(): number;
54
62
  get op1(): BoxedExpression;
55
63
  get op2(): BoxedExpression;
@@ -75,9 +83,13 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
75
83
  get shape(): number[];
76
84
  get rank(): number;
77
85
  subs(_sub: Substitution, options?: {
78
- canonical: boolean;
86
+ canonical?: CanonicalOptions;
87
+ }): BoxedExpression;
88
+ map(fn: (x: BoxedExpression) => BoxedExpression, options?: {
89
+ canonical: CanonicalOptions;
90
+ recursive?: boolean;
79
91
  }): BoxedExpression;
80
- solve(_vars: Iterable<string>): null | BoxedExpression[];
92
+ solve(_vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
81
93
  replace(_rules: BoxedRuleSet | Rule | Rule[]): null | BoxedExpression;
82
94
  has(_v: string | string[]): boolean;
83
95
  isLess(_rhs: BoxedExpression): boolean | undefined;
@@ -103,7 +115,7 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
103
115
  get keysCount(): number;
104
116
  getKey(_key: string): BoxedExpression | undefined;
105
117
  hasKey(_key: string): boolean;
106
- get value(): number | boolean | string | number[] | undefined;
118
+ get value(): number | boolean | string | Object | undefined;
107
119
  set value(_value: BoxedExpression | number | boolean | string | number[] | undefined);
108
120
  get domain(): BoxedDomain | undefined;
109
121
  set domain(_domain: BoxedDomain);
@@ -123,4 +135,4 @@ export declare abstract class _BoxedExpression implements BoxedExpression {
123
135
  optimize: ('simplify' | 'evaluate')[];
124
136
  }): ((args: Record<string, any>) => any | undefined) | undefined;
125
137
  }
126
- export declare function getSubexpressions(expr: BoxedExpression, head: string): BoxedExpression[];
138
+ export declare function getSubexpressions(expr: BoxedExpression, head: string): ReadonlyArray<BoxedExpression>;
@@ -1,7 +1,8 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
- import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, Rational, CanonicalForm } from '../public';
3
+ import { IComputeEngine, SemiBoxedExpression, BoxedExpression, Metadata, CanonicalOptions } from './public';
4
4
  import { MathJsonNumber } from '../../math-json/math-json-format';
5
+ import { Rational } from '../numerics/rationals';
5
6
  /**
6
7
  * ### THEORY OF OPERATIONS
7
8
  *
@@ -68,11 +69,11 @@ export declare function boxNumber(ce: IComputeEngine, num: MathJsonNumber | numb
68
69
  *
69
70
  * If available, preserve LaTeX and wikidata metadata in the boxed expression.
70
71
  *
71
- * Note that `boxFunction()` should only be called from `ce.box()`
72
+ * Note that `boxFunction()` should only be called from `ce.function()`
72
73
  */
73
- export declare function boxFunction(ce: IComputeEngine, head: string, ops: SemiBoxedExpression[], options: {
74
+ export declare function boxFunction(ce: IComputeEngine, head: string, ops: readonly SemiBoxedExpression[], options?: {
74
75
  metadata?: Metadata;
75
- canonical?: boolean;
76
+ canonical?: CanonicalOptions;
76
77
  }): BoxedExpression;
77
78
  /**
78
79
  * Notes about the boxed form:
@@ -93,13 +94,12 @@ export declare function boxFunction(ce: IComputeEngine, head: string, ops: SemiB
93
94
  *
94
95
  * [4] A `Negate` function applied to a number literal is converted to a number.
95
96
  *
96
- *
97
- * Note that `Negate` is only distributed over addition. In practice, having
97
+ * Note that `Negate` is only distributed over addition. In practice, having
98
98
  * `Negate` factored on multiply/divide is more useful to detect patterns.
99
99
  *
100
- * Note that the `box()` function should only be called from `ce.box()`
100
+ * Note that this function should only be called from `ce.box()`
101
101
  *
102
102
  */
103
103
  export declare function box(ce: IComputeEngine, expr: null | undefined | Decimal | Complex | Rational | SemiBoxedExpression, options?: {
104
- canonical?: boolean | CanonicalForm | CanonicalForm[];
104
+ canonical?: CanonicalOptions;
105
105
  }): BoxedExpression;
@@ -1,7 +1,7 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution, Rule } from '../public';
4
+ import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution, Rule, CanonicalOptions } from './public';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
6
  /**
7
7
  * BoxedDictionary
@@ -14,7 +14,7 @@ export declare class BoxedDictionary extends _BoxedExpression {
14
14
  constructor(ce: IComputeEngine, dict: {
15
15
  [key: string]: SemiBoxedExpression;
16
16
  } | Map<string, BoxedExpression>, options?: {
17
- canonical?: boolean;
17
+ canonical?: CanonicalOptions;
18
18
  metadata?: Metadata;
19
19
  });
20
20
  bind(): void;
@@ -43,6 +43,6 @@ export declare class BoxedDictionary extends _BoxedExpression {
43
43
  N(_options?: NOptions): BoxedExpression;
44
44
  replace(rules: BoxedRuleSet | Rule | Rule[], options?: ReplaceOptions): null | BoxedExpression;
45
45
  subs(sub: Substitution, options?: {
46
- canonical: boolean;
46
+ canonical?: CanonicalOptions;
47
47
  }): BoxedExpression;
48
48
  }
@@ -1,8 +1,9 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions, SemiBoxedExpression } from '../public';
4
+ import { BoxedDomain, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
+ import { BoxedExpression, SemiBoxedExpression } from './public';
6
7
  /**
7
8
  * A `_BoxedDomain` is a wrapper around a boxed, canonical, domain
8
9
  * expression.
@@ -1,4 +1,5 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
+ import { BoxedExpression } from './public';
2
3
  export declare class _BoxedFunctionDefinition implements BoxedFunctionDefinition {
3
4
  engine: IComputeEngine;
4
5
  scope: RuntimeScope;
@@ -1,8 +1,9 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { _BoxedExpression } from './abstract-boxed-expression';
4
4
  import { Expression } from '../../math-json/math-json-format';
5
- import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition, Hold, Rule } from '../public';
5
+ import { BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions, BoxedBaseDefinition, Hold, Rule, CanonicalOptions } from '../public';
6
+ import { BoxedExpression, SemiBoxedExpression } from './public';
6
7
  /**
7
8
  * A boxed function represent an expression that can be
8
9
  * represented by a function call.
@@ -26,7 +27,7 @@ export declare class BoxedFunction extends _BoxedExpression {
26
27
  private _isPure;
27
28
  private _result;
28
29
  private _hash;
29
- constructor(ce: IComputeEngine, head: string | BoxedExpression, ops: BoxedExpression[], options?: {
30
+ constructor(ce: IComputeEngine, head: string | BoxedExpression, ops: ReadonlyArray<BoxedExpression>, options?: {
30
31
  metadata?: Metadata;
31
32
  canonical?: boolean;
32
33
  });
@@ -39,19 +40,17 @@ export declare class BoxedFunction extends _BoxedExpression {
39
40
  set isCanonical(val: boolean);
40
41
  get isPure(): boolean;
41
42
  get json(): Expression;
42
- get rawJson(): Expression;
43
43
  get scope(): RuntimeScope | null;
44
44
  get head(): string | BoxedExpression;
45
- get ops(): BoxedExpression[];
45
+ get ops(): ReadonlyArray<BoxedExpression>;
46
46
  get nops(): number;
47
47
  get op1(): BoxedExpression;
48
48
  get op2(): BoxedExpression;
49
49
  get op3(): BoxedExpression;
50
50
  get isValid(): boolean;
51
51
  get canonical(): BoxedExpression;
52
- map<T = BoxedExpression>(fn: (x: BoxedExpression) => T): IterableIterator<T>;
53
52
  subs(sub: Substitution, options?: {
54
- canonical?: boolean;
53
+ canonical?: CanonicalOptions;
55
54
  }): BoxedExpression;
56
55
  replace(rules: BoxedRuleSet | Rule | Rule[], options?: ReplaceOptions): BoxedExpression | null;
57
56
  has(x: string | string[]): boolean;
@@ -75,9 +74,9 @@ export declare class BoxedFunction extends _BoxedExpression {
75
74
  simplify(options?: SimplifyOptions): BoxedExpression;
76
75
  evaluate(options?: EvaluateOptions): BoxedExpression;
77
76
  N(options?: NOptions): BoxedExpression;
78
- solve(vars: string[]): null | BoxedExpression[];
77
+ solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
79
78
  }
80
- export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops: SemiBoxedExpression[], metadata?: Metadata): BoxedExpression;
79
+ export declare function makeCanonicalFunction(ce: IComputeEngine, head: string | BoxedExpression, ops: ReadonlyArray<SemiBoxedExpression>, metadata?: Metadata): BoxedExpression;
81
80
  /** Apply the function `f` to elements of `xs`, except to the elements
82
81
  * described by `skip`:
83
82
  * - `all`: don't apply f to any elements
@@ -91,4 +90,4 @@ export declare function makeCanonicalFunction(ce: IComputeEngine, head: string |
91
90
  *
92
91
  * If `f` returns `null`, the element is not added to the result
93
92
  */
94
- export declare function holdMap(xs: BoxedExpression[], skip: Hold, associativeHead: string, f: (x: BoxedExpression) => BoxedExpression | null): BoxedExpression[];
93
+ export declare function holdMap(xs: ReadonlyArray<BoxedExpression>, skip: Hold, associativeHead: string, f: (x: BoxedExpression) => BoxedExpression | null): ReadonlyArray<BoxedExpression>;
@@ -1,8 +1,9 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
- import { Expression } from '../../math-json/math-json-format';
4
- import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution, EvaluateOptions, SemiBoxedExpression } from '../public';
3
+ import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, SimplifyOptions, BoxedSubstitution, EvaluateOptions, SemiBoxedExpression } from '../public';
4
+ import { Rational } from '../numerics/rationals';
5
5
  import { _BoxedExpression } from './abstract-boxed-expression';
6
+ import { Expression } from '../../math-json';
6
7
  /**
7
8
  * BoxedNumber
8
9
  *
@@ -30,6 +31,7 @@ export declare class BoxedNumber extends _BoxedExpression {
30
31
  canonical?: boolean;
31
32
  });
32
33
  get hash(): number;
34
+ get json(): Expression;
33
35
  get head(): string;
34
36
  get isPure(): boolean;
35
37
  get isExact(): boolean;
@@ -38,7 +40,6 @@ export declare class BoxedNumber extends _BoxedExpression {
38
40
  get complexity(): number;
39
41
  get numericValue(): number | Decimal | Complex | Rational;
40
42
  get domain(): BoxedDomain;
41
- get json(): Expression;
42
43
  get sgn(): -1 | 0 | 1 | undefined | null;
43
44
  isSame(rhs: BoxedExpression): boolean;
44
45
  isEqual(rhs: BoxedExpression): boolean;
@@ -1,17 +1,4 @@
1
- /* 0.24.1 */
2
- import { BoxedSymbol } from './boxed-symbol';
3
- import Complex from 'complex.js';
4
- import Decimal from 'decimal.js';
1
+ /* 0.25.1 */
2
+ import { BoxedExpression } from './public';
5
3
  export declare function isWildcard(expr: BoxedExpression): expr is BoxedSymbol;
6
4
  export declare function wildcardName(expr: BoxedExpression): string | null;
7
- /**
8
- * The function attempts to match a subject expression to a
9
- * [pattern](/compute-engine/guides/patterns-and-rules/).
10
- *
11
- * If the match is successful, it returns a `Substitution` indicating how to
12
- * transform the pattern to become the subject.
13
- *
14
- * If the expression does not match the pattern, it returns `null`.
15
- *
16
- */
17
- export declare function match(subject: BoxedExpression, pattern: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression | BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -1,6 +1,5 @@
1
- /* 0.24.1 */
2
- import { _BoxedExpression } from './abstract-boxed-expression';
3
- import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution, SemiBoxedExpression } from '../public';
1
+ /* 0.25.1 */
2
+ import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, PatternMatchOptions, BoxedSubstitution, SemiBoxedExpression } from './public';
4
3
  import Complex from 'complex.js';
5
4
  import Decimal from 'decimal.js';
6
5
  /**
@@ -11,8 +10,8 @@ import Decimal from 'decimal.js';
11
10
  export declare class BoxedString extends _BoxedExpression {
12
11
  private readonly _string;
13
12
  constructor(ce: IComputeEngine, expr: string, metadata?: Metadata);
13
+ get json(): string;
14
14
  get hash(): number;
15
- get json(): Expression;
16
15
  get head(): string;
17
16
  get isPure(): boolean;
18
17
  get isCanonical(): boolean;
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * ### THEORY OF OPERATIONS
4
4
  *
@@ -1,8 +1,8 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { _BoxedExpression } from './abstract-boxed-expression';
5
- import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution, Rule, SemiBoxedExpression } from '../public';
5
+ import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution, Rule, SemiBoxedExpression, CanonicalOptions } from './public';
6
6
  /**
7
7
  * BoxedSymbol
8
8
  *
@@ -26,12 +26,12 @@ export declare class BoxedSymbol extends _BoxedExpression {
26
26
  private _def;
27
27
  constructor(ce: IComputeEngine, name: string, options?: {
28
28
  metadata?: Metadata;
29
- canonical?: boolean;
29
+ canonical?: CanonicalOptions;
30
30
  def?: BoxedSymbolDefinition | BoxedFunctionDefinition;
31
31
  });
32
+ get json(): Expression;
32
33
  get hash(): number;
33
34
  get isPure(): boolean;
34
- get json(): Expression;
35
35
  get scope(): RuntimeScope | null;
36
36
  get isConstant(): boolean;
37
37
  /**
@@ -42,11 +42,10 @@ export declare class BoxedSymbol extends _BoxedExpression {
42
42
  get isCanonical(): boolean;
43
43
  set isCanonical(val: boolean);
44
44
  get canonical(): BoxedExpression;
45
- solve(vars: string[]): null | BoxedExpression[];
45
+ solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
46
46
  get complexity(): number;
47
47
  get head(): string;
48
48
  get symbol(): string;
49
- get isNothing(): boolean;
50
49
  get baseDefinition(): BoxedBaseDefinition | undefined;
51
50
  get symbolDefinition(): BoxedSymbolDefinition | undefined;
52
51
  get functionDefinition(): BoxedFunctionDefinition | undefined;
@@ -57,7 +56,7 @@ export declare class BoxedSymbol extends _BoxedExpression {
57
56
  * f(x) => x:integer narrowed from integer to real
58
57
  */
59
58
  infer(domain: BoxedDomain): boolean;
60
- get value(): number | boolean | string | number[] | undefined;
59
+ get value(): number | boolean | string | Object | undefined;
61
60
  set value(value: boolean | string | Decimal | Complex | {
62
61
  re: number;
63
62
  im: number;
@@ -104,7 +103,7 @@ export declare class BoxedSymbol extends _BoxedExpression {
104
103
  N(options?: NOptions): BoxedExpression;
105
104
  replace(rules: BoxedRuleSet | Rule | Rule[], options?: ReplaceOptions): BoxedExpression | null;
106
105
  subs(sub: Substitution, options?: {
107
- canonical: boolean;
106
+ canonical?: CanonicalOptions;
108
107
  }): BoxedExpression;
109
108
  }
110
109
  export declare function makeCanonicalSymbol(ce: IComputeEngine, name: string): BoxedExpression;
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  import Decimal from 'decimal.js';
3
3
  import { Expression } from '../../math-json/math-json-format';
4
4
  import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, SimplifyOptions, Metadata, BoxedDomain, BoxedSubstitution, PatternMatchOptions, BoxedBaseDefinition, BoxedFunctionDefinition, SemiBoxedExpression } from '../public';
@@ -26,10 +26,10 @@ export declare class BoxedTensor extends _BoxedExpression {
26
26
  private _expression;
27
27
  constructor(ce: IComputeEngine, input: {
28
28
  head?: string;
29
- ops: BoxedExpression[];
29
+ ops: ReadonlyArray<BoxedExpression>;
30
30
  } | AbstractTensor<'expression'>, options?: {
31
- canonical?: boolean;
32
31
  metadata?: Metadata;
32
+ canonical?: boolean;
33
33
  });
34
34
  get expression(): BoxedExpression;
35
35
  /** Create the tensor on demand */
@@ -47,7 +47,7 @@ export declare class BoxedTensor extends _BoxedExpression {
47
47
  get complexity(): number;
48
48
  get head(): string;
49
49
  get nops(): number;
50
- get ops(): BoxedExpression[];
50
+ get ops(): ReadonlyArray<BoxedExpression>;
51
51
  get op1(): BoxedExpression;
52
52
  get op2(): BoxedExpression;
53
53
  get op3(): BoxedExpression;
@@ -55,7 +55,6 @@ export declare class BoxedTensor extends _BoxedExpression {
55
55
  get rank(): number;
56
56
  get domain(): BoxedDomain | undefined;
57
57
  get json(): Expression;
58
- get rawJson(): Expression;
59
58
  /** Structural equality */
60
59
  isSame(rhs: BoxedExpression): boolean;
61
60
  /** Mathematical equality */
@@ -66,8 +65,8 @@ export declare class BoxedTensor extends _BoxedExpression {
66
65
  N(options?: NOptions): BoxedExpression;
67
66
  }
68
67
  export declare function isBoxedTensor(val: unknown): val is BoxedTensor;
69
- export declare function expressionTensorInfo(head: string, rows: BoxedExpression[]): {
68
+ export declare function expressionTensorInfo(head: string, rows: ReadonlyArray<BoxedExpression>): {
70
69
  shape: number[];
71
70
  dtype: keyof DataTypeMap;
72
71
  };
73
- export declare function expressionAsTensor<T extends TensorDataType>(head: string, rows: BoxedExpression[]): TensorData<T> | undefined;
72
+ export declare function expressionAsTensor<T extends TensorDataType>(head: string, rows: ReadonlyArray<BoxedExpression>): TensorData<T> | undefined;
@@ -1,2 +1,2 @@
1
- /* 0.24.1 */
2
- export declare function canonicalForm(expr: BoxedExpression, forms: boolean | CanonicalForm | CanonicalForm[]): BoxedExpression;
1
+ /* 0.25.1 */
2
+ export declare function canonicalForm(expr: BoxedExpression, forms: CanonicalOptions): BoxedExpression;
@@ -0,0 +1,56 @@
1
+ /* 0.25.1 */
2
+ *
3
+ * ## THEORY OF OPERATIONS
4
+ *
5
+ * In order to preserve exact results, some numeric operations are performed
6
+ * on "coefficients" which represent a product of a rational number,
7
+ * an algebraic numbers and the square root of an integer.
8
+ *
9
+ * A field is defined on these coefficients.
10
+ *
11
+ *
12
+ */
13
+ import { Rational } from '../numerics/rationals';
14
+ import { BoxedExpression } from './public';
15
+ export interface CoefficientData {
16
+ float: number;
17
+ rational: Rational;
18
+ sqrt: number;
19
+ }
20
+ export declare class Coefficient implements CoefficientData {
21
+ static zero: Coefficient;
22
+ static one: Coefficient;
23
+ /**
24
+ * Attempt to factor a numeric coefficient `c` and a `rest` out of a
25
+ * canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
26
+ *
27
+ * Attempts to make `rest` a positive value (i.e. pulls out negative sign).
28
+ *
29
+ * For example:
30
+ *
31
+ * ['Multiply', 2, 'x', 3, 'a']
32
+ * -> [6, ['Multiply', 'x', 'a']]
33
+ *
34
+ * ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
35
+ * -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
36
+ */
37
+ static fromExpression(expr: BoxedExpression): [coef: Coefficient, rest: BoxedExpression];
38
+ float: number;
39
+ rational: Rational;
40
+ sqrt: number;
41
+ constructor(value?: number | Partial<CoefficientData>);
42
+ asFloat(): number;
43
+ asRational(): Rational;
44
+ normalize(): void;
45
+ get isZero(): boolean;
46
+ get isOne(): boolean;
47
+ get sign(): number;
48
+ neg(): Coefficient;
49
+ inv(): Coefficient;
50
+ mul(other: Partial<CoefficientData> | number | Rational): Coefficient;
51
+ pow(exponent: number): Coefficient;
52
+ div(other: Partial<CoefficientData> | number | Rational): Coefficient;
53
+ add(other: Partial<CoefficientData> | number | Rational): Coefficient;
54
+ sub(other: Partial<CoefficientData> | number | Rational): Coefficient;
55
+ eq(other: Coefficient): boolean;
56
+ }
@@ -1,4 +1,4 @@
1
- /* 0.24.1 */
1
+ /* 0.25.1 */
2
2
  export declare class ExpressionMap<U> implements ExpressionMapInterface<U> {
3
3
  readonly _items: Map<BoxedExpression, U>;
4
4
  constructor(source?: ExpressionMapInterface<U> | readonly (readonly [BoxedExpression, U])[]);
@@ -0,0 +1,11 @@
1
+ /* 0.25.1 */
2
+ import Decimal from 'decimal.js';
3
+ import { Rational } from '../numerics/rationals';
4
+ import { BoxedExpression } from './public';
5
+ export declare function applyCoefficient(value: number | Decimal | Complex | Rational | null, coef: Rational): number | Decimal | Complex | Rational | null;
6
+ /** Combine rational expressions into a single fraction */
7
+ export declare function together(op: BoxedExpression): BoxedExpression;
8
+ /**
9
+ * Return a list of expressions that multiply together to form `expr`.
10
+ */
11
+ export declare function factor(expr: BoxedExpression): BoxedExpression;
@@ -0,0 +1,14 @@
1
+ /* 0.25.1 */
2
+ import Decimal from 'decimal.js';
3
+ import { BoxedSubstitution, PatternMatchOptions, BoxedExpression, SemiBoxedExpression } from './public';
4
+ /**
5
+ * The function attempts to match a subject expression to a
6
+ * [pattern](/compute-engine/guides/patterns-and-rules/).
7
+ *
8
+ * If the match is successful, it returns a `Substitution` indicating how to
9
+ * transform the pattern to become the subject.
10
+ *
11
+ * If the expression does not match the pattern, it returns `null`.
12
+ *
13
+ */
14
+ export declare function match(subject: BoxedExpression, pattern: Decimal | Complex | [num: number, denom: number] | SemiBoxedExpression | BoxedExpression, options?: PatternMatchOptions): BoxedSubstitution | null;
@@ -0,0 +1,41 @@
1
+ /* 0.25.1 */
2
+ import { Rational } from '../numerics/rationals';
3
+ import { BoxedExpression } from './public';
4
+ /**
5
+ * Attempt to factor a numeric coefficient `c` and a `rest` out of a
6
+ * canonical expression `expr` such that `ce.mul(c, rest)` is equal to `expr`.
7
+ *
8
+ * Attempts to make `rest` a positive value (i.e. pulls out negative sign).
9
+ *
10
+ * For example:
11
+ *
12
+ * ['Multiply', 2, 'x', 3, 'a']
13
+ * -> [6, ['Multiply', 'x', 'a']]
14
+ *
15
+ * ['Divide', ['Multiply', 2, 'x'], ['Multiply', 3, 'y', 'a']]
16
+ * -> [['Rational', 2, 3], ['Divide', 'x', ['Multiply, 'y', 'a']]]
17
+ */
18
+ export declare function asCoefficient(expr: BoxedExpression): [coef: Rational, rest: BoxedExpression];
19
+ export declare function asRational(expr: BoxedExpression): Rational | undefined;
20
+ export declare function asApproximateRational(expr: BoxedExpression): Rational | undefined;
21
+ export declare function div(lhs: Rational, rhs: Rational): Rational;
22
+ /**
23
+ * Add a literal numeric value to a rational.
24
+ * If the rational is a bigint, this is a hint to do the calculation in bigint
25
+ * (no need to check `bignumPreferred()`).
26
+ * @param lhs
27
+ * @param rhs
28
+ * @returns
29
+ */
30
+ export declare function add(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
31
+ export declare function mul(lhs: Rational, rhs: BoxedExpression | Rational): Rational;
32
+ export declare function asFloat(expr: BoxedExpression | undefined): number | null;
33
+ export declare function asBignum(expr: BoxedExpression | undefined): Decimal | null;
34
+ export declare function asMachineInteger(expr: BoxedExpression | undefined): number | null;
35
+ /**
36
+ *
37
+ * @param lhs
38
+ * @param rhs
39
+ * @returns the sign (-1, 0, 1) of the difference between `lhs` and `rhs`
40
+ */
41
+ export declare function signDiff(lhs: BoxedExpression, rhs: BoxedExpression, tolerance?: number): -1 | 0 | 1 | undefined;