numpy-ts 0.9.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)
@@ -421,6 +444,71 @@ export declare class NDArray {
421
444
  * @returns Result of right shift
422
445
  */
423
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;
424
512
  /**
425
513
  * Sum array elements over a given axis
426
514
  * @param axis - Axis along which to sum. If undefined, sum all elements
@@ -662,6 +750,12 @@ export declare class NDArray {
662
750
  * @returns Tuple of arrays, one for each dimension
663
751
  */
664
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;
665
759
  /**
666
760
  * Find indices where elements should be inserted to maintain order
667
761
  * @param v - Values to insert
@@ -1131,6 +1225,7 @@ export declare function sqrt(x: NDArray): NDArray;
1131
1225
  * @returns Array of x raised to exponent
1132
1226
  */
1133
1227
  export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
1228
+ export { power as pow };
1134
1229
  /**
1135
1230
  * Element-wise natural exponential (e^x)
1136
1231
  * @param x - Input array
@@ -1197,6 +1292,7 @@ export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
1197
1292
  * @returns Array of absolute values
1198
1293
  */
1199
1294
  export declare function absolute(x: NDArray): NDArray;
1295
+ export { absolute as abs };
1200
1296
  /**
1201
1297
  * Element-wise negation
1202
1298
  * @param x - Input array
@@ -1216,6 +1312,14 @@ export declare function sign(x: NDArray): NDArray;
1216
1312
  * @returns Remainder after division
1217
1313
  */
1218
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 };
1219
1323
  /**
1220
1324
  * Element-wise floor division
1221
1325
  * @param x - Dividend array
@@ -1341,18 +1445,21 @@ export declare function tan(x: NDArray): NDArray;
1341
1445
  * @returns Array of angles in radians
1342
1446
  */
1343
1447
  export declare function arcsin(x: NDArray): NDArray;
1448
+ export { arcsin as asin };
1344
1449
  /**
1345
1450
  * Element-wise inverse cosine
1346
1451
  * @param x - Input array (values in range [-1, 1])
1347
1452
  * @returns Array of angles in radians
1348
1453
  */
1349
1454
  export declare function arccos(x: NDArray): NDArray;
1455
+ export { arccos as acos };
1350
1456
  /**
1351
1457
  * Element-wise inverse tangent
1352
1458
  * @param x - Input array
1353
1459
  * @returns Array of angles in radians
1354
1460
  */
1355
1461
  export declare function arctan(x: NDArray): NDArray;
1462
+ export { arctan as atan };
1356
1463
  /**
1357
1464
  * Element-wise arc tangent of x1/x2 choosing the quadrant correctly
1358
1465
  * @param x1 - y-coordinates
@@ -1360,6 +1467,7 @@ export declare function arctan(x: NDArray): NDArray;
1360
1467
  * @returns Angles in radians between -π and π
1361
1468
  */
1362
1469
  export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
1470
+ export { arctan2 as atan2 };
1363
1471
  /**
1364
1472
  * Given the "legs" of a right triangle, return its hypotenuse
1365
1473
  * Equivalent to sqrt(x1**2 + x2**2), element-wise
@@ -1416,18 +1524,21 @@ export declare function tanh(x: NDArray): NDArray;
1416
1524
  * @returns Array of arcsinh values
1417
1525
  */
1418
1526
  export declare function arcsinh(x: NDArray): NDArray;
1527
+ export { arcsinh as asinh };
1419
1528
  /**
1420
1529
  * Element-wise inverse hyperbolic cosine
1421
1530
  * @param x - Input array (values >= 1)
1422
1531
  * @returns Array of arccosh values
1423
1532
  */
1424
1533
  export declare function arccosh(x: NDArray): NDArray;
1534
+ export { arccosh as acosh };
1425
1535
  /**
1426
1536
  * Element-wise inverse hyperbolic tangent
1427
1537
  * @param x - Input array (values in range (-1, 1))
1428
1538
  * @returns Array of arctanh values
1429
1539
  */
1430
1540
  export declare function arctanh(x: NDArray): NDArray;
1541
+ export { arctanh as atanh };
1431
1542
  /**
1432
1543
  * Swap two axes of an array
1433
1544
  *
@@ -1746,6 +1857,22 @@ export declare function take(a: NDArray, indices: number[], axis?: number): NDAr
1746
1857
  * @param values - Values to put
1747
1858
  */
1748
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;
1749
1876
  /**
1750
1877
  * Construct array from index array and choices
1751
1878
  *
@@ -1779,6 +1906,7 @@ export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
1779
1906
  * @returns Array with cumulative sums
1780
1907
  */
1781
1908
  export declare function cumsum(a: NDArray, axis?: number): NDArray;
1909
+ export { cumsum as cumulative_sum };
1782
1910
  /**
1783
1911
  * Return the cumulative product of the elements along a given axis.
1784
1912
  * @param a - Input array
@@ -1786,6 +1914,25 @@ export declare function cumsum(a: NDArray, axis?: number): NDArray;
1786
1914
  * @returns Array with cumulative products
1787
1915
  */
1788
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 };
1789
1936
  /**
1790
1937
  * Peak to peak (maximum - minimum) value along a given axis.
1791
1938
  * @param a - Input array
@@ -1968,6 +2115,55 @@ export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
1968
2115
  * @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
1969
2116
  */
1970
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];
1971
2167
  /**
1972
2168
  * Bitwise AND element-wise
1973
2169
  *
@@ -2046,6 +2242,189 @@ export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | '
2046
2242
  * @returns Unpacked uint8 array of 0s and 1s
2047
2243
  */
2048
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;
2049
2428
  /**
2050
2429
  * Einstein summation convention
2051
2430
  *
@@ -2222,6 +2601,13 @@ export declare function select(condlist: NDArray[], choicelist: NDArray[], defau
2222
2601
  * @param vals - Values to place where mask is True (cycles if shorter)
2223
2602
  */
2224
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;
2225
2611
  /**
2226
2612
  * Return the indices to access the main diagonal of an array.
2227
2613
  *
@@ -2364,6 +2750,14 @@ export declare function sort_complex(a: NDArray): NDArray;
2364
2750
  * @returns Tuple of arrays, one for each dimension
2365
2751
  */
2366
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;
2367
2761
  /**
2368
2762
  * Return indices of non-zero elements in flattened array
2369
2763
  * @param a - Input array
@@ -2408,6 +2802,7 @@ export declare function count_nonzero(a: NDArray, axis?: number): NDArray | numb
2408
2802
  * @returns Rounded array
2409
2803
  */
2410
2804
  export declare function around(a: NDArray, decimals?: number): NDArray;
2805
+ export { around as round_ };
2411
2806
  /**
2412
2807
  * Return the ceiling of the input, element-wise
2413
2808
  * @param x - Input array
@@ -2537,4 +2932,94 @@ export declare function gradient(f: NDArray, varargs?: number | number[], axis?:
2537
2932
  * @returns Cross product array
2538
2933
  */
2539
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;
2540
3025
  //# sourceMappingURL=ndarray.d.ts.map
@@ -3,7 +3,46 @@
3
3
  *
4
4
  * @module numpy-ts
5
5
  */
6
- export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, asanyarray, ascontiguousarray, asfortranarray, diag, diagflat, frombuffer, fromfile, fromfunction, fromiter, fromstring, meshgrid, tri, tril, triu, vander, sqrt, power, exp, exp2, expm1, log, log2, log10, log1p, logaddexp, logaddexp2, absolute, negative, sign, mod, floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, linalg, sin, cos, tan, arcsin, arccos, arctan, arctan2, hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, arccosh, arctanh, swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, split, array_split, vsplit, hsplit, tile, repeat, ravel, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumprod, ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, flatnonzero, where, searchsorted, extract, count_nonzero, around, ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, diff, ediff1d, gradient, cross, } from './core/ndarray';
6
+ export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, asanyarray, ascontiguousarray, asfortranarray, diag, diagflat, frombuffer, fromfile, fromfunction, fromiter, fromstring, meshgrid, tri, tril, triu, vander, sqrt, power, pow, // alias for power
7
+ exp, exp2, expm1, log, log2, log10, log1p, logaddexp, logaddexp2, absolute, abs, // alias for absolute
8
+ negative, sign, mod, divide, true_divide, // alias for divide
9
+ floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, float_power, fmod, frexp, gcd, lcm, ldexp, modf, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, linalg, sin, cos, tan, arcsin, asin, // alias for arcsin
10
+ arccos, acos, // alias for arccos
11
+ arctan, atan, // alias for arctan
12
+ arctan2, atan2, // alias for arctan2
13
+ hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, asinh, // alias for arcsinh
14
+ arccosh, acosh, // alias for arccosh
15
+ arctanh, atanh, // alias for arctanh
16
+ swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, split, array_split, vsplit, hsplit, tile, repeat, ravel, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, copyto, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, fill_diagonal, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumulative_sum, // alias for cumsum
17
+ cumprod, cumulative_prod, // alias for cumprod
18
+ max, amax, // alias for max
19
+ min, amin, // alias for min
20
+ ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, logical_and, logical_or, logical_not, logical_xor, isfinite, isinf, isnan, isnat, iscomplex, iscomplexobj, isreal, isrealobj, isneginf, isposinf, isfortran, real_if_close, isscalar, iterable, isdtype, promote_types, copysign, signbit, nextafter, spacing, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, argwhere, flatnonzero, where, searchsorted, extract, count_nonzero, around, round_, // alias for around
21
+ ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, diff, ediff1d, gradient, cross, bincount, digitize, histogram, histogram2d, histogramdd, correlate, convolve, cov, corrcoef, } from './core/ndarray';
7
22
  export { parseNpy, serializeNpy, parseNpyHeader, parseNpyData, UnsupportedDTypeError, InvalidNpyError, SUPPORTED_DTYPES, DTYPE_TO_DESCR, type NpyHeader, type NpyMetadata, type NpyVersion, parseNpz, parseNpzSync, loadNpz, loadNpzSync, serializeNpz, serializeNpzSync, type NpzParseOptions, type NpzParseResult, type NpzSerializeOptions, } from './io';
23
+ import * as randomOps from './ops/random';
24
+ import { ArrayStorage } from './core/storage';
25
+ import { NDArray as NDArrayClass } from './core/ndarray';
26
+ import { DType } from './core/dtype';
27
+ export declare const random: {
28
+ seed: typeof randomOps.seed;
29
+ random: (size?: number | number[]) => number | ArrayStorage | NDArrayClass;
30
+ rand: (...shape: number[]) => number | ArrayStorage | NDArrayClass;
31
+ randn: (...shape: number[]) => number | ArrayStorage | NDArrayClass;
32
+ randint: (low: number, high?: number | null, size?: number | number[], dtype?: DType) => number | ArrayStorage | NDArrayClass;
33
+ uniform: (low?: number, high?: number, size?: number | number[]) => number | ArrayStorage | NDArrayClass;
34
+ normal: (loc?: number, scale?: number, size?: number | number[]) => number | ArrayStorage | NDArrayClass;
35
+ standard_normal: (size?: number | number[]) => number | ArrayStorage | NDArrayClass;
36
+ exponential: (scale?: number, size?: number | number[]) => number | ArrayStorage | NDArrayClass;
37
+ poisson: (lam?: number, size?: number | number[]) => number | ArrayStorage | NDArrayClass;
38
+ binomial: (n: number, p: number, size?: number | number[]) => number | ArrayStorage | NDArrayClass;
39
+ choice: (a: number | ArrayStorage, size?: number | number[], replace?: boolean, p?: ArrayStorage | number[]) => number | ArrayStorage | NDArrayClass;
40
+ permutation: (x: number | ArrayStorage) => ArrayStorage | NDArrayClass;
41
+ shuffle: typeof randomOps.shuffle;
42
+ get_state: typeof randomOps.get_state;
43
+ set_state: typeof randomOps.set_state;
44
+ default_rng: typeof randomOps.default_rng;
45
+ Generator: typeof randomOps.Generator;
46
+ };
8
47
  export declare const __version__: string;
9
48
  //# sourceMappingURL=index.d.ts.map
@@ -105,4 +105,11 @@ export declare function ravel_multi_index(multi_index: ArrayStorage[], dims: num
105
105
  * Convert flat index array to tuple of coordinate arrays
106
106
  */
107
107
  export declare function unravel_index(indices: ArrayStorage | number, shape: number[], order?: 'C' | 'F'): ArrayStorage[];
108
+ /**
109
+ * Fill the main diagonal of a given array (modifies in-place)
110
+ * @param a - Array storage (at least 2D)
111
+ * @param val - Value or array of values to fill diagonal with
112
+ * @param wrap - Whether to wrap for tall matrices
113
+ */
114
+ export declare function fill_diagonal(a: ArrayStorage, val: ArrayStorage | number, wrap?: boolean): void;
108
115
  //# sourceMappingURL=advanced.d.ts.map