@danielsimonjr/mathts-compat 0.1.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.
@@ -0,0 +1,320 @@
1
+ import { Complex, Fraction, BigNumber } from '@danielsimonjr/mathts-core';
2
+ export { BIGNUMBER_E, BIGNUMBER_ONE, BIGNUMBER_PI, BIGNUMBER_ZERO, BigNumber, COMPLEX_ONE, COMPLEX_ZERO, Complex, FRACTION_ONE, FRACTION_ZERO, Fraction, I } from '@danielsimonjr/mathts-core';
3
+ import { add as add$1, subtract as subtract$1, multiply as multiply$1, divide as divide$1, pow as pow$1, sqrt as sqrt$1, abs as abs$1, exp as exp$1, log as log$1, sin as sin$1, cos as cos$1, tan as tan$1, sum as sum$1, mean as mean$1, min as min$1, max as max$1, gcd as gcd$1, lcm as lcm$1, round as round$1, floor as floor$1, ceil as ceil$1 } from '@danielsimonjr/mathts-functions';
4
+ import { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
5
+ export { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
6
+ export { computePool } from '@danielsimonjr/mathts-parallel';
7
+
8
+ /**
9
+ * mathjs Compatibility Shims
10
+ *
11
+ * Provides mathjs-compatible API wrappers around MathTS functions.
12
+ * This allows gradual migration from mathjs to MathTS.
13
+ *
14
+ * @packageDocumentation
15
+ */
16
+
17
+ /**
18
+ * Create a complex number (mathjs-compatible)
19
+ * @example
20
+ * complex(3, 4) // Complex(3, 4)
21
+ * complex(5) // Complex(5, 0)
22
+ * complex('3+4i') // Complex(3, 4)
23
+ */
24
+ declare function complex(re?: number | string | Complex, im?: number): Complex;
25
+ /**
26
+ * Create a fraction (mathjs-compatible)
27
+ * @example
28
+ * fraction(1, 2) // Fraction(1, 2)
29
+ * fraction('1/2') // Fraction(1, 2)
30
+ * fraction(0.5) // Fraction(1, 2)
31
+ */
32
+ declare function fraction(numerator?: number | string | Fraction, denominator?: number): Fraction;
33
+ /**
34
+ * Create a BigNumber (mathjs-compatible)
35
+ * @example
36
+ * bignumber('123.456')
37
+ * bignumber(123)
38
+ */
39
+ declare function bignumber(value?: number | string | BigNumber): BigNumber;
40
+ /**
41
+ * Create a matrix (mathjs-compatible)
42
+ * @example
43
+ * matrix([[1,2],[3,4]])
44
+ * matrix([[1,2],[3,4]], 'sparse')
45
+ */
46
+ declare function matrix(data?: number[][] | DenseMatrix | SparseMatrix, format?: 'dense' | 'sparse'): DenseMatrix | SparseMatrix;
47
+ /**
48
+ * Create a sparse matrix (mathjs-compatible)
49
+ */
50
+ declare function sparse(data?: number[][]): SparseMatrix;
51
+ declare const add: typeof add$1;
52
+ declare const subtract: typeof subtract$1;
53
+ declare const multiply: typeof multiply$1;
54
+ declare const divide: typeof divide$1;
55
+ declare const pow: typeof pow$1;
56
+ declare const sqrt: typeof sqrt$1;
57
+ declare const abs: typeof abs$1;
58
+ declare const exp: typeof exp$1;
59
+ declare const log: typeof log$1;
60
+ declare const sin: typeof sin$1;
61
+ declare const cos: typeof cos$1;
62
+ declare const tan: typeof tan$1;
63
+ declare function asin(x: number): number;
64
+ declare function acos(x: number): number;
65
+ declare function atan(x: number): number;
66
+ declare function atan2(y: number, x: number): number;
67
+ declare const sum: typeof sum$1;
68
+ declare const mean: typeof mean$1;
69
+ declare const min: typeof min$1;
70
+ declare const max: typeof max$1;
71
+ declare const gcd: typeof gcd$1;
72
+ declare const lcm: typeof lcm$1;
73
+ declare const round: typeof round$1;
74
+ declare const floor: typeof floor$1;
75
+ declare const ceil: typeof ceil$1;
76
+ /**
77
+ * Complex conjugate (mathjs-compatible)
78
+ */
79
+ declare function conj(c: Complex): Complex;
80
+ /**
81
+ * Real part (mathjs-compatible)
82
+ */
83
+ declare function re(c: Complex | number): number;
84
+ /**
85
+ * Imaginary part (mathjs-compatible)
86
+ */
87
+ declare function im(c: Complex | number): number;
88
+ /**
89
+ * Argument (phase) of complex number (mathjs-compatible)
90
+ */
91
+ declare function arg(c: Complex): number;
92
+ /**
93
+ * Transpose matrix (mathjs-compatible)
94
+ */
95
+ declare function transpose(m: DenseMatrix | SparseMatrix | number[][]): DenseMatrix | SparseMatrix;
96
+ /**
97
+ * Matrix determinant (mathjs-compatible)
98
+ *
99
+ * Computes the determinant using LU decomposition.
100
+ */
101
+ declare function det(m: DenseMatrix | number[][]): number;
102
+ /**
103
+ * Identity matrix (mathjs-compatible)
104
+ */
105
+ declare function identity(n: number): DenseMatrix;
106
+ /**
107
+ * Zeros matrix (mathjs-compatible)
108
+ */
109
+ declare function zeros(rows: number, cols?: number): DenseMatrix;
110
+ /**
111
+ * Ones matrix (mathjs-compatible)
112
+ */
113
+ declare function ones(rows: number, cols?: number): DenseMatrix;
114
+ /**
115
+ * Matrix size (mathjs-compatible)
116
+ */
117
+ declare function size(m: DenseMatrix | SparseMatrix | number[][]): [number, number];
118
+ declare function isComplex_(x: unknown): x is Complex;
119
+ declare function isFraction_(x: unknown): x is Fraction;
120
+ declare function isBigNumber_(x: unknown): x is BigNumber;
121
+ declare function isNumber_(x: unknown): x is number;
122
+ declare function isMatrix(x: unknown): x is DenseMatrix | SparseMatrix;
123
+ declare const i: Complex;
124
+ declare const pi: number;
125
+ declare const e: number;
126
+ declare const phi: number;
127
+ declare const tau: number;
128
+ declare const LN2: number;
129
+ declare const LN10: number;
130
+ declare const LOG2E: number;
131
+ declare const LOG10E: number;
132
+ declare const SQRT2: number;
133
+ declare const SQRT1_2: number;
134
+ declare const Infinity_: number;
135
+ declare const NaN_: number;
136
+ declare const shims: {
137
+ complex: typeof complex;
138
+ fraction: typeof fraction;
139
+ bignumber: typeof bignumber;
140
+ matrix: typeof matrix;
141
+ sparse: typeof sparse;
142
+ add: typeof add$1;
143
+ subtract: typeof subtract$1;
144
+ multiply: typeof multiply$1;
145
+ divide: typeof divide$1;
146
+ pow: typeof pow$1;
147
+ sqrt: typeof sqrt$1;
148
+ abs: typeof abs$1;
149
+ exp: typeof exp$1;
150
+ log: typeof log$1;
151
+ sin: typeof sin$1;
152
+ cos: typeof cos$1;
153
+ tan: typeof tan$1;
154
+ asin: typeof asin;
155
+ acos: typeof acos;
156
+ atan: typeof atan;
157
+ atan2: typeof atan2;
158
+ sum: typeof sum$1;
159
+ mean: typeof mean$1;
160
+ min: typeof min$1;
161
+ max: typeof max$1;
162
+ gcd: typeof gcd$1;
163
+ lcm: typeof lcm$1;
164
+ round: typeof round$1;
165
+ floor: typeof floor$1;
166
+ ceil: typeof ceil$1;
167
+ conj: typeof conj;
168
+ re: typeof re;
169
+ im: typeof im;
170
+ arg: typeof arg;
171
+ transpose: typeof transpose;
172
+ det: typeof det;
173
+ identity: typeof identity;
174
+ zeros: typeof zeros;
175
+ ones: typeof ones;
176
+ size: typeof size;
177
+ isComplex: typeof isComplex_;
178
+ isFraction: typeof isFraction_;
179
+ isBigNumber: typeof isBigNumber_;
180
+ isNumber: typeof isNumber_;
181
+ isMatrix: typeof isMatrix;
182
+ i: Complex;
183
+ pi: number;
184
+ e: number;
185
+ phi: number;
186
+ tau: number;
187
+ LN2: number;
188
+ LN10: number;
189
+ LOG2E: number;
190
+ LOG10E: number;
191
+ SQRT2: number;
192
+ SQRT1_2: number;
193
+ Infinity: number;
194
+ NaN: number;
195
+ };
196
+
197
+ /**
198
+ * @danielsimonjr/mathts-compat - mathjs Compatibility Layer
199
+ *
200
+ * Provides a mathjs-compatible API for gradual migration to MathTS.
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * import { create, all } from '@danielsimonjr/mathts-compat';
205
+ * const math = create(all);
206
+ *
207
+ * // Use mathjs-style API
208
+ * math.add(1, 2);
209
+ * math.complex(3, 4);
210
+ * math.matrix([[1,2],[3,4]]);
211
+ * ```
212
+ *
213
+ * @packageDocumentation
214
+ */
215
+
216
+ /**
217
+ * mathjs-compatible configuration interface
218
+ */
219
+ interface MathJSConfig {
220
+ /** Numeric precision for BigNumber (default: 64) */
221
+ precision?: number;
222
+ /** Matrix type: 'Matrix' or 'Array' */
223
+ matrix?: 'Matrix' | 'Array';
224
+ /** Number type for parsing */
225
+ number?: 'number' | 'BigNumber' | 'Fraction';
226
+ /** Epsilon for floating point comparisons */
227
+ epsilon?: number;
228
+ /** Predictable random seed */
229
+ randomSeed?: string | null;
230
+ }
231
+ /**
232
+ * MathTS instance with mathjs-compatible API
233
+ */
234
+ interface MathInstance {
235
+ config: (newConfig?: Partial<MathJSConfig>) => MathJSConfig;
236
+ complex: typeof shims.complex;
237
+ fraction: typeof shims.fraction;
238
+ bignumber: typeof shims.bignumber;
239
+ matrix: typeof shims.matrix;
240
+ sparse: typeof shims.sparse;
241
+ add: typeof shims.add;
242
+ subtract: typeof shims.subtract;
243
+ multiply: typeof shims.multiply;
244
+ divide: typeof shims.divide;
245
+ pow: typeof shims.pow;
246
+ sqrt: typeof shims.sqrt;
247
+ abs: typeof shims.abs;
248
+ exp: typeof shims.exp;
249
+ log: typeof shims.log;
250
+ sin: typeof shims.sin;
251
+ cos: typeof shims.cos;
252
+ tan: typeof shims.tan;
253
+ asin: typeof shims.asin;
254
+ acos: typeof shims.acos;
255
+ atan: typeof shims.atan;
256
+ atan2: typeof shims.atan2;
257
+ sum: typeof shims.sum;
258
+ mean: typeof shims.mean;
259
+ min: typeof shims.min;
260
+ max: typeof shims.max;
261
+ gcd: typeof shims.gcd;
262
+ lcm: typeof shims.lcm;
263
+ round: typeof shims.round;
264
+ floor: typeof shims.floor;
265
+ ceil: typeof shims.ceil;
266
+ conj: typeof shims.conj;
267
+ re: typeof shims.re;
268
+ im: typeof shims.im;
269
+ arg: typeof shims.arg;
270
+ transpose: typeof shims.transpose;
271
+ det: typeof shims.det;
272
+ identity: typeof shims.identity;
273
+ zeros: typeof shims.zeros;
274
+ ones: typeof shims.ones;
275
+ size: typeof shims.size;
276
+ isComplex: typeof shims.isComplex;
277
+ isFraction: typeof shims.isFraction;
278
+ isBigNumber: typeof shims.isBigNumber;
279
+ isNumber: typeof shims.isNumber;
280
+ isMatrix: typeof shims.isMatrix;
281
+ i: typeof shims.i;
282
+ pi: typeof shims.pi;
283
+ e: typeof shims.e;
284
+ phi: typeof shims.phi;
285
+ tau: typeof shims.tau;
286
+ LN2: typeof shims.LN2;
287
+ LN10: typeof shims.LN10;
288
+ LOG2E: typeof shims.LOG2E;
289
+ LOG10E: typeof shims.LOG10E;
290
+ SQRT2: typeof shims.SQRT2;
291
+ SQRT1_2: typeof shims.SQRT1_2;
292
+ Infinity: typeof shims.Infinity;
293
+ NaN: typeof shims.NaN;
294
+ }
295
+ /**
296
+ * Create a MathTS instance with mathjs-compatible API
297
+ *
298
+ * @param _factories - Factory functions to include (use `all` for all functions)
299
+ * @param config - Configuration options
300
+ * @returns MathTS instance with mathjs-compatible API
301
+ *
302
+ * @example
303
+ * ```typescript
304
+ * import { create, all } from '@danielsimonjr/mathts-compat';
305
+ * const math = create(all);
306
+ *
307
+ * math.add(1, 2); // 3
308
+ * math.complex(3, 4); // Complex(3, 4)
309
+ * math.matrix([[1,2],[3,4]]); // DenseMatrix
310
+ * ```
311
+ */
312
+ declare function create(_factories?: Record<string, unknown>, config?: Partial<MathJSConfig>): MathInstance;
313
+ /**
314
+ * All available factory functions
315
+ *
316
+ * Use with `create(all)` to get a fully-featured math instance.
317
+ */
318
+ declare const all: Record<string, unknown>;
319
+
320
+ export { Infinity_, LN10, LN2, LOG10E, LOG2E, type MathInstance, type MathJSConfig, NaN_, SQRT1_2, SQRT2, abs, acos, add, all, arg, asin, atan, atan2, bignumber, ceil, complex, conj, cos, create, det, divide, e, exp, floor, fraction, gcd, i, identity, im, isBigNumber_, isComplex_, isFraction_, isMatrix, isNumber_, lcm, log, matrix, max, mean, min, multiply, ones, phi, pi, pow, re, round, shims, sin, size, sparse, sqrt, subtract, sum, tan, tau, transpose, zeros };
package/dist/index.js ADDED
@@ -0,0 +1,512 @@
1
+ // src/shims.ts
2
+ import {
3
+ Complex,
4
+ Fraction,
5
+ BigNumber,
6
+ I,
7
+ COMPLEX_ZERO,
8
+ isComplex,
9
+ isFraction,
10
+ isBigNumber,
11
+ isNumber
12
+ } from "@danielsimonjr/mathts-core";
13
+ import {
14
+ add as _add,
15
+ subtract as _subtract,
16
+ multiply as _multiply,
17
+ divide as _divide,
18
+ pow as _pow,
19
+ sqrt as _sqrt,
20
+ abs as _abs,
21
+ exp as _exp,
22
+ log as _log,
23
+ sin as _sin,
24
+ cos as _cos,
25
+ tan as _tan,
26
+ sum as _sum,
27
+ mean as _mean,
28
+ min as _min,
29
+ max as _max,
30
+ gcd as _gcd,
31
+ lcm as _lcm,
32
+ round as _round,
33
+ floor as _floor,
34
+ ceil as _ceil
35
+ } from "@danielsimonjr/mathts-functions";
36
+ import { DenseMatrix, SparseMatrix } from "@danielsimonjr/mathts-matrix";
37
+ function complex(re2, im2) {
38
+ if (re2 === void 0) {
39
+ return COMPLEX_ZERO;
40
+ }
41
+ if (re2 instanceof Complex) {
42
+ return re2;
43
+ }
44
+ if (typeof re2 === "string") {
45
+ return Complex.parse(re2);
46
+ }
47
+ return new Complex(re2, im2 ?? 0);
48
+ }
49
+ function fraction(numerator, denominator) {
50
+ if (numerator === void 0) {
51
+ return new Fraction(0, 1);
52
+ }
53
+ if (numerator instanceof Fraction) {
54
+ return numerator;
55
+ }
56
+ if (typeof numerator === "string") {
57
+ return Fraction.parse(numerator);
58
+ }
59
+ if (denominator !== void 0) {
60
+ return new Fraction(numerator, denominator);
61
+ }
62
+ return Fraction.fromNumber(numerator);
63
+ }
64
+ function bignumber(value) {
65
+ if (value === void 0) {
66
+ return BigNumber.fromNumber(0);
67
+ }
68
+ if (value instanceof BigNumber) {
69
+ return value;
70
+ }
71
+ if (typeof value === "string") {
72
+ return BigNumber.parse(value);
73
+ }
74
+ return BigNumber.fromNumber(value);
75
+ }
76
+ function matrix(data, format) {
77
+ if (data === void 0) {
78
+ return DenseMatrix.zeros(0, 0);
79
+ }
80
+ if (data instanceof DenseMatrix || data instanceof SparseMatrix) {
81
+ return data;
82
+ }
83
+ const dense = DenseMatrix.fromArray(data);
84
+ if (format === "sparse") {
85
+ return SparseMatrix.fromDense(dense);
86
+ }
87
+ return dense;
88
+ }
89
+ function sparse(data) {
90
+ if (data === void 0) {
91
+ return SparseMatrix.zeros(0, 0);
92
+ }
93
+ return SparseMatrix.fromDense(DenseMatrix.fromArray(data));
94
+ }
95
+ var add = _add;
96
+ var subtract = _subtract;
97
+ var multiply = _multiply;
98
+ var divide = _divide;
99
+ var pow = _pow;
100
+ var sqrt = _sqrt;
101
+ var abs = _abs;
102
+ var exp = _exp;
103
+ var log = _log;
104
+ var sin = _sin;
105
+ var cos = _cos;
106
+ var tan = _tan;
107
+ function asin(x) {
108
+ return Math.asin(x);
109
+ }
110
+ function acos(x) {
111
+ return Math.acos(x);
112
+ }
113
+ function atan(x) {
114
+ return Math.atan(x);
115
+ }
116
+ function atan2(y, x) {
117
+ return Math.atan2(y, x);
118
+ }
119
+ var sum = _sum;
120
+ var mean = _mean;
121
+ var min = _min;
122
+ var max = _max;
123
+ var gcd = _gcd;
124
+ var lcm = _lcm;
125
+ var round = _round;
126
+ var floor = _floor;
127
+ var ceil = _ceil;
128
+ function conj(c) {
129
+ if (!isComplex(c)) {
130
+ throw new TypeError("Expected Complex number");
131
+ }
132
+ return c.conjugate();
133
+ }
134
+ function re(c) {
135
+ if (typeof c === "number") return c;
136
+ if (isComplex(c)) return c.re;
137
+ throw new TypeError("Expected Complex or number");
138
+ }
139
+ function im(c) {
140
+ if (typeof c === "number") return 0;
141
+ if (isComplex(c)) return c.im;
142
+ throw new TypeError("Expected Complex or number");
143
+ }
144
+ function arg(c) {
145
+ if (!isComplex(c)) {
146
+ throw new TypeError("Expected Complex number");
147
+ }
148
+ return c.arg();
149
+ }
150
+ function transpose(m) {
151
+ if (Array.isArray(m)) {
152
+ return DenseMatrix.fromArray(m).transpose();
153
+ }
154
+ return m.transpose();
155
+ }
156
+ function det(m) {
157
+ const matrix2 = Array.isArray(m) ? DenseMatrix.fromArray(m) : m;
158
+ if (!(matrix2 instanceof DenseMatrix)) {
159
+ throw new TypeError("Expected DenseMatrix or 2D array");
160
+ }
161
+ if (matrix2.rows !== matrix2.cols) {
162
+ throw new Error("Determinant requires a square matrix");
163
+ }
164
+ const n = matrix2.rows;
165
+ if (n === 0) return 1;
166
+ if (n === 1) return matrix2.get(0, 0);
167
+ if (n === 2) {
168
+ return matrix2.get(0, 0) * matrix2.get(1, 1) - matrix2.get(0, 1) * matrix2.get(1, 0);
169
+ }
170
+ if (n === 3) {
171
+ const a = matrix2.get(0, 0), b = matrix2.get(0, 1), c = matrix2.get(0, 2);
172
+ const d = matrix2.get(1, 0), e2 = matrix2.get(1, 1), f = matrix2.get(1, 2);
173
+ const g = matrix2.get(2, 0), h = matrix2.get(2, 1), i2 = matrix2.get(2, 2);
174
+ return a * (e2 * i2 - f * h) - b * (d * i2 - f * g) + c * (d * h - e2 * g);
175
+ }
176
+ const lu = [];
177
+ for (let i2 = 0; i2 < n; i2++) {
178
+ lu[i2] = [];
179
+ for (let j = 0; j < n; j++) {
180
+ lu[i2][j] = matrix2.get(i2, j);
181
+ }
182
+ }
183
+ let swaps = 0;
184
+ for (let k = 0; k < n - 1; k++) {
185
+ let maxVal = Math.abs(lu[k][k]);
186
+ let maxRow = k;
187
+ for (let i2 = k + 1; i2 < n; i2++) {
188
+ if (Math.abs(lu[i2][k]) > maxVal) {
189
+ maxVal = Math.abs(lu[i2][k]);
190
+ maxRow = i2;
191
+ }
192
+ }
193
+ if (maxVal < 1e-12) {
194
+ return 0;
195
+ }
196
+ if (maxRow !== k) {
197
+ [lu[k], lu[maxRow]] = [lu[maxRow], lu[k]];
198
+ swaps++;
199
+ }
200
+ for (let i2 = k + 1; i2 < n; i2++) {
201
+ lu[i2][k] /= lu[k][k];
202
+ for (let j = k + 1; j < n; j++) {
203
+ lu[i2][j] -= lu[i2][k] * lu[k][j];
204
+ }
205
+ }
206
+ }
207
+ let result = 1;
208
+ for (let i2 = 0; i2 < n; i2++) {
209
+ result *= lu[i2][i2];
210
+ }
211
+ return swaps % 2 === 0 ? result : -result;
212
+ }
213
+ function identity(n) {
214
+ return DenseMatrix.identity(n);
215
+ }
216
+ function zeros(rows, cols) {
217
+ return DenseMatrix.zeros(rows, cols ?? rows);
218
+ }
219
+ function ones(rows, cols) {
220
+ return DenseMatrix.ones(rows, cols ?? rows);
221
+ }
222
+ function size(m) {
223
+ if (Array.isArray(m)) {
224
+ return [m.length, m[0]?.length ?? 0];
225
+ }
226
+ return [m.rows, m.cols];
227
+ }
228
+ function isComplex_(x) {
229
+ return isComplex(x);
230
+ }
231
+ function isFraction_(x) {
232
+ return isFraction(x);
233
+ }
234
+ function isBigNumber_(x) {
235
+ return isBigNumber(x);
236
+ }
237
+ function isNumber_(x) {
238
+ return isNumber(x);
239
+ }
240
+ function isMatrix(x) {
241
+ return x instanceof DenseMatrix || x instanceof SparseMatrix;
242
+ }
243
+ var i = I;
244
+ var pi = Math.PI;
245
+ var e = Math.E;
246
+ var phi = (1 + Math.sqrt(5)) / 2;
247
+ var tau = 2 * Math.PI;
248
+ var LN2 = Math.LN2;
249
+ var LN10 = Math.LN10;
250
+ var LOG2E = Math.LOG2E;
251
+ var LOG10E = Math.LOG10E;
252
+ var SQRT2 = Math.SQRT2;
253
+ var SQRT1_2 = Math.SQRT1_2;
254
+ var Infinity_ = Infinity;
255
+ var NaN_ = NaN;
256
+ var shims = {
257
+ // Type creation
258
+ complex,
259
+ fraction,
260
+ bignumber,
261
+ matrix,
262
+ sparse,
263
+ // Arithmetic
264
+ add,
265
+ subtract,
266
+ multiply,
267
+ divide,
268
+ pow,
269
+ sqrt,
270
+ abs,
271
+ exp,
272
+ log,
273
+ // Trigonometry
274
+ sin,
275
+ cos,
276
+ tan,
277
+ asin,
278
+ acos,
279
+ atan,
280
+ atan2,
281
+ // Statistics
282
+ sum,
283
+ mean,
284
+ min,
285
+ max,
286
+ // Number theory
287
+ gcd,
288
+ lcm,
289
+ // Rounding
290
+ round,
291
+ floor,
292
+ ceil,
293
+ // Complex-specific
294
+ conj,
295
+ re,
296
+ im,
297
+ arg,
298
+ // Matrix-specific
299
+ transpose,
300
+ det,
301
+ identity,
302
+ zeros,
303
+ ones,
304
+ size,
305
+ // Type checking
306
+ isComplex: isComplex_,
307
+ isFraction: isFraction_,
308
+ isBigNumber: isBigNumber_,
309
+ isNumber: isNumber_,
310
+ isMatrix,
311
+ // Constants
312
+ i,
313
+ pi,
314
+ e,
315
+ phi,
316
+ tau,
317
+ LN2,
318
+ LN10,
319
+ LOG2E,
320
+ LOG10E,
321
+ SQRT2,
322
+ SQRT1_2,
323
+ Infinity: Infinity_,
324
+ NaN: NaN_
325
+ };
326
+
327
+ // src/index.ts
328
+ import {
329
+ Complex as Complex2,
330
+ Fraction as Fraction2,
331
+ BigNumber as BigNumber2,
332
+ I as I2,
333
+ COMPLEX_ZERO as COMPLEX_ZERO2,
334
+ COMPLEX_ONE,
335
+ FRACTION_ZERO,
336
+ FRACTION_ONE,
337
+ BIGNUMBER_ZERO,
338
+ BIGNUMBER_ONE,
339
+ BIGNUMBER_PI,
340
+ BIGNUMBER_E
341
+ } from "@danielsimonjr/mathts-core";
342
+ import { DenseMatrix as DenseMatrix2, SparseMatrix as SparseMatrix2 } from "@danielsimonjr/mathts-matrix";
343
+ import { computePool } from "@danielsimonjr/mathts-parallel";
344
+ var defaultConfig = {
345
+ precision: 64,
346
+ matrix: "Matrix",
347
+ number: "number",
348
+ epsilon: 1e-12,
349
+ randomSeed: null
350
+ };
351
+ function create(_factories = {}, config = {}) {
352
+ const currentConfig = { ...defaultConfig, ...config };
353
+ return {
354
+ // Configuration
355
+ config: (newConfig) => {
356
+ if (newConfig) {
357
+ Object.assign(currentConfig, newConfig);
358
+ }
359
+ return { ...currentConfig };
360
+ },
361
+ // Type creation
362
+ complex: shims.complex,
363
+ fraction: shims.fraction,
364
+ bignumber: shims.bignumber,
365
+ matrix: shims.matrix,
366
+ sparse: shims.sparse,
367
+ // Arithmetic
368
+ add: shims.add,
369
+ subtract: shims.subtract,
370
+ multiply: shims.multiply,
371
+ divide: shims.divide,
372
+ pow: shims.pow,
373
+ sqrt: shims.sqrt,
374
+ abs: shims.abs,
375
+ exp: shims.exp,
376
+ log: shims.log,
377
+ // Trigonometry
378
+ sin: shims.sin,
379
+ cos: shims.cos,
380
+ tan: shims.tan,
381
+ asin: shims.asin,
382
+ acos: shims.acos,
383
+ atan: shims.atan,
384
+ atan2: shims.atan2,
385
+ // Statistics
386
+ sum: shims.sum,
387
+ mean: shims.mean,
388
+ min: shims.min,
389
+ max: shims.max,
390
+ // Number theory
391
+ gcd: shims.gcd,
392
+ lcm: shims.lcm,
393
+ // Rounding
394
+ round: shims.round,
395
+ floor: shims.floor,
396
+ ceil: shims.ceil,
397
+ // Complex-specific
398
+ conj: shims.conj,
399
+ re: shims.re,
400
+ im: shims.im,
401
+ arg: shims.arg,
402
+ // Matrix-specific
403
+ transpose: shims.transpose,
404
+ det: shims.det,
405
+ identity: shims.identity,
406
+ zeros: shims.zeros,
407
+ ones: shims.ones,
408
+ size: shims.size,
409
+ // Type checking
410
+ isComplex: shims.isComplex,
411
+ isFraction: shims.isFraction,
412
+ isBigNumber: shims.isBigNumber,
413
+ isNumber: shims.isNumber,
414
+ isMatrix: shims.isMatrix,
415
+ // Constants
416
+ i: shims.i,
417
+ pi: shims.pi,
418
+ e: shims.e,
419
+ phi: shims.phi,
420
+ tau: shims.tau,
421
+ LN2: shims.LN2,
422
+ LN10: shims.LN10,
423
+ LOG2E: shims.LOG2E,
424
+ LOG10E: shims.LOG10E,
425
+ SQRT2: shims.SQRT2,
426
+ SQRT1_2: shims.SQRT1_2,
427
+ Infinity: shims.Infinity,
428
+ NaN: shims.NaN
429
+ };
430
+ }
431
+ var all = {
432
+ // Placeholder - in mathjs this contains all factory functions
433
+ // For MathTS compat, we include everything by default in create()
434
+ };
435
+ export {
436
+ BIGNUMBER_E,
437
+ BIGNUMBER_ONE,
438
+ BIGNUMBER_PI,
439
+ BIGNUMBER_ZERO,
440
+ BigNumber2 as BigNumber,
441
+ COMPLEX_ONE,
442
+ COMPLEX_ZERO2 as COMPLEX_ZERO,
443
+ Complex2 as Complex,
444
+ DenseMatrix2 as DenseMatrix,
445
+ FRACTION_ONE,
446
+ FRACTION_ZERO,
447
+ Fraction2 as Fraction,
448
+ I2 as I,
449
+ Infinity_,
450
+ LN10,
451
+ LN2,
452
+ LOG10E,
453
+ LOG2E,
454
+ NaN_,
455
+ SQRT1_2,
456
+ SQRT2,
457
+ SparseMatrix2 as SparseMatrix,
458
+ abs,
459
+ acos,
460
+ add,
461
+ all,
462
+ arg,
463
+ asin,
464
+ atan,
465
+ atan2,
466
+ bignumber,
467
+ ceil,
468
+ complex,
469
+ computePool,
470
+ conj,
471
+ cos,
472
+ create,
473
+ det,
474
+ divide,
475
+ e,
476
+ exp,
477
+ floor,
478
+ fraction,
479
+ gcd,
480
+ i,
481
+ identity,
482
+ im,
483
+ isBigNumber_,
484
+ isComplex_,
485
+ isFraction_,
486
+ isMatrix,
487
+ isNumber_,
488
+ lcm,
489
+ log,
490
+ matrix,
491
+ max,
492
+ mean,
493
+ min,
494
+ multiply,
495
+ ones,
496
+ phi,
497
+ pi,
498
+ pow,
499
+ re,
500
+ round,
501
+ shims,
502
+ sin,
503
+ size,
504
+ sparse,
505
+ sqrt,
506
+ subtract,
507
+ sum,
508
+ tan,
509
+ tau,
510
+ transpose,
511
+ zeros
512
+ };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@danielsimonjr/mathts-compat",
3
+ "version": "0.1.1",
4
+ "description": "mathjs compatibility layer for MathTS",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format esm --dts --clean",
20
+ "dev": "tsup src/index.ts --format esm --dts --watch",
21
+ "typecheck": "tsc --noEmit",
22
+ "test": "vitest run",
23
+ "build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
24
+ },
25
+ "dependencies": {
26
+ "@danielsimonjr/mathts-core": "*",
27
+ "@danielsimonjr/mathts-functions": "*",
28
+ "@danielsimonjr/mathts-matrix": "*",
29
+ "@danielsimonjr/mathts-parallel": "*"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^25.5.2",
33
+ "tsup": "^8.5.1",
34
+ "typescript": "^5.8.3",
35
+ "vitest": "^2.1.9"
36
+ },
37
+ "keywords": [
38
+ "math",
39
+ "mathjs",
40
+ "compat",
41
+ "compatibility",
42
+ "migration"
43
+ ],
44
+ "author": "",
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/danielsimonjr/Mathts.git",
49
+ "directory": "compat"
50
+ },
51
+ "module": "./dist/index.js",
52
+ "publishConfig": {
53
+ "access": "public"
54
+ }
55
+ }