numpy-ts 0.12.0 → 0.13.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.
Files changed (144) hide show
  1. package/README.md +18 -14
  2. package/dist/esm/common/broadcasting.js +1 -0
  3. package/dist/esm/common/complex.js +1 -0
  4. package/dist/esm/common/dtype.js +1 -0
  5. package/dist/esm/common/internal/compute.js +1 -0
  6. package/dist/esm/common/internal/indexing.js +1 -0
  7. package/dist/esm/common/ndarray-core.js +1 -0
  8. package/dist/esm/common/ops/advanced.js +1 -0
  9. package/dist/esm/common/ops/arithmetic.js +1 -0
  10. package/dist/esm/common/ops/bitwise.js +1 -0
  11. package/dist/esm/common/ops/comparison.js +1 -0
  12. package/dist/esm/common/ops/complex.js +1 -0
  13. package/dist/esm/common/ops/exponential.js +1 -0
  14. package/dist/esm/common/ops/fft.js +1 -0
  15. package/dist/esm/common/ops/formatting.js +2 -0
  16. package/dist/esm/common/ops/gradient.js +1 -0
  17. package/dist/esm/common/ops/hyperbolic.js +1 -0
  18. package/dist/esm/common/ops/linalg.js +2 -0
  19. package/dist/esm/common/ops/logic.js +1 -0
  20. package/dist/esm/common/ops/random.js +1 -0
  21. package/dist/esm/common/ops/reduction.js +1 -0
  22. package/dist/esm/common/ops/rounding.js +1 -0
  23. package/dist/esm/common/ops/sets.js +1 -0
  24. package/dist/esm/common/ops/shape.js +1 -0
  25. package/dist/esm/common/ops/sorting.js +1 -0
  26. package/dist/esm/common/ops/statistics.js +1 -0
  27. package/dist/esm/common/ops/trig.js +1 -0
  28. package/dist/esm/common/slicing.js +1 -0
  29. package/dist/esm/common/storage.js +1 -0
  30. package/dist/esm/core/advanced.js +1 -0
  31. package/dist/esm/core/arithmetic.js +1 -0
  32. package/dist/esm/core/bitwise.js +1 -0
  33. package/dist/esm/core/complex.js +1 -0
  34. package/dist/esm/core/creation.js +1 -0
  35. package/dist/esm/core/formatting.js +1 -0
  36. package/dist/esm/core/gradient.js +1 -0
  37. package/dist/esm/core/index.js +1 -0
  38. package/dist/esm/core/linalg.js +1 -0
  39. package/dist/esm/core/logic.js +1 -0
  40. package/dist/esm/core/polynomial.js +1 -0
  41. package/dist/esm/core/reduction.js +1 -0
  42. package/dist/esm/core/rounding.js +1 -0
  43. package/dist/esm/core/sets.js +1 -0
  44. package/dist/esm/core/shape-extra.js +1 -0
  45. package/dist/esm/core/shape.js +1 -0
  46. package/dist/esm/core/sorting.js +1 -0
  47. package/dist/esm/core/statistics.js +1 -0
  48. package/dist/esm/core/trig.js +1 -0
  49. package/dist/esm/core/typechecking.js +1 -0
  50. package/dist/esm/core/types.js +1 -0
  51. package/dist/esm/core/utility.js +1 -0
  52. package/dist/esm/core.js +1 -0
  53. package/dist/esm/full/index.js +1 -0
  54. package/dist/esm/full/ndarray.js +1 -0
  55. package/dist/esm/index.js +1 -0
  56. package/dist/esm/io/index.js +1 -0
  57. package/dist/esm/io/npy/format.js +1 -0
  58. package/dist/esm/io/npy/index.js +1 -0
  59. package/dist/esm/io/npy/parser.js +1 -0
  60. package/dist/esm/io/npy/serializer.js +2 -0
  61. package/dist/esm/io/npz/index.js +1 -0
  62. package/dist/esm/io/npz/parser.js +1 -0
  63. package/dist/esm/io/npz/serializer.js +1 -0
  64. package/dist/esm/io/txt/index.js +1 -0
  65. package/dist/esm/io/txt/parser.js +1 -0
  66. package/dist/esm/io/txt/serializer.js +2 -0
  67. package/dist/esm/io/zip/index.js +1 -0
  68. package/dist/esm/io/zip/reader.js +1 -0
  69. package/dist/esm/io/zip/types.js +1 -0
  70. package/dist/esm/io/zip/writer.js +1 -0
  71. package/dist/esm/node.js +1 -0
  72. package/dist/numpy-ts.browser.js +5 -2
  73. package/dist/numpy-ts.node-io.cjs +5 -3
  74. package/dist/numpy-ts.node-io.cjs.map +4 -4
  75. package/dist/numpy-ts.node-io.mjs +5 -3
  76. package/dist/numpy-ts.node-io.mjs.map +4 -4
  77. package/dist/numpy-ts.node.cjs +5 -2
  78. package/dist/numpy-ts.node.cjs.map +4 -4
  79. package/dist/types/common/complex.d.ts +94 -0
  80. package/dist/types/{internal → common/internal}/compute.d.ts +1 -1
  81. package/dist/types/{internal → common/internal}/indexing.d.ts +6 -0
  82. package/dist/types/common/ndarray-core.d.ts +126 -0
  83. package/dist/types/{ops → common/ops}/advanced.d.ts +2 -2
  84. package/dist/types/{ops → common/ops}/arithmetic.d.ts +1 -1
  85. package/dist/types/{ops → common/ops}/bitwise.d.ts +1 -1
  86. package/dist/types/{ops → common/ops}/comparison.d.ts +1 -1
  87. package/dist/types/{ops → common/ops}/complex.d.ts +1 -1
  88. package/dist/types/{ops → common/ops}/exponential.d.ts +1 -1
  89. package/dist/types/common/ops/fft.d.ts +166 -0
  90. package/dist/types/common/ops/formatting.d.ts +229 -0
  91. package/dist/types/{ops → common/ops}/gradient.d.ts +1 -1
  92. package/dist/types/{ops → common/ops}/hyperbolic.d.ts +1 -1
  93. package/dist/types/{ops → common/ops}/linalg.d.ts +24 -3
  94. package/dist/types/{ops → common/ops}/logic.d.ts +2 -2
  95. package/dist/types/common/ops/random.d.ts +376 -0
  96. package/dist/types/{ops → common/ops}/reduction.d.ts +2 -2
  97. package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
  98. package/dist/types/{ops → common/ops}/sets.d.ts +1 -1
  99. package/dist/types/{ops → common/ops}/shape.d.ts +1 -1
  100. package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
  101. package/dist/types/{ops → common/ops}/statistics.d.ts +1 -1
  102. package/dist/types/{ops → common/ops}/trig.d.ts +1 -1
  103. package/dist/types/{core → common}/storage.d.ts +1 -0
  104. package/dist/types/core/advanced.d.ts +54 -0
  105. package/dist/types/core/arithmetic.d.ts +110 -0
  106. package/dist/types/core/bitwise.d.ts +34 -0
  107. package/dist/types/core/complex.d.ts +15 -90
  108. package/dist/types/core/creation.d.ts +98 -0
  109. package/dist/types/core/formatting.d.ts +29 -0
  110. package/dist/types/core/gradient.d.ts +14 -0
  111. package/dist/types/core/index.d.ts +40 -0
  112. package/dist/types/core/linalg.d.ts +141 -0
  113. package/dist/types/core/logic.d.ts +72 -0
  114. package/dist/types/core/polynomial.d.ts +50 -0
  115. package/dist/types/core/reduction.d.ts +82 -0
  116. package/dist/types/core/rounding.d.ts +24 -0
  117. package/dist/types/core/sets.d.ts +48 -0
  118. package/dist/types/core/shape-extra.d.ts +24 -0
  119. package/dist/types/core/shape.d.ts +77 -0
  120. package/dist/types/core/sorting.d.ts +34 -0
  121. package/dist/types/core/statistics.d.ts +32 -0
  122. package/dist/types/core/trig.d.ts +58 -0
  123. package/dist/types/core/typechecking.d.ts +50 -0
  124. package/dist/types/core/types.d.ts +43 -0
  125. package/dist/types/core/utility.d.ts +30 -0
  126. package/dist/types/core.d.ts +30 -0
  127. package/dist/types/full/index.d.ts +603 -0
  128. package/dist/types/full/ndarray.d.ts +880 -0
  129. package/dist/types/index.d.ts +140 -26
  130. package/dist/types/io/npy/format.d.ts +1 -1
  131. package/dist/types/io/npy/parser.d.ts +3 -3
  132. package/dist/types/io/npy/serializer.d.ts +2 -2
  133. package/dist/types/io/npz/parser.d.ts +4 -4
  134. package/dist/types/io/npz/serializer.d.ts +6 -6
  135. package/dist/types/io/txt/parser.d.ts +5 -5
  136. package/dist/types/io/txt/serializer.d.ts +2 -2
  137. package/dist/types/node.d.ts +12 -8
  138. package/package.json +30 -29
  139. package/dist/numpy-ts.esm.js +0 -2
  140. package/dist/types/core/ndarray.d.ts +0 -3923
  141. package/dist/types/ops/random.d.ts +0 -136
  142. /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
  143. /package/dist/types/{core → common}/dtype.d.ts +0 -0
  144. /package/dist/types/{core → common}/slicing.d.ts +0 -0
@@ -1,3923 +0,0 @@
1
- /**
2
- * NDArray - NumPy-compatible multidimensional array
3
- *
4
- * Core array class providing NumPy-like API
5
- */
6
- import { type DType, type TypedArray } from './dtype';
7
- import { Complex } from './complex';
8
- import { ArrayStorage } from './storage';
9
- export declare class NDArray {
10
- private _storage;
11
- private _base?;
12
- constructor(storage: ArrayStorage, base?: NDArray);
13
- /**
14
- * Get internal storage (for ops modules)
15
- * @internal
16
- */
17
- get storage(): ArrayStorage;
18
- /**
19
- * Create NDArray from storage (for ops modules)
20
- * @internal
21
- */
22
- static _fromStorage(storage: ArrayStorage, base?: NDArray): NDArray;
23
- get shape(): readonly number[];
24
- get ndim(): number;
25
- get size(): number;
26
- get dtype(): string;
27
- get data(): TypedArray;
28
- get strides(): readonly number[];
29
- /**
30
- * Array flags (similar to NumPy's flags)
31
- * Provides information about memory layout
32
- */
33
- get flags(): {
34
- C_CONTIGUOUS: boolean;
35
- F_CONTIGUOUS: boolean;
36
- OWNDATA: boolean;
37
- };
38
- /**
39
- * Base array if this is a view, null if this array owns its data
40
- * Similar to NumPy's base attribute
41
- */
42
- get base(): NDArray | null;
43
- /**
44
- * Transpose of the array (shorthand for transpose())
45
- * Returns a view with axes reversed
46
- */
47
- get T(): NDArray;
48
- /**
49
- * Size of one array element in bytes
50
- */
51
- get itemsize(): number;
52
- /**
53
- * Total bytes consumed by the elements of the array
54
- */
55
- get nbytes(): number;
56
- /**
57
- * Fill the array with a scalar value (in-place)
58
- * @param value - Value to fill with
59
- */
60
- fill(value: number | bigint): void;
61
- /**
62
- * Iterator protocol - iterate over the first axis
63
- * For 1D arrays, yields elements; for ND arrays, yields (N-1)D subarrays
64
- */
65
- [Symbol.iterator](): Iterator<NDArray | number | bigint | Complex>;
66
- /**
67
- * Get a single element from the array
68
- * @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
69
- * @returns The element value (BigInt for int64/uint64, Complex for complex, number otherwise)
70
- */
71
- get(indices: number[]): number | bigint | Complex;
72
- /**
73
- * Set a single element in the array
74
- * @param indices - Array of indices, one per dimension (e.g., [0, 1] for 2D array)
75
- * @param value - Value to set (will be converted to array's dtype)
76
- */
77
- set(indices: number[], value: number | bigint | Complex | {
78
- re: number;
79
- im: number;
80
- }): void;
81
- /**
82
- * Return a deep copy of the array
83
- */
84
- copy(): NDArray;
85
- /**
86
- * Cast array to a different dtype
87
- * @param dtype - Target dtype
88
- * @param copy - If false and dtype matches, return self; otherwise create copy (default: true)
89
- * @returns Array with specified dtype
90
- */
91
- astype(dtype: DType, copy?: boolean): NDArray;
92
- /**
93
- * Element-wise addition
94
- * @param other - Array or scalar to add
95
- * @returns Result of addition with broadcasting
96
- */
97
- add(other: NDArray | number): NDArray;
98
- /**
99
- * Element-wise subtraction
100
- * @param other - Array or scalar to subtract
101
- * @returns Result of subtraction with broadcasting
102
- */
103
- subtract(other: NDArray | number): NDArray;
104
- /**
105
- * Element-wise multiplication
106
- * @param other - Array or scalar to multiply
107
- * @returns Result of multiplication with broadcasting
108
- */
109
- multiply(other: NDArray | number): NDArray;
110
- /**
111
- * Element-wise division
112
- * @param other - Array or scalar to divide by
113
- * @returns Result of division with broadcasting
114
- */
115
- divide(other: NDArray | number): NDArray;
116
- /**
117
- * Element-wise modulo operation
118
- * @param other - Array or scalar divisor
119
- * @returns Remainder after division
120
- */
121
- mod(other: NDArray | number): NDArray;
122
- /**
123
- * Element-wise floor division
124
- * @param other - Array or scalar to divide by
125
- * @returns Floor of the quotient
126
- */
127
- floor_divide(other: NDArray | number): NDArray;
128
- /**
129
- * Numerical positive (element-wise +x)
130
- * @returns Copy of the array
131
- */
132
- positive(): NDArray;
133
- /**
134
- * Element-wise reciprocal (1/x)
135
- * @returns New array with reciprocals
136
- */
137
- reciprocal(): NDArray;
138
- /**
139
- * Square root of each element
140
- * Promotes integer types to float64
141
- * @returns New array with square roots
142
- */
143
- sqrt(): NDArray;
144
- /**
145
- * Raise elements to power
146
- * @param exponent - Power to raise to (array or scalar)
147
- * @returns New array with powered values
148
- */
149
- power(exponent: NDArray | number): NDArray;
150
- /**
151
- * Natural exponential (e^x) of each element
152
- * Promotes integer types to float64
153
- * @returns New array with exp values
154
- */
155
- exp(): NDArray;
156
- /**
157
- * Base-2 exponential (2^x) of each element
158
- * Promotes integer types to float64
159
- * @returns New array with exp2 values
160
- */
161
- exp2(): NDArray;
162
- /**
163
- * Exponential minus one (e^x - 1) of each element
164
- * More accurate than exp(x) - 1 for small x
165
- * Promotes integer types to float64
166
- * @returns New array with expm1 values
167
- */
168
- expm1(): NDArray;
169
- /**
170
- * Natural logarithm (ln) of each element
171
- * Promotes integer types to float64
172
- * @returns New array with log values
173
- */
174
- log(): NDArray;
175
- /**
176
- * Base-2 logarithm of each element
177
- * Promotes integer types to float64
178
- * @returns New array with log2 values
179
- */
180
- log2(): NDArray;
181
- /**
182
- * Base-10 logarithm of each element
183
- * Promotes integer types to float64
184
- * @returns New array with log10 values
185
- */
186
- log10(): NDArray;
187
- /**
188
- * Natural logarithm of (1 + x) of each element
189
- * More accurate than log(1 + x) for small x
190
- * Promotes integer types to float64
191
- * @returns New array with log1p values
192
- */
193
- log1p(): NDArray;
194
- /**
195
- * Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
196
- * More numerically stable than computing the expression directly
197
- * Promotes integer types to float64
198
- * @param x2 - Second operand (array or scalar)
199
- * @returns New array with logaddexp values
200
- */
201
- logaddexp(x2: NDArray | number): NDArray;
202
- /**
203
- * Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
204
- * More numerically stable than computing the expression directly
205
- * Promotes integer types to float64
206
- * @param x2 - Second operand (array or scalar)
207
- * @returns New array with logaddexp2 values
208
- */
209
- logaddexp2(x2: NDArray | number): NDArray;
210
- /**
211
- * Absolute value of each element
212
- * @returns New array with absolute values
213
- */
214
- absolute(): NDArray;
215
- /**
216
- * Numerical negative (element-wise negation)
217
- * @returns New array with negated values
218
- */
219
- negative(): NDArray;
220
- /**
221
- * Sign of each element (-1, 0, or 1)
222
- * @returns New array with signs
223
- */
224
- sign(): NDArray;
225
- /**
226
- * Round an array to the given number of decimals
227
- * @param decimals - Number of decimal places to round to (default: 0)
228
- * @returns New array with rounded values
229
- */
230
- around(decimals?: number): NDArray;
231
- /**
232
- * Round an array to the given number of decimals (alias for around)
233
- * @param decimals - Number of decimal places to round to (default: 0)
234
- * @returns New array with rounded values
235
- */
236
- round(decimals?: number): NDArray;
237
- /**
238
- * Return the ceiling of the input, element-wise
239
- * @returns New array with ceiling values
240
- */
241
- ceil(): NDArray;
242
- /**
243
- * Round to nearest integer towards zero
244
- * @returns New array with values truncated towards zero
245
- */
246
- fix(): NDArray;
247
- /**
248
- * Return the floor of the input, element-wise
249
- * @returns New array with floor values
250
- */
251
- floor(): NDArray;
252
- /**
253
- * Round elements to the nearest integer
254
- * @returns New array with rounded integer values
255
- */
256
- rint(): NDArray;
257
- /**
258
- * Return the truncated value of the input, element-wise
259
- * @returns New array with truncated values
260
- */
261
- trunc(): NDArray;
262
- /**
263
- * Sine of each element (in radians)
264
- * Promotes integer types to float64
265
- * @returns New array with sine values
266
- */
267
- sin(): NDArray;
268
- /**
269
- * Cosine of each element (in radians)
270
- * Promotes integer types to float64
271
- * @returns New array with cosine values
272
- */
273
- cos(): NDArray;
274
- /**
275
- * Tangent of each element (in radians)
276
- * Promotes integer types to float64
277
- * @returns New array with tangent values
278
- */
279
- tan(): NDArray;
280
- /**
281
- * Inverse sine of each element
282
- * Promotes integer types to float64
283
- * @returns New array with arcsin values (radians)
284
- */
285
- arcsin(): NDArray;
286
- /**
287
- * Inverse cosine of each element
288
- * Promotes integer types to float64
289
- * @returns New array with arccos values (radians)
290
- */
291
- arccos(): NDArray;
292
- /**
293
- * Inverse tangent of each element
294
- * Promotes integer types to float64
295
- * @returns New array with arctan values (radians)
296
- */
297
- arctan(): NDArray;
298
- /**
299
- * Element-wise arc tangent of this/other choosing the quadrant correctly
300
- * @param other - x-coordinates (array or scalar)
301
- * @returns Angle in radians between -π and π
302
- */
303
- arctan2(other: NDArray | number): NDArray;
304
- /**
305
- * Given the "legs" of a right triangle, return its hypotenuse
306
- * Equivalent to sqrt(this**2 + other**2), element-wise
307
- * @param other - Second leg (array or scalar)
308
- * @returns Hypotenuse values
309
- */
310
- hypot(other: NDArray | number): NDArray;
311
- /**
312
- * Convert angles from radians to degrees
313
- * @returns New array with angles in degrees
314
- */
315
- degrees(): NDArray;
316
- /**
317
- * Convert angles from degrees to radians
318
- * @returns New array with angles in radians
319
- */
320
- radians(): NDArray;
321
- /**
322
- * Hyperbolic sine of each element
323
- * Promotes integer types to float64
324
- * @returns New array with sinh values
325
- */
326
- sinh(): NDArray;
327
- /**
328
- * Hyperbolic cosine of each element
329
- * Promotes integer types to float64
330
- * @returns New array with cosh values
331
- */
332
- cosh(): NDArray;
333
- /**
334
- * Hyperbolic tangent of each element
335
- * Promotes integer types to float64
336
- * @returns New array with tanh values
337
- */
338
- tanh(): NDArray;
339
- /**
340
- * Inverse hyperbolic sine of each element
341
- * Promotes integer types to float64
342
- * @returns New array with arcsinh values
343
- */
344
- arcsinh(): NDArray;
345
- /**
346
- * Inverse hyperbolic cosine of each element
347
- * Promotes integer types to float64
348
- * @returns New array with arccosh values
349
- */
350
- arccosh(): NDArray;
351
- /**
352
- * Inverse hyperbolic tangent of each element
353
- * Promotes integer types to float64
354
- * @returns New array with arctanh values
355
- */
356
- arctanh(): NDArray;
357
- /**
358
- * Element-wise greater than comparison
359
- * @param other - Value or array to compare with
360
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
361
- */
362
- greater(other: NDArray | number): NDArray;
363
- /**
364
- * Element-wise greater than or equal comparison
365
- * @param other - Value or array to compare with
366
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
367
- */
368
- greater_equal(other: NDArray | number): NDArray;
369
- /**
370
- * Element-wise less than comparison
371
- * @param other - Value or array to compare with
372
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
373
- */
374
- less(other: NDArray | number): NDArray;
375
- /**
376
- * Element-wise less than or equal comparison
377
- * @param other - Value or array to compare with
378
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
379
- */
380
- less_equal(other: NDArray | number): NDArray;
381
- /**
382
- * Element-wise equality comparison
383
- * @param other - Value or array to compare with
384
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
385
- */
386
- equal(other: NDArray | number): NDArray;
387
- /**
388
- * Element-wise not equal comparison
389
- * @param other - Value or array to compare with
390
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
391
- */
392
- not_equal(other: NDArray | number): NDArray;
393
- /**
394
- * Element-wise comparison with tolerance
395
- * Returns True where |a - b| <= (atol + rtol * |b|)
396
- * @param other - Value or array to compare with
397
- * @param rtol - Relative tolerance (default: 1e-5)
398
- * @param atol - Absolute tolerance (default: 1e-8)
399
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
400
- */
401
- isclose(other: NDArray | number, rtol?: number, atol?: number): NDArray;
402
- /**
403
- * Element-wise comparison with tolerance
404
- * Returns True where |a - b| <= (atol + rtol * |b|)
405
- * @param other - Value or array to compare with
406
- * @param rtol - Relative tolerance (default: 1e-5)
407
- * @param atol - Absolute tolerance (default: 1e-8)
408
- * @returns Boolean array (represented as uint8: 1=true, 0=false)
409
- */
410
- allclose(other: NDArray | number, rtol?: number, atol?: number): boolean;
411
- /**
412
- * Bitwise AND element-wise
413
- * @param other - Array or scalar for AND operation (must be integer type)
414
- * @returns Result of bitwise AND
415
- */
416
- bitwise_and(other: NDArray | number): NDArray;
417
- /**
418
- * Bitwise OR element-wise
419
- * @param other - Array or scalar for OR operation (must be integer type)
420
- * @returns Result of bitwise OR
421
- */
422
- bitwise_or(other: NDArray | number): NDArray;
423
- /**
424
- * Bitwise XOR element-wise
425
- * @param other - Array or scalar for XOR operation (must be integer type)
426
- * @returns Result of bitwise XOR
427
- */
428
- bitwise_xor(other: NDArray | number): NDArray;
429
- /**
430
- * Bitwise NOT (inversion) element-wise
431
- * @returns Result of bitwise NOT
432
- */
433
- bitwise_not(): NDArray;
434
- /**
435
- * Invert (bitwise NOT) element-wise - alias for bitwise_not
436
- * @returns Result of bitwise inversion
437
- */
438
- invert(): NDArray;
439
- /**
440
- * Left shift elements by positions
441
- * @param shift - Shift amount (array or scalar)
442
- * @returns Result of left shift
443
- */
444
- left_shift(shift: NDArray | number): NDArray;
445
- /**
446
- * Right shift elements by positions
447
- * @param shift - Shift amount (array or scalar)
448
- * @returns Result of right shift
449
- */
450
- right_shift(shift: NDArray | number): NDArray;
451
- /**
452
- * Logical AND element-wise
453
- * @param other - Array or scalar for AND operation
454
- * @returns Boolean array (1 = true, 0 = false)
455
- */
456
- logical_and(other: NDArray | number): NDArray;
457
- /**
458
- * Logical OR element-wise
459
- * @param other - Array or scalar for OR operation
460
- * @returns Boolean array (1 = true, 0 = false)
461
- */
462
- logical_or(other: NDArray | number): NDArray;
463
- /**
464
- * Logical NOT element-wise
465
- * @returns Boolean array (1 = true, 0 = false)
466
- */
467
- logical_not(): NDArray;
468
- /**
469
- * Logical XOR element-wise
470
- * @param other - Array or scalar for XOR operation
471
- * @returns Boolean array (1 = true, 0 = false)
472
- */
473
- logical_xor(other: NDArray | number): NDArray;
474
- /**
475
- * Test element-wise for finiteness (not infinity and not NaN)
476
- * @returns Boolean array
477
- */
478
- isfinite(): NDArray;
479
- /**
480
- * Test element-wise for positive or negative infinity
481
- * @returns Boolean array
482
- */
483
- isinf(): NDArray;
484
- /**
485
- * Test element-wise for NaN (Not a Number)
486
- * @returns Boolean array
487
- */
488
- isnan(): NDArray;
489
- /**
490
- * Test element-wise for NaT (Not a Time)
491
- * @returns Boolean array (always false without datetime support)
492
- */
493
- isnat(): NDArray;
494
- /**
495
- * Change the sign of x1 to that of x2, element-wise
496
- * @param x2 - Values whose sign is used
497
- * @returns Array with magnitude from this and sign from x2
498
- */
499
- copysign(x2: NDArray | number): NDArray;
500
- /**
501
- * Returns element-wise True where signbit is set (less than zero)
502
- * @returns Boolean array
503
- */
504
- signbit(): NDArray;
505
- /**
506
- * Return the next floating-point value after x1 towards x2, element-wise
507
- * @param x2 - Direction to look for the next representable value
508
- * @returns Array of next representable values
509
- */
510
- nextafter(x2: NDArray | number): NDArray;
511
- /**
512
- * Return the distance between x and the nearest adjacent number
513
- * @returns Array of spacing values
514
- */
515
- spacing(): NDArray;
516
- /**
517
- * Sum array elements over a given axis
518
- * @param axis - Axis along which to sum. If undefined, sum all elements
519
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
520
- * @returns Sum of array elements, or array of sums along axis
521
- */
522
- sum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
523
- /**
524
- * Compute the arithmetic mean along the specified axis
525
- * @param axis - Axis along which to compute mean. If undefined, compute mean of all elements
526
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
527
- * @returns Mean of array elements, or array of means along axis
528
- *
529
- * Note: mean() returns float64 for integer dtypes, matching NumPy behavior
530
- */
531
- mean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
532
- /**
533
- * Return the maximum along a given axis
534
- * @param axis - Axis along which to compute maximum. If undefined, compute maximum of all elements
535
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
536
- * @returns Maximum of array elements, or array of maximums along axis
537
- */
538
- max(axis?: number, keepdims?: boolean): NDArray | number | Complex;
539
- /**
540
- * Return the minimum along a given axis
541
- * @param axis - Axis along which to compute minimum. If undefined, compute minimum of all elements
542
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
543
- * @returns Minimum of array elements, or array of minimums along axis
544
- */
545
- min(axis?: number, keepdims?: boolean): NDArray | number | Complex;
546
- /**
547
- * Product of array elements over a given axis
548
- * @param axis - Axis along which to compute the product. If undefined, product of all elements.
549
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
550
- * @returns Product of array elements, or array of products along axis
551
- */
552
- prod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
553
- /**
554
- * Indices of the minimum values along an axis
555
- * @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
556
- * @returns Indices of minimum values
557
- */
558
- argmin(axis?: number): NDArray | number;
559
- /**
560
- * Indices of the maximum values along an axis
561
- * @param axis - Axis along which to find maximum indices. If undefined, index of global maximum.
562
- * @returns Indices of maximum values
563
- */
564
- argmax(axis?: number): NDArray | number;
565
- /**
566
- * Compute variance along the specified axis
567
- * @param axis - Axis along which to compute variance. If undefined, variance of all elements.
568
- * @param ddof - Delta degrees of freedom (default: 0)
569
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
570
- * @returns Variance of array elements
571
- */
572
- var(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
573
- /**
574
- * Compute standard deviation along the specified axis
575
- * @param axis - Axis along which to compute std. If undefined, std of all elements.
576
- * @param ddof - Delta degrees of freedom (default: 0)
577
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
578
- * @returns Standard deviation of array elements
579
- */
580
- std(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
581
- /**
582
- * Test whether all array elements along a given axis evaluate to True
583
- * @param axis - Axis along which to perform logical AND. If undefined, test all elements.
584
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
585
- * @returns Boolean or array of booleans
586
- */
587
- all(axis?: number, keepdims?: boolean): NDArray | boolean;
588
- /**
589
- * Test whether any array elements along a given axis evaluate to True
590
- * @param axis - Axis along which to perform logical OR. If undefined, test all elements.
591
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
592
- * @returns Boolean or array of booleans
593
- */
594
- any(axis?: number, keepdims?: boolean): NDArray | boolean;
595
- /**
596
- * Return the cumulative sum of elements along a given axis
597
- * @param axis - Axis along which to compute cumsum. If undefined, compute over flattened array.
598
- * @returns Array with cumulative sums
599
- */
600
- cumsum(axis?: number): NDArray;
601
- /**
602
- * Return the cumulative product of elements along a given axis
603
- * @param axis - Axis along which to compute cumprod. If undefined, compute over flattened array.
604
- * @returns Array with cumulative products
605
- */
606
- cumprod(axis?: number): NDArray;
607
- /**
608
- * Peak to peak (maximum - minimum) value along a given axis
609
- * @param axis - Axis along which to compute ptp. If undefined, compute over all elements.
610
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
611
- * @returns Range of values
612
- */
613
- ptp(axis?: number, keepdims?: boolean): NDArray | number | Complex;
614
- /**
615
- * Compute the median along the specified axis
616
- * @param axis - Axis along which to compute median. If undefined, compute over all elements.
617
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
618
- * @returns Median of array elements
619
- */
620
- median(axis?: number, keepdims?: boolean): NDArray | number;
621
- /**
622
- * Compute the q-th percentile of the data along the specified axis
623
- * @param q - Percentile to compute (0-100)
624
- * @param axis - Axis along which to compute percentile. If undefined, compute over all elements.
625
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
626
- * @returns Percentile of array elements
627
- */
628
- percentile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
629
- /**
630
- * Compute the q-th quantile of the data along the specified axis
631
- * @param q - Quantile to compute (0-1)
632
- * @param axis - Axis along which to compute quantile. If undefined, compute over all elements.
633
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
634
- * @returns Quantile of array elements
635
- */
636
- quantile(q: number, axis?: number, keepdims?: boolean): NDArray | number;
637
- /**
638
- * Compute the weighted average along the specified axis
639
- * @param weights - Array of weights (optional)
640
- * @param axis - Axis along which to compute average. If undefined, compute over all elements.
641
- * @returns Weighted average of array elements
642
- */
643
- average(weights?: NDArray, axis?: number): NDArray | number | Complex;
644
- /**
645
- * Return the sum of array elements, treating NaNs as zero
646
- * @param axis - Axis along which to compute sum. If undefined, compute over all elements.
647
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
648
- * @returns Sum of array elements ignoring NaNs
649
- */
650
- nansum(axis?: number, keepdims?: boolean): NDArray | number | Complex;
651
- /**
652
- * Return the product of array elements, treating NaNs as ones
653
- * @param axis - Axis along which to compute product. If undefined, compute over all elements.
654
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
655
- * @returns Product of array elements ignoring NaNs
656
- */
657
- nanprod(axis?: number, keepdims?: boolean): NDArray | number | Complex;
658
- /**
659
- * Compute the arithmetic mean, ignoring NaNs
660
- * @param axis - Axis along which to compute mean. If undefined, compute over all elements.
661
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
662
- * @returns Mean of array elements ignoring NaNs
663
- */
664
- nanmean(axis?: number, keepdims?: boolean): NDArray | number | Complex;
665
- /**
666
- * Compute the variance, ignoring NaNs
667
- * @param axis - Axis along which to compute variance. If undefined, compute over all elements.
668
- * @param ddof - Delta degrees of freedom (default: 0)
669
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
670
- * @returns Variance of array elements ignoring NaNs
671
- */
672
- nanvar(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
673
- /**
674
- * Compute the standard deviation, ignoring NaNs
675
- * @param axis - Axis along which to compute std. If undefined, compute over all elements.
676
- * @param ddof - Delta degrees of freedom (default: 0)
677
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
678
- * @returns Standard deviation of array elements ignoring NaNs
679
- */
680
- nanstd(axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
681
- /**
682
- * Return minimum of an array or minimum along an axis, ignoring NaNs
683
- * @param axis - Axis along which to compute minimum. If undefined, compute over all elements.
684
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
685
- * @returns Minimum of array elements ignoring NaNs
686
- */
687
- nanmin(axis?: number, keepdims?: boolean): NDArray | number | Complex;
688
- /**
689
- * Return maximum of an array or maximum along an axis, ignoring NaNs
690
- * @param axis - Axis along which to compute maximum. If undefined, compute over all elements.
691
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
692
- * @returns Maximum of array elements ignoring NaNs
693
- */
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;
711
- /**
712
- * Return the indices of the minimum values, ignoring NaNs
713
- * @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
714
- * @returns Indices of minimum values ignoring NaNs
715
- */
716
- nanargmin(axis?: number): NDArray | number;
717
- /**
718
- * Return the indices of the maximum values, ignoring NaNs
719
- * @param axis - Axis along which to find maximum indices. If undefined, index of global maximum.
720
- * @returns Indices of maximum values ignoring NaNs
721
- */
722
- nanargmax(axis?: number): NDArray | number;
723
- /**
724
- * Return the cumulative sum of elements, treating NaNs as zero
725
- * @param axis - Axis along which to compute cumsum. If undefined, compute over flattened array.
726
- * @returns Array with cumulative sums ignoring NaNs
727
- */
728
- nancumsum(axis?: number): NDArray;
729
- /**
730
- * Return the cumulative product of elements, treating NaNs as one
731
- * @param axis - Axis along which to compute cumprod. If undefined, compute over flattened array.
732
- * @returns Array with cumulative products ignoring NaNs
733
- */
734
- nancumprod(axis?: number): NDArray;
735
- /**
736
- * Compute the median, ignoring NaNs
737
- * @param axis - Axis along which to compute median. If undefined, compute over all elements.
738
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
739
- * @returns Median of array elements ignoring NaNs
740
- */
741
- nanmedian(axis?: number, keepdims?: boolean): NDArray | number;
742
- /**
743
- * Return a sorted copy of the array
744
- * @param axis - Axis along which to sort. Default is -1 (last axis)
745
- * @returns Sorted array
746
- */
747
- sort(axis?: number): NDArray;
748
- /**
749
- * Returns the indices that would sort this array
750
- * @param axis - Axis along which to sort. Default is -1 (last axis)
751
- * @returns Array of indices that sort the array
752
- */
753
- argsort(axis?: number): NDArray;
754
- /**
755
- * Partially sort the array
756
- * @param kth - Element index to partition by
757
- * @param axis - Axis along which to sort. Default is -1 (last axis)
758
- * @returns Partitioned array
759
- */
760
- partition(kth: number, axis?: number): NDArray;
761
- /**
762
- * Returns indices that would partition the array
763
- * @param kth - Element index to partition by
764
- * @param axis - Axis along which to sort. Default is -1 (last axis)
765
- * @returns Array of indices
766
- */
767
- argpartition(kth: number, axis?: number): NDArray;
768
- /**
769
- * Return the indices of non-zero elements
770
- * @returns Tuple of arrays, one for each dimension
771
- */
772
- nonzero(): NDArray[];
773
- /**
774
- * Find the indices of array elements that are non-zero, grouped by element
775
- * Returns a 2D array where each row is the index of a non-zero element.
776
- * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
777
- */
778
- argwhere(): NDArray;
779
- /**
780
- * Find indices where elements should be inserted to maintain order
781
- * @param v - Values to insert
782
- * @param side - 'left' or 'right' side to insert
783
- * @returns Indices where values should be inserted
784
- */
785
- searchsorted(v: NDArray, side?: 'left' | 'right'): NDArray;
786
- /**
787
- * Calculate the n-th discrete difference along the given axis
788
- * @param n - Number of times values are differenced (default: 1)
789
- * @param axis - Axis along which to compute difference (default: -1)
790
- * @returns Array of differences
791
- */
792
- diff(n?: number, axis?: number): NDArray;
793
- /**
794
- * Reshape array to a new shape
795
- * Returns a new array with the specified shape
796
- * @param shape - New shape (must be compatible with current size)
797
- * @returns Reshaped array
798
- */
799
- reshape(...shape: number[]): NDArray;
800
- /**
801
- * Return a flattened copy of the array
802
- * @returns 1D array containing all elements
803
- */
804
- flatten(): NDArray;
805
- /**
806
- * Return a flattened array (view when possible, otherwise copy)
807
- * @returns 1D array containing all elements
808
- */
809
- ravel(): NDArray;
810
- /**
811
- * Transpose array (permute dimensions)
812
- * @param axes - Permutation of axes. If undefined, reverse the dimensions
813
- * @returns Transposed array (always a view)
814
- */
815
- transpose(axes?: number[]): NDArray;
816
- /**
817
- * Remove axes of length 1
818
- * @param axis - Axis to squeeze. If undefined, squeeze all axes of length 1
819
- * @returns Array with specified dimensions removed (always a view)
820
- */
821
- squeeze(axis?: number): NDArray;
822
- /**
823
- * Expand the shape by inserting a new axis of length 1
824
- * @param axis - Position where new axis is placed
825
- * @returns Array with additional dimension (always a view)
826
- */
827
- expand_dims(axis: number): NDArray;
828
- /**
829
- * Swap two axes of an array
830
- * @param axis1 - First axis
831
- * @param axis2 - Second axis
832
- * @returns Array with swapped axes (always a view)
833
- */
834
- swapaxes(axis1: number, axis2: number): NDArray;
835
- /**
836
- * Move axes to new positions
837
- * @param source - Original positions of axes to move
838
- * @param destination - New positions for axes
839
- * @returns Array with moved axes (always a view)
840
- */
841
- moveaxis(source: number | number[], destination: number | number[]): NDArray;
842
- /**
843
- * Repeat elements of an array
844
- * @param repeats - Number of repetitions for each element
845
- * @param axis - Axis along which to repeat (if undefined, flattens first)
846
- * @returns New array with repeated elements
847
- */
848
- repeat(repeats: number | number[], axis?: number): NDArray;
849
- /**
850
- * Take elements from array along an axis
851
- * @param indices - Indices of elements to take
852
- * @param axis - Axis along which to take (if undefined, flattens first)
853
- * @returns New array with selected elements
854
- */
855
- take(indices: number[], axis?: number): NDArray;
856
- /**
857
- * Put values at specified indices (modifies array in-place)
858
- * @param indices - Indices at which to place values
859
- * @param values - Values to put
860
- */
861
- put(indices: number[], values: NDArray | number | bigint): void;
862
- /**
863
- * Integer array indexing (fancy indexing)
864
- *
865
- * Select elements using an array of indices. This is NumPy's "fancy indexing"
866
- * feature: `arr[[0, 2, 4]]` becomes `arr.iindex([0, 2, 4])` or `arr.iindex(indices)`.
867
- *
868
- * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
869
- * @param axis - Axis along which to index (default: 0, or flattens if undefined with flat indices)
870
- * @returns New array with selected elements
871
- *
872
- * @example
873
- * ```typescript
874
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
875
- *
876
- * // Select rows 0 and 2
877
- * arr.iindex([0, 2]); // [[1, 2, 3], [7, 8, 9]]
878
- *
879
- * // Select along axis 1 (columns)
880
- * arr.iindex([0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
881
- *
882
- * // With NDArray indices
883
- * const idx = np.array([0, 2]);
884
- * arr.iindex(idx); // [[1, 2, 3], [7, 8, 9]]
885
- * ```
886
- */
887
- iindex(indices: NDArray | number[] | number[][], axis?: number): NDArray;
888
- /**
889
- * Boolean array indexing (fancy indexing with mask)
890
- *
891
- * Select elements where a boolean mask is true. This is NumPy's boolean
892
- * indexing: `arr[arr > 5]` becomes `arr.bindex(arr.greater(5))`.
893
- *
894
- * @param mask - Boolean NDArray mask
895
- * @param axis - Axis along which to apply the mask (default: flattens array)
896
- * @returns New 1D array with selected elements (or along axis if specified)
897
- *
898
- * @example
899
- * ```typescript
900
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
901
- *
902
- * // Select all elements > 5
903
- * const mask = arr.greater(5);
904
- * arr.bindex(mask); // [6, 7, 8, 9]
905
- *
906
- * // Select rows where first column > 3
907
- * const rowMask = np.array([false, true, true]);
908
- * arr.bindex(rowMask, 0); // [[4, 5, 6], [7, 8, 9]]
909
- * ```
910
- */
911
- bindex(mask: NDArray, axis?: number): NDArray;
912
- /**
913
- * Matrix multiplication
914
- * @param other - Array to multiply with
915
- * @returns Result of matrix multiplication
916
- */
917
- matmul(other: NDArray): NDArray;
918
- /**
919
- * Dot product (matching NumPy behavior)
920
- * @param other - Array to dot with
921
- * @returns Result of dot product (scalar or array depending on dimensions, Complex for complex arrays)
922
- */
923
- dot(other: NDArray): NDArray | number | bigint | Complex;
924
- /**
925
- * Sum of diagonal elements (trace)
926
- * @returns Sum of diagonal elements (Complex for complex arrays)
927
- */
928
- trace(): number | bigint | Complex;
929
- /**
930
- * Inner product (contracts over last axes of both arrays)
931
- * @param other - Array to compute inner product with
932
- * @returns Inner product result (Complex for complex arrays)
933
- */
934
- inner(other: NDArray): NDArray | number | bigint | Complex;
935
- /**
936
- * Outer product (flattens inputs then computes a[i]*b[j])
937
- * @param other - Array to compute outer product with
938
- * @returns 2D outer product matrix
939
- */
940
- outer(other: NDArray): NDArray;
941
- /**
942
- * Tensor dot product along specified axes
943
- * @param other - Array to contract with
944
- * @param axes - Axes to contract (integer or [a_axes, b_axes])
945
- * @returns Tensor dot product result
946
- */
947
- tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
948
- /**
949
- * Element-wise cube root
950
- * Promotes integer types to float64
951
- * @returns New array with cube root values
952
- */
953
- cbrt(): NDArray;
954
- /**
955
- * Element-wise absolute value (always returns float)
956
- * @returns New array with absolute values as float
957
- */
958
- fabs(): NDArray;
959
- /**
960
- * Returns both quotient and remainder (floor divide and modulo)
961
- * @param divisor - Array or scalar divisor
962
- * @returns Tuple of [quotient, remainder] arrays
963
- */
964
- divmod(divisor: NDArray | number): [NDArray, NDArray];
965
- /**
966
- * Element-wise square (x**2)
967
- * @returns New array with squared values
968
- */
969
- square(): NDArray;
970
- /**
971
- * Element-wise remainder (same as mod)
972
- * @param divisor - Array or scalar divisor
973
- * @returns New array with remainder values
974
- */
975
- remainder(divisor: NDArray | number): NDArray;
976
- /**
977
- * Heaviside step function
978
- * @param x2 - Value to use when this array element is 0
979
- * @returns New array with heaviside values
980
- */
981
- heaviside(x2: NDArray | number): NDArray;
982
- /**
983
- * Slice the array using NumPy-style string syntax
984
- *
985
- * @param sliceStrs - Slice specifications, one per dimension
986
- * @returns Sliced view of the array
987
- */
988
- slice(...sliceStrs: string[]): NDArray;
989
- /**
990
- * Get a single row (convenience method)
991
- * @param i - Row index
992
- * @returns Row as 1D or (n-1)D array
993
- */
994
- row(i: number): NDArray;
995
- /**
996
- * Get a single column (convenience method)
997
- * @param j - Column index
998
- * @returns Column as 1D or (n-1)D array
999
- */
1000
- col(j: number): NDArray;
1001
- /**
1002
- * Get a range of rows (convenience method)
1003
- * @param start - Start row index
1004
- * @param stop - Stop row index (exclusive)
1005
- * @returns Rows as array
1006
- */
1007
- rows(start: number, stop: number): NDArray;
1008
- /**
1009
- * Get a range of columns (convenience method)
1010
- * @param start - Start column index
1011
- * @param stop - Stop column index (exclusive)
1012
- * @returns Columns as array
1013
- */
1014
- cols(start: number, stop: number): NDArray;
1015
- /**
1016
- * String representation of the array
1017
- * @returns String describing the array shape and dtype
1018
- */
1019
- toString(): string;
1020
- /**
1021
- * Convert to nested JavaScript array
1022
- * @returns Nested JavaScript array representation
1023
- */
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;
1049
- }
1050
- /**
1051
- * Create array of zeros
1052
- * @param shape - Shape of the array
1053
- * @param dtype - Data type (default: float64)
1054
- * @returns Array filled with zeros
1055
- */
1056
- export declare function zeros(shape: number[], dtype?: DType): NDArray;
1057
- /**
1058
- * Create array of ones
1059
- * @param shape - Shape of the array
1060
- * @param dtype - Data type (default: float64)
1061
- * @returns Array filled with ones
1062
- */
1063
- export declare function ones(shape: number[], dtype?: DType): NDArray;
1064
- /**
1065
- * Create array from nested JavaScript arrays
1066
- * @param data - Nested arrays or existing NDArray
1067
- * @param dtype - Data type (optional, will be inferred if not provided)
1068
- * @returns New NDArray
1069
- */
1070
- export declare function array(data: any, dtype?: DType): NDArray;
1071
- /**
1072
- * Create array with evenly spaced values within a given interval
1073
- * Similar to Python's range() but returns array
1074
- * @param start - Start value (or stop if only one argument)
1075
- * @param stop - Stop value (exclusive)
1076
- * @param step - Step between values (default: 1)
1077
- * @param dtype - Data type (default: float64)
1078
- * @returns Array of evenly spaced values
1079
- */
1080
- export declare function arange(start: number, stop?: number, step?: number, dtype?: DType): NDArray;
1081
- /**
1082
- * Create array with evenly spaced values over a specified interval
1083
- * @param start - Starting value
1084
- * @param stop - Ending value (inclusive)
1085
- * @param num - Number of samples (default: 50)
1086
- * @param dtype - Data type (default: float64)
1087
- * @returns Array of evenly spaced values
1088
- */
1089
- export declare function linspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
1090
- /**
1091
- * Create array with logarithmically spaced values
1092
- * Returns num samples, equally spaced on a log scale from base^start to base^stop
1093
- * @param start - base^start is the starting value
1094
- * @param stop - base^stop is the ending value
1095
- * @param num - Number of samples (default: 50)
1096
- * @param base - Base of the log space (default: 10.0)
1097
- * @param dtype - Data type (default: float64)
1098
- * @returns Array of logarithmically spaced values
1099
- */
1100
- export declare function logspace(start: number, stop: number, num?: number, base?: number, dtype?: DType): NDArray;
1101
- /**
1102
- * Create array with geometrically spaced values
1103
- * Returns num samples, equally spaced on a log scale (geometric progression)
1104
- * @param start - Starting value
1105
- * @param stop - Ending value
1106
- * @param num - Number of samples (default: 50)
1107
- * @param dtype - Data type (default: float64)
1108
- * @returns Array of geometrically spaced values
1109
- */
1110
- export declare function geomspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
1111
- /**
1112
- * Create identity matrix
1113
- * @param n - Number of rows
1114
- * @param m - Number of columns (default: n)
1115
- * @param k - Index of diagonal (0 for main diagonal, positive for upper, negative for lower)
1116
- * @param dtype - Data type (default: float64)
1117
- * @returns Identity matrix
1118
- */
1119
- export declare function eye(n: number, m?: number, k?: number, dtype?: DType): NDArray;
1120
- /**
1121
- * Create an uninitialized array
1122
- * Note: TypedArrays are zero-initialized by default in JavaScript
1123
- * @param shape - Shape of the array
1124
- * @param dtype - Data type (default: float64)
1125
- * @returns Uninitialized array
1126
- */
1127
- export declare function empty(shape: number[], dtype?: DType): NDArray;
1128
- /**
1129
- * Create array filled with a constant value
1130
- * @param shape - Shape of the array
1131
- * @param fill_value - Value to fill the array with
1132
- * @param dtype - Data type (optional, inferred from fill_value if not provided)
1133
- * @returns Array filled with the constant value
1134
- */
1135
- export declare function full(shape: number[], fill_value: number | bigint | boolean, dtype?: DType): NDArray;
1136
- /**
1137
- * Create a square identity matrix
1138
- * @param n - Size of the square matrix
1139
- * @param dtype - Data type (default: float64)
1140
- * @returns n×n identity matrix
1141
- */
1142
- export declare function identity(n: number, dtype?: DType): NDArray;
1143
- /**
1144
- * Convert input to an ndarray
1145
- * @param a - Input data (array-like or NDArray)
1146
- * @param dtype - Data type (optional)
1147
- * @returns NDArray representation of the input
1148
- */
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;
1166
- /**
1167
- * Create a deep copy of an array
1168
- * @param a - Array to copy
1169
- * @returns Deep copy of the array
1170
- */
1171
- export declare function copy(a: NDArray): NDArray;
1172
- /**
1173
- * Create array of zeros with the same shape as another array
1174
- * @param a - Array to match shape from
1175
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1176
- * @returns Array of zeros
1177
- */
1178
- export declare function zeros_like(a: NDArray, dtype?: DType): NDArray;
1179
- /**
1180
- * Create array of ones with the same shape as another array
1181
- * @param a - Array to match shape from
1182
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1183
- * @returns Array of ones
1184
- */
1185
- export declare function ones_like(a: NDArray, dtype?: DType): NDArray;
1186
- /**
1187
- * Create uninitialized array with the same shape as another array
1188
- * @param a - Array to match shape from
1189
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1190
- * @returns Uninitialized array
1191
- */
1192
- export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
1193
- /**
1194
- * Create array filled with a constant value, same shape as another array
1195
- * @param a - Array to match shape from
1196
- * @param fill_value - Value to fill with
1197
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1198
- * @returns Filled array
1199
- */
1200
- export declare function full_like(a: NDArray, fill_value: number | bigint | boolean, dtype?: DType): NDArray;
1201
- /**
1202
- * Convert input to an ndarray (alias for asarray for compatibility)
1203
- * In numpy-ts, this behaves the same as asarray since we don't have subclasses
1204
- * @param a - Input data
1205
- * @param dtype - Data type (optional)
1206
- * @returns NDArray
1207
- */
1208
- export declare function asanyarray(a: NDArray | any, dtype?: DType): NDArray;
1209
- /**
1210
- * Return a contiguous array (ndim >= 1) in memory (C order)
1211
- * Since our arrays are already C-contiguous in memory, this either
1212
- * returns the input unchanged or creates a contiguous copy
1213
- * @param a - Input data
1214
- * @param dtype - Data type (optional)
1215
- * @returns Contiguous array in C order
1216
- */
1217
- export declare function ascontiguousarray(a: NDArray | any, dtype?: DType): NDArray;
1218
- /**
1219
- * Return an array laid out in Fortran order in memory
1220
- * Note: numpy-ts uses C-order internally, so this creates a copy
1221
- * that is equivalent to the Fortran-ordered layout
1222
- * @param a - Input data
1223
- * @param dtype - Data type (optional)
1224
- * @returns Array (copy in C order, as Fortran order is not supported)
1225
- */
1226
- export declare function asfortranarray(a: NDArray | any, dtype?: DType): NDArray;
1227
- /**
1228
- * Extract a diagonal or construct a diagonal array
1229
- * @param v - Input array (if 2D, extract diagonal; if 1D, construct diagonal matrix)
1230
- * @param k - Diagonal offset (default 0 is main diagonal, positive above, negative below)
1231
- * @returns Diagonal elements as 1D array, or 2D diagonal matrix
1232
- */
1233
- export declare function diag(v: NDArray, k?: number): NDArray;
1234
- /**
1235
- * Create a 2-D array with the flattened input as a diagonal
1236
- * @param v - Input array (will be flattened)
1237
- * @param k - Diagonal offset (default 0)
1238
- * @returns 2D diagonal matrix
1239
- */
1240
- export declare function diagflat(v: NDArray, k?: number): NDArray;
1241
- /**
1242
- * Construct an array by executing a function over each coordinate
1243
- * @param fn - Function that takes coordinate indices and returns value
1244
- * @param shape - Shape of output array
1245
- * @param dtype - Data type (default: float64)
1246
- * @returns Array with values computed from function
1247
- */
1248
- export declare function fromfunction(fn: (...indices: number[]) => number | bigint | boolean, shape: number[], dtype?: DType): NDArray;
1249
- /**
1250
- * Return coordinate matrices from coordinate vectors
1251
- * @param arrays - 1D coordinate arrays
1252
- * @param indexing - 'xy' (Cartesian, default) or 'ij' (matrix indexing)
1253
- * @returns Array of coordinate grids
1254
- */
1255
- export declare function meshgrid(...args: (NDArray | {
1256
- indexing?: 'xy' | 'ij';
1257
- })[]): NDArray[];
1258
- /**
1259
- * An array with ones at and below the given diagonal and zeros elsewhere
1260
- * @param N - Number of rows
1261
- * @param M - Number of columns (default: N)
1262
- * @param k - Diagonal offset (default 0)
1263
- * @param dtype - Data type (default: float64)
1264
- * @returns Triangular array
1265
- */
1266
- export declare function tri(N: number, M?: number, k?: number, dtype?: DType): NDArray;
1267
- /**
1268
- * Lower triangle of an array
1269
- * @param m - Input array
1270
- * @param k - Diagonal above which to zero elements (default 0)
1271
- * @returns Copy with upper triangle zeroed
1272
- */
1273
- export declare function tril(m: NDArray, k?: number): NDArray;
1274
- /**
1275
- * Upper triangle of an array
1276
- * @param m - Input array
1277
- * @param k - Diagonal below which to zero elements (default 0)
1278
- * @returns Copy with lower triangle zeroed
1279
- */
1280
- export declare function triu(m: NDArray, k?: number): NDArray;
1281
- /**
1282
- * Generate a Vandermonde matrix
1283
- * @param x - Input 1D array
1284
- * @param N - Number of columns (default: length of x)
1285
- * @param increasing - Order of powers (default: false, highest powers first)
1286
- * @returns Vandermonde matrix
1287
- */
1288
- export declare function vander(x: NDArray, N?: number, increasing?: boolean): NDArray;
1289
- /**
1290
- * Interpret a buffer as a 1-dimensional array
1291
- * @param buffer - Buffer-like object (ArrayBuffer, TypedArray, or DataView)
1292
- * @param dtype - Data type (default: float64)
1293
- * @param count - Number of items to read (-1 means all)
1294
- * @param offset - Start reading from this byte offset
1295
- * @returns NDArray from buffer data
1296
- */
1297
- export declare function frombuffer(buffer: ArrayBuffer | ArrayBufferView, dtype?: DType, count?: number, offset?: number): NDArray;
1298
- /**
1299
- * Construct an array by executing a function over each coordinate.
1300
- * Note: This is a JS implementation - fromfile for actual files isn't directly applicable in browser JS.
1301
- * This function creates an array from an iterable or callable.
1302
- * @param file - In JS context, this is an iterable yielding values
1303
- * @param dtype - Data type
1304
- * @param count - Number of items to read (-1 means all)
1305
- * @returns NDArray from the iterable
1306
- */
1307
- export declare function fromfile(file: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
1308
- /**
1309
- * Create a new 1-dimensional array from an iterable object
1310
- * @param iter - Iterable object
1311
- * @param dtype - Data type
1312
- * @param count - Number of items to read (-1 means all)
1313
- * @returns NDArray from the iterable
1314
- */
1315
- export declare function fromiter(iter: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
1316
- /**
1317
- * Create a new 1-dimensional array from text string
1318
- * @param string - Input string containing numbers separated by whitespace or separator
1319
- * @param dtype - Data type (default: float64)
1320
- * @param count - Number of items to read (-1 means all)
1321
- * @param sep - Separator between values (default: any whitespace)
1322
- * @returns NDArray from parsed string
1323
- */
1324
- export declare function fromstring(string: string, dtype?: DType, count?: number, sep?: string): NDArray;
1325
- /**
1326
- * Element-wise square root
1327
- * @param x - Input array
1328
- * @returns Array of square roots
1329
- */
1330
- export declare function sqrt(x: NDArray): NDArray;
1331
- /**
1332
- * Element-wise power
1333
- * @param x - Base array
1334
- * @param exponent - Exponent (array or scalar)
1335
- * @returns Array of x raised to exponent
1336
- */
1337
- export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
1338
- export { power as pow };
1339
- /**
1340
- * Element-wise natural exponential (e^x)
1341
- * @param x - Input array
1342
- * @returns Array of e^x values
1343
- */
1344
- export declare function exp(x: NDArray): NDArray;
1345
- /**
1346
- * Element-wise base-2 exponential (2^x)
1347
- * @param x - Input array
1348
- * @returns Array of 2^x values
1349
- */
1350
- export declare function exp2(x: NDArray): NDArray;
1351
- /**
1352
- * Element-wise exponential minus one (e^x - 1)
1353
- * More accurate than exp(x) - 1 for small x
1354
- * @param x - Input array
1355
- * @returns Array of expm1 values
1356
- */
1357
- export declare function expm1(x: NDArray): NDArray;
1358
- /**
1359
- * Element-wise natural logarithm (ln)
1360
- * @param x - Input array
1361
- * @returns Array of log values
1362
- */
1363
- export declare function log(x: NDArray): NDArray;
1364
- /**
1365
- * Element-wise base-2 logarithm
1366
- * @param x - Input array
1367
- * @returns Array of log2 values
1368
- */
1369
- export declare function log2(x: NDArray): NDArray;
1370
- /**
1371
- * Element-wise base-10 logarithm
1372
- * @param x - Input array
1373
- * @returns Array of log10 values
1374
- */
1375
- export declare function log10(x: NDArray): NDArray;
1376
- /**
1377
- * Element-wise natural logarithm of (1 + x)
1378
- * More accurate than log(1 + x) for small x
1379
- * @param x - Input array
1380
- * @returns Array of log1p values
1381
- */
1382
- export declare function log1p(x: NDArray): NDArray;
1383
- /**
1384
- * Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
1385
- * More numerically stable than computing the expression directly
1386
- * @param x1 - First input array
1387
- * @param x2 - Second input array or scalar
1388
- * @returns Array of logaddexp values
1389
- */
1390
- export declare function logaddexp(x1: NDArray, x2: NDArray | number): NDArray;
1391
- /**
1392
- * Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
1393
- * More numerically stable than computing the expression directly
1394
- * @param x1 - First input array
1395
- * @param x2 - Second input array or scalar
1396
- * @returns Array of logaddexp2 values
1397
- */
1398
- export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
1399
- /**
1400
- * Element-wise absolute value
1401
- * @param x - Input array
1402
- * @returns Array of absolute values
1403
- */
1404
- export declare function absolute(x: NDArray): NDArray;
1405
- export { absolute as abs };
1406
- /**
1407
- * Element-wise negation
1408
- * @param x - Input array
1409
- * @returns Array of negated values
1410
- */
1411
- export declare function negative(x: NDArray): NDArray;
1412
- /**
1413
- * Element-wise sign (-1, 0, or 1)
1414
- * @param x - Input array
1415
- * @returns Array of signs
1416
- */
1417
- export declare function sign(x: NDArray): NDArray;
1418
- /**
1419
- * Element-wise modulo
1420
- * @param x - Dividend array
1421
- * @param divisor - Divisor (array or scalar)
1422
- * @returns Remainder after division
1423
- */
1424
- export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
1425
- /**
1426
- * Element-wise division
1427
- * @param x - Dividend array
1428
- * @param divisor - Divisor (array or scalar)
1429
- * @returns Array of quotients
1430
- */
1431
- export declare function divide(x: NDArray, divisor: NDArray | number): NDArray;
1432
- export { divide as true_divide };
1433
- /**
1434
- * Element-wise floor division
1435
- * @param x - Dividend array
1436
- * @param divisor - Divisor (array or scalar)
1437
- * @returns Floor of the quotient
1438
- */
1439
- export declare function floor_divide(x: NDArray, divisor: NDArray | number): NDArray;
1440
- /**
1441
- * Element-wise positive (unary +)
1442
- * @param x - Input array
1443
- * @returns Copy of the array
1444
- */
1445
- export declare function positive(x: NDArray): NDArray;
1446
- /**
1447
- * Element-wise reciprocal (1/x)
1448
- * @param x - Input array
1449
- * @returns Array of reciprocals
1450
- */
1451
- export declare function reciprocal(x: NDArray): NDArray;
1452
- /**
1453
- * Dot product of two arrays
1454
- *
1455
- * Fully NumPy-compatible. Behavior depends on input dimensions:
1456
- * - 0D · 0D: Multiply scalars → scalar
1457
- * - 0D · ND or ND · 0D: Element-wise multiply → ND
1458
- * - 1D · 1D: Inner product → scalar
1459
- * - 2D · 2D: Matrix multiplication → 2D
1460
- * - 2D · 1D: Matrix-vector product → 1D
1461
- * - 1D · 2D: Vector-matrix product → 1D
1462
- * - ND · 1D (N>2): Sum over last axis → (N-1)D
1463
- * - 1D · ND (N>2): Sum over first axis → (N-1)D
1464
- * - ND · MD (N,M≥2): Tensor contraction → (N+M-2)D
1465
- *
1466
- * @param a - First array
1467
- * @param b - Second array
1468
- * @returns Result of dot product (Complex for complex arrays)
1469
- */
1470
- export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1471
- /**
1472
- * Sum of diagonal elements
1473
- *
1474
- * @param a - Input 2D array
1475
- * @returns Sum of diagonal elements (Complex for complex arrays)
1476
- */
1477
- export declare function trace(a: NDArray): number | bigint | Complex;
1478
- /**
1479
- * Extract a diagonal from a matrix or N-D array
1480
- *
1481
- * @param a - Input array (must be at least 2D)
1482
- * @param offset - Offset of the diagonal from the main diagonal (default: 0)
1483
- * @param axis1 - First axis (default: 0)
1484
- * @param axis2 - Second axis (default: 1)
1485
- * @returns Array containing the diagonal elements
1486
- */
1487
- export declare function diagonal(a: NDArray, offset?: number, axis1?: number, axis2?: number): NDArray;
1488
- /**
1489
- * Kronecker product of two arrays
1490
- *
1491
- * @param a - First input array
1492
- * @param b - Second input array
1493
- * @returns Kronecker product of a and b
1494
- */
1495
- export declare function kron(a: NDArray, b: NDArray): NDArray;
1496
- /**
1497
- * Permute array dimensions
1498
- *
1499
- * @param a - Input array
1500
- * @param axes - Optional permutation of axes (defaults to reverse order)
1501
- * @returns Transposed view
1502
- */
1503
- export declare function transpose(a: NDArray, axes?: number[]): NDArray;
1504
- /**
1505
- * Inner product of two arrays
1506
- *
1507
- * Contracts over last axes of both arrays.
1508
- * Result shape: (*a.shape[:-1], *b.shape[:-1])
1509
- *
1510
- * @param a - First array
1511
- * @param b - Second array
1512
- * @returns Inner product result (Complex for complex arrays)
1513
- */
1514
- export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1515
- /**
1516
- * Outer product of two arrays
1517
- *
1518
- * Flattens inputs then computes result[i,j] = a[i] * b[j]
1519
- *
1520
- * @param a - First array
1521
- * @param b - Second array
1522
- * @returns 2D outer product matrix
1523
- */
1524
- export declare function outer(a: NDArray, b: NDArray): NDArray;
1525
- /**
1526
- * Tensor dot product along specified axes
1527
- *
1528
- * @param a - First array
1529
- * @param b - Second array
1530
- * @param axes - Axes to contract (integer or [a_axes, b_axes])
1531
- * @returns Tensor dot product
1532
- */
1533
- export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
1534
- /**
1535
- * Element-wise sine
1536
- * @param x - Input array (angles in radians)
1537
- * @returns Array of sine values
1538
- */
1539
- export declare function sin(x: NDArray): NDArray;
1540
- /**
1541
- * Element-wise cosine
1542
- * @param x - Input array (angles in radians)
1543
- * @returns Array of cosine values
1544
- */
1545
- export declare function cos(x: NDArray): NDArray;
1546
- /**
1547
- * Element-wise tangent
1548
- * @param x - Input array (angles in radians)
1549
- * @returns Array of tangent values
1550
- */
1551
- export declare function tan(x: NDArray): NDArray;
1552
- /**
1553
- * Element-wise inverse sine
1554
- * @param x - Input array (values in range [-1, 1])
1555
- * @returns Array of angles in radians
1556
- */
1557
- export declare function arcsin(x: NDArray): NDArray;
1558
- export { arcsin as asin };
1559
- /**
1560
- * Element-wise inverse cosine
1561
- * @param x - Input array (values in range [-1, 1])
1562
- * @returns Array of angles in radians
1563
- */
1564
- export declare function arccos(x: NDArray): NDArray;
1565
- export { arccos as acos };
1566
- /**
1567
- * Element-wise inverse tangent
1568
- * @param x - Input array
1569
- * @returns Array of angles in radians
1570
- */
1571
- export declare function arctan(x: NDArray): NDArray;
1572
- export { arctan as atan };
1573
- /**
1574
- * Element-wise arc tangent of x1/x2 choosing the quadrant correctly
1575
- * @param x1 - y-coordinates
1576
- * @param x2 - x-coordinates (array or scalar)
1577
- * @returns Angles in radians between -π and π
1578
- */
1579
- export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
1580
- export { arctan2 as atan2 };
1581
- /**
1582
- * Given the "legs" of a right triangle, return its hypotenuse
1583
- * Equivalent to sqrt(x1**2 + x2**2), element-wise
1584
- * @param x1 - First leg
1585
- * @param x2 - Second leg (array or scalar)
1586
- * @returns Hypotenuse values
1587
- */
1588
- export declare function hypot(x1: NDArray, x2: NDArray | number): NDArray;
1589
- /**
1590
- * Convert angles from radians to degrees
1591
- * @param x - Input array (angles in radians)
1592
- * @returns Angles in degrees
1593
- */
1594
- export declare function degrees(x: NDArray): NDArray;
1595
- /**
1596
- * Convert angles from degrees to radians
1597
- * @param x - Input array (angles in degrees)
1598
- * @returns Angles in radians
1599
- */
1600
- export declare function radians(x: NDArray): NDArray;
1601
- /**
1602
- * Convert angles from degrees to radians (alias for radians)
1603
- * @param x - Input array (angles in degrees)
1604
- * @returns Angles in radians
1605
- */
1606
- export declare function deg2rad(x: NDArray): NDArray;
1607
- /**
1608
- * Convert angles from radians to degrees (alias for degrees)
1609
- * @param x - Input array (angles in radians)
1610
- * @returns Angles in degrees
1611
- */
1612
- export declare function rad2deg(x: NDArray): NDArray;
1613
- /**
1614
- * Element-wise hyperbolic sine
1615
- * @param x - Input array
1616
- * @returns Array of sinh values
1617
- */
1618
- export declare function sinh(x: NDArray): NDArray;
1619
- /**
1620
- * Element-wise hyperbolic cosine
1621
- * @param x - Input array
1622
- * @returns Array of cosh values
1623
- */
1624
- export declare function cosh(x: NDArray): NDArray;
1625
- /**
1626
- * Element-wise hyperbolic tangent
1627
- * @param x - Input array
1628
- * @returns Array of tanh values
1629
- */
1630
- export declare function tanh(x: NDArray): NDArray;
1631
- /**
1632
- * Element-wise inverse hyperbolic sine
1633
- * @param x - Input array
1634
- * @returns Array of arcsinh values
1635
- */
1636
- export declare function arcsinh(x: NDArray): NDArray;
1637
- export { arcsinh as asinh };
1638
- /**
1639
- * Element-wise inverse hyperbolic cosine
1640
- * @param x - Input array (values >= 1)
1641
- * @returns Array of arccosh values
1642
- */
1643
- export declare function arccosh(x: NDArray): NDArray;
1644
- export { arccosh as acosh };
1645
- /**
1646
- * Element-wise inverse hyperbolic tangent
1647
- * @param x - Input array (values in range (-1, 1))
1648
- * @returns Array of arctanh values
1649
- */
1650
- export declare function arctanh(x: NDArray): NDArray;
1651
- export { arctanh as atanh };
1652
- /**
1653
- * Swap two axes of an array
1654
- *
1655
- * @param a - Input array
1656
- * @param axis1 - First axis
1657
- * @param axis2 - Second axis
1658
- * @returns View with axes swapped
1659
- */
1660
- export declare function swapaxes(a: NDArray, axis1: number, axis2: number): NDArray;
1661
- /**
1662
- * Move axes to new positions
1663
- *
1664
- * @param a - Input array
1665
- * @param source - Original positions of axes to move
1666
- * @param destination - New positions for axes
1667
- * @returns View with axes moved
1668
- */
1669
- export declare function moveaxis(a: NDArray, source: number | number[], destination: number | number[]): NDArray;
1670
- /**
1671
- * Concatenate arrays along an existing axis
1672
- *
1673
- * @param arrays - Arrays to concatenate
1674
- * @param axis - Axis along which to concatenate (default: 0)
1675
- * @returns Concatenated array
1676
- */
1677
- export declare function concatenate(arrays: NDArray[], axis?: number): NDArray;
1678
- /**
1679
- * Stack arrays along a new axis
1680
- *
1681
- * @param arrays - Arrays to stack (must have same shape)
1682
- * @param axis - Axis in the result array along which to stack (default: 0)
1683
- * @returns Stacked array
1684
- */
1685
- export declare function stack(arrays: NDArray[], axis?: number): NDArray;
1686
- /**
1687
- * Stack arrays vertically (row-wise)
1688
- *
1689
- * @param arrays - Arrays to stack
1690
- * @returns Vertically stacked array
1691
- */
1692
- export declare function vstack(arrays: NDArray[]): NDArray;
1693
- /**
1694
- * Stack arrays horizontally (column-wise)
1695
- *
1696
- * @param arrays - Arrays to stack
1697
- * @returns Horizontally stacked array
1698
- */
1699
- export declare function hstack(arrays: NDArray[]): NDArray;
1700
- /**
1701
- * Stack arrays depth-wise (along third axis)
1702
- *
1703
- * @param arrays - Arrays to stack
1704
- * @returns Depth-stacked array
1705
- */
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;
1719
- /**
1720
- * Split array into multiple sub-arrays
1721
- *
1722
- * @param a - Array to split
1723
- * @param indicesOrSections - Number of equal sections or indices where to split
1724
- * @param axis - Axis along which to split (default: 0)
1725
- * @returns List of sub-arrays
1726
- */
1727
- export declare function split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
1728
- /**
1729
- * Split array into multiple sub-arrays (allows unequal splits)
1730
- *
1731
- * @param a - Array to split
1732
- * @param indicesOrSections - Number of sections or indices where to split
1733
- * @param axis - Axis along which to split (default: 0)
1734
- * @returns List of sub-arrays
1735
- */
1736
- export declare function array_split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
1737
- /**
1738
- * Split array vertically (row-wise)
1739
- *
1740
- * @param a - Array to split
1741
- * @param indicesOrSections - Number of sections or indices where to split
1742
- * @returns List of sub-arrays
1743
- */
1744
- export declare function vsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
1745
- /**
1746
- * Split array horizontally (column-wise)
1747
- *
1748
- * @param a - Array to split
1749
- * @param indicesOrSections - Number of sections or indices where to split
1750
- * @returns List of sub-arrays
1751
- */
1752
- export declare function hsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
1753
- /**
1754
- * Tile array by repeating along each axis
1755
- *
1756
- * @param a - Input array
1757
- * @param reps - Number of repetitions along each axis
1758
- * @returns Tiled array
1759
- */
1760
- export declare function tile(a: NDArray, reps: number | number[]): NDArray;
1761
- /**
1762
- * Repeat elements of an array
1763
- *
1764
- * @param a - Input array
1765
- * @param repeats - Number of repetitions for each element
1766
- * @param axis - Axis along which to repeat (if undefined, flattens first)
1767
- * @returns Array with repeated elements
1768
- */
1769
- export declare function repeat(a: NDArray, repeats: number | number[], axis?: number): NDArray;
1770
- /**
1771
- * Return a contiguous flattened array
1772
- *
1773
- * @param a - Input array
1774
- * @returns Flattened 1-D array (view if possible)
1775
- */
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;
1809
- /**
1810
- * Reshape array to new shape
1811
- *
1812
- * @param a - Input array
1813
- * @param newShape - New shape
1814
- * @returns Reshaped array (view if possible)
1815
- */
1816
- export declare function reshape(a: NDArray, newShape: number[]): NDArray;
1817
- /**
1818
- * Remove axes of length 1
1819
- *
1820
- * @param a - Input array
1821
- * @param axis - Axis to squeeze (optional, squeezes all if not specified)
1822
- * @returns Squeezed array (view)
1823
- */
1824
- export declare function squeeze(a: NDArray, axis?: number): NDArray;
1825
- /**
1826
- * Expand the shape of an array by inserting a new axis
1827
- *
1828
- * @param a - Input array
1829
- * @param axis - Position where new axis should be inserted
1830
- * @returns Array with expanded shape (view)
1831
- */
1832
- export declare function expand_dims(a: NDArray, axis: number): NDArray;
1833
- /**
1834
- * Reverse the order of elements along the given axis
1835
- *
1836
- * @param m - Input array
1837
- * @param axis - Axis or axes to flip (flips all if undefined)
1838
- * @returns Flipped array
1839
- */
1840
- export declare function flip(m: NDArray, axis?: number | number[]): NDArray;
1841
- /**
1842
- * Flip array in the left/right direction (reverse along axis 1)
1843
- *
1844
- * @param m - Input array (must be at least 2-D)
1845
- * @returns Flipped array
1846
- */
1847
- export declare function fliplr(m: NDArray): NDArray;
1848
- /**
1849
- * Flip array in the up/down direction (reverse along axis 0)
1850
- *
1851
- * @param m - Input array (must be at least 2-D)
1852
- * @returns Flipped array
1853
- */
1854
- export declare function flipud(m: NDArray): NDArray;
1855
- /**
1856
- * Rotate array by 90 degrees
1857
- *
1858
- * @param m - Input array
1859
- * @param k - Number of times to rotate (default 1)
1860
- * @param axes - The axes to rotate in (default [0, 1])
1861
- * @returns Rotated array
1862
- */
1863
- export declare function rot90(m: NDArray, k?: number, axes?: [number, number]): NDArray;
1864
- /**
1865
- * Roll array elements along a given axis
1866
- *
1867
- * @param a - Input array
1868
- * @param shift - Number of positions to shift
1869
- * @param axis - Axis along which to roll (rolls flattened array if undefined)
1870
- * @returns Rolled array
1871
- */
1872
- export declare function roll(a: NDArray, shift: number | number[], axis?: number | number[]): NDArray;
1873
- /**
1874
- * Roll the specified axis backwards until it lies in a given position
1875
- *
1876
- * @param a - Input array
1877
- * @param axis - The axis to roll backwards
1878
- * @param start - Position to roll to (default 0)
1879
- * @returns Array with rolled axis (view)
1880
- */
1881
- export declare function rollaxis(a: NDArray, axis: number, start?: number): NDArray;
1882
- /**
1883
- * Convert inputs to arrays with at least 1 dimension
1884
- *
1885
- * @param arrays - Input arrays
1886
- * @returns Arrays with at least 1 dimension
1887
- */
1888
- export declare function atleast_1d(...arrays: NDArray[]): NDArray | NDArray[];
1889
- /**
1890
- * Convert inputs to arrays with at least 2 dimensions
1891
- *
1892
- * @param arrays - Input arrays
1893
- * @returns Arrays with at least 2 dimensions
1894
- */
1895
- export declare function atleast_2d(...arrays: NDArray[]): NDArray | NDArray[];
1896
- /**
1897
- * Convert inputs to arrays with at least 3 dimensions
1898
- *
1899
- * @param arrays - Input arrays
1900
- * @returns Arrays with at least 3 dimensions
1901
- */
1902
- export declare function atleast_3d(...arrays: NDArray[]): NDArray | NDArray[];
1903
- /**
1904
- * Split array along third axis (depth)
1905
- *
1906
- * @param ary - Input array (must be at least 3-D)
1907
- * @param indices_or_sections - Number of sections or indices where to split
1908
- * @returns List of sub-arrays
1909
- */
1910
- export declare function dsplit(ary: NDArray, indices_or_sections: number | number[]): NDArray[];
1911
- /**
1912
- * Stack 1-D arrays as columns into a 2-D array
1913
- *
1914
- * @param arrays - 1-D arrays to stack
1915
- * @returns 2-D array with inputs as columns
1916
- */
1917
- export declare function column_stack(arrays: NDArray[]): NDArray;
1918
- /**
1919
- * Stack arrays in sequence vertically (alias for vstack)
1920
- *
1921
- * @param arrays - Arrays to stack
1922
- * @returns Vertically stacked array
1923
- */
1924
- export declare function row_stack(arrays: NDArray[]): NDArray;
1925
- /**
1926
- * Return a new array with the given shape (repeating data if needed)
1927
- *
1928
- * @param a - Input array
1929
- * @param new_shape - New shape
1930
- * @returns Resized array
1931
- */
1932
- export declare function resize(a: NDArray, new_shape: number[]): NDArray;
1933
- /**
1934
- * Append values to the end of an array
1935
- *
1936
- * @param arr - Input array
1937
- * @param values - Values to append
1938
- * @param axis - Axis along which to append (flattens if undefined)
1939
- * @returns Array with values appended
1940
- */
1941
- export declare function append(arr: NDArray, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
1942
- /**
1943
- * Return a new array with sub-arrays along an axis deleted
1944
- *
1945
- * @param arr - Input array
1946
- * @param obj - Indices to delete
1947
- * @param axis - Axis along which to delete (flattens if undefined)
1948
- * @returns Array with elements deleted
1949
- */
1950
- export declare function delete_(arr: NDArray, obj: number | number[], axis?: number): NDArray;
1951
- /**
1952
- * Insert values along the given axis before the given indices
1953
- *
1954
- * @param arr - Input array
1955
- * @param obj - Index before which to insert
1956
- * @param values - Values to insert
1957
- * @param axis - Axis along which to insert (flattens if undefined)
1958
- * @returns Array with values inserted
1959
- */
1960
- export declare function insert(arr: NDArray, obj: number, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
1961
- /**
1962
- * Pad an array
1963
- *
1964
- * @param array - Input array
1965
- * @param pad_width - Number of values padded to edges of each axis
1966
- * @param mode - Padding mode ('constant', 'edge', 'reflect', 'symmetric', 'wrap')
1967
- * @param constant_values - Value for constant padding (default 0)
1968
- * @returns Padded array
1969
- */
1970
- export declare function pad(arr: NDArray, pad_width: number | [number, number] | Array<[number, number]>, mode?: 'constant' | 'edge' | 'reflect' | 'symmetric' | 'wrap', constant_values?: number): NDArray;
1971
- /**
1972
- * Broadcast an array to a given shape
1973
- *
1974
- * @param a - Input array
1975
- * @param shape - Target shape
1976
- * @returns View broadcast to target shape
1977
- */
1978
- export declare function broadcast_to(a: NDArray, shape: number[]): NDArray;
1979
- /**
1980
- * Broadcast arrays to a common shape
1981
- *
1982
- * @param arrays - Arrays to broadcast
1983
- * @returns Arrays broadcast to common shape
1984
- */
1985
- export declare function broadcast_arrays(...arrays: NDArray[]): NDArray[];
1986
- /**
1987
- * Compute the broadcast shape for multiple shapes
1988
- *
1989
- * Returns the resulting shape if all shapes are broadcast-compatible.
1990
- * Throws an error if shapes are not broadcast-compatible.
1991
- *
1992
- * @param shapes - Variable number of shapes to broadcast
1993
- * @returns The broadcast output shape
1994
- * @throws Error if shapes are not broadcast-compatible
1995
- */
1996
- export declare function broadcast_shapes(...shapes: number[][]): number[];
1997
- /**
1998
- * Take elements from an array along an axis
1999
- *
2000
- * @param a - Input array
2001
- * @param indices - Indices of elements to take
2002
- * @param axis - Axis along which to take (if undefined, flattens first)
2003
- * @returns Array with selected elements
2004
- */
2005
- export declare function take(a: NDArray, indices: number[], axis?: number): NDArray;
2006
- /**
2007
- * Put values at specified indices (modifies array in-place)
2008
- *
2009
- * @param a - Target array
2010
- * @param indices - Indices at which to place values
2011
- * @param values - Values to put
2012
- */
2013
- export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
2014
- /**
2015
- * Integer array indexing (fancy indexing)
2016
- *
2017
- * Select elements from an array using an array of indices.
2018
- * NumPy equivalent: `arr[[0, 2, 4]]`
2019
- *
2020
- * @param a - Input array
2021
- * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
2022
- * @param axis - Axis along which to index (default: 0)
2023
- * @returns New array with selected elements
2024
- *
2025
- * @example
2026
- * ```typescript
2027
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
2028
- * np.iindex(arr, [0, 2]); // [[1, 2, 3], [7, 8, 9]]
2029
- * np.iindex(arr, [0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
2030
- * ```
2031
- */
2032
- export declare function iindex(a: NDArray, indices: NDArray | number[] | number[][], axis?: number): NDArray;
2033
- /**
2034
- * Boolean array indexing (fancy indexing with mask)
2035
- *
2036
- * Select elements from an array where a boolean mask is true.
2037
- * NumPy equivalent: `arr[arr > 5]`
2038
- *
2039
- * @param a - Input array
2040
- * @param mask - Boolean NDArray mask
2041
- * @param axis - Axis along which to apply the mask (default: flattens array)
2042
- * @returns New array with selected elements
2043
- *
2044
- * @example
2045
- * ```typescript
2046
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
2047
- * const mask = arr.greater(5);
2048
- * np.bindex(arr, mask); // [6, 7, 8, 9]
2049
- * ```
2050
- */
2051
- export declare function bindex(a: NDArray, mask: NDArray, axis?: number): NDArray;
2052
- /**
2053
- * Copy values from one array to another, broadcasting as necessary.
2054
- *
2055
- * @param dst - Destination array (modified in-place)
2056
- * @param src - Source array or scalar
2057
- * @param where - Optional boolean array. Only copy where True (not yet implemented)
2058
- * @throws Error if shapes are not broadcastable
2059
- *
2060
- * @example
2061
- * ```typescript
2062
- * const dst = np.zeros([3, 3]);
2063
- * const src = np.array([1, 2, 3]);
2064
- * np.copyto(dst, src); // Each row of dst becomes [1, 2, 3]
2065
- * ```
2066
- */
2067
- export declare function copyto(dst: NDArray, src: NDArray | number | bigint, where?: NDArray): void;
2068
- /**
2069
- * Construct array from index array and choices
2070
- *
2071
- * @param a - Index array (integer indices into choices)
2072
- * @param choices - Arrays to choose from
2073
- * @returns Array constructed from choices
2074
- */
2075
- export declare function choose(a: NDArray, choices: NDArray[]): NDArray;
2076
- /**
2077
- * Check if two arrays are element-wise equal
2078
- *
2079
- * @param a - First array
2080
- * @param b - Second array
2081
- * @param equal_nan - Whether to consider NaN equal to NaN (default: false)
2082
- * @returns True if arrays are equal element-wise
2083
- */
2084
- export declare function array_equal(a: NDArray, b: NDArray, equal_nan?: boolean): boolean;
2085
- /**
2086
- * Returns True if two arrays are element-wise equal within a tolerance.
2087
- * Unlike array_equal, this function broadcasts the arrays before comparison.
2088
- *
2089
- * @param a1 - First input array
2090
- * @param a2 - Second input array
2091
- * @returns True if arrays are equivalent (after broadcasting)
2092
- */
2093
- export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
2094
- /**
2095
- * Return the cumulative sum of the elements along a given axis.
2096
- * @param a - Input array
2097
- * @param axis - Axis along which to compute. If undefined, flattened array is used.
2098
- * @returns Array with cumulative sums
2099
- */
2100
- export declare function cumsum(a: NDArray, axis?: number): NDArray;
2101
- export { cumsum as cumulative_sum };
2102
- /**
2103
- * Return the cumulative product of the elements along a given axis.
2104
- * @param a - Input array
2105
- * @param axis - Axis along which to compute. If undefined, flattened array is used.
2106
- * @returns Array with cumulative products
2107
- */
2108
- export declare function cumprod(a: NDArray, axis?: number): NDArray;
2109
- export { cumprod as cumulative_prod };
2110
- /**
2111
- * Return the maximum along a given axis.
2112
- * @param a - Input array
2113
- * @param axis - Axis along which to compute. If undefined, use all elements.
2114
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2115
- * @returns Maximum value(s)
2116
- */
2117
- export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2118
- export { max as amax };
2119
- /**
2120
- * Return the minimum along a given axis.
2121
- * @param a - Input array
2122
- * @param axis - Axis along which to compute. If undefined, use all elements.
2123
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2124
- * @returns Minimum value(s)
2125
- */
2126
- export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2127
- export { min as amin };
2128
- /**
2129
- * Peak to peak (maximum - minimum) value along a given axis.
2130
- * @param a - Input array
2131
- * @param axis - Axis along which to compute. If undefined, use all elements.
2132
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2133
- * @returns Peak to peak value(s)
2134
- */
2135
- export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2136
- /**
2137
- * Compute the median along the specified axis.
2138
- * @param a - Input array
2139
- * @param axis - Axis along which to compute. If undefined, use all elements.
2140
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2141
- * @returns Median value(s)
2142
- */
2143
- export declare function median(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2144
- /**
2145
- * Compute the q-th percentile of the data along the specified axis.
2146
- * @param a - Input array
2147
- * @param q - Percentile (0-100)
2148
- * @param axis - Axis along which to compute. If undefined, use all elements.
2149
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2150
- * @returns Percentile value(s)
2151
- */
2152
- export declare function percentile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2153
- /**
2154
- * Compute the q-th quantile of the data along the specified axis.
2155
- * @param a - Input array
2156
- * @param q - Quantile (0-1)
2157
- * @param axis - Axis along which to compute. If undefined, use all elements.
2158
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2159
- * @returns Quantile value(s)
2160
- */
2161
- export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2162
- /**
2163
- * Compute the weighted average along the specified axis.
2164
- * @param a - Input array
2165
- * @param axis - Axis along which to compute. If undefined, use all elements.
2166
- * @param weights - Array of weights (must be same shape as array along specified axis)
2167
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2168
- * @returns Weighted average value(s)
2169
- */
2170
- export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number | Complex;
2171
- /**
2172
- * Return the sum of array elements over a given axis, treating NaNs as zero.
2173
- * @param a - Input array
2174
- * @param axis - Axis along which to compute. If undefined, use all elements.
2175
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2176
- * @returns Sum value(s)
2177
- */
2178
- export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2179
- /**
2180
- * Return the product of array elements over a given axis, treating NaNs as one.
2181
- * @param a - Input array
2182
- * @param axis - Axis along which to compute. If undefined, use all elements.
2183
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2184
- * @returns Product value(s)
2185
- */
2186
- export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2187
- /**
2188
- * Compute the arithmetic mean along the specified axis, ignoring NaNs.
2189
- * @param a - Input array
2190
- * @param axis - Axis along which to compute. If undefined, use all elements.
2191
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2192
- * @returns Mean value(s)
2193
- */
2194
- export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2195
- /**
2196
- * Compute the variance along the specified axis, ignoring NaNs.
2197
- * @param a - Input array
2198
- * @param axis - Axis along which to compute. If undefined, use all elements.
2199
- * @param ddof - Delta degrees of freedom (default 0)
2200
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2201
- * @returns Variance value(s)
2202
- */
2203
- export declare function nanvar(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
2204
- /**
2205
- * Compute the standard deviation along the specified axis, ignoring NaNs.
2206
- * @param a - Input array
2207
- * @param axis - Axis along which to compute. If undefined, use all elements.
2208
- * @param ddof - Delta degrees of freedom (default 0)
2209
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2210
- * @returns Standard deviation value(s)
2211
- */
2212
- export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
2213
- /**
2214
- * Return minimum of an array, ignoring NaNs.
2215
- * @param a - Input array
2216
- * @param axis - Axis along which to compute. If undefined, use all elements.
2217
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2218
- * @returns Minimum value(s)
2219
- */
2220
- export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2221
- /**
2222
- * Return maximum of an array, ignoring NaNs.
2223
- * @param a - Input array
2224
- * @param axis - Axis along which to compute. If undefined, use all elements.
2225
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2226
- * @returns Maximum value(s)
2227
- */
2228
- export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2229
- /**
2230
- * Return indices of the minimum value, ignoring NaNs.
2231
- * @param a - Input array
2232
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2233
- * @returns Index/indices of minimum value(s)
2234
- */
2235
- export declare function nanargmin(a: NDArray, axis?: number): NDArray | number;
2236
- /**
2237
- * Return indices of the maximum value, ignoring NaNs.
2238
- * @param a - Input array
2239
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2240
- * @returns Index/indices of maximum value(s)
2241
- */
2242
- export declare function nanargmax(a: NDArray, axis?: number): NDArray | number;
2243
- /**
2244
- * Return cumulative sum of elements, treating NaNs as zero.
2245
- * @param a - Input array
2246
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2247
- * @returns Array with cumulative sums
2248
- */
2249
- export declare function nancumsum(a: NDArray, axis?: number): NDArray;
2250
- /**
2251
- * Return cumulative product of elements, treating NaNs as one.
2252
- * @param a - Input array
2253
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2254
- * @returns Array with cumulative products
2255
- */
2256
- export declare function nancumprod(a: NDArray, axis?: number): NDArray;
2257
- /**
2258
- * Compute the median, ignoring NaNs.
2259
- * @param a - Input array
2260
- * @param axis - Axis along which to compute. If undefined, use all elements.
2261
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2262
- * @returns Median value(s)
2263
- */
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;
2273
- /**
2274
- * Element-wise cube root
2275
- *
2276
- * @param x - Input array
2277
- * @returns Array with cube root of each element
2278
- */
2279
- export declare function cbrt(x: NDArray): NDArray;
2280
- /**
2281
- * Element-wise absolute value (always returns float)
2282
- *
2283
- * @param x - Input array
2284
- * @returns Array with absolute values as float
2285
- */
2286
- export declare function fabs(x: NDArray): NDArray;
2287
- /**
2288
- * Returns both quotient and remainder (floor divide and modulo)
2289
- *
2290
- * @param x - Dividend array
2291
- * @param y - Divisor (array or scalar)
2292
- * @returns Tuple of [quotient, remainder] arrays
2293
- */
2294
- export declare function divmod(x: NDArray, y: NDArray | number): [NDArray, NDArray];
2295
- /**
2296
- * Element-wise square (x**2)
2297
- *
2298
- * @param x - Input array
2299
- * @returns Array with squared values
2300
- */
2301
- export declare function square(x: NDArray): NDArray;
2302
- /**
2303
- * Element-wise remainder (same as mod)
2304
- *
2305
- * @param x - Dividend array
2306
- * @param y - Divisor (array or scalar)
2307
- * @returns Array with remainder values
2308
- */
2309
- export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
2310
- /**
2311
- * Heaviside step function
2312
- *
2313
- * @param x1 - Input array
2314
- * @param x2 - Value to use when x1 is 0
2315
- * @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
2316
- */
2317
- export declare function heaviside(x1: NDArray, x2: NDArray | number): NDArray;
2318
- /**
2319
- * First array raised to power of second, always promoting to float
2320
- * @param x1 - Base values
2321
- * @param x2 - Exponent values
2322
- * @returns Result in float64
2323
- */
2324
- export declare function float_power(x1: NDArray, x2: NDArray | number): NDArray;
2325
- /**
2326
- * Element-wise remainder of division (fmod)
2327
- * Unlike mod/remainder, fmod matches C fmod behavior
2328
- * @param x1 - Dividend
2329
- * @param x2 - Divisor
2330
- * @returns Remainder
2331
- */
2332
- export declare function fmod(x1: NDArray, x2: NDArray | number): NDArray;
2333
- /**
2334
- * Decompose floating point numbers into mantissa and exponent
2335
- * Returns [mantissa, exponent] where x = mantissa * 2^exponent
2336
- * @param x - Input array
2337
- * @returns Tuple of [mantissa, exponent] arrays
2338
- */
2339
- export declare function frexp(x: NDArray): [NDArray, NDArray];
2340
- /**
2341
- * Greatest common divisor
2342
- * @param x1 - First array
2343
- * @param x2 - Second array or scalar
2344
- * @returns GCD
2345
- */
2346
- export declare function gcd(x1: NDArray, x2: NDArray | number): NDArray;
2347
- /**
2348
- * Least common multiple
2349
- * @param x1 - First array
2350
- * @param x2 - Second array or scalar
2351
- * @returns LCM
2352
- */
2353
- export declare function lcm(x1: NDArray, x2: NDArray | number): NDArray;
2354
- /**
2355
- * Returns x1 * 2^x2, element-wise
2356
- * @param x1 - Mantissa
2357
- * @param x2 - Exponent
2358
- * @returns Result
2359
- */
2360
- export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
2361
- /**
2362
- * Return fractional and integral parts of array
2363
- * @param x - Input array
2364
- * @returns Tuple of [fractional, integral] arrays
2365
- */
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;
2477
- /**
2478
- * Bitwise AND element-wise
2479
- *
2480
- * @param x1 - First input array (must be integer type)
2481
- * @param x2 - Second input array or scalar (must be integer type)
2482
- * @returns Result of bitwise AND
2483
- */
2484
- export declare function bitwise_and(x1: NDArray, x2: NDArray | number): NDArray;
2485
- /**
2486
- * Bitwise OR element-wise
2487
- *
2488
- * @param x1 - First input array (must be integer type)
2489
- * @param x2 - Second input array or scalar (must be integer type)
2490
- * @returns Result of bitwise OR
2491
- */
2492
- export declare function bitwise_or(x1: NDArray, x2: NDArray | number): NDArray;
2493
- /**
2494
- * Bitwise XOR element-wise
2495
- *
2496
- * @param x1 - First input array (must be integer type)
2497
- * @param x2 - Second input array or scalar (must be integer type)
2498
- * @returns Result of bitwise XOR
2499
- */
2500
- export declare function bitwise_xor(x1: NDArray, x2: NDArray | number): NDArray;
2501
- /**
2502
- * Bitwise NOT (inversion) element-wise
2503
- *
2504
- * @param x - Input array (must be integer type)
2505
- * @returns Result of bitwise NOT
2506
- */
2507
- export declare function bitwise_not(x: NDArray): NDArray;
2508
- /**
2509
- * Invert (bitwise NOT) element-wise
2510
- * Alias for bitwise_not
2511
- *
2512
- * @param x - Input array (must be integer type)
2513
- * @returns Result of bitwise inversion
2514
- */
2515
- export declare function invert(x: NDArray): NDArray;
2516
- /**
2517
- * Left shift elements by positions
2518
- *
2519
- * @param x1 - Input array (must be integer type)
2520
- * @param x2 - Shift amount (array or scalar)
2521
- * @returns Result of left shift
2522
- */
2523
- export declare function left_shift(x1: NDArray, x2: NDArray | number): NDArray;
2524
- /**
2525
- * Right shift elements by positions
2526
- *
2527
- * @param x1 - Input array (must be integer type)
2528
- * @param x2 - Shift amount (array or scalar)
2529
- * @returns Result of right shift
2530
- */
2531
- export declare function right_shift(x1: NDArray, x2: NDArray | number): NDArray;
2532
- /**
2533
- * Pack binary values into uint8 array
2534
- *
2535
- * Packs the elements of a binary-valued array into bits in a uint8 array.
2536
- *
2537
- * @param a - Input array (values are interpreted as binary: 0 or non-zero)
2538
- * @param axis - The dimension over which bit-packing is done (default: -1)
2539
- * @param bitorder - Order of bits: 'big' or 'little' (default: 'big')
2540
- * @returns Packed uint8 array
2541
- */
2542
- export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | 'little'): NDArray;
2543
- /**
2544
- * Unpack uint8 array into binary values
2545
- *
2546
- * Unpacks elements of a uint8 array into a binary-valued output array.
2547
- *
2548
- * @param a - Input uint8 array
2549
- * @param axis - The dimension over which bit-unpacking is done (default: -1)
2550
- * @param count - Number of elements to unpack, or -1 for all (default: -1)
2551
- * @param bitorder - Order of bits: 'big' or 'little' (default: 'big')
2552
- * @returns Unpacked uint8 array of 0s and 1s
2553
- */
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;
2585
- /**
2586
- * Logical AND element-wise
2587
- *
2588
- * Returns a boolean array where each element is the logical AND
2589
- * of corresponding elements (non-zero = true, zero = false).
2590
- *
2591
- * @param x1 - First input array
2592
- * @param x2 - Second input array or scalar
2593
- * @returns Boolean result array
2594
- */
2595
- export declare function logical_and(x1: NDArray, x2: NDArray | number): NDArray;
2596
- /**
2597
- * Logical OR element-wise
2598
- *
2599
- * Returns a boolean array where each element is the logical OR
2600
- * of corresponding elements (non-zero = true, zero = false).
2601
- *
2602
- * @param x1 - First input array
2603
- * @param x2 - Second input array or scalar
2604
- * @returns Boolean result array
2605
- */
2606
- export declare function logical_or(x1: NDArray, x2: NDArray | number): NDArray;
2607
- /**
2608
- * Logical NOT element-wise
2609
- *
2610
- * Returns a boolean array where each element is the logical NOT
2611
- * of the input (non-zero = false, zero = true).
2612
- *
2613
- * @param x - Input array
2614
- * @returns Boolean result array
2615
- */
2616
- export declare function logical_not(x: NDArray): NDArray;
2617
- /**
2618
- * Logical XOR element-wise
2619
- *
2620
- * Returns a boolean array where each element is the logical XOR
2621
- * of corresponding elements (non-zero = true, zero = false).
2622
- *
2623
- * @param x1 - First input array
2624
- * @param x2 - Second input array or scalar
2625
- * @returns Boolean result array
2626
- */
2627
- export declare function logical_xor(x1: NDArray, x2: NDArray | number): NDArray;
2628
- /**
2629
- * Test element-wise for finiteness (not infinity and not NaN)
2630
- *
2631
- * @param x - Input array
2632
- * @returns Boolean array where True means finite
2633
- */
2634
- export declare function isfinite(x: NDArray): NDArray;
2635
- /**
2636
- * Test element-wise for positive or negative infinity
2637
- *
2638
- * @param x - Input array
2639
- * @returns Boolean array where True means infinite
2640
- */
2641
- export declare function isinf(x: NDArray): NDArray;
2642
- /**
2643
- * Test element-wise for NaN (Not a Number)
2644
- *
2645
- * @param x - Input array
2646
- * @returns Boolean array where True means NaN
2647
- */
2648
- export declare function isnan(x: NDArray): NDArray;
2649
- /**
2650
- * Test element-wise for NaT (Not a Time)
2651
- *
2652
- * @param x - Input array
2653
- * @returns Boolean array (always false without datetime support)
2654
- */
2655
- export declare function isnat(x: NDArray): NDArray;
2656
- /**
2657
- * Change the sign of x1 to that of x2, element-wise
2658
- *
2659
- * Returns a value with the magnitude of x1 and the sign of x2.
2660
- *
2661
- * @param x1 - Values to change sign of (magnitude source)
2662
- * @param x2 - Values whose sign is used (sign source)
2663
- * @returns Array with magnitude from x1 and sign from x2
2664
- */
2665
- export declare function copysign(x1: NDArray, x2: NDArray | number): NDArray;
2666
- /**
2667
- * Returns element-wise True where signbit is set (less than zero)
2668
- *
2669
- * @param x - Input array
2670
- * @returns Boolean array where True means signbit is set
2671
- */
2672
- export declare function signbit(x: NDArray): NDArray;
2673
- /**
2674
- * Return the next floating-point value after x1 towards x2, element-wise
2675
- *
2676
- * @param x1 - Values to find the next representable value of
2677
- * @param x2 - Direction to look for the next representable value
2678
- * @returns Array of next representable values
2679
- */
2680
- export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
2681
- /**
2682
- * Return the distance between x and the nearest adjacent number
2683
- *
2684
- * @param x - Input array
2685
- * @returns Array of spacing values
2686
- */
2687
- export declare function spacing(x: NDArray): NDArray;
2688
- /**
2689
- * Test element-wise for complex number.
2690
- *
2691
- * For complex arrays, returns true for elements with non-zero imaginary part.
2692
- * For real arrays, always returns false.
2693
- *
2694
- * @param x - Input array
2695
- * @returns Boolean array
2696
- */
2697
- export declare function iscomplex(x: NDArray): NDArray;
2698
- /**
2699
- * Check whether array is complex type.
2700
- *
2701
- * @param x - Input array
2702
- * @returns true if dtype is complex64 or complex128
2703
- */
2704
- export declare function iscomplexobj(x: NDArray): boolean;
2705
- /**
2706
- * Test element-wise for real number (not complex).
2707
- *
2708
- * For complex arrays, returns true for elements with zero imaginary part.
2709
- * For real arrays, always returns true.
2710
- *
2711
- * @param x - Input array
2712
- * @returns Boolean array
2713
- */
2714
- export declare function isreal(x: NDArray): NDArray;
2715
- /**
2716
- * Check whether array is real type (not complex).
2717
- *
2718
- * @param x - Input array
2719
- * @returns true if dtype is NOT complex64 or complex128
2720
- */
2721
- export declare function isrealobj(x: NDArray): boolean;
2722
- /**
2723
- * Return the real part of complex argument.
2724
- *
2725
- * For complex arrays, returns the real components.
2726
- * For real arrays, returns a copy of the input.
2727
- *
2728
- * @param x - Input array
2729
- * @returns Array with real parts
2730
- */
2731
- export declare function real(x: NDArray): NDArray;
2732
- /**
2733
- * Return the imaginary part of complex argument.
2734
- *
2735
- * For complex arrays, returns the imaginary components.
2736
- * For real arrays, returns zeros.
2737
- *
2738
- * @param x - Input array
2739
- * @returns Array with imaginary parts
2740
- */
2741
- export declare function imag(x: NDArray): NDArray;
2742
- /**
2743
- * Return the complex conjugate.
2744
- *
2745
- * For complex arrays, negates the imaginary part: (a + bi) -> (a - bi)
2746
- * For real arrays, returns a copy of the input.
2747
- *
2748
- * @param x - Input array
2749
- * @returns Complex conjugate array
2750
- */
2751
- export declare function conj(x: NDArray): NDArray;
2752
- export declare const conjugate: typeof conj;
2753
- /**
2754
- * Return the angle (phase) of complex argument.
2755
- *
2756
- * angle(z) = arctan2(imag(z), real(z))
2757
- *
2758
- * For real arrays, returns 0 for positive, pi for negative.
2759
- *
2760
- * @param x - Input array
2761
- * @param deg - Return angle in degrees if true (default: false, returns radians)
2762
- * @returns Array with angles in radians (or degrees)
2763
- */
2764
- export declare function angle(x: NDArray, deg?: boolean): NDArray;
2765
- /**
2766
- * Test element-wise for negative infinity
2767
- * @param x - Input array
2768
- * @returns Boolean array
2769
- */
2770
- export declare function isneginf(x: NDArray): NDArray;
2771
- /**
2772
- * Test element-wise for positive infinity
2773
- * @param x - Input array
2774
- * @returns Boolean array
2775
- */
2776
- export declare function isposinf(x: NDArray): NDArray;
2777
- /**
2778
- * Check if array is Fortran contiguous (column-major order)
2779
- * @param x - Input array
2780
- * @returns true if F-contiguous
2781
- */
2782
- export declare function isfortran(x: NDArray): boolean;
2783
- /**
2784
- * Returns array with complex parts close to zero set to real
2785
- * Since numpy-ts doesn't support complex numbers, returns copy
2786
- * @param x - Input array
2787
- * @param tol - Tolerance
2788
- * @returns Copy of input array
2789
- */
2790
- export declare function real_if_close(x: NDArray, tol?: number): NDArray;
2791
- /**
2792
- * Check if element is a scalar type
2793
- * @param val - Value to check
2794
- * @returns true if scalar
2795
- */
2796
- export declare function isscalar(val: unknown): boolean;
2797
- /**
2798
- * Check if object is iterable
2799
- * @param obj - Object to check
2800
- * @returns true if iterable
2801
- */
2802
- export declare function iterable(obj: unknown): boolean;
2803
- /**
2804
- * Check if dtype meets specified criteria
2805
- * @param dtype - Dtype to check
2806
- * @param kind - Kind of dtype ('b' bool, 'i' int, 'u' uint, 'f' float)
2807
- * @returns true if dtype matches kind
2808
- */
2809
- export declare function isdtype(dtype: DType, kind: string): boolean;
2810
- /**
2811
- * Find the dtype that can represent both input dtypes
2812
- * @param dtype1 - First dtype
2813
- * @param dtype2 - Second dtype
2814
- * @returns Promoted dtype
2815
- */
2816
- export declare function promote_types(dtype1: DType, dtype2: DType): DType;
2817
- /**
2818
- * Einstein summation convention
2819
- *
2820
- * Performs tensor contractions and reductions using Einstein notation.
2821
- *
2822
- * @param subscripts - Einstein summation subscripts (e.g., 'ij,jk->ik')
2823
- * @param operands - Input arrays
2824
- * @returns Result of the Einstein summation
2825
- *
2826
- * @example
2827
- * // Matrix multiplication
2828
- * einsum('ij,jk->ik', a, b)
2829
- *
2830
- * @example
2831
- * // Inner product
2832
- * einsum('i,i->', a, b)
2833
- *
2834
- * @example
2835
- * // Trace
2836
- * einsum('ii->', a)
2837
- */
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;
2904
- /**
2905
- * numpy.linalg module - Linear algebra functions
2906
- */
2907
- export declare const linalg: {
2908
- /**
2909
- * Cross product of two vectors.
2910
- */
2911
- cross: (a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number, axis?: number) => NDArray | number;
2912
- /**
2913
- * Compute the norm of a vector or matrix.
2914
- */
2915
- norm: (x: NDArray, ord?: number | "fro" | "nuc" | null, axis?: number | [number, number] | null, keepdims?: boolean) => NDArray | number;
2916
- /**
2917
- * Compute the vector norm.
2918
- */
2919
- vector_norm: (x: NDArray, ord?: number, axis?: number | null, keepdims?: boolean) => NDArray | number;
2920
- /**
2921
- * Compute the matrix norm.
2922
- */
2923
- matrix_norm: (x: NDArray, ord?: number | "fro" | "nuc", keepdims?: boolean) => NDArray | number;
2924
- /**
2925
- * QR decomposition.
2926
- */
2927
- qr: (a: NDArray, mode?: "reduced" | "complete" | "r" | "raw") => {
2928
- q: NDArray;
2929
- r: NDArray;
2930
- } | NDArray | {
2931
- h: NDArray;
2932
- tau: NDArray;
2933
- };
2934
- /**
2935
- * Cholesky decomposition.
2936
- */
2937
- cholesky: (a: NDArray, upper?: boolean) => NDArray;
2938
- /**
2939
- * Singular Value Decomposition.
2940
- */
2941
- svd: (a: NDArray, full_matrices?: boolean, compute_uv?: boolean) => {
2942
- u: NDArray;
2943
- s: NDArray;
2944
- vt: NDArray;
2945
- } | NDArray;
2946
- /**
2947
- * Compute the determinant of a matrix.
2948
- */
2949
- det: (a: NDArray) => number;
2950
- /**
2951
- * Compute the matrix inverse.
2952
- */
2953
- inv: (a: NDArray) => NDArray;
2954
- /**
2955
- * Solve a linear system.
2956
- */
2957
- solve: (a: NDArray, b: NDArray) => NDArray;
2958
- /**
2959
- * Least-squares solution to a linear matrix equation.
2960
- */
2961
- lstsq: (a: NDArray, b: NDArray, rcond?: number | null) => {
2962
- x: NDArray;
2963
- residuals: NDArray;
2964
- rank: number;
2965
- s: NDArray;
2966
- };
2967
- /**
2968
- * Compute the condition number.
2969
- */
2970
- cond: (a: NDArray, p?: number | "fro" | "nuc") => number;
2971
- /**
2972
- * Compute the matrix rank.
2973
- */
2974
- matrix_rank: (a: NDArray, tol?: number) => number;
2975
- /**
2976
- * Raise a square matrix to an integer power.
2977
- */
2978
- matrix_power: (a: NDArray, n: number) => NDArray;
2979
- /**
2980
- * Compute the Moore-Penrose pseudo-inverse.
2981
- */
2982
- pinv: (a: NDArray, rcond?: number) => NDArray;
2983
- /**
2984
- * Compute eigenvalues and eigenvectors.
2985
- */
2986
- eig: (a: NDArray) => {
2987
- w: NDArray;
2988
- v: NDArray;
2989
- };
2990
- /**
2991
- * Compute eigenvalues and eigenvectors of a Hermitian matrix.
2992
- */
2993
- eigh: (a: NDArray, UPLO?: "L" | "U") => {
2994
- w: NDArray;
2995
- v: NDArray;
2996
- };
2997
- /**
2998
- * Compute eigenvalues of a matrix.
2999
- */
3000
- eigvals: (a: NDArray) => NDArray;
3001
- /**
3002
- * Compute eigenvalues of a Hermitian matrix.
3003
- */
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;
3056
- };
3057
- /**
3058
- * Take values from the input array by matching 1d index and data slices along axis.
3059
- *
3060
- * @param arr - Input array
3061
- * @param indices - Index array with same ndim as arr
3062
- * @param axis - The axis along which to select values
3063
- * @returns Array of values taken along the axis
3064
- */
3065
- export declare function take_along_axis(arr: NDArray, indices: NDArray, axis: number): NDArray;
3066
- /**
3067
- * Put values into the destination array using 1d index and data slices along axis.
3068
- *
3069
- * @param arr - Destination array (modified in-place)
3070
- * @param indices - Index array with same ndim as arr
3071
- * @param values - Values to put
3072
- * @param axis - The axis along which to put values
3073
- */
3074
- export declare function put_along_axis(arr: NDArray, indices: NDArray, values: NDArray, axis: number): void;
3075
- /**
3076
- * Change elements of array based on conditional mask.
3077
- *
3078
- * @param a - Array to modify (in-place)
3079
- * @param mask - Boolean mask array
3080
- * @param values - Values to put where mask is True
3081
- */
3082
- export declare function putmask(a: NDArray, mask: NDArray, values: NDArray | number | bigint): void;
3083
- /**
3084
- * Return selected slices of array along given axis.
3085
- *
3086
- * @param condition - Boolean array for selecting
3087
- * @param a - Array from which to select
3088
- * @param axis - Axis along which to select (if undefined, works on flattened array)
3089
- * @returns Compressed array
3090
- */
3091
- export declare function compress(condition: NDArray, a: NDArray, axis?: number): NDArray;
3092
- /**
3093
- * Return an array drawn from elements in choicelist, depending on conditions.
3094
- *
3095
- * @param condlist - List of boolean arrays (conditions)
3096
- * @param choicelist - List of arrays to choose from
3097
- * @param defaultVal - Default value when no condition is met (default 0)
3098
- * @returns Array with selected values
3099
- */
3100
- export declare function select(condlist: NDArray[], choicelist: NDArray[], defaultVal?: number | bigint): NDArray;
3101
- /**
3102
- * Change elements of an array based on conditional and input values.
3103
- *
3104
- * @param arr - Array to modify (in-place)
3105
- * @param mask - Boolean mask array
3106
- * @param vals - Values to place where mask is True (cycles if shorter)
3107
- */
3108
- export declare function place(arr: NDArray, mask: NDArray, vals: NDArray): void;
3109
- /**
3110
- * Fill the main diagonal of a given array (modifies in-place)
3111
- * @param a - Array (at least 2D)
3112
- * @param val - Value or array of values to fill diagonal with
3113
- * @param wrap - Whether to wrap for tall matrices
3114
- */
3115
- export declare function fill_diagonal(a: NDArray, val: NDArray | number, wrap?: boolean): void;
3116
- /**
3117
- * Return the indices to access the main diagonal of an array.
3118
- *
3119
- * @param n - Size of arrays for which indices are returned
3120
- * @param ndim - Number of dimensions (default 2)
3121
- * @returns Tuple of index arrays
3122
- */
3123
- export declare function diag_indices(n: number, ndim?: number): NDArray[];
3124
- /**
3125
- * Return the indices to access the main diagonal of an n-dimensional array.
3126
- *
3127
- * @param arr - Input array (must have all equal dimensions)
3128
- * @returns Tuple of index arrays
3129
- */
3130
- export declare function diag_indices_from(arr: NDArray): NDArray[];
3131
- /**
3132
- * Return the indices for the lower-triangle of an (n, m) array.
3133
- *
3134
- * @param n - Number of rows
3135
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
3136
- * @param m - Number of columns (default n)
3137
- * @returns Tuple of row and column index arrays
3138
- */
3139
- export declare function tril_indices(n: number, k?: number, m?: number): NDArray[];
3140
- /**
3141
- * Return the indices for the lower-triangle of arr.
3142
- *
3143
- * @param arr - Input 2-D array
3144
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
3145
- * @returns Tuple of row and column index arrays
3146
- */
3147
- export declare function tril_indices_from(arr: NDArray, k?: number): NDArray[];
3148
- /**
3149
- * Return the indices for the upper-triangle of an (n, m) array.
3150
- *
3151
- * @param n - Number of rows
3152
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
3153
- * @param m - Number of columns (default n)
3154
- * @returns Tuple of row and column index arrays
3155
- */
3156
- export declare function triu_indices(n: number, k?: number, m?: number): NDArray[];
3157
- /**
3158
- * Return the indices for the upper-triangle of arr.
3159
- *
3160
- * @param arr - Input 2-D array
3161
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
3162
- * @returns Tuple of row and column index arrays
3163
- */
3164
- export declare function triu_indices_from(arr: NDArray, k?: number): NDArray[];
3165
- /**
3166
- * Return the indices to access (n, n) arrays, given a masking function.
3167
- *
3168
- * @param n - The returned indices will be valid to access arrays of shape (n, n)
3169
- * @param mask_func - A function that generates an (n, n) boolean mask
3170
- * @param k - Optional diagonal offset passed to mask_func
3171
- * @returns Tuple of row and column index arrays
3172
- */
3173
- export declare function mask_indices(n: number, mask_func: (n: number, k: number) => NDArray, k?: number): NDArray[];
3174
- /**
3175
- * Return an array representing the indices of a grid.
3176
- *
3177
- * @param dimensions - The shape of the grid
3178
- * @param dtype - Data type of result (default 'int32')
3179
- * @returns Array of shape (len(dimensions), *dimensions)
3180
- */
3181
- export declare function indices(dimensions: number[], dtype?: 'int32' | 'int64' | 'float64'): NDArray;
3182
- /**
3183
- * Construct an open mesh from multiple sequences.
3184
- *
3185
- * This function returns a list of arrays with shapes suitable for broadcasting.
3186
- *
3187
- * @param args - 1-D sequences
3188
- * @returns Tuple of arrays for open mesh
3189
- */
3190
- export declare function ix_(...args: NDArray[]): NDArray[];
3191
- /**
3192
- * Convert a tuple of index arrays into an array of flat indices.
3193
- *
3194
- * @param multi_index - Tuple of index arrays
3195
- * @param dims - Shape of array into which indices apply
3196
- * @param mode - How to handle out-of-bounds indices ('raise', 'wrap', 'clip')
3197
- * @returns Flattened indices
3198
- */
3199
- export declare function ravel_multi_index(multi_index: NDArray[], dims: number[], mode?: 'raise' | 'wrap' | 'clip'): NDArray;
3200
- /**
3201
- * Convert a flat index or array of flat indices into a tuple of coordinate arrays.
3202
- *
3203
- * @param indices - Array of indices or single index
3204
- * @param shape - Shape of the array to index into
3205
- * @param order - Row-major ('C') or column-major ('F') order
3206
- * @returns Tuple of coordinate arrays
3207
- */
3208
- export declare function unravel_index(indices: NDArray | number, shape: number[], order?: 'C' | 'F'): NDArray[];
3209
- /**
3210
- * Return a sorted copy of an array
3211
- * @param a - Input array
3212
- * @param axis - Axis along which to sort. Default is -1 (last axis)
3213
- * @returns Sorted array
3214
- */
3215
- export declare function sort(a: NDArray, axis?: number): NDArray;
3216
- /**
3217
- * Returns the indices that would sort an array
3218
- * @param a - Input array
3219
- * @param axis - Axis along which to sort. Default is -1 (last axis)
3220
- * @returns Array of indices that sort the input array
3221
- */
3222
- export declare function argsort(a: NDArray, axis?: number): NDArray;
3223
- /**
3224
- * Perform an indirect stable sort using a sequence of keys
3225
- * @param keys - Array of NDArrays, the last key is the primary sort key
3226
- * @returns Array of indices that would sort the keys
3227
- */
3228
- export declare function lexsort(keys: NDArray[]): NDArray;
3229
- /**
3230
- * Partially sort an array
3231
- * @param a - Input array
3232
- * @param kth - Element index to partition by
3233
- * @param axis - Axis along which to sort. Default is -1 (last axis)
3234
- * @returns Partitioned array
3235
- */
3236
- export declare function partition(a: NDArray, kth: number, axis?: number): NDArray;
3237
- /**
3238
- * Returns indices that would partition an array
3239
- * @param a - Input array
3240
- * @param kth - Element index to partition by
3241
- * @param axis - Axis along which to sort. Default is -1 (last axis)
3242
- * @returns Array of indices
3243
- */
3244
- export declare function argpartition(a: NDArray, kth: number, axis?: number): NDArray;
3245
- /**
3246
- * Sort a complex array using the real part first, then the imaginary part
3247
- * For real arrays, returns a sorted 1D array
3248
- * @param a - Input array
3249
- * @returns Sorted 1D array
3250
- */
3251
- export declare function sort_complex(a: NDArray): NDArray;
3252
- /**
3253
- * Return the indices of the elements that are non-zero
3254
- * @param a - Input array
3255
- * @returns Tuple of arrays, one for each dimension
3256
- */
3257
- export declare function nonzero(a: NDArray): NDArray[];
3258
- /**
3259
- * Find the indices of array elements that are non-zero, grouped by element
3260
- * Returns a 2D array where each row is the index of a non-zero element.
3261
- * This is equivalent to transpose(nonzero(a)).
3262
- * @param a - Input array
3263
- * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
3264
- */
3265
- export declare function argwhere(a: NDArray): NDArray;
3266
- /**
3267
- * Return indices of non-zero elements in flattened array
3268
- * @param a - Input array
3269
- * @returns Array of indices
3270
- */
3271
- export declare function flatnonzero(a: NDArray): NDArray;
3272
- /**
3273
- * Return elements from x or y depending on condition
3274
- * If only condition is given, returns indices where condition is true (like nonzero)
3275
- * @param condition - Boolean array or condition
3276
- * @param x - Values where condition is true (optional)
3277
- * @param y - Values where condition is false (optional)
3278
- * @returns Array with elements chosen from x or y, or indices if only condition given
3279
- */
3280
- export declare function where(condition: NDArray, x?: NDArray, y?: NDArray): NDArray | NDArray[];
3281
- /**
3282
- * Find indices where elements should be inserted to maintain order
3283
- * @param a - Input array (must be sorted in ascending order)
3284
- * @param v - Values to insert
3285
- * @param side - 'left' or 'right' side to insert
3286
- * @returns Indices where values should be inserted
3287
- */
3288
- export declare function searchsorted(a: NDArray, v: NDArray, side?: 'left' | 'right'): NDArray;
3289
- /**
3290
- * Return the elements of an array that satisfy some condition
3291
- * @param condition - Boolean array
3292
- * @param a - Input array
3293
- * @returns 1D array of elements where condition is true
3294
- */
3295
- export declare function extract(condition: NDArray, a: NDArray): NDArray;
3296
- /**
3297
- * Count number of non-zero values in the array
3298
- * @param a - Input array
3299
- * @param axis - Axis along which to count (optional)
3300
- * @returns Count of non-zero values
3301
- */
3302
- export declare function count_nonzero(a: NDArray, axis?: number): NDArray | number;
3303
- /**
3304
- * Round an array to the given number of decimals
3305
- * @param a - Input array
3306
- * @param decimals - Number of decimal places to round to (default: 0)
3307
- * @returns Rounded array
3308
- */
3309
- export declare function around(a: NDArray, decimals?: number): NDArray;
3310
- export { around as round_ };
3311
- /**
3312
- * Return the ceiling of the input, element-wise
3313
- * @param x - Input array
3314
- * @returns Element-wise ceiling
3315
- */
3316
- export declare function ceil(x: NDArray): NDArray;
3317
- /**
3318
- * Round to nearest integer towards zero
3319
- * @param x - Input array
3320
- * @returns Array with values truncated towards zero
3321
- */
3322
- export declare function fix(x: NDArray): NDArray;
3323
- /**
3324
- * Return the floor of the input, element-wise
3325
- * @param x - Input array
3326
- * @returns Element-wise floor
3327
- */
3328
- export declare function floor(x: NDArray): NDArray;
3329
- /**
3330
- * Round elements of the array to the nearest integer
3331
- * @param x - Input array
3332
- * @returns Array with rounded integer values
3333
- */
3334
- export declare function rint(x: NDArray): NDArray;
3335
- /**
3336
- * Evenly round to the given number of decimals (alias for around)
3337
- * @param a - Input array
3338
- * @param decimals - Number of decimal places to round to (default: 0)
3339
- * @returns Rounded array
3340
- */
3341
- export { around as round };
3342
- /**
3343
- * Return the truncated value of the input, element-wise
3344
- * @param x - Input array
3345
- * @returns Element-wise truncated values
3346
- */
3347
- export declare function trunc(x: NDArray): NDArray;
3348
- /**
3349
- * Find the unique elements of an array
3350
- * @param ar - Input array
3351
- * @param returnIndex - If True, also return the indices of the first occurrences
3352
- * @param returnInverse - If True, also return the indices to reconstruct the original array
3353
- * @param returnCounts - If True, also return the number of times each unique value appears
3354
- * @returns Unique sorted values, and optionally indices/inverse/counts
3355
- */
3356
- export declare function unique(ar: NDArray, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): NDArray | {
3357
- values: NDArray;
3358
- indices?: NDArray;
3359
- inverse?: NDArray;
3360
- counts?: NDArray;
3361
- };
3362
- /**
3363
- * Test whether each element of a 1-D array is also present in a second array
3364
- * @param ar1 - Input array
3365
- * @param ar2 - Test values
3366
- * @returns Boolean array indicating membership
3367
- */
3368
- export declare function in1d(ar1: NDArray, ar2: NDArray): NDArray;
3369
- /**
3370
- * Find the intersection of two arrays
3371
- * @param ar1 - First input array
3372
- * @param ar2 - Second input array
3373
- * @returns Sorted 1D array of common and unique elements
3374
- */
3375
- export declare function intersect1d(ar1: NDArray, ar2: NDArray): NDArray;
3376
- /**
3377
- * Test whether each element of an ND array is also present in a second array
3378
- * @param element - Input array
3379
- * @param testElements - Test values
3380
- * @returns Boolean array indicating membership (same shape as element)
3381
- */
3382
- export declare function isin(element: NDArray, testElements: NDArray): NDArray;
3383
- /**
3384
- * Find the set difference of two arrays
3385
- * @param ar1 - First input array
3386
- * @param ar2 - Second input array
3387
- * @returns Sorted 1D array of values in ar1 that are not in ar2
3388
- */
3389
- export declare function setdiff1d(ar1: NDArray, ar2: NDArray): NDArray;
3390
- /**
3391
- * Find the set exclusive-or of two arrays
3392
- * @param ar1 - First input array
3393
- * @param ar2 - Second input array
3394
- * @returns Sorted 1D array of values that are in only one array
3395
- */
3396
- export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
3397
- /**
3398
- * Find the union of two arrays
3399
- * @param ar1 - First input array
3400
- * @param ar2 - Second input array
3401
- * @returns Sorted 1D array of unique values from both arrays
3402
- */
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;
3453
- /**
3454
- * Calculate the n-th discrete difference along the given axis
3455
- * @param a - Input array
3456
- * @param n - Number of times values are differenced (default: 1)
3457
- * @param axis - Axis along which to compute difference (default: -1)
3458
- * @returns Array of differences
3459
- */
3460
- export declare function diff(a: NDArray, n?: number, axis?: number): NDArray;
3461
- /**
3462
- * The differences between consecutive elements of a flattened array
3463
- * @param ary - Input array
3464
- * @param to_end - Number(s) to append at the end
3465
- * @param to_begin - Number(s) to prepend at the beginning
3466
- * @returns Array of differences
3467
- */
3468
- export declare function ediff1d(ary: NDArray, to_end?: number[] | null, to_begin?: number[] | null): NDArray;
3469
- /**
3470
- * Return the gradient of an N-dimensional array
3471
- * The gradient is computed using second order accurate central differences
3472
- * in the interior and first order accurate one-sided differences at the boundaries.
3473
- * @param f - Input array
3474
- * @param varargs - Spacing between values (scalar or array per dimension)
3475
- * @param axis - Axis or axes along which to compute gradient
3476
- * @returns Array of gradients (one per axis) or single gradient
3477
- */
3478
- export declare function gradient(f: NDArray, varargs?: number | number[], axis?: number | number[] | null): NDArray | NDArray[];
3479
- /**
3480
- * Return the cross product of two (arrays of) vectors
3481
- * @param a - First input array
3482
- * @param b - Second input array
3483
- * @param axisa - Axis of a that defines the vector(s) (default: -1)
3484
- * @param axisb - Axis of b that defines the vector(s) (default: -1)
3485
- * @param axisc - Axis of c containing the cross product (default: -1)
3486
- * @returns Cross product array
3487
- */
3488
- export declare function cross(a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number): NDArray;
3489
- /**
3490
- * Count number of occurrences of each value in array of non-negative ints.
3491
- *
3492
- * @param x - Input array (must contain non-negative integers)
3493
- * @param weights - Optional weights, same shape as x
3494
- * @param minlength - Minimum number of bins for output (default: 0)
3495
- * @returns Array of bin counts
3496
- */
3497
- export declare function bincount(x: NDArray, weights?: NDArray, minlength?: number): NDArray;
3498
- /**
3499
- * Return the indices of the bins to which each value in input array belongs.
3500
- *
3501
- * @param x - Input array to be binned
3502
- * @param bins - Array of bins (monotonically increasing or decreasing)
3503
- * @param right - If true, intervals are closed on the right (default: false)
3504
- * @returns Array of bin indices
3505
- */
3506
- export declare function digitize(x: NDArray, bins: NDArray, right?: boolean): NDArray;
3507
- /**
3508
- * Compute the histogram of a set of data.
3509
- *
3510
- * @param a - Input data (flattened if not 1D)
3511
- * @param bins - Number of bins (default: 10) or array of bin edges
3512
- * @param range - Lower and upper range of bins
3513
- * @param density - If true, return probability density function (default: false)
3514
- * @param weights - Optional weights for each data point
3515
- * @returns Tuple of [hist, bin_edges]
3516
- */
3517
- export declare function histogram(a: NDArray, bins?: number | NDArray, range?: [number, number], density?: boolean, weights?: NDArray): [NDArray, NDArray];
3518
- /**
3519
- * Compute the bi-dimensional histogram of two data samples.
3520
- *
3521
- * @param x - Array of x coordinates
3522
- * @param y - Array of y coordinates (must have same length as x)
3523
- * @param bins - Number of bins or [nx, ny] or [x_edges, y_edges]
3524
- * @param range - [[xmin, xmax], [ymin, ymax]]
3525
- * @param density - If true, return probability density function
3526
- * @param weights - Optional weights for each data point
3527
- * @returns Tuple of [hist, x_edges, y_edges]
3528
- */
3529
- 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];
3530
- /**
3531
- * Compute the multidimensional histogram of some data.
3532
- *
3533
- * @param sample - Array of shape (N, D) where N is number of samples and D is number of dimensions
3534
- * @param bins - Number of bins for all axes, or array of bin counts per axis
3535
- * @param range - Array of [min, max] for each dimension
3536
- * @param density - If true, return probability density function
3537
- * @param weights - Optional weights for each sample
3538
- * @returns Tuple of [hist, edges (array of edge arrays)]
3539
- */
3540
- export declare function histogramdd(sample: NDArray, bins?: number | number[], range?: [number, number][], density?: boolean, weights?: NDArray): [NDArray, NDArray[]];
3541
- /**
3542
- * Cross-correlation of two 1-dimensional sequences.
3543
- *
3544
- * @param a - First input sequence
3545
- * @param v - Second input sequence
3546
- * @param mode - 'full', 'same', or 'valid' (default: 'full')
3547
- * @returns Cross-correlation of a and v
3548
- */
3549
- export declare function correlate(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
3550
- /**
3551
- * Discrete, linear convolution of two one-dimensional sequences.
3552
- *
3553
- * @param a - First input sequence
3554
- * @param v - Second input sequence
3555
- * @param mode - 'full', 'same', or 'valid' (default: 'full')
3556
- * @returns Convolution of a and v
3557
- */
3558
- export declare function convolve(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
3559
- /**
3560
- * Estimate a covariance matrix.
3561
- *
3562
- * @param m - Input array (1D or 2D). Each row represents a variable, columns are observations.
3563
- * @param y - Optional second array (for 2 variable case)
3564
- * @param rowvar - If true, each row is a variable (default: true)
3565
- * @param bias - If true, use N for normalization; if false, use N-1 (default: false)
3566
- * @param ddof - Delta degrees of freedom (overrides bias if provided)
3567
- * @returns Covariance matrix
3568
- */
3569
- export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: boolean, ddof?: number): NDArray;
3570
- /**
3571
- * Return Pearson product-moment correlation coefficients.
3572
- *
3573
- * @param x - Input array (1D or 2D)
3574
- * @param y - Optional second array (for 2 variable case)
3575
- * @param rowvar - If true, each row is a variable (default: true)
3576
- * @returns Correlation coefficient matrix
3577
- */
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;
3923
- //# sourceMappingURL=ndarray.d.ts.map