numpy-ts 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -24
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -3
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +3 -3
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/core/complex.d.ts +94 -0
- package/dist/types/core/dtype.d.ts +62 -3
- package/dist/types/core/ndarray.d.ts +950 -52
- package/dist/types/core/storage.d.ts +15 -4
- package/dist/types/index.d.ts +6 -5
- package/dist/types/ops/advanced.d.ts +65 -0
- package/dist/types/ops/arithmetic.d.ts +103 -0
- package/dist/types/ops/bitwise.d.ts +30 -0
- package/dist/types/ops/comparison.d.ts +6 -0
- package/dist/types/ops/complex.d.ts +65 -0
- package/dist/types/ops/exponential.d.ts +9 -0
- package/dist/types/ops/hyperbolic.d.ts +6 -0
- package/dist/types/ops/linalg.d.ts +130 -5
- package/dist/types/ops/logic.d.ts +35 -17
- package/dist/types/ops/reduction.d.ts +34 -18
- package/dist/types/ops/rounding.d.ts +3 -0
- package/dist/types/ops/sets.d.ts +49 -0
- package/dist/types/ops/shape.d.ts +13 -0
- package/dist/types/ops/statistics.d.ts +22 -0
- package/dist/types/ops/trig.d.ts +6 -0
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Core array class providing NumPy-like API
|
|
5
5
|
*/
|
|
6
6
|
import { type DType, type TypedArray } from './dtype';
|
|
7
|
+
import { Complex } from './complex';
|
|
7
8
|
import { ArrayStorage } from './storage';
|
|
8
9
|
export declare class NDArray {
|
|
9
10
|
private _storage;
|
|
@@ -61,19 +62,22 @@ export declare class NDArray {
|
|
|
61
62
|
* Iterator protocol - iterate over the first axis
|
|
62
63
|
* For 1D arrays, yields elements; for ND arrays, yields (N-1)D subarrays
|
|
63
64
|
*/
|
|
64
|
-
[Symbol.iterator](): Iterator<NDArray | number | bigint>;
|
|
65
|
+
[Symbol.iterator](): Iterator<NDArray | number | bigint | Complex>;
|
|
65
66
|
/**
|
|
66
67
|
* Get a single element from the array
|
|
67
68
|
* @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
|
|
68
|
-
* @returns The element value (BigInt for int64/uint64, number otherwise)
|
|
69
|
+
* @returns The element value (BigInt for int64/uint64, Complex for complex, number otherwise)
|
|
69
70
|
*/
|
|
70
|
-
get(indices: number[]): number | bigint;
|
|
71
|
+
get(indices: number[]): number | bigint | Complex;
|
|
71
72
|
/**
|
|
72
73
|
* Set a single element in the array
|
|
73
74
|
* @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
|
|
74
75
|
* @param value - Value to set (will be converted to array's dtype)
|
|
75
76
|
*/
|
|
76
|
-
set(indices: number[], value: number | bigint
|
|
77
|
+
set(indices: number[], value: number | bigint | Complex | {
|
|
78
|
+
re: number;
|
|
79
|
+
im: number;
|
|
80
|
+
}): void;
|
|
77
81
|
/**
|
|
78
82
|
* Return a deep copy of the array
|
|
79
83
|
*/
|
|
@@ -515,7 +519,7 @@ export declare class NDArray {
|
|
|
515
519
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
516
520
|
* @returns Sum of array elements, or array of sums along axis
|
|
517
521
|
*/
|
|
518
|
-
sum(axis?: number, keepdims?: boolean): NDArray | number;
|
|
522
|
+
sum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
519
523
|
/**
|
|
520
524
|
* Compute the arithmetic mean along the specified axis
|
|
521
525
|
* @param axis - Axis along which to compute mean. If undefined, compute mean of all elements
|
|
@@ -524,28 +528,28 @@ export declare class NDArray {
|
|
|
524
528
|
*
|
|
525
529
|
* Note: mean() returns float64 for integer dtypes, matching NumPy behavior
|
|
526
530
|
*/
|
|
527
|
-
mean(axis?: number, keepdims?: boolean): NDArray | number;
|
|
531
|
+
mean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
528
532
|
/**
|
|
529
533
|
* Return the maximum along a given axis
|
|
530
534
|
* @param axis - Axis along which to compute maximum. If undefined, compute maximum of all elements
|
|
531
535
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
532
536
|
* @returns Maximum of array elements, or array of maximums along axis
|
|
533
537
|
*/
|
|
534
|
-
max(axis?: number, keepdims?: boolean): NDArray | number;
|
|
538
|
+
max(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
535
539
|
/**
|
|
536
540
|
* Return the minimum along a given axis
|
|
537
541
|
* @param axis - Axis along which to compute minimum. If undefined, compute minimum of all elements
|
|
538
542
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
539
543
|
* @returns Minimum of array elements, or array of minimums along axis
|
|
540
544
|
*/
|
|
541
|
-
min(axis?: number, keepdims?: boolean): NDArray | number;
|
|
545
|
+
min(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
542
546
|
/**
|
|
543
547
|
* Product of array elements over a given axis
|
|
544
548
|
* @param axis - Axis along which to compute the product. If undefined, product of all elements.
|
|
545
549
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
546
550
|
* @returns Product of array elements, or array of products along axis
|
|
547
551
|
*/
|
|
548
|
-
prod(axis?: number, keepdims?: boolean): NDArray | number;
|
|
552
|
+
prod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
549
553
|
/**
|
|
550
554
|
* Indices of the minimum values along an axis
|
|
551
555
|
* @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
|
|
@@ -606,7 +610,7 @@ export declare class NDArray {
|
|
|
606
610
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
607
611
|
* @returns Range of values
|
|
608
612
|
*/
|
|
609
|
-
ptp(axis?: number, keepdims?: boolean): NDArray | number;
|
|
613
|
+
ptp(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
610
614
|
/**
|
|
611
615
|
* Compute the median along the specified axis
|
|
612
616
|
* @param axis - Axis along which to compute median. If undefined, compute over all elements.
|
|
@@ -636,28 +640,28 @@ export declare class NDArray {
|
|
|
636
640
|
* @param axis - Axis along which to compute average. If undefined, compute over all elements.
|
|
637
641
|
* @returns Weighted average of array elements
|
|
638
642
|
*/
|
|
639
|
-
average(weights?: NDArray, axis?: number): NDArray | number;
|
|
643
|
+
average(weights?: NDArray, axis?: number): NDArray | number | Complex;
|
|
640
644
|
/**
|
|
641
645
|
* Return the sum of array elements, treating NaNs as zero
|
|
642
646
|
* @param axis - Axis along which to compute sum. If undefined, compute over all elements.
|
|
643
647
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
644
648
|
* @returns Sum of array elements ignoring NaNs
|
|
645
649
|
*/
|
|
646
|
-
nansum(axis?: number, keepdims?: boolean): NDArray | number;
|
|
650
|
+
nansum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
647
651
|
/**
|
|
648
652
|
* Return the product of array elements, treating NaNs as ones
|
|
649
653
|
* @param axis - Axis along which to compute product. If undefined, compute over all elements.
|
|
650
654
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
651
655
|
* @returns Product of array elements ignoring NaNs
|
|
652
656
|
*/
|
|
653
|
-
nanprod(axis?: number, keepdims?: boolean): NDArray | number;
|
|
657
|
+
nanprod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
654
658
|
/**
|
|
655
659
|
* Compute the arithmetic mean, ignoring NaNs
|
|
656
660
|
* @param axis - Axis along which to compute mean. If undefined, compute over all elements.
|
|
657
661
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
658
662
|
* @returns Mean of array elements ignoring NaNs
|
|
659
663
|
*/
|
|
660
|
-
nanmean(axis?: number, keepdims?: boolean): NDArray | number;
|
|
664
|
+
nanmean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
661
665
|
/**
|
|
662
666
|
* Compute the variance, ignoring NaNs
|
|
663
667
|
* @param axis - Axis along which to compute variance. If undefined, compute over all elements.
|
|
@@ -680,14 +684,30 @@ export declare class NDArray {
|
|
|
680
684
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
681
685
|
* @returns Minimum of array elements ignoring NaNs
|
|
682
686
|
*/
|
|
683
|
-
nanmin(axis?: number, keepdims?: boolean): NDArray | number;
|
|
687
|
+
nanmin(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
684
688
|
/**
|
|
685
689
|
* Return maximum of an array or maximum along an axis, ignoring NaNs
|
|
686
690
|
* @param axis - Axis along which to compute maximum. If undefined, compute over all elements.
|
|
687
691
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
688
692
|
* @returns Maximum of array elements ignoring NaNs
|
|
689
693
|
*/
|
|
690
|
-
nanmax(axis?: number, keepdims?: boolean): NDArray | number;
|
|
694
|
+
nanmax(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
695
|
+
/**
|
|
696
|
+
* Compute the q-th quantile of the data along the specified axis, ignoring NaNs
|
|
697
|
+
* @param q - Quantile to compute (0-1)
|
|
698
|
+
* @param axis - Axis along which to compute quantile. If undefined, compute over all elements.
|
|
699
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
700
|
+
* @returns Quantile of array elements ignoring NaNs
|
|
701
|
+
*/
|
|
702
|
+
nanquantile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
703
|
+
/**
|
|
704
|
+
* Compute the q-th percentile of the data along the specified axis, ignoring NaNs
|
|
705
|
+
* @param q - Percentile to compute (0-100)
|
|
706
|
+
* @param axis - Axis along which to compute percentile. If undefined, compute over all elements.
|
|
707
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
708
|
+
* @returns Percentile of array elements ignoring NaNs
|
|
709
|
+
*/
|
|
710
|
+
nanpercentile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
691
711
|
/**
|
|
692
712
|
* Return the indices of the minimum values, ignoring NaNs
|
|
693
713
|
* @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
|
|
@@ -839,6 +859,56 @@ export declare class NDArray {
|
|
|
839
859
|
* @param values - Values to put
|
|
840
860
|
*/
|
|
841
861
|
put(indices: number[], values: NDArray | number | bigint): void;
|
|
862
|
+
/**
|
|
863
|
+
* Integer array indexing (fancy indexing)
|
|
864
|
+
*
|
|
865
|
+
* Select elements using an array of indices. This is NumPy's "fancy indexing"
|
|
866
|
+
* feature: `arr[[0, 2, 4]]` becomes `arr.iindex([0, 2, 4])` or `arr.iindex(indices)`.
|
|
867
|
+
*
|
|
868
|
+
* @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
|
|
869
|
+
* @param axis - Axis along which to index (default: 0, or flattens if undefined with flat indices)
|
|
870
|
+
* @returns New array with selected elements
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* ```typescript
|
|
874
|
+
* const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
|
875
|
+
*
|
|
876
|
+
* // Select rows 0 and 2
|
|
877
|
+
* arr.iindex([0, 2]); // [[1, 2, 3], [7, 8, 9]]
|
|
878
|
+
*
|
|
879
|
+
* // Select along axis 1 (columns)
|
|
880
|
+
* arr.iindex([0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
|
|
881
|
+
*
|
|
882
|
+
* // With NDArray indices
|
|
883
|
+
* const idx = np.array([0, 2]);
|
|
884
|
+
* arr.iindex(idx); // [[1, 2, 3], [7, 8, 9]]
|
|
885
|
+
* ```
|
|
886
|
+
*/
|
|
887
|
+
iindex(indices: NDArray | number[] | number[][], axis?: number): NDArray;
|
|
888
|
+
/**
|
|
889
|
+
* Boolean array indexing (fancy indexing with mask)
|
|
890
|
+
*
|
|
891
|
+
* Select elements where a boolean mask is true. This is NumPy's boolean
|
|
892
|
+
* indexing: `arr[arr > 5]` becomes `arr.bindex(arr.greater(5))`.
|
|
893
|
+
*
|
|
894
|
+
* @param mask - Boolean NDArray mask
|
|
895
|
+
* @param axis - Axis along which to apply the mask (default: flattens array)
|
|
896
|
+
* @returns New 1D array with selected elements (or along axis if specified)
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* ```typescript
|
|
900
|
+
* const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
|
901
|
+
*
|
|
902
|
+
* // Select all elements > 5
|
|
903
|
+
* const mask = arr.greater(5);
|
|
904
|
+
* arr.bindex(mask); // [6, 7, 8, 9]
|
|
905
|
+
*
|
|
906
|
+
* // Select rows where first column > 3
|
|
907
|
+
* const rowMask = np.array([false, true, true]);
|
|
908
|
+
* arr.bindex(rowMask, 0); // [[4, 5, 6], [7, 8, 9]]
|
|
909
|
+
* ```
|
|
910
|
+
*/
|
|
911
|
+
bindex(mask: NDArray, axis?: number): NDArray;
|
|
842
912
|
/**
|
|
843
913
|
* Matrix multiplication
|
|
844
914
|
* @param other - Array to multiply with
|
|
@@ -848,20 +918,20 @@ export declare class NDArray {
|
|
|
848
918
|
/**
|
|
849
919
|
* Dot product (matching NumPy behavior)
|
|
850
920
|
* @param other - Array to dot with
|
|
851
|
-
* @returns Result of dot product (scalar or array depending on dimensions)
|
|
921
|
+
* @returns Result of dot product (scalar or array depending on dimensions, Complex for complex arrays)
|
|
852
922
|
*/
|
|
853
|
-
dot(other: NDArray): NDArray | number | bigint;
|
|
923
|
+
dot(other: NDArray): NDArray | number | bigint | Complex;
|
|
854
924
|
/**
|
|
855
925
|
* Sum of diagonal elements (trace)
|
|
856
|
-
* @returns Sum of diagonal elements
|
|
926
|
+
* @returns Sum of diagonal elements (Complex for complex arrays)
|
|
857
927
|
*/
|
|
858
|
-
trace(): number | bigint;
|
|
928
|
+
trace(): number | bigint | Complex;
|
|
859
929
|
/**
|
|
860
930
|
* Inner product (contracts over last axes of both arrays)
|
|
861
931
|
* @param other - Array to compute inner product with
|
|
862
|
-
* @returns Inner product result
|
|
932
|
+
* @returns Inner product result (Complex for complex arrays)
|
|
863
933
|
*/
|
|
864
|
-
inner(other: NDArray): NDArray | number | bigint;
|
|
934
|
+
inner(other: NDArray): NDArray | number | bigint | Complex;
|
|
865
935
|
/**
|
|
866
936
|
* Outer product (flattens inputs then computes a[i]*b[j])
|
|
867
937
|
* @param other - Array to compute outer product with
|
|
@@ -874,7 +944,7 @@ export declare class NDArray {
|
|
|
874
944
|
* @param axes - Axes to contract (integer or [a_axes, b_axes])
|
|
875
945
|
* @returns Tensor dot product result
|
|
876
946
|
*/
|
|
877
|
-
tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
|
|
947
|
+
tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
|
|
878
948
|
/**
|
|
879
949
|
* Element-wise cube root
|
|
880
950
|
* Promotes integer types to float64
|
|
@@ -952,6 +1022,30 @@ export declare class NDArray {
|
|
|
952
1022
|
* @returns Nested JavaScript array representation
|
|
953
1023
|
*/
|
|
954
1024
|
toArray(): any;
|
|
1025
|
+
/**
|
|
1026
|
+
* Return the array as a nested list (same as toArray)
|
|
1027
|
+
*/
|
|
1028
|
+
tolist(): any;
|
|
1029
|
+
/**
|
|
1030
|
+
* Return the raw bytes of the array data
|
|
1031
|
+
*/
|
|
1032
|
+
tobytes(): ArrayBuffer;
|
|
1033
|
+
/**
|
|
1034
|
+
* Copy an element of an array to a standard scalar and return it
|
|
1035
|
+
*/
|
|
1036
|
+
item(...args: number[]): number | bigint | Complex;
|
|
1037
|
+
/**
|
|
1038
|
+
* Swap the bytes of the array elements
|
|
1039
|
+
*/
|
|
1040
|
+
byteswap(inplace?: boolean): NDArray;
|
|
1041
|
+
/**
|
|
1042
|
+
* Return a view of the array with a different dtype
|
|
1043
|
+
*/
|
|
1044
|
+
view(dtype?: DType): NDArray;
|
|
1045
|
+
/**
|
|
1046
|
+
* Write array to a file (stub - use node.ts module for file operations)
|
|
1047
|
+
*/
|
|
1048
|
+
tofile(_file: string, _sep?: string, _format?: string): void;
|
|
955
1049
|
}
|
|
956
1050
|
/**
|
|
957
1051
|
* Create array of zeros
|
|
@@ -1053,6 +1147,22 @@ export declare function identity(n: number, dtype?: DType): NDArray;
|
|
|
1053
1147
|
* @returns NDArray representation of the input
|
|
1054
1148
|
*/
|
|
1055
1149
|
export declare function asarray(a: NDArray | any, dtype?: DType): NDArray;
|
|
1150
|
+
/**
|
|
1151
|
+
* Convert input to an array, checking for NaN and Inf values.
|
|
1152
|
+
* @param a - Input data
|
|
1153
|
+
* @param dtype - Data type (optional)
|
|
1154
|
+
* @returns NDArray
|
|
1155
|
+
* @throws If array contains NaN or Inf values
|
|
1156
|
+
*/
|
|
1157
|
+
export declare function asarray_chkfinite(a: NDArray | ArrayLike<number | bigint>, dtype?: DType): NDArray;
|
|
1158
|
+
/**
|
|
1159
|
+
* Return array satisfying requirements.
|
|
1160
|
+
* @param a - Input array
|
|
1161
|
+
* @param dtype - Data type (optional)
|
|
1162
|
+
* @param requirements - Requirements ('C', 'F', 'A', 'W', 'O', 'E') (optional)
|
|
1163
|
+
* @returns Array satisfying requirements
|
|
1164
|
+
*/
|
|
1165
|
+
export declare function require(a: NDArray, dtype?: DType, requirements?: string | string[]): NDArray;
|
|
1056
1166
|
/**
|
|
1057
1167
|
* Create a deep copy of an array
|
|
1058
1168
|
* @param a - Array to copy
|
|
@@ -1355,16 +1465,16 @@ export declare function reciprocal(x: NDArray): NDArray;
|
|
|
1355
1465
|
*
|
|
1356
1466
|
* @param a - First array
|
|
1357
1467
|
* @param b - Second array
|
|
1358
|
-
* @returns Result of dot product
|
|
1468
|
+
* @returns Result of dot product (Complex for complex arrays)
|
|
1359
1469
|
*/
|
|
1360
|
-
export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
|
|
1470
|
+
export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
|
|
1361
1471
|
/**
|
|
1362
1472
|
* Sum of diagonal elements
|
|
1363
1473
|
*
|
|
1364
1474
|
* @param a - Input 2D array
|
|
1365
|
-
* @returns Sum of diagonal elements
|
|
1475
|
+
* @returns Sum of diagonal elements (Complex for complex arrays)
|
|
1366
1476
|
*/
|
|
1367
|
-
export declare function trace(a: NDArray): number | bigint;
|
|
1477
|
+
export declare function trace(a: NDArray): number | bigint | Complex;
|
|
1368
1478
|
/**
|
|
1369
1479
|
* Extract a diagonal from a matrix or N-D array
|
|
1370
1480
|
*
|
|
@@ -1399,9 +1509,9 @@ export declare function transpose(a: NDArray, axes?: number[]): NDArray;
|
|
|
1399
1509
|
*
|
|
1400
1510
|
* @param a - First array
|
|
1401
1511
|
* @param b - Second array
|
|
1402
|
-
* @returns Inner product result
|
|
1512
|
+
* @returns Inner product result (Complex for complex arrays)
|
|
1403
1513
|
*/
|
|
1404
|
-
export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint;
|
|
1514
|
+
export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
|
|
1405
1515
|
/**
|
|
1406
1516
|
* Outer product of two arrays
|
|
1407
1517
|
*
|
|
@@ -1420,7 +1530,7 @@ export declare function outer(a: NDArray, b: NDArray): NDArray;
|
|
|
1420
1530
|
* @param axes - Axes to contract (integer or [a_axes, b_axes])
|
|
1421
1531
|
* @returns Tensor dot product
|
|
1422
1532
|
*/
|
|
1423
|
-
export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
|
|
1533
|
+
export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
|
|
1424
1534
|
/**
|
|
1425
1535
|
* Element-wise sine
|
|
1426
1536
|
* @param x - Input array (angles in radians)
|
|
@@ -1594,6 +1704,18 @@ export declare function hstack(arrays: NDArray[]): NDArray;
|
|
|
1594
1704
|
* @returns Depth-stacked array
|
|
1595
1705
|
*/
|
|
1596
1706
|
export declare function dstack(arrays: NDArray[]): NDArray;
|
|
1707
|
+
/**
|
|
1708
|
+
* Join a sequence of arrays along an existing axis (alias for concatenate)
|
|
1709
|
+
*/
|
|
1710
|
+
export declare function concat(arrays: NDArray[], axis?: number): NDArray;
|
|
1711
|
+
/**
|
|
1712
|
+
* Split an array into a sequence of sub-arrays along an axis (inverse of stack)
|
|
1713
|
+
*/
|
|
1714
|
+
export declare function unstack(a: NDArray, axis?: number): NDArray[];
|
|
1715
|
+
/**
|
|
1716
|
+
* Assemble an nd-array from nested lists of blocks
|
|
1717
|
+
*/
|
|
1718
|
+
export declare function block(arrays: NDArray[]): NDArray;
|
|
1597
1719
|
/**
|
|
1598
1720
|
* Split array into multiple sub-arrays
|
|
1599
1721
|
*
|
|
@@ -1652,6 +1774,38 @@ export declare function repeat(a: NDArray, repeats: number | number[], axis?: nu
|
|
|
1652
1774
|
* @returns Flattened 1-D array (view if possible)
|
|
1653
1775
|
*/
|
|
1654
1776
|
export declare function ravel(a: NDArray): NDArray;
|
|
1777
|
+
/**
|
|
1778
|
+
* Return a copy of the array collapsed into one dimension
|
|
1779
|
+
*/
|
|
1780
|
+
export declare function flatten(a: NDArray): NDArray;
|
|
1781
|
+
/**
|
|
1782
|
+
* Fill the array with a scalar value (in-place)
|
|
1783
|
+
*/
|
|
1784
|
+
export declare function fill(a: NDArray, value: number | bigint): void;
|
|
1785
|
+
/**
|
|
1786
|
+
* Copy an element of an array to a standard scalar and return it
|
|
1787
|
+
*/
|
|
1788
|
+
export declare function item(a: NDArray, ...args: number[]): number | bigint | Complex;
|
|
1789
|
+
/**
|
|
1790
|
+
* Return the array as a nested list
|
|
1791
|
+
*/
|
|
1792
|
+
export declare function tolist(a: NDArray): any;
|
|
1793
|
+
/**
|
|
1794
|
+
* Return the raw bytes of the array data
|
|
1795
|
+
*/
|
|
1796
|
+
export declare function tobytes(a: NDArray): ArrayBuffer;
|
|
1797
|
+
/**
|
|
1798
|
+
* Swap the bytes of the array elements
|
|
1799
|
+
*/
|
|
1800
|
+
export declare function byteswap(a: NDArray, inplace?: boolean): NDArray;
|
|
1801
|
+
/**
|
|
1802
|
+
* New view of array with the same data
|
|
1803
|
+
*/
|
|
1804
|
+
export declare function view(a: NDArray, dtype?: DType): NDArray;
|
|
1805
|
+
/**
|
|
1806
|
+
* Write array to a file as text or binary
|
|
1807
|
+
*/
|
|
1808
|
+
export declare function tofile(a: NDArray, file: string, sep?: string, format?: string): void;
|
|
1655
1809
|
/**
|
|
1656
1810
|
* Reshape array to new shape
|
|
1657
1811
|
*
|
|
@@ -1857,6 +2011,44 @@ export declare function take(a: NDArray, indices: number[], axis?: number): NDAr
|
|
|
1857
2011
|
* @param values - Values to put
|
|
1858
2012
|
*/
|
|
1859
2013
|
export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
|
|
2014
|
+
/**
|
|
2015
|
+
* Integer array indexing (fancy indexing)
|
|
2016
|
+
*
|
|
2017
|
+
* Select elements from an array using an array of indices.
|
|
2018
|
+
* NumPy equivalent: `arr[[0, 2, 4]]`
|
|
2019
|
+
*
|
|
2020
|
+
* @param a - Input array
|
|
2021
|
+
* @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
|
|
2022
|
+
* @param axis - Axis along which to index (default: 0)
|
|
2023
|
+
* @returns New array with selected elements
|
|
2024
|
+
*
|
|
2025
|
+
* @example
|
|
2026
|
+
* ```typescript
|
|
2027
|
+
* const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
|
2028
|
+
* np.iindex(arr, [0, 2]); // [[1, 2, 3], [7, 8, 9]]
|
|
2029
|
+
* np.iindex(arr, [0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
|
|
2030
|
+
* ```
|
|
2031
|
+
*/
|
|
2032
|
+
export declare function iindex(a: NDArray, indices: NDArray | number[] | number[][], axis?: number): NDArray;
|
|
2033
|
+
/**
|
|
2034
|
+
* Boolean array indexing (fancy indexing with mask)
|
|
2035
|
+
*
|
|
2036
|
+
* Select elements from an array where a boolean mask is true.
|
|
2037
|
+
* NumPy equivalent: `arr[arr > 5]`
|
|
2038
|
+
*
|
|
2039
|
+
* @param a - Input array
|
|
2040
|
+
* @param mask - Boolean NDArray mask
|
|
2041
|
+
* @param axis - Axis along which to apply the mask (default: flattens array)
|
|
2042
|
+
* @returns New array with selected elements
|
|
2043
|
+
*
|
|
2044
|
+
* @example
|
|
2045
|
+
* ```typescript
|
|
2046
|
+
* const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
|
|
2047
|
+
* const mask = arr.greater(5);
|
|
2048
|
+
* np.bindex(arr, mask); // [6, 7, 8, 9]
|
|
2049
|
+
* ```
|
|
2050
|
+
*/
|
|
2051
|
+
export declare function bindex(a: NDArray, mask: NDArray, axis?: number): NDArray;
|
|
1860
2052
|
/**
|
|
1861
2053
|
* Copy values from one array to another, broadcasting as necessary.
|
|
1862
2054
|
*
|
|
@@ -1922,7 +2114,7 @@ export { cumprod as cumulative_prod };
|
|
|
1922
2114
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1923
2115
|
* @returns Maximum value(s)
|
|
1924
2116
|
*/
|
|
1925
|
-
export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2117
|
+
export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
1926
2118
|
export { max as amax };
|
|
1927
2119
|
/**
|
|
1928
2120
|
* Return the minimum along a given axis.
|
|
@@ -1931,7 +2123,7 @@ export { max as amax };
|
|
|
1931
2123
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1932
2124
|
* @returns Minimum value(s)
|
|
1933
2125
|
*/
|
|
1934
|
-
export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2126
|
+
export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
1935
2127
|
export { min as amin };
|
|
1936
2128
|
/**
|
|
1937
2129
|
* Peak to peak (maximum - minimum) value along a given axis.
|
|
@@ -1940,7 +2132,7 @@ export { min as amin };
|
|
|
1940
2132
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1941
2133
|
* @returns Peak to peak value(s)
|
|
1942
2134
|
*/
|
|
1943
|
-
export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2135
|
+
export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
1944
2136
|
/**
|
|
1945
2137
|
* Compute the median along the specified axis.
|
|
1946
2138
|
* @param a - Input array
|
|
@@ -1975,7 +2167,7 @@ export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?
|
|
|
1975
2167
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1976
2168
|
* @returns Weighted average value(s)
|
|
1977
2169
|
*/
|
|
1978
|
-
export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number;
|
|
2170
|
+
export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number | Complex;
|
|
1979
2171
|
/**
|
|
1980
2172
|
* Return the sum of array elements over a given axis, treating NaNs as zero.
|
|
1981
2173
|
* @param a - Input array
|
|
@@ -1983,7 +2175,7 @@ export declare function average(a: NDArray, axis?: number, weights?: NDArray, ke
|
|
|
1983
2175
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1984
2176
|
* @returns Sum value(s)
|
|
1985
2177
|
*/
|
|
1986
|
-
export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2178
|
+
export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
1987
2179
|
/**
|
|
1988
2180
|
* Return the product of array elements over a given axis, treating NaNs as one.
|
|
1989
2181
|
* @param a - Input array
|
|
@@ -1991,7 +2183,7 @@ export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): N
|
|
|
1991
2183
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1992
2184
|
* @returns Product value(s)
|
|
1993
2185
|
*/
|
|
1994
|
-
export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2186
|
+
export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
1995
2187
|
/**
|
|
1996
2188
|
* Compute the arithmetic mean along the specified axis, ignoring NaNs.
|
|
1997
2189
|
* @param a - Input array
|
|
@@ -1999,7 +2191,7 @@ export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean):
|
|
|
1999
2191
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
2000
2192
|
* @returns Mean value(s)
|
|
2001
2193
|
*/
|
|
2002
|
-
export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2194
|
+
export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
2003
2195
|
/**
|
|
2004
2196
|
* Compute the variance along the specified axis, ignoring NaNs.
|
|
2005
2197
|
* @param a - Input array
|
|
@@ -2025,7 +2217,7 @@ export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdim
|
|
|
2025
2217
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
2026
2218
|
* @returns Minimum value(s)
|
|
2027
2219
|
*/
|
|
2028
|
-
export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2220
|
+
export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
2029
2221
|
/**
|
|
2030
2222
|
* Return maximum of an array, ignoring NaNs.
|
|
2031
2223
|
* @param a - Input array
|
|
@@ -2033,7 +2225,7 @@ export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): N
|
|
|
2033
2225
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
2034
2226
|
* @returns Maximum value(s)
|
|
2035
2227
|
*/
|
|
2036
|
-
export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2228
|
+
export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
2037
2229
|
/**
|
|
2038
2230
|
* Return indices of the minimum value, ignoring NaNs.
|
|
2039
2231
|
* @param a - Input array
|
|
@@ -2070,6 +2262,14 @@ export declare function nancumprod(a: NDArray, axis?: number): NDArray;
|
|
|
2070
2262
|
* @returns Median value(s)
|
|
2071
2263
|
*/
|
|
2072
2264
|
export declare function nanmedian(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2265
|
+
/**
|
|
2266
|
+
* Compute the q-th quantile of data along specified axis, ignoring NaNs
|
|
2267
|
+
*/
|
|
2268
|
+
export declare function nanquantile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2269
|
+
/**
|
|
2270
|
+
* Compute the q-th percentile of data along specified axis, ignoring NaNs
|
|
2271
|
+
*/
|
|
2272
|
+
export declare function nanpercentile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
|
|
2073
2273
|
/**
|
|
2074
2274
|
* Element-wise cube root
|
|
2075
2275
|
*
|
|
@@ -2164,6 +2364,116 @@ export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
|
|
|
2164
2364
|
* @returns Tuple of [fractional, integral] arrays
|
|
2165
2365
|
*/
|
|
2166
2366
|
export declare function modf(x: NDArray): [NDArray, NDArray];
|
|
2367
|
+
/**
|
|
2368
|
+
* Clip (limit) the values in an array.
|
|
2369
|
+
*
|
|
2370
|
+
* Given an interval, values outside the interval are clipped to the interval edges.
|
|
2371
|
+
*
|
|
2372
|
+
* @param a - Input array
|
|
2373
|
+
* @param a_min - Minimum value (null to not clip minimum)
|
|
2374
|
+
* @param a_max - Maximum value (null to not clip maximum)
|
|
2375
|
+
* @returns Clipped array
|
|
2376
|
+
*/
|
|
2377
|
+
export declare function clip(a: NDArray, a_min: NDArray | number | null, a_max: NDArray | number | null): NDArray;
|
|
2378
|
+
/**
|
|
2379
|
+
* Element-wise maximum of array elements.
|
|
2380
|
+
*
|
|
2381
|
+
* Compare two arrays and return a new array containing the element-wise maxima.
|
|
2382
|
+
* If one of the elements being compared is a NaN, then that element is returned.
|
|
2383
|
+
*
|
|
2384
|
+
* @param x1 - First input array
|
|
2385
|
+
* @param x2 - Second input array or scalar
|
|
2386
|
+
* @returns Element-wise maximum
|
|
2387
|
+
*/
|
|
2388
|
+
export declare function maximum(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2389
|
+
/**
|
|
2390
|
+
* Element-wise minimum of array elements.
|
|
2391
|
+
*
|
|
2392
|
+
* Compare two arrays and return a new array containing the element-wise minima.
|
|
2393
|
+
* If one of the elements being compared is a NaN, then that element is returned.
|
|
2394
|
+
*
|
|
2395
|
+
* @param x1 - First input array
|
|
2396
|
+
* @param x2 - Second input array or scalar
|
|
2397
|
+
* @returns Element-wise minimum
|
|
2398
|
+
*/
|
|
2399
|
+
export declare function minimum(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2400
|
+
/**
|
|
2401
|
+
* Element-wise maximum of array elements, ignoring NaNs.
|
|
2402
|
+
*
|
|
2403
|
+
* Compare two arrays and return a new array containing the element-wise maxima.
|
|
2404
|
+
* If one of the values being compared is a NaN, the other is returned.
|
|
2405
|
+
*
|
|
2406
|
+
* @param x1 - First input array
|
|
2407
|
+
* @param x2 - Second input array or scalar
|
|
2408
|
+
* @returns Element-wise maximum, NaN-aware
|
|
2409
|
+
*/
|
|
2410
|
+
export declare function fmax(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2411
|
+
/**
|
|
2412
|
+
* Element-wise minimum of array elements, ignoring NaNs.
|
|
2413
|
+
*
|
|
2414
|
+
* Compare two arrays and return a new array containing the element-wise minima.
|
|
2415
|
+
* If one of the values being compared is a NaN, the other is returned.
|
|
2416
|
+
*
|
|
2417
|
+
* @param x1 - First input array
|
|
2418
|
+
* @param x2 - Second input array or scalar
|
|
2419
|
+
* @returns Element-wise minimum, NaN-aware
|
|
2420
|
+
*/
|
|
2421
|
+
export declare function fmin(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2422
|
+
/**
|
|
2423
|
+
* Replace NaN with zero and Inf with large finite numbers.
|
|
2424
|
+
*
|
|
2425
|
+
* @param x - Input array
|
|
2426
|
+
* @param nan - Value to replace NaN (default: 0.0)
|
|
2427
|
+
* @param posinf - Value to replace positive infinity (default: largest finite)
|
|
2428
|
+
* @param neginf - Value to replace negative infinity (default: most negative finite)
|
|
2429
|
+
* @returns Array with replacements
|
|
2430
|
+
*/
|
|
2431
|
+
export declare function nan_to_num(x: NDArray, nan?: number, posinf?: number, neginf?: number): NDArray;
|
|
2432
|
+
/**
|
|
2433
|
+
* One-dimensional linear interpolation.
|
|
2434
|
+
*
|
|
2435
|
+
* Returns the one-dimensional piecewise linear interpolant to a function
|
|
2436
|
+
* with given discrete data points (xp, fp), evaluated at x.
|
|
2437
|
+
*
|
|
2438
|
+
* @param x - The x-coordinates at which to evaluate the interpolated values
|
|
2439
|
+
* @param xp - The x-coordinates of the data points (must be increasing)
|
|
2440
|
+
* @param fp - The y-coordinates of the data points
|
|
2441
|
+
* @param left - Value for x < xp[0] (default: fp[0])
|
|
2442
|
+
* @param right - Value for x > xp[-1] (default: fp[-1])
|
|
2443
|
+
* @returns Interpolated values
|
|
2444
|
+
*/
|
|
2445
|
+
export declare function interp(x: NDArray, xp: NDArray, fp: NDArray, left?: number, right?: number): NDArray;
|
|
2446
|
+
/**
|
|
2447
|
+
* Unwrap by changing deltas between values to 2*pi complement.
|
|
2448
|
+
*
|
|
2449
|
+
* Unwrap radian phase p by changing absolute jumps greater than
|
|
2450
|
+
* discont to their 2*pi complement along the given axis.
|
|
2451
|
+
*
|
|
2452
|
+
* @param p - Input array of phase angles in radians
|
|
2453
|
+
* @param discont - Maximum discontinuity between values (default: pi)
|
|
2454
|
+
* @param axis - Axis along which to unwrap (default: -1, last axis)
|
|
2455
|
+
* @param period - Size of the range over which the input wraps (default: 2*pi)
|
|
2456
|
+
* @returns Unwrapped array
|
|
2457
|
+
*/
|
|
2458
|
+
export declare function unwrap(p: NDArray, discont?: number, axis?: number, period?: number): NDArray;
|
|
2459
|
+
/**
|
|
2460
|
+
* Return the normalized sinc function.
|
|
2461
|
+
*
|
|
2462
|
+
* sinc(x) = sin(pi*x) / (pi*x)
|
|
2463
|
+
*
|
|
2464
|
+
* The sinc function is 1 at x = 0, and sin(pi*x)/(pi*x) otherwise.
|
|
2465
|
+
*
|
|
2466
|
+
* @param x - Input array
|
|
2467
|
+
* @returns Array of sinc values
|
|
2468
|
+
*/
|
|
2469
|
+
export declare function sinc(x: NDArray): NDArray;
|
|
2470
|
+
/**
|
|
2471
|
+
* Modified Bessel function of the first kind, order 0.
|
|
2472
|
+
*
|
|
2473
|
+
* @param x - Input array
|
|
2474
|
+
* @returns Array of I0 values
|
|
2475
|
+
*/
|
|
2476
|
+
export declare function i0(x: NDArray): NDArray;
|
|
2167
2477
|
/**
|
|
2168
2478
|
* Bitwise AND element-wise
|
|
2169
2479
|
*
|
|
@@ -2242,6 +2552,36 @@ export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | '
|
|
|
2242
2552
|
* @returns Unpacked uint8 array of 0s and 1s
|
|
2243
2553
|
*/
|
|
2244
2554
|
export declare function unpackbits(a: NDArray, axis?: number, count?: number, bitorder?: 'big' | 'little'): NDArray;
|
|
2555
|
+
/**
|
|
2556
|
+
* Count the number of 1-bits (population count) in each element.
|
|
2557
|
+
*
|
|
2558
|
+
* @param x - Input array (must be integer type)
|
|
2559
|
+
* @returns Array with population count for each element
|
|
2560
|
+
*/
|
|
2561
|
+
export declare function bitwise_count(x: NDArray): NDArray;
|
|
2562
|
+
/**
|
|
2563
|
+
* Bitwise invert (alias for bitwise_not).
|
|
2564
|
+
*
|
|
2565
|
+
* @param x - Input array (must be integer type)
|
|
2566
|
+
* @returns Result with bitwise NOT values
|
|
2567
|
+
*/
|
|
2568
|
+
export declare function bitwise_invert(x: NDArray): NDArray;
|
|
2569
|
+
/**
|
|
2570
|
+
* Bitwise left shift (alias for left_shift).
|
|
2571
|
+
*
|
|
2572
|
+
* @param x1 - Input array (must be integer type)
|
|
2573
|
+
* @param x2 - Shift amount (array or scalar)
|
|
2574
|
+
* @returns Result with left-shifted values
|
|
2575
|
+
*/
|
|
2576
|
+
export declare function bitwise_left_shift(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2577
|
+
/**
|
|
2578
|
+
* Bitwise right shift (alias for right_shift).
|
|
2579
|
+
*
|
|
2580
|
+
* @param x1 - Input array (must be integer type)
|
|
2581
|
+
* @param x2 - Shift amount (array or scalar)
|
|
2582
|
+
* @returns Result with right-shifted values
|
|
2583
|
+
*/
|
|
2584
|
+
export declare function bitwise_right_shift(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2245
2585
|
/**
|
|
2246
2586
|
* Logical AND element-wise
|
|
2247
2587
|
*
|
|
@@ -2346,33 +2686,82 @@ export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
|
|
|
2346
2686
|
*/
|
|
2347
2687
|
export declare function spacing(x: NDArray): NDArray;
|
|
2348
2688
|
/**
|
|
2349
|
-
* Test element-wise for complex number
|
|
2350
|
-
*
|
|
2689
|
+
* Test element-wise for complex number.
|
|
2690
|
+
*
|
|
2691
|
+
* For complex arrays, returns true for elements with non-zero imaginary part.
|
|
2692
|
+
* For real arrays, always returns false.
|
|
2693
|
+
*
|
|
2351
2694
|
* @param x - Input array
|
|
2352
|
-
* @returns Boolean array
|
|
2695
|
+
* @returns Boolean array
|
|
2353
2696
|
*/
|
|
2354
2697
|
export declare function iscomplex(x: NDArray): NDArray;
|
|
2355
2698
|
/**
|
|
2356
|
-
* Check whether array is complex type
|
|
2357
|
-
*
|
|
2699
|
+
* Check whether array is complex type.
|
|
2700
|
+
*
|
|
2358
2701
|
* @param x - Input array
|
|
2359
|
-
* @returns
|
|
2702
|
+
* @returns true if dtype is complex64 or complex128
|
|
2360
2703
|
*/
|
|
2361
2704
|
export declare function iscomplexobj(x: NDArray): boolean;
|
|
2362
2705
|
/**
|
|
2363
|
-
* Test element-wise for real number (not complex)
|
|
2364
|
-
*
|
|
2706
|
+
* Test element-wise for real number (not complex).
|
|
2707
|
+
*
|
|
2708
|
+
* For complex arrays, returns true for elements with zero imaginary part.
|
|
2709
|
+
* For real arrays, always returns true.
|
|
2710
|
+
*
|
|
2365
2711
|
* @param x - Input array
|
|
2366
|
-
* @returns Boolean array
|
|
2712
|
+
* @returns Boolean array
|
|
2367
2713
|
*/
|
|
2368
2714
|
export declare function isreal(x: NDArray): NDArray;
|
|
2369
2715
|
/**
|
|
2370
|
-
* Check whether array is real type (not complex)
|
|
2371
|
-
*
|
|
2716
|
+
* Check whether array is real type (not complex).
|
|
2717
|
+
*
|
|
2372
2718
|
* @param x - Input array
|
|
2373
|
-
* @returns true
|
|
2719
|
+
* @returns true if dtype is NOT complex64 or complex128
|
|
2374
2720
|
*/
|
|
2375
2721
|
export declare function isrealobj(x: NDArray): boolean;
|
|
2722
|
+
/**
|
|
2723
|
+
* Return the real part of complex argument.
|
|
2724
|
+
*
|
|
2725
|
+
* For complex arrays, returns the real components.
|
|
2726
|
+
* For real arrays, returns a copy of the input.
|
|
2727
|
+
*
|
|
2728
|
+
* @param x - Input array
|
|
2729
|
+
* @returns Array with real parts
|
|
2730
|
+
*/
|
|
2731
|
+
export declare function real(x: NDArray): NDArray;
|
|
2732
|
+
/**
|
|
2733
|
+
* Return the imaginary part of complex argument.
|
|
2734
|
+
*
|
|
2735
|
+
* For complex arrays, returns the imaginary components.
|
|
2736
|
+
* For real arrays, returns zeros.
|
|
2737
|
+
*
|
|
2738
|
+
* @param x - Input array
|
|
2739
|
+
* @returns Array with imaginary parts
|
|
2740
|
+
*/
|
|
2741
|
+
export declare function imag(x: NDArray): NDArray;
|
|
2742
|
+
/**
|
|
2743
|
+
* Return the complex conjugate.
|
|
2744
|
+
*
|
|
2745
|
+
* For complex arrays, negates the imaginary part: (a + bi) -> (a - bi)
|
|
2746
|
+
* For real arrays, returns a copy of the input.
|
|
2747
|
+
*
|
|
2748
|
+
* @param x - Input array
|
|
2749
|
+
* @returns Complex conjugate array
|
|
2750
|
+
*/
|
|
2751
|
+
export declare function conj(x: NDArray): NDArray;
|
|
2752
|
+
export declare const conjugate: typeof conj;
|
|
2753
|
+
/**
|
|
2754
|
+
* Return the angle (phase) of complex argument.
|
|
2755
|
+
*
|
|
2756
|
+
* angle(z) = arctan2(imag(z), real(z))
|
|
2757
|
+
*
|
|
2758
|
+
* For real arrays, returns 0 for positive, pi for negative.
|
|
2759
|
+
*
|
|
2760
|
+
* @param x - Input array
|
|
2761
|
+
* @param deg - Return angle in degrees if true (default: false, returns radians)
|
|
2762
|
+
* @returns Array with angles in radians (or degrees)
|
|
2763
|
+
*/
|
|
2764
|
+
export declare function angle(x: NDArray, deg?: boolean): NDArray;
|
|
2376
2765
|
/**
|
|
2377
2766
|
* Test element-wise for negative infinity
|
|
2378
2767
|
* @param x - Input array
|
|
@@ -2446,7 +2835,72 @@ export declare function promote_types(dtype1: DType, dtype2: DType): DType;
|
|
|
2446
2835
|
* // Trace
|
|
2447
2836
|
* einsum('ii->', a)
|
|
2448
2837
|
*/
|
|
2449
|
-
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
|
|
2838
|
+
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint | Complex;
|
|
2839
|
+
/**
|
|
2840
|
+
* Return the dot product of two vectors (flattened).
|
|
2841
|
+
*
|
|
2842
|
+
* Unlike dot(), vdot flattens both inputs before computing the dot product.
|
|
2843
|
+
* For complex numbers, vdot uses the complex conjugate of the first argument.
|
|
2844
|
+
*
|
|
2845
|
+
* @param a - First input array (will be flattened)
|
|
2846
|
+
* @param b - Second input array (will be flattened)
|
|
2847
|
+
* @returns Scalar dot product
|
|
2848
|
+
*/
|
|
2849
|
+
export declare function vdot(a: NDArray, b: NDArray): number | bigint | Complex;
|
|
2850
|
+
/**
|
|
2851
|
+
* Vector dot product along the last axis.
|
|
2852
|
+
*
|
|
2853
|
+
* Computes the dot product of vectors along the last axis of both inputs.
|
|
2854
|
+
* The last dimensions of a and b must match.
|
|
2855
|
+
*
|
|
2856
|
+
* @param a - First input array
|
|
2857
|
+
* @param b - Second input array
|
|
2858
|
+
* @param axis - Axis along which to compute (default: -1, meaning last axis)
|
|
2859
|
+
* @returns Result with last dimension removed
|
|
2860
|
+
*/
|
|
2861
|
+
export declare function vecdot(a: NDArray, b: NDArray, axis?: number): NDArray | number | bigint | Complex;
|
|
2862
|
+
/**
|
|
2863
|
+
* Transpose the last two axes of an array.
|
|
2864
|
+
*
|
|
2865
|
+
* Equivalent to swapaxes(a, -2, -1) or transpose with axes that swap the last two.
|
|
2866
|
+
* For a 2D array, this is the same as transpose.
|
|
2867
|
+
*
|
|
2868
|
+
* @param a - Input array with at least 2 dimensions
|
|
2869
|
+
* @returns Array with last two axes transposed
|
|
2870
|
+
*/
|
|
2871
|
+
export declare function matrix_transpose(a: NDArray): NDArray;
|
|
2872
|
+
/**
|
|
2873
|
+
* Permute the dimensions of an array.
|
|
2874
|
+
*
|
|
2875
|
+
* This is an alias for transpose to match the Array API standard.
|
|
2876
|
+
*
|
|
2877
|
+
* @param a - Input array
|
|
2878
|
+
* @param axes - Permutation of axes. If not specified, reverses the axes.
|
|
2879
|
+
* @returns Transposed array
|
|
2880
|
+
*/
|
|
2881
|
+
export declare function permute_dims(a: NDArray, axes?: number[]): NDArray;
|
|
2882
|
+
/**
|
|
2883
|
+
* Matrix-vector multiplication.
|
|
2884
|
+
*
|
|
2885
|
+
* Computes the matrix-vector product over the last two axes of x1 and
|
|
2886
|
+
* the last axis of x2.
|
|
2887
|
+
*
|
|
2888
|
+
* @param x1 - First input array (matrix) with shape (..., M, N)
|
|
2889
|
+
* @param x2 - Second input array (vector) with shape (..., N)
|
|
2890
|
+
* @returns Result with shape (..., M)
|
|
2891
|
+
*/
|
|
2892
|
+
export declare function matvec(x1: NDArray, x2: NDArray): NDArray;
|
|
2893
|
+
/**
|
|
2894
|
+
* Vector-matrix multiplication.
|
|
2895
|
+
*
|
|
2896
|
+
* Computes the vector-matrix product over the last axis of x1 and
|
|
2897
|
+
* the second-to-last axis of x2.
|
|
2898
|
+
*
|
|
2899
|
+
* @param x1 - First input array (vector) with shape (..., M)
|
|
2900
|
+
* @param x2 - Second input array (matrix) with shape (..., M, N)
|
|
2901
|
+
* @returns Result with shape (..., N)
|
|
2902
|
+
*/
|
|
2903
|
+
export declare function vecmat(x1: NDArray, x2: NDArray): NDArray;
|
|
2450
2904
|
/**
|
|
2451
2905
|
* numpy.linalg module - Linear algebra functions
|
|
2452
2906
|
*/
|
|
@@ -2548,6 +3002,57 @@ export declare const linalg: {
|
|
|
2548
3002
|
* Compute eigenvalues of a Hermitian matrix.
|
|
2549
3003
|
*/
|
|
2550
3004
|
eigvalsh: (a: NDArray, UPLO?: "L" | "U") => NDArray;
|
|
3005
|
+
/**
|
|
3006
|
+
* Return specified diagonals.
|
|
3007
|
+
*/
|
|
3008
|
+
diagonal: (a: NDArray, offset?: number, axis1?: number, axis2?: number) => NDArray;
|
|
3009
|
+
/**
|
|
3010
|
+
* Matrix multiplication.
|
|
3011
|
+
*/
|
|
3012
|
+
matmul: (a: NDArray, b: NDArray) => NDArray;
|
|
3013
|
+
/**
|
|
3014
|
+
* Transpose the last two axes of an array.
|
|
3015
|
+
*/
|
|
3016
|
+
matrix_transpose: (a: NDArray) => NDArray;
|
|
3017
|
+
/**
|
|
3018
|
+
* Compute the dot product of two or more arrays.
|
|
3019
|
+
*/
|
|
3020
|
+
multi_dot: (arrays: NDArray[]) => NDArray;
|
|
3021
|
+
/**
|
|
3022
|
+
* Outer product of two vectors.
|
|
3023
|
+
*/
|
|
3024
|
+
outer: (a: NDArray, b: NDArray) => NDArray;
|
|
3025
|
+
/**
|
|
3026
|
+
* Compute sign and (natural) logarithm of the determinant.
|
|
3027
|
+
*/
|
|
3028
|
+
slogdet: (a: NDArray) => {
|
|
3029
|
+
sign: number;
|
|
3030
|
+
logabsdet: number;
|
|
3031
|
+
};
|
|
3032
|
+
/**
|
|
3033
|
+
* Compute singular values of a matrix.
|
|
3034
|
+
*/
|
|
3035
|
+
svdvals: (a: NDArray) => NDArray;
|
|
3036
|
+
/**
|
|
3037
|
+
* Tensor dot product along specified axes.
|
|
3038
|
+
*/
|
|
3039
|
+
tensordot: (a: NDArray, b: NDArray, axes?: number | [number[], number[]]) => NDArray | number | bigint | Complex;
|
|
3040
|
+
/**
|
|
3041
|
+
* Compute the tensor inverse.
|
|
3042
|
+
*/
|
|
3043
|
+
tensorinv: (a: NDArray, ind?: number) => NDArray;
|
|
3044
|
+
/**
|
|
3045
|
+
* Solve the tensor equation a x = b for x.
|
|
3046
|
+
*/
|
|
3047
|
+
tensorsolve: (a: NDArray, b: NDArray, axes?: number[] | null) => NDArray;
|
|
3048
|
+
/**
|
|
3049
|
+
* Sum along diagonals.
|
|
3050
|
+
*/
|
|
3051
|
+
trace: (a: NDArray) => number | bigint | Complex;
|
|
3052
|
+
/**
|
|
3053
|
+
* Vector dot product.
|
|
3054
|
+
*/
|
|
3055
|
+
vecdot: (a: NDArray, b: NDArray, axis?: number) => NDArray | number | bigint | Complex;
|
|
2551
3056
|
};
|
|
2552
3057
|
/**
|
|
2553
3058
|
* Take values from the input array by matching 1d index and data slices along axis.
|
|
@@ -2896,6 +3401,55 @@ export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
|
2896
3401
|
* @returns Sorted 1D array of unique values from both arrays
|
|
2897
3402
|
*/
|
|
2898
3403
|
export declare function union1d(ar1: NDArray, ar2: NDArray): NDArray;
|
|
3404
|
+
/**
|
|
3405
|
+
* Trim leading and/or trailing zeros from a 1-D array.
|
|
3406
|
+
*
|
|
3407
|
+
* @param filt - Input 1-D array
|
|
3408
|
+
* @param trim - 'fb' to trim front and back, 'f' for front only, 'b' for back only (default: 'fb')
|
|
3409
|
+
* @returns Trimmed array
|
|
3410
|
+
*/
|
|
3411
|
+
export declare function trim_zeros(filt: NDArray, trim?: 'f' | 'b' | 'fb'): NDArray;
|
|
3412
|
+
/**
|
|
3413
|
+
* Find the unique elements of an array, returning all optional outputs.
|
|
3414
|
+
*
|
|
3415
|
+
* @param x - Input array (flattened for uniqueness)
|
|
3416
|
+
* @returns Object with values, indices, inverse_indices, and counts (all as NDArray)
|
|
3417
|
+
*/
|
|
3418
|
+
export declare function unique_all(x: NDArray): {
|
|
3419
|
+
values: NDArray;
|
|
3420
|
+
indices: NDArray;
|
|
3421
|
+
inverse_indices: NDArray;
|
|
3422
|
+
counts: NDArray;
|
|
3423
|
+
};
|
|
3424
|
+
/**
|
|
3425
|
+
* Find the unique elements of an array and their counts.
|
|
3426
|
+
*
|
|
3427
|
+
* @param x - Input array (flattened for uniqueness)
|
|
3428
|
+
* @returns Object with values and counts (both as NDArray)
|
|
3429
|
+
*/
|
|
3430
|
+
export declare function unique_counts(x: NDArray): {
|
|
3431
|
+
values: NDArray;
|
|
3432
|
+
counts: NDArray;
|
|
3433
|
+
};
|
|
3434
|
+
/**
|
|
3435
|
+
* Find the unique elements of an array and their inverse indices.
|
|
3436
|
+
*
|
|
3437
|
+
* @param x - Input array (flattened for uniqueness)
|
|
3438
|
+
* @returns Object with values and inverse_indices (both as NDArray)
|
|
3439
|
+
*/
|
|
3440
|
+
export declare function unique_inverse(x: NDArray): {
|
|
3441
|
+
values: NDArray;
|
|
3442
|
+
inverse_indices: NDArray;
|
|
3443
|
+
};
|
|
3444
|
+
/**
|
|
3445
|
+
* Find the unique elements of an array (values only).
|
|
3446
|
+
*
|
|
3447
|
+
* This is equivalent to unique(x) but with a clearer name for the Array API.
|
|
3448
|
+
*
|
|
3449
|
+
* @param x - Input array (flattened for uniqueness)
|
|
3450
|
+
* @returns Array of unique values, sorted
|
|
3451
|
+
*/
|
|
3452
|
+
export declare function unique_values(x: NDArray): NDArray;
|
|
2899
3453
|
/**
|
|
2900
3454
|
* Calculate the n-th discrete difference along the given axis
|
|
2901
3455
|
* @param a - Input array
|
|
@@ -3022,4 +3576,348 @@ export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: bo
|
|
|
3022
3576
|
* @returns Correlation coefficient matrix
|
|
3023
3577
|
*/
|
|
3024
3578
|
export declare function corrcoef(x: NDArray, y?: NDArray, rowvar?: boolean): NDArray;
|
|
3579
|
+
/**
|
|
3580
|
+
* Compute the edges of the bins for histogram.
|
|
3581
|
+
*
|
|
3582
|
+
* This function computes the bin edges without computing the histogram itself.
|
|
3583
|
+
*
|
|
3584
|
+
* @param a - Input data (flattened if not 1D)
|
|
3585
|
+
* @param bins - Number of bins (default: 10) or a string specifying the bin algorithm
|
|
3586
|
+
* @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
|
|
3587
|
+
* @param weights - Optional weights for each data point (used for some algorithms)
|
|
3588
|
+
* @returns Array of bin edges (length = bins + 1)
|
|
3589
|
+
*/
|
|
3590
|
+
export declare function histogram_bin_edges(a: NDArray, bins?: number | 'auto' | 'fd' | 'doane' | 'scott' | 'stone' | 'rice' | 'sturges' | 'sqrt', range?: [number, number], weights?: NDArray): NDArray;
|
|
3591
|
+
/**
|
|
3592
|
+
* Integrate along the given axis using the composite trapezoidal rule.
|
|
3593
|
+
*
|
|
3594
|
+
* @param y - Input array to integrate
|
|
3595
|
+
* @param x - Optional sample points corresponding to y values. If not provided, spacing is assumed to be 1.
|
|
3596
|
+
* @param dx - Spacing between sample points when x is not given (default: 1.0)
|
|
3597
|
+
* @param axis - The axis along which to integrate (default: -1, meaning last axis)
|
|
3598
|
+
* @returns Definite integral approximated using the composite trapezoidal rule
|
|
3599
|
+
*/
|
|
3600
|
+
export declare function trapezoid(y: NDArray, x?: NDArray, dx?: number, axis?: number): NDArray | number;
|
|
3601
|
+
/**
|
|
3602
|
+
* Apply a function along a given axis.
|
|
3603
|
+
*
|
|
3604
|
+
* @param func1d - Function that takes a 1D array and returns a scalar or array
|
|
3605
|
+
* @param axis - Axis along which to apply the function
|
|
3606
|
+
* @param arr - Input array
|
|
3607
|
+
* @returns Result array
|
|
3608
|
+
*/
|
|
3609
|
+
export declare function apply_along_axis(func1d: (arr: NDArray) => NDArray | number, axis: number, arr: NDArray): NDArray;
|
|
3610
|
+
/**
|
|
3611
|
+
* Apply a function over multiple axes.
|
|
3612
|
+
*
|
|
3613
|
+
* @param func - Function that operates on an array along an axis
|
|
3614
|
+
* @param a - Input array
|
|
3615
|
+
* @param axes - Axes over which to apply the function
|
|
3616
|
+
* @returns Result array
|
|
3617
|
+
*/
|
|
3618
|
+
export declare function apply_over_axes(func: (a: NDArray, axis: number) => NDArray, a: NDArray, axes: number[]): NDArray;
|
|
3619
|
+
/**
|
|
3620
|
+
* Check if two arrays may share memory.
|
|
3621
|
+
*
|
|
3622
|
+
* @param a - First array
|
|
3623
|
+
* @param b - Second array
|
|
3624
|
+
* @returns True if arrays may share memory
|
|
3625
|
+
*/
|
|
3626
|
+
export declare function may_share_memory(a: NDArray, b: NDArray): boolean;
|
|
3627
|
+
/**
|
|
3628
|
+
* Check if two arrays share memory.
|
|
3629
|
+
*
|
|
3630
|
+
* @param a - First array
|
|
3631
|
+
* @param b - Second array
|
|
3632
|
+
* @returns True if arrays share memory
|
|
3633
|
+
*/
|
|
3634
|
+
export declare function shares_memory(a: NDArray, b: NDArray): boolean;
|
|
3635
|
+
/**
|
|
3636
|
+
* Return the number of dimensions of an array.
|
|
3637
|
+
*
|
|
3638
|
+
* @param a - Input array
|
|
3639
|
+
* @returns Number of dimensions
|
|
3640
|
+
*/
|
|
3641
|
+
export declare function ndim(a: NDArray | number | unknown[] | unknown): number;
|
|
3642
|
+
/**
|
|
3643
|
+
* Return the shape of an array.
|
|
3644
|
+
*
|
|
3645
|
+
* @param a - Input array
|
|
3646
|
+
* @returns Shape tuple
|
|
3647
|
+
*/
|
|
3648
|
+
export declare function shape(a: NDArray | number | unknown[] | unknown): number[];
|
|
3649
|
+
/**
|
|
3650
|
+
* Return the number of elements in an array.
|
|
3651
|
+
*
|
|
3652
|
+
* @param a - Input array
|
|
3653
|
+
* @returns Number of elements
|
|
3654
|
+
*/
|
|
3655
|
+
export declare function size(a: NDArray | number | unknown[] | unknown): number;
|
|
3656
|
+
export { geterr, seterr, type FloatErrorState } from '../ops/advanced';
|
|
3657
|
+
/**
|
|
3658
|
+
* Casting rules for safe type conversion
|
|
3659
|
+
* In 'safe' mode: casting is allowed only if the value can be represented without loss
|
|
3660
|
+
* In 'same_kind': same kind of types allowed (e.g., float to float, int to int)
|
|
3661
|
+
* In 'unsafe': any conversion is allowed
|
|
3662
|
+
*/
|
|
3663
|
+
type CastingRule = 'no' | 'equiv' | 'safe' | 'same_kind' | 'unsafe';
|
|
3664
|
+
/**
|
|
3665
|
+
* Returns true if cast between data types can occur according to the casting rule.
|
|
3666
|
+
*
|
|
3667
|
+
* @param from_dtype - Data type to cast from
|
|
3668
|
+
* @param to_dtype - Data type to cast to
|
|
3669
|
+
* @param casting - Casting rule: 'no', 'equiv', 'safe', 'same_kind', or 'unsafe'
|
|
3670
|
+
* @returns Whether the cast is allowed
|
|
3671
|
+
*
|
|
3672
|
+
* @example
|
|
3673
|
+
* ```typescript
|
|
3674
|
+
* can_cast('int32', 'float64') // true - safe upcast
|
|
3675
|
+
* can_cast('float64', 'int32') // false - would lose precision
|
|
3676
|
+
* can_cast('float64', 'int32', 'unsafe') // true - forced cast
|
|
3677
|
+
* ```
|
|
3678
|
+
*/
|
|
3679
|
+
export declare function can_cast(from_dtype: DType | NDArray, to_dtype: DType, casting?: CastingRule): boolean;
|
|
3680
|
+
/**
|
|
3681
|
+
* Return a scalar type which is common to the input arrays.
|
|
3682
|
+
*
|
|
3683
|
+
* The return type will always be an inexact (floating point) type, even if
|
|
3684
|
+
* all the input arrays are integer types.
|
|
3685
|
+
*
|
|
3686
|
+
* @param arrays - Input arrays
|
|
3687
|
+
* @returns Common scalar type ('float32' or 'float64', or complex variants)
|
|
3688
|
+
*
|
|
3689
|
+
* @example
|
|
3690
|
+
* ```typescript
|
|
3691
|
+
* const a = array([1, 2], { dtype: 'int32' });
|
|
3692
|
+
* const b = array([3.0, 4.0], { dtype: 'float32' });
|
|
3693
|
+
* common_type(a, b) // 'float32'
|
|
3694
|
+
* ```
|
|
3695
|
+
*/
|
|
3696
|
+
export declare function common_type(...arrays: NDArray[]): DType;
|
|
3697
|
+
/**
|
|
3698
|
+
* Returns the type that results from applying the NumPy type promotion rules
|
|
3699
|
+
* to the arguments.
|
|
3700
|
+
*
|
|
3701
|
+
* @param arrays_and_dtypes - A mix of arrays or dtype strings
|
|
3702
|
+
* @returns The result dtype
|
|
3703
|
+
*
|
|
3704
|
+
* @example
|
|
3705
|
+
* ```typescript
|
|
3706
|
+
* result_type('int32', 'float32') // 'float64'
|
|
3707
|
+
* result_type(array([1, 2], { dtype: 'int8' }), 'float32') // 'float32'
|
|
3708
|
+
* ```
|
|
3709
|
+
*/
|
|
3710
|
+
export declare function result_type(...arrays_and_dtypes: (NDArray | DType)[]): DType;
|
|
3711
|
+
/**
|
|
3712
|
+
* For scalar val, returns the data type with the smallest size and smallest
|
|
3713
|
+
* scalar kind which can hold its value.
|
|
3714
|
+
*
|
|
3715
|
+
* @param val - Scalar value
|
|
3716
|
+
* @returns Minimum dtype to represent the value
|
|
3717
|
+
*
|
|
3718
|
+
* @example
|
|
3719
|
+
* ```typescript
|
|
3720
|
+
* min_scalar_type(10) // 'uint8'
|
|
3721
|
+
* min_scalar_type(1000) // 'uint16'
|
|
3722
|
+
* min_scalar_type(-1) // 'int8'
|
|
3723
|
+
* min_scalar_type(3.14) // 'float64'
|
|
3724
|
+
* ```
|
|
3725
|
+
*/
|
|
3726
|
+
export declare function min_scalar_type(val: number | bigint | boolean): DType;
|
|
3727
|
+
/**
|
|
3728
|
+
* Returns true if first argument is a typecode lower/equal in type hierarchy.
|
|
3729
|
+
*
|
|
3730
|
+
* In NumPy, issubdtype checks if dtype1 is a subtype of dtype2.
|
|
3731
|
+
* For specific types (not categories), types are only subtypes of themselves.
|
|
3732
|
+
*
|
|
3733
|
+
* @param dtype1 - First dtype to check
|
|
3734
|
+
* @param dtype2 - Second dtype (or type category string)
|
|
3735
|
+
* @returns Whether dtype1 is a subtype of dtype2
|
|
3736
|
+
*
|
|
3737
|
+
* @example
|
|
3738
|
+
* ```typescript
|
|
3739
|
+
* issubdtype('int32', 'int32') // true - same type
|
|
3740
|
+
* issubdtype('int32', 'int64') // false - different types
|
|
3741
|
+
* issubdtype('int32', 'integer') // true - int32 is an integer type
|
|
3742
|
+
* issubdtype('float32', 'floating') // true - float32 is a floating type
|
|
3743
|
+
* ```
|
|
3744
|
+
*/
|
|
3745
|
+
export declare function issubdtype(dtype1: DType | NDArray, dtype2: DType | string): boolean;
|
|
3746
|
+
/**
|
|
3747
|
+
* Return a description for the given data type code.
|
|
3748
|
+
*
|
|
3749
|
+
* @param dtype - Data type to describe
|
|
3750
|
+
* @returns Human-readable description
|
|
3751
|
+
*
|
|
3752
|
+
* @example
|
|
3753
|
+
* ```typescript
|
|
3754
|
+
* typename('float64') // 'float64'
|
|
3755
|
+
* typename('int32') // 'int32'
|
|
3756
|
+
* ```
|
|
3757
|
+
*/
|
|
3758
|
+
export declare function typename(dtype: DType): string;
|
|
3759
|
+
/**
|
|
3760
|
+
* Return the character for the minimum-size type to which given types can be
|
|
3761
|
+
* safely cast.
|
|
3762
|
+
*
|
|
3763
|
+
* @param typechars - String of type characters
|
|
3764
|
+
* @param typeset - Which set of types to consider: 'GDFgdf' (default)
|
|
3765
|
+
* @param default_dtype - Default type if no valid types found
|
|
3766
|
+
* @returns Type character for minimum safe type
|
|
3767
|
+
*
|
|
3768
|
+
* @example
|
|
3769
|
+
* ```typescript
|
|
3770
|
+
* mintypecode('if') // 'd' (float64)
|
|
3771
|
+
* mintypecode('ff') // 'f' (float32)
|
|
3772
|
+
* ```
|
|
3773
|
+
*/
|
|
3774
|
+
export declare function mintypecode(typechars: string, typeset?: string, default_dtype?: string): string;
|
|
3775
|
+
/**
|
|
3776
|
+
* Find the coefficients of a polynomial with the given sequence of roots.
|
|
3777
|
+
*
|
|
3778
|
+
* Returns the coefficients of the polynomial whose leading coefficient is one
|
|
3779
|
+
* for the given sequence of zeros (multiple roots must be included in the
|
|
3780
|
+
* sequence as many times as their multiplicity).
|
|
3781
|
+
*
|
|
3782
|
+
* @param seq_of_zeros - Sequence of polynomial roots
|
|
3783
|
+
* @returns Array of polynomial coefficients, highest power first
|
|
3784
|
+
*
|
|
3785
|
+
* @example
|
|
3786
|
+
* ```typescript
|
|
3787
|
+
* poly([1, 2, 3]) // array([1, -6, 11, -6]) = (x-1)(x-2)(x-3)
|
|
3788
|
+
* poly([0, 0, 0]) // array([1, 0, 0, 0]) = x^3
|
|
3789
|
+
* ```
|
|
3790
|
+
*/
|
|
3791
|
+
export declare function poly(seq_of_zeros: NDArray | number[]): NDArray;
|
|
3792
|
+
/**
|
|
3793
|
+
* Find the sum of two polynomials.
|
|
3794
|
+
*
|
|
3795
|
+
* @param a1 - First polynomial coefficients (highest power first)
|
|
3796
|
+
* @param a2 - Second polynomial coefficients (highest power first)
|
|
3797
|
+
* @returns Sum polynomial coefficients
|
|
3798
|
+
*
|
|
3799
|
+
* @example
|
|
3800
|
+
* ```typescript
|
|
3801
|
+
* polyadd([1, 2], [3, 4, 5]) // array([3, 5, 7])
|
|
3802
|
+
* ```
|
|
3803
|
+
*/
|
|
3804
|
+
export declare function polyadd(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
|
|
3805
|
+
/**
|
|
3806
|
+
* Return the derivative of the specified order of a polynomial.
|
|
3807
|
+
*
|
|
3808
|
+
* @param p - Polynomial coefficients (highest power first)
|
|
3809
|
+
* @param m - Order of the derivative (default: 1)
|
|
3810
|
+
* @returns Derivative polynomial coefficients
|
|
3811
|
+
*
|
|
3812
|
+
* @example
|
|
3813
|
+
* ```typescript
|
|
3814
|
+
* polyder([3, 2, 1]) // array([6, 2]) - derivative of 3x^2 + 2x + 1
|
|
3815
|
+
* polyder([4, 3, 2, 1], 2) // array([24, 6]) - second derivative
|
|
3816
|
+
* ```
|
|
3817
|
+
*/
|
|
3818
|
+
export declare function polyder(p: NDArray | number[], m?: number): NDArray;
|
|
3819
|
+
/**
|
|
3820
|
+
* Returns the quotient and remainder of polynomial division.
|
|
3821
|
+
*
|
|
3822
|
+
* @param u - Dividend polynomial coefficients (highest power first)
|
|
3823
|
+
* @param v - Divisor polynomial coefficients (highest power first)
|
|
3824
|
+
* @returns Tuple [quotient, remainder]
|
|
3825
|
+
*
|
|
3826
|
+
* @example
|
|
3827
|
+
* ```typescript
|
|
3828
|
+
* polydiv([1, -3, 2], [1, -1]) // [array([1, -2]), array([0])]
|
|
3829
|
+
* // (x^2 - 3x + 2) / (x - 1) = (x - 2) with remainder 0
|
|
3830
|
+
* ```
|
|
3831
|
+
*/
|
|
3832
|
+
export declare function polydiv(u: NDArray | number[], v: NDArray | number[]): [NDArray, NDArray];
|
|
3833
|
+
/**
|
|
3834
|
+
* Least squares polynomial fit.
|
|
3835
|
+
*
|
|
3836
|
+
* Fit a polynomial p(x) = p[0] * x^deg + ... + p[deg] of degree deg to points (x, y).
|
|
3837
|
+
*
|
|
3838
|
+
* @param x - x-coordinates of the sample points
|
|
3839
|
+
* @param y - y-coordinates of the sample points
|
|
3840
|
+
* @param deg - Degree of the fitting polynomial
|
|
3841
|
+
* @returns Polynomial coefficients, highest power first
|
|
3842
|
+
*
|
|
3843
|
+
* @example
|
|
3844
|
+
* ```typescript
|
|
3845
|
+
* const x = array([0, 1, 2, 3, 4]);
|
|
3846
|
+
* const y = array([0, 1, 4, 9, 16]);
|
|
3847
|
+
* polyfit(x, y, 2) // approximately array([1, 0, 0]) for y = x^2
|
|
3848
|
+
* ```
|
|
3849
|
+
*/
|
|
3850
|
+
export declare function polyfit(x: NDArray, y: NDArray, deg: number): NDArray;
|
|
3851
|
+
/**
|
|
3852
|
+
* Return an antiderivative (indefinite integral) of a polynomial.
|
|
3853
|
+
*
|
|
3854
|
+
* @param p - Polynomial coefficients (highest power first)
|
|
3855
|
+
* @param m - Order of the antiderivative (default: 1)
|
|
3856
|
+
* @param k - Integration constants (default: 0)
|
|
3857
|
+
* @returns Antiderivative polynomial coefficients
|
|
3858
|
+
*
|
|
3859
|
+
* @example
|
|
3860
|
+
* ```typescript
|
|
3861
|
+
* polyint([3, 2, 1]) // array([1, 1, 1, 0]) - integral of 3x^2 + 2x + 1
|
|
3862
|
+
* polyint([6, 2], 1, 5) // array([2, 1, 5]) - with constant 5
|
|
3863
|
+
* ```
|
|
3864
|
+
*/
|
|
3865
|
+
export declare function polyint(p: NDArray | number[], m?: number, k?: number | number[]): NDArray;
|
|
3866
|
+
/**
|
|
3867
|
+
* Find the product of two polynomials.
|
|
3868
|
+
*
|
|
3869
|
+
* @param a1 - First polynomial coefficients (highest power first)
|
|
3870
|
+
* @param a2 - Second polynomial coefficients (highest power first)
|
|
3871
|
+
* @returns Product polynomial coefficients
|
|
3872
|
+
*
|
|
3873
|
+
* @example
|
|
3874
|
+
* ```typescript
|
|
3875
|
+
* polymul([1, 2], [1, 3]) // array([1, 5, 6]) = (x+2)(x+3)
|
|
3876
|
+
* ```
|
|
3877
|
+
*/
|
|
3878
|
+
export declare function polymul(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
|
|
3879
|
+
/**
|
|
3880
|
+
* Difference (subtraction) of two polynomials.
|
|
3881
|
+
*
|
|
3882
|
+
* @param a1 - First polynomial coefficients (highest power first)
|
|
3883
|
+
* @param a2 - Second polynomial coefficients (highest power first)
|
|
3884
|
+
* @returns Difference polynomial coefficients
|
|
3885
|
+
*
|
|
3886
|
+
* @example
|
|
3887
|
+
* ```typescript
|
|
3888
|
+
* polysub([1, 2, 3], [0, 1, 1]) // array([1, 1, 2])
|
|
3889
|
+
* ```
|
|
3890
|
+
*/
|
|
3891
|
+
export declare function polysub(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
|
|
3892
|
+
/**
|
|
3893
|
+
* Evaluate a polynomial at specific values.
|
|
3894
|
+
*
|
|
3895
|
+
* @param p - Polynomial coefficients (highest power first)
|
|
3896
|
+
* @param x - Values at which to evaluate the polynomial
|
|
3897
|
+
* @returns Polynomial values at x
|
|
3898
|
+
*
|
|
3899
|
+
* @example
|
|
3900
|
+
* ```typescript
|
|
3901
|
+
* polyval([1, -2, 1], 3) // 4 = 3^2 - 2*3 + 1
|
|
3902
|
+
* polyval([1, 0, 0], array([1, 2, 3])) // array([1, 4, 9])
|
|
3903
|
+
* ```
|
|
3904
|
+
*/
|
|
3905
|
+
export declare function polyval(p: NDArray | number[], x: NDArray | number | number[]): NDArray | number;
|
|
3906
|
+
/**
|
|
3907
|
+
* Return the roots of a polynomial with coefficients given in p.
|
|
3908
|
+
*
|
|
3909
|
+
* The values in the rank-1 array p are coefficients of a polynomial.
|
|
3910
|
+
* If the length of p is n+1 then the polynomial is:
|
|
3911
|
+
* p[0]*x^n + p[1]*x^(n-1) + ... + p[n-1]*x + p[n]
|
|
3912
|
+
*
|
|
3913
|
+
* @param p - Polynomial coefficients (highest power first)
|
|
3914
|
+
* @returns Array of roots (may be complex, returned as numbers for real roots)
|
|
3915
|
+
*
|
|
3916
|
+
* @example
|
|
3917
|
+
* ```typescript
|
|
3918
|
+
* roots([1, -3, 2]) // array([2, 1]) - roots of x^2 - 3x + 2
|
|
3919
|
+
* roots([1, 0, -1]) // array([1, -1]) - roots of x^2 - 1
|
|
3920
|
+
* ```
|
|
3921
|
+
*/
|
|
3922
|
+
export declare function roots(p: NDArray | number[]): NDArray;
|
|
3025
3923
|
//# sourceMappingURL=ndarray.d.ts.map
|