nerdamer 2.0.0-rc.2 → 2.0.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 (69) hide show
  1. package/README.md +11 -5
  2. package/dist/bundle.js +1 -1
  3. package/dist/bundle.js.LICENSE.txt +6 -6
  4. package/output/algebra/dispatch.js +1 -1
  5. package/output/algebra/partfrac.js +1 -1
  6. package/output/algebra/simplify/funcsimp.js +1 -1
  7. package/output/algebra/simplify/ratsimp.js +1 -1
  8. package/output/algebra/utils.d.ts +1 -1
  9. package/output/algebra/utils.js +3 -3
  10. package/output/api/algebra.d.ts +19 -2
  11. package/output/api/algebra.js +18 -2
  12. package/output/api/assumptions.d.ts +1 -1
  13. package/output/api/assumptions.js +2 -1
  14. package/output/api/core.d.ts +28 -7
  15. package/output/api/core.js +28 -2
  16. package/output/calculus/derivative/diff.js +1 -1
  17. package/output/calculus/dispatch.js +2 -2
  18. package/output/calculus/integrate/integrate.js +4 -4
  19. package/output/calculus/integrate/integrationTable.js +16 -16
  20. package/output/calculus/laplace/ilaplace.js +1 -1
  21. package/output/calculus/laplace/ilaplaceTable.js +18 -17
  22. package/output/calculus/laplace/laplaceTable.js +3 -2
  23. package/output/calculus/limit/limit.js +1 -1
  24. package/output/core/classes/assumption/assume.d.ts +6 -0
  25. package/output/core/classes/assumption/assume.js +9 -0
  26. package/output/core/classes/expression/CoeffObject.d.ts +1 -1
  27. package/output/core/classes/expression/Expression.d.ts +8 -16
  28. package/output/core/classes/expression/Expression.js +11 -33
  29. package/output/core/classes/matrix/Matrix.d.ts +2 -3
  30. package/output/core/classes/matrix/Matrix.js +7 -16
  31. package/output/core/classes/matrix/dispatch.js +1 -1
  32. package/output/core/classes/parser/Parser.d.ts +17 -4
  33. package/output/core/classes/parser/Parser.js +312 -450
  34. package/output/core/classes/parser/operations/functions.d.ts +3 -4
  35. package/output/core/classes/parser/operations/functions.js +35 -97
  36. package/output/core/classes/parser/operations/power.js +2 -2
  37. package/output/core/classes/parser/preprocess.js +14 -7
  38. package/output/core/classes/parser/scripting/controlFlow.js +49 -25
  39. package/output/core/classes/parser/scripting/deferred.d.ts +1 -1
  40. package/output/core/classes/parser/scripting/deferred.js +1 -1
  41. package/output/core/classes/parser/scripting/scope.js +38 -19
  42. package/output/core/classes/parser/types.d.ts +0 -5
  43. package/output/core/classes/parser/wrappers/IndexedReference.d.ts +4 -3
  44. package/output/core/classes/parser/wrappers/IndexedReference.js +8 -0
  45. package/output/core/classes/parser/wrappers/KeyValuePair.d.ts +2 -2
  46. package/output/core/classes/polynomial/Polynomial.js +1 -1
  47. package/output/core/classes/polynomial/SparsePolynomial.d.ts +11 -11
  48. package/output/core/classes/polynomial/SparsePolynomial.js +65 -65
  49. package/output/core/classes/vector/Vector.d.ts +2 -3
  50. package/output/core/classes/vector/Vector.js +6 -14
  51. package/output/core/common/classes/StructuredEntity.d.ts +0 -17
  52. package/output/core/common/classes/StructuredEntity.js +3 -64
  53. package/output/core/converters/BaseConverter.js +2 -1
  54. package/output/core/fullFunctions.js +14 -14
  55. package/output/core/functions/bigint/bigint.d.ts +1 -1
  56. package/output/core/functions/numeric.d.ts +1 -1
  57. package/output/core/parserFunctions.js +10 -10
  58. package/output/index.d.ts +29 -29
  59. package/output/index.js +124 -20
  60. package/output/math/dispatch.js +1 -1
  61. package/output/math/math.js +21 -21
  62. package/output/math/trig.js +4 -4
  63. package/output/solve/solve.js +1 -1
  64. package/package.json +34 -15
  65. package/dist/parser.js +0 -2
  66. package/dist/parser.js.LICENSE.txt +0 -7
  67. package/docs-data/parser-functions.json +0 -2248
  68. package/output/core/classes/parser/operations/comma.d.ts +0 -7
  69. package/output/core/classes/parser/operations/comma.js +0 -11
@@ -18,14 +18,15 @@ export declare class IndexedReference {
18
18
  isEnumerable: boolean;
19
19
  constructor(target: ParserEntity, indices: number[] | string, targetName?: string | undefined);
20
20
  static isIndexedReference(obj: unknown): obj is IndexedReference;
21
- copy(): import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../collection/Collection").Collection | import("../../matrix/Matrix").Matrix | Dictionary | import("../../equation/Equation").Equation;
21
+ copy(): import("../../collection/Collection").Collection | import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../matrix/Matrix").Matrix | import("../../equation/Equation").Equation | Dictionary;
22
22
  eq(other: ParserEntity): boolean;
23
- evaluate(): import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../collection/Collection").Collection | import("../../matrix/Matrix").Matrix | Dictionary | import("../../equation/Equation").Equation;
24
- expand(): import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../collection/Collection").Collection | import("../../matrix/Matrix").Matrix | Dictionary | import("../../equation/Equation").Equation;
23
+ evaluate(): import("../../collection/Collection").Collection | import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../matrix/Matrix").Matrix | import("../../equation/Equation").Equation | Dictionary;
24
+ expand(): import("../../collection/Collection").Collection | import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../matrix/Matrix").Matrix | import("../../equation/Equation").Equation | Dictionary;
25
25
  gt(other: ParserEntity): boolean;
26
26
  gte(other: ParserEntity): boolean;
27
27
  lt(other: ParserEntity): boolean;
28
28
  lte(other: ParserEntity): boolean;
29
29
  resolve(): ParserEntity;
30
+ set(value: ParserEntity): void;
30
31
  text(): string;
31
32
  }
@@ -61,6 +61,14 @@ class IndexedReference {
61
61
  }
62
62
  return this._resolved;
63
63
  }
64
+ set(value) {
65
+ if (typeof this.indices === 'string') {
66
+ this.target.__set__(this.indices, value);
67
+ }
68
+ else {
69
+ this.target.__set__(this.indices, value);
70
+ }
71
+ }
64
72
  text() {
65
73
  return this.resolve().text();
66
74
  }
@@ -14,8 +14,8 @@ export declare class KeyValuePair {
14
14
  static isKeyValuePair(obj: unknown): obj is KeyValuePair;
15
15
  copy(): KeyValuePair;
16
16
  eq(): boolean;
17
- evaluate(): import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../collection/Collection").Collection | import("../../matrix/Matrix").Matrix | import("../../dictionary/Dictionary").Dictionary | import("../../equation/Equation").Equation;
18
- expand(): import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../collection/Collection").Collection | import("../../matrix/Matrix").Matrix | import("../../dictionary/Dictionary").Dictionary | import("../../equation/Equation").Equation;
17
+ evaluate(): import("../../collection/Collection").Collection | import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../matrix/Matrix").Matrix | import("../../equation/Equation").Equation | import("../../dictionary/Dictionary").Dictionary;
18
+ expand(): import("../../collection/Collection").Collection | import("../../expression/Expression").Expression | import("../../vector/Vector").Vector | import("../../valuesSet/ValuesSet").ValuesSet | import("../../matrix/Matrix").Matrix | import("../../equation/Equation").Equation | import("../../dictionary/Dictionary").Dictionary;
19
19
  gt(): boolean;
20
20
  gte(): boolean;
21
21
  lt(): boolean;
@@ -103,7 +103,7 @@ class Polynomial {
103
103
  // Expand the expression but only if needed. This will be needed if the value has a bracket
104
104
  // or if the expression has a power greater than one.
105
105
  let expandedForCoefficients = false;
106
- if (x.value.includes('(') || (x.isSum() && x.getPower().gt('1'))) {
106
+ if (x.value.includes('(') || (x.isSum() && x.getPower().gt((0, shortcuts_1.one)()))) {
107
107
  x = (0, expand_1.expand)(x);
108
108
  expandedForCoefficients = true;
109
109
  }
@@ -161,13 +161,6 @@ export declare class SparsePolynomial {
161
161
  mapCoefficients(mapper: (coefficient: bigint) => bigint): SparsePolynomial;
162
162
  /** Returns the largest absolute coefficient, or zero for the zero polynomial. */
163
163
  maxAbsoluteCoefficient(): bigint;
164
- /**
165
- * Multiplies by another polynomial in the same ring.
166
- *
167
- * Monomial exponents are added as bigints. The constructor combines products
168
- * that land on the same monomial and removes coefficients that cancel to zero.
169
- */
170
- multiply(other: SparsePolynomial): SparsePolynomial;
171
164
  /**
172
165
  * Computes the difference of two monomial-scaled polynomials in one sparse
173
166
  * traversal. This avoids constructing the monomial factors and multiplication
@@ -175,11 +168,12 @@ export declare class SparsePolynomial {
175
168
  */
176
169
  monomialScaleSubtract(leftScalar: bigint, leftMonomialExponents: readonly bigint[], other: SparsePolynomial, rightScalar: bigint, rightMonomialExponents: readonly bigint[]): SparsePolynomial;
177
170
  /**
178
- * Computes a scaled subtraction where the right polynomial is also multiplied
179
- * by one monomial. This avoids constructing the two scaled intermediate
180
- * polynomials used by fraction-free reduction.
171
+ * Multiplies by another polynomial in the same ring.
172
+ *
173
+ * Monomial exponents are added as bigints. The constructor combines products
174
+ * that land on the same monomial and removes coefficients that cancel to zero.
181
175
  */
182
- scaleSubtractMonomial(leftScalar: bigint, other: SparsePolynomial, rightScalar: bigint, monomialExponents: readonly bigint[]): SparsePolynomial;
176
+ multiply(other: SparsePolynomial): SparsePolynomial;
183
177
  /**
184
178
  * Returns the additive inverse of this polynomial.
185
179
  */
@@ -198,6 +192,12 @@ export declare class SparsePolynomial {
198
192
  * Multiplies every coefficient by an exact integer scalar.
199
193
  */
200
194
  scale(scalar: bigint): SparsePolynomial;
195
+ /**
196
+ * Computes a scaled subtraction where the right polynomial is also multiplied
197
+ * by one monomial. This avoids constructing the two scaled intermediate
198
+ * polynomials used by fraction-free reduction.
199
+ */
200
+ scaleSubtractMonomial(leftScalar: bigint, other: SparsePolynomial, rightScalar: bigint, monomialExponents: readonly bigint[]): SparsePolynomial;
201
201
  /**
202
202
  * Subtracts another polynomial in the same ring.
203
203
  */
@@ -573,35 +573,6 @@ class SparsePolynomial {
573
573
  }
574
574
  return maximum;
575
575
  }
576
- /**
577
- * Multiplies by another polynomial in the same ring.
578
- *
579
- * Monomial exponents are added as bigints. The constructor combines products
580
- * that land on the same monomial and removes coefficients that cancel to zero.
581
- */
582
- multiply(other) {
583
- if (this.variableCount !== other.variableCount) {
584
- throw new RangeError((0, errors_1.message)('sparseMultiplicationRingMismatch'));
585
- }
586
- if (this.isZero() || other.isZero()) {
587
- return SparsePolynomial.zero(this.variableCount);
588
- }
589
- const terms = [];
590
- for (const left of this.termsByKey.values()) {
591
- for (const right of other.termsByKey.values()) {
592
- const exponents = new Array(this.variableCount);
593
- for (let variableIndex = 0; variableIndex < this.variableCount; variableIndex++) {
594
- exponents[variableIndex] =
595
- left.exponents[variableIndex] + right.exponents[variableIndex];
596
- }
597
- terms.push({
598
- coefficient: left.coefficient * right.coefficient,
599
- exponents,
600
- });
601
- }
602
- }
603
- return new SparsePolynomial(this.variableCount, terms);
604
- }
605
576
  /**
606
577
  * Computes the difference of two monomial-scaled polynomials in one sparse
607
578
  * traversal. This avoids constructing the monomial factors and multiplication
@@ -641,48 +612,33 @@ class SparsePolynomial {
641
612
  return result;
642
613
  }
643
614
  /**
644
- * Computes a scaled subtraction where the right polynomial is also multiplied
645
- * by one monomial. This avoids constructing the two scaled intermediate
646
- * polynomials used by fraction-free reduction.
615
+ * Multiplies by another polynomial in the same ring.
616
+ *
617
+ * Monomial exponents are added as bigints. The constructor combines products
618
+ * that land on the same monomial and removes coefficients that cancel to zero.
647
619
  */
648
- scaleSubtractMonomial(leftScalar, other, rightScalar, monomialExponents) {
620
+ multiply(other) {
649
621
  if (this.variableCount !== other.variableCount) {
650
- throw new RangeError((0, errors_1.message)('sparseSubtractionRingMismatch'));
651
- }
652
- SparsePolynomial.assertExponents(this.variableCount, monomialExponents);
653
- const result = SparsePolynomial.zero(this.variableCount);
654
- if (leftScalar !== 0n) {
655
- for (const [key, term] of this.termsByKey) {
656
- const coefficient = term.coefficient * leftScalar;
657
- if (coefficient !== 0n) {
658
- result.termsByKey.set(key, Object.freeze({ coefficient, exponents: term.exponents }));
659
- }
660
- }
622
+ throw new RangeError((0, errors_1.message)('sparseMultiplicationRingMismatch'));
661
623
  }
662
- if (rightScalar === 0n) {
663
- return result;
624
+ if (this.isZero() || other.isZero()) {
625
+ return SparsePolynomial.zero(this.variableCount);
664
626
  }
665
- for (const term of other.termsByKey.values()) {
666
- const exponents = new Array(this.variableCount);
667
- for (let variableIndex = 0; variableIndex < this.variableCount; variableIndex++) {
668
- exponents[variableIndex] =
669
- term.exponents[variableIndex] + monomialExponents[variableIndex];
670
- }
671
- const frozenExponents = Object.freeze(exponents);
672
- const key = SparsePolynomial.keyOf(frozenExponents);
673
- const existing = result.termsByKey.get(key);
674
- const coefficient = (existing?.coefficient ?? 0n) - term.coefficient * rightScalar;
675
- if (coefficient === 0n) {
676
- result.termsByKey.delete(key);
677
- }
678
- else {
679
- result.termsByKey.set(key, Object.freeze({
680
- coefficient,
681
- exponents: existing?.exponents ?? frozenExponents,
682
- }));
627
+ const terms = [];
628
+ for (const left of this.termsByKey.values()) {
629
+ for (const right of other.termsByKey.values()) {
630
+ const exponents = new Array(this.variableCount);
631
+ for (let variableIndex = 0; variableIndex < this.variableCount; variableIndex++) {
632
+ exponents[variableIndex] =
633
+ left.exponents[variableIndex] + right.exponents[variableIndex];
634
+ }
635
+ terms.push({
636
+ coefficient: left.coefficient * right.coefficient,
637
+ exponents,
638
+ });
683
639
  }
684
640
  }
685
- return result;
641
+ return new SparsePolynomial(this.variableCount, terms);
686
642
  }
687
643
  /**
688
644
  * Returns the additive inverse of this polynomial.
@@ -749,6 +705,50 @@ class SparsePolynomial {
749
705
  }
750
706
  return result;
751
707
  }
708
+ /**
709
+ * Computes a scaled subtraction where the right polynomial is also multiplied
710
+ * by one monomial. This avoids constructing the two scaled intermediate
711
+ * polynomials used by fraction-free reduction.
712
+ */
713
+ scaleSubtractMonomial(leftScalar, other, rightScalar, monomialExponents) {
714
+ if (this.variableCount !== other.variableCount) {
715
+ throw new RangeError((0, errors_1.message)('sparseSubtractionRingMismatch'));
716
+ }
717
+ SparsePolynomial.assertExponents(this.variableCount, monomialExponents);
718
+ const result = SparsePolynomial.zero(this.variableCount);
719
+ if (leftScalar !== 0n) {
720
+ for (const [key, term] of this.termsByKey) {
721
+ const coefficient = term.coefficient * leftScalar;
722
+ if (coefficient !== 0n) {
723
+ result.termsByKey.set(key, Object.freeze({ coefficient, exponents: term.exponents }));
724
+ }
725
+ }
726
+ }
727
+ if (rightScalar === 0n) {
728
+ return result;
729
+ }
730
+ for (const term of other.termsByKey.values()) {
731
+ const exponents = new Array(this.variableCount);
732
+ for (let variableIndex = 0; variableIndex < this.variableCount; variableIndex++) {
733
+ exponents[variableIndex] =
734
+ term.exponents[variableIndex] + monomialExponents[variableIndex];
735
+ }
736
+ const frozenExponents = Object.freeze(exponents);
737
+ const key = SparsePolynomial.keyOf(frozenExponents);
738
+ const existing = result.termsByKey.get(key);
739
+ const coefficient = (existing?.coefficient ?? 0n) - term.coefficient * rightScalar;
740
+ if (coefficient === 0n) {
741
+ result.termsByKey.delete(key);
742
+ }
743
+ else {
744
+ result.termsByKey.set(key, Object.freeze({
745
+ coefficient,
746
+ exponents: existing?.exponents ?? frozenExponents,
747
+ }));
748
+ }
749
+ }
750
+ return result;
751
+ }
752
752
  /**
753
753
  * Subtracts another polynomial in the same ring.
754
754
  */
@@ -107,9 +107,8 @@ export declare class Vector extends MathematicalAggregate<Vector> {
107
107
  */
108
108
  each(callback: (e: ParserEntity, i: number) => ParserEntity | void): this;
109
109
  eq(V: ParserEntity): boolean;
110
- /** Evaluates a copied Vector, resolving symbolic bracket access when values are supplied. */
111
- evaluate(): Vector;
112
- evaluate(values: ParserValuesObject): ParserEntity;
110
+ /** Evaluates and returns a copied Vector. */
111
+ evaluate(values?: ParserValuesObject): Vector;
113
112
  /** Expands a copied Vector, leaving this one unchanged. */
114
113
  expand(): Vector;
115
114
  /**
@@ -125,7 +125,7 @@ class Vector extends MathematicalAggregate_1.MathematicalAggregate {
125
125
  copy.elements[i] = e.copy();
126
126
  return e;
127
127
  });
128
- return this.copySymbolicAccessTo(copy);
128
+ return copy;
129
129
  }
130
130
  /**
131
131
  * Gets the number of current elements in the Vector.
@@ -222,18 +222,11 @@ class Vector extends MathematicalAggregate_1.MathematicalAggregate {
222
222
  }
223
223
  return true;
224
224
  }
225
+ /** Evaluates and returns a copied Vector. */
225
226
  evaluate(values) {
226
- let retval;
227
- const symbolicAccess = Expression_1.Expression.fromSymbolicAccess(this);
228
- if (symbolicAccess && values) {
229
- retval = symbolicAccess.evaluate(values);
230
- }
231
- else {
232
- const copy = this.copy();
233
- copy.each(e => (Expression_1.Expression.isExpression(e) ? e.evaluate(values) : e.evaluate()));
234
- retval = copy;
235
- }
236
- return retval;
227
+ const copy = this.copy();
228
+ copy.each(e => (Expression_1.Expression.isExpression(e) ? e.evaluate(values) : e.evaluate()));
229
+ return copy;
237
230
  }
238
231
  /** Expands a copied Vector, leaving this one unchanged. */
239
232
  expand() {
@@ -440,8 +433,7 @@ class Vector extends MathematicalAggregate_1.MathematicalAggregate {
440
433
  return retval;
441
434
  }
442
435
  text() {
443
- const text = `[${this.elements.map(e => e.text()).join(', ')}]`;
444
- return this.formatSymbolicAccess(text);
436
+ return `[${this.elements.map(e => e.text()).join(', ')}]`;
445
437
  }
446
438
  /**
447
439
  * Multiplies corresponding Vector elements, broadcasts a scalar factor, or
@@ -1,4 +1,3 @@
1
- import type { Expression } from '../../classes/expression/Expression';
2
1
  import type { ParserEntity } from '../../types';
3
2
  import type { NerdamerInput } from '../../types';
4
3
  /**
@@ -14,17 +13,6 @@ export declare abstract class StructuredEntity<T extends StructuredEntity<T, TPr
14
13
  abstract elements: ParserEntity[] | ParserEntity[][];
15
14
  abstract isEnumerable: boolean;
16
15
  abstract precision?: number;
17
- /**
18
- * Public index expressions retained when bracket access cannot yet be resolved.
19
- * This state belongs to a copied structured entity, never the stored source value.
20
- */
21
- symbolicAccessor?: Expression[];
22
- /** Original symbolic target used to render and later re-evaluate bracket access. */
23
- symbolicTarget?: Expression;
24
- /** Copies symbolic access metadata alongside a concrete structured copy. */
25
- protected copySymbolicAccessTo(copy: T): T;
26
- /** Renders symbolic access without exposing the carrier's concrete contents. */
27
- protected formatSymbolicAccess(baseText: string): string;
28
16
  private binaryOp;
29
17
  abstract __get__(indices: number[] | string): ParserEntity;
30
18
  abstract __set__(indices: number[] | string, value: ParserEntity): void;
@@ -47,9 +35,4 @@ export declare abstract class StructuredEntity<T extends StructuredEntity<T, TPr
47
35
  abstract text(): string;
48
36
  times(x: NerdamerInput): T | TProduct;
49
37
  toString(): string;
50
- /**
51
- * Returns a copied structured entity carrying an unresolved bracket access.
52
- * Existing accessor state is retained so chained symbolic access can be extended.
53
- */
54
- withSymbolicAccessor(target: Expression, indices: Expression[]): T;
55
38
  }
@@ -37,29 +37,9 @@ function getAggregateElement(agg, i, j) {
37
37
  return row;
38
38
  }
39
39
  function applyBinaryOp(op, lhs, rhs) {
40
- switch (op) {
41
- case 'plus': {
42
- const target = lhs;
43
- return target.plus(rhs);
44
- }
45
- case 'minus': {
46
- const target = lhs;
47
- return target.minus(rhs);
48
- }
49
- case 'times': {
50
- const target = lhs;
51
- return target.times(rhs);
52
- }
53
- case 'div': {
54
- const target = lhs;
55
- return target.div(rhs);
56
- }
57
- case 'pow': {
58
- const target = lhs;
59
- // Preserve the historical dynamic failure if an Equation reaches element-wise power.
60
- return target.pow(rhs);
61
- }
62
- }
40
+ const target = lhs;
41
+ const operation = target[op];
42
+ return operation.call(target, rhs);
63
43
  }
64
44
  /**
65
45
  * Abstract base class for Vector, Matrix, and Collection classes.
@@ -70,32 +50,6 @@ function applyBinaryOp(op, lhs, rhs) {
70
50
  * so their inherited multiplication continues to return `T` exactly.
71
51
  */
72
52
  class StructuredEntity {
73
- /**
74
- * Public index expressions retained when bracket access cannot yet be resolved.
75
- * This state belongs to a copied structured entity, never the stored source value.
76
- */
77
- symbolicAccessor;
78
- /** Original symbolic target used to render and later re-evaluate bracket access. */
79
- symbolicTarget;
80
- /** Copies symbolic access metadata alongside a concrete structured copy. */
81
- copySymbolicAccessTo(copy) {
82
- if (this.symbolicTarget) {
83
- copy.symbolicTarget = this.symbolicTarget.copy();
84
- }
85
- if (this.symbolicAccessor) {
86
- copy.symbolicAccessor = this.symbolicAccessor.map(index => index.copy());
87
- }
88
- return copy;
89
- }
90
- /** Renders symbolic access without exposing the carrier's concrete contents. */
91
- formatSymbolicAccess(baseText) {
92
- let retval = baseText;
93
- if (this.symbolicAccessor && this.symbolicAccessor.length > 0) {
94
- const target = this.symbolicTarget ? this.symbolicTarget.text() : baseText;
95
- retval = `${target}[${this.symbolicAccessor.map(index => index.text()).join(', ')}]`;
96
- }
97
- return retval;
98
- }
99
53
  binaryOp(op, x) {
100
54
  const rhsAgg = isEnumerableLike(x) && x.dataType === this.dataType ? x : undefined;
101
55
  return this.copy().each((e, i, j) => {
@@ -132,20 +86,5 @@ class StructuredEntity {
132
86
  toString() {
133
87
  return this.text();
134
88
  }
135
- /**
136
- * Returns a copied structured entity carrying an unresolved bracket access.
137
- * Existing accessor state is retained so chained symbolic access can be extended.
138
- */
139
- withSymbolicAccessor(target, indices) {
140
- const retval = this.copy();
141
- if (!retval.symbolicTarget) {
142
- retval.symbolicTarget = target.copy();
143
- }
144
- retval.symbolicAccessor = [
145
- ...(retval.symbolicAccessor ?? []),
146
- ...indices.map(index => index.copy()),
147
- ];
148
- return retval;
149
- }
150
89
  }
151
90
  exports.StructuredEntity = StructuredEntity;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BaseConverter = void 0;
4
4
  const Expression_1 = require("../classes/expression/Expression");
5
+ const shortcuts_1 = require("../classes/expression/shortcuts");
5
6
  const constants_1 = require("../classes/parser/constants");
6
7
  const errors_1 = require("../errors");
7
8
  const modes = {
@@ -247,7 +248,7 @@ class BaseConverter {
247
248
  // Preserve them verbatim instead of trying to move them into the denominator.
248
249
  const isComplexPower = pExpr.isComplex();
249
250
  const power = isComplexPower ? pExpr : pExpr.signFree();
250
- const isInverted = !isComplexPower && (pExpr.lt(0) || pExpr.sign() === -1);
251
+ const isInverted = !isComplexPower && (pExpr.lt((0, shortcuts_1.zero)()) || pExpr.sign() === -1);
251
252
  const isNegative = input.getMultiplier().isNegative();
252
253
  const m = input.getMultiplier().abs();
253
254
  const multiplierArray = ['', ''];
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.registerNerdamerFunctions = registerNerdamerFunctions;
4
4
  const dispatch_1 = require("../algebra/dispatch");
5
5
  const dispatch_2 = require("../calculus/dispatch");
6
- const dispatch_3 = require("./classes/assumption/dispatch");
7
- const dispatch_4 = require("./classes/matrix/dispatch");
8
- const dispatch_5 = require("./classes/polynomial/dispatch");
9
- const dispatch_6 = require("./classes/parser/scripting/dispatch");
10
- const dispatch_7 = require("./classes/vector/dispatch");
6
+ const dispatch_3 = require("../math/dispatch");
7
+ const dispatch_4 = require("../solve/dispatch");
8
+ const dispatch_5 = require("./classes/assumption/dispatch");
9
+ const dispatch_6 = require("./classes/matrix/dispatch");
10
+ const dispatch_7 = require("./classes/parser/scripting/dispatch");
11
+ const dispatch_8 = require("./classes/polynomial/dispatch");
12
+ const dispatch_9 = require("./classes/vector/dispatch");
11
13
  const complex_dispatch_1 = require("./functions/complex.dispatch");
12
- const dispatch_8 = require("../math/dispatch");
13
- const dispatch_9 = require("../solve/dispatch");
14
14
  /**
15
15
  * Registers the complete Nerdamer parser function surface.
16
16
  *
@@ -18,14 +18,14 @@ const dispatch_9 = require("../solve/dispatch");
18
18
  * and consumers that require the complete Nerdamer notation surface call this registration function.
19
19
  */
20
20
  function registerNerdamerFunctions() {
21
- (0, dispatch_6.loadScriptingFunctions)();
22
- (0, dispatch_3.loadAssumptionFunctions)();
23
- (0, dispatch_4.loadMatrixFunctions)();
24
- (0, dispatch_7.loadVectorFunctions)();
21
+ (0, dispatch_7.loadScriptingFunctions)();
22
+ (0, dispatch_5.loadAssumptionFunctions)();
23
+ (0, dispatch_6.loadMatrixFunctions)();
24
+ (0, dispatch_9.loadVectorFunctions)();
25
25
  (0, complex_dispatch_1.loadComplexFunctions)();
26
- (0, dispatch_5.loadPolynomialFunctions)();
27
- (0, dispatch_8.loadMathFunctions)();
26
+ (0, dispatch_8.loadPolynomialFunctions)();
27
+ (0, dispatch_3.loadMathFunctions)();
28
28
  (0, dispatch_1.loadAlgebraFunctions)();
29
29
  (0, dispatch_2.loadCalculusFunctions)();
30
- (0, dispatch_9.loadSolveFunctions)();
30
+ (0, dispatch_4.loadSolveFunctions)();
31
31
  }
@@ -45,7 +45,7 @@ export declare function convert(numStr: string): [bigint, bigint];
45
45
  * @param n
46
46
  * @returns -1 if negative and 1 for positive and 0 for zero
47
47
  */
48
- export declare function sign(n: bigint): 0 | 1 | -1;
48
+ export declare function sign(n: bigint): 1 | 0 | -1;
49
49
  /**
50
50
  * Checks if a bigint is an even number
51
51
  *
@@ -65,7 +65,7 @@ export declare function LCM(...args: number[]): number;
65
65
  /** Computes the modular multiplicative inverse for integer JavaScript numbers. */
66
66
  export declare function modInv(a: number, p: number): number;
67
67
  /** Returns `1` for a prime safe integer and `0` otherwise. */
68
- export declare function isPrime(x: number): 0 | 1;
68
+ export declare function isPrime(x: number): 1 | 0;
69
69
  /** Numeric half-maximum convention for the Heaviside step function. */
70
70
  export declare function heaviside(x: number): number;
71
71
  /**
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadParserFunctions = loadParserFunctions;
4
- const dispatch_1 = require("./classes/assumption/dispatch");
5
- const dispatch_2 = require("./classes/matrix/dispatch");
6
- const dispatch_3 = require("./classes/polynomial/dispatch");
4
+ const dispatch_1 = require("../math/dispatch");
5
+ const dispatch_2 = require("./classes/assumption/dispatch");
6
+ const dispatch_3 = require("./classes/matrix/dispatch");
7
7
  const dispatch_4 = require("./classes/parser/scripting/dispatch");
8
- const dispatch_5 = require("./classes/vector/dispatch");
8
+ const dispatch_5 = require("./classes/polynomial/dispatch");
9
+ const dispatch_6 = require("./classes/vector/dispatch");
9
10
  const complex_dispatch_1 = require("./functions/complex.dispatch");
10
- const dispatch_6 = require("../math/dispatch");
11
11
  /**
12
12
  * Registers the function surface supplied by the parser package.
13
13
  *
@@ -16,10 +16,10 @@ const dispatch_6 = require("../math/dispatch");
16
16
  */
17
17
  function loadParserFunctions() {
18
18
  (0, dispatch_4.loadScriptingFunctions)();
19
- (0, dispatch_1.loadAssumptionFunctions)();
20
- (0, dispatch_2.loadMatrixFunctions)();
21
- (0, dispatch_5.loadVectorFunctions)();
22
- (0, dispatch_3.loadPolynomialFunctions)();
19
+ (0, dispatch_2.loadAssumptionFunctions)();
20
+ (0, dispatch_3.loadMatrixFunctions)();
21
+ (0, dispatch_6.loadVectorFunctions)();
22
+ (0, dispatch_5.loadPolynomialFunctions)();
23
23
  (0, complex_dispatch_1.loadComplexFunctions)();
24
- (0, dispatch_6.loadMathFunctions)();
24
+ (0, dispatch_1.loadMathFunctions)();
25
25
  }