numpy-ts 0.10.0 → 0.11.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.
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Complex number class for numpy-ts
3
+ *
4
+ * Represents complex numbers in JavaScript, similar to Python's complex type.
5
+ * Used when converting complex arrays to JavaScript values via toArray().
6
+ */
7
+ /**
8
+ * Represents a complex number with real and imaginary parts.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const z = new Complex(1, 2); // 1 + 2i
13
+ * console.log(z.re); // 1
14
+ * console.log(z.im); // 2
15
+ * console.log(z.toString()); // "(1+2j)"
16
+ * ```
17
+ */
18
+ export declare class Complex {
19
+ /** Real part */
20
+ readonly re: number;
21
+ /** Imaginary part */
22
+ readonly im: number;
23
+ constructor(re: number, im?: number);
24
+ /**
25
+ * Returns the magnitude (absolute value) of the complex number.
26
+ * |z| = sqrt(re² + im²)
27
+ */
28
+ abs(): number;
29
+ /**
30
+ * Returns the phase angle (argument) of the complex number in radians.
31
+ * arg(z) = atan2(im, re)
32
+ */
33
+ angle(): number;
34
+ /**
35
+ * Returns the complex conjugate.
36
+ * conj(a + bi) = a - bi
37
+ */
38
+ conj(): Complex;
39
+ /**
40
+ * Add another complex number or real number.
41
+ */
42
+ add(other: Complex | number): Complex;
43
+ /**
44
+ * Subtract another complex number or real number.
45
+ */
46
+ sub(other: Complex | number): Complex;
47
+ /**
48
+ * Multiply by another complex number or real number.
49
+ * (a + bi)(c + di) = (ac - bd) + (ad + bc)i
50
+ */
51
+ mul(other: Complex | number): Complex;
52
+ /**
53
+ * Divide by another complex number or real number.
54
+ * (a + bi) / (c + di) = ((ac + bd) + (bc - ad)i) / (c² + d²)
55
+ */
56
+ div(other: Complex | number): Complex;
57
+ /**
58
+ * Returns the negation of this complex number.
59
+ */
60
+ neg(): Complex;
61
+ /**
62
+ * Check equality with another complex number.
63
+ */
64
+ equals(other: Complex): boolean;
65
+ /**
66
+ * String representation matching NumPy/Python format: "(a+bj)"
67
+ */
68
+ toString(): string;
69
+ /**
70
+ * Create a Complex from various input formats.
71
+ * Accepts:
72
+ * - Complex instance
73
+ * - {re, im} object
74
+ * - [re, im] array
75
+ * - number (creates re + 0i)
76
+ */
77
+ static from(value: ComplexInput): Complex;
78
+ /**
79
+ * Check if a value is a complex number representation.
80
+ */
81
+ static isComplex(value: unknown): value is ComplexInput;
82
+ }
83
+ /**
84
+ * Input types that can be converted to Complex.
85
+ */
86
+ export type ComplexInput = Complex | {
87
+ re: number;
88
+ im?: number;
89
+ } | [number, number] | number;
90
+ /**
91
+ * Helper to check if a value looks like a complex number input.
92
+ */
93
+ export declare function isComplexLike(value: unknown): value is ComplexInput;
94
+ //# sourceMappingURL=complex.d.ts.map
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Supports NumPy numeric types:
5
5
  * - Floating point: float32, float64
6
+ * - Complex: complex64, complex128
6
7
  * - Signed integers: int8, int16, int32, int64
7
8
  * - Unsigned integers: uint8, uint16, uint32, uint64
8
9
  * - Boolean: bool
@@ -10,7 +11,7 @@
10
11
  /**
11
12
  * All supported dtypes
12
13
  */
13
- export type DType = 'float64' | 'float32' | 'int64' | 'int32' | 'int16' | 'int8' | 'uint64' | 'uint32' | 'uint16' | 'uint8' | 'bool';
14
+ export type DType = 'float64' | 'float32' | 'complex128' | 'complex64' | 'int64' | 'int32' | 'int16' | 'int8' | 'uint64' | 'uint32' | 'uint16' | 'uint8' | 'bool';
14
15
  /**
15
16
  * TypedArray types for each dtype
16
17
  */
@@ -20,12 +21,16 @@ export type TypedArray = Float64Array | Float32Array | BigInt64Array | Int32Arra
20
21
  */
21
22
  export declare const DEFAULT_DTYPE: DType;
22
23
  /**
23
- * Get the TypedArray constructor for a given dtype
24
+ * Get the TypedArray constructor for a given dtype.
25
+ * For complex types, returns the underlying float array constructor.
26
+ * complex128 uses Float64Array, complex64 uses Float32Array.
27
+ * Note: Complex arrays have 2x the physical elements (interleaved real, imag).
24
28
  */
25
29
  export declare function getTypedArrayConstructor(dtype: DType): TypedArrayConstructor | null;
26
30
  type TypedArrayConstructor = Float64ArrayConstructor | Float32ArrayConstructor | BigInt64ArrayConstructor | Int32ArrayConstructor | Int16ArrayConstructor | Int8ArrayConstructor | BigUint64ArrayConstructor | Uint32ArrayConstructor | Uint16ArrayConstructor | Uint8ArrayConstructor;
27
31
  /**
28
- * Get the element size in bytes for a given dtype
32
+ * Get the element size in bytes for a given dtype.
33
+ * For complex types, returns the full element size (both real and imag parts).
29
34
  */
30
35
  export declare function getDTypeSize(dtype: DType): number;
31
36
  /**
@@ -40,6 +45,60 @@ export declare function isFloatDType(dtype: DType): boolean;
40
45
  * Check if dtype uses BigInt
41
46
  */
42
47
  export declare function isBigIntDType(dtype: DType): boolean;
48
+ /**
49
+ * Check if dtype is complex
50
+ */
51
+ export declare function isComplexDType(dtype: DType): boolean;
52
+ /**
53
+ * Throw a TypeError if the dtype is complex.
54
+ * Use this at the start of functions that don't support complex numbers.
55
+ *
56
+ * @param dtype - The dtype to check
57
+ * @param functionName - The name of the function (for error message)
58
+ * @param reason - Optional reason why complex is not supported
59
+ * @throws TypeError if dtype is complex
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * export function floor(storage: ArrayStorage): ArrayStorage {
64
+ * throwIfComplex(storage.dtype, 'floor', 'rounding is not defined for complex numbers');
65
+ * // ... rest of implementation
66
+ * }
67
+ * ```
68
+ */
69
+ export declare function throwIfComplex(dtype: DType, functionName: string, reason?: string): void;
70
+ /**
71
+ * Throw an error if the dtype is complex and the function doesn't yet support it.
72
+ * Use this for functions that SHOULD support complex but haven't been implemented yet.
73
+ *
74
+ * @param dtype - The dtype to check
75
+ * @param functionName - The name of the function (for error message)
76
+ * @throws Error if dtype is complex
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * export function sin(storage: ArrayStorage): ArrayStorage {
81
+ * throwIfComplexNotImplemented(storage.dtype, 'sin');
82
+ * // ... existing real-only implementation
83
+ * }
84
+ * ```
85
+ */
86
+ export declare function throwIfComplexNotImplemented(dtype: DType, functionName: string): void;
87
+ /**
88
+ * Get the underlying float dtype for a complex dtype.
89
+ * complex128 -> float64, complex64 -> float32
90
+ */
91
+ export declare function getComplexComponentDType(dtype: DType): 'float64' | 'float32';
92
+ /**
93
+ * Get the complex dtype for a given float component dtype.
94
+ * float64 -> complex128, float32 -> complex64
95
+ */
96
+ export declare function getComplexDType(componentDtype: 'float64' | 'float32'): 'complex128' | 'complex64';
97
+ /**
98
+ * Check if a value looks like a complex number input.
99
+ * Accepts: Complex instance, {re, im} object
100
+ */
101
+ export declare function isComplexLike(value: unknown): boolean;
43
102
  /**
44
103
  * Infer dtype from JavaScript value
45
104
  */
@@ -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): void;
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,14 @@ 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;
691
695
  /**
692
696
  * Return the indices of the minimum values, ignoring NaNs
693
697
  * @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
@@ -839,6 +843,56 @@ export declare class NDArray {
839
843
  * @param values - Values to put
840
844
  */
841
845
  put(indices: number[], values: NDArray | number | bigint): void;
846
+ /**
847
+ * Integer array indexing (fancy indexing)
848
+ *
849
+ * Select elements using an array of indices. This is NumPy's "fancy indexing"
850
+ * feature: `arr[[0, 2, 4]]` becomes `arr.iindex([0, 2, 4])` or `arr.iindex(indices)`.
851
+ *
852
+ * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
853
+ * @param axis - Axis along which to index (default: 0, or flattens if undefined with flat indices)
854
+ * @returns New array with selected elements
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
859
+ *
860
+ * // Select rows 0 and 2
861
+ * arr.iindex([0, 2]); // [[1, 2, 3], [7, 8, 9]]
862
+ *
863
+ * // Select along axis 1 (columns)
864
+ * arr.iindex([0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
865
+ *
866
+ * // With NDArray indices
867
+ * const idx = np.array([0, 2]);
868
+ * arr.iindex(idx); // [[1, 2, 3], [7, 8, 9]]
869
+ * ```
870
+ */
871
+ iindex(indices: NDArray | number[] | number[][], axis?: number): NDArray;
872
+ /**
873
+ * Boolean array indexing (fancy indexing with mask)
874
+ *
875
+ * Select elements where a boolean mask is true. This is NumPy's boolean
876
+ * indexing: `arr[arr > 5]` becomes `arr.bindex(arr.greater(5))`.
877
+ *
878
+ * @param mask - Boolean NDArray mask
879
+ * @param axis - Axis along which to apply the mask (default: flattens array)
880
+ * @returns New 1D array with selected elements (or along axis if specified)
881
+ *
882
+ * @example
883
+ * ```typescript
884
+ * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
885
+ *
886
+ * // Select all elements > 5
887
+ * const mask = arr.greater(5);
888
+ * arr.bindex(mask); // [6, 7, 8, 9]
889
+ *
890
+ * // Select rows where first column > 3
891
+ * const rowMask = np.array([false, true, true]);
892
+ * arr.bindex(rowMask, 0); // [[4, 5, 6], [7, 8, 9]]
893
+ * ```
894
+ */
895
+ bindex(mask: NDArray, axis?: number): NDArray;
842
896
  /**
843
897
  * Matrix multiplication
844
898
  * @param other - Array to multiply with
@@ -848,20 +902,20 @@ export declare class NDArray {
848
902
  /**
849
903
  * Dot product (matching NumPy behavior)
850
904
  * @param other - Array to dot with
851
- * @returns Result of dot product (scalar or array depending on dimensions)
905
+ * @returns Result of dot product (scalar or array depending on dimensions, Complex for complex arrays)
852
906
  */
853
- dot(other: NDArray): NDArray | number | bigint;
907
+ dot(other: NDArray): NDArray | number | bigint | Complex;
854
908
  /**
855
909
  * Sum of diagonal elements (trace)
856
- * @returns Sum of diagonal elements
910
+ * @returns Sum of diagonal elements (Complex for complex arrays)
857
911
  */
858
- trace(): number | bigint;
912
+ trace(): number | bigint | Complex;
859
913
  /**
860
914
  * Inner product (contracts over last axes of both arrays)
861
915
  * @param other - Array to compute inner product with
862
- * @returns Inner product result
916
+ * @returns Inner product result (Complex for complex arrays)
863
917
  */
864
- inner(other: NDArray): NDArray | number | bigint;
918
+ inner(other: NDArray): NDArray | number | bigint | Complex;
865
919
  /**
866
920
  * Outer product (flattens inputs then computes a[i]*b[j])
867
921
  * @param other - Array to compute outer product with
@@ -874,7 +928,7 @@ export declare class NDArray {
874
928
  * @param axes - Axes to contract (integer or [a_axes, b_axes])
875
929
  * @returns Tensor dot product result
876
930
  */
877
- tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
931
+ tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
878
932
  /**
879
933
  * Element-wise cube root
880
934
  * Promotes integer types to float64
@@ -1355,16 +1409,16 @@ export declare function reciprocal(x: NDArray): NDArray;
1355
1409
  *
1356
1410
  * @param a - First array
1357
1411
  * @param b - Second array
1358
- * @returns Result of dot product
1412
+ * @returns Result of dot product (Complex for complex arrays)
1359
1413
  */
1360
- export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
1414
+ export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1361
1415
  /**
1362
1416
  * Sum of diagonal elements
1363
1417
  *
1364
1418
  * @param a - Input 2D array
1365
- * @returns Sum of diagonal elements
1419
+ * @returns Sum of diagonal elements (Complex for complex arrays)
1366
1420
  */
1367
- export declare function trace(a: NDArray): number | bigint;
1421
+ export declare function trace(a: NDArray): number | bigint | Complex;
1368
1422
  /**
1369
1423
  * Extract a diagonal from a matrix or N-D array
1370
1424
  *
@@ -1399,9 +1453,9 @@ export declare function transpose(a: NDArray, axes?: number[]): NDArray;
1399
1453
  *
1400
1454
  * @param a - First array
1401
1455
  * @param b - Second array
1402
- * @returns Inner product result
1456
+ * @returns Inner product result (Complex for complex arrays)
1403
1457
  */
1404
- export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint;
1458
+ export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1405
1459
  /**
1406
1460
  * Outer product of two arrays
1407
1461
  *
@@ -1420,7 +1474,7 @@ export declare function outer(a: NDArray, b: NDArray): NDArray;
1420
1474
  * @param axes - Axes to contract (integer or [a_axes, b_axes])
1421
1475
  * @returns Tensor dot product
1422
1476
  */
1423
- export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
1477
+ export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
1424
1478
  /**
1425
1479
  * Element-wise sine
1426
1480
  * @param x - Input array (angles in radians)
@@ -1857,6 +1911,44 @@ export declare function take(a: NDArray, indices: number[], axis?: number): NDAr
1857
1911
  * @param values - Values to put
1858
1912
  */
1859
1913
  export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
1914
+ /**
1915
+ * Integer array indexing (fancy indexing)
1916
+ *
1917
+ * Select elements from an array using an array of indices.
1918
+ * NumPy equivalent: `arr[[0, 2, 4]]`
1919
+ *
1920
+ * @param a - Input array
1921
+ * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
1922
+ * @param axis - Axis along which to index (default: 0)
1923
+ * @returns New array with selected elements
1924
+ *
1925
+ * @example
1926
+ * ```typescript
1927
+ * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
1928
+ * np.iindex(arr, [0, 2]); // [[1, 2, 3], [7, 8, 9]]
1929
+ * np.iindex(arr, [0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
1930
+ * ```
1931
+ */
1932
+ export declare function iindex(a: NDArray, indices: NDArray | number[] | number[][], axis?: number): NDArray;
1933
+ /**
1934
+ * Boolean array indexing (fancy indexing with mask)
1935
+ *
1936
+ * Select elements from an array where a boolean mask is true.
1937
+ * NumPy equivalent: `arr[arr > 5]`
1938
+ *
1939
+ * @param a - Input array
1940
+ * @param mask - Boolean NDArray mask
1941
+ * @param axis - Axis along which to apply the mask (default: flattens array)
1942
+ * @returns New array with selected elements
1943
+ *
1944
+ * @example
1945
+ * ```typescript
1946
+ * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
1947
+ * const mask = arr.greater(5);
1948
+ * np.bindex(arr, mask); // [6, 7, 8, 9]
1949
+ * ```
1950
+ */
1951
+ export declare function bindex(a: NDArray, mask: NDArray, axis?: number): NDArray;
1860
1952
  /**
1861
1953
  * Copy values from one array to another, broadcasting as necessary.
1862
1954
  *
@@ -1922,7 +2014,7 @@ export { cumprod as cumulative_prod };
1922
2014
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1923
2015
  * @returns Maximum value(s)
1924
2016
  */
1925
- export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2017
+ export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
1926
2018
  export { max as amax };
1927
2019
  /**
1928
2020
  * Return the minimum along a given axis.
@@ -1931,7 +2023,7 @@ export { max as amax };
1931
2023
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1932
2024
  * @returns Minimum value(s)
1933
2025
  */
1934
- export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2026
+ export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
1935
2027
  export { min as amin };
1936
2028
  /**
1937
2029
  * Peak to peak (maximum - minimum) value along a given axis.
@@ -1940,7 +2032,7 @@ export { min as amin };
1940
2032
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1941
2033
  * @returns Peak to peak value(s)
1942
2034
  */
1943
- export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2035
+ export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
1944
2036
  /**
1945
2037
  * Compute the median along the specified axis.
1946
2038
  * @param a - Input array
@@ -1975,7 +2067,7 @@ export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?
1975
2067
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1976
2068
  * @returns Weighted average value(s)
1977
2069
  */
1978
- export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number;
2070
+ export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number | Complex;
1979
2071
  /**
1980
2072
  * Return the sum of array elements over a given axis, treating NaNs as zero.
1981
2073
  * @param a - Input array
@@ -1983,7 +2075,7 @@ export declare function average(a: NDArray, axis?: number, weights?: NDArray, ke
1983
2075
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1984
2076
  * @returns Sum value(s)
1985
2077
  */
1986
- export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2078
+ export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
1987
2079
  /**
1988
2080
  * Return the product of array elements over a given axis, treating NaNs as one.
1989
2081
  * @param a - Input array
@@ -1991,7 +2083,7 @@ export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): N
1991
2083
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
1992
2084
  * @returns Product value(s)
1993
2085
  */
1994
- export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2086
+ export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
1995
2087
  /**
1996
2088
  * Compute the arithmetic mean along the specified axis, ignoring NaNs.
1997
2089
  * @param a - Input array
@@ -1999,7 +2091,7 @@ export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean):
1999
2091
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
2000
2092
  * @returns Mean value(s)
2001
2093
  */
2002
- export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2094
+ export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2003
2095
  /**
2004
2096
  * Compute the variance along the specified axis, ignoring NaNs.
2005
2097
  * @param a - Input array
@@ -2025,7 +2117,7 @@ export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdim
2025
2117
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
2026
2118
  * @returns Minimum value(s)
2027
2119
  */
2028
- export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2120
+ export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2029
2121
  /**
2030
2122
  * Return maximum of an array, ignoring NaNs.
2031
2123
  * @param a - Input array
@@ -2033,7 +2125,7 @@ export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): N
2033
2125
  * @param keepdims - If true, reduced axes are left as dimensions with size 1
2034
2126
  * @returns Maximum value(s)
2035
2127
  */
2036
- export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2128
+ export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2037
2129
  /**
2038
2130
  * Return indices of the minimum value, ignoring NaNs.
2039
2131
  * @param a - Input array
@@ -2346,33 +2438,82 @@ export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
2346
2438
  */
2347
2439
  export declare function spacing(x: NDArray): NDArray;
2348
2440
  /**
2349
- * Test element-wise for complex number
2350
- * Since numpy-ts doesn't support complex numbers, always returns false
2441
+ * Test element-wise for complex number.
2442
+ *
2443
+ * For complex arrays, returns true for elements with non-zero imaginary part.
2444
+ * For real arrays, always returns false.
2445
+ *
2351
2446
  * @param x - Input array
2352
- * @returns Boolean array (all false)
2447
+ * @returns Boolean array
2353
2448
  */
2354
2449
  export declare function iscomplex(x: NDArray): NDArray;
2355
2450
  /**
2356
- * Check whether array is complex type
2357
- * Since numpy-ts doesn't support complex numbers, always returns false
2451
+ * Check whether array is complex type.
2452
+ *
2358
2453
  * @param x - Input array
2359
- * @returns false
2454
+ * @returns true if dtype is complex64 or complex128
2360
2455
  */
2361
2456
  export declare function iscomplexobj(x: NDArray): boolean;
2362
2457
  /**
2363
- * Test element-wise for real number (not complex)
2364
- * Since numpy-ts doesn't support complex numbers, always returns true
2458
+ * Test element-wise for real number (not complex).
2459
+ *
2460
+ * For complex arrays, returns true for elements with zero imaginary part.
2461
+ * For real arrays, always returns true.
2462
+ *
2365
2463
  * @param x - Input array
2366
- * @returns Boolean array (all true)
2464
+ * @returns Boolean array
2367
2465
  */
2368
2466
  export declare function isreal(x: NDArray): NDArray;
2369
2467
  /**
2370
- * Check whether array is real type (not complex)
2371
- * Since numpy-ts doesn't support complex numbers, always returns true
2468
+ * Check whether array is real type (not complex).
2469
+ *
2372
2470
  * @param x - Input array
2373
- * @returns true
2471
+ * @returns true if dtype is NOT complex64 or complex128
2374
2472
  */
2375
2473
  export declare function isrealobj(x: NDArray): boolean;
2474
+ /**
2475
+ * Return the real part of complex argument.
2476
+ *
2477
+ * For complex arrays, returns the real components.
2478
+ * For real arrays, returns a copy of the input.
2479
+ *
2480
+ * @param x - Input array
2481
+ * @returns Array with real parts
2482
+ */
2483
+ export declare function real(x: NDArray): NDArray;
2484
+ /**
2485
+ * Return the imaginary part of complex argument.
2486
+ *
2487
+ * For complex arrays, returns the imaginary components.
2488
+ * For real arrays, returns zeros.
2489
+ *
2490
+ * @param x - Input array
2491
+ * @returns Array with imaginary parts
2492
+ */
2493
+ export declare function imag(x: NDArray): NDArray;
2494
+ /**
2495
+ * Return the complex conjugate.
2496
+ *
2497
+ * For complex arrays, negates the imaginary part: (a + bi) -> (a - bi)
2498
+ * For real arrays, returns a copy of the input.
2499
+ *
2500
+ * @param x - Input array
2501
+ * @returns Complex conjugate array
2502
+ */
2503
+ export declare function conj(x: NDArray): NDArray;
2504
+ export declare const conjugate: typeof conj;
2505
+ /**
2506
+ * Return the angle (phase) of complex argument.
2507
+ *
2508
+ * angle(z) = arctan2(imag(z), real(z))
2509
+ *
2510
+ * For real arrays, returns 0 for positive, pi for negative.
2511
+ *
2512
+ * @param x - Input array
2513
+ * @param deg - Return angle in degrees if true (default: false, returns radians)
2514
+ * @returns Array with angles in radians (or degrees)
2515
+ */
2516
+ export declare function angle(x: NDArray, deg?: boolean): NDArray;
2376
2517
  /**
2377
2518
  * Test element-wise for negative infinity
2378
2519
  * @param x - Input array
@@ -2446,7 +2587,7 @@ export declare function promote_types(dtype1: DType, dtype2: DType): DType;
2446
2587
  * // Trace
2447
2588
  * einsum('ii->', a)
2448
2589
  */
2449
- export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
2590
+ export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint | Complex;
2450
2591
  /**
2451
2592
  * numpy.linalg module - Linear algebra functions
2452
2593
  */