@danielsimonjr/mathts-compat 0.4.21 → 0.4.22

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,28 @@
1
+ /**
2
+ * GC12 — mathjs-style fluent `chain` API.
3
+ *
4
+ * chain(3).add(4).multiply(2).done() // 14
5
+ *
6
+ * Each math function `f` becomes a chain method that calls `f(value, ...args)`
7
+ * and returns a new chain wrapping the result. `.done()` / `.valueOf()` unwrap.
8
+ */
9
+ export interface Chain {
10
+ done(): unknown;
11
+ valueOf(): unknown;
12
+ toString(): string;
13
+ [method: string]: (...args: unknown[]) => Chain | unknown;
14
+ }
15
+ /**
16
+ * Build the `chain` factory for one math instance.
17
+ *
18
+ * Each chain method looks up a function of the same name in `math` when the method is read.
19
+ * The method calls that function with the wrapped value first, then the method arguments.
20
+ * The method returns a new chain that wraps the result.
21
+ * `done()` and `valueOf()` return the wrapped value.
22
+ * A name that is not a function in `math` gives `undefined`.
23
+ *
24
+ * @param math - The math instance that supplies the chain methods.
25
+ * @returns A function that wraps a value in a chain.
26
+ */
27
+ export declare function createChain(math: Record<string, unknown>): (value: unknown) => Chain;
28
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,KAAK;IACpB,IAAI,IAAI,OAAO,CAAC;IAChB,OAAO,IAAI,OAAO,CAAC;IACnB,QAAQ,IAAI,MAAM,CAAC;IACnB,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,KAAK,GAAG,OAAO,CAAC;CAC3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAsBpF"}
package/dist/index.d.ts CHANGED
@@ -1,221 +1,3 @@
1
- import * as typed_function from 'typed-function';
2
- import { Complex, Fraction, BigNumber } from '@danielsimonjr/mathts-core';
3
- 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';
4
- import { add as add$1, multiply as multiply$1, subtract as subtract$1 } from '@danielsimonjr/mathts-functions';
5
- import { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
6
- export { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
7
- export { computePool } from '@danielsimonjr/mathts-parallel';
8
-
9
- /**
10
- * Create a complex number (mathjs-compatible)
11
- * @example
12
- * complex(3, 4) // Complex(3, 4)
13
- * complex(5) // Complex(5, 0)
14
- * complex('3+4i') // Complex(3, 4)
15
- */
16
- declare function complex(re?: number | string | Complex, im?: number): Complex;
17
- /**
18
- * Create a fraction (mathjs-compatible)
19
- * @example
20
- * fraction(1, 2) // Fraction(1, 2)
21
- * fraction('1/2') // Fraction(1, 2)
22
- * fraction(0.5) // Fraction(1, 2)
23
- */
24
- declare function fraction(numerator?: number | string | Fraction, denominator?: number): Fraction;
25
- /**
26
- * Create a BigNumber (mathjs-compatible)
27
- * @example
28
- * bignumber('123.456')
29
- * bignumber(123)
30
- */
31
- declare function bignumber(value?: number | string | BigNumber): BigNumber;
32
- /**
33
- * Create a matrix (mathjs-compatible)
34
- * @example
35
- * matrix([[1,2],[3,4]])
36
- * matrix([[1,2],[3,4]], 'sparse')
37
- */
38
- declare function matrix(data?: number[][] | DenseMatrix | SparseMatrix, format?: 'dense' | 'sparse'): DenseMatrix | SparseMatrix;
39
- /**
40
- * Create a sparse matrix (mathjs-compatible)
41
- */
42
- declare function sparse(data?: number[][]): SparseMatrix;
43
- declare const add: typeof add$1;
44
- declare const subtract: typeof subtract$1;
45
- declare const multiply: typeof multiply$1;
46
- declare const divide: typed_function.TypedFunction;
47
- declare const pow: typed_function.TypedFunction;
48
- declare const sqrt: typed_function.TypedFunction;
49
- declare const abs: typed_function.TypedFunction;
50
- declare const exp: typed_function.TypedFunction;
51
- declare const log: typed_function.TypedFunction;
52
- declare const sin: typed_function.TypedFunction;
53
- declare const cos: typed_function.TypedFunction;
54
- declare const tan: typed_function.TypedFunction;
55
- declare function asin(x: number): number;
56
- declare function acos(x: number): number;
57
- declare function atan(x: number): number;
58
- declare function atan2(y: number, x: number): number;
59
- declare const sum: typed_function.TypedFunction;
60
- declare const mean: typed_function.TypedFunction;
61
- type Normalization = 'unbiased' | 'uncorrected' | 'biased';
62
- declare function variance(data: unknown, normalization?: Normalization): number;
63
- declare function std(data: unknown, normalization?: Normalization): number;
64
- declare const min: typed_function.TypedFunction;
65
- declare const max: typed_function.TypedFunction;
66
- declare const gcd: typed_function.TypedFunction;
67
- declare const lcm: typed_function.TypedFunction;
68
- declare const round: typed_function.TypedFunction;
69
- declare const floor: typed_function.TypedFunction;
70
- declare const ceil: typed_function.TypedFunction;
71
- /**
72
- * Complex conjugate (mathjs-compatible)
73
- */
74
- declare function conj(c: Complex): Complex;
75
- /**
76
- * Real part (mathjs-compatible)
77
- */
78
- declare function re(c: Complex | number): number;
79
- /**
80
- * Imaginary part (mathjs-compatible)
81
- */
82
- declare function im(c: Complex | number): number;
83
- /**
84
- * Argument (phase) of complex number (mathjs-compatible)
85
- */
86
- declare function arg(c: Complex): number;
87
- /**
88
- * Transpose matrix (mathjs-compatible). Array in → array out (mathjs returns a
89
- * plain nested array for array input, a Matrix for Matrix input).
90
- */
91
- declare function transpose(m: DenseMatrix | SparseMatrix | number[][]): DenseMatrix | SparseMatrix | number[][];
92
- /**
93
- * Matrix determinant (mathjs-compatible)
94
- *
95
- * Computes the determinant using LU decomposition.
96
- */
97
- declare function det(m: DenseMatrix | number[][]): number;
98
- /**
99
- * Identity matrix (mathjs-compatible)
100
- */
101
- declare function identity(n: number): DenseMatrix;
102
- /**
103
- * Zeros (mathjs-compatible).
104
- *
105
- * Single-arg `zeros(n)` is a length-`n` **vector** matching mathjs
106
- * (`math.zeros(3).toArray()` === `[0,0,0]`, size `[3]`); two-arg `zeros(r,c)` is
107
- * an `r×c` DenseMatrix. (matrix's DenseMatrix is strictly 2-D, so the vector case
108
- * returns a `number[]`.)
109
- */
110
- declare function zeros(rows: number, cols?: number): DenseMatrix | number[];
111
- /**
112
- * Ones (mathjs-compatible).
113
- *
114
- * Single-arg `ones(n)` is a length-`n` **vector** matching mathjs
115
- * (`math.ones(3).toArray()` === `[1,1,1]`); two-arg `ones(r,c)` is an `r×c`
116
- * DenseMatrix.
117
- */
118
- declare function ones(rows: number, cols?: number): DenseMatrix | number[];
119
- /**
120
- * Matrix size (mathjs-compatible)
121
- */
122
- declare function size(m: DenseMatrix | SparseMatrix | number[][]): [number, number];
123
- declare function isComplex_(x: unknown): x is Complex;
124
- declare function isFraction_(x: unknown): x is Fraction;
125
- declare function isBigNumber_(x: unknown): x is BigNumber;
126
- declare function isNumber_(x: unknown): x is number;
127
- declare function isMatrix(x: unknown): x is DenseMatrix | SparseMatrix;
128
- declare const i: Complex;
129
- declare const pi: number;
130
- declare const e: number;
131
- declare const phi: number;
132
- declare const tau: number;
133
- declare const LN2: number;
134
- declare const LN10: number;
135
- declare const LOG2E: number;
136
- declare const LOG10E: number;
137
- declare const SQRT2: number;
138
- declare const SQRT1_2: number;
139
- declare const Infinity_: number;
140
- declare const NaN_: number;
141
- declare const shims: {
142
- complex: typeof complex;
143
- fraction: typeof fraction;
144
- bignumber: typeof bignumber;
145
- matrix: typeof matrix;
146
- sparse: typeof sparse;
147
- add: typed_function.TypedFunction;
148
- subtract: typed_function.TypedFunction;
149
- multiply: typed_function.TypedFunction;
150
- divide: typed_function.TypedFunction;
151
- pow: typed_function.TypedFunction;
152
- sqrt: typed_function.TypedFunction;
153
- abs: typed_function.TypedFunction;
154
- exp: typed_function.TypedFunction;
155
- log: typed_function.TypedFunction;
156
- sin: typed_function.TypedFunction;
157
- cos: typed_function.TypedFunction;
158
- tan: typed_function.TypedFunction;
159
- asin: typeof asin;
160
- acos: typeof acos;
161
- atan: typeof atan;
162
- atan2: typeof atan2;
163
- sum: typed_function.TypedFunction;
164
- mean: typed_function.TypedFunction;
165
- std: typeof std;
166
- variance: typeof variance;
167
- min: typed_function.TypedFunction;
168
- max: typed_function.TypedFunction;
169
- gcd: typed_function.TypedFunction;
170
- lcm: typed_function.TypedFunction;
171
- round: typed_function.TypedFunction;
172
- floor: typed_function.TypedFunction;
173
- ceil: typed_function.TypedFunction;
174
- conj: typeof conj;
175
- re: typeof re;
176
- im: typeof im;
177
- arg: typeof arg;
178
- transpose: typeof transpose;
179
- det: typeof det;
180
- identity: typeof identity;
181
- zeros: typeof zeros;
182
- ones: typeof ones;
183
- size: typeof size;
184
- isComplex: typeof isComplex_;
185
- isFraction: typeof isFraction_;
186
- isBigNumber: typeof isBigNumber_;
187
- isNumber: typeof isNumber_;
188
- isMatrix: typeof isMatrix;
189
- i: Complex;
190
- pi: number;
191
- e: number;
192
- phi: number;
193
- tau: number;
194
- LN2: number;
195
- LN10: number;
196
- LOG2E: number;
197
- LOG10E: number;
198
- SQRT2: number;
199
- SQRT1_2: number;
200
- Infinity: number;
201
- NaN: number;
202
- };
203
-
204
- /**
205
- * GC12 — mathjs-style fluent `chain` API.
206
- *
207
- * chain(3).add(4).multiply(2).done() // 14
208
- *
209
- * Each math function `f` becomes a chain method that calls `f(value, ...args)`
210
- * and returns a new chain wrapping the result. `.done()` / `.valueOf()` unwrap.
211
- */
212
- interface Chain {
213
- done(): unknown;
214
- valueOf(): unknown;
215
- toString(): string;
216
- [method: string]: (...args: unknown[]) => Chain | unknown;
217
- }
218
-
219
1
  /**
220
2
  * @danielsimonjr/mathts-compat - mathjs Compatibility Layer
221
3
  *
@@ -234,11 +16,12 @@ interface Chain {
234
16
  *
235
17
  * @packageDocumentation
236
18
  */
237
-
19
+ import { shims } from './shims.js';
20
+ import { type Chain } from './chain.js';
238
21
  /**
239
22
  * mathjs-compatible configuration interface
240
23
  */
241
- interface MathJSConfig {
24
+ export interface MathJSConfig {
242
25
  /** Numeric precision for BigNumber (default: 64) */
243
26
  precision?: number;
244
27
  /** Matrix type: 'Matrix' or 'Array' */
@@ -253,7 +36,7 @@ interface MathJSConfig {
253
36
  /**
254
37
  * MathTS instance with mathjs-compatible API
255
38
  */
256
- interface MathInstance {
39
+ export interface MathInstance {
257
40
  /**
258
41
  * Index signature for the full functions namespace surfaced by
259
42
  * `create(all)`. Members declared explicitly below keep their precise
@@ -344,12 +127,15 @@ interface MathInstance {
344
127
  * math.det([[1,2],[3,4]]); // -2 (full functions surface)
345
128
  * ```
346
129
  */
347
- declare function create(factories?: Record<string, unknown>, config?: Partial<MathJSConfig>): MathInstance;
130
+ export declare function create(factories?: Record<string, unknown>, config?: Partial<MathJSConfig>): MathInstance;
348
131
  /**
349
132
  * All available factory functions
350
133
  *
351
134
  * Use with `create(all)` to get a fully-featured math instance.
352
135
  */
353
- declare const all: Record<string, unknown>;
354
-
355
- 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, std, subtract, sum, tan, tau, transpose, variance, zeros };
136
+ export declare const all: Record<string, unknown>;
137
+ export * from './shims.js';
138
+ export { Complex, Fraction, BigNumber, I, COMPLEX_ZERO, COMPLEX_ONE, FRACTION_ZERO, FRACTION_ONE, BIGNUMBER_ZERO, BIGNUMBER_ONE, BIGNUMBER_PI, BIGNUMBER_E, } from '@danielsimonjr/mathts-core';
139
+ export { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
140
+ export { computePool } from '@danielsimonjr/mathts-parallel';
141
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAOrD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC5B,8BAA8B;IAC9B,MAAM,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,CAAC;IAC7C,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAiBD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAExB,mDAAmD;IACnD,KAAK,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,KAAK,CAAC;IAGjC,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,KAAK,YAAY,CAAC;IAG5D,OAAO,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAC9B,QAAQ,EAAE,OAAO,KAAK,CAAC,QAAQ,CAAC;IAChC,SAAS,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC;IAClC,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,OAAO,KAAK,CAAC,MAAM,CAAC;IAG5B,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IACtB,QAAQ,EAAE,OA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IAC1B,OAAO,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAC9B,QAAQ,EAAE,OAAO,KAAK,CAAC,QAAQ,CAAC;IAChC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CACpB,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAO,EACxC,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM,GACjC,YAAY,CAkHd;AAED;;;;GAIG;AACH,eAAO,MAAM,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAEvC,CAAC;AAOF,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,CAAC,EACD,YAAY,EACZ,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,GACZ,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAGzE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,285 @@
1
+ /**
2
+ * mathjs Compatibility Shims
3
+ *
4
+ * Provides mathjs-compatible API wrappers around MathTS functions.
5
+ * This allows gradual migration from mathjs to MathTS.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ import { Complex, Fraction, BigNumber } from '@danielsimonjr/mathts-core';
10
+ import { add as _add, subtract as _subtract, multiply as _multiply } from '@danielsimonjr/mathts-functions';
11
+ import { DenseMatrix, SparseMatrix } from '@danielsimonjr/mathts-matrix';
12
+ /**
13
+ * Create a complex number (mathjs-compatible)
14
+ * @example
15
+ * complex(3, 4) // Complex(3, 4)
16
+ * complex(5) // Complex(5, 0)
17
+ * complex('3+4i') // Complex(3, 4)
18
+ */
19
+ export declare function complex(re?: number | string | Complex, im?: number): Complex;
20
+ /**
21
+ * Create a fraction (mathjs-compatible)
22
+ * @example
23
+ * fraction(1, 2) // Fraction(1, 2)
24
+ * fraction('1/2') // Fraction(1, 2)
25
+ * fraction(0.5) // Fraction(1, 2)
26
+ */
27
+ export declare function fraction(numerator?: number | string | Fraction, denominator?: number): Fraction;
28
+ /**
29
+ * Create a BigNumber (mathjs-compatible)
30
+ * @example
31
+ * bignumber('123.456')
32
+ * bignumber(123)
33
+ */
34
+ export declare function bignumber(value?: number | string | BigNumber): BigNumber;
35
+ /**
36
+ * Create a matrix (mathjs-compatible)
37
+ * @example
38
+ * matrix([[1,2],[3,4]])
39
+ * matrix([[1,2],[3,4]], 'sparse')
40
+ */
41
+ export declare function matrix(data?: number[][] | DenseMatrix | SparseMatrix, format?: 'dense' | 'sparse'): DenseMatrix | SparseMatrix;
42
+ /**
43
+ * Create a sparse matrix (mathjs-compatible)
44
+ */
45
+ export declare function sparse(data?: number[][]): SparseMatrix;
46
+ export declare const add: typeof _add;
47
+ export declare const subtract: typeof _subtract;
48
+ export declare const multiply: typeof _multiply;
49
+ export declare const divide: import("typed-function").TypedFunction;
50
+ export declare const pow: import("typed-function").TypedFunction;
51
+ export declare const sqrt: import("typed-function").TypedFunction;
52
+ export declare const abs: import("typed-function").TypedFunction;
53
+ export declare const exp: import("typed-function").TypedFunction;
54
+ export declare const log: import("typed-function").TypedFunction;
55
+ export declare const sin: import("typed-function").TypedFunction;
56
+ export declare const cos: import("typed-function").TypedFunction;
57
+ export declare const tan: import("typed-function").TypedFunction;
58
+ /**
59
+ * Return the inverse sine of `x`. This shim calls `Math.asin`.
60
+ *
61
+ * @param x - The sine value.
62
+ * @returns The angle in radians.
63
+ */
64
+ export declare function asin(x: number): number;
65
+ /**
66
+ * Return the inverse cosine of `x`. This shim calls `Math.acos`.
67
+ *
68
+ * @param x - The cosine value.
69
+ * @returns The angle in radians.
70
+ */
71
+ export declare function acos(x: number): number;
72
+ /**
73
+ * Return the inverse tangent of `x`. This shim calls `Math.atan`.
74
+ *
75
+ * @param x - The tangent value.
76
+ * @returns The angle in radians.
77
+ */
78
+ export declare function atan(x: number): number;
79
+ /**
80
+ * Return the angle of the point (`x`, `y`). This shim calls `Math.atan2(y, x)`.
81
+ *
82
+ * @param y - The y coordinate. This argument comes first.
83
+ * @param x - The x coordinate.
84
+ * @returns The angle in radians.
85
+ */
86
+ export declare function atan2(y: number, x: number): number;
87
+ export declare const sum: import("typed-function").TypedFunction;
88
+ export declare const mean: import("typed-function").TypedFunction;
89
+ type Normalization = 'unbiased' | 'uncorrected' | 'biased';
90
+ /**
91
+ * Return the variance of all values in `data`.
92
+ *
93
+ * This function flattens a DenseMatrix or a nested array to one list.
94
+ * It uses any other input as a list of one value.
95
+ * An empty list gives `NaN`.
96
+ * The divisor is N - 1 for `'unbiased'` (N for one value), N for `'uncorrected'` and N + 1 for `'biased'`.
97
+ *
98
+ * @param data - A number, a DenseMatrix or a nested array of numbers.
99
+ * @param normalization - The divisor rule. The default is `'unbiased'`, as in mathjs.
100
+ * @returns The variance.
101
+ */
102
+ export declare function variance(data: unknown, normalization?: Normalization): number;
103
+ /**
104
+ * Return the standard deviation of all values in `data`.
105
+ *
106
+ * The result is the square root of `variance(data, normalization)`.
107
+ *
108
+ * @param data - A number, a DenseMatrix or a nested array of numbers.
109
+ * @param normalization - The divisor rule. The default is `'unbiased'`, as in mathjs.
110
+ * @returns The standard deviation.
111
+ */
112
+ export declare function std(data: unknown, normalization?: Normalization): number;
113
+ export declare const min: import("typed-function").TypedFunction;
114
+ export declare const max: import("typed-function").TypedFunction;
115
+ export declare const gcd: import("typed-function").TypedFunction;
116
+ export declare const lcm: import("typed-function").TypedFunction;
117
+ export declare const round: import("typed-function").TypedFunction;
118
+ export declare const floor: import("typed-function").TypedFunction;
119
+ export declare const ceil: import("typed-function").TypedFunction;
120
+ /**
121
+ * Complex conjugate (mathjs-compatible)
122
+ */
123
+ export declare function conj(c: Complex): Complex;
124
+ /**
125
+ * Real part (mathjs-compatible)
126
+ */
127
+ export declare function re(c: Complex | number): number;
128
+ /**
129
+ * Imaginary part (mathjs-compatible)
130
+ */
131
+ export declare function im(c: Complex | number): number;
132
+ /**
133
+ * Argument (phase) of complex number (mathjs-compatible)
134
+ */
135
+ export declare function arg(c: Complex): number;
136
+ /**
137
+ * Transpose matrix (mathjs-compatible). Array in → array out (mathjs returns a
138
+ * plain nested array for array input, a Matrix for Matrix input).
139
+ */
140
+ export declare function transpose(m: DenseMatrix | SparseMatrix | number[][]): DenseMatrix | SparseMatrix | number[][];
141
+ /**
142
+ * Matrix determinant (mathjs-compatible)
143
+ *
144
+ * Computes the determinant using LU decomposition.
145
+ */
146
+ export declare function det(m: DenseMatrix | number[][]): number;
147
+ /**
148
+ * Identity matrix (mathjs-compatible)
149
+ */
150
+ export declare function identity(n: number): DenseMatrix;
151
+ /**
152
+ * Zeros (mathjs-compatible).
153
+ *
154
+ * Single-arg `zeros(n)` is a length-`n` **vector** matching mathjs
155
+ * (`math.zeros(3).toArray()` === `[0,0,0]`, size `[3]`); two-arg `zeros(r,c)` is
156
+ * an `r×c` DenseMatrix. (matrix's DenseMatrix is strictly 2-D, so the vector case
157
+ * returns a `number[]`.)
158
+ */
159
+ export declare function zeros(rows: number, cols?: number): DenseMatrix | number[];
160
+ /**
161
+ * Ones (mathjs-compatible).
162
+ *
163
+ * Single-arg `ones(n)` is a length-`n` **vector** matching mathjs
164
+ * (`math.ones(3).toArray()` === `[1,1,1]`); two-arg `ones(r,c)` is an `r×c`
165
+ * DenseMatrix.
166
+ */
167
+ export declare function ones(rows: number, cols?: number): DenseMatrix | number[];
168
+ /**
169
+ * Matrix size (mathjs-compatible)
170
+ */
171
+ export declare function size(m: DenseMatrix | SparseMatrix | number[][]): [number, number];
172
+ /**
173
+ * Return `true` if `x` is a Complex. This shim calls the core `isComplex` check.
174
+ *
175
+ * @param x - The value to check.
176
+ * @returns `true` if `x` is a Complex.
177
+ */
178
+ export declare function isComplex_(x: unknown): x is Complex;
179
+ /**
180
+ * Return `true` if `x` is a Fraction. This shim calls the core `isFraction` check.
181
+ *
182
+ * @param x - The value to check.
183
+ * @returns `true` if `x` is a Fraction.
184
+ */
185
+ export declare function isFraction_(x: unknown): x is Fraction;
186
+ /**
187
+ * Return `true` if `x` is a BigNumber. This shim calls the core `isBigNumber` check.
188
+ *
189
+ * @param x - The value to check.
190
+ * @returns `true` if `x` is a BigNumber.
191
+ */
192
+ export declare function isBigNumber_(x: unknown): x is BigNumber;
193
+ /**
194
+ * Return `true` if `x` is a number. This shim calls the core `isNumber` check.
195
+ *
196
+ * @param x - The value to check.
197
+ * @returns `true` if `x` is a number.
198
+ */
199
+ export declare function isNumber_(x: unknown): x is number;
200
+ /**
201
+ * Return `true` if `x` is a DenseMatrix or a SparseMatrix instance.
202
+ *
203
+ * A nested array gives `false`.
204
+ *
205
+ * @param x - The value to check.
206
+ * @returns `true` if `x` is a DenseMatrix or a SparseMatrix.
207
+ */
208
+ export declare function isMatrix(x: unknown): x is DenseMatrix | SparseMatrix;
209
+ export declare const i: Complex;
210
+ export declare const pi: number;
211
+ export declare const e: number;
212
+ export declare const phi: number;
213
+ export declare const tau: number;
214
+ export declare const LN2: number;
215
+ export declare const LN10: number;
216
+ export declare const LOG2E: number;
217
+ export declare const LOG10E: number;
218
+ export declare const SQRT2: number;
219
+ export declare const SQRT1_2: number;
220
+ export declare const Infinity_: number;
221
+ export declare const NaN_: number;
222
+ export declare const shims: {
223
+ complex: typeof complex;
224
+ fraction: typeof fraction;
225
+ bignumber: typeof bignumber;
226
+ matrix: typeof matrix;
227
+ sparse: typeof sparse;
228
+ add: import("typed-function").TypedFunction;
229
+ subtract: import("typed-function").TypedFunction;
230
+ multiply: import("typed-function").TypedFunction;
231
+ divide: import("typed-function").TypedFunction;
232
+ pow: import("typed-function").TypedFunction;
233
+ sqrt: import("typed-function").TypedFunction;
234
+ abs: import("typed-function").TypedFunction;
235
+ exp: import("typed-function").TypedFunction;
236
+ log: import("typed-function").TypedFunction;
237
+ sin: import("typed-function").TypedFunction;
238
+ cos: import("typed-function").TypedFunction;
239
+ tan: import("typed-function").TypedFunction;
240
+ asin: typeof asin;
241
+ acos: typeof acos;
242
+ atan: typeof atan;
243
+ atan2: typeof atan2;
244
+ sum: import("typed-function").TypedFunction;
245
+ mean: import("typed-function").TypedFunction;
246
+ std: typeof std;
247
+ variance: typeof variance;
248
+ min: import("typed-function").TypedFunction;
249
+ max: import("typed-function").TypedFunction;
250
+ gcd: import("typed-function").TypedFunction;
251
+ lcm: import("typed-function").TypedFunction;
252
+ round: import("typed-function").TypedFunction;
253
+ floor: import("typed-function").TypedFunction;
254
+ ceil: import("typed-function").TypedFunction;
255
+ conj: typeof conj;
256
+ re: typeof re;
257
+ im: typeof im;
258
+ arg: typeof arg;
259
+ transpose: typeof transpose;
260
+ det: typeof det;
261
+ identity: typeof identity;
262
+ zeros: typeof zeros;
263
+ ones: typeof ones;
264
+ size: typeof size;
265
+ isComplex: typeof isComplex_;
266
+ isFraction: typeof isFraction_;
267
+ isBigNumber: typeof isBigNumber_;
268
+ isNumber: typeof isNumber_;
269
+ isMatrix: typeof isMatrix;
270
+ i: Complex;
271
+ pi: number;
272
+ e: number;
273
+ phi: number;
274
+ tau: number;
275
+ LN2: number;
276
+ LN10: number;
277
+ LOG2E: number;
278
+ LOG10E: number;
279
+ SQRT2: number;
280
+ SQRT1_2: number;
281
+ Infinity: number;
282
+ NaN: number;
283
+ };
284
+ export {};
285
+ //# sourceMappingURL=shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shims.d.ts","sourceRoot":"","sources":["../src/shims.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EAaV,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,GAAG,IAAI,IAAI,EACX,QAAQ,IAAI,SAAS,EACrB,QAAQ,IAAI,SAAS,EAmBtB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,WAAW,EACX,YAAY,EAIb,MAAM,8B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,EAAE,QAAU,CAAC;AAC1B,eAAO,MAAM,CAAC,QAAS,CAAC;AACxB,eAAO,MAAM,GAAG,QAAyB,CAAC;AAC1C,eAAO,MAAM,GAAG,QAAc,CAAC;AAC/B,eAAO,MAAM,GAAG,QAAW,CAAC;AAC5B,eAAO,MAAM,IAAI,QAAY,CAAC;AAC9B,eAAO,MAAM,KAAK,QAAa,CAAC;AAChC,eAAO,MAAM,MAAM,QAAc,CAAC;AAClC,eAAO,MAAM,KAAK,QAAa,CAAC;AAChC,eAAO,MAAM,OAAO,QAAe,CAAC;AACpC,eAAO,MAAM,SAAS,QAAW,CAAC;AAClC,eAAO,MAAM,IAAI,QAAM,CAAC;AAMxB,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFjB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-compat",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "description": "mathjs compatibility layer for MathTS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,24 +16,24 @@
16
16
  "README.md"
17
17
  ],
18
18
  "scripts": {
19
- "build": "tsup src/index.ts --format esm --dts --clean",
19
+ "build": "tsup src/index.ts --format esm --clean && tsc -p tsconfig.dts.json",
20
20
  "dev": "tsup src/index.ts --format esm --dts --watch",
21
21
  "typecheck": "tsc --noEmit",
22
- "test": "vitest run",
23
- "test:coverage": "vitest run --coverage",
22
+ "test": "bun test --isolate --timeout 30000",
23
+ "test:coverage": "bun test --isolate --timeout 30000 --coverage",
24
24
  "build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
25
25
  },
26
26
  "dependencies": {
27
- "@danielsimonjr/mathts-core": "^0.14.1",
28
- "@danielsimonjr/mathts-functions": "^0.64.0",
29
- "@danielsimonjr/mathts-matrix": "^0.7.1",
30
- "@danielsimonjr/mathts-parallel": "^0.6.4"
27
+ "@danielsimonjr/mathts-core": "^0.15.0",
28
+ "@danielsimonjr/mathts-functions": "^0.64.1",
29
+ "@danielsimonjr/mathts-matrix": "^0.7.2",
30
+ "@danielsimonjr/mathts-parallel": "^0.6.5"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^26.2.0",
33
+ "@types/node": "^26.4.0",
34
34
  "tsup": "^8.0.0",
35
- "typescript": "^5.3.0",
36
- "vitest": "^4.1.10"
35
+ "typescript": "^7.0.2",
36
+ "vitest": "^5.0.0"
37
37
  },
38
38
  "keywords": [
39
39
  "math",