numpy-ts 0.10.0 → 0.12.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.
@@ -5,6 +5,7 @@
5
5
  * @module ops/linalg
6
6
  */
7
7
  import { ArrayStorage } from '../core/storage';
8
+ import { Complex } from '../core/complex';
8
9
  /**
9
10
  * Dot product of two arrays (fully NumPy-compatible)
10
11
  *
@@ -21,7 +22,7 @@ import { ArrayStorage } from '../core/storage';
21
22
  *
22
23
  * For 2D·2D, prefer using matmul() instead.
23
24
  */
24
- export declare function dot(a: ArrayStorage, b: ArrayStorage): ArrayStorage | number | bigint;
25
+ export declare function dot(a: ArrayStorage, b: ArrayStorage): ArrayStorage | number | bigint | Complex;
25
26
  /**
26
27
  * Matrix multiplication
27
28
  * Requires 2D arrays with compatible shapes
@@ -42,7 +43,7 @@ export declare function matmul(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
42
43
  * @param a - Input 2D array
43
44
  * @returns Sum of diagonal elements
44
45
  */
45
- export declare function trace(a: ArrayStorage): number | bigint;
46
+ export declare function trace(a: ArrayStorage): number | bigint | Complex;
46
47
  /**
47
48
  * Permute the dimensions of an array
48
49
  *
@@ -67,7 +68,7 @@ export declare function transpose(a: ArrayStorage, axes?: number[]): ArrayStorag
67
68
  * @param b - Second array
68
69
  * @returns Inner product result
69
70
  */
70
- export declare function inner(a: ArrayStorage, b: ArrayStorage): ArrayStorage | number | bigint;
71
+ export declare function inner(a: ArrayStorage, b: ArrayStorage): ArrayStorage | number | bigint | Complex;
71
72
  /**
72
73
  * Outer product of two vectors
73
74
  *
@@ -91,7 +92,7 @@ export declare function outer(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
91
92
  * - [a_axes, b_axes]: Contract specified axes
92
93
  * @returns Tensor dot product
93
94
  */
94
- export declare function tensordot(a: ArrayStorage, b: ArrayStorage, axes: number | [number[], number[]]): ArrayStorage | number | bigint;
95
+ export declare function tensordot(a: ArrayStorage, b: ArrayStorage, axes: number | [number[], number[]]): ArrayStorage | number | bigint | Complex;
95
96
  /**
96
97
  * Extract a diagonal or construct a diagonal array.
97
98
  *
@@ -126,7 +127,7 @@ export declare function diagonal(a: ArrayStorage, offset?: number, axis1?: numbe
126
127
  * @param operands - Input arrays
127
128
  * @returns Result of the Einstein summation
128
129
  */
129
- export declare function einsum(subscripts: string, ...operands: ArrayStorage[]): ArrayStorage | number | bigint;
130
+ export declare function einsum(subscripts: string, ...operands: ArrayStorage[]): ArrayStorage | number | bigint | Complex;
130
131
  /**
131
132
  * Kronecker product of two arrays.
132
133
  *
@@ -363,4 +364,128 @@ export declare function eigvals(a: ArrayStorage): ArrayStorage;
363
364
  * @returns Array of eigenvalues (sorted ascending)
364
365
  */
365
366
  export declare function eigvalsh(a: ArrayStorage, UPLO?: 'L' | 'U'): ArrayStorage;
367
+ /**
368
+ * Return the dot product of two vectors (flattened).
369
+ *
370
+ * Unlike dot(), vdot flattens both inputs before computing the dot product.
371
+ * For complex numbers, vdot uses the complex conjugate of the first argument.
372
+ *
373
+ * @param a - First input array (will be flattened)
374
+ * @param b - Second input array (will be flattened)
375
+ * @returns Scalar dot product
376
+ */
377
+ export declare function vdot(a: ArrayStorage, b: ArrayStorage): number | bigint | Complex;
378
+ /**
379
+ * Vector dot product along the last axis.
380
+ *
381
+ * Computes the dot product of vectors along the last axis of both inputs.
382
+ * The last dimensions of a and b must match.
383
+ *
384
+ * @param a - First input array
385
+ * @param b - Second input array
386
+ * @param axis - Axis along which to compute (default: -1, meaning last axis)
387
+ * @returns Result with last dimension removed
388
+ */
389
+ export declare function vecdot(a: ArrayStorage, b: ArrayStorage, axis?: number): ArrayStorage | number | bigint | Complex;
390
+ /**
391
+ * Transpose the last two axes of an array.
392
+ *
393
+ * Equivalent to swapaxes(a, -2, -1) or transpose with axes that swap the last two.
394
+ * For a 2D array, this is the same as transpose.
395
+ *
396
+ * @param a - Input array with at least 2 dimensions
397
+ * @returns Array with last two axes transposed
398
+ */
399
+ export declare function matrix_transpose(a: ArrayStorage): ArrayStorage;
400
+ /**
401
+ * Permute the dimensions of an array.
402
+ *
403
+ * This is an alias for transpose to match the Array API standard.
404
+ *
405
+ * @param a - Input array
406
+ * @param axes - Permutation of axes. If not specified, reverses the axes.
407
+ * @returns Transposed array
408
+ */
409
+ export declare function permute_dims(a: ArrayStorage, axes?: number[]): ArrayStorage;
410
+ /**
411
+ * Matrix-vector multiplication.
412
+ *
413
+ * Computes the matrix-vector product over the last two axes of x1 and
414
+ * the last axis of x2.
415
+ *
416
+ * @param x1 - First input array (matrix) with shape (..., M, N)
417
+ * @param x2 - Second input array (vector) with shape (..., N)
418
+ * @returns Result with shape (..., M)
419
+ */
420
+ export declare function matvec(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
421
+ /**
422
+ * Vector-matrix multiplication.
423
+ *
424
+ * Computes the vector-matrix product over the last axis of x1 and
425
+ * the second-to-last axis of x2.
426
+ *
427
+ * @param x1 - First input array (vector) with shape (..., M)
428
+ * @param x2 - Second input array (matrix) with shape (..., M, N)
429
+ * @returns Result with shape (..., N)
430
+ */
431
+ export declare function vecmat(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
432
+ /**
433
+ * Compute sign and (natural) logarithm of the determinant.
434
+ *
435
+ * Returns (sign, logabsdet) where sign is the sign of the determinant
436
+ * and logabsdet is the natural log of the absolute value of the determinant.
437
+ *
438
+ * This is useful for computing determinants of large matrices where the
439
+ * determinant itself might overflow or underflow.
440
+ *
441
+ * @param a - Square matrix
442
+ * @returns { sign, logabsdet }
443
+ */
444
+ export declare function slogdet(a: ArrayStorage): {
445
+ sign: number;
446
+ logabsdet: number;
447
+ };
448
+ /**
449
+ * Compute singular values of a matrix.
450
+ *
451
+ * This is equivalent to svd(a, compute_uv=False) but more efficient
452
+ * as it doesn't compute the U and V matrices.
453
+ *
454
+ * @param a - Input matrix (m x n)
455
+ * @returns 1D array of singular values in descending order
456
+ */
457
+ export declare function svdvals(a: ArrayStorage): ArrayStorage;
458
+ /**
459
+ * Compute the dot product of two or more arrays in a single function call.
460
+ *
461
+ * Optimizes the order of multiplications to minimize computation.
462
+ * For example, for three arrays A, B, C with shapes (10, 100), (100, 5), (5, 50),
463
+ * it's more efficient to compute (A @ B) @ C than A @ (B @ C).
464
+ *
465
+ * @param arrays - List of arrays to multiply
466
+ * @returns Result of multiplying all arrays
467
+ */
468
+ export declare function multi_dot(arrays: ArrayStorage[]): ArrayStorage;
469
+ /**
470
+ * Compute the 'inverse' of an N-dimensional array.
471
+ *
472
+ * The inverse is defined such that tensordot(tensorinv(a), a, ind) == I
473
+ * where I is the identity operator.
474
+ *
475
+ * @param a - Input array to invert
476
+ * @param ind - Number of first indices that are involved in the inverse sum (default: 2)
477
+ * @returns Tensor inverse
478
+ */
479
+ export declare function tensorinv(a: ArrayStorage, ind?: number): ArrayStorage;
480
+ /**
481
+ * Solve the tensor equation a x = b for x.
482
+ *
483
+ * This is equivalent to solve after reshaping a and b appropriately.
484
+ *
485
+ * @param a - Coefficient tensor
486
+ * @param b - Target tensor
487
+ * @param axes - Axes of a to be summed over in the contraction (default based on b.ndim)
488
+ * @returns Solution tensor x
489
+ */
490
+ export declare function tensorsolve(a: ArrayStorage, b: ArrayStorage, axes?: number[] | null): ArrayStorage;
366
491
  //# sourceMappingURL=linalg.d.ts.map
@@ -56,6 +56,8 @@ export declare function logical_xor(a: ArrayStorage, b: ArrayStorage | number):
56
56
  /**
57
57
  * Test element-wise for finiteness (not infinity and not NaN)
58
58
  *
59
+ * For complex numbers: True if both real and imaginary parts are finite.
60
+ *
59
61
  * @param a - Input array storage
60
62
  * @returns Boolean result storage
61
63
  */
@@ -63,6 +65,8 @@ export declare function isfinite(a: ArrayStorage): ArrayStorage;
63
65
  /**
64
66
  * Test element-wise for positive or negative infinity
65
67
  *
68
+ * For complex numbers: True if either real or imaginary part is infinite.
69
+ *
66
70
  * @param a - Input array storage
67
71
  * @returns Boolean result storage
68
72
  */
@@ -70,6 +74,8 @@ export declare function isinf(a: ArrayStorage): ArrayStorage;
70
74
  /**
71
75
  * Test element-wise for NaN (Not a Number)
72
76
  *
77
+ * For complex numbers: True if either real or imaginary part is NaN.
78
+ *
73
79
  * @param a - Input array storage
74
80
  * @returns Boolean result storage
75
81
  */
@@ -119,41 +125,53 @@ export declare function nextafter(x1: ArrayStorage, x2: ArrayStorage | number):
119
125
  */
120
126
  export declare function spacing(a: ArrayStorage): ArrayStorage;
121
127
  /**
122
- * Test element-wise for complex number
123
- * Since numpy-ts doesn't support complex numbers, always returns false
128
+ * Test element-wise for complex number.
129
+ *
130
+ * For complex arrays, returns true for elements with non-zero imaginary part.
131
+ * For real arrays, always returns false.
132
+ *
124
133
  * @param a - Input array storage
125
- * @returns Boolean array (all false)
134
+ * @returns Boolean array
126
135
  */
127
136
  export declare function iscomplex(a: ArrayStorage): ArrayStorage;
128
137
  /**
129
- * Check whether object is complex type array
130
- * Since numpy-ts doesn't support complex numbers, always returns false
131
- * @param _a - Input array storage (unused)
132
- * @returns false
138
+ * Check whether object is complex type array.
139
+ *
140
+ * @param a - Input array storage
141
+ * @returns true if dtype is complex64 or complex128
133
142
  */
134
- export declare function iscomplexobj(_a: ArrayStorage): boolean;
143
+ export declare function iscomplexobj(a: ArrayStorage): boolean;
135
144
  /**
136
- * Test element-wise for real number (not complex)
137
- * Since numpy-ts doesn't support complex numbers, always returns true
145
+ * Test element-wise for real number (not complex).
146
+ *
147
+ * For complex arrays, returns true for elements with zero imaginary part.
148
+ * For real arrays, always returns true.
149
+ *
138
150
  * @param a - Input array storage
139
- * @returns Boolean array (all true)
151
+ * @returns Boolean array
140
152
  */
141
153
  export declare function isreal(a: ArrayStorage): ArrayStorage;
142
154
  /**
143
- * Check whether object is real type array (not complex)
144
- * Since numpy-ts doesn't support complex numbers, always returns true
145
- * @param _a - Input array storage (unused)
146
- * @returns true
155
+ * Check whether object is real type array (not complex).
156
+ *
157
+ * @param a - Input array storage
158
+ * @returns true if dtype is NOT complex64 or complex128
147
159
  */
148
- export declare function isrealobj(_a: ArrayStorage): boolean;
160
+ export declare function isrealobj(a: ArrayStorage): boolean;
149
161
  /**
150
162
  * Test element-wise for negative infinity
163
+ *
164
+ * For complex numbers: True if either real or imaginary part is -Infinity.
165
+ *
151
166
  * @param a - Input array storage
152
167
  * @returns Boolean array
153
168
  */
154
169
  export declare function isneginf(a: ArrayStorage): ArrayStorage;
155
170
  /**
156
171
  * Test element-wise for positive infinity
172
+ *
173
+ * For complex numbers: True if either real or imaginary part is +Infinity.
174
+ *
157
175
  * @param a - Input array storage
158
176
  * @returns Boolean array
159
177
  */
@@ -171,7 +189,7 @@ export declare function isfortran(a: ArrayStorage): boolean;
171
189
  * @param _tol - Tolerance (unused, for API compatibility)
172
190
  * @returns Copy of input array
173
191
  */
174
- export declare function real_if_close(a: ArrayStorage, _tol?: number): ArrayStorage;
192
+ export declare function real_if_close(a: ArrayStorage, tol?: number): ArrayStorage;
175
193
  /**
176
194
  * Check if element is a scalar type
177
195
  * @param val - Value to check
@@ -5,30 +5,29 @@
5
5
  * @module ops/reduction
6
6
  */
7
7
  import { ArrayStorage } from '../core/storage';
8
+ import { Complex } from '../core/complex';
8
9
  /**
9
10
  * Sum array elements over a given axis
10
11
  */
11
- export declare function sum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
12
+ export declare function sum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
12
13
  /**
13
14
  * Compute the arithmetic mean along the specified axis
14
15
  * Note: mean() returns float64 for integer dtypes, matching NumPy behavior
16
+ * For complex arrays, returns complex mean
15
17
  */
16
- export declare function mean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
18
+ export declare function mean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
17
19
  /**
18
20
  * Return the maximum along a given axis
19
21
  */
20
- export declare function max(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
22
+ export declare function max(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
21
23
  /**
22
24
  * Product array elements over a given axis
23
25
  */
24
- export declare function prod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
26
+ export declare function prod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
25
27
  /**
26
28
  * Return the minimum along a given axis
27
29
  */
28
- export declare function min(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
29
- /**
30
- * Return the indices of the minimum values along a given axis
31
- */
30
+ export declare function min(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
32
31
  export declare function argmin(storage: ArrayStorage, axis?: number): ArrayStorage | number;
33
32
  /**
34
33
  * Return the indices of the maximum values along a given axis
@@ -40,6 +39,9 @@ export declare function argmax(storage: ArrayStorage, axis?: number): ArrayStora
40
39
  * @param axis - Axis along which to compute variance
41
40
  * @param ddof - Delta degrees of freedom (default: 0)
42
41
  * @param keepdims - Keep dimensions (default: false)
42
+ *
43
+ * For complex arrays: Var(X) = E[|X - E[X]|²] where |z|² = re² + im²
44
+ * Returns real values (float64) for both real and complex input
43
45
  */
44
46
  export declare function variance(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
45
47
  /**
@@ -48,6 +50,9 @@ export declare function variance(storage: ArrayStorage, axis?: number, ddof?: nu
48
50
  * @param axis - Axis along which to compute std
49
51
  * @param ddof - Delta degrees of freedom (default: 0)
50
52
  * @param keepdims - Keep dimensions (default: false)
53
+ *
54
+ * For complex arrays: returns sqrt(Var(X)) where Var(X) = E[|X - E[X]|²]
55
+ * Returns real values (float64) for both real and complex input
51
56
  */
52
57
  export declare function std(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
53
58
  /**
@@ -60,16 +65,19 @@ export declare function all(storage: ArrayStorage, axis?: number, keepdims?: boo
60
65
  export declare function any(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | boolean;
61
66
  /**
62
67
  * Return cumulative sum of elements along a given axis
68
+ * For complex arrays: returns complex cumulative sum
63
69
  */
64
70
  export declare function cumsum(storage: ArrayStorage, axis?: number): ArrayStorage;
65
71
  /**
66
72
  * Return cumulative product of elements along a given axis
73
+ * For complex arrays: returns complex cumulative product
74
+ * Complex multiplication: (a+bi)(c+di) = (ac-bd) + (ad+bc)i
67
75
  */
68
76
  export declare function cumprod(storage: ArrayStorage, axis?: number): ArrayStorage;
69
77
  /**
70
78
  * Peak to peak (maximum - minimum) value along a given axis
71
79
  */
72
- export declare function ptp(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
80
+ export declare function ptp(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
73
81
  /**
74
82
  * Compute the median along the specified axis
75
83
  */
@@ -85,41 +93,40 @@ export declare function quantile(storage: ArrayStorage, q: number, axis?: number
85
93
  /**
86
94
  * Compute the weighted average along the specified axis
87
95
  */
88
- export declare function average(storage: ArrayStorage, axis?: number, weights?: ArrayStorage, keepdims?: boolean): ArrayStorage | number;
89
- /**
90
- * Return sum of elements, treating NaNs as zero
91
- */
92
- export declare function nansum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
96
+ export declare function average(storage: ArrayStorage, axis?: number, weights?: ArrayStorage, keepdims?: boolean): ArrayStorage | number | Complex;
97
+ export declare function nansum(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
93
98
  /**
94
99
  * Return product of elements, treating NaNs as one
95
100
  */
96
- export declare function nanprod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
101
+ export declare function nanprod(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
97
102
  /**
98
103
  * Compute mean ignoring NaN values
99
104
  */
100
- export declare function nanmean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
105
+ export declare function nanmean(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
101
106
  /**
102
107
  * Compute variance ignoring NaN values
103
108
  */
104
109
  export declare function nanvar(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
105
110
  /**
106
111
  * Compute standard deviation ignoring NaN values
112
+ * For complex arrays: returns sqrt of variance (always real values)
107
113
  */
108
114
  export declare function nanstd(storage: ArrayStorage, axis?: number, ddof?: number, keepdims?: boolean): ArrayStorage | number;
109
115
  /**
110
116
  * Return minimum ignoring NaN values
111
117
  */
112
- export declare function nanmin(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
118
+ export declare function nanmin(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
113
119
  /**
114
120
  * Return maximum ignoring NaN values
115
121
  */
116
- export declare function nanmax(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
122
+ export declare function nanmax(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number | Complex;
117
123
  /**
118
124
  * Return indices of minimum value, ignoring NaNs
119
125
  */
120
126
  export declare function nanargmin(storage: ArrayStorage, axis?: number): ArrayStorage | number;
121
127
  /**
122
128
  * Return indices of maximum value, ignoring NaNs
129
+ * For complex arrays: uses lexicographic ordering (real first, then imaginary)
123
130
  */
124
131
  export declare function nanargmax(storage: ArrayStorage, axis?: number): ArrayStorage | number;
125
132
  /**
@@ -128,10 +135,19 @@ export declare function nanargmax(storage: ArrayStorage, axis?: number): ArraySt
128
135
  export declare function nancumsum(storage: ArrayStorage, axis?: number): ArrayStorage;
129
136
  /**
130
137
  * Return cumulative product, treating NaNs as one
138
+ * For complex arrays: NaN values (either part NaN) are treated as 1+0i
131
139
  */
132
140
  export declare function nancumprod(storage: ArrayStorage, axis?: number): ArrayStorage;
133
141
  /**
134
142
  * Compute median ignoring NaN values
135
143
  */
136
144
  export declare function nanmedian(storage: ArrayStorage, axis?: number, keepdims?: boolean): ArrayStorage | number;
145
+ /**
146
+ * Compute the q-th quantile of data along specified axis, ignoring NaNs
147
+ */
148
+ export declare function nanquantile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
149
+ /**
150
+ * Compute the q-th percentile of data along specified axis, ignoring NaNs
151
+ */
152
+ export declare function nanpercentile(storage: ArrayStorage, q: number, axis?: number, keepdims?: boolean): ArrayStorage | number;
137
153
  //# sourceMappingURL=reduction.d.ts.map
@@ -3,6 +3,9 @@
3
3
  *
4
4
  * Pure functions for element-wise rounding operations:
5
5
  * around, ceil, fix, floor, rint, round, trunc
6
+ *
7
+ * Note: Rounding operations are not defined for complex numbers.
8
+ * All functions throw TypeError for complex dtypes.
6
9
  */
7
10
  import { ArrayStorage } from '../core/storage';
8
11
  /**
@@ -35,4 +35,53 @@ export declare function setxor1d(ar1: ArrayStorage, ar2: ArrayStorage): ArraySto
35
35
  * Find the union of two arrays
36
36
  */
37
37
  export declare function union1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
38
+ /**
39
+ * Trim leading and/or trailing zeros from a 1-D array.
40
+ *
41
+ * @param filt - Input 1-D array
42
+ * @param trim - 'fb' to trim front and back, 'f' for front only, 'b' for back only (default: 'fb')
43
+ * @returns Trimmed array
44
+ */
45
+ export declare function trim_zeros(filt: ArrayStorage, trim?: 'f' | 'b' | 'fb'): ArrayStorage;
46
+ /**
47
+ * Find the unique elements of an array, returning all optional outputs.
48
+ *
49
+ * @param x - Input array (flattened for uniqueness)
50
+ * @returns Object with values, indices, inverse_indices, and counts
51
+ */
52
+ export declare function unique_all(x: ArrayStorage): {
53
+ values: ArrayStorage;
54
+ indices: ArrayStorage;
55
+ inverse_indices: ArrayStorage;
56
+ counts: ArrayStorage;
57
+ };
58
+ /**
59
+ * Find the unique elements of an array and their counts.
60
+ *
61
+ * @param x - Input array (flattened for uniqueness)
62
+ * @returns Object with values and counts
63
+ */
64
+ export declare function unique_counts(x: ArrayStorage): {
65
+ values: ArrayStorage;
66
+ counts: ArrayStorage;
67
+ };
68
+ /**
69
+ * Find the unique elements of an array and their inverse indices.
70
+ *
71
+ * @param x - Input array (flattened for uniqueness)
72
+ * @returns Object with values and inverse_indices
73
+ */
74
+ export declare function unique_inverse(x: ArrayStorage): {
75
+ values: ArrayStorage;
76
+ inverse_indices: ArrayStorage;
77
+ };
78
+ /**
79
+ * Find the unique elements of an array (values only).
80
+ *
81
+ * This is equivalent to unique(x) but with a clearer name for the Array API.
82
+ *
83
+ * @param x - Input array (flattened for uniqueness)
84
+ * @returns Array of unique values, sorted
85
+ */
86
+ export declare function unique_values(x: ArrayStorage): ArrayStorage;
38
87
  //# sourceMappingURL=sets.d.ts.map
@@ -141,4 +141,17 @@ export declare function atleast2d(storages: ArrayStorage[]): ArrayStorage[];
141
141
  * Convert arrays to at least 3D
142
142
  */
143
143
  export declare function atleast3d(storages: ArrayStorage[]): ArrayStorage[];
144
+ /**
145
+ * Alias for concatenate
146
+ */
147
+ export declare function concat(storages: ArrayStorage[], axis?: number): ArrayStorage;
148
+ /**
149
+ * Split an array into a sequence of sub-arrays along an axis (inverse of stack)
150
+ */
151
+ export declare function unstack(storage: ArrayStorage, axis?: number): ArrayStorage[];
152
+ /**
153
+ * Assemble an nd-array from nested lists of blocks
154
+ * For a simple list [a, b] of nD arrays, concatenates along the last axis (like np.block)
155
+ */
156
+ export declare function block(storages: ArrayStorage[], _depth?: number): ArrayStorage;
144
157
  //# sourceMappingURL=shape.d.ts.map
@@ -105,4 +105,26 @@ export declare function cov(m: ArrayStorage, y?: ArrayStorage, rowvar?: boolean,
105
105
  * @returns Correlation coefficient matrix
106
106
  */
107
107
  export declare function corrcoef(x: ArrayStorage, y?: ArrayStorage, rowvar?: boolean): ArrayStorage;
108
+ /**
109
+ * Compute the edges of the bins for histogram.
110
+ *
111
+ * This function computes the bin edges without computing the histogram itself.
112
+ *
113
+ * @param a - Input data (flattened if not 1D)
114
+ * @param bins - Number of bins (default: 10) or a string specifying the bin algorithm
115
+ * @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
116
+ * @param weights - Optional weights for each data point (used for some algorithms)
117
+ * @returns Array of bin edges (length = bins + 1)
118
+ */
119
+ export declare function histogram_bin_edges(a: ArrayStorage, bins?: number | 'auto' | 'fd' | 'doane' | 'scott' | 'stone' | 'rice' | 'sturges' | 'sqrt', range?: [number, number], _weights?: ArrayStorage): ArrayStorage;
120
+ /**
121
+ * Integrate along the given axis using the composite trapezoidal rule.
122
+ *
123
+ * @param y - Input array to integrate
124
+ * @param x - Optional sample points corresponding to y values. If not provided, spacing is assumed to be 1.
125
+ * @param dx - Spacing between sample points when x is not given (default: 1.0)
126
+ * @param axis - The axis along which to integrate (default: -1, meaning last axis)
127
+ * @returns Definite integral approximated using the composite trapezoidal rule
128
+ */
129
+ export declare function trapezoid(y: ArrayStorage, x?: ArrayStorage, dx?: number, axis?: number): ArrayStorage | number;
108
130
  //# sourceMappingURL=statistics.d.ts.map
@@ -11,6 +11,7 @@ import { ArrayStorage } from '../core/storage';
11
11
  /**
12
12
  * Sine of each element (element-wise)
13
13
  * NumPy behavior: Always promotes to float64 for integer types
14
+ * For complex: sin(a+bi) = sin(a)cosh(b) + i*cos(a)sinh(b)
14
15
  *
15
16
  * @param a - Input array storage (angles in radians)
16
17
  * @returns Result storage with sin applied
@@ -19,6 +20,7 @@ export declare function sin(a: ArrayStorage): ArrayStorage;
19
20
  /**
20
21
  * Cosine of each element (element-wise)
21
22
  * NumPy behavior: Always promotes to float64 for integer types
23
+ * For complex: cos(a+bi) = cos(a)cosh(b) - i*sin(a)sinh(b)
22
24
  *
23
25
  * @param a - Input array storage (angles in radians)
24
26
  * @returns Result storage with cos applied
@@ -27,6 +29,7 @@ export declare function cos(a: ArrayStorage): ArrayStorage;
27
29
  /**
28
30
  * Tangent of each element (element-wise)
29
31
  * NumPy behavior: Always promotes to float64 for integer types
32
+ * For complex: tan(a+bi) = (sin(2a) + i*sinh(2b)) / (cos(2a) + cosh(2b))
30
33
  *
31
34
  * @param a - Input array storage (angles in radians)
32
35
  * @returns Result storage with tan applied
@@ -35,6 +38,7 @@ export declare function tan(a: ArrayStorage): ArrayStorage;
35
38
  /**
36
39
  * Inverse sine of each element (element-wise)
37
40
  * NumPy behavior: Always promotes to float64 for integer types
41
+ * For complex: arcsin(z) = -i * log(iz + sqrt(1 - z²))
38
42
  *
39
43
  * @param a - Input array storage (values in range [-1, 1])
40
44
  * @returns Result storage with arcsin applied (radians)
@@ -43,6 +47,7 @@ export declare function arcsin(a: ArrayStorage): ArrayStorage;
43
47
  /**
44
48
  * Inverse cosine of each element (element-wise)
45
49
  * NumPy behavior: Always promotes to float64 for integer types
50
+ * For complex: arccos(z) = -i * log(z + i*sqrt(1 - z²))
46
51
  *
47
52
  * @param a - Input array storage (values in range [-1, 1])
48
53
  * @returns Result storage with arccos applied (radians)
@@ -51,6 +56,7 @@ export declare function arccos(a: ArrayStorage): ArrayStorage;
51
56
  /**
52
57
  * Inverse tangent of each element (element-wise)
53
58
  * NumPy behavior: Always promotes to float64 for integer types
59
+ * For complex: arctan(z) = (i/2) * log((1 - iz) / (1 + iz))
54
60
  *
55
61
  * @param a - Input array storage
56
62
  * @returns Result storage with arctan applied (radians)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "numpy-ts",
3
- "version": "0.10.0",
4
- "description": "Complete NumPy implementation for TypeScript and JavaScript (under construction)",
3
+ "version": "0.12.0",
4
+ "description": "Complete NumPy implementation for TypeScript and JavaScript (81% API coverage)",
5
5
  "main": "dist/numpy-ts.node.cjs",
6
6
  "browser": "dist/numpy-ts.browser.js",
7
7
  "module": "dist/numpy-ts.esm.js",
@@ -105,7 +105,7 @@
105
105
  "@vitest/coverage-v8": "^4.0.3",
106
106
  "chart.js": "^4.5.1",
107
107
  "chartjs-node-canvas": "^5.0.0",
108
- "esbuild": "^0.25.11",
108
+ "esbuild": "^0.27.2",
109
109
  "eslint": "^9.38.0",
110
110
  "eslint-config-prettier": "^10.1.8",
111
111
  "eslint-plugin-prettier": "^5.0.1",