numpy-ts 0.8.0 → 0.10.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.
@@ -39,6 +39,29 @@ export declare class NDArray {
39
39
  * Similar to NumPy's base attribute
40
40
  */
41
41
  get base(): NDArray | null;
42
+ /**
43
+ * Transpose of the array (shorthand for transpose())
44
+ * Returns a view with axes reversed
45
+ */
46
+ get T(): NDArray;
47
+ /**
48
+ * Size of one array element in bytes
49
+ */
50
+ get itemsize(): number;
51
+ /**
52
+ * Total bytes consumed by the elements of the array
53
+ */
54
+ get nbytes(): number;
55
+ /**
56
+ * Fill the array with a scalar value (in-place)
57
+ * @param value - Value to fill with
58
+ */
59
+ fill(value: number | bigint): void;
60
+ /**
61
+ * Iterator protocol - iterate over the first axis
62
+ * For 1D arrays, yields elements; for ND arrays, yields (N-1)D subarrays
63
+ */
64
+ [Symbol.iterator](): Iterator<NDArray | number | bigint>;
42
65
  /**
43
66
  * Get a single element from the array
44
67
  * @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
@@ -120,6 +143,66 @@ export declare class NDArray {
120
143
  * @returns New array with powered values
121
144
  */
122
145
  power(exponent: NDArray | number): NDArray;
146
+ /**
147
+ * Natural exponential (e^x) of each element
148
+ * Promotes integer types to float64
149
+ * @returns New array with exp values
150
+ */
151
+ exp(): NDArray;
152
+ /**
153
+ * Base-2 exponential (2^x) of each element
154
+ * Promotes integer types to float64
155
+ * @returns New array with exp2 values
156
+ */
157
+ exp2(): NDArray;
158
+ /**
159
+ * Exponential minus one (e^x - 1) of each element
160
+ * More accurate than exp(x) - 1 for small x
161
+ * Promotes integer types to float64
162
+ * @returns New array with expm1 values
163
+ */
164
+ expm1(): NDArray;
165
+ /**
166
+ * Natural logarithm (ln) of each element
167
+ * Promotes integer types to float64
168
+ * @returns New array with log values
169
+ */
170
+ log(): NDArray;
171
+ /**
172
+ * Base-2 logarithm of each element
173
+ * Promotes integer types to float64
174
+ * @returns New array with log2 values
175
+ */
176
+ log2(): NDArray;
177
+ /**
178
+ * Base-10 logarithm of each element
179
+ * Promotes integer types to float64
180
+ * @returns New array with log10 values
181
+ */
182
+ log10(): NDArray;
183
+ /**
184
+ * Natural logarithm of (1 + x) of each element
185
+ * More accurate than log(1 + x) for small x
186
+ * Promotes integer types to float64
187
+ * @returns New array with log1p values
188
+ */
189
+ log1p(): NDArray;
190
+ /**
191
+ * Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
192
+ * More numerically stable than computing the expression directly
193
+ * Promotes integer types to float64
194
+ * @param x2 - Second operand (array or scalar)
195
+ * @returns New array with logaddexp values
196
+ */
197
+ logaddexp(x2: NDArray | number): NDArray;
198
+ /**
199
+ * Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
200
+ * More numerically stable than computing the expression directly
201
+ * Promotes integer types to float64
202
+ * @param x2 - Second operand (array or scalar)
203
+ * @returns New array with logaddexp2 values
204
+ */
205
+ logaddexp2(x2: NDArray | number): NDArray;
123
206
  /**
124
207
  * Absolute value of each element
125
208
  * @returns New array with absolute values
@@ -135,6 +218,43 @@ export declare class NDArray {
135
218
  * @returns New array with signs
136
219
  */
137
220
  sign(): NDArray;
221
+ /**
222
+ * Round an array to the given number of decimals
223
+ * @param decimals - Number of decimal places to round to (default: 0)
224
+ * @returns New array with rounded values
225
+ */
226
+ around(decimals?: number): NDArray;
227
+ /**
228
+ * Round an array to the given number of decimals (alias for around)
229
+ * @param decimals - Number of decimal places to round to (default: 0)
230
+ * @returns New array with rounded values
231
+ */
232
+ round(decimals?: number): NDArray;
233
+ /**
234
+ * Return the ceiling of the input, element-wise
235
+ * @returns New array with ceiling values
236
+ */
237
+ ceil(): NDArray;
238
+ /**
239
+ * Round to nearest integer towards zero
240
+ * @returns New array with values truncated towards zero
241
+ */
242
+ fix(): NDArray;
243
+ /**
244
+ * Return the floor of the input, element-wise
245
+ * @returns New array with floor values
246
+ */
247
+ floor(): NDArray;
248
+ /**
249
+ * Round elements to the nearest integer
250
+ * @returns New array with rounded integer values
251
+ */
252
+ rint(): NDArray;
253
+ /**
254
+ * Return the truncated value of the input, element-wise
255
+ * @returns New array with truncated values
256
+ */
257
+ trunc(): NDArray;
138
258
  /**
139
259
  * Sine of each element (in radians)
140
260
  * Promotes integer types to float64
@@ -324,6 +444,71 @@ export declare class NDArray {
324
444
  * @returns Result of right shift
325
445
  */
326
446
  right_shift(shift: NDArray | number): NDArray;
447
+ /**
448
+ * Logical AND element-wise
449
+ * @param other - Array or scalar for AND operation
450
+ * @returns Boolean array (1 = true, 0 = false)
451
+ */
452
+ logical_and(other: NDArray | number): NDArray;
453
+ /**
454
+ * Logical OR element-wise
455
+ * @param other - Array or scalar for OR operation
456
+ * @returns Boolean array (1 = true, 0 = false)
457
+ */
458
+ logical_or(other: NDArray | number): NDArray;
459
+ /**
460
+ * Logical NOT element-wise
461
+ * @returns Boolean array (1 = true, 0 = false)
462
+ */
463
+ logical_not(): NDArray;
464
+ /**
465
+ * Logical XOR element-wise
466
+ * @param other - Array or scalar for XOR operation
467
+ * @returns Boolean array (1 = true, 0 = false)
468
+ */
469
+ logical_xor(other: NDArray | number): NDArray;
470
+ /**
471
+ * Test element-wise for finiteness (not infinity and not NaN)
472
+ * @returns Boolean array
473
+ */
474
+ isfinite(): NDArray;
475
+ /**
476
+ * Test element-wise for positive or negative infinity
477
+ * @returns Boolean array
478
+ */
479
+ isinf(): NDArray;
480
+ /**
481
+ * Test element-wise for NaN (Not a Number)
482
+ * @returns Boolean array
483
+ */
484
+ isnan(): NDArray;
485
+ /**
486
+ * Test element-wise for NaT (Not a Time)
487
+ * @returns Boolean array (always false without datetime support)
488
+ */
489
+ isnat(): NDArray;
490
+ /**
491
+ * Change the sign of x1 to that of x2, element-wise
492
+ * @param x2 - Values whose sign is used
493
+ * @returns Array with magnitude from this and sign from x2
494
+ */
495
+ copysign(x2: NDArray | number): NDArray;
496
+ /**
497
+ * Returns element-wise True where signbit is set (less than zero)
498
+ * @returns Boolean array
499
+ */
500
+ signbit(): NDArray;
501
+ /**
502
+ * Return the next floating-point value after x1 towards x2, element-wise
503
+ * @param x2 - Direction to look for the next representable value
504
+ * @returns Array of next representable values
505
+ */
506
+ nextafter(x2: NDArray | number): NDArray;
507
+ /**
508
+ * Return the distance between x and the nearest adjacent number
509
+ * @returns Array of spacing values
510
+ */
511
+ spacing(): NDArray;
327
512
  /**
328
513
  * Sum array elements over a given axis
329
514
  * @param axis - Axis along which to sum. If undefined, sum all elements
@@ -565,6 +750,12 @@ export declare class NDArray {
565
750
  * @returns Tuple of arrays, one for each dimension
566
751
  */
567
752
  nonzero(): NDArray[];
753
+ /**
754
+ * Find the indices of array elements that are non-zero, grouped by element
755
+ * Returns a 2D array where each row is the index of a non-zero element.
756
+ * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
757
+ */
758
+ argwhere(): NDArray;
568
759
  /**
569
760
  * Find indices where elements should be inserted to maintain order
570
761
  * @param v - Values to insert
@@ -572,6 +763,13 @@ export declare class NDArray {
572
763
  * @returns Indices where values should be inserted
573
764
  */
574
765
  searchsorted(v: NDArray, side?: 'left' | 'right'): NDArray;
766
+ /**
767
+ * Calculate the n-th discrete difference along the given axis
768
+ * @param n - Number of times values are differenced (default: 1)
769
+ * @param axis - Axis along which to compute difference (default: -1)
770
+ * @returns Array of differences
771
+ */
772
+ diff(n?: number, axis?: number): NDArray;
575
773
  /**
576
774
  * Reshape array to a new shape
577
775
  * Returns a new array with the specified shape
@@ -1027,12 +1225,74 @@ export declare function sqrt(x: NDArray): NDArray;
1027
1225
  * @returns Array of x raised to exponent
1028
1226
  */
1029
1227
  export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
1228
+ export { power as pow };
1229
+ /**
1230
+ * Element-wise natural exponential (e^x)
1231
+ * @param x - Input array
1232
+ * @returns Array of e^x values
1233
+ */
1234
+ export declare function exp(x: NDArray): NDArray;
1235
+ /**
1236
+ * Element-wise base-2 exponential (2^x)
1237
+ * @param x - Input array
1238
+ * @returns Array of 2^x values
1239
+ */
1240
+ export declare function exp2(x: NDArray): NDArray;
1241
+ /**
1242
+ * Element-wise exponential minus one (e^x - 1)
1243
+ * More accurate than exp(x) - 1 for small x
1244
+ * @param x - Input array
1245
+ * @returns Array of expm1 values
1246
+ */
1247
+ export declare function expm1(x: NDArray): NDArray;
1248
+ /**
1249
+ * Element-wise natural logarithm (ln)
1250
+ * @param x - Input array
1251
+ * @returns Array of log values
1252
+ */
1253
+ export declare function log(x: NDArray): NDArray;
1254
+ /**
1255
+ * Element-wise base-2 logarithm
1256
+ * @param x - Input array
1257
+ * @returns Array of log2 values
1258
+ */
1259
+ export declare function log2(x: NDArray): NDArray;
1260
+ /**
1261
+ * Element-wise base-10 logarithm
1262
+ * @param x - Input array
1263
+ * @returns Array of log10 values
1264
+ */
1265
+ export declare function log10(x: NDArray): NDArray;
1266
+ /**
1267
+ * Element-wise natural logarithm of (1 + x)
1268
+ * More accurate than log(1 + x) for small x
1269
+ * @param x - Input array
1270
+ * @returns Array of log1p values
1271
+ */
1272
+ export declare function log1p(x: NDArray): NDArray;
1273
+ /**
1274
+ * Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
1275
+ * More numerically stable than computing the expression directly
1276
+ * @param x1 - First input array
1277
+ * @param x2 - Second input array or scalar
1278
+ * @returns Array of logaddexp values
1279
+ */
1280
+ export declare function logaddexp(x1: NDArray, x2: NDArray | number): NDArray;
1281
+ /**
1282
+ * Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
1283
+ * More numerically stable than computing the expression directly
1284
+ * @param x1 - First input array
1285
+ * @param x2 - Second input array or scalar
1286
+ * @returns Array of logaddexp2 values
1287
+ */
1288
+ export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
1030
1289
  /**
1031
1290
  * Element-wise absolute value
1032
1291
  * @param x - Input array
1033
1292
  * @returns Array of absolute values
1034
1293
  */
1035
1294
  export declare function absolute(x: NDArray): NDArray;
1295
+ export { absolute as abs };
1036
1296
  /**
1037
1297
  * Element-wise negation
1038
1298
  * @param x - Input array
@@ -1052,6 +1312,14 @@ export declare function sign(x: NDArray): NDArray;
1052
1312
  * @returns Remainder after division
1053
1313
  */
1054
1314
  export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
1315
+ /**
1316
+ * Element-wise division
1317
+ * @param x - Dividend array
1318
+ * @param divisor - Divisor (array or scalar)
1319
+ * @returns Array of quotients
1320
+ */
1321
+ export declare function divide(x: NDArray, divisor: NDArray | number): NDArray;
1322
+ export { divide as true_divide };
1055
1323
  /**
1056
1324
  * Element-wise floor division
1057
1325
  * @param x - Dividend array
@@ -1177,18 +1445,21 @@ export declare function tan(x: NDArray): NDArray;
1177
1445
  * @returns Array of angles in radians
1178
1446
  */
1179
1447
  export declare function arcsin(x: NDArray): NDArray;
1448
+ export { arcsin as asin };
1180
1449
  /**
1181
1450
  * Element-wise inverse cosine
1182
1451
  * @param x - Input array (values in range [-1, 1])
1183
1452
  * @returns Array of angles in radians
1184
1453
  */
1185
1454
  export declare function arccos(x: NDArray): NDArray;
1455
+ export { arccos as acos };
1186
1456
  /**
1187
1457
  * Element-wise inverse tangent
1188
1458
  * @param x - Input array
1189
1459
  * @returns Array of angles in radians
1190
1460
  */
1191
1461
  export declare function arctan(x: NDArray): NDArray;
1462
+ export { arctan as atan };
1192
1463
  /**
1193
1464
  * Element-wise arc tangent of x1/x2 choosing the quadrant correctly
1194
1465
  * @param x1 - y-coordinates
@@ -1196,6 +1467,7 @@ export declare function arctan(x: NDArray): NDArray;
1196
1467
  * @returns Angles in radians between -π and π
1197
1468
  */
1198
1469
  export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
1470
+ export { arctan2 as atan2 };
1199
1471
  /**
1200
1472
  * Given the "legs" of a right triangle, return its hypotenuse
1201
1473
  * Equivalent to sqrt(x1**2 + x2**2), element-wise
@@ -1252,18 +1524,21 @@ export declare function tanh(x: NDArray): NDArray;
1252
1524
  * @returns Array of arcsinh values
1253
1525
  */
1254
1526
  export declare function arcsinh(x: NDArray): NDArray;
1527
+ export { arcsinh as asinh };
1255
1528
  /**
1256
1529
  * Element-wise inverse hyperbolic cosine
1257
1530
  * @param x - Input array (values >= 1)
1258
1531
  * @returns Array of arccosh values
1259
1532
  */
1260
1533
  export declare function arccosh(x: NDArray): NDArray;
1534
+ export { arccosh as acosh };
1261
1535
  /**
1262
1536
  * Element-wise inverse hyperbolic tangent
1263
1537
  * @param x - Input array (values in range (-1, 1))
1264
1538
  * @returns Array of arctanh values
1265
1539
  */
1266
1540
  export declare function arctanh(x: NDArray): NDArray;
1541
+ export { arctanh as atanh };
1267
1542
  /**
1268
1543
  * Swap two axes of an array
1269
1544
  *
@@ -1582,6 +1857,22 @@ export declare function take(a: NDArray, indices: number[], axis?: number): NDAr
1582
1857
  * @param values - Values to put
1583
1858
  */
1584
1859
  export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
1860
+ /**
1861
+ * Copy values from one array to another, broadcasting as necessary.
1862
+ *
1863
+ * @param dst - Destination array (modified in-place)
1864
+ * @param src - Source array or scalar
1865
+ * @param where - Optional boolean array. Only copy where True (not yet implemented)
1866
+ * @throws Error if shapes are not broadcastable
1867
+ *
1868
+ * @example
1869
+ * ```typescript
1870
+ * const dst = np.zeros([3, 3]);
1871
+ * const src = np.array([1, 2, 3]);
1872
+ * np.copyto(dst, src); // Each row of dst becomes [1, 2, 3]
1873
+ * ```
1874
+ */
1875
+ export declare function copyto(dst: NDArray, src: NDArray | number | bigint, where?: NDArray): void;
1585
1876
  /**
1586
1877
  * Construct array from index array and choices
1587
1878
  *
@@ -1615,6 +1906,7 @@ export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
1615
1906
  * @returns Array with cumulative sums
1616
1907
  */
1617
1908
  export declare function cumsum(a: NDArray, axis?: number): NDArray;
1909
+ export { cumsum as cumulative_sum };
1618
1910
  /**
1619
1911
  * Return the cumulative product of the elements along a given axis.
1620
1912
  * @param a - Input array
@@ -1622,6 +1914,25 @@ export declare function cumsum(a: NDArray, axis?: number): NDArray;
1622
1914
  * @returns Array with cumulative products
1623
1915
  */
1624
1916
  export declare function cumprod(a: NDArray, axis?: number): NDArray;
1917
+ export { cumprod as cumulative_prod };
1918
+ /**
1919
+ * Return the maximum along a given axis.
1920
+ * @param a - Input array
1921
+ * @param axis - Axis along which to compute. If undefined, use all elements.
1922
+ * @param keepdims - If true, reduced axes are left as dimensions with size 1
1923
+ * @returns Maximum value(s)
1924
+ */
1925
+ export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
1926
+ export { max as amax };
1927
+ /**
1928
+ * Return the minimum along a given axis.
1929
+ * @param a - Input array
1930
+ * @param axis - Axis along which to compute. If undefined, use all elements.
1931
+ * @param keepdims - If true, reduced axes are left as dimensions with size 1
1932
+ * @returns Minimum value(s)
1933
+ */
1934
+ export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
1935
+ export { min as amin };
1625
1936
  /**
1626
1937
  * Peak to peak (maximum - minimum) value along a given axis.
1627
1938
  * @param a - Input array
@@ -1804,6 +2115,55 @@ export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
1804
2115
  * @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
1805
2116
  */
1806
2117
  export declare function heaviside(x1: NDArray, x2: NDArray | number): NDArray;
2118
+ /**
2119
+ * First array raised to power of second, always promoting to float
2120
+ * @param x1 - Base values
2121
+ * @param x2 - Exponent values
2122
+ * @returns Result in float64
2123
+ */
2124
+ export declare function float_power(x1: NDArray, x2: NDArray | number): NDArray;
2125
+ /**
2126
+ * Element-wise remainder of division (fmod)
2127
+ * Unlike mod/remainder, fmod matches C fmod behavior
2128
+ * @param x1 - Dividend
2129
+ * @param x2 - Divisor
2130
+ * @returns Remainder
2131
+ */
2132
+ export declare function fmod(x1: NDArray, x2: NDArray | number): NDArray;
2133
+ /**
2134
+ * Decompose floating point numbers into mantissa and exponent
2135
+ * Returns [mantissa, exponent] where x = mantissa * 2^exponent
2136
+ * @param x - Input array
2137
+ * @returns Tuple of [mantissa, exponent] arrays
2138
+ */
2139
+ export declare function frexp(x: NDArray): [NDArray, NDArray];
2140
+ /**
2141
+ * Greatest common divisor
2142
+ * @param x1 - First array
2143
+ * @param x2 - Second array or scalar
2144
+ * @returns GCD
2145
+ */
2146
+ export declare function gcd(x1: NDArray, x2: NDArray | number): NDArray;
2147
+ /**
2148
+ * Least common multiple
2149
+ * @param x1 - First array
2150
+ * @param x2 - Second array or scalar
2151
+ * @returns LCM
2152
+ */
2153
+ export declare function lcm(x1: NDArray, x2: NDArray | number): NDArray;
2154
+ /**
2155
+ * Returns x1 * 2^x2, element-wise
2156
+ * @param x1 - Mantissa
2157
+ * @param x2 - Exponent
2158
+ * @returns Result
2159
+ */
2160
+ export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
2161
+ /**
2162
+ * Return fractional and integral parts of array
2163
+ * @param x - Input array
2164
+ * @returns Tuple of [fractional, integral] arrays
2165
+ */
2166
+ export declare function modf(x: NDArray): [NDArray, NDArray];
1807
2167
  /**
1808
2168
  * Bitwise AND element-wise
1809
2169
  *
@@ -1882,6 +2242,189 @@ export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | '
1882
2242
  * @returns Unpacked uint8 array of 0s and 1s
1883
2243
  */
1884
2244
  export declare function unpackbits(a: NDArray, axis?: number, count?: number, bitorder?: 'big' | 'little'): NDArray;
2245
+ /**
2246
+ * Logical AND element-wise
2247
+ *
2248
+ * Returns a boolean array where each element is the logical AND
2249
+ * of corresponding elements (non-zero = true, zero = false).
2250
+ *
2251
+ * @param x1 - First input array
2252
+ * @param x2 - Second input array or scalar
2253
+ * @returns Boolean result array
2254
+ */
2255
+ export declare function logical_and(x1: NDArray, x2: NDArray | number): NDArray;
2256
+ /**
2257
+ * Logical OR element-wise
2258
+ *
2259
+ * Returns a boolean array where each element is the logical OR
2260
+ * of corresponding elements (non-zero = true, zero = false).
2261
+ *
2262
+ * @param x1 - First input array
2263
+ * @param x2 - Second input array or scalar
2264
+ * @returns Boolean result array
2265
+ */
2266
+ export declare function logical_or(x1: NDArray, x2: NDArray | number): NDArray;
2267
+ /**
2268
+ * Logical NOT element-wise
2269
+ *
2270
+ * Returns a boolean array where each element is the logical NOT
2271
+ * of the input (non-zero = false, zero = true).
2272
+ *
2273
+ * @param x - Input array
2274
+ * @returns Boolean result array
2275
+ */
2276
+ export declare function logical_not(x: NDArray): NDArray;
2277
+ /**
2278
+ * Logical XOR element-wise
2279
+ *
2280
+ * Returns a boolean array where each element is the logical XOR
2281
+ * of corresponding elements (non-zero = true, zero = false).
2282
+ *
2283
+ * @param x1 - First input array
2284
+ * @param x2 - Second input array or scalar
2285
+ * @returns Boolean result array
2286
+ */
2287
+ export declare function logical_xor(x1: NDArray, x2: NDArray | number): NDArray;
2288
+ /**
2289
+ * Test element-wise for finiteness (not infinity and not NaN)
2290
+ *
2291
+ * @param x - Input array
2292
+ * @returns Boolean array where True means finite
2293
+ */
2294
+ export declare function isfinite(x: NDArray): NDArray;
2295
+ /**
2296
+ * Test element-wise for positive or negative infinity
2297
+ *
2298
+ * @param x - Input array
2299
+ * @returns Boolean array where True means infinite
2300
+ */
2301
+ export declare function isinf(x: NDArray): NDArray;
2302
+ /**
2303
+ * Test element-wise for NaN (Not a Number)
2304
+ *
2305
+ * @param x - Input array
2306
+ * @returns Boolean array where True means NaN
2307
+ */
2308
+ export declare function isnan(x: NDArray): NDArray;
2309
+ /**
2310
+ * Test element-wise for NaT (Not a Time)
2311
+ *
2312
+ * @param x - Input array
2313
+ * @returns Boolean array (always false without datetime support)
2314
+ */
2315
+ export declare function isnat(x: NDArray): NDArray;
2316
+ /**
2317
+ * Change the sign of x1 to that of x2, element-wise
2318
+ *
2319
+ * Returns a value with the magnitude of x1 and the sign of x2.
2320
+ *
2321
+ * @param x1 - Values to change sign of (magnitude source)
2322
+ * @param x2 - Values whose sign is used (sign source)
2323
+ * @returns Array with magnitude from x1 and sign from x2
2324
+ */
2325
+ export declare function copysign(x1: NDArray, x2: NDArray | number): NDArray;
2326
+ /**
2327
+ * Returns element-wise True where signbit is set (less than zero)
2328
+ *
2329
+ * @param x - Input array
2330
+ * @returns Boolean array where True means signbit is set
2331
+ */
2332
+ export declare function signbit(x: NDArray): NDArray;
2333
+ /**
2334
+ * Return the next floating-point value after x1 towards x2, element-wise
2335
+ *
2336
+ * @param x1 - Values to find the next representable value of
2337
+ * @param x2 - Direction to look for the next representable value
2338
+ * @returns Array of next representable values
2339
+ */
2340
+ export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
2341
+ /**
2342
+ * Return the distance between x and the nearest adjacent number
2343
+ *
2344
+ * @param x - Input array
2345
+ * @returns Array of spacing values
2346
+ */
2347
+ export declare function spacing(x: NDArray): NDArray;
2348
+ /**
2349
+ * Test element-wise for complex number
2350
+ * Since numpy-ts doesn't support complex numbers, always returns false
2351
+ * @param x - Input array
2352
+ * @returns Boolean array (all false)
2353
+ */
2354
+ export declare function iscomplex(x: NDArray): NDArray;
2355
+ /**
2356
+ * Check whether array is complex type
2357
+ * Since numpy-ts doesn't support complex numbers, always returns false
2358
+ * @param x - Input array
2359
+ * @returns false
2360
+ */
2361
+ export declare function iscomplexobj(x: NDArray): boolean;
2362
+ /**
2363
+ * Test element-wise for real number (not complex)
2364
+ * Since numpy-ts doesn't support complex numbers, always returns true
2365
+ * @param x - Input array
2366
+ * @returns Boolean array (all true)
2367
+ */
2368
+ export declare function isreal(x: NDArray): NDArray;
2369
+ /**
2370
+ * Check whether array is real type (not complex)
2371
+ * Since numpy-ts doesn't support complex numbers, always returns true
2372
+ * @param x - Input array
2373
+ * @returns true
2374
+ */
2375
+ export declare function isrealobj(x: NDArray): boolean;
2376
+ /**
2377
+ * Test element-wise for negative infinity
2378
+ * @param x - Input array
2379
+ * @returns Boolean array
2380
+ */
2381
+ export declare function isneginf(x: NDArray): NDArray;
2382
+ /**
2383
+ * Test element-wise for positive infinity
2384
+ * @param x - Input array
2385
+ * @returns Boolean array
2386
+ */
2387
+ export declare function isposinf(x: NDArray): NDArray;
2388
+ /**
2389
+ * Check if array is Fortran contiguous (column-major order)
2390
+ * @param x - Input array
2391
+ * @returns true if F-contiguous
2392
+ */
2393
+ export declare function isfortran(x: NDArray): boolean;
2394
+ /**
2395
+ * Returns array with complex parts close to zero set to real
2396
+ * Since numpy-ts doesn't support complex numbers, returns copy
2397
+ * @param x - Input array
2398
+ * @param tol - Tolerance
2399
+ * @returns Copy of input array
2400
+ */
2401
+ export declare function real_if_close(x: NDArray, tol?: number): NDArray;
2402
+ /**
2403
+ * Check if element is a scalar type
2404
+ * @param val - Value to check
2405
+ * @returns true if scalar
2406
+ */
2407
+ export declare function isscalar(val: unknown): boolean;
2408
+ /**
2409
+ * Check if object is iterable
2410
+ * @param obj - Object to check
2411
+ * @returns true if iterable
2412
+ */
2413
+ export declare function iterable(obj: unknown): boolean;
2414
+ /**
2415
+ * Check if dtype meets specified criteria
2416
+ * @param dtype - Dtype to check
2417
+ * @param kind - Kind of dtype ('b' bool, 'i' int, 'u' uint, 'f' float)
2418
+ * @returns true if dtype matches kind
2419
+ */
2420
+ export declare function isdtype(dtype: DType, kind: string): boolean;
2421
+ /**
2422
+ * Find the dtype that can represent both input dtypes
2423
+ * @param dtype1 - First dtype
2424
+ * @param dtype2 - Second dtype
2425
+ * @returns Promoted dtype
2426
+ */
2427
+ export declare function promote_types(dtype1: DType, dtype2: DType): DType;
1885
2428
  /**
1886
2429
  * Einstein summation convention
1887
2430
  *
@@ -1904,6 +2447,108 @@ export declare function unpackbits(a: NDArray, axis?: number, count?: number, bi
1904
2447
  * einsum('ii->', a)
1905
2448
  */
1906
2449
  export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint;
2450
+ /**
2451
+ * numpy.linalg module - Linear algebra functions
2452
+ */
2453
+ export declare const linalg: {
2454
+ /**
2455
+ * Cross product of two vectors.
2456
+ */
2457
+ cross: (a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number, axis?: number) => NDArray | number;
2458
+ /**
2459
+ * Compute the norm of a vector or matrix.
2460
+ */
2461
+ norm: (x: NDArray, ord?: number | "fro" | "nuc" | null, axis?: number | [number, number] | null, keepdims?: boolean) => NDArray | number;
2462
+ /**
2463
+ * Compute the vector norm.
2464
+ */
2465
+ vector_norm: (x: NDArray, ord?: number, axis?: number | null, keepdims?: boolean) => NDArray | number;
2466
+ /**
2467
+ * Compute the matrix norm.
2468
+ */
2469
+ matrix_norm: (x: NDArray, ord?: number | "fro" | "nuc", keepdims?: boolean) => NDArray | number;
2470
+ /**
2471
+ * QR decomposition.
2472
+ */
2473
+ qr: (a: NDArray, mode?: "reduced" | "complete" | "r" | "raw") => {
2474
+ q: NDArray;
2475
+ r: NDArray;
2476
+ } | NDArray | {
2477
+ h: NDArray;
2478
+ tau: NDArray;
2479
+ };
2480
+ /**
2481
+ * Cholesky decomposition.
2482
+ */
2483
+ cholesky: (a: NDArray, upper?: boolean) => NDArray;
2484
+ /**
2485
+ * Singular Value Decomposition.
2486
+ */
2487
+ svd: (a: NDArray, full_matrices?: boolean, compute_uv?: boolean) => {
2488
+ u: NDArray;
2489
+ s: NDArray;
2490
+ vt: NDArray;
2491
+ } | NDArray;
2492
+ /**
2493
+ * Compute the determinant of a matrix.
2494
+ */
2495
+ det: (a: NDArray) => number;
2496
+ /**
2497
+ * Compute the matrix inverse.
2498
+ */
2499
+ inv: (a: NDArray) => NDArray;
2500
+ /**
2501
+ * Solve a linear system.
2502
+ */
2503
+ solve: (a: NDArray, b: NDArray) => NDArray;
2504
+ /**
2505
+ * Least-squares solution to a linear matrix equation.
2506
+ */
2507
+ lstsq: (a: NDArray, b: NDArray, rcond?: number | null) => {
2508
+ x: NDArray;
2509
+ residuals: NDArray;
2510
+ rank: number;
2511
+ s: NDArray;
2512
+ };
2513
+ /**
2514
+ * Compute the condition number.
2515
+ */
2516
+ cond: (a: NDArray, p?: number | "fro" | "nuc") => number;
2517
+ /**
2518
+ * Compute the matrix rank.
2519
+ */
2520
+ matrix_rank: (a: NDArray, tol?: number) => number;
2521
+ /**
2522
+ * Raise a square matrix to an integer power.
2523
+ */
2524
+ matrix_power: (a: NDArray, n: number) => NDArray;
2525
+ /**
2526
+ * Compute the Moore-Penrose pseudo-inverse.
2527
+ */
2528
+ pinv: (a: NDArray, rcond?: number) => NDArray;
2529
+ /**
2530
+ * Compute eigenvalues and eigenvectors.
2531
+ */
2532
+ eig: (a: NDArray) => {
2533
+ w: NDArray;
2534
+ v: NDArray;
2535
+ };
2536
+ /**
2537
+ * Compute eigenvalues and eigenvectors of a Hermitian matrix.
2538
+ */
2539
+ eigh: (a: NDArray, UPLO?: "L" | "U") => {
2540
+ w: NDArray;
2541
+ v: NDArray;
2542
+ };
2543
+ /**
2544
+ * Compute eigenvalues of a matrix.
2545
+ */
2546
+ eigvals: (a: NDArray) => NDArray;
2547
+ /**
2548
+ * Compute eigenvalues of a Hermitian matrix.
2549
+ */
2550
+ eigvalsh: (a: NDArray, UPLO?: "L" | "U") => NDArray;
2551
+ };
1907
2552
  /**
1908
2553
  * Take values from the input array by matching 1d index and data slices along axis.
1909
2554
  *
@@ -1956,6 +2601,13 @@ export declare function select(condlist: NDArray[], choicelist: NDArray[], defau
1956
2601
  * @param vals - Values to place where mask is True (cycles if shorter)
1957
2602
  */
1958
2603
  export declare function place(arr: NDArray, mask: NDArray, vals: NDArray): void;
2604
+ /**
2605
+ * Fill the main diagonal of a given array (modifies in-place)
2606
+ * @param a - Array (at least 2D)
2607
+ * @param val - Value or array of values to fill diagonal with
2608
+ * @param wrap - Whether to wrap for tall matrices
2609
+ */
2610
+ export declare function fill_diagonal(a: NDArray, val: NDArray | number, wrap?: boolean): void;
1959
2611
  /**
1960
2612
  * Return the indices to access the main diagonal of an array.
1961
2613
  *
@@ -2098,6 +2750,14 @@ export declare function sort_complex(a: NDArray): NDArray;
2098
2750
  * @returns Tuple of arrays, one for each dimension
2099
2751
  */
2100
2752
  export declare function nonzero(a: NDArray): NDArray[];
2753
+ /**
2754
+ * Find the indices of array elements that are non-zero, grouped by element
2755
+ * Returns a 2D array where each row is the index of a non-zero element.
2756
+ * This is equivalent to transpose(nonzero(a)).
2757
+ * @param a - Input array
2758
+ * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
2759
+ */
2760
+ export declare function argwhere(a: NDArray): NDArray;
2101
2761
  /**
2102
2762
  * Return indices of non-zero elements in flattened array
2103
2763
  * @param a - Input array
@@ -2135,4 +2795,231 @@ export declare function extract(condition: NDArray, a: NDArray): NDArray;
2135
2795
  * @returns Count of non-zero values
2136
2796
  */
2137
2797
  export declare function count_nonzero(a: NDArray, axis?: number): NDArray | number;
2798
+ /**
2799
+ * Round an array to the given number of decimals
2800
+ * @param a - Input array
2801
+ * @param decimals - Number of decimal places to round to (default: 0)
2802
+ * @returns Rounded array
2803
+ */
2804
+ export declare function around(a: NDArray, decimals?: number): NDArray;
2805
+ export { around as round_ };
2806
+ /**
2807
+ * Return the ceiling of the input, element-wise
2808
+ * @param x - Input array
2809
+ * @returns Element-wise ceiling
2810
+ */
2811
+ export declare function ceil(x: NDArray): NDArray;
2812
+ /**
2813
+ * Round to nearest integer towards zero
2814
+ * @param x - Input array
2815
+ * @returns Array with values truncated towards zero
2816
+ */
2817
+ export declare function fix(x: NDArray): NDArray;
2818
+ /**
2819
+ * Return the floor of the input, element-wise
2820
+ * @param x - Input array
2821
+ * @returns Element-wise floor
2822
+ */
2823
+ export declare function floor(x: NDArray): NDArray;
2824
+ /**
2825
+ * Round elements of the array to the nearest integer
2826
+ * @param x - Input array
2827
+ * @returns Array with rounded integer values
2828
+ */
2829
+ export declare function rint(x: NDArray): NDArray;
2830
+ /**
2831
+ * Evenly round to the given number of decimals (alias for around)
2832
+ * @param a - Input array
2833
+ * @param decimals - Number of decimal places to round to (default: 0)
2834
+ * @returns Rounded array
2835
+ */
2836
+ export { around as round };
2837
+ /**
2838
+ * Return the truncated value of the input, element-wise
2839
+ * @param x - Input array
2840
+ * @returns Element-wise truncated values
2841
+ */
2842
+ export declare function trunc(x: NDArray): NDArray;
2843
+ /**
2844
+ * Find the unique elements of an array
2845
+ * @param ar - Input array
2846
+ * @param returnIndex - If True, also return the indices of the first occurrences
2847
+ * @param returnInverse - If True, also return the indices to reconstruct the original array
2848
+ * @param returnCounts - If True, also return the number of times each unique value appears
2849
+ * @returns Unique sorted values, and optionally indices/inverse/counts
2850
+ */
2851
+ export declare function unique(ar: NDArray, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): NDArray | {
2852
+ values: NDArray;
2853
+ indices?: NDArray;
2854
+ inverse?: NDArray;
2855
+ counts?: NDArray;
2856
+ };
2857
+ /**
2858
+ * Test whether each element of a 1-D array is also present in a second array
2859
+ * @param ar1 - Input array
2860
+ * @param ar2 - Test values
2861
+ * @returns Boolean array indicating membership
2862
+ */
2863
+ export declare function in1d(ar1: NDArray, ar2: NDArray): NDArray;
2864
+ /**
2865
+ * Find the intersection of two arrays
2866
+ * @param ar1 - First input array
2867
+ * @param ar2 - Second input array
2868
+ * @returns Sorted 1D array of common and unique elements
2869
+ */
2870
+ export declare function intersect1d(ar1: NDArray, ar2: NDArray): NDArray;
2871
+ /**
2872
+ * Test whether each element of an ND array is also present in a second array
2873
+ * @param element - Input array
2874
+ * @param testElements - Test values
2875
+ * @returns Boolean array indicating membership (same shape as element)
2876
+ */
2877
+ export declare function isin(element: NDArray, testElements: NDArray): NDArray;
2878
+ /**
2879
+ * Find the set difference of two arrays
2880
+ * @param ar1 - First input array
2881
+ * @param ar2 - Second input array
2882
+ * @returns Sorted 1D array of values in ar1 that are not in ar2
2883
+ */
2884
+ export declare function setdiff1d(ar1: NDArray, ar2: NDArray): NDArray;
2885
+ /**
2886
+ * Find the set exclusive-or of two arrays
2887
+ * @param ar1 - First input array
2888
+ * @param ar2 - Second input array
2889
+ * @returns Sorted 1D array of values that are in only one array
2890
+ */
2891
+ export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
2892
+ /**
2893
+ * Find the union of two arrays
2894
+ * @param ar1 - First input array
2895
+ * @param ar2 - Second input array
2896
+ * @returns Sorted 1D array of unique values from both arrays
2897
+ */
2898
+ export declare function union1d(ar1: NDArray, ar2: NDArray): NDArray;
2899
+ /**
2900
+ * Calculate the n-th discrete difference along the given axis
2901
+ * @param a - Input array
2902
+ * @param n - Number of times values are differenced (default: 1)
2903
+ * @param axis - Axis along which to compute difference (default: -1)
2904
+ * @returns Array of differences
2905
+ */
2906
+ export declare function diff(a: NDArray, n?: number, axis?: number): NDArray;
2907
+ /**
2908
+ * The differences between consecutive elements of a flattened array
2909
+ * @param ary - Input array
2910
+ * @param to_end - Number(s) to append at the end
2911
+ * @param to_begin - Number(s) to prepend at the beginning
2912
+ * @returns Array of differences
2913
+ */
2914
+ export declare function ediff1d(ary: NDArray, to_end?: number[] | null, to_begin?: number[] | null): NDArray;
2915
+ /**
2916
+ * Return the gradient of an N-dimensional array
2917
+ * The gradient is computed using second order accurate central differences
2918
+ * in the interior and first order accurate one-sided differences at the boundaries.
2919
+ * @param f - Input array
2920
+ * @param varargs - Spacing between values (scalar or array per dimension)
2921
+ * @param axis - Axis or axes along which to compute gradient
2922
+ * @returns Array of gradients (one per axis) or single gradient
2923
+ */
2924
+ export declare function gradient(f: NDArray, varargs?: number | number[], axis?: number | number[] | null): NDArray | NDArray[];
2925
+ /**
2926
+ * Return the cross product of two (arrays of) vectors
2927
+ * @param a - First input array
2928
+ * @param b - Second input array
2929
+ * @param axisa - Axis of a that defines the vector(s) (default: -1)
2930
+ * @param axisb - Axis of b that defines the vector(s) (default: -1)
2931
+ * @param axisc - Axis of c containing the cross product (default: -1)
2932
+ * @returns Cross product array
2933
+ */
2934
+ export declare function cross(a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number): NDArray;
2935
+ /**
2936
+ * Count number of occurrences of each value in array of non-negative ints.
2937
+ *
2938
+ * @param x - Input array (must contain non-negative integers)
2939
+ * @param weights - Optional weights, same shape as x
2940
+ * @param minlength - Minimum number of bins for output (default: 0)
2941
+ * @returns Array of bin counts
2942
+ */
2943
+ export declare function bincount(x: NDArray, weights?: NDArray, minlength?: number): NDArray;
2944
+ /**
2945
+ * Return the indices of the bins to which each value in input array belongs.
2946
+ *
2947
+ * @param x - Input array to be binned
2948
+ * @param bins - Array of bins (monotonically increasing or decreasing)
2949
+ * @param right - If true, intervals are closed on the right (default: false)
2950
+ * @returns Array of bin indices
2951
+ */
2952
+ export declare function digitize(x: NDArray, bins: NDArray, right?: boolean): NDArray;
2953
+ /**
2954
+ * Compute the histogram of a set of data.
2955
+ *
2956
+ * @param a - Input data (flattened if not 1D)
2957
+ * @param bins - Number of bins (default: 10) or array of bin edges
2958
+ * @param range - Lower and upper range of bins
2959
+ * @param density - If true, return probability density function (default: false)
2960
+ * @param weights - Optional weights for each data point
2961
+ * @returns Tuple of [hist, bin_edges]
2962
+ */
2963
+ export declare function histogram(a: NDArray, bins?: number | NDArray, range?: [number, number], density?: boolean, weights?: NDArray): [NDArray, NDArray];
2964
+ /**
2965
+ * Compute the bi-dimensional histogram of two data samples.
2966
+ *
2967
+ * @param x - Array of x coordinates
2968
+ * @param y - Array of y coordinates (must have same length as x)
2969
+ * @param bins - Number of bins or [nx, ny] or [x_edges, y_edges]
2970
+ * @param range - [[xmin, xmax], [ymin, ymax]]
2971
+ * @param density - If true, return probability density function
2972
+ * @param weights - Optional weights for each data point
2973
+ * @returns Tuple of [hist, x_edges, y_edges]
2974
+ */
2975
+ 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];
2976
+ /**
2977
+ * Compute the multidimensional histogram of some data.
2978
+ *
2979
+ * @param sample - Array of shape (N, D) where N is number of samples and D is number of dimensions
2980
+ * @param bins - Number of bins for all axes, or array of bin counts per axis
2981
+ * @param range - Array of [min, max] for each dimension
2982
+ * @param density - If true, return probability density function
2983
+ * @param weights - Optional weights for each sample
2984
+ * @returns Tuple of [hist, edges (array of edge arrays)]
2985
+ */
2986
+ export declare function histogramdd(sample: NDArray, bins?: number | number[], range?: [number, number][], density?: boolean, weights?: NDArray): [NDArray, NDArray[]];
2987
+ /**
2988
+ * Cross-correlation of two 1-dimensional sequences.
2989
+ *
2990
+ * @param a - First input sequence
2991
+ * @param v - Second input sequence
2992
+ * @param mode - 'full', 'same', or 'valid' (default: 'full')
2993
+ * @returns Cross-correlation of a and v
2994
+ */
2995
+ export declare function correlate(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
2996
+ /**
2997
+ * Discrete, linear convolution of two one-dimensional sequences.
2998
+ *
2999
+ * @param a - First input sequence
3000
+ * @param v - Second input sequence
3001
+ * @param mode - 'full', 'same', or 'valid' (default: 'full')
3002
+ * @returns Convolution of a and v
3003
+ */
3004
+ export declare function convolve(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
3005
+ /**
3006
+ * Estimate a covariance matrix.
3007
+ *
3008
+ * @param m - Input array (1D or 2D). Each row represents a variable, columns are observations.
3009
+ * @param y - Optional second array (for 2 variable case)
3010
+ * @param rowvar - If true, each row is a variable (default: true)
3011
+ * @param bias - If true, use N for normalization; if false, use N-1 (default: false)
3012
+ * @param ddof - Delta degrees of freedom (overrides bias if provided)
3013
+ * @returns Covariance matrix
3014
+ */
3015
+ export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: boolean, ddof?: number): NDArray;
3016
+ /**
3017
+ * Return Pearson product-moment correlation coefficients.
3018
+ *
3019
+ * @param x - Input array (1D or 2D)
3020
+ * @param y - Optional second array (for 2 variable case)
3021
+ * @param rowvar - If true, each row is a variable (default: true)
3022
+ * @returns Correlation coefficient matrix
3023
+ */
3024
+ export declare function corrcoef(x: NDArray, y?: NDArray, rowvar?: boolean): NDArray;
2138
3025
  //# sourceMappingURL=ndarray.d.ts.map