numpy-ts 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -692,6 +692,22 @@ export declare class NDArray {
692
692
  * @returns Maximum of array elements ignoring NaNs
693
693
  */
694
694
  nanmax(axis?: number, keepdims?: boolean): NDArray | number | Complex;
695
+ /**
696
+ * Compute the q-th quantile of the data along the specified axis, ignoring NaNs
697
+ * @param q - Quantile to compute (0-1)
698
+ * @param axis - Axis along which to compute quantile. If undefined, compute over all elements.
699
+ * @param keepdims - If true, reduced axes are left as dimensions with size 1
700
+ * @returns Quantile of array elements ignoring NaNs
701
+ */
702
+ nanquantile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
703
+ /**
704
+ * Compute the q-th percentile of the data along the specified axis, ignoring NaNs
705
+ * @param q - Percentile to compute (0-100)
706
+ * @param axis - Axis along which to compute percentile. If undefined, compute over all elements.
707
+ * @param keepdims - If true, reduced axes are left as dimensions with size 1
708
+ * @returns Percentile of array elements ignoring NaNs
709
+ */
710
+ nanpercentile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
695
711
  /**
696
712
  * Return the indices of the minimum values, ignoring NaNs
697
713
  * @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
@@ -1006,6 +1022,30 @@ export declare class NDArray {
1006
1022
  * @returns Nested JavaScript array representation
1007
1023
  */
1008
1024
  toArray(): any;
1025
+ /**
1026
+ * Return the array as a nested list (same as toArray)
1027
+ */
1028
+ tolist(): any;
1029
+ /**
1030
+ * Return the raw bytes of the array data
1031
+ */
1032
+ tobytes(): ArrayBuffer;
1033
+ /**
1034
+ * Copy an element of an array to a standard scalar and return it
1035
+ */
1036
+ item(...args: number[]): number | bigint | Complex;
1037
+ /**
1038
+ * Swap the bytes of the array elements
1039
+ */
1040
+ byteswap(inplace?: boolean): NDArray;
1041
+ /**
1042
+ * Return a view of the array with a different dtype
1043
+ */
1044
+ view(dtype?: DType): NDArray;
1045
+ /**
1046
+ * Write array to a file (stub - use node.ts module for file operations)
1047
+ */
1048
+ tofile(_file: string, _sep?: string, _format?: string): void;
1009
1049
  }
1010
1050
  /**
1011
1051
  * Create array of zeros
@@ -1107,6 +1147,22 @@ export declare function identity(n: number, dtype?: DType): NDArray;
1107
1147
  * @returns NDArray representation of the input
1108
1148
  */
1109
1149
  export declare function asarray(a: NDArray | any, dtype?: DType): NDArray;
1150
+ /**
1151
+ * Convert input to an array, checking for NaN and Inf values.
1152
+ * @param a - Input data
1153
+ * @param dtype - Data type (optional)
1154
+ * @returns NDArray
1155
+ * @throws If array contains NaN or Inf values
1156
+ */
1157
+ export declare function asarray_chkfinite(a: NDArray | ArrayLike<number | bigint>, dtype?: DType): NDArray;
1158
+ /**
1159
+ * Return array satisfying requirements.
1160
+ * @param a - Input array
1161
+ * @param dtype - Data type (optional)
1162
+ * @param requirements - Requirements ('C', 'F', 'A', 'W', 'O', 'E') (optional)
1163
+ * @returns Array satisfying requirements
1164
+ */
1165
+ export declare function require(a: NDArray, dtype?: DType, requirements?: string | string[]): NDArray;
1110
1166
  /**
1111
1167
  * Create a deep copy of an array
1112
1168
  * @param a - Array to copy
@@ -1648,6 +1704,18 @@ export declare function hstack(arrays: NDArray[]): NDArray;
1648
1704
  * @returns Depth-stacked array
1649
1705
  */
1650
1706
  export declare function dstack(arrays: NDArray[]): NDArray;
1707
+ /**
1708
+ * Join a sequence of arrays along an existing axis (alias for concatenate)
1709
+ */
1710
+ export declare function concat(arrays: NDArray[], axis?: number): NDArray;
1711
+ /**
1712
+ * Split an array into a sequence of sub-arrays along an axis (inverse of stack)
1713
+ */
1714
+ export declare function unstack(a: NDArray, axis?: number): NDArray[];
1715
+ /**
1716
+ * Assemble an nd-array from nested lists of blocks
1717
+ */
1718
+ export declare function block(arrays: NDArray[]): NDArray;
1651
1719
  /**
1652
1720
  * Split array into multiple sub-arrays
1653
1721
  *
@@ -1706,6 +1774,38 @@ export declare function repeat(a: NDArray, repeats: number | number[], axis?: nu
1706
1774
  * @returns Flattened 1-D array (view if possible)
1707
1775
  */
1708
1776
  export declare function ravel(a: NDArray): NDArray;
1777
+ /**
1778
+ * Return a copy of the array collapsed into one dimension
1779
+ */
1780
+ export declare function flatten(a: NDArray): NDArray;
1781
+ /**
1782
+ * Fill the array with a scalar value (in-place)
1783
+ */
1784
+ export declare function fill(a: NDArray, value: number | bigint): void;
1785
+ /**
1786
+ * Copy an element of an array to a standard scalar and return it
1787
+ */
1788
+ export declare function item(a: NDArray, ...args: number[]): number | bigint | Complex;
1789
+ /**
1790
+ * Return the array as a nested list
1791
+ */
1792
+ export declare function tolist(a: NDArray): any;
1793
+ /**
1794
+ * Return the raw bytes of the array data
1795
+ */
1796
+ export declare function tobytes(a: NDArray): ArrayBuffer;
1797
+ /**
1798
+ * Swap the bytes of the array elements
1799
+ */
1800
+ export declare function byteswap(a: NDArray, inplace?: boolean): NDArray;
1801
+ /**
1802
+ * New view of array with the same data
1803
+ */
1804
+ export declare function view(a: NDArray, dtype?: DType): NDArray;
1805
+ /**
1806
+ * Write array to a file as text or binary
1807
+ */
1808
+ export declare function tofile(a: NDArray, file: string, sep?: string, format?: string): void;
1709
1809
  /**
1710
1810
  * Reshape array to new shape
1711
1811
  *
@@ -2162,6 +2262,14 @@ export declare function nancumprod(a: NDArray, axis?: number): NDArray;
2162
2262
  * @returns Median value(s)
2163
2263
  */
2164
2264
  export declare function nanmedian(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2265
+ /**
2266
+ * Compute the q-th quantile of data along specified axis, ignoring NaNs
2267
+ */
2268
+ export declare function nanquantile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2269
+ /**
2270
+ * Compute the q-th percentile of data along specified axis, ignoring NaNs
2271
+ */
2272
+ export declare function nanpercentile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2165
2273
  /**
2166
2274
  * Element-wise cube root
2167
2275
  *
@@ -2256,6 +2364,116 @@ export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
2256
2364
  * @returns Tuple of [fractional, integral] arrays
2257
2365
  */
2258
2366
  export declare function modf(x: NDArray): [NDArray, NDArray];
2367
+ /**
2368
+ * Clip (limit) the values in an array.
2369
+ *
2370
+ * Given an interval, values outside the interval are clipped to the interval edges.
2371
+ *
2372
+ * @param a - Input array
2373
+ * @param a_min - Minimum value (null to not clip minimum)
2374
+ * @param a_max - Maximum value (null to not clip maximum)
2375
+ * @returns Clipped array
2376
+ */
2377
+ export declare function clip(a: NDArray, a_min: NDArray | number | null, a_max: NDArray | number | null): NDArray;
2378
+ /**
2379
+ * Element-wise maximum of array elements.
2380
+ *
2381
+ * Compare two arrays and return a new array containing the element-wise maxima.
2382
+ * If one of the elements being compared is a NaN, then that element is returned.
2383
+ *
2384
+ * @param x1 - First input array
2385
+ * @param x2 - Second input array or scalar
2386
+ * @returns Element-wise maximum
2387
+ */
2388
+ export declare function maximum(x1: NDArray, x2: NDArray | number): NDArray;
2389
+ /**
2390
+ * Element-wise minimum of array elements.
2391
+ *
2392
+ * Compare two arrays and return a new array containing the element-wise minima.
2393
+ * If one of the elements being compared is a NaN, then that element is returned.
2394
+ *
2395
+ * @param x1 - First input array
2396
+ * @param x2 - Second input array or scalar
2397
+ * @returns Element-wise minimum
2398
+ */
2399
+ export declare function minimum(x1: NDArray, x2: NDArray | number): NDArray;
2400
+ /**
2401
+ * Element-wise maximum of array elements, ignoring NaNs.
2402
+ *
2403
+ * Compare two arrays and return a new array containing the element-wise maxima.
2404
+ * If one of the values being compared is a NaN, the other is returned.
2405
+ *
2406
+ * @param x1 - First input array
2407
+ * @param x2 - Second input array or scalar
2408
+ * @returns Element-wise maximum, NaN-aware
2409
+ */
2410
+ export declare function fmax(x1: NDArray, x2: NDArray | number): NDArray;
2411
+ /**
2412
+ * Element-wise minimum of array elements, ignoring NaNs.
2413
+ *
2414
+ * Compare two arrays and return a new array containing the element-wise minima.
2415
+ * If one of the values being compared is a NaN, the other is returned.
2416
+ *
2417
+ * @param x1 - First input array
2418
+ * @param x2 - Second input array or scalar
2419
+ * @returns Element-wise minimum, NaN-aware
2420
+ */
2421
+ export declare function fmin(x1: NDArray, x2: NDArray | number): NDArray;
2422
+ /**
2423
+ * Replace NaN with zero and Inf with large finite numbers.
2424
+ *
2425
+ * @param x - Input array
2426
+ * @param nan - Value to replace NaN (default: 0.0)
2427
+ * @param posinf - Value to replace positive infinity (default: largest finite)
2428
+ * @param neginf - Value to replace negative infinity (default: most negative finite)
2429
+ * @returns Array with replacements
2430
+ */
2431
+ export declare function nan_to_num(x: NDArray, nan?: number, posinf?: number, neginf?: number): NDArray;
2432
+ /**
2433
+ * One-dimensional linear interpolation.
2434
+ *
2435
+ * Returns the one-dimensional piecewise linear interpolant to a function
2436
+ * with given discrete data points (xp, fp), evaluated at x.
2437
+ *
2438
+ * @param x - The x-coordinates at which to evaluate the interpolated values
2439
+ * @param xp - The x-coordinates of the data points (must be increasing)
2440
+ * @param fp - The y-coordinates of the data points
2441
+ * @param left - Value for x < xp[0] (default: fp[0])
2442
+ * @param right - Value for x > xp[-1] (default: fp[-1])
2443
+ * @returns Interpolated values
2444
+ */
2445
+ export declare function interp(x: NDArray, xp: NDArray, fp: NDArray, left?: number, right?: number): NDArray;
2446
+ /**
2447
+ * Unwrap by changing deltas between values to 2*pi complement.
2448
+ *
2449
+ * Unwrap radian phase p by changing absolute jumps greater than
2450
+ * discont to their 2*pi complement along the given axis.
2451
+ *
2452
+ * @param p - Input array of phase angles in radians
2453
+ * @param discont - Maximum discontinuity between values (default: pi)
2454
+ * @param axis - Axis along which to unwrap (default: -1, last axis)
2455
+ * @param period - Size of the range over which the input wraps (default: 2*pi)
2456
+ * @returns Unwrapped array
2457
+ */
2458
+ export declare function unwrap(p: NDArray, discont?: number, axis?: number, period?: number): NDArray;
2459
+ /**
2460
+ * Return the normalized sinc function.
2461
+ *
2462
+ * sinc(x) = sin(pi*x) / (pi*x)
2463
+ *
2464
+ * The sinc function is 1 at x = 0, and sin(pi*x)/(pi*x) otherwise.
2465
+ *
2466
+ * @param x - Input array
2467
+ * @returns Array of sinc values
2468
+ */
2469
+ export declare function sinc(x: NDArray): NDArray;
2470
+ /**
2471
+ * Modified Bessel function of the first kind, order 0.
2472
+ *
2473
+ * @param x - Input array
2474
+ * @returns Array of I0 values
2475
+ */
2476
+ export declare function i0(x: NDArray): NDArray;
2259
2477
  /**
2260
2478
  * Bitwise AND element-wise
2261
2479
  *
@@ -2334,6 +2552,36 @@ export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | '
2334
2552
  * @returns Unpacked uint8 array of 0s and 1s
2335
2553
  */
2336
2554
  export declare function unpackbits(a: NDArray, axis?: number, count?: number, bitorder?: 'big' | 'little'): NDArray;
2555
+ /**
2556
+ * Count the number of 1-bits (population count) in each element.
2557
+ *
2558
+ * @param x - Input array (must be integer type)
2559
+ * @returns Array with population count for each element
2560
+ */
2561
+ export declare function bitwise_count(x: NDArray): NDArray;
2562
+ /**
2563
+ * Bitwise invert (alias for bitwise_not).
2564
+ *
2565
+ * @param x - Input array (must be integer type)
2566
+ * @returns Result with bitwise NOT values
2567
+ */
2568
+ export declare function bitwise_invert(x: NDArray): NDArray;
2569
+ /**
2570
+ * Bitwise left shift (alias for left_shift).
2571
+ *
2572
+ * @param x1 - Input array (must be integer type)
2573
+ * @param x2 - Shift amount (array or scalar)
2574
+ * @returns Result with left-shifted values
2575
+ */
2576
+ export declare function bitwise_left_shift(x1: NDArray, x2: NDArray | number): NDArray;
2577
+ /**
2578
+ * Bitwise right shift (alias for right_shift).
2579
+ *
2580
+ * @param x1 - Input array (must be integer type)
2581
+ * @param x2 - Shift amount (array or scalar)
2582
+ * @returns Result with right-shifted values
2583
+ */
2584
+ export declare function bitwise_right_shift(x1: NDArray, x2: NDArray | number): NDArray;
2337
2585
  /**
2338
2586
  * Logical AND element-wise
2339
2587
  *
@@ -2588,6 +2836,71 @@ export declare function promote_types(dtype1: DType, dtype2: DType): DType;
2588
2836
  * einsum('ii->', a)
2589
2837
  */
2590
2838
  export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint | Complex;
2839
+ /**
2840
+ * Return the dot product of two vectors (flattened).
2841
+ *
2842
+ * Unlike dot(), vdot flattens both inputs before computing the dot product.
2843
+ * For complex numbers, vdot uses the complex conjugate of the first argument.
2844
+ *
2845
+ * @param a - First input array (will be flattened)
2846
+ * @param b - Second input array (will be flattened)
2847
+ * @returns Scalar dot product
2848
+ */
2849
+ export declare function vdot(a: NDArray, b: NDArray): number | bigint | Complex;
2850
+ /**
2851
+ * Vector dot product along the last axis.
2852
+ *
2853
+ * Computes the dot product of vectors along the last axis of both inputs.
2854
+ * The last dimensions of a and b must match.
2855
+ *
2856
+ * @param a - First input array
2857
+ * @param b - Second input array
2858
+ * @param axis - Axis along which to compute (default: -1, meaning last axis)
2859
+ * @returns Result with last dimension removed
2860
+ */
2861
+ export declare function vecdot(a: NDArray, b: NDArray, axis?: number): NDArray | number | bigint | Complex;
2862
+ /**
2863
+ * Transpose the last two axes of an array.
2864
+ *
2865
+ * Equivalent to swapaxes(a, -2, -1) or transpose with axes that swap the last two.
2866
+ * For a 2D array, this is the same as transpose.
2867
+ *
2868
+ * @param a - Input array with at least 2 dimensions
2869
+ * @returns Array with last two axes transposed
2870
+ */
2871
+ export declare function matrix_transpose(a: NDArray): NDArray;
2872
+ /**
2873
+ * Permute the dimensions of an array.
2874
+ *
2875
+ * This is an alias for transpose to match the Array API standard.
2876
+ *
2877
+ * @param a - Input array
2878
+ * @param axes - Permutation of axes. If not specified, reverses the axes.
2879
+ * @returns Transposed array
2880
+ */
2881
+ export declare function permute_dims(a: NDArray, axes?: number[]): NDArray;
2882
+ /**
2883
+ * Matrix-vector multiplication.
2884
+ *
2885
+ * Computes the matrix-vector product over the last two axes of x1 and
2886
+ * the last axis of x2.
2887
+ *
2888
+ * @param x1 - First input array (matrix) with shape (..., M, N)
2889
+ * @param x2 - Second input array (vector) with shape (..., N)
2890
+ * @returns Result with shape (..., M)
2891
+ */
2892
+ export declare function matvec(x1: NDArray, x2: NDArray): NDArray;
2893
+ /**
2894
+ * Vector-matrix multiplication.
2895
+ *
2896
+ * Computes the vector-matrix product over the last axis of x1 and
2897
+ * the second-to-last axis of x2.
2898
+ *
2899
+ * @param x1 - First input array (vector) with shape (..., M)
2900
+ * @param x2 - Second input array (matrix) with shape (..., M, N)
2901
+ * @returns Result with shape (..., N)
2902
+ */
2903
+ export declare function vecmat(x1: NDArray, x2: NDArray): NDArray;
2591
2904
  /**
2592
2905
  * numpy.linalg module - Linear algebra functions
2593
2906
  */
@@ -2689,6 +3002,57 @@ export declare const linalg: {
2689
3002
  * Compute eigenvalues of a Hermitian matrix.
2690
3003
  */
2691
3004
  eigvalsh: (a: NDArray, UPLO?: "L" | "U") => NDArray;
3005
+ /**
3006
+ * Return specified diagonals.
3007
+ */
3008
+ diagonal: (a: NDArray, offset?: number, axis1?: number, axis2?: number) => NDArray;
3009
+ /**
3010
+ * Matrix multiplication.
3011
+ */
3012
+ matmul: (a: NDArray, b: NDArray) => NDArray;
3013
+ /**
3014
+ * Transpose the last two axes of an array.
3015
+ */
3016
+ matrix_transpose: (a: NDArray) => NDArray;
3017
+ /**
3018
+ * Compute the dot product of two or more arrays.
3019
+ */
3020
+ multi_dot: (arrays: NDArray[]) => NDArray;
3021
+ /**
3022
+ * Outer product of two vectors.
3023
+ */
3024
+ outer: (a: NDArray, b: NDArray) => NDArray;
3025
+ /**
3026
+ * Compute sign and (natural) logarithm of the determinant.
3027
+ */
3028
+ slogdet: (a: NDArray) => {
3029
+ sign: number;
3030
+ logabsdet: number;
3031
+ };
3032
+ /**
3033
+ * Compute singular values of a matrix.
3034
+ */
3035
+ svdvals: (a: NDArray) => NDArray;
3036
+ /**
3037
+ * Tensor dot product along specified axes.
3038
+ */
3039
+ tensordot: (a: NDArray, b: NDArray, axes?: number | [number[], number[]]) => NDArray | number | bigint | Complex;
3040
+ /**
3041
+ * Compute the tensor inverse.
3042
+ */
3043
+ tensorinv: (a: NDArray, ind?: number) => NDArray;
3044
+ /**
3045
+ * Solve the tensor equation a x = b for x.
3046
+ */
3047
+ tensorsolve: (a: NDArray, b: NDArray, axes?: number[] | null) => NDArray;
3048
+ /**
3049
+ * Sum along diagonals.
3050
+ */
3051
+ trace: (a: NDArray) => number | bigint | Complex;
3052
+ /**
3053
+ * Vector dot product.
3054
+ */
3055
+ vecdot: (a: NDArray, b: NDArray, axis?: number) => NDArray | number | bigint | Complex;
2692
3056
  };
2693
3057
  /**
2694
3058
  * Take values from the input array by matching 1d index and data slices along axis.
@@ -3037,6 +3401,55 @@ export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
3037
3401
  * @returns Sorted 1D array of unique values from both arrays
3038
3402
  */
3039
3403
  export declare function union1d(ar1: NDArray, ar2: NDArray): NDArray;
3404
+ /**
3405
+ * Trim leading and/or trailing zeros from a 1-D array.
3406
+ *
3407
+ * @param filt - Input 1-D array
3408
+ * @param trim - 'fb' to trim front and back, 'f' for front only, 'b' for back only (default: 'fb')
3409
+ * @returns Trimmed array
3410
+ */
3411
+ export declare function trim_zeros(filt: NDArray, trim?: 'f' | 'b' | 'fb'): NDArray;
3412
+ /**
3413
+ * Find the unique elements of an array, returning all optional outputs.
3414
+ *
3415
+ * @param x - Input array (flattened for uniqueness)
3416
+ * @returns Object with values, indices, inverse_indices, and counts (all as NDArray)
3417
+ */
3418
+ export declare function unique_all(x: NDArray): {
3419
+ values: NDArray;
3420
+ indices: NDArray;
3421
+ inverse_indices: NDArray;
3422
+ counts: NDArray;
3423
+ };
3424
+ /**
3425
+ * Find the unique elements of an array and their counts.
3426
+ *
3427
+ * @param x - Input array (flattened for uniqueness)
3428
+ * @returns Object with values and counts (both as NDArray)
3429
+ */
3430
+ export declare function unique_counts(x: NDArray): {
3431
+ values: NDArray;
3432
+ counts: NDArray;
3433
+ };
3434
+ /**
3435
+ * Find the unique elements of an array and their inverse indices.
3436
+ *
3437
+ * @param x - Input array (flattened for uniqueness)
3438
+ * @returns Object with values and inverse_indices (both as NDArray)
3439
+ */
3440
+ export declare function unique_inverse(x: NDArray): {
3441
+ values: NDArray;
3442
+ inverse_indices: NDArray;
3443
+ };
3444
+ /**
3445
+ * Find the unique elements of an array (values only).
3446
+ *
3447
+ * This is equivalent to unique(x) but with a clearer name for the Array API.
3448
+ *
3449
+ * @param x - Input array (flattened for uniqueness)
3450
+ * @returns Array of unique values, sorted
3451
+ */
3452
+ export declare function unique_values(x: NDArray): NDArray;
3040
3453
  /**
3041
3454
  * Calculate the n-th discrete difference along the given axis
3042
3455
  * @param a - Input array
@@ -3163,4 +3576,348 @@ export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: bo
3163
3576
  * @returns Correlation coefficient matrix
3164
3577
  */
3165
3578
  export declare function corrcoef(x: NDArray, y?: NDArray, rowvar?: boolean): NDArray;
3579
+ /**
3580
+ * Compute the edges of the bins for histogram.
3581
+ *
3582
+ * This function computes the bin edges without computing the histogram itself.
3583
+ *
3584
+ * @param a - Input data (flattened if not 1D)
3585
+ * @param bins - Number of bins (default: 10) or a string specifying the bin algorithm
3586
+ * @param range - Lower and upper range of bins. If not provided, uses [a.min(), a.max()]
3587
+ * @param weights - Optional weights for each data point (used for some algorithms)
3588
+ * @returns Array of bin edges (length = bins + 1)
3589
+ */
3590
+ export declare function histogram_bin_edges(a: NDArray, bins?: number | 'auto' | 'fd' | 'doane' | 'scott' | 'stone' | 'rice' | 'sturges' | 'sqrt', range?: [number, number], weights?: NDArray): NDArray;
3591
+ /**
3592
+ * Integrate along the given axis using the composite trapezoidal rule.
3593
+ *
3594
+ * @param y - Input array to integrate
3595
+ * @param x - Optional sample points corresponding to y values. If not provided, spacing is assumed to be 1.
3596
+ * @param dx - Spacing between sample points when x is not given (default: 1.0)
3597
+ * @param axis - The axis along which to integrate (default: -1, meaning last axis)
3598
+ * @returns Definite integral approximated using the composite trapezoidal rule
3599
+ */
3600
+ export declare function trapezoid(y: NDArray, x?: NDArray, dx?: number, axis?: number): NDArray | number;
3601
+ /**
3602
+ * Apply a function along a given axis.
3603
+ *
3604
+ * @param func1d - Function that takes a 1D array and returns a scalar or array
3605
+ * @param axis - Axis along which to apply the function
3606
+ * @param arr - Input array
3607
+ * @returns Result array
3608
+ */
3609
+ export declare function apply_along_axis(func1d: (arr: NDArray) => NDArray | number, axis: number, arr: NDArray): NDArray;
3610
+ /**
3611
+ * Apply a function over multiple axes.
3612
+ *
3613
+ * @param func - Function that operates on an array along an axis
3614
+ * @param a - Input array
3615
+ * @param axes - Axes over which to apply the function
3616
+ * @returns Result array
3617
+ */
3618
+ export declare function apply_over_axes(func: (a: NDArray, axis: number) => NDArray, a: NDArray, axes: number[]): NDArray;
3619
+ /**
3620
+ * Check if two arrays may share memory.
3621
+ *
3622
+ * @param a - First array
3623
+ * @param b - Second array
3624
+ * @returns True if arrays may share memory
3625
+ */
3626
+ export declare function may_share_memory(a: NDArray, b: NDArray): boolean;
3627
+ /**
3628
+ * Check if two arrays share memory.
3629
+ *
3630
+ * @param a - First array
3631
+ * @param b - Second array
3632
+ * @returns True if arrays share memory
3633
+ */
3634
+ export declare function shares_memory(a: NDArray, b: NDArray): boolean;
3635
+ /**
3636
+ * Return the number of dimensions of an array.
3637
+ *
3638
+ * @param a - Input array
3639
+ * @returns Number of dimensions
3640
+ */
3641
+ export declare function ndim(a: NDArray | number | unknown[] | unknown): number;
3642
+ /**
3643
+ * Return the shape of an array.
3644
+ *
3645
+ * @param a - Input array
3646
+ * @returns Shape tuple
3647
+ */
3648
+ export declare function shape(a: NDArray | number | unknown[] | unknown): number[];
3649
+ /**
3650
+ * Return the number of elements in an array.
3651
+ *
3652
+ * @param a - Input array
3653
+ * @returns Number of elements
3654
+ */
3655
+ export declare function size(a: NDArray | number | unknown[] | unknown): number;
3656
+ export { geterr, seterr, type FloatErrorState } from '../ops/advanced';
3657
+ /**
3658
+ * Casting rules for safe type conversion
3659
+ * In 'safe' mode: casting is allowed only if the value can be represented without loss
3660
+ * In 'same_kind': same kind of types allowed (e.g., float to float, int to int)
3661
+ * In 'unsafe': any conversion is allowed
3662
+ */
3663
+ type CastingRule = 'no' | 'equiv' | 'safe' | 'same_kind' | 'unsafe';
3664
+ /**
3665
+ * Returns true if cast between data types can occur according to the casting rule.
3666
+ *
3667
+ * @param from_dtype - Data type to cast from
3668
+ * @param to_dtype - Data type to cast to
3669
+ * @param casting - Casting rule: 'no', 'equiv', 'safe', 'same_kind', or 'unsafe'
3670
+ * @returns Whether the cast is allowed
3671
+ *
3672
+ * @example
3673
+ * ```typescript
3674
+ * can_cast('int32', 'float64') // true - safe upcast
3675
+ * can_cast('float64', 'int32') // false - would lose precision
3676
+ * can_cast('float64', 'int32', 'unsafe') // true - forced cast
3677
+ * ```
3678
+ */
3679
+ export declare function can_cast(from_dtype: DType | NDArray, to_dtype: DType, casting?: CastingRule): boolean;
3680
+ /**
3681
+ * Return a scalar type which is common to the input arrays.
3682
+ *
3683
+ * The return type will always be an inexact (floating point) type, even if
3684
+ * all the input arrays are integer types.
3685
+ *
3686
+ * @param arrays - Input arrays
3687
+ * @returns Common scalar type ('float32' or 'float64', or complex variants)
3688
+ *
3689
+ * @example
3690
+ * ```typescript
3691
+ * const a = array([1, 2], { dtype: 'int32' });
3692
+ * const b = array([3.0, 4.0], { dtype: 'float32' });
3693
+ * common_type(a, b) // 'float32'
3694
+ * ```
3695
+ */
3696
+ export declare function common_type(...arrays: NDArray[]): DType;
3697
+ /**
3698
+ * Returns the type that results from applying the NumPy type promotion rules
3699
+ * to the arguments.
3700
+ *
3701
+ * @param arrays_and_dtypes - A mix of arrays or dtype strings
3702
+ * @returns The result dtype
3703
+ *
3704
+ * @example
3705
+ * ```typescript
3706
+ * result_type('int32', 'float32') // 'float64'
3707
+ * result_type(array([1, 2], { dtype: 'int8' }), 'float32') // 'float32'
3708
+ * ```
3709
+ */
3710
+ export declare function result_type(...arrays_and_dtypes: (NDArray | DType)[]): DType;
3711
+ /**
3712
+ * For scalar val, returns the data type with the smallest size and smallest
3713
+ * scalar kind which can hold its value.
3714
+ *
3715
+ * @param val - Scalar value
3716
+ * @returns Minimum dtype to represent the value
3717
+ *
3718
+ * @example
3719
+ * ```typescript
3720
+ * min_scalar_type(10) // 'uint8'
3721
+ * min_scalar_type(1000) // 'uint16'
3722
+ * min_scalar_type(-1) // 'int8'
3723
+ * min_scalar_type(3.14) // 'float64'
3724
+ * ```
3725
+ */
3726
+ export declare function min_scalar_type(val: number | bigint | boolean): DType;
3727
+ /**
3728
+ * Returns true if first argument is a typecode lower/equal in type hierarchy.
3729
+ *
3730
+ * In NumPy, issubdtype checks if dtype1 is a subtype of dtype2.
3731
+ * For specific types (not categories), types are only subtypes of themselves.
3732
+ *
3733
+ * @param dtype1 - First dtype to check
3734
+ * @param dtype2 - Second dtype (or type category string)
3735
+ * @returns Whether dtype1 is a subtype of dtype2
3736
+ *
3737
+ * @example
3738
+ * ```typescript
3739
+ * issubdtype('int32', 'int32') // true - same type
3740
+ * issubdtype('int32', 'int64') // false - different types
3741
+ * issubdtype('int32', 'integer') // true - int32 is an integer type
3742
+ * issubdtype('float32', 'floating') // true - float32 is a floating type
3743
+ * ```
3744
+ */
3745
+ export declare function issubdtype(dtype1: DType | NDArray, dtype2: DType | string): boolean;
3746
+ /**
3747
+ * Return a description for the given data type code.
3748
+ *
3749
+ * @param dtype - Data type to describe
3750
+ * @returns Human-readable description
3751
+ *
3752
+ * @example
3753
+ * ```typescript
3754
+ * typename('float64') // 'float64'
3755
+ * typename('int32') // 'int32'
3756
+ * ```
3757
+ */
3758
+ export declare function typename(dtype: DType): string;
3759
+ /**
3760
+ * Return the character for the minimum-size type to which given types can be
3761
+ * safely cast.
3762
+ *
3763
+ * @param typechars - String of type characters
3764
+ * @param typeset - Which set of types to consider: 'GDFgdf' (default)
3765
+ * @param default_dtype - Default type if no valid types found
3766
+ * @returns Type character for minimum safe type
3767
+ *
3768
+ * @example
3769
+ * ```typescript
3770
+ * mintypecode('if') // 'd' (float64)
3771
+ * mintypecode('ff') // 'f' (float32)
3772
+ * ```
3773
+ */
3774
+ export declare function mintypecode(typechars: string, typeset?: string, default_dtype?: string): string;
3775
+ /**
3776
+ * Find the coefficients of a polynomial with the given sequence of roots.
3777
+ *
3778
+ * Returns the coefficients of the polynomial whose leading coefficient is one
3779
+ * for the given sequence of zeros (multiple roots must be included in the
3780
+ * sequence as many times as their multiplicity).
3781
+ *
3782
+ * @param seq_of_zeros - Sequence of polynomial roots
3783
+ * @returns Array of polynomial coefficients, highest power first
3784
+ *
3785
+ * @example
3786
+ * ```typescript
3787
+ * poly([1, 2, 3]) // array([1, -6, 11, -6]) = (x-1)(x-2)(x-3)
3788
+ * poly([0, 0, 0]) // array([1, 0, 0, 0]) = x^3
3789
+ * ```
3790
+ */
3791
+ export declare function poly(seq_of_zeros: NDArray | number[]): NDArray;
3792
+ /**
3793
+ * Find the sum of two polynomials.
3794
+ *
3795
+ * @param a1 - First polynomial coefficients (highest power first)
3796
+ * @param a2 - Second polynomial coefficients (highest power first)
3797
+ * @returns Sum polynomial coefficients
3798
+ *
3799
+ * @example
3800
+ * ```typescript
3801
+ * polyadd([1, 2], [3, 4, 5]) // array([3, 5, 7])
3802
+ * ```
3803
+ */
3804
+ export declare function polyadd(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
3805
+ /**
3806
+ * Return the derivative of the specified order of a polynomial.
3807
+ *
3808
+ * @param p - Polynomial coefficients (highest power first)
3809
+ * @param m - Order of the derivative (default: 1)
3810
+ * @returns Derivative polynomial coefficients
3811
+ *
3812
+ * @example
3813
+ * ```typescript
3814
+ * polyder([3, 2, 1]) // array([6, 2]) - derivative of 3x^2 + 2x + 1
3815
+ * polyder([4, 3, 2, 1], 2) // array([24, 6]) - second derivative
3816
+ * ```
3817
+ */
3818
+ export declare function polyder(p: NDArray | number[], m?: number): NDArray;
3819
+ /**
3820
+ * Returns the quotient and remainder of polynomial division.
3821
+ *
3822
+ * @param u - Dividend polynomial coefficients (highest power first)
3823
+ * @param v - Divisor polynomial coefficients (highest power first)
3824
+ * @returns Tuple [quotient, remainder]
3825
+ *
3826
+ * @example
3827
+ * ```typescript
3828
+ * polydiv([1, -3, 2], [1, -1]) // [array([1, -2]), array([0])]
3829
+ * // (x^2 - 3x + 2) / (x - 1) = (x - 2) with remainder 0
3830
+ * ```
3831
+ */
3832
+ export declare function polydiv(u: NDArray | number[], v: NDArray | number[]): [NDArray, NDArray];
3833
+ /**
3834
+ * Least squares polynomial fit.
3835
+ *
3836
+ * Fit a polynomial p(x) = p[0] * x^deg + ... + p[deg] of degree deg to points (x, y).
3837
+ *
3838
+ * @param x - x-coordinates of the sample points
3839
+ * @param y - y-coordinates of the sample points
3840
+ * @param deg - Degree of the fitting polynomial
3841
+ * @returns Polynomial coefficients, highest power first
3842
+ *
3843
+ * @example
3844
+ * ```typescript
3845
+ * const x = array([0, 1, 2, 3, 4]);
3846
+ * const y = array([0, 1, 4, 9, 16]);
3847
+ * polyfit(x, y, 2) // approximately array([1, 0, 0]) for y = x^2
3848
+ * ```
3849
+ */
3850
+ export declare function polyfit(x: NDArray, y: NDArray, deg: number): NDArray;
3851
+ /**
3852
+ * Return an antiderivative (indefinite integral) of a polynomial.
3853
+ *
3854
+ * @param p - Polynomial coefficients (highest power first)
3855
+ * @param m - Order of the antiderivative (default: 1)
3856
+ * @param k - Integration constants (default: 0)
3857
+ * @returns Antiderivative polynomial coefficients
3858
+ *
3859
+ * @example
3860
+ * ```typescript
3861
+ * polyint([3, 2, 1]) // array([1, 1, 1, 0]) - integral of 3x^2 + 2x + 1
3862
+ * polyint([6, 2], 1, 5) // array([2, 1, 5]) - with constant 5
3863
+ * ```
3864
+ */
3865
+ export declare function polyint(p: NDArray | number[], m?: number, k?: number | number[]): NDArray;
3866
+ /**
3867
+ * Find the product of two polynomials.
3868
+ *
3869
+ * @param a1 - First polynomial coefficients (highest power first)
3870
+ * @param a2 - Second polynomial coefficients (highest power first)
3871
+ * @returns Product polynomial coefficients
3872
+ *
3873
+ * @example
3874
+ * ```typescript
3875
+ * polymul([1, 2], [1, 3]) // array([1, 5, 6]) = (x+2)(x+3)
3876
+ * ```
3877
+ */
3878
+ export declare function polymul(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
3879
+ /**
3880
+ * Difference (subtraction) of two polynomials.
3881
+ *
3882
+ * @param a1 - First polynomial coefficients (highest power first)
3883
+ * @param a2 - Second polynomial coefficients (highest power first)
3884
+ * @returns Difference polynomial coefficients
3885
+ *
3886
+ * @example
3887
+ * ```typescript
3888
+ * polysub([1, 2, 3], [0, 1, 1]) // array([1, 1, 2])
3889
+ * ```
3890
+ */
3891
+ export declare function polysub(a1: NDArray | number[], a2: NDArray | number[]): NDArray;
3892
+ /**
3893
+ * Evaluate a polynomial at specific values.
3894
+ *
3895
+ * @param p - Polynomial coefficients (highest power first)
3896
+ * @param x - Values at which to evaluate the polynomial
3897
+ * @returns Polynomial values at x
3898
+ *
3899
+ * @example
3900
+ * ```typescript
3901
+ * polyval([1, -2, 1], 3) // 4 = 3^2 - 2*3 + 1
3902
+ * polyval([1, 0, 0], array([1, 2, 3])) // array([1, 4, 9])
3903
+ * ```
3904
+ */
3905
+ export declare function polyval(p: NDArray | number[], x: NDArray | number | number[]): NDArray | number;
3906
+ /**
3907
+ * Return the roots of a polynomial with coefficients given in p.
3908
+ *
3909
+ * The values in the rank-1 array p are coefficients of a polynomial.
3910
+ * If the length of p is n+1 then the polynomial is:
3911
+ * p[0]*x^n + p[1]*x^(n-1) + ... + p[n-1]*x + p[n]
3912
+ *
3913
+ * @param p - Polynomial coefficients (highest power first)
3914
+ * @returns Array of roots (may be complex, returned as numbers for real roots)
3915
+ *
3916
+ * @example
3917
+ * ```typescript
3918
+ * roots([1, -3, 2]) // array([2, 1]) - roots of x^2 - 3x + 2
3919
+ * roots([1, 0, -1]) // array([1, -1]) - roots of x^2 - 1
3920
+ * ```
3921
+ */
3922
+ export declare function roots(p: NDArray | number[]): NDArray;
3166
3923
  //# sourceMappingURL=ndarray.d.ts.map