numpy-ts 0.4.0 → 0.6.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.
- package/README.md +200 -294
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -0
- package/dist/numpy-ts.node-io.cjs.map +7 -0
- package/dist/numpy-ts.node-io.mjs +3 -0
- package/dist/numpy-ts.node-io.mjs.map +7 -0
- package/dist/numpy-ts.node.cjs +2 -1
- package/dist/numpy-ts.node.cjs.map +7 -0
- package/dist/types/core/broadcasting.d.ts +18 -0
- package/dist/types/core/ndarray.d.ts +1109 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/io/index.d.ts +17 -0
- package/dist/types/io/npy/format.d.ts +91 -0
- package/dist/types/io/npy/index.d.ts +7 -0
- package/dist/types/io/npy/parser.d.ts +28 -0
- package/dist/types/io/npy/serializer.d.ts +17 -0
- package/dist/types/io/npz/index.d.ts +6 -0
- package/dist/types/io/npz/parser.d.ts +57 -0
- package/dist/types/io/npz/serializer.d.ts +49 -0
- package/dist/types/io/zip/index.d.ts +7 -0
- package/dist/types/io/zip/reader.d.ts +22 -0
- package/dist/types/io/zip/types.d.ts +59 -0
- package/dist/types/io/zip/writer.d.ts +29 -0
- package/dist/types/node.d.ts +154 -0
- package/dist/types/ops/advanced.d.ts +40 -0
- package/dist/types/ops/arithmetic.d.ts +54 -0
- package/dist/types/ops/comparison.d.ts +12 -0
- package/dist/types/ops/hyperbolic.d.ts +59 -0
- package/dist/types/ops/linalg.d.ts +51 -0
- package/dist/types/ops/reduction.d.ts +76 -0
- package/dist/types/ops/shape.d.ts +105 -0
- package/dist/types/ops/trig.d.ts +110 -0
- package/package.json +22 -9
|
@@ -135,6 +135,101 @@ export declare class NDArray {
|
|
|
135
135
|
* @returns New array with signs
|
|
136
136
|
*/
|
|
137
137
|
sign(): NDArray;
|
|
138
|
+
/**
|
|
139
|
+
* Sine of each element (in radians)
|
|
140
|
+
* Promotes integer types to float64
|
|
141
|
+
* @returns New array with sine values
|
|
142
|
+
*/
|
|
143
|
+
sin(): NDArray;
|
|
144
|
+
/**
|
|
145
|
+
* Cosine of each element (in radians)
|
|
146
|
+
* Promotes integer types to float64
|
|
147
|
+
* @returns New array with cosine values
|
|
148
|
+
*/
|
|
149
|
+
cos(): NDArray;
|
|
150
|
+
/**
|
|
151
|
+
* Tangent of each element (in radians)
|
|
152
|
+
* Promotes integer types to float64
|
|
153
|
+
* @returns New array with tangent values
|
|
154
|
+
*/
|
|
155
|
+
tan(): NDArray;
|
|
156
|
+
/**
|
|
157
|
+
* Inverse sine of each element
|
|
158
|
+
* Promotes integer types to float64
|
|
159
|
+
* @returns New array with arcsin values (radians)
|
|
160
|
+
*/
|
|
161
|
+
arcsin(): NDArray;
|
|
162
|
+
/**
|
|
163
|
+
* Inverse cosine of each element
|
|
164
|
+
* Promotes integer types to float64
|
|
165
|
+
* @returns New array with arccos values (radians)
|
|
166
|
+
*/
|
|
167
|
+
arccos(): NDArray;
|
|
168
|
+
/**
|
|
169
|
+
* Inverse tangent of each element
|
|
170
|
+
* Promotes integer types to float64
|
|
171
|
+
* @returns New array with arctan values (radians)
|
|
172
|
+
*/
|
|
173
|
+
arctan(): NDArray;
|
|
174
|
+
/**
|
|
175
|
+
* Element-wise arc tangent of this/other choosing the quadrant correctly
|
|
176
|
+
* @param other - x-coordinates (array or scalar)
|
|
177
|
+
* @returns Angle in radians between -π and π
|
|
178
|
+
*/
|
|
179
|
+
arctan2(other: NDArray | number): NDArray;
|
|
180
|
+
/**
|
|
181
|
+
* Given the "legs" of a right triangle, return its hypotenuse
|
|
182
|
+
* Equivalent to sqrt(this**2 + other**2), element-wise
|
|
183
|
+
* @param other - Second leg (array or scalar)
|
|
184
|
+
* @returns Hypotenuse values
|
|
185
|
+
*/
|
|
186
|
+
hypot(other: NDArray | number): NDArray;
|
|
187
|
+
/**
|
|
188
|
+
* Convert angles from radians to degrees
|
|
189
|
+
* @returns New array with angles in degrees
|
|
190
|
+
*/
|
|
191
|
+
degrees(): NDArray;
|
|
192
|
+
/**
|
|
193
|
+
* Convert angles from degrees to radians
|
|
194
|
+
* @returns New array with angles in radians
|
|
195
|
+
*/
|
|
196
|
+
radians(): NDArray;
|
|
197
|
+
/**
|
|
198
|
+
* Hyperbolic sine of each element
|
|
199
|
+
* Promotes integer types to float64
|
|
200
|
+
* @returns New array with sinh values
|
|
201
|
+
*/
|
|
202
|
+
sinh(): NDArray;
|
|
203
|
+
/**
|
|
204
|
+
* Hyperbolic cosine of each element
|
|
205
|
+
* Promotes integer types to float64
|
|
206
|
+
* @returns New array with cosh values
|
|
207
|
+
*/
|
|
208
|
+
cosh(): NDArray;
|
|
209
|
+
/**
|
|
210
|
+
* Hyperbolic tangent of each element
|
|
211
|
+
* Promotes integer types to float64
|
|
212
|
+
* @returns New array with tanh values
|
|
213
|
+
*/
|
|
214
|
+
tanh(): NDArray;
|
|
215
|
+
/**
|
|
216
|
+
* Inverse hyperbolic sine of each element
|
|
217
|
+
* Promotes integer types to float64
|
|
218
|
+
* @returns New array with arcsinh values
|
|
219
|
+
*/
|
|
220
|
+
arcsinh(): NDArray;
|
|
221
|
+
/**
|
|
222
|
+
* Inverse hyperbolic cosine of each element
|
|
223
|
+
* Promotes integer types to float64
|
|
224
|
+
* @returns New array with arccosh values
|
|
225
|
+
*/
|
|
226
|
+
arccosh(): NDArray;
|
|
227
|
+
/**
|
|
228
|
+
* Inverse hyperbolic tangent of each element
|
|
229
|
+
* Promotes integer types to float64
|
|
230
|
+
* @returns New array with arctanh values
|
|
231
|
+
*/
|
|
232
|
+
arctanh(): NDArray;
|
|
138
233
|
/**
|
|
139
234
|
* Element-wise greater than comparison
|
|
140
235
|
* @param other - Value or array to compare with
|
|
@@ -268,6 +363,137 @@ export declare class NDArray {
|
|
|
268
363
|
* @returns Boolean or array of booleans
|
|
269
364
|
*/
|
|
270
365
|
any(axis?: number, keepdims?: boolean): NDArray | boolean;
|
|
366
|
+
/**
|
|
367
|
+
* Return the cumulative sum of elements along a given axis
|
|
368
|
+
* @param axis - Axis along which to compute cumsum. If undefined, compute over flattened array.
|
|
369
|
+
* @returns Array with cumulative sums
|
|
370
|
+
*/
|
|
371
|
+
cumsum(axis?: number): NDArray;
|
|
372
|
+
/**
|
|
373
|
+
* Return the cumulative product of elements along a given axis
|
|
374
|
+
* @param axis - Axis along which to compute cumprod. If undefined, compute over flattened array.
|
|
375
|
+
* @returns Array with cumulative products
|
|
376
|
+
*/
|
|
377
|
+
cumprod(axis?: number): NDArray;
|
|
378
|
+
/**
|
|
379
|
+
* Peak to peak (maximum - minimum) value along a given axis
|
|
380
|
+
* @param axis - Axis along which to compute ptp. If undefined, compute over all elements.
|
|
381
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
382
|
+
* @returns Range of values
|
|
383
|
+
*/
|
|
384
|
+
ptp(axis?: number, keepdims?: boolean): NDArray | number;
|
|
385
|
+
/**
|
|
386
|
+
* Compute the median along the specified axis
|
|
387
|
+
* @param axis - Axis along which to compute median. If undefined, compute over all elements.
|
|
388
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
389
|
+
* @returns Median of array elements
|
|
390
|
+
*/
|
|
391
|
+
median(axis?: number, keepdims?: boolean): NDArray | number;
|
|
392
|
+
/**
|
|
393
|
+
* Compute the q-th percentile of the data along the specified axis
|
|
394
|
+
* @param q - Percentile to compute (0-100)
|
|
395
|
+
* @param axis - Axis along which to compute percentile. If undefined, compute over all elements.
|
|
396
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
397
|
+
* @returns Percentile of array elements
|
|
398
|
+
*/
|
|
399
|
+
percentile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
400
|
+
/**
|
|
401
|
+
* Compute the q-th quantile of the data along the specified axis
|
|
402
|
+
* @param q - Quantile to compute (0-1)
|
|
403
|
+
* @param axis - Axis along which to compute quantile. If undefined, compute over all elements.
|
|
404
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
405
|
+
* @returns Quantile of array elements
|
|
406
|
+
*/
|
|
407
|
+
quantile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
408
|
+
/**
|
|
409
|
+
* Compute the weighted average along the specified axis
|
|
410
|
+
* @param weights - Array of weights (optional)
|
|
411
|
+
* @param axis - Axis along which to compute average. If undefined, compute over all elements.
|
|
412
|
+
* @returns Weighted average of array elements
|
|
413
|
+
*/
|
|
414
|
+
average(weights?: NDArray, axis?: number): NDArray | number;
|
|
415
|
+
/**
|
|
416
|
+
* Return the sum of array elements, treating NaNs as zero
|
|
417
|
+
* @param axis - Axis along which to compute sum. If undefined, compute over all elements.
|
|
418
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
419
|
+
* @returns Sum of array elements ignoring NaNs
|
|
420
|
+
*/
|
|
421
|
+
nansum(axis?: number, keepdims?: boolean): NDArray | number;
|
|
422
|
+
/**
|
|
423
|
+
* Return the product of array elements, treating NaNs as ones
|
|
424
|
+
* @param axis - Axis along which to compute product. If undefined, compute over all elements.
|
|
425
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
426
|
+
* @returns Product of array elements ignoring NaNs
|
|
427
|
+
*/
|
|
428
|
+
nanprod(axis?: number, keepdims?: boolean): NDArray | number;
|
|
429
|
+
/**
|
|
430
|
+
* Compute the arithmetic mean, ignoring NaNs
|
|
431
|
+
* @param axis - Axis along which to compute mean. If undefined, compute over all elements.
|
|
432
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
433
|
+
* @returns Mean of array elements ignoring NaNs
|
|
434
|
+
*/
|
|
435
|
+
nanmean(axis?: number, keepdims?: boolean): NDArray | number;
|
|
436
|
+
/**
|
|
437
|
+
* Compute the variance, ignoring NaNs
|
|
438
|
+
* @param axis - Axis along which to compute variance. If undefined, compute over all elements.
|
|
439
|
+
* @param ddof - Delta degrees of freedom (default: 0)
|
|
440
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
441
|
+
* @returns Variance of array elements ignoring NaNs
|
|
442
|
+
*/
|
|
443
|
+
nanvar(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
|
|
444
|
+
/**
|
|
445
|
+
* Compute the standard deviation, ignoring NaNs
|
|
446
|
+
* @param axis - Axis along which to compute std. If undefined, compute over all elements.
|
|
447
|
+
* @param ddof - Delta degrees of freedom (default: 0)
|
|
448
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
449
|
+
* @returns Standard deviation of array elements ignoring NaNs
|
|
450
|
+
*/
|
|
451
|
+
nanstd(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
|
|
452
|
+
/**
|
|
453
|
+
* Return minimum of an array or minimum along an axis, ignoring NaNs
|
|
454
|
+
* @param axis - Axis along which to compute minimum. If undefined, compute over all elements.
|
|
455
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
456
|
+
* @returns Minimum of array elements ignoring NaNs
|
|
457
|
+
*/
|
|
458
|
+
nanmin(axis?: number, keepdims?: boolean): NDArray | number;
|
|
459
|
+
/**
|
|
460
|
+
* Return maximum of an array or maximum along an axis, ignoring NaNs
|
|
461
|
+
* @param axis - Axis along which to compute maximum. If undefined, compute over all elements.
|
|
462
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
463
|
+
* @returns Maximum of array elements ignoring NaNs
|
|
464
|
+
*/
|
|
465
|
+
nanmax(axis?: number, keepdims?: boolean): NDArray | number;
|
|
466
|
+
/**
|
|
467
|
+
* Return the indices of the minimum values, ignoring NaNs
|
|
468
|
+
* @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
|
|
469
|
+
* @returns Indices of minimum values ignoring NaNs
|
|
470
|
+
*/
|
|
471
|
+
nanargmin(axis?: number): NDArray | number;
|
|
472
|
+
/**
|
|
473
|
+
* Return the indices of the maximum values, ignoring NaNs
|
|
474
|
+
* @param axis - Axis along which to find maximum indices. If undefined, index of global maximum.
|
|
475
|
+
* @returns Indices of maximum values ignoring NaNs
|
|
476
|
+
*/
|
|
477
|
+
nanargmax(axis?: number): NDArray | number;
|
|
478
|
+
/**
|
|
479
|
+
* Return the cumulative sum of elements, treating NaNs as zero
|
|
480
|
+
* @param axis - Axis along which to compute cumsum. If undefined, compute over flattened array.
|
|
481
|
+
* @returns Array with cumulative sums ignoring NaNs
|
|
482
|
+
*/
|
|
483
|
+
nancumsum(axis?: number): NDArray;
|
|
484
|
+
/**
|
|
485
|
+
* Return the cumulative product of elements, treating NaNs as one
|
|
486
|
+
* @param axis - Axis along which to compute cumprod. If undefined, compute over flattened array.
|
|
487
|
+
* @returns Array with cumulative products ignoring NaNs
|
|
488
|
+
*/
|
|
489
|
+
nancumprod(axis?: number): NDArray;
|
|
490
|
+
/**
|
|
491
|
+
* Compute the median, ignoring NaNs
|
|
492
|
+
* @param axis - Axis along which to compute median. If undefined, compute over all elements.
|
|
493
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
494
|
+
* @returns Median of array elements ignoring NaNs
|
|
495
|
+
*/
|
|
496
|
+
nanmedian(axis?: number, keepdims?: boolean): NDArray | number;
|
|
271
497
|
/**
|
|
272
498
|
* Reshape array to a new shape
|
|
273
499
|
* Returns a new array with the specified shape
|
|
@@ -303,6 +529,40 @@ export declare class NDArray {
|
|
|
303
529
|
* @returns Array with additional dimension (always a view)
|
|
304
530
|
*/
|
|
305
531
|
expand_dims(axis: number): NDArray;
|
|
532
|
+
/**
|
|
533
|
+
* Swap two axes of an array
|
|
534
|
+
* @param axis1 - First axis
|
|
535
|
+
* @param axis2 - Second axis
|
|
536
|
+
* @returns Array with swapped axes (always a view)
|
|
537
|
+
*/
|
|
538
|
+
swapaxes(axis1: number, axis2: number): NDArray;
|
|
539
|
+
/**
|
|
540
|
+
* Move axes to new positions
|
|
541
|
+
* @param source - Original positions of axes to move
|
|
542
|
+
* @param destination - New positions for axes
|
|
543
|
+
* @returns Array with moved axes (always a view)
|
|
544
|
+
*/
|
|
545
|
+
moveaxis(source: number | number[], destination: number | number[]): NDArray;
|
|
546
|
+
/**
|
|
547
|
+
* Repeat elements of an array
|
|
548
|
+
* @param repeats - Number of repetitions for each element
|
|
549
|
+
* @param axis - Axis along which to repeat (if undefined, flattens first)
|
|
550
|
+
* @returns New array with repeated elements
|
|
551
|
+
*/
|
|
552
|
+
repeat(repeats: number | number[], axis?: number): NDArray;
|
|
553
|
+
/**
|
|
554
|
+
* Take elements from array along an axis
|
|
555
|
+
* @param indices - Indices of elements to take
|
|
556
|
+
* @param axis - Axis along which to take (if undefined, flattens first)
|
|
557
|
+
* @returns New array with selected elements
|
|
558
|
+
*/
|
|
559
|
+
take(indices: number[], axis?: number): NDArray;
|
|
560
|
+
/**
|
|
561
|
+
* Put values at specified indices (modifies array in-place)
|
|
562
|
+
* @param indices - Indices at which to place values
|
|
563
|
+
* @param values - Values to put
|
|
564
|
+
*/
|
|
565
|
+
put(indices: number[], values: NDArray | number | bigint): void;
|
|
306
566
|
/**
|
|
307
567
|
* Matrix multiplication
|
|
308
568
|
* @param other - Array to multiply with
|
|
@@ -339,6 +599,40 @@ export declare class NDArray {
|
|
|
339
599
|
* @returns Tensor dot product result
|
|
340
600
|
*/
|
|
341
601
|
tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
|
|
602
|
+
/**
|
|
603
|
+
* Element-wise cube root
|
|
604
|
+
* Promotes integer types to float64
|
|
605
|
+
* @returns New array with cube root values
|
|
606
|
+
*/
|
|
607
|
+
cbrt(): NDArray;
|
|
608
|
+
/**
|
|
609
|
+
* Element-wise absolute value (always returns float)
|
|
610
|
+
* @returns New array with absolute values as float
|
|
611
|
+
*/
|
|
612
|
+
fabs(): NDArray;
|
|
613
|
+
/**
|
|
614
|
+
* Returns both quotient and remainder (floor divide and modulo)
|
|
615
|
+
* @param divisor - Array or scalar divisor
|
|
616
|
+
* @returns Tuple of [quotient, remainder] arrays
|
|
617
|
+
*/
|
|
618
|
+
divmod(divisor: NDArray | number): [NDArray, NDArray];
|
|
619
|
+
/**
|
|
620
|
+
* Element-wise square (x**2)
|
|
621
|
+
* @returns New array with squared values
|
|
622
|
+
*/
|
|
623
|
+
square(): NDArray;
|
|
624
|
+
/**
|
|
625
|
+
* Element-wise remainder (same as mod)
|
|
626
|
+
* @param divisor - Array or scalar divisor
|
|
627
|
+
* @returns New array with remainder values
|
|
628
|
+
*/
|
|
629
|
+
remainder(divisor: NDArray | number): NDArray;
|
|
630
|
+
/**
|
|
631
|
+
* Heaviside step function
|
|
632
|
+
* @param x2 - Value to use when this array element is 0
|
|
633
|
+
* @returns New array with heaviside values
|
|
634
|
+
*/
|
|
635
|
+
heaviside(x2: NDArray | number): NDArray;
|
|
342
636
|
/**
|
|
343
637
|
* Slice the array using NumPy-style string syntax
|
|
344
638
|
*
|
|
@@ -518,6 +812,130 @@ export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
|
|
|
518
812
|
* @returns Filled array
|
|
519
813
|
*/
|
|
520
814
|
export declare function full_like(a: NDArray, fill_value: number | bigint | boolean, dtype?: DType): NDArray;
|
|
815
|
+
/**
|
|
816
|
+
* Convert input to an ndarray (alias for asarray for compatibility)
|
|
817
|
+
* In numpy-ts, this behaves the same as asarray since we don't have subclasses
|
|
818
|
+
* @param a - Input data
|
|
819
|
+
* @param dtype - Data type (optional)
|
|
820
|
+
* @returns NDArray
|
|
821
|
+
*/
|
|
822
|
+
export declare function asanyarray(a: NDArray | any, dtype?: DType): NDArray;
|
|
823
|
+
/**
|
|
824
|
+
* Return a contiguous array (ndim >= 1) in memory (C order)
|
|
825
|
+
* Since our arrays are already C-contiguous in memory, this either
|
|
826
|
+
* returns the input unchanged or creates a contiguous copy
|
|
827
|
+
* @param a - Input data
|
|
828
|
+
* @param dtype - Data type (optional)
|
|
829
|
+
* @returns Contiguous array in C order
|
|
830
|
+
*/
|
|
831
|
+
export declare function ascontiguousarray(a: NDArray | any, dtype?: DType): NDArray;
|
|
832
|
+
/**
|
|
833
|
+
* Return an array laid out in Fortran order in memory
|
|
834
|
+
* Note: numpy-ts uses C-order internally, so this creates a copy
|
|
835
|
+
* that is equivalent to the Fortran-ordered layout
|
|
836
|
+
* @param a - Input data
|
|
837
|
+
* @param dtype - Data type (optional)
|
|
838
|
+
* @returns Array (copy in C order, as Fortran order is not supported)
|
|
839
|
+
*/
|
|
840
|
+
export declare function asfortranarray(a: NDArray | any, dtype?: DType): NDArray;
|
|
841
|
+
/**
|
|
842
|
+
* Extract a diagonal or construct a diagonal array
|
|
843
|
+
* @param v - Input array (if 2D, extract diagonal; if 1D, construct diagonal matrix)
|
|
844
|
+
* @param k - Diagonal offset (default 0 is main diagonal, positive above, negative below)
|
|
845
|
+
* @returns Diagonal elements as 1D array, or 2D diagonal matrix
|
|
846
|
+
*/
|
|
847
|
+
export declare function diag(v: NDArray, k?: number): NDArray;
|
|
848
|
+
/**
|
|
849
|
+
* Create a 2-D array with the flattened input as a diagonal
|
|
850
|
+
* @param v - Input array (will be flattened)
|
|
851
|
+
* @param k - Diagonal offset (default 0)
|
|
852
|
+
* @returns 2D diagonal matrix
|
|
853
|
+
*/
|
|
854
|
+
export declare function diagflat(v: NDArray, k?: number): NDArray;
|
|
855
|
+
/**
|
|
856
|
+
* Construct an array by executing a function over each coordinate
|
|
857
|
+
* @param fn - Function that takes coordinate indices and returns value
|
|
858
|
+
* @param shape - Shape of output array
|
|
859
|
+
* @param dtype - Data type (default: float64)
|
|
860
|
+
* @returns Array with values computed from function
|
|
861
|
+
*/
|
|
862
|
+
export declare function fromfunction(fn: (...indices: number[]) => number | bigint | boolean, shape: number[], dtype?: DType): NDArray;
|
|
863
|
+
/**
|
|
864
|
+
* Return coordinate matrices from coordinate vectors
|
|
865
|
+
* @param arrays - 1D coordinate arrays
|
|
866
|
+
* @param indexing - 'xy' (Cartesian, default) or 'ij' (matrix indexing)
|
|
867
|
+
* @returns Array of coordinate grids
|
|
868
|
+
*/
|
|
869
|
+
export declare function meshgrid(...args: (NDArray | {
|
|
870
|
+
indexing?: 'xy' | 'ij';
|
|
871
|
+
})[]): NDArray[];
|
|
872
|
+
/**
|
|
873
|
+
* An array with ones at and below the given diagonal and zeros elsewhere
|
|
874
|
+
* @param N - Number of rows
|
|
875
|
+
* @param M - Number of columns (default: N)
|
|
876
|
+
* @param k - Diagonal offset (default 0)
|
|
877
|
+
* @param dtype - Data type (default: float64)
|
|
878
|
+
* @returns Triangular array
|
|
879
|
+
*/
|
|
880
|
+
export declare function tri(N: number, M?: number, k?: number, dtype?: DType): NDArray;
|
|
881
|
+
/**
|
|
882
|
+
* Lower triangle of an array
|
|
883
|
+
* @param m - Input array
|
|
884
|
+
* @param k - Diagonal above which to zero elements (default 0)
|
|
885
|
+
* @returns Copy with upper triangle zeroed
|
|
886
|
+
*/
|
|
887
|
+
export declare function tril(m: NDArray, k?: number): NDArray;
|
|
888
|
+
/**
|
|
889
|
+
* Upper triangle of an array
|
|
890
|
+
* @param m - Input array
|
|
891
|
+
* @param k - Diagonal below which to zero elements (default 0)
|
|
892
|
+
* @returns Copy with lower triangle zeroed
|
|
893
|
+
*/
|
|
894
|
+
export declare function triu(m: NDArray, k?: number): NDArray;
|
|
895
|
+
/**
|
|
896
|
+
* Generate a Vandermonde matrix
|
|
897
|
+
* @param x - Input 1D array
|
|
898
|
+
* @param N - Number of columns (default: length of x)
|
|
899
|
+
* @param increasing - Order of powers (default: false, highest powers first)
|
|
900
|
+
* @returns Vandermonde matrix
|
|
901
|
+
*/
|
|
902
|
+
export declare function vander(x: NDArray, N?: number, increasing?: boolean): NDArray;
|
|
903
|
+
/**
|
|
904
|
+
* Interpret a buffer as a 1-dimensional array
|
|
905
|
+
* @param buffer - Buffer-like object (ArrayBuffer, TypedArray, or DataView)
|
|
906
|
+
* @param dtype - Data type (default: float64)
|
|
907
|
+
* @param count - Number of items to read (-1 means all)
|
|
908
|
+
* @param offset - Start reading from this byte offset
|
|
909
|
+
* @returns NDArray from buffer data
|
|
910
|
+
*/
|
|
911
|
+
export declare function frombuffer(buffer: ArrayBuffer | ArrayBufferView, dtype?: DType, count?: number, offset?: number): NDArray;
|
|
912
|
+
/**
|
|
913
|
+
* Construct an array by executing a function over each coordinate.
|
|
914
|
+
* Note: This is a JS implementation - fromfile for actual files isn't directly applicable in browser JS.
|
|
915
|
+
* This function creates an array from an iterable or callable.
|
|
916
|
+
* @param file - In JS context, this is an iterable yielding values
|
|
917
|
+
* @param dtype - Data type
|
|
918
|
+
* @param count - Number of items to read (-1 means all)
|
|
919
|
+
* @returns NDArray from the iterable
|
|
920
|
+
*/
|
|
921
|
+
export declare function fromfile(file: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
|
|
922
|
+
/**
|
|
923
|
+
* Create a new 1-dimensional array from an iterable object
|
|
924
|
+
* @param iter - Iterable object
|
|
925
|
+
* @param dtype - Data type
|
|
926
|
+
* @param count - Number of items to read (-1 means all)
|
|
927
|
+
* @returns NDArray from the iterable
|
|
928
|
+
*/
|
|
929
|
+
export declare function fromiter(iter: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
|
|
930
|
+
/**
|
|
931
|
+
* Create a new 1-dimensional array from text string
|
|
932
|
+
* @param string - Input string containing numbers separated by whitespace or separator
|
|
933
|
+
* @param dtype - Data type (default: float64)
|
|
934
|
+
* @param count - Number of items to read (-1 means all)
|
|
935
|
+
* @param sep - Separator between values (default: any whitespace)
|
|
936
|
+
* @returns NDArray from parsed string
|
|
937
|
+
*/
|
|
938
|
+
export declare function fromstring(string: string, dtype?: DType, count?: number, sep?: string): NDArray;
|
|
521
939
|
/**
|
|
522
940
|
* Element-wise square root
|
|
523
941
|
* @param x - Input array
|
|
@@ -601,6 +1019,24 @@ export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
|
|
|
601
1019
|
* @returns Sum of diagonal elements
|
|
602
1020
|
*/
|
|
603
1021
|
export declare function trace(a: NDArray): number | bigint;
|
|
1022
|
+
/**
|
|
1023
|
+
* Extract a diagonal from a matrix or N-D array
|
|
1024
|
+
*
|
|
1025
|
+
* @param a - Input array (must be at least 2D)
|
|
1026
|
+
* @param offset - Offset of the diagonal from the main diagonal (default: 0)
|
|
1027
|
+
* @param axis1 - First axis (default: 0)
|
|
1028
|
+
* @param axis2 - Second axis (default: 1)
|
|
1029
|
+
* @returns Array containing the diagonal elements
|
|
1030
|
+
*/
|
|
1031
|
+
export declare function diagonal(a: NDArray, offset?: number, axis1?: number, axis2?: number): NDArray;
|
|
1032
|
+
/**
|
|
1033
|
+
* Kronecker product of two arrays
|
|
1034
|
+
*
|
|
1035
|
+
* @param a - First input array
|
|
1036
|
+
* @param b - Second input array
|
|
1037
|
+
* @returns Kronecker product of a and b
|
|
1038
|
+
*/
|
|
1039
|
+
export declare function kron(a: NDArray, b: NDArray): NDArray;
|
|
604
1040
|
/**
|
|
605
1041
|
* Permute array dimensions
|
|
606
1042
|
*
|
|
@@ -639,4 +1075,677 @@ export declare function outer(a: NDArray, b: NDArray): NDArray;
|
|
|
639
1075
|
* @returns Tensor dot product
|
|
640
1076
|
*/
|
|
641
1077
|
export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
|
|
1078
|
+
/**
|
|
1079
|
+
* Element-wise sine
|
|
1080
|
+
* @param x - Input array (angles in radians)
|
|
1081
|
+
* @returns Array of sine values
|
|
1082
|
+
*/
|
|
1083
|
+
export declare function sin(x: NDArray): NDArray;
|
|
1084
|
+
/**
|
|
1085
|
+
* Element-wise cosine
|
|
1086
|
+
* @param x - Input array (angles in radians)
|
|
1087
|
+
* @returns Array of cosine values
|
|
1088
|
+
*/
|
|
1089
|
+
export declare function cos(x: NDArray): NDArray;
|
|
1090
|
+
/**
|
|
1091
|
+
* Element-wise tangent
|
|
1092
|
+
* @param x - Input array (angles in radians)
|
|
1093
|
+
* @returns Array of tangent values
|
|
1094
|
+
*/
|
|
1095
|
+
export declare function tan(x: NDArray): NDArray;
|
|
1096
|
+
/**
|
|
1097
|
+
* Element-wise inverse sine
|
|
1098
|
+
* @param x - Input array (values in range [-1, 1])
|
|
1099
|
+
* @returns Array of angles in radians
|
|
1100
|
+
*/
|
|
1101
|
+
export declare function arcsin(x: NDArray): NDArray;
|
|
1102
|
+
/**
|
|
1103
|
+
* Element-wise inverse cosine
|
|
1104
|
+
* @param x - Input array (values in range [-1, 1])
|
|
1105
|
+
* @returns Array of angles in radians
|
|
1106
|
+
*/
|
|
1107
|
+
export declare function arccos(x: NDArray): NDArray;
|
|
1108
|
+
/**
|
|
1109
|
+
* Element-wise inverse tangent
|
|
1110
|
+
* @param x - Input array
|
|
1111
|
+
* @returns Array of angles in radians
|
|
1112
|
+
*/
|
|
1113
|
+
export declare function arctan(x: NDArray): NDArray;
|
|
1114
|
+
/**
|
|
1115
|
+
* Element-wise arc tangent of x1/x2 choosing the quadrant correctly
|
|
1116
|
+
* @param x1 - y-coordinates
|
|
1117
|
+
* @param x2 - x-coordinates (array or scalar)
|
|
1118
|
+
* @returns Angles in radians between -π and π
|
|
1119
|
+
*/
|
|
1120
|
+
export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
|
|
1121
|
+
/**
|
|
1122
|
+
* Given the "legs" of a right triangle, return its hypotenuse
|
|
1123
|
+
* Equivalent to sqrt(x1**2 + x2**2), element-wise
|
|
1124
|
+
* @param x1 - First leg
|
|
1125
|
+
* @param x2 - Second leg (array or scalar)
|
|
1126
|
+
* @returns Hypotenuse values
|
|
1127
|
+
*/
|
|
1128
|
+
export declare function hypot(x1: NDArray, x2: NDArray | number): NDArray;
|
|
1129
|
+
/**
|
|
1130
|
+
* Convert angles from radians to degrees
|
|
1131
|
+
* @param x - Input array (angles in radians)
|
|
1132
|
+
* @returns Angles in degrees
|
|
1133
|
+
*/
|
|
1134
|
+
export declare function degrees(x: NDArray): NDArray;
|
|
1135
|
+
/**
|
|
1136
|
+
* Convert angles from degrees to radians
|
|
1137
|
+
* @param x - Input array (angles in degrees)
|
|
1138
|
+
* @returns Angles in radians
|
|
1139
|
+
*/
|
|
1140
|
+
export declare function radians(x: NDArray): NDArray;
|
|
1141
|
+
/**
|
|
1142
|
+
* Convert angles from degrees to radians (alias for radians)
|
|
1143
|
+
* @param x - Input array (angles in degrees)
|
|
1144
|
+
* @returns Angles in radians
|
|
1145
|
+
*/
|
|
1146
|
+
export declare function deg2rad(x: NDArray): NDArray;
|
|
1147
|
+
/**
|
|
1148
|
+
* Convert angles from radians to degrees (alias for degrees)
|
|
1149
|
+
* @param x - Input array (angles in radians)
|
|
1150
|
+
* @returns Angles in degrees
|
|
1151
|
+
*/
|
|
1152
|
+
export declare function rad2deg(x: NDArray): NDArray;
|
|
1153
|
+
/**
|
|
1154
|
+
* Element-wise hyperbolic sine
|
|
1155
|
+
* @param x - Input array
|
|
1156
|
+
* @returns Array of sinh values
|
|
1157
|
+
*/
|
|
1158
|
+
export declare function sinh(x: NDArray): NDArray;
|
|
1159
|
+
/**
|
|
1160
|
+
* Element-wise hyperbolic cosine
|
|
1161
|
+
* @param x - Input array
|
|
1162
|
+
* @returns Array of cosh values
|
|
1163
|
+
*/
|
|
1164
|
+
export declare function cosh(x: NDArray): NDArray;
|
|
1165
|
+
/**
|
|
1166
|
+
* Element-wise hyperbolic tangent
|
|
1167
|
+
* @param x - Input array
|
|
1168
|
+
* @returns Array of tanh values
|
|
1169
|
+
*/
|
|
1170
|
+
export declare function tanh(x: NDArray): NDArray;
|
|
1171
|
+
/**
|
|
1172
|
+
* Element-wise inverse hyperbolic sine
|
|
1173
|
+
* @param x - Input array
|
|
1174
|
+
* @returns Array of arcsinh values
|
|
1175
|
+
*/
|
|
1176
|
+
export declare function arcsinh(x: NDArray): NDArray;
|
|
1177
|
+
/**
|
|
1178
|
+
* Element-wise inverse hyperbolic cosine
|
|
1179
|
+
* @param x - Input array (values >= 1)
|
|
1180
|
+
* @returns Array of arccosh values
|
|
1181
|
+
*/
|
|
1182
|
+
export declare function arccosh(x: NDArray): NDArray;
|
|
1183
|
+
/**
|
|
1184
|
+
* Element-wise inverse hyperbolic tangent
|
|
1185
|
+
* @param x - Input array (values in range (-1, 1))
|
|
1186
|
+
* @returns Array of arctanh values
|
|
1187
|
+
*/
|
|
1188
|
+
export declare function arctanh(x: NDArray): NDArray;
|
|
1189
|
+
/**
|
|
1190
|
+
* Swap two axes of an array
|
|
1191
|
+
*
|
|
1192
|
+
* @param a - Input array
|
|
1193
|
+
* @param axis1 - First axis
|
|
1194
|
+
* @param axis2 - Second axis
|
|
1195
|
+
* @returns View with axes swapped
|
|
1196
|
+
*/
|
|
1197
|
+
export declare function swapaxes(a: NDArray, axis1: number, axis2: number): NDArray;
|
|
1198
|
+
/**
|
|
1199
|
+
* Move axes to new positions
|
|
1200
|
+
*
|
|
1201
|
+
* @param a - Input array
|
|
1202
|
+
* @param source - Original positions of axes to move
|
|
1203
|
+
* @param destination - New positions for axes
|
|
1204
|
+
* @returns View with axes moved
|
|
1205
|
+
*/
|
|
1206
|
+
export declare function moveaxis(a: NDArray, source: number | number[], destination: number | number[]): NDArray;
|
|
1207
|
+
/**
|
|
1208
|
+
* Concatenate arrays along an existing axis
|
|
1209
|
+
*
|
|
1210
|
+
* @param arrays - Arrays to concatenate
|
|
1211
|
+
* @param axis - Axis along which to concatenate (default: 0)
|
|
1212
|
+
* @returns Concatenated array
|
|
1213
|
+
*/
|
|
1214
|
+
export declare function concatenate(arrays: NDArray[], axis?: number): NDArray;
|
|
1215
|
+
/**
|
|
1216
|
+
* Stack arrays along a new axis
|
|
1217
|
+
*
|
|
1218
|
+
* @param arrays - Arrays to stack (must have same shape)
|
|
1219
|
+
* @param axis - Axis in the result array along which to stack (default: 0)
|
|
1220
|
+
* @returns Stacked array
|
|
1221
|
+
*/
|
|
1222
|
+
export declare function stack(arrays: NDArray[], axis?: number): NDArray;
|
|
1223
|
+
/**
|
|
1224
|
+
* Stack arrays vertically (row-wise)
|
|
1225
|
+
*
|
|
1226
|
+
* @param arrays - Arrays to stack
|
|
1227
|
+
* @returns Vertically stacked array
|
|
1228
|
+
*/
|
|
1229
|
+
export declare function vstack(arrays: NDArray[]): NDArray;
|
|
1230
|
+
/**
|
|
1231
|
+
* Stack arrays horizontally (column-wise)
|
|
1232
|
+
*
|
|
1233
|
+
* @param arrays - Arrays to stack
|
|
1234
|
+
* @returns Horizontally stacked array
|
|
1235
|
+
*/
|
|
1236
|
+
export declare function hstack(arrays: NDArray[]): NDArray;
|
|
1237
|
+
/**
|
|
1238
|
+
* Stack arrays depth-wise (along third axis)
|
|
1239
|
+
*
|
|
1240
|
+
* @param arrays - Arrays to stack
|
|
1241
|
+
* @returns Depth-stacked array
|
|
1242
|
+
*/
|
|
1243
|
+
export declare function dstack(arrays: NDArray[]): NDArray;
|
|
1244
|
+
/**
|
|
1245
|
+
* Split array into multiple sub-arrays
|
|
1246
|
+
*
|
|
1247
|
+
* @param a - Array to split
|
|
1248
|
+
* @param indicesOrSections - Number of equal sections or indices where to split
|
|
1249
|
+
* @param axis - Axis along which to split (default: 0)
|
|
1250
|
+
* @returns List of sub-arrays
|
|
1251
|
+
*/
|
|
1252
|
+
export declare function split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
|
|
1253
|
+
/**
|
|
1254
|
+
* Split array into multiple sub-arrays (allows unequal splits)
|
|
1255
|
+
*
|
|
1256
|
+
* @param a - Array to split
|
|
1257
|
+
* @param indicesOrSections - Number of sections or indices where to split
|
|
1258
|
+
* @param axis - Axis along which to split (default: 0)
|
|
1259
|
+
* @returns List of sub-arrays
|
|
1260
|
+
*/
|
|
1261
|
+
export declare function array_split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
|
|
1262
|
+
/**
|
|
1263
|
+
* Split array vertically (row-wise)
|
|
1264
|
+
*
|
|
1265
|
+
* @param a - Array to split
|
|
1266
|
+
* @param indicesOrSections - Number of sections or indices where to split
|
|
1267
|
+
* @returns List of sub-arrays
|
|
1268
|
+
*/
|
|
1269
|
+
export declare function vsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
|
|
1270
|
+
/**
|
|
1271
|
+
* Split array horizontally (column-wise)
|
|
1272
|
+
*
|
|
1273
|
+
* @param a - Array to split
|
|
1274
|
+
* @param indicesOrSections - Number of sections or indices where to split
|
|
1275
|
+
* @returns List of sub-arrays
|
|
1276
|
+
*/
|
|
1277
|
+
export declare function hsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
|
|
1278
|
+
/**
|
|
1279
|
+
* Tile array by repeating along each axis
|
|
1280
|
+
*
|
|
1281
|
+
* @param a - Input array
|
|
1282
|
+
* @param reps - Number of repetitions along each axis
|
|
1283
|
+
* @returns Tiled array
|
|
1284
|
+
*/
|
|
1285
|
+
export declare function tile(a: NDArray, reps: number | number[]): NDArray;
|
|
1286
|
+
/**
|
|
1287
|
+
* Repeat elements of an array
|
|
1288
|
+
*
|
|
1289
|
+
* @param a - Input array
|
|
1290
|
+
* @param repeats - Number of repetitions for each element
|
|
1291
|
+
* @param axis - Axis along which to repeat (if undefined, flattens first)
|
|
1292
|
+
* @returns Array with repeated elements
|
|
1293
|
+
*/
|
|
1294
|
+
export declare function repeat(a: NDArray, repeats: number | number[], axis?: number): NDArray;
|
|
1295
|
+
/**
|
|
1296
|
+
* Return a contiguous flattened array
|
|
1297
|
+
*
|
|
1298
|
+
* @param a - Input array
|
|
1299
|
+
* @returns Flattened 1-D array (view if possible)
|
|
1300
|
+
*/
|
|
1301
|
+
export declare function ravel(a: NDArray): NDArray;
|
|
1302
|
+
/**
|
|
1303
|
+
* Reshape array to new shape
|
|
1304
|
+
*
|
|
1305
|
+
* @param a - Input array
|
|
1306
|
+
* @param newShape - New shape
|
|
1307
|
+
* @returns Reshaped array (view if possible)
|
|
1308
|
+
*/
|
|
1309
|
+
export declare function reshape(a: NDArray, newShape: number[]): NDArray;
|
|
1310
|
+
/**
|
|
1311
|
+
* Remove axes of length 1
|
|
1312
|
+
*
|
|
1313
|
+
* @param a - Input array
|
|
1314
|
+
* @param axis - Axis to squeeze (optional, squeezes all if not specified)
|
|
1315
|
+
* @returns Squeezed array (view)
|
|
1316
|
+
*/
|
|
1317
|
+
export declare function squeeze(a: NDArray, axis?: number): NDArray;
|
|
1318
|
+
/**
|
|
1319
|
+
* Expand the shape of an array by inserting a new axis
|
|
1320
|
+
*
|
|
1321
|
+
* @param a - Input array
|
|
1322
|
+
* @param axis - Position where new axis should be inserted
|
|
1323
|
+
* @returns Array with expanded shape (view)
|
|
1324
|
+
*/
|
|
1325
|
+
export declare function expand_dims(a: NDArray, axis: number): NDArray;
|
|
1326
|
+
/**
|
|
1327
|
+
* Reverse the order of elements along the given axis
|
|
1328
|
+
*
|
|
1329
|
+
* @param m - Input array
|
|
1330
|
+
* @param axis - Axis or axes to flip (flips all if undefined)
|
|
1331
|
+
* @returns Flipped array
|
|
1332
|
+
*/
|
|
1333
|
+
export declare function flip(m: NDArray, axis?: number | number[]): NDArray;
|
|
1334
|
+
/**
|
|
1335
|
+
* Flip array in the left/right direction (reverse along axis 1)
|
|
1336
|
+
*
|
|
1337
|
+
* @param m - Input array (must be at least 2-D)
|
|
1338
|
+
* @returns Flipped array
|
|
1339
|
+
*/
|
|
1340
|
+
export declare function fliplr(m: NDArray): NDArray;
|
|
1341
|
+
/**
|
|
1342
|
+
* Flip array in the up/down direction (reverse along axis 0)
|
|
1343
|
+
*
|
|
1344
|
+
* @param m - Input array (must be at least 2-D)
|
|
1345
|
+
* @returns Flipped array
|
|
1346
|
+
*/
|
|
1347
|
+
export declare function flipud(m: NDArray): NDArray;
|
|
1348
|
+
/**
|
|
1349
|
+
* Rotate array by 90 degrees
|
|
1350
|
+
*
|
|
1351
|
+
* @param m - Input array
|
|
1352
|
+
* @param k - Number of times to rotate (default 1)
|
|
1353
|
+
* @param axes - The axes to rotate in (default [0, 1])
|
|
1354
|
+
* @returns Rotated array
|
|
1355
|
+
*/
|
|
1356
|
+
export declare function rot90(m: NDArray, k?: number, axes?: [number, number]): NDArray;
|
|
1357
|
+
/**
|
|
1358
|
+
* Roll array elements along a given axis
|
|
1359
|
+
*
|
|
1360
|
+
* @param a - Input array
|
|
1361
|
+
* @param shift - Number of positions to shift
|
|
1362
|
+
* @param axis - Axis along which to roll (rolls flattened array if undefined)
|
|
1363
|
+
* @returns Rolled array
|
|
1364
|
+
*/
|
|
1365
|
+
export declare function roll(a: NDArray, shift: number | number[], axis?: number | number[]): NDArray;
|
|
1366
|
+
/**
|
|
1367
|
+
* Roll the specified axis backwards until it lies in a given position
|
|
1368
|
+
*
|
|
1369
|
+
* @param a - Input array
|
|
1370
|
+
* @param axis - The axis to roll backwards
|
|
1371
|
+
* @param start - Position to roll to (default 0)
|
|
1372
|
+
* @returns Array with rolled axis (view)
|
|
1373
|
+
*/
|
|
1374
|
+
export declare function rollaxis(a: NDArray, axis: number, start?: number): NDArray;
|
|
1375
|
+
/**
|
|
1376
|
+
* Convert inputs to arrays with at least 1 dimension
|
|
1377
|
+
*
|
|
1378
|
+
* @param arrays - Input arrays
|
|
1379
|
+
* @returns Arrays with at least 1 dimension
|
|
1380
|
+
*/
|
|
1381
|
+
export declare function atleast_1d(...arrays: NDArray[]): NDArray | NDArray[];
|
|
1382
|
+
/**
|
|
1383
|
+
* Convert inputs to arrays with at least 2 dimensions
|
|
1384
|
+
*
|
|
1385
|
+
* @param arrays - Input arrays
|
|
1386
|
+
* @returns Arrays with at least 2 dimensions
|
|
1387
|
+
*/
|
|
1388
|
+
export declare function atleast_2d(...arrays: NDArray[]): NDArray | NDArray[];
|
|
1389
|
+
/**
|
|
1390
|
+
* Convert inputs to arrays with at least 3 dimensions
|
|
1391
|
+
*
|
|
1392
|
+
* @param arrays - Input arrays
|
|
1393
|
+
* @returns Arrays with at least 3 dimensions
|
|
1394
|
+
*/
|
|
1395
|
+
export declare function atleast_3d(...arrays: NDArray[]): NDArray | NDArray[];
|
|
1396
|
+
/**
|
|
1397
|
+
* Split array along third axis (depth)
|
|
1398
|
+
*
|
|
1399
|
+
* @param ary - Input array (must be at least 3-D)
|
|
1400
|
+
* @param indices_or_sections - Number of sections or indices where to split
|
|
1401
|
+
* @returns List of sub-arrays
|
|
1402
|
+
*/
|
|
1403
|
+
export declare function dsplit(ary: NDArray, indices_or_sections: number | number[]): NDArray[];
|
|
1404
|
+
/**
|
|
1405
|
+
* Stack 1-D arrays as columns into a 2-D array
|
|
1406
|
+
*
|
|
1407
|
+
* @param arrays - 1-D arrays to stack
|
|
1408
|
+
* @returns 2-D array with inputs as columns
|
|
1409
|
+
*/
|
|
1410
|
+
export declare function column_stack(arrays: NDArray[]): NDArray;
|
|
1411
|
+
/**
|
|
1412
|
+
* Stack arrays in sequence vertically (alias for vstack)
|
|
1413
|
+
*
|
|
1414
|
+
* @param arrays - Arrays to stack
|
|
1415
|
+
* @returns Vertically stacked array
|
|
1416
|
+
*/
|
|
1417
|
+
export declare function row_stack(arrays: NDArray[]): NDArray;
|
|
1418
|
+
/**
|
|
1419
|
+
* Return a new array with the given shape (repeating data if needed)
|
|
1420
|
+
*
|
|
1421
|
+
* @param a - Input array
|
|
1422
|
+
* @param new_shape - New shape
|
|
1423
|
+
* @returns Resized array
|
|
1424
|
+
*/
|
|
1425
|
+
export declare function resize(a: NDArray, new_shape: number[]): NDArray;
|
|
1426
|
+
/**
|
|
1427
|
+
* Append values to the end of an array
|
|
1428
|
+
*
|
|
1429
|
+
* @param arr - Input array
|
|
1430
|
+
* @param values - Values to append
|
|
1431
|
+
* @param axis - Axis along which to append (flattens if undefined)
|
|
1432
|
+
* @returns Array with values appended
|
|
1433
|
+
*/
|
|
1434
|
+
export declare function append(arr: NDArray, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
|
|
1435
|
+
/**
|
|
1436
|
+
* Return a new array with sub-arrays along an axis deleted
|
|
1437
|
+
*
|
|
1438
|
+
* @param arr - Input array
|
|
1439
|
+
* @param obj - Indices to delete
|
|
1440
|
+
* @param axis - Axis along which to delete (flattens if undefined)
|
|
1441
|
+
* @returns Array with elements deleted
|
|
1442
|
+
*/
|
|
1443
|
+
export declare function delete_(arr: NDArray, obj: number | number[], axis?: number): NDArray;
|
|
1444
|
+
/**
|
|
1445
|
+
* Insert values along the given axis before the given indices
|
|
1446
|
+
*
|
|
1447
|
+
* @param arr - Input array
|
|
1448
|
+
* @param obj - Index before which to insert
|
|
1449
|
+
* @param values - Values to insert
|
|
1450
|
+
* @param axis - Axis along which to insert (flattens if undefined)
|
|
1451
|
+
* @returns Array with values inserted
|
|
1452
|
+
*/
|
|
1453
|
+
export declare function insert(arr: NDArray, obj: number, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
|
|
1454
|
+
/**
|
|
1455
|
+
* Pad an array
|
|
1456
|
+
*
|
|
1457
|
+
* @param array - Input array
|
|
1458
|
+
* @param pad_width - Number of values padded to edges of each axis
|
|
1459
|
+
* @param mode - Padding mode ('constant', 'edge', 'reflect', 'symmetric', 'wrap')
|
|
1460
|
+
* @param constant_values - Value for constant padding (default 0)
|
|
1461
|
+
* @returns Padded array
|
|
1462
|
+
*/
|
|
1463
|
+
export declare function pad(arr: NDArray, pad_width: number | [number, number] | Array<[number, number]>, mode?: 'constant' | 'edge' | 'reflect' | 'symmetric' | 'wrap', constant_values?: number): NDArray;
|
|
1464
|
+
/**
|
|
1465
|
+
* Broadcast an array to a given shape
|
|
1466
|
+
*
|
|
1467
|
+
* @param a - Input array
|
|
1468
|
+
* @param shape - Target shape
|
|
1469
|
+
* @returns View broadcast to target shape
|
|
1470
|
+
*/
|
|
1471
|
+
export declare function broadcast_to(a: NDArray, shape: number[]): NDArray;
|
|
1472
|
+
/**
|
|
1473
|
+
* Broadcast arrays to a common shape
|
|
1474
|
+
*
|
|
1475
|
+
* @param arrays - Arrays to broadcast
|
|
1476
|
+
* @returns Arrays broadcast to common shape
|
|
1477
|
+
*/
|
|
1478
|
+
export declare function broadcast_arrays(...arrays: NDArray[]): NDArray[];
|
|
1479
|
+
/**
|
|
1480
|
+
* Compute the broadcast shape for multiple shapes
|
|
1481
|
+
*
|
|
1482
|
+
* Returns the resulting shape if all shapes are broadcast-compatible.
|
|
1483
|
+
* Throws an error if shapes are not broadcast-compatible.
|
|
1484
|
+
*
|
|
1485
|
+
* @param shapes - Variable number of shapes to broadcast
|
|
1486
|
+
* @returns The broadcast output shape
|
|
1487
|
+
* @throws Error if shapes are not broadcast-compatible
|
|
1488
|
+
*/
|
|
1489
|
+
export declare function broadcast_shapes(...shapes: number[][]): number[];
|
|
1490
|
+
/**
|
|
1491
|
+
* Take elements from an array along an axis
|
|
1492
|
+
*
|
|
1493
|
+
* @param a - Input array
|
|
1494
|
+
* @param indices - Indices of elements to take
|
|
1495
|
+
* @param axis - Axis along which to take (if undefined, flattens first)
|
|
1496
|
+
* @returns Array with selected elements
|
|
1497
|
+
*/
|
|
1498
|
+
export declare function take(a: NDArray, indices: number[], axis?: number): NDArray;
|
|
1499
|
+
/**
|
|
1500
|
+
* Put values at specified indices (modifies array in-place)
|
|
1501
|
+
*
|
|
1502
|
+
* @param a - Target array
|
|
1503
|
+
* @param indices - Indices at which to place values
|
|
1504
|
+
* @param values - Values to put
|
|
1505
|
+
*/
|
|
1506
|
+
export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
|
|
1507
|
+
/**
|
|
1508
|
+
* Construct array from index array and choices
|
|
1509
|
+
*
|
|
1510
|
+
* @param a - Index array (integer indices into choices)
|
|
1511
|
+
* @param choices - Arrays to choose from
|
|
1512
|
+
* @returns Array constructed from choices
|
|
1513
|
+
*/
|
|
1514
|
+
export declare function choose(a: NDArray, choices: NDArray[]): NDArray;
|
|
1515
|
+
/**
|
|
1516
|
+
* Check if two arrays are element-wise equal
|
|
1517
|
+
*
|
|
1518
|
+
* @param a - First array
|
|
1519
|
+
* @param b - Second array
|
|
1520
|
+
* @param equal_nan - Whether to consider NaN equal to NaN (default: false)
|
|
1521
|
+
* @returns True if arrays are equal element-wise
|
|
1522
|
+
*/
|
|
1523
|
+
export declare function array_equal(a: NDArray, b: NDArray, equal_nan?: boolean): boolean;
|
|
1524
|
+
/**
|
|
1525
|
+
* Returns True if two arrays are element-wise equal within a tolerance.
|
|
1526
|
+
* Unlike array_equal, this function broadcasts the arrays before comparison.
|
|
1527
|
+
*
|
|
1528
|
+
* @param a1 - First input array
|
|
1529
|
+
* @param a2 - Second input array
|
|
1530
|
+
* @returns True if arrays are equivalent (after broadcasting)
|
|
1531
|
+
*/
|
|
1532
|
+
export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
|
|
1533
|
+
/**
|
|
1534
|
+
* Return the cumulative sum of the elements along a given axis.
|
|
1535
|
+
* @param a - Input array
|
|
1536
|
+
* @param axis - Axis along which to compute. If undefined, flattened array is used.
|
|
1537
|
+
* @returns Array with cumulative sums
|
|
1538
|
+
*/
|
|
1539
|
+
export declare function cumsum(a: NDArray, axis?: number): NDArray;
|
|
1540
|
+
/**
|
|
1541
|
+
* Return the cumulative product of the elements along a given axis.
|
|
1542
|
+
* @param a - Input array
|
|
1543
|
+
* @param axis - Axis along which to compute. If undefined, flattened array is used.
|
|
1544
|
+
* @returns Array with cumulative products
|
|
1545
|
+
*/
|
|
1546
|
+
export declare function cumprod(a: NDArray, axis?: number): NDArray;
|
|
1547
|
+
/**
|
|
1548
|
+
* Peak to peak (maximum - minimum) value along a given axis.
|
|
1549
|
+
* @param a - Input array
|
|
1550
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1551
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1552
|
+
* @returns Peak to peak value(s)
|
|
1553
|
+
*/
|
|
1554
|
+
export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1555
|
+
/**
|
|
1556
|
+
* Compute the median along the specified axis.
|
|
1557
|
+
* @param a - Input array
|
|
1558
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1559
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1560
|
+
* @returns Median value(s)
|
|
1561
|
+
*/
|
|
1562
|
+
export declare function median(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1563
|
+
/**
|
|
1564
|
+
* Compute the q-th percentile of the data along the specified axis.
|
|
1565
|
+
* @param a - Input array
|
|
1566
|
+
* @param q - Percentile (0-100)
|
|
1567
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1568
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1569
|
+
* @returns Percentile value(s)
|
|
1570
|
+
*/
|
|
1571
|
+
export declare function percentile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1572
|
+
/**
|
|
1573
|
+
* Compute the q-th quantile of the data along the specified axis.
|
|
1574
|
+
* @param a - Input array
|
|
1575
|
+
* @param q - Quantile (0-1)
|
|
1576
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1577
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1578
|
+
* @returns Quantile value(s)
|
|
1579
|
+
*/
|
|
1580
|
+
export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1581
|
+
/**
|
|
1582
|
+
* Compute the weighted average along the specified axis.
|
|
1583
|
+
* @param a - Input array
|
|
1584
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1585
|
+
* @param weights - Array of weights (must be same shape as array along specified axis)
|
|
1586
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1587
|
+
* @returns Weighted average value(s)
|
|
1588
|
+
*/
|
|
1589
|
+
export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number;
|
|
1590
|
+
/**
|
|
1591
|
+
* Return the sum of array elements over a given axis, treating NaNs as zero.
|
|
1592
|
+
* @param a - Input array
|
|
1593
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1594
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1595
|
+
* @returns Sum value(s)
|
|
1596
|
+
*/
|
|
1597
|
+
export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1598
|
+
/**
|
|
1599
|
+
* Return the product of array elements over a given axis, treating NaNs as one.
|
|
1600
|
+
* @param a - Input array
|
|
1601
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1602
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1603
|
+
* @returns Product value(s)
|
|
1604
|
+
*/
|
|
1605
|
+
export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1606
|
+
/**
|
|
1607
|
+
* Compute the arithmetic mean along the specified axis, ignoring NaNs.
|
|
1608
|
+
* @param a - Input array
|
|
1609
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1610
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1611
|
+
* @returns Mean value(s)
|
|
1612
|
+
*/
|
|
1613
|
+
export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1614
|
+
/**
|
|
1615
|
+
* Compute the variance along the specified axis, ignoring NaNs.
|
|
1616
|
+
* @param a - Input array
|
|
1617
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1618
|
+
* @param ddof - Delta degrees of freedom (default 0)
|
|
1619
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1620
|
+
* @returns Variance value(s)
|
|
1621
|
+
*/
|
|
1622
|
+
export declare function nanvar(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
|
|
1623
|
+
/**
|
|
1624
|
+
* Compute the standard deviation along the specified axis, ignoring NaNs.
|
|
1625
|
+
* @param a - Input array
|
|
1626
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1627
|
+
* @param ddof - Delta degrees of freedom (default 0)
|
|
1628
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1629
|
+
* @returns Standard deviation value(s)
|
|
1630
|
+
*/
|
|
1631
|
+
export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
|
|
1632
|
+
/**
|
|
1633
|
+
* Return minimum of an array, ignoring NaNs.
|
|
1634
|
+
* @param a - Input array
|
|
1635
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1636
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1637
|
+
* @returns Minimum value(s)
|
|
1638
|
+
*/
|
|
1639
|
+
export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1640
|
+
/**
|
|
1641
|
+
* Return maximum of an array, ignoring NaNs.
|
|
1642
|
+
* @param a - Input array
|
|
1643
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1644
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1645
|
+
* @returns Maximum value(s)
|
|
1646
|
+
*/
|
|
1647
|
+
export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1648
|
+
/**
|
|
1649
|
+
* Return indices of the minimum value, ignoring NaNs.
|
|
1650
|
+
* @param a - Input array
|
|
1651
|
+
* @param axis - Axis along which to compute. If undefined, use flattened array.
|
|
1652
|
+
* @returns Index/indices of minimum value(s)
|
|
1653
|
+
*/
|
|
1654
|
+
export declare function nanargmin(a: NDArray, axis?: number): NDArray | number;
|
|
1655
|
+
/**
|
|
1656
|
+
* Return indices of the maximum value, ignoring NaNs.
|
|
1657
|
+
* @param a - Input array
|
|
1658
|
+
* @param axis - Axis along which to compute. If undefined, use flattened array.
|
|
1659
|
+
* @returns Index/indices of maximum value(s)
|
|
1660
|
+
*/
|
|
1661
|
+
export declare function nanargmax(a: NDArray, axis?: number): NDArray | number;
|
|
1662
|
+
/**
|
|
1663
|
+
* Return cumulative sum of elements, treating NaNs as zero.
|
|
1664
|
+
* @param a - Input array
|
|
1665
|
+
* @param axis - Axis along which to compute. If undefined, use flattened array.
|
|
1666
|
+
* @returns Array with cumulative sums
|
|
1667
|
+
*/
|
|
1668
|
+
export declare function nancumsum(a: NDArray, axis?: number): NDArray;
|
|
1669
|
+
/**
|
|
1670
|
+
* Return cumulative product of elements, treating NaNs as one.
|
|
1671
|
+
* @param a - Input array
|
|
1672
|
+
* @param axis - Axis along which to compute. If undefined, use flattened array.
|
|
1673
|
+
* @returns Array with cumulative products
|
|
1674
|
+
*/
|
|
1675
|
+
export declare function nancumprod(a: NDArray, axis?: number): NDArray;
|
|
1676
|
+
/**
|
|
1677
|
+
* Compute the median, ignoring NaNs.
|
|
1678
|
+
* @param a - Input array
|
|
1679
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
1680
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1681
|
+
* @returns Median value(s)
|
|
1682
|
+
*/
|
|
1683
|
+
export declare function nanmedian(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
1684
|
+
/**
|
|
1685
|
+
* Element-wise cube root
|
|
1686
|
+
*
|
|
1687
|
+
* @param x - Input array
|
|
1688
|
+
* @returns Array with cube root of each element
|
|
1689
|
+
*/
|
|
1690
|
+
export declare function cbrt(x: NDArray): NDArray;
|
|
1691
|
+
/**
|
|
1692
|
+
* Element-wise absolute value (always returns float)
|
|
1693
|
+
*
|
|
1694
|
+
* @param x - Input array
|
|
1695
|
+
* @returns Array with absolute values as float
|
|
1696
|
+
*/
|
|
1697
|
+
export declare function fabs(x: NDArray): NDArray;
|
|
1698
|
+
/**
|
|
1699
|
+
* Returns both quotient and remainder (floor divide and modulo)
|
|
1700
|
+
*
|
|
1701
|
+
* @param x - Dividend array
|
|
1702
|
+
* @param y - Divisor (array or scalar)
|
|
1703
|
+
* @returns Tuple of [quotient, remainder] arrays
|
|
1704
|
+
*/
|
|
1705
|
+
export declare function divmod(x: NDArray, y: NDArray | number): [NDArray, NDArray];
|
|
1706
|
+
/**
|
|
1707
|
+
* Element-wise square (x**2)
|
|
1708
|
+
*
|
|
1709
|
+
* @param x - Input array
|
|
1710
|
+
* @returns Array with squared values
|
|
1711
|
+
*/
|
|
1712
|
+
export declare function square(x: NDArray): NDArray;
|
|
1713
|
+
/**
|
|
1714
|
+
* Element-wise remainder (same as mod)
|
|
1715
|
+
*
|
|
1716
|
+
* @param x - Dividend array
|
|
1717
|
+
* @param y - Divisor (array or scalar)
|
|
1718
|
+
* @returns Array with remainder values
|
|
1719
|
+
*/
|
|
1720
|
+
export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
|
|
1721
|
+
/**
|
|
1722
|
+
* Heaviside step function
|
|
1723
|
+
*
|
|
1724
|
+
* @param x1 - Input array
|
|
1725
|
+
* @param x2 - Value to use when x1 is 0
|
|
1726
|
+
* @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
|
|
1727
|
+
*/
|
|
1728
|
+
export declare function heaviside(x1: NDArray, x2: NDArray | number): NDArray;
|
|
1729
|
+
/**
|
|
1730
|
+
* Einstein summation convention
|
|
1731
|
+
*
|
|
1732
|
+
* Performs tensor contractions and reductions using Einstein notation.
|
|
1733
|
+
*
|
|
1734
|
+
* @param subscripts - Einstein summation subscripts (e.g., 'ij,jk->ik')
|
|
1735
|
+
* @param operands - Input arrays
|
|
1736
|
+
* @returns Result of the Einstein summation
|
|
1737
|
+
*
|
|
1738
|
+
* @example
|
|
1739
|
+
* // Matrix multiplication
|
|
1740
|
+
* einsum('ij,jk->ik', a, b)
|
|
1741
|
+
*
|
|
1742
|
+
* @example
|
|
1743
|
+
* // Inner product
|
|
1744
|
+
* einsum('i,i->', a, b)
|
|
1745
|
+
*
|
|
1746
|
+
* @example
|
|
1747
|
+
* // Trace
|
|
1748
|
+
* einsum('ii->', a)
|
|
1749
|
+
*/
|
|
1750
|
+
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
|
|
642
1751
|
//# sourceMappingURL=ndarray.d.ts.map
|