numpy-ts 0.9.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.
- package/README.md +45 -26
- 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 +663 -37
- package/dist/types/core/storage.d.ts +15 -4
- package/dist/types/index.d.ts +41 -1
- package/dist/types/ops/advanced.d.ts +7 -0
- package/dist/types/ops/arithmetic.d.ts +53 -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 +6 -5
- package/dist/types/ops/logic.d.ts +219 -0
- package/dist/types/ops/random.d.ts +136 -0
- package/dist/types/ops/reduction.d.ts +26 -18
- package/dist/types/ops/rounding.d.ts +3 -0
- package/dist/types/ops/sorting.d.ts +8 -0
- package/dist/types/ops/statistics.d.ts +108 -0
- package/dist/types/ops/trig.d.ts +6 -0
- package/package.json +2 -2
|
@@ -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;
|
|
@@ -39,18 +40,44 @@ export declare class NDArray {
|
|
|
39
40
|
* Similar to NumPy's base attribute
|
|
40
41
|
*/
|
|
41
42
|
get base(): NDArray | null;
|
|
43
|
+
/**
|
|
44
|
+
* Transpose of the array (shorthand for transpose())
|
|
45
|
+
* Returns a view with axes reversed
|
|
46
|
+
*/
|
|
47
|
+
get T(): NDArray;
|
|
48
|
+
/**
|
|
49
|
+
* Size of one array element in bytes
|
|
50
|
+
*/
|
|
51
|
+
get itemsize(): number;
|
|
52
|
+
/**
|
|
53
|
+
* Total bytes consumed by the elements of the array
|
|
54
|
+
*/
|
|
55
|
+
get nbytes(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Fill the array with a scalar value (in-place)
|
|
58
|
+
* @param value - Value to fill with
|
|
59
|
+
*/
|
|
60
|
+
fill(value: number | bigint): void;
|
|
61
|
+
/**
|
|
62
|
+
* Iterator protocol - iterate over the first axis
|
|
63
|
+
* For 1D arrays, yields elements; for ND arrays, yields (N-1)D subarrays
|
|
64
|
+
*/
|
|
65
|
+
[Symbol.iterator](): Iterator<NDArray | number | bigint | Complex>;
|
|
42
66
|
/**
|
|
43
67
|
* Get a single element from the array
|
|
44
68
|
* @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
|
|
45
|
-
* @returns The element value (BigInt for int64/uint64, number otherwise)
|
|
69
|
+
* @returns The element value (BigInt for int64/uint64, Complex for complex, number otherwise)
|
|
46
70
|
*/
|
|
47
|
-
get(indices: number[]): number | bigint;
|
|
71
|
+
get(indices: number[]): number | bigint | Complex;
|
|
48
72
|
/**
|
|
49
73
|
* Set a single element in the array
|
|
50
74
|
* @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
|
|
51
75
|
* @param value - Value to set (will be converted to array's dtype)
|
|
52
76
|
*/
|
|
53
|
-
set(indices: number[], value: number | bigint
|
|
77
|
+
set(indices: number[], value: number | bigint | Complex | {
|
|
78
|
+
re: number;
|
|
79
|
+
im: number;
|
|
80
|
+
}): void;
|
|
54
81
|
/**
|
|
55
82
|
* Return a deep copy of the array
|
|
56
83
|
*/
|
|
@@ -421,13 +448,78 @@ export declare class NDArray {
|
|
|
421
448
|
* @returns Result of right shift
|
|
422
449
|
*/
|
|
423
450
|
right_shift(shift: NDArray | number): NDArray;
|
|
451
|
+
/**
|
|
452
|
+
* Logical AND element-wise
|
|
453
|
+
* @param other - Array or scalar for AND operation
|
|
454
|
+
* @returns Boolean array (1 = true, 0 = false)
|
|
455
|
+
*/
|
|
456
|
+
logical_and(other: NDArray | number): NDArray;
|
|
457
|
+
/**
|
|
458
|
+
* Logical OR element-wise
|
|
459
|
+
* @param other - Array or scalar for OR operation
|
|
460
|
+
* @returns Boolean array (1 = true, 0 = false)
|
|
461
|
+
*/
|
|
462
|
+
logical_or(other: NDArray | number): NDArray;
|
|
463
|
+
/**
|
|
464
|
+
* Logical NOT element-wise
|
|
465
|
+
* @returns Boolean array (1 = true, 0 = false)
|
|
466
|
+
*/
|
|
467
|
+
logical_not(): NDArray;
|
|
468
|
+
/**
|
|
469
|
+
* Logical XOR element-wise
|
|
470
|
+
* @param other - Array or scalar for XOR operation
|
|
471
|
+
* @returns Boolean array (1 = true, 0 = false)
|
|
472
|
+
*/
|
|
473
|
+
logical_xor(other: NDArray | number): NDArray;
|
|
474
|
+
/**
|
|
475
|
+
* Test element-wise for finiteness (not infinity and not NaN)
|
|
476
|
+
* @returns Boolean array
|
|
477
|
+
*/
|
|
478
|
+
isfinite(): NDArray;
|
|
479
|
+
/**
|
|
480
|
+
* Test element-wise for positive or negative infinity
|
|
481
|
+
* @returns Boolean array
|
|
482
|
+
*/
|
|
483
|
+
isinf(): NDArray;
|
|
484
|
+
/**
|
|
485
|
+
* Test element-wise for NaN (Not a Number)
|
|
486
|
+
* @returns Boolean array
|
|
487
|
+
*/
|
|
488
|
+
isnan(): NDArray;
|
|
489
|
+
/**
|
|
490
|
+
* Test element-wise for NaT (Not a Time)
|
|
491
|
+
* @returns Boolean array (always false without datetime support)
|
|
492
|
+
*/
|
|
493
|
+
isnat(): NDArray;
|
|
494
|
+
/**
|
|
495
|
+
* Change the sign of x1 to that of x2, element-wise
|
|
496
|
+
* @param x2 - Values whose sign is used
|
|
497
|
+
* @returns Array with magnitude from this and sign from x2
|
|
498
|
+
*/
|
|
499
|
+
copysign(x2: NDArray | number): NDArray;
|
|
500
|
+
/**
|
|
501
|
+
* Returns element-wise True where signbit is set (less than zero)
|
|
502
|
+
* @returns Boolean array
|
|
503
|
+
*/
|
|
504
|
+
signbit(): NDArray;
|
|
505
|
+
/**
|
|
506
|
+
* Return the next floating-point value after x1 towards x2, element-wise
|
|
507
|
+
* @param x2 - Direction to look for the next representable value
|
|
508
|
+
* @returns Array of next representable values
|
|
509
|
+
*/
|
|
510
|
+
nextafter(x2: NDArray | number): NDArray;
|
|
511
|
+
/**
|
|
512
|
+
* Return the distance between x and the nearest adjacent number
|
|
513
|
+
* @returns Array of spacing values
|
|
514
|
+
*/
|
|
515
|
+
spacing(): NDArray;
|
|
424
516
|
/**
|
|
425
517
|
* Sum array elements over a given axis
|
|
426
518
|
* @param axis - Axis along which to sum. If undefined, sum all elements
|
|
427
519
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
428
520
|
* @returns Sum of array elements, or array of sums along axis
|
|
429
521
|
*/
|
|
430
|
-
sum(axis?: number, keepdims?: boolean): NDArray | number;
|
|
522
|
+
sum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
431
523
|
/**
|
|
432
524
|
* Compute the arithmetic mean along the specified axis
|
|
433
525
|
* @param axis - Axis along which to compute mean. If undefined, compute mean of all elements
|
|
@@ -436,28 +528,28 @@ export declare class NDArray {
|
|
|
436
528
|
*
|
|
437
529
|
* Note: mean() returns float64 for integer dtypes, matching NumPy behavior
|
|
438
530
|
*/
|
|
439
|
-
mean(axis?: number, keepdims?: boolean): NDArray | number;
|
|
531
|
+
mean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
440
532
|
/**
|
|
441
533
|
* Return the maximum along a given axis
|
|
442
534
|
* @param axis - Axis along which to compute maximum. If undefined, compute maximum of all elements
|
|
443
535
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
444
536
|
* @returns Maximum of array elements, or array of maximums along axis
|
|
445
537
|
*/
|
|
446
|
-
max(axis?: number, keepdims?: boolean): NDArray | number;
|
|
538
|
+
max(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
447
539
|
/**
|
|
448
540
|
* Return the minimum along a given axis
|
|
449
541
|
* @param axis - Axis along which to compute minimum. If undefined, compute minimum of all elements
|
|
450
542
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
451
543
|
* @returns Minimum of array elements, or array of minimums along axis
|
|
452
544
|
*/
|
|
453
|
-
min(axis?: number, keepdims?: boolean): NDArray | number;
|
|
545
|
+
min(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
454
546
|
/**
|
|
455
547
|
* Product of array elements over a given axis
|
|
456
548
|
* @param axis - Axis along which to compute the product. If undefined, product of all elements.
|
|
457
549
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
458
550
|
* @returns Product of array elements, or array of products along axis
|
|
459
551
|
*/
|
|
460
|
-
prod(axis?: number, keepdims?: boolean): NDArray | number;
|
|
552
|
+
prod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
461
553
|
/**
|
|
462
554
|
* Indices of the minimum values along an axis
|
|
463
555
|
* @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
|
|
@@ -518,7 +610,7 @@ export declare class NDArray {
|
|
|
518
610
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
519
611
|
* @returns Range of values
|
|
520
612
|
*/
|
|
521
|
-
ptp(axis?: number, keepdims?: boolean): NDArray | number;
|
|
613
|
+
ptp(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
522
614
|
/**
|
|
523
615
|
* Compute the median along the specified axis
|
|
524
616
|
* @param axis - Axis along which to compute median. If undefined, compute over all elements.
|
|
@@ -548,28 +640,28 @@ export declare class NDArray {
|
|
|
548
640
|
* @param axis - Axis along which to compute average. If undefined, compute over all elements.
|
|
549
641
|
* @returns Weighted average of array elements
|
|
550
642
|
*/
|
|
551
|
-
average(weights?: NDArray, axis?: number): NDArray | number;
|
|
643
|
+
average(weights?: NDArray, axis?: number): NDArray | number | Complex;
|
|
552
644
|
/**
|
|
553
645
|
* Return the sum of array elements, treating NaNs as zero
|
|
554
646
|
* @param axis - Axis along which to compute sum. If undefined, compute over all elements.
|
|
555
647
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
556
648
|
* @returns Sum of array elements ignoring NaNs
|
|
557
649
|
*/
|
|
558
|
-
nansum(axis?: number, keepdims?: boolean): NDArray | number;
|
|
650
|
+
nansum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
559
651
|
/**
|
|
560
652
|
* Return the product of array elements, treating NaNs as ones
|
|
561
653
|
* @param axis - Axis along which to compute product. If undefined, compute over all elements.
|
|
562
654
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
563
655
|
* @returns Product of array elements ignoring NaNs
|
|
564
656
|
*/
|
|
565
|
-
nanprod(axis?: number, keepdims?: boolean): NDArray | number;
|
|
657
|
+
nanprod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
566
658
|
/**
|
|
567
659
|
* Compute the arithmetic mean, ignoring NaNs
|
|
568
660
|
* @param axis - Axis along which to compute mean. If undefined, compute over all elements.
|
|
569
661
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
570
662
|
* @returns Mean of array elements ignoring NaNs
|
|
571
663
|
*/
|
|
572
|
-
nanmean(axis?: number, keepdims?: boolean): NDArray | number;
|
|
664
|
+
nanmean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
573
665
|
/**
|
|
574
666
|
* Compute the variance, ignoring NaNs
|
|
575
667
|
* @param axis - Axis along which to compute variance. If undefined, compute over all elements.
|
|
@@ -592,14 +684,14 @@ export declare class NDArray {
|
|
|
592
684
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
593
685
|
* @returns Minimum of array elements ignoring NaNs
|
|
594
686
|
*/
|
|
595
|
-
nanmin(axis?: number, keepdims?: boolean): NDArray | number;
|
|
687
|
+
nanmin(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
596
688
|
/**
|
|
597
689
|
* Return maximum of an array or maximum along an axis, ignoring NaNs
|
|
598
690
|
* @param axis - Axis along which to compute maximum. If undefined, compute over all elements.
|
|
599
691
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
600
692
|
* @returns Maximum of array elements ignoring NaNs
|
|
601
693
|
*/
|
|
602
|
-
nanmax(axis?: number, keepdims?: boolean): NDArray | number;
|
|
694
|
+
nanmax(axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
603
695
|
/**
|
|
604
696
|
* Return the indices of the minimum values, ignoring NaNs
|
|
605
697
|
* @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
|
|
@@ -662,6 +754,12 @@ export declare class NDArray {
|
|
|
662
754
|
* @returns Tuple of arrays, one for each dimension
|
|
663
755
|
*/
|
|
664
756
|
nonzero(): NDArray[];
|
|
757
|
+
/**
|
|
758
|
+
* Find the indices of array elements that are non-zero, grouped by element
|
|
759
|
+
* Returns a 2D array where each row is the index of a non-zero element.
|
|
760
|
+
* @returns 2D array of shape (N, ndim) where N is number of non-zero elements
|
|
761
|
+
*/
|
|
762
|
+
argwhere(): NDArray;
|
|
665
763
|
/**
|
|
666
764
|
* Find indices where elements should be inserted to maintain order
|
|
667
765
|
* @param v - Values to insert
|
|
@@ -745,6 +843,56 @@ export declare class NDArray {
|
|
|
745
843
|
* @param values - Values to put
|
|
746
844
|
*/
|
|
747
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;
|
|
748
896
|
/**
|
|
749
897
|
* Matrix multiplication
|
|
750
898
|
* @param other - Array to multiply with
|
|
@@ -754,20 +902,20 @@ export declare class NDArray {
|
|
|
754
902
|
/**
|
|
755
903
|
* Dot product (matching NumPy behavior)
|
|
756
904
|
* @param other - Array to dot with
|
|
757
|
-
* @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)
|
|
758
906
|
*/
|
|
759
|
-
dot(other: NDArray): NDArray | number | bigint;
|
|
907
|
+
dot(other: NDArray): NDArray | number | bigint | Complex;
|
|
760
908
|
/**
|
|
761
909
|
* Sum of diagonal elements (trace)
|
|
762
|
-
* @returns Sum of diagonal elements
|
|
910
|
+
* @returns Sum of diagonal elements (Complex for complex arrays)
|
|
763
911
|
*/
|
|
764
|
-
trace(): number | bigint;
|
|
912
|
+
trace(): number | bigint | Complex;
|
|
765
913
|
/**
|
|
766
914
|
* Inner product (contracts over last axes of both arrays)
|
|
767
915
|
* @param other - Array to compute inner product with
|
|
768
|
-
* @returns Inner product result
|
|
916
|
+
* @returns Inner product result (Complex for complex arrays)
|
|
769
917
|
*/
|
|
770
|
-
inner(other: NDArray): NDArray | number | bigint;
|
|
918
|
+
inner(other: NDArray): NDArray | number | bigint | Complex;
|
|
771
919
|
/**
|
|
772
920
|
* Outer product (flattens inputs then computes a[i]*b[j])
|
|
773
921
|
* @param other - Array to compute outer product with
|
|
@@ -780,7 +928,7 @@ export declare class NDArray {
|
|
|
780
928
|
* @param axes - Axes to contract (integer or [a_axes, b_axes])
|
|
781
929
|
* @returns Tensor dot product result
|
|
782
930
|
*/
|
|
783
|
-
tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint;
|
|
931
|
+
tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
|
|
784
932
|
/**
|
|
785
933
|
* Element-wise cube root
|
|
786
934
|
* Promotes integer types to float64
|
|
@@ -1131,6 +1279,7 @@ export declare function sqrt(x: NDArray): NDArray;
|
|
|
1131
1279
|
* @returns Array of x raised to exponent
|
|
1132
1280
|
*/
|
|
1133
1281
|
export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
|
|
1282
|
+
export { power as pow };
|
|
1134
1283
|
/**
|
|
1135
1284
|
* Element-wise natural exponential (e^x)
|
|
1136
1285
|
* @param x - Input array
|
|
@@ -1197,6 +1346,7 @@ export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
|
|
|
1197
1346
|
* @returns Array of absolute values
|
|
1198
1347
|
*/
|
|
1199
1348
|
export declare function absolute(x: NDArray): NDArray;
|
|
1349
|
+
export { absolute as abs };
|
|
1200
1350
|
/**
|
|
1201
1351
|
* Element-wise negation
|
|
1202
1352
|
* @param x - Input array
|
|
@@ -1216,6 +1366,14 @@ export declare function sign(x: NDArray): NDArray;
|
|
|
1216
1366
|
* @returns Remainder after division
|
|
1217
1367
|
*/
|
|
1218
1368
|
export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
|
|
1369
|
+
/**
|
|
1370
|
+
* Element-wise division
|
|
1371
|
+
* @param x - Dividend array
|
|
1372
|
+
* @param divisor - Divisor (array or scalar)
|
|
1373
|
+
* @returns Array of quotients
|
|
1374
|
+
*/
|
|
1375
|
+
export declare function divide(x: NDArray, divisor: NDArray | number): NDArray;
|
|
1376
|
+
export { divide as true_divide };
|
|
1219
1377
|
/**
|
|
1220
1378
|
* Element-wise floor division
|
|
1221
1379
|
* @param x - Dividend array
|
|
@@ -1251,16 +1409,16 @@ export declare function reciprocal(x: NDArray): NDArray;
|
|
|
1251
1409
|
*
|
|
1252
1410
|
* @param a - First array
|
|
1253
1411
|
* @param b - Second array
|
|
1254
|
-
* @returns Result of dot product
|
|
1412
|
+
* @returns Result of dot product (Complex for complex arrays)
|
|
1255
1413
|
*/
|
|
1256
|
-
export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint;
|
|
1414
|
+
export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
|
|
1257
1415
|
/**
|
|
1258
1416
|
* Sum of diagonal elements
|
|
1259
1417
|
*
|
|
1260
1418
|
* @param a - Input 2D array
|
|
1261
|
-
* @returns Sum of diagonal elements
|
|
1419
|
+
* @returns Sum of diagonal elements (Complex for complex arrays)
|
|
1262
1420
|
*/
|
|
1263
|
-
export declare function trace(a: NDArray): number | bigint;
|
|
1421
|
+
export declare function trace(a: NDArray): number | bigint | Complex;
|
|
1264
1422
|
/**
|
|
1265
1423
|
* Extract a diagonal from a matrix or N-D array
|
|
1266
1424
|
*
|
|
@@ -1295,9 +1453,9 @@ export declare function transpose(a: NDArray, axes?: number[]): NDArray;
|
|
|
1295
1453
|
*
|
|
1296
1454
|
* @param a - First array
|
|
1297
1455
|
* @param b - Second array
|
|
1298
|
-
* @returns Inner product result
|
|
1456
|
+
* @returns Inner product result (Complex for complex arrays)
|
|
1299
1457
|
*/
|
|
1300
|
-
export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint;
|
|
1458
|
+
export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
|
|
1301
1459
|
/**
|
|
1302
1460
|
* Outer product of two arrays
|
|
1303
1461
|
*
|
|
@@ -1316,7 +1474,7 @@ export declare function outer(a: NDArray, b: NDArray): NDArray;
|
|
|
1316
1474
|
* @param axes - Axes to contract (integer or [a_axes, b_axes])
|
|
1317
1475
|
* @returns Tensor dot product
|
|
1318
1476
|
*/
|
|
1319
|
-
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;
|
|
1320
1478
|
/**
|
|
1321
1479
|
* Element-wise sine
|
|
1322
1480
|
* @param x - Input array (angles in radians)
|
|
@@ -1341,18 +1499,21 @@ export declare function tan(x: NDArray): NDArray;
|
|
|
1341
1499
|
* @returns Array of angles in radians
|
|
1342
1500
|
*/
|
|
1343
1501
|
export declare function arcsin(x: NDArray): NDArray;
|
|
1502
|
+
export { arcsin as asin };
|
|
1344
1503
|
/**
|
|
1345
1504
|
* Element-wise inverse cosine
|
|
1346
1505
|
* @param x - Input array (values in range [-1, 1])
|
|
1347
1506
|
* @returns Array of angles in radians
|
|
1348
1507
|
*/
|
|
1349
1508
|
export declare function arccos(x: NDArray): NDArray;
|
|
1509
|
+
export { arccos as acos };
|
|
1350
1510
|
/**
|
|
1351
1511
|
* Element-wise inverse tangent
|
|
1352
1512
|
* @param x - Input array
|
|
1353
1513
|
* @returns Array of angles in radians
|
|
1354
1514
|
*/
|
|
1355
1515
|
export declare function arctan(x: NDArray): NDArray;
|
|
1516
|
+
export { arctan as atan };
|
|
1356
1517
|
/**
|
|
1357
1518
|
* Element-wise arc tangent of x1/x2 choosing the quadrant correctly
|
|
1358
1519
|
* @param x1 - y-coordinates
|
|
@@ -1360,6 +1521,7 @@ export declare function arctan(x: NDArray): NDArray;
|
|
|
1360
1521
|
* @returns Angles in radians between -π and π
|
|
1361
1522
|
*/
|
|
1362
1523
|
export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
|
|
1524
|
+
export { arctan2 as atan2 };
|
|
1363
1525
|
/**
|
|
1364
1526
|
* Given the "legs" of a right triangle, return its hypotenuse
|
|
1365
1527
|
* Equivalent to sqrt(x1**2 + x2**2), element-wise
|
|
@@ -1416,18 +1578,21 @@ export declare function tanh(x: NDArray): NDArray;
|
|
|
1416
1578
|
* @returns Array of arcsinh values
|
|
1417
1579
|
*/
|
|
1418
1580
|
export declare function arcsinh(x: NDArray): NDArray;
|
|
1581
|
+
export { arcsinh as asinh };
|
|
1419
1582
|
/**
|
|
1420
1583
|
* Element-wise inverse hyperbolic cosine
|
|
1421
1584
|
* @param x - Input array (values >= 1)
|
|
1422
1585
|
* @returns Array of arccosh values
|
|
1423
1586
|
*/
|
|
1424
1587
|
export declare function arccosh(x: NDArray): NDArray;
|
|
1588
|
+
export { arccosh as acosh };
|
|
1425
1589
|
/**
|
|
1426
1590
|
* Element-wise inverse hyperbolic tangent
|
|
1427
1591
|
* @param x - Input array (values in range (-1, 1))
|
|
1428
1592
|
* @returns Array of arctanh values
|
|
1429
1593
|
*/
|
|
1430
1594
|
export declare function arctanh(x: NDArray): NDArray;
|
|
1595
|
+
export { arctanh as atanh };
|
|
1431
1596
|
/**
|
|
1432
1597
|
* Swap two axes of an array
|
|
1433
1598
|
*
|
|
@@ -1746,6 +1911,60 @@ export declare function take(a: NDArray, indices: number[], axis?: number): NDAr
|
|
|
1746
1911
|
* @param values - Values to put
|
|
1747
1912
|
*/
|
|
1748
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;
|
|
1952
|
+
/**
|
|
1953
|
+
* Copy values from one array to another, broadcasting as necessary.
|
|
1954
|
+
*
|
|
1955
|
+
* @param dst - Destination array (modified in-place)
|
|
1956
|
+
* @param src - Source array or scalar
|
|
1957
|
+
* @param where - Optional boolean array. Only copy where True (not yet implemented)
|
|
1958
|
+
* @throws Error if shapes are not broadcastable
|
|
1959
|
+
*
|
|
1960
|
+
* @example
|
|
1961
|
+
* ```typescript
|
|
1962
|
+
* const dst = np.zeros([3, 3]);
|
|
1963
|
+
* const src = np.array([1, 2, 3]);
|
|
1964
|
+
* np.copyto(dst, src); // Each row of dst becomes [1, 2, 3]
|
|
1965
|
+
* ```
|
|
1966
|
+
*/
|
|
1967
|
+
export declare function copyto(dst: NDArray, src: NDArray | number | bigint, where?: NDArray): void;
|
|
1749
1968
|
/**
|
|
1750
1969
|
* Construct array from index array and choices
|
|
1751
1970
|
*
|
|
@@ -1779,6 +1998,7 @@ export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
|
|
|
1779
1998
|
* @returns Array with cumulative sums
|
|
1780
1999
|
*/
|
|
1781
2000
|
export declare function cumsum(a: NDArray, axis?: number): NDArray;
|
|
2001
|
+
export { cumsum as cumulative_sum };
|
|
1782
2002
|
/**
|
|
1783
2003
|
* Return the cumulative product of the elements along a given axis.
|
|
1784
2004
|
* @param a - Input array
|
|
@@ -1786,6 +2006,25 @@ export declare function cumsum(a: NDArray, axis?: number): NDArray;
|
|
|
1786
2006
|
* @returns Array with cumulative products
|
|
1787
2007
|
*/
|
|
1788
2008
|
export declare function cumprod(a: NDArray, axis?: number): NDArray;
|
|
2009
|
+
export { cumprod as cumulative_prod };
|
|
2010
|
+
/**
|
|
2011
|
+
* Return the maximum along a given axis.
|
|
2012
|
+
* @param a - Input array
|
|
2013
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
2014
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
2015
|
+
* @returns Maximum value(s)
|
|
2016
|
+
*/
|
|
2017
|
+
export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
2018
|
+
export { max as amax };
|
|
2019
|
+
/**
|
|
2020
|
+
* Return the minimum along a given axis.
|
|
2021
|
+
* @param a - Input array
|
|
2022
|
+
* @param axis - Axis along which to compute. If undefined, use all elements.
|
|
2023
|
+
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
2024
|
+
* @returns Minimum value(s)
|
|
2025
|
+
*/
|
|
2026
|
+
export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
|
|
2027
|
+
export { min as amin };
|
|
1789
2028
|
/**
|
|
1790
2029
|
* Peak to peak (maximum - minimum) value along a given axis.
|
|
1791
2030
|
* @param a - Input array
|
|
@@ -1793,7 +2032,7 @@ export declare function cumprod(a: NDArray, axis?: number): NDArray;
|
|
|
1793
2032
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1794
2033
|
* @returns Peak to peak value(s)
|
|
1795
2034
|
*/
|
|
1796
|
-
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;
|
|
1797
2036
|
/**
|
|
1798
2037
|
* Compute the median along the specified axis.
|
|
1799
2038
|
* @param a - Input array
|
|
@@ -1828,7 +2067,7 @@ export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?
|
|
|
1828
2067
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1829
2068
|
* @returns Weighted average value(s)
|
|
1830
2069
|
*/
|
|
1831
|
-
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;
|
|
1832
2071
|
/**
|
|
1833
2072
|
* Return the sum of array elements over a given axis, treating NaNs as zero.
|
|
1834
2073
|
* @param a - Input array
|
|
@@ -1836,7 +2075,7 @@ export declare function average(a: NDArray, axis?: number, weights?: NDArray, ke
|
|
|
1836
2075
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1837
2076
|
* @returns Sum value(s)
|
|
1838
2077
|
*/
|
|
1839
|
-
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;
|
|
1840
2079
|
/**
|
|
1841
2080
|
* Return the product of array elements over a given axis, treating NaNs as one.
|
|
1842
2081
|
* @param a - Input array
|
|
@@ -1844,7 +2083,7 @@ export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): N
|
|
|
1844
2083
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1845
2084
|
* @returns Product value(s)
|
|
1846
2085
|
*/
|
|
1847
|
-
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;
|
|
1848
2087
|
/**
|
|
1849
2088
|
* Compute the arithmetic mean along the specified axis, ignoring NaNs.
|
|
1850
2089
|
* @param a - Input array
|
|
@@ -1852,7 +2091,7 @@ export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean):
|
|
|
1852
2091
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1853
2092
|
* @returns Mean value(s)
|
|
1854
2093
|
*/
|
|
1855
|
-
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;
|
|
1856
2095
|
/**
|
|
1857
2096
|
* Compute the variance along the specified axis, ignoring NaNs.
|
|
1858
2097
|
* @param a - Input array
|
|
@@ -1878,7 +2117,7 @@ export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdim
|
|
|
1878
2117
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1879
2118
|
* @returns Minimum value(s)
|
|
1880
2119
|
*/
|
|
1881
|
-
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;
|
|
1882
2121
|
/**
|
|
1883
2122
|
* Return maximum of an array, ignoring NaNs.
|
|
1884
2123
|
* @param a - Input array
|
|
@@ -1886,7 +2125,7 @@ export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): N
|
|
|
1886
2125
|
* @param keepdims - If true, reduced axes are left as dimensions with size 1
|
|
1887
2126
|
* @returns Maximum value(s)
|
|
1888
2127
|
*/
|
|
1889
|
-
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;
|
|
1890
2129
|
/**
|
|
1891
2130
|
* Return indices of the minimum value, ignoring NaNs.
|
|
1892
2131
|
* @param a - Input array
|
|
@@ -1968,6 +2207,55 @@ export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
|
|
|
1968
2207
|
* @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
|
|
1969
2208
|
*/
|
|
1970
2209
|
export declare function heaviside(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2210
|
+
/**
|
|
2211
|
+
* First array raised to power of second, always promoting to float
|
|
2212
|
+
* @param x1 - Base values
|
|
2213
|
+
* @param x2 - Exponent values
|
|
2214
|
+
* @returns Result in float64
|
|
2215
|
+
*/
|
|
2216
|
+
export declare function float_power(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2217
|
+
/**
|
|
2218
|
+
* Element-wise remainder of division (fmod)
|
|
2219
|
+
* Unlike mod/remainder, fmod matches C fmod behavior
|
|
2220
|
+
* @param x1 - Dividend
|
|
2221
|
+
* @param x2 - Divisor
|
|
2222
|
+
* @returns Remainder
|
|
2223
|
+
*/
|
|
2224
|
+
export declare function fmod(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2225
|
+
/**
|
|
2226
|
+
* Decompose floating point numbers into mantissa and exponent
|
|
2227
|
+
* Returns [mantissa, exponent] where x = mantissa * 2^exponent
|
|
2228
|
+
* @param x - Input array
|
|
2229
|
+
* @returns Tuple of [mantissa, exponent] arrays
|
|
2230
|
+
*/
|
|
2231
|
+
export declare function frexp(x: NDArray): [NDArray, NDArray];
|
|
2232
|
+
/**
|
|
2233
|
+
* Greatest common divisor
|
|
2234
|
+
* @param x1 - First array
|
|
2235
|
+
* @param x2 - Second array or scalar
|
|
2236
|
+
* @returns GCD
|
|
2237
|
+
*/
|
|
2238
|
+
export declare function gcd(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2239
|
+
/**
|
|
2240
|
+
* Least common multiple
|
|
2241
|
+
* @param x1 - First array
|
|
2242
|
+
* @param x2 - Second array or scalar
|
|
2243
|
+
* @returns LCM
|
|
2244
|
+
*/
|
|
2245
|
+
export declare function lcm(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2246
|
+
/**
|
|
2247
|
+
* Returns x1 * 2^x2, element-wise
|
|
2248
|
+
* @param x1 - Mantissa
|
|
2249
|
+
* @param x2 - Exponent
|
|
2250
|
+
* @returns Result
|
|
2251
|
+
*/
|
|
2252
|
+
export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2253
|
+
/**
|
|
2254
|
+
* Return fractional and integral parts of array
|
|
2255
|
+
* @param x - Input array
|
|
2256
|
+
* @returns Tuple of [fractional, integral] arrays
|
|
2257
|
+
*/
|
|
2258
|
+
export declare function modf(x: NDArray): [NDArray, NDArray];
|
|
1971
2259
|
/**
|
|
1972
2260
|
* Bitwise AND element-wise
|
|
1973
2261
|
*
|
|
@@ -2046,6 +2334,238 @@ export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | '
|
|
|
2046
2334
|
* @returns Unpacked uint8 array of 0s and 1s
|
|
2047
2335
|
*/
|
|
2048
2336
|
export declare function unpackbits(a: NDArray, axis?: number, count?: number, bitorder?: 'big' | 'little'): NDArray;
|
|
2337
|
+
/**
|
|
2338
|
+
* Logical AND element-wise
|
|
2339
|
+
*
|
|
2340
|
+
* Returns a boolean array where each element is the logical AND
|
|
2341
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
2342
|
+
*
|
|
2343
|
+
* @param x1 - First input array
|
|
2344
|
+
* @param x2 - Second input array or scalar
|
|
2345
|
+
* @returns Boolean result array
|
|
2346
|
+
*/
|
|
2347
|
+
export declare function logical_and(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2348
|
+
/**
|
|
2349
|
+
* Logical OR element-wise
|
|
2350
|
+
*
|
|
2351
|
+
* Returns a boolean array where each element is the logical OR
|
|
2352
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
2353
|
+
*
|
|
2354
|
+
* @param x1 - First input array
|
|
2355
|
+
* @param x2 - Second input array or scalar
|
|
2356
|
+
* @returns Boolean result array
|
|
2357
|
+
*/
|
|
2358
|
+
export declare function logical_or(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2359
|
+
/**
|
|
2360
|
+
* Logical NOT element-wise
|
|
2361
|
+
*
|
|
2362
|
+
* Returns a boolean array where each element is the logical NOT
|
|
2363
|
+
* of the input (non-zero = false, zero = true).
|
|
2364
|
+
*
|
|
2365
|
+
* @param x - Input array
|
|
2366
|
+
* @returns Boolean result array
|
|
2367
|
+
*/
|
|
2368
|
+
export declare function logical_not(x: NDArray): NDArray;
|
|
2369
|
+
/**
|
|
2370
|
+
* Logical XOR element-wise
|
|
2371
|
+
*
|
|
2372
|
+
* Returns a boolean array where each element is the logical XOR
|
|
2373
|
+
* of corresponding elements (non-zero = true, zero = false).
|
|
2374
|
+
*
|
|
2375
|
+
* @param x1 - First input array
|
|
2376
|
+
* @param x2 - Second input array or scalar
|
|
2377
|
+
* @returns Boolean result array
|
|
2378
|
+
*/
|
|
2379
|
+
export declare function logical_xor(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2380
|
+
/**
|
|
2381
|
+
* Test element-wise for finiteness (not infinity and not NaN)
|
|
2382
|
+
*
|
|
2383
|
+
* @param x - Input array
|
|
2384
|
+
* @returns Boolean array where True means finite
|
|
2385
|
+
*/
|
|
2386
|
+
export declare function isfinite(x: NDArray): NDArray;
|
|
2387
|
+
/**
|
|
2388
|
+
* Test element-wise for positive or negative infinity
|
|
2389
|
+
*
|
|
2390
|
+
* @param x - Input array
|
|
2391
|
+
* @returns Boolean array where True means infinite
|
|
2392
|
+
*/
|
|
2393
|
+
export declare function isinf(x: NDArray): NDArray;
|
|
2394
|
+
/**
|
|
2395
|
+
* Test element-wise for NaN (Not a Number)
|
|
2396
|
+
*
|
|
2397
|
+
* @param x - Input array
|
|
2398
|
+
* @returns Boolean array where True means NaN
|
|
2399
|
+
*/
|
|
2400
|
+
export declare function isnan(x: NDArray): NDArray;
|
|
2401
|
+
/**
|
|
2402
|
+
* Test element-wise for NaT (Not a Time)
|
|
2403
|
+
*
|
|
2404
|
+
* @param x - Input array
|
|
2405
|
+
* @returns Boolean array (always false without datetime support)
|
|
2406
|
+
*/
|
|
2407
|
+
export declare function isnat(x: NDArray): NDArray;
|
|
2408
|
+
/**
|
|
2409
|
+
* Change the sign of x1 to that of x2, element-wise
|
|
2410
|
+
*
|
|
2411
|
+
* Returns a value with the magnitude of x1 and the sign of x2.
|
|
2412
|
+
*
|
|
2413
|
+
* @param x1 - Values to change sign of (magnitude source)
|
|
2414
|
+
* @param x2 - Values whose sign is used (sign source)
|
|
2415
|
+
* @returns Array with magnitude from x1 and sign from x2
|
|
2416
|
+
*/
|
|
2417
|
+
export declare function copysign(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2418
|
+
/**
|
|
2419
|
+
* Returns element-wise True where signbit is set (less than zero)
|
|
2420
|
+
*
|
|
2421
|
+
* @param x - Input array
|
|
2422
|
+
* @returns Boolean array where True means signbit is set
|
|
2423
|
+
*/
|
|
2424
|
+
export declare function signbit(x: NDArray): NDArray;
|
|
2425
|
+
/**
|
|
2426
|
+
* Return the next floating-point value after x1 towards x2, element-wise
|
|
2427
|
+
*
|
|
2428
|
+
* @param x1 - Values to find the next representable value of
|
|
2429
|
+
* @param x2 - Direction to look for the next representable value
|
|
2430
|
+
* @returns Array of next representable values
|
|
2431
|
+
*/
|
|
2432
|
+
export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
|
|
2433
|
+
/**
|
|
2434
|
+
* Return the distance between x and the nearest adjacent number
|
|
2435
|
+
*
|
|
2436
|
+
* @param x - Input array
|
|
2437
|
+
* @returns Array of spacing values
|
|
2438
|
+
*/
|
|
2439
|
+
export declare function spacing(x: NDArray): NDArray;
|
|
2440
|
+
/**
|
|
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
|
+
*
|
|
2446
|
+
* @param x - Input array
|
|
2447
|
+
* @returns Boolean array
|
|
2448
|
+
*/
|
|
2449
|
+
export declare function iscomplex(x: NDArray): NDArray;
|
|
2450
|
+
/**
|
|
2451
|
+
* Check whether array is complex type.
|
|
2452
|
+
*
|
|
2453
|
+
* @param x - Input array
|
|
2454
|
+
* @returns true if dtype is complex64 or complex128
|
|
2455
|
+
*/
|
|
2456
|
+
export declare function iscomplexobj(x: NDArray): boolean;
|
|
2457
|
+
/**
|
|
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
|
+
*
|
|
2463
|
+
* @param x - Input array
|
|
2464
|
+
* @returns Boolean array
|
|
2465
|
+
*/
|
|
2466
|
+
export declare function isreal(x: NDArray): NDArray;
|
|
2467
|
+
/**
|
|
2468
|
+
* Check whether array is real type (not complex).
|
|
2469
|
+
*
|
|
2470
|
+
* @param x - Input array
|
|
2471
|
+
* @returns true if dtype is NOT complex64 or complex128
|
|
2472
|
+
*/
|
|
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;
|
|
2517
|
+
/**
|
|
2518
|
+
* Test element-wise for negative infinity
|
|
2519
|
+
* @param x - Input array
|
|
2520
|
+
* @returns Boolean array
|
|
2521
|
+
*/
|
|
2522
|
+
export declare function isneginf(x: NDArray): NDArray;
|
|
2523
|
+
/**
|
|
2524
|
+
* Test element-wise for positive infinity
|
|
2525
|
+
* @param x - Input array
|
|
2526
|
+
* @returns Boolean array
|
|
2527
|
+
*/
|
|
2528
|
+
export declare function isposinf(x: NDArray): NDArray;
|
|
2529
|
+
/**
|
|
2530
|
+
* Check if array is Fortran contiguous (column-major order)
|
|
2531
|
+
* @param x - Input array
|
|
2532
|
+
* @returns true if F-contiguous
|
|
2533
|
+
*/
|
|
2534
|
+
export declare function isfortran(x: NDArray): boolean;
|
|
2535
|
+
/**
|
|
2536
|
+
* Returns array with complex parts close to zero set to real
|
|
2537
|
+
* Since numpy-ts doesn't support complex numbers, returns copy
|
|
2538
|
+
* @param x - Input array
|
|
2539
|
+
* @param tol - Tolerance
|
|
2540
|
+
* @returns Copy of input array
|
|
2541
|
+
*/
|
|
2542
|
+
export declare function real_if_close(x: NDArray, tol?: number): NDArray;
|
|
2543
|
+
/**
|
|
2544
|
+
* Check if element is a scalar type
|
|
2545
|
+
* @param val - Value to check
|
|
2546
|
+
* @returns true if scalar
|
|
2547
|
+
*/
|
|
2548
|
+
export declare function isscalar(val: unknown): boolean;
|
|
2549
|
+
/**
|
|
2550
|
+
* Check if object is iterable
|
|
2551
|
+
* @param obj - Object to check
|
|
2552
|
+
* @returns true if iterable
|
|
2553
|
+
*/
|
|
2554
|
+
export declare function iterable(obj: unknown): boolean;
|
|
2555
|
+
/**
|
|
2556
|
+
* Check if dtype meets specified criteria
|
|
2557
|
+
* @param dtype - Dtype to check
|
|
2558
|
+
* @param kind - Kind of dtype ('b' bool, 'i' int, 'u' uint, 'f' float)
|
|
2559
|
+
* @returns true if dtype matches kind
|
|
2560
|
+
*/
|
|
2561
|
+
export declare function isdtype(dtype: DType, kind: string): boolean;
|
|
2562
|
+
/**
|
|
2563
|
+
* Find the dtype that can represent both input dtypes
|
|
2564
|
+
* @param dtype1 - First dtype
|
|
2565
|
+
* @param dtype2 - Second dtype
|
|
2566
|
+
* @returns Promoted dtype
|
|
2567
|
+
*/
|
|
2568
|
+
export declare function promote_types(dtype1: DType, dtype2: DType): DType;
|
|
2049
2569
|
/**
|
|
2050
2570
|
* Einstein summation convention
|
|
2051
2571
|
*
|
|
@@ -2067,7 +2587,7 @@ export declare function unpackbits(a: NDArray, axis?: number, count?: number, bi
|
|
|
2067
2587
|
* // Trace
|
|
2068
2588
|
* einsum('ii->', a)
|
|
2069
2589
|
*/
|
|
2070
|
-
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
|
|
2590
|
+
export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint | Complex;
|
|
2071
2591
|
/**
|
|
2072
2592
|
* numpy.linalg module - Linear algebra functions
|
|
2073
2593
|
*/
|
|
@@ -2222,6 +2742,13 @@ export declare function select(condlist: NDArray[], choicelist: NDArray[], defau
|
|
|
2222
2742
|
* @param vals - Values to place where mask is True (cycles if shorter)
|
|
2223
2743
|
*/
|
|
2224
2744
|
export declare function place(arr: NDArray, mask: NDArray, vals: NDArray): void;
|
|
2745
|
+
/**
|
|
2746
|
+
* Fill the main diagonal of a given array (modifies in-place)
|
|
2747
|
+
* @param a - Array (at least 2D)
|
|
2748
|
+
* @param val - Value or array of values to fill diagonal with
|
|
2749
|
+
* @param wrap - Whether to wrap for tall matrices
|
|
2750
|
+
*/
|
|
2751
|
+
export declare function fill_diagonal(a: NDArray, val: NDArray | number, wrap?: boolean): void;
|
|
2225
2752
|
/**
|
|
2226
2753
|
* Return the indices to access the main diagonal of an array.
|
|
2227
2754
|
*
|
|
@@ -2364,6 +2891,14 @@ export declare function sort_complex(a: NDArray): NDArray;
|
|
|
2364
2891
|
* @returns Tuple of arrays, one for each dimension
|
|
2365
2892
|
*/
|
|
2366
2893
|
export declare function nonzero(a: NDArray): NDArray[];
|
|
2894
|
+
/**
|
|
2895
|
+
* Find the indices of array elements that are non-zero, grouped by element
|
|
2896
|
+
* Returns a 2D array where each row is the index of a non-zero element.
|
|
2897
|
+
* This is equivalent to transpose(nonzero(a)).
|
|
2898
|
+
* @param a - Input array
|
|
2899
|
+
* @returns 2D array of shape (N, ndim) where N is number of non-zero elements
|
|
2900
|
+
*/
|
|
2901
|
+
export declare function argwhere(a: NDArray): NDArray;
|
|
2367
2902
|
/**
|
|
2368
2903
|
* Return indices of non-zero elements in flattened array
|
|
2369
2904
|
* @param a - Input array
|
|
@@ -2408,6 +2943,7 @@ export declare function count_nonzero(a: NDArray, axis?: number): NDArray | numb
|
|
|
2408
2943
|
* @returns Rounded array
|
|
2409
2944
|
*/
|
|
2410
2945
|
export declare function around(a: NDArray, decimals?: number): NDArray;
|
|
2946
|
+
export { around as round_ };
|
|
2411
2947
|
/**
|
|
2412
2948
|
* Return the ceiling of the input, element-wise
|
|
2413
2949
|
* @param x - Input array
|
|
@@ -2537,4 +3073,94 @@ export declare function gradient(f: NDArray, varargs?: number | number[], axis?:
|
|
|
2537
3073
|
* @returns Cross product array
|
|
2538
3074
|
*/
|
|
2539
3075
|
export declare function cross(a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number): NDArray;
|
|
3076
|
+
/**
|
|
3077
|
+
* Count number of occurrences of each value in array of non-negative ints.
|
|
3078
|
+
*
|
|
3079
|
+
* @param x - Input array (must contain non-negative integers)
|
|
3080
|
+
* @param weights - Optional weights, same shape as x
|
|
3081
|
+
* @param minlength - Minimum number of bins for output (default: 0)
|
|
3082
|
+
* @returns Array of bin counts
|
|
3083
|
+
*/
|
|
3084
|
+
export declare function bincount(x: NDArray, weights?: NDArray, minlength?: number): NDArray;
|
|
3085
|
+
/**
|
|
3086
|
+
* Return the indices of the bins to which each value in input array belongs.
|
|
3087
|
+
*
|
|
3088
|
+
* @param x - Input array to be binned
|
|
3089
|
+
* @param bins - Array of bins (monotonically increasing or decreasing)
|
|
3090
|
+
* @param right - If true, intervals are closed on the right (default: false)
|
|
3091
|
+
* @returns Array of bin indices
|
|
3092
|
+
*/
|
|
3093
|
+
export declare function digitize(x: NDArray, bins: NDArray, right?: boolean): NDArray;
|
|
3094
|
+
/**
|
|
3095
|
+
* Compute the histogram of a set of data.
|
|
3096
|
+
*
|
|
3097
|
+
* @param a - Input data (flattened if not 1D)
|
|
3098
|
+
* @param bins - Number of bins (default: 10) or array of bin edges
|
|
3099
|
+
* @param range - Lower and upper range of bins
|
|
3100
|
+
* @param density - If true, return probability density function (default: false)
|
|
3101
|
+
* @param weights - Optional weights for each data point
|
|
3102
|
+
* @returns Tuple of [hist, bin_edges]
|
|
3103
|
+
*/
|
|
3104
|
+
export declare function histogram(a: NDArray, bins?: number | NDArray, range?: [number, number], density?: boolean, weights?: NDArray): [NDArray, NDArray];
|
|
3105
|
+
/**
|
|
3106
|
+
* Compute the bi-dimensional histogram of two data samples.
|
|
3107
|
+
*
|
|
3108
|
+
* @param x - Array of x coordinates
|
|
3109
|
+
* @param y - Array of y coordinates (must have same length as x)
|
|
3110
|
+
* @param bins - Number of bins or [nx, ny] or [x_edges, y_edges]
|
|
3111
|
+
* @param range - [[xmin, xmax], [ymin, ymax]]
|
|
3112
|
+
* @param density - If true, return probability density function
|
|
3113
|
+
* @param weights - Optional weights for each data point
|
|
3114
|
+
* @returns Tuple of [hist, x_edges, y_edges]
|
|
3115
|
+
*/
|
|
3116
|
+
export declare function histogram2d(x: NDArray, y: NDArray, bins?: number | [number, number] | [NDArray, NDArray], range?: [[number, number], [number, number]], density?: boolean, weights?: NDArray): [NDArray, NDArray, NDArray];
|
|
3117
|
+
/**
|
|
3118
|
+
* Compute the multidimensional histogram of some data.
|
|
3119
|
+
*
|
|
3120
|
+
* @param sample - Array of shape (N, D) where N is number of samples and D is number of dimensions
|
|
3121
|
+
* @param bins - Number of bins for all axes, or array of bin counts per axis
|
|
3122
|
+
* @param range - Array of [min, max] for each dimension
|
|
3123
|
+
* @param density - If true, return probability density function
|
|
3124
|
+
* @param weights - Optional weights for each sample
|
|
3125
|
+
* @returns Tuple of [hist, edges (array of edge arrays)]
|
|
3126
|
+
*/
|
|
3127
|
+
export declare function histogramdd(sample: NDArray, bins?: number | number[], range?: [number, number][], density?: boolean, weights?: NDArray): [NDArray, NDArray[]];
|
|
3128
|
+
/**
|
|
3129
|
+
* Cross-correlation of two 1-dimensional sequences.
|
|
3130
|
+
*
|
|
3131
|
+
* @param a - First input sequence
|
|
3132
|
+
* @param v - Second input sequence
|
|
3133
|
+
* @param mode - 'full', 'same', or 'valid' (default: 'full')
|
|
3134
|
+
* @returns Cross-correlation of a and v
|
|
3135
|
+
*/
|
|
3136
|
+
export declare function correlate(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
|
|
3137
|
+
/**
|
|
3138
|
+
* Discrete, linear convolution of two one-dimensional sequences.
|
|
3139
|
+
*
|
|
3140
|
+
* @param a - First input sequence
|
|
3141
|
+
* @param v - Second input sequence
|
|
3142
|
+
* @param mode - 'full', 'same', or 'valid' (default: 'full')
|
|
3143
|
+
* @returns Convolution of a and v
|
|
3144
|
+
*/
|
|
3145
|
+
export declare function convolve(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
|
|
3146
|
+
/**
|
|
3147
|
+
* Estimate a covariance matrix.
|
|
3148
|
+
*
|
|
3149
|
+
* @param m - Input array (1D or 2D). Each row represents a variable, columns are observations.
|
|
3150
|
+
* @param y - Optional second array (for 2 variable case)
|
|
3151
|
+
* @param rowvar - If true, each row is a variable (default: true)
|
|
3152
|
+
* @param bias - If true, use N for normalization; if false, use N-1 (default: false)
|
|
3153
|
+
* @param ddof - Delta degrees of freedom (overrides bias if provided)
|
|
3154
|
+
* @returns Covariance matrix
|
|
3155
|
+
*/
|
|
3156
|
+
export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: boolean, ddof?: number): NDArray;
|
|
3157
|
+
/**
|
|
3158
|
+
* Return Pearson product-moment correlation coefficients.
|
|
3159
|
+
*
|
|
3160
|
+
* @param x - Input array (1D or 2D)
|
|
3161
|
+
* @param y - Optional second array (for 2 variable case)
|
|
3162
|
+
* @param rowvar - If true, each row is a variable (default: true)
|
|
3163
|
+
* @returns Correlation coefficient matrix
|
|
3164
|
+
*/
|
|
3165
|
+
export declare function corrcoef(x: NDArray, y?: NDArray, rowvar?: boolean): NDArray;
|
|
2540
3166
|
//# sourceMappingURL=ndarray.d.ts.map
|