@danielsimonjr/mathts-core 0.14.3 → 0.15.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 (89) hide show
  1. package/dist/arithmetic/scalar.d.ts +56 -0
  2. package/dist/arithmetic/scalar.d.ts.map +1 -0
  3. package/dist/array.d.ts +253 -0
  4. package/dist/array.d.ts.map +1 -0
  5. package/dist/bignumber-formatter.d.ts +135 -0
  6. package/dist/bignumber-formatter.d.ts.map +1 -0
  7. package/dist/collection.d.ts +67 -0
  8. package/dist/collection.d.ts.map +1 -0
  9. package/dist/config.d.ts +17 -0
  10. package/dist/config.d.ts.map +1 -0
  11. package/dist/constants.d.ts +30 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/customs.d.ts +44 -0
  14. package/dist/customs.d.ts.map +1 -0
  15. package/dist/error/DimensionError.d.ts +26 -0
  16. package/dist/error/DimensionError.d.ts.map +1 -0
  17. package/dist/error/IndexError.d.ts +33 -0
  18. package/dist/error/IndexError.d.ts.map +1 -0
  19. package/dist/error/MathjsError.d.ts +13 -0
  20. package/dist/error/MathjsError.d.ts.map +1 -0
  21. package/dist/factory/factory.d.ts +154 -0
  22. package/dist/factory/factory.d.ts.map +1 -0
  23. package/dist/factory/index.d.ts +6 -0
  24. package/dist/factory/index.d.ts.map +1 -0
  25. package/dist/factory.d.ts +112 -0
  26. package/dist/factory.d.ts.map +1 -0
  27. package/dist/index.d.ts +24 -2593
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +22 -13
  30. package/dist/internal.d.ts +33 -1344
  31. package/dist/internal.d.ts.map +1 -0
  32. package/dist/is.d.ts +102 -0
  33. package/dist/is.d.ts.map +1 -0
  34. package/dist/map.d.ts +113 -0
  35. package/dist/map.d.ts.map +1 -0
  36. package/dist/number.d.ts +314 -0
  37. package/dist/number.d.ts.map +1 -0
  38. package/dist/numeric/stable.d.ts +130 -0
  39. package/dist/numeric/stable.d.ts.map +1 -0
  40. package/dist/object.d.ts +119 -0
  41. package/dist/object.d.ts.map +1 -0
  42. package/dist/shared.d.ts +41 -0
  43. package/dist/shared.d.ts.map +1 -0
  44. package/dist/string.d.ts +70 -0
  45. package/dist/string.d.ts.map +1 -0
  46. package/dist/switch.d.ts +9 -0
  47. package/dist/switch.d.ts.map +1 -0
  48. package/dist/typed/index.d.ts +7 -0
  49. package/dist/typed/index.d.ts.map +1 -0
  50. package/dist/typed/mathts-typed.d.ts +246 -0
  51. package/dist/typed/mathts-typed.d.ts.map +1 -0
  52. package/dist/typed/type-bridge.d.ts +2 -0
  53. package/dist/typed/type-bridge.d.ts.map +1 -0
  54. package/dist/types/bignumber.d.ts +367 -0
  55. package/dist/types/bignumber.d.ts.map +1 -0
  56. package/dist/types/complex.d.ts +284 -0
  57. package/dist/types/complex.d.ts.map +1 -0
  58. package/dist/types/dual-rules.d.ts +129 -0
  59. package/dist/types/dual-rules.d.ts.map +1 -0
  60. package/dist/types/dual.d.ts +36 -0
  61. package/dist/types/dual.d.ts.map +1 -0
  62. package/dist/types/fraction.d.ts +215 -0
  63. package/dist/types/fraction.d.ts.map +1 -0
  64. package/dist/types/interfaces.d.ts +143 -0
  65. package/dist/types/interfaces.d.ts.map +1 -0
  66. package/dist/types/matrix/Range.d.ts +767 -0
  67. package/dist/types/matrix/Range.d.ts.map +1 -0
  68. package/dist/types/unit/Unit.d.ts +3 -0
  69. package/dist/types/unit/Unit.d.ts.map +1 -0
  70. package/dist/types/unit/dependencies.d.ts +4 -0
  71. package/dist/types/unit/dependencies.d.ts.map +1 -0
  72. package/dist/types/unit/errors.d.ts +18 -0
  73. package/dist/types/unit/errors.d.ts.map +1 -0
  74. package/dist/types/unit/index.d.ts +7 -0
  75. package/dist/types/unit/index.d.ts.map +1 -0
  76. package/dist/types/unit/unit-types.d.ts +231 -0
  77. package/dist/types/unit/unit-types.d.ts.map +1 -0
  78. package/dist/types/unit-definitions.d.ts +79 -0
  79. package/dist/types/unit-definitions.d.ts.map +1 -0
  80. package/dist/types/unit-prefixes.d.ts +29 -0
  81. package/dist/types/unit-prefixes.d.ts.map +1 -0
  82. package/dist/types/unit.d.ts +28 -0
  83. package/dist/types/unit.d.ts.map +1 -0
  84. package/dist/types/wasm-loader.d.ts +35 -0
  85. package/dist/types/wasm-loader.d.ts.map +1 -0
  86. package/dist/wasm-loader.d.ts +97 -0
  87. package/dist/wasm-loader.d.ts.map +1 -0
  88. package/package.json +8 -8
  89. package/dist/index-B4LIOfHN.d.ts +0 -449
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Canonical elementary-function derivative rules for forward-mode automatic
3
+ * differentiation. This is the single source of truth for the chain rules,
4
+ * shared by the scalar {@link Dual} (core) and the tensor `DualTensor`
5
+ * (autograd) so neither reinvents them.
6
+ *
7
+ * Each rule is a pair of pure `number → number` functions:
8
+ * - `primal(x)` — f(x)
9
+ * - `deriv(x, y)` — f′(x), given both x and the already-computed y = f(x),
10
+ * so output-reusing derivatives (exp, tanh, sqrt, cbrt, expm1) stay cheap.
11
+ *
12
+ * Keeping these as plain scalar functions (no `Dual`/`Tensor` allocation) is
13
+ * what lets autograd's `Float64Array` element-wise loop stay allocation-free.
14
+ * It is also the propagation path: a future accelerated `primal` in the
15
+ * standard layer (WASM/SIMD batch kernels) can be swapped in here and every
16
+ * consumer inherits the speedup without touching this contract.
17
+ */
18
+ /** A forward-mode derivative rule for a unary elementary function. */
19
+ export interface DualUnaryRule {
20
+ /** f(x). */
21
+ readonly primal: (x: number) => number;
22
+ /** f′(x), given x and y = f(x) (y lets exp/tanh/sqrt/… avoid recomputation). */
23
+ readonly deriv: (x: number, y: number) => number;
24
+ }
25
+ /**
26
+ * The canonical table. Derivatives are stated in the cheapest exact form
27
+ * (reusing y where that avoids a redundant transcendental call).
28
+ */
29
+ export declare const DUAL_UNARY_RULES: {
30
+ exp: {
31
+ primal: (x: number) => number;
32
+ deriv: (_x: number, y: number) => number;
33
+ };
34
+ expm1: {
35
+ primal: (x: number) => number;
36
+ deriv: (_x: number, y: number) => number;
37
+ };
38
+ log: {
39
+ primal: (x: number) => number;
40
+ deriv: (x: number) => number;
41
+ };
42
+ log2: {
43
+ primal: (x: number) => number;
44
+ deriv: (x: number) => number;
45
+ };
46
+ log10: {
47
+ primal: (x: number) => number;
48
+ deriv: (x: number) => number;
49
+ };
50
+ log1p: {
51
+ primal: (x: number) => number;
52
+ deriv: (x: number) => number;
53
+ };
54
+ sin: {
55
+ primal: (x: number) => number;
56
+ deriv: (x: number) => number;
57
+ };
58
+ cos: {
59
+ primal: (x: number) => number;
60
+ deriv: (x: number) => number;
61
+ };
62
+ tan: {
63
+ primal: (x: number) => number;
64
+ deriv: (x: number) => number;
65
+ };
66
+ asin: {
67
+ primal: (x: number) => number;
68
+ deriv: (x: number) => number;
69
+ };
70
+ acos: {
71
+ primal: (x: number) => number;
72
+ deriv: (x: number) => number;
73
+ };
74
+ atan: {
75
+ primal: (x: number) => number;
76
+ deriv: (x: number) => number;
77
+ };
78
+ sinh: {
79
+ primal: (x: number) => number;
80
+ deriv: (x: number) => number;
81
+ };
82
+ cosh: {
83
+ primal: (x: number) => number;
84
+ deriv: (x: number) => number;
85
+ };
86
+ tanh: {
87
+ primal: (x: number) => number;
88
+ deriv: (_x: number, y: number) => number;
89
+ };
90
+ asinh: {
91
+ primal: (x: number) => number;
92
+ deriv: (x: number) => number;
93
+ };
94
+ acosh: {
95
+ primal: (x: number) => number;
96
+ deriv: (x: number) => number;
97
+ };
98
+ atanh: {
99
+ primal: (x: number) => number;
100
+ deriv: (x: number) => number;
101
+ };
102
+ sqrt: {
103
+ primal: (x: number) => number;
104
+ deriv: (_x: number, y: number) => number;
105
+ };
106
+ cbrt: {
107
+ primal: (x: number) => number;
108
+ deriv: (_x: number, y: number) => number;
109
+ };
110
+ square: {
111
+ primal: (x: number) => number;
112
+ deriv: (x: number) => number;
113
+ };
114
+ reciprocal: {
115
+ primal: (x: number) => number;
116
+ deriv: (x: number) => number;
117
+ };
118
+ abs: {
119
+ primal: (x: number) => number;
120
+ deriv: (x: number) => number;
121
+ };
122
+ sign: {
123
+ primal: (x: number) => number;
124
+ deriv: () => number;
125
+ };
126
+ };
127
+ /** Name of a rule in {@link DUAL_UNARY_RULES}. */
128
+ export type DualUnaryRuleName = keyof typeof DUAL_UNARY_RULES;
129
+ //# sourceMappingURL=dual-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dual-rules.d.ts","sourceRoot":"","sources":["../../src/types/dual-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sEAAsE;AACtE,MAAM,WAAW,aAAa;IAC5B,YAAY;IACZ,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAClD;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwBnB,MAAM;QAAa,KAAK;;CACO,CAAC;AAE1C,kDAAkD;AAClD,MAAM,MAAM,iBAAiB,GAAG,MAAM,OAAO,gBAAgB,CAAC"}
@@ -0,0 +1,36 @@
1
+ export declare class Dual {
2
+ /** Function value (the real part). */
3
+ readonly value: number;
4
+ /** First derivative (the ε coefficient). */
5
+ readonly deriv: number;
6
+ constructor(value: number, deriv?: number);
7
+ /** A constant (derivative 0). */
8
+ static constant(v: number): Dual;
9
+ /** A seed variable (derivative 1) — the point of differentiation. */
10
+ static variable(v: number): Dual;
11
+ add(o: Dual): Dual;
12
+ sub(o: Dual): Dual;
13
+ mul(o: Dual): Dual;
14
+ div(o: Dual): Dual;
15
+ neg(): Dual;
16
+ /** Power with a constant real exponent: d(xᵏ) = k·xᵏ⁻¹·dx. */
17
+ powConst(k: number): Dual;
18
+ /** General power a^b: d = a^b·(b'·ln a + b·a'/a). */
19
+ pow(o: Dual): Dual;
20
+ private unary;
21
+ sin(): Dual;
22
+ cos(): Dual;
23
+ tan(): Dual;
24
+ exp(): Dual;
25
+ log(): Dual;
26
+ sqrt(): Dual;
27
+ square(): Dual;
28
+ abs(): Dual;
29
+ sinh(): Dual;
30
+ cosh(): Dual;
31
+ tanh(): Dual;
32
+ toString(): string;
33
+ }
34
+ /** Type guard for {@link Dual}. */
35
+ export declare function isDual(x: unknown): x is Dual;
36
+ //# sourceMappingURL=dual.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dual.d.ts","sourceRoot":"","sources":["../../src/types/dual.ts"],"names":[],"mappings":"AAkBA,qBAAa,IAAI;IACf,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,YAAY,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,EAGnC;IAED,iCAAiC;IACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAE/B;IAED,qEAAqE;IACrE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAE/B;IAGD,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAEjB;IACD,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAEjB;IACD,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAEjB;IACD,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAGjB;IACD,GAAG,IAAI,IAAI,CAEV;IACD,8DAA8D;IAC9D,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAExB;IACD,qDAAqD;IACrD,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,CAIjB;IAMD,OAAO,CAAC,KAAK;IAIb,GAAG,IAAI,IAAI,CAEV;IACD,GAAG,IAAI,IAAI,CAEV;IACD,GAAG,IAAI,IAAI,CAEV;IACD,GAAG,IAAI,IAAI,CAEV;IACD,GAAG,IAAI,IAAI,CAEV;IACD,IAAI,IAAI,IAAI,CAEX;IACD,MAAM,IAAI,IAAI,CAEb;IACD,GAAG,IAAI,IAAI,CAEV;IACD,IAAI,IAAI,IAAI,CAEX;IACD,IAAI,IAAI,IAAI,CAEX;IACD,IAAI,IAAI,IAAI,CAEX;IAED,QAAQ,IAAI,MAAM,CAEjB;CACF;AAED,mCAAmC;AACnC,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,IAAI,CAE5C"}
@@ -0,0 +1,215 @@
1
+ /**
2
+ * Fraction (rational number) implementation
3
+ * @module @danielsimonjr/mathts-core/types/fraction
4
+ */
5
+ import type { Scalar, IFraction } from './interfaces';
6
+ /**
7
+ * Check if a value is a Fraction
8
+ */
9
+ export declare function isFraction(value: unknown): value is Fraction;
10
+ /**
11
+ * Fraction class for exact rational arithmetic
12
+ * Uses bigint for arbitrary precision numerator and denominator.
13
+ * All fractions are automatically reduced to lowest terms.
14
+ */
15
+ export declare class Fraction implements IFraction {
16
+ readonly type = "Fraction";
17
+ readonly numerator: bigint;
18
+ readonly denominator: bigint;
19
+ constructor(numerator: bigint | number | string | Fraction, denominator?: bigint | number | string | Fraction);
20
+ /**
21
+ * Create a Fraction from a number (with optional precision)
22
+ */
23
+ static fromNumber(n: number, maxDenominator?: bigint): Fraction;
24
+ /**
25
+ * Create a Fraction from a decimal string
26
+ */
27
+ static fromDecimalString(str: string): Fraction;
28
+ /**
29
+ * Parse a fraction from a string
30
+ * Supports formats: "3/4", "-3/4", "3", "3.14", "0.(3)"
31
+ */
32
+ static parse(str: string): Fraction;
33
+ /**
34
+ * Create a Fraction from a JSON object
35
+ */
36
+ static fromJSON(json: {
37
+ n: string;
38
+ d: string;
39
+ } | {
40
+ numerator: string;
41
+ denominator: string;
42
+ }): Fraction;
43
+ /**
44
+ * Compare two fractions
45
+ * @returns -1, 0, or 1
46
+ */
47
+ static compare(a: Fraction, b: Fraction): number;
48
+ valueOf(): number;
49
+ toString(): string;
50
+ toJSON(): {
51
+ mathjs: string;
52
+ n: string;
53
+ d: string;
54
+ };
55
+ /**
56
+ * Convert to number
57
+ */
58
+ toNumber(): number;
59
+ /**
60
+ * Convert to decimal string with specified precision
61
+ */
62
+ toDecimal(precision?: number): string;
63
+ /**
64
+ * Convert to LaTeX string
65
+ */
66
+ toLatex(): string;
67
+ /**
68
+ * Convert to mixed number representation
69
+ */
70
+ toMixed(): {
71
+ whole: bigint;
72
+ numerator: bigint;
73
+ denominator: bigint;
74
+ };
75
+ /**
76
+ * Addition: a/b + c/d = (ad + bc) / bd
77
+ */
78
+ add(other: Scalar): Fraction;
79
+ /**
80
+ * Subtraction: a/b - c/d = (ad - bc) / bd
81
+ */
82
+ subtract(other: Scalar): Fraction;
83
+ /**
84
+ * Multiplication: a/b * c/d = ac / bd
85
+ */
86
+ multiply(other: Scalar): Fraction;
87
+ /**
88
+ * Division: a/b ÷ c/d = ad / bc
89
+ */
90
+ divide(other: Scalar): Fraction;
91
+ mul(other: Scalar): Fraction;
92
+ sub(other: Scalar): Fraction;
93
+ div(other: Scalar): Fraction;
94
+ /**
95
+ * Negation: -(a/b) = -a/b
96
+ */
97
+ negate(): Fraction;
98
+ /**
99
+ * Absolute value: |a/b|
100
+ */
101
+ abs(): Fraction;
102
+ /**
103
+ * Reciprocal: b/a
104
+ */
105
+ inverse(): Fraction;
106
+ /**
107
+ * Power (integer exponent)
108
+ */
109
+ pow(n: number | bigint): Fraction;
110
+ /**
111
+ * Modulo operation
112
+ */
113
+ mod(other: Fraction): Fraction;
114
+ /**
115
+ * Check equality
116
+ */
117
+ equals(other: Fraction): boolean;
118
+ /**
119
+ * Check if less than
120
+ */
121
+ lessThan(other: Fraction): boolean;
122
+ /**
123
+ * Check if less than or equal
124
+ */
125
+ lessThanOrEqual(other: Fraction): boolean;
126
+ /**
127
+ * Check if greater than
128
+ */
129
+ greaterThan(other: Fraction): boolean;
130
+ /**
131
+ * Check if greater than or equal
132
+ */
133
+ greaterThanOrEqual(other: Fraction): boolean;
134
+ /**
135
+ * Compare with another fraction
136
+ * @returns -1, 0, or 1
137
+ */
138
+ compareTo(other: Fraction): number;
139
+ compare(other: Fraction): number;
140
+ /**
141
+ * Return fraction already in lowest terms (no-op since constructor reduces)
142
+ */
143
+ simplify(): Fraction;
144
+ /**
145
+ * Check if this is zero
146
+ */
147
+ isZero(): boolean;
148
+ /**
149
+ * Check if this is positive
150
+ */
151
+ isPositive(): boolean;
152
+ /**
153
+ * Check if this is negative
154
+ */
155
+ isNegative(): boolean;
156
+ /**
157
+ * Check if this is an integer
158
+ */
159
+ isInteger(): boolean;
160
+ /**
161
+ * Check if this is a unit fraction (1/n)
162
+ */
163
+ isUnit(): boolean;
164
+ /**
165
+ * Floor: largest integer ≤ this
166
+ */
167
+ floor(): Fraction;
168
+ /**
169
+ * Ceiling: smallest integer ≥ this
170
+ */
171
+ ceil(): Fraction;
172
+ /**
173
+ * Round to nearest integer
174
+ */
175
+ round(): Fraction;
176
+ /**
177
+ * Truncate (round toward zero)
178
+ */
179
+ trunc(): Fraction;
180
+ /**
181
+ * Get the sign: -1, 0, or 1
182
+ */
183
+ sign(): number;
184
+ /**
185
+ * Clone this fraction
186
+ */
187
+ clone(): Fraction;
188
+ /**
189
+ * Get the GCD of numerator and denominator (always 1 since we reduce)
190
+ */
191
+ gcd(): bigint;
192
+ /**
193
+ * Get continued fraction representation
194
+ */
195
+ toContinuedFraction(): bigint[];
196
+ /**
197
+ * Create fraction from continued fraction
198
+ */
199
+ static fromContinuedFraction(cf: bigint[]): Fraction;
200
+ /**
201
+ * Mediant of two fractions: (a+c)/(b+d)
202
+ * Used in Stern-Brocot tree and Farey sequences
203
+ */
204
+ mediant(other: Fraction): Fraction;
205
+ }
206
+ /**
207
+ * Common fraction constants
208
+ */
209
+ export declare const FRACTION_ZERO: Fraction;
210
+ export declare const FRACTION_ONE: Fraction;
211
+ export declare const FRACTION_NEG_ONE: Fraction;
212
+ export declare const FRACTION_HALF: Fraction;
213
+ export declare const FRACTION_THIRD: Fraction;
214
+ export declare const FRACTION_QUARTER: Fraction;
215
+ //# sourceMappingURL=fraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fraction.d.ts","sourceRoot":"","sources":["../../src/types/fraction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AA8BD;;;;GAIG;AACH,qBAAa,QAAS,YAAW,SAAS;IACxC,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,YACE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,EAC9C,WAAW,GAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAa,EAqEtD;IAMD;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,GAAE,MAAiB,GAAG,QAAQ,CA+BxE;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAoC9C;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAgBlC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CACb,IAAI,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,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AE,GAAG,QAAQ,CAenD;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAEjC;CACF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,UAAuB,CAAC;AAClD,eAAO,MAAM,YAAY,UAAuB,CAAC;AACjD,eAAO,MAAM,gBAAgB,UAAwB,CAAC;AACtD,eAAO,MAAM,aAAa,UAAuB,CAAC;AAClD,eAAO,MAAM,cAAc,UAAuB,CAAC;AACnD,eAAO,MAAM,gBAAgB,UAAuB,CAAC"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Base interfaces for MathTS types
3
+ * @module @danielsimonjr/mathts-core/types/interfaces
4
+ */
5
+ /**
6
+ * Base interface for all MathTS numeric types
7
+ */
8
+ export interface MathTSValue {
9
+ readonly type: string;
10
+ valueOf(): number | bigint;
11
+ toString(): string;
12
+ toJSON(): unknown;
13
+ }
14
+ /**
15
+ * Scalar types that support arithmetic
16
+ */
17
+ export interface Scalar extends MathTSValue {
18
+ add(other: Scalar): Scalar;
19
+ subtract(other: Scalar): Scalar;
20
+ multiply(other: Scalar): Scalar;
21
+ divide(other: Scalar): Scalar;
22
+ negate(): Scalar;
23
+ abs(): Scalar | number;
24
+ }
25
+ /**
26
+ * Available computation backends
27
+ */
28
+ export type BackendType = 'js' | 'wasm' | 'gpu';
29
+ /**
30
+ * Supported numeric types
31
+ */
32
+ export type NumericType = 'float32' | 'float64' | 'int32' | 'int64' | 'complex64' | 'complex128';
33
+ /**
34
+ * Matrix backend interface
35
+ */
36
+ export interface MatrixBackend {
37
+ readonly name: BackendType;
38
+ readonly isAvailable: boolean;
39
+ matmul(a: Float64Array, b: Float64Array, m: number, n: number, k: number): Float64Array;
40
+ transpose(data: Float64Array, rows: number, cols: number): Float64Array;
41
+ add(a: Float64Array, b: Float64Array): Float64Array;
42
+ subtract(a: Float64Array, b: Float64Array): Float64Array;
43
+ scale(data: Float64Array, scalar: number): Float64Array;
44
+ lu(data: Float64Array, n: number): {
45
+ L: Float64Array;
46
+ U: Float64Array;
47
+ P: Int32Array;
48
+ };
49
+ qr(data: Float64Array, m: number, n: number): {
50
+ Q: Float64Array;
51
+ R: Float64Array;
52
+ };
53
+ svd(data: Float64Array, m: number, n: number): {
54
+ U: Float64Array;
55
+ S: Float64Array;
56
+ V: Float64Array;
57
+ };
58
+ eig(data: Float64Array, n: number): {
59
+ values: Float64Array;
60
+ vectors: Float64Array;
61
+ };
62
+ }
63
+ /**
64
+ * Matrix interface with backend abstraction
65
+ */
66
+ export interface IMatrix<T = number> extends MathTSValue {
67
+ readonly rows: number;
68
+ readonly cols: number;
69
+ readonly size: readonly [number, number];
70
+ readonly length: number;
71
+ readonly backend: MatrixBackend;
72
+ get(row: number, col: number): T;
73
+ set(row: number, col: number, value: T): void;
74
+ row(index: number): IMatrix<T>;
75
+ column(index: number): IMatrix<T>;
76
+ slice(rowStart: number, rowEnd: number, colStart: number, colEnd: number): IMatrix<T>;
77
+ transpose(): IMatrix<T>;
78
+ reshape(rows: number, cols: number): IMatrix<T>;
79
+ flatten(): T[];
80
+ add(other: IMatrix<T> | T): IMatrix<T>;
81
+ subtract(other: IMatrix<T> | T): IMatrix<T>;
82
+ multiply(other: IMatrix<T> | T): IMatrix<T>;
83
+ toArray(): T[][];
84
+ toBuffer(): ArrayBuffer;
85
+ clone(): IMatrix<T>;
86
+ }
87
+ /**
88
+ * Complex number interface
89
+ */
90
+ export interface IComplex extends Scalar {
91
+ readonly re: number;
92
+ readonly im: number;
93
+ conjugate(): IComplex;
94
+ arg(): number;
95
+ sqrt(): IComplex;
96
+ exp(): IComplex;
97
+ log(): IComplex;
98
+ }
99
+ /**
100
+ * Fraction interface for exact rational arithmetic
101
+ */
102
+ export interface IFraction extends Scalar {
103
+ readonly numerator: bigint;
104
+ readonly denominator: bigint;
105
+ simplify(): IFraction;
106
+ toNumber(): number;
107
+ }
108
+ /**
109
+ * BigNumber interface for arbitrary precision decimals
110
+ */
111
+ export interface IBigNumber extends MathTSValue {
112
+ add(other: IBigNumber | number | string): IBigNumber;
113
+ subtract(other: IBigNumber | number | string): IBigNumber;
114
+ multiply(other: IBigNumber | number | string): IBigNumber;
115
+ divide(other: IBigNumber | number | string): IBigNumber;
116
+ negate(): IBigNumber;
117
+ abs(): IBigNumber;
118
+ pow(n: number | bigint): IBigNumber;
119
+ sqrt(): IBigNumber;
120
+ isNaN(): boolean;
121
+ isFinite(): boolean;
122
+ isInfinite(): boolean;
123
+ isZero(): boolean;
124
+ isPositive(): boolean;
125
+ isNegative(): boolean;
126
+ isInteger(): boolean;
127
+ equals(other: IBigNumber): boolean;
128
+ lessThan(other: IBigNumber): boolean;
129
+ greaterThan(other: IBigNumber): boolean;
130
+ compareTo(other: IBigNumber): number;
131
+ toFixed(decimalPlaces?: number): string;
132
+ toExponential(decimalPlaces?: number): string;
133
+ toPrecision(significantDigits?: number): string;
134
+ toBigInt(): bigint;
135
+ }
136
+ /**
137
+ * Matrix dimensions
138
+ */
139
+ export interface MatrixDimensions {
140
+ rows: number;
141
+ cols: number;
142
+ }
143
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,IAAI,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,IAAI,MAAM,CAAC;IACnB,MAAM,IAAI,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,MAAO,SAAQ,WAAW;IACzC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,MA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