numpy-ts 0.5.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.
@@ -363,6 +363,137 @@ export declare class NDArray {
363
363
  * @returns Boolean or array of booleans
364
364
  */
365
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;
366
497
  /**
367
498
  * Reshape array to a new shape
368
499
  * Returns a new array with the specified shape
@@ -468,6 +599,40 @@ export declare class NDArray {
468
599
  * @returns Tensor dot product result
469
600
  */
470
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;
471
636
  /**
472
637
  * Slice the array using NumPy-style string syntax
473
638
  *
@@ -647,6 +812,130 @@ export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
647
812
  * @returns Filled array
648
813
  */
649
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;
650
939
  /**
651
940
  * Element-wise square root
652
941
  * @param x - Input array
@@ -730,6 +1019,24 @@ export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
730
1019
  * @returns Sum of diagonal elements
731
1020
  */
732
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;
733
1040
  /**
734
1041
  * Permute array dimensions
735
1042
  *
@@ -831,6 +1138,18 @@ export declare function degrees(x: NDArray): NDArray;
831
1138
  * @returns Angles in radians
832
1139
  */
833
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;
834
1153
  /**
835
1154
  * Element-wise hyperbolic sine
836
1155
  * @param x - Input array
@@ -973,6 +1292,175 @@ export declare function tile(a: NDArray, reps: number | number[]): NDArray;
973
1292
  * @returns Array with repeated elements
974
1293
  */
975
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;
976
1464
  /**
977
1465
  * Broadcast an array to a given shape
978
1466
  *
@@ -988,6 +1476,17 @@ export declare function broadcast_to(a: NDArray, shape: number[]): NDArray;
988
1476
  * @returns Arrays broadcast to common shape
989
1477
  */
990
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[];
991
1490
  /**
992
1491
  * Take elements from an array along an axis
993
1492
  *
@@ -1022,4 +1521,231 @@ export declare function choose(a: NDArray, choices: NDArray[]): NDArray;
1022
1521
  * @returns True if arrays are equal element-wise
1023
1522
  */
1024
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;
1025
1751
  //# sourceMappingURL=ndarray.d.ts.map