numpy-ts 0.11.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 (145) hide show
  1. package/README.md +29 -25
  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 +67 -2
  84. package/dist/types/{ops → common/ops}/arithmetic.d.ts +100 -1
  85. package/dist/types/{ops → common/ops}/bitwise.d.ts +31 -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 +148 -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 +10 -2
  97. package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
  98. package/dist/types/common/ops/sets.d.ts +87 -0
  99. package/dist/types/{ops → common/ops}/shape.d.ts +14 -1
  100. package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
  101. package/dist/types/{ops → common/ops}/statistics.d.ts +23 -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 +31 -30
  139. package/dist/numpy-ts.esm.js +0 -2
  140. package/dist/types/core/ndarray.d.ts +0 -3166
  141. package/dist/types/ops/random.d.ts +0 -136
  142. package/dist/types/ops/sets.d.ts +0 -38
  143. /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
  144. /package/dist/types/{core → common}/dtype.d.ts +0 -0
  145. /package/dist/types/{core → common}/slicing.d.ts +0 -0
@@ -1,3166 +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
- * Return the indices of the minimum values, ignoring NaNs
697
- * @param axis - Axis along which to find minimum indices. If undefined, index of global minimum.
698
- * @returns Indices of minimum values ignoring NaNs
699
- */
700
- nanargmin(axis?: number): NDArray | number;
701
- /**
702
- * Return the indices of the maximum values, ignoring NaNs
703
- * @param axis - Axis along which to find maximum indices. If undefined, index of global maximum.
704
- * @returns Indices of maximum values ignoring NaNs
705
- */
706
- nanargmax(axis?: number): NDArray | number;
707
- /**
708
- * Return the cumulative sum of elements, treating NaNs as zero
709
- * @param axis - Axis along which to compute cumsum. If undefined, compute over flattened array.
710
- * @returns Array with cumulative sums ignoring NaNs
711
- */
712
- nancumsum(axis?: number): NDArray;
713
- /**
714
- * Return the cumulative product of elements, treating NaNs as one
715
- * @param axis - Axis along which to compute cumprod. If undefined, compute over flattened array.
716
- * @returns Array with cumulative products ignoring NaNs
717
- */
718
- nancumprod(axis?: number): NDArray;
719
- /**
720
- * Compute the median, ignoring NaNs
721
- * @param axis - Axis along which to compute median. If undefined, compute over all elements.
722
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
723
- * @returns Median of array elements ignoring NaNs
724
- */
725
- nanmedian(axis?: number, keepdims?: boolean): NDArray | number;
726
- /**
727
- * Return a sorted copy of the array
728
- * @param axis - Axis along which to sort. Default is -1 (last axis)
729
- * @returns Sorted array
730
- */
731
- sort(axis?: number): NDArray;
732
- /**
733
- * Returns the indices that would sort this array
734
- * @param axis - Axis along which to sort. Default is -1 (last axis)
735
- * @returns Array of indices that sort the array
736
- */
737
- argsort(axis?: number): NDArray;
738
- /**
739
- * Partially sort the array
740
- * @param kth - Element index to partition by
741
- * @param axis - Axis along which to sort. Default is -1 (last axis)
742
- * @returns Partitioned array
743
- */
744
- partition(kth: number, axis?: number): NDArray;
745
- /**
746
- * Returns indices that would partition the array
747
- * @param kth - Element index to partition by
748
- * @param axis - Axis along which to sort. Default is -1 (last axis)
749
- * @returns Array of indices
750
- */
751
- argpartition(kth: number, axis?: number): NDArray;
752
- /**
753
- * Return the indices of non-zero elements
754
- * @returns Tuple of arrays, one for each dimension
755
- */
756
- nonzero(): NDArray[];
757
- /**
758
- * Find the indices of array elements that are non-zero, grouped by element
759
- * Returns a 2D array where each row is the index of a non-zero element.
760
- * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
761
- */
762
- argwhere(): NDArray;
763
- /**
764
- * Find indices where elements should be inserted to maintain order
765
- * @param v - Values to insert
766
- * @param side - 'left' or 'right' side to insert
767
- * @returns Indices where values should be inserted
768
- */
769
- searchsorted(v: NDArray, side?: 'left' | 'right'): NDArray;
770
- /**
771
- * Calculate the n-th discrete difference along the given axis
772
- * @param n - Number of times values are differenced (default: 1)
773
- * @param axis - Axis along which to compute difference (default: -1)
774
- * @returns Array of differences
775
- */
776
- diff(n?: number, axis?: number): NDArray;
777
- /**
778
- * Reshape array to a new shape
779
- * Returns a new array with the specified shape
780
- * @param shape - New shape (must be compatible with current size)
781
- * @returns Reshaped array
782
- */
783
- reshape(...shape: number[]): NDArray;
784
- /**
785
- * Return a flattened copy of the array
786
- * @returns 1D array containing all elements
787
- */
788
- flatten(): NDArray;
789
- /**
790
- * Return a flattened array (view when possible, otherwise copy)
791
- * @returns 1D array containing all elements
792
- */
793
- ravel(): NDArray;
794
- /**
795
- * Transpose array (permute dimensions)
796
- * @param axes - Permutation of axes. If undefined, reverse the dimensions
797
- * @returns Transposed array (always a view)
798
- */
799
- transpose(axes?: number[]): NDArray;
800
- /**
801
- * Remove axes of length 1
802
- * @param axis - Axis to squeeze. If undefined, squeeze all axes of length 1
803
- * @returns Array with specified dimensions removed (always a view)
804
- */
805
- squeeze(axis?: number): NDArray;
806
- /**
807
- * Expand the shape by inserting a new axis of length 1
808
- * @param axis - Position where new axis is placed
809
- * @returns Array with additional dimension (always a view)
810
- */
811
- expand_dims(axis: number): NDArray;
812
- /**
813
- * Swap two axes of an array
814
- * @param axis1 - First axis
815
- * @param axis2 - Second axis
816
- * @returns Array with swapped axes (always a view)
817
- */
818
- swapaxes(axis1: number, axis2: number): NDArray;
819
- /**
820
- * Move axes to new positions
821
- * @param source - Original positions of axes to move
822
- * @param destination - New positions for axes
823
- * @returns Array with moved axes (always a view)
824
- */
825
- moveaxis(source: number | number[], destination: number | number[]): NDArray;
826
- /**
827
- * Repeat elements of an array
828
- * @param repeats - Number of repetitions for each element
829
- * @param axis - Axis along which to repeat (if undefined, flattens first)
830
- * @returns New array with repeated elements
831
- */
832
- repeat(repeats: number | number[], axis?: number): NDArray;
833
- /**
834
- * Take elements from array along an axis
835
- * @param indices - Indices of elements to take
836
- * @param axis - Axis along which to take (if undefined, flattens first)
837
- * @returns New array with selected elements
838
- */
839
- take(indices: number[], axis?: number): NDArray;
840
- /**
841
- * Put values at specified indices (modifies array in-place)
842
- * @param indices - Indices at which to place values
843
- * @param values - Values to put
844
- */
845
- put(indices: number[], values: NDArray | number | bigint): void;
846
- /**
847
- * Integer array indexing (fancy indexing)
848
- *
849
- * Select elements using an array of indices. This is NumPy's "fancy indexing"
850
- * feature: `arr[[0, 2, 4]]` becomes `arr.iindex([0, 2, 4])` or `arr.iindex(indices)`.
851
- *
852
- * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
853
- * @param axis - Axis along which to index (default: 0, or flattens if undefined with flat indices)
854
- * @returns New array with selected elements
855
- *
856
- * @example
857
- * ```typescript
858
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
859
- *
860
- * // Select rows 0 and 2
861
- * arr.iindex([0, 2]); // [[1, 2, 3], [7, 8, 9]]
862
- *
863
- * // Select along axis 1 (columns)
864
- * arr.iindex([0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
865
- *
866
- * // With NDArray indices
867
- * const idx = np.array([0, 2]);
868
- * arr.iindex(idx); // [[1, 2, 3], [7, 8, 9]]
869
- * ```
870
- */
871
- iindex(indices: NDArray | number[] | number[][], axis?: number): NDArray;
872
- /**
873
- * Boolean array indexing (fancy indexing with mask)
874
- *
875
- * Select elements where a boolean mask is true. This is NumPy's boolean
876
- * indexing: `arr[arr > 5]` becomes `arr.bindex(arr.greater(5))`.
877
- *
878
- * @param mask - Boolean NDArray mask
879
- * @param axis - Axis along which to apply the mask (default: flattens array)
880
- * @returns New 1D array with selected elements (or along axis if specified)
881
- *
882
- * @example
883
- * ```typescript
884
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
885
- *
886
- * // Select all elements > 5
887
- * const mask = arr.greater(5);
888
- * arr.bindex(mask); // [6, 7, 8, 9]
889
- *
890
- * // Select rows where first column > 3
891
- * const rowMask = np.array([false, true, true]);
892
- * arr.bindex(rowMask, 0); // [[4, 5, 6], [7, 8, 9]]
893
- * ```
894
- */
895
- bindex(mask: NDArray, axis?: number): NDArray;
896
- /**
897
- * Matrix multiplication
898
- * @param other - Array to multiply with
899
- * @returns Result of matrix multiplication
900
- */
901
- matmul(other: NDArray): NDArray;
902
- /**
903
- * Dot product (matching NumPy behavior)
904
- * @param other - Array to dot with
905
- * @returns Result of dot product (scalar or array depending on dimensions, Complex for complex arrays)
906
- */
907
- dot(other: NDArray): NDArray | number | bigint | Complex;
908
- /**
909
- * Sum of diagonal elements (trace)
910
- * @returns Sum of diagonal elements (Complex for complex arrays)
911
- */
912
- trace(): number | bigint | Complex;
913
- /**
914
- * Inner product (contracts over last axes of both arrays)
915
- * @param other - Array to compute inner product with
916
- * @returns Inner product result (Complex for complex arrays)
917
- */
918
- inner(other: NDArray): NDArray | number | bigint | Complex;
919
- /**
920
- * Outer product (flattens inputs then computes a[i]*b[j])
921
- * @param other - Array to compute outer product with
922
- * @returns 2D outer product matrix
923
- */
924
- outer(other: NDArray): NDArray;
925
- /**
926
- * Tensor dot product along specified axes
927
- * @param other - Array to contract with
928
- * @param axes - Axes to contract (integer or [a_axes, b_axes])
929
- * @returns Tensor dot product result
930
- */
931
- tensordot(other: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
932
- /**
933
- * Element-wise cube root
934
- * Promotes integer types to float64
935
- * @returns New array with cube root values
936
- */
937
- cbrt(): NDArray;
938
- /**
939
- * Element-wise absolute value (always returns float)
940
- * @returns New array with absolute values as float
941
- */
942
- fabs(): NDArray;
943
- /**
944
- * Returns both quotient and remainder (floor divide and modulo)
945
- * @param divisor - Array or scalar divisor
946
- * @returns Tuple of [quotient, remainder] arrays
947
- */
948
- divmod(divisor: NDArray | number): [NDArray, NDArray];
949
- /**
950
- * Element-wise square (x**2)
951
- * @returns New array with squared values
952
- */
953
- square(): NDArray;
954
- /**
955
- * Element-wise remainder (same as mod)
956
- * @param divisor - Array or scalar divisor
957
- * @returns New array with remainder values
958
- */
959
- remainder(divisor: NDArray | number): NDArray;
960
- /**
961
- * Heaviside step function
962
- * @param x2 - Value to use when this array element is 0
963
- * @returns New array with heaviside values
964
- */
965
- heaviside(x2: NDArray | number): NDArray;
966
- /**
967
- * Slice the array using NumPy-style string syntax
968
- *
969
- * @param sliceStrs - Slice specifications, one per dimension
970
- * @returns Sliced view of the array
971
- */
972
- slice(...sliceStrs: string[]): NDArray;
973
- /**
974
- * Get a single row (convenience method)
975
- * @param i - Row index
976
- * @returns Row as 1D or (n-1)D array
977
- */
978
- row(i: number): NDArray;
979
- /**
980
- * Get a single column (convenience method)
981
- * @param j - Column index
982
- * @returns Column as 1D or (n-1)D array
983
- */
984
- col(j: number): NDArray;
985
- /**
986
- * Get a range of rows (convenience method)
987
- * @param start - Start row index
988
- * @param stop - Stop row index (exclusive)
989
- * @returns Rows as array
990
- */
991
- rows(start: number, stop: number): NDArray;
992
- /**
993
- * Get a range of columns (convenience method)
994
- * @param start - Start column index
995
- * @param stop - Stop column index (exclusive)
996
- * @returns Columns as array
997
- */
998
- cols(start: number, stop: number): NDArray;
999
- /**
1000
- * String representation of the array
1001
- * @returns String describing the array shape and dtype
1002
- */
1003
- toString(): string;
1004
- /**
1005
- * Convert to nested JavaScript array
1006
- * @returns Nested JavaScript array representation
1007
- */
1008
- toArray(): any;
1009
- }
1010
- /**
1011
- * Create array of zeros
1012
- * @param shape - Shape of the array
1013
- * @param dtype - Data type (default: float64)
1014
- * @returns Array filled with zeros
1015
- */
1016
- export declare function zeros(shape: number[], dtype?: DType): NDArray;
1017
- /**
1018
- * Create array of ones
1019
- * @param shape - Shape of the array
1020
- * @param dtype - Data type (default: float64)
1021
- * @returns Array filled with ones
1022
- */
1023
- export declare function ones(shape: number[], dtype?: DType): NDArray;
1024
- /**
1025
- * Create array from nested JavaScript arrays
1026
- * @param data - Nested arrays or existing NDArray
1027
- * @param dtype - Data type (optional, will be inferred if not provided)
1028
- * @returns New NDArray
1029
- */
1030
- export declare function array(data: any, dtype?: DType): NDArray;
1031
- /**
1032
- * Create array with evenly spaced values within a given interval
1033
- * Similar to Python's range() but returns array
1034
- * @param start - Start value (or stop if only one argument)
1035
- * @param stop - Stop value (exclusive)
1036
- * @param step - Step between values (default: 1)
1037
- * @param dtype - Data type (default: float64)
1038
- * @returns Array of evenly spaced values
1039
- */
1040
- export declare function arange(start: number, stop?: number, step?: number, dtype?: DType): NDArray;
1041
- /**
1042
- * Create array with evenly spaced values over a specified interval
1043
- * @param start - Starting value
1044
- * @param stop - Ending value (inclusive)
1045
- * @param num - Number of samples (default: 50)
1046
- * @param dtype - Data type (default: float64)
1047
- * @returns Array of evenly spaced values
1048
- */
1049
- export declare function linspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
1050
- /**
1051
- * Create array with logarithmically spaced values
1052
- * Returns num samples, equally spaced on a log scale from base^start to base^stop
1053
- * @param start - base^start is the starting value
1054
- * @param stop - base^stop is the ending value
1055
- * @param num - Number of samples (default: 50)
1056
- * @param base - Base of the log space (default: 10.0)
1057
- * @param dtype - Data type (default: float64)
1058
- * @returns Array of logarithmically spaced values
1059
- */
1060
- export declare function logspace(start: number, stop: number, num?: number, base?: number, dtype?: DType): NDArray;
1061
- /**
1062
- * Create array with geometrically spaced values
1063
- * Returns num samples, equally spaced on a log scale (geometric progression)
1064
- * @param start - Starting value
1065
- * @param stop - Ending value
1066
- * @param num - Number of samples (default: 50)
1067
- * @param dtype - Data type (default: float64)
1068
- * @returns Array of geometrically spaced values
1069
- */
1070
- export declare function geomspace(start: number, stop: number, num?: number, dtype?: DType): NDArray;
1071
- /**
1072
- * Create identity matrix
1073
- * @param n - Number of rows
1074
- * @param m - Number of columns (default: n)
1075
- * @param k - Index of diagonal (0 for main diagonal, positive for upper, negative for lower)
1076
- * @param dtype - Data type (default: float64)
1077
- * @returns Identity matrix
1078
- */
1079
- export declare function eye(n: number, m?: number, k?: number, dtype?: DType): NDArray;
1080
- /**
1081
- * Create an uninitialized array
1082
- * Note: TypedArrays are zero-initialized by default in JavaScript
1083
- * @param shape - Shape of the array
1084
- * @param dtype - Data type (default: float64)
1085
- * @returns Uninitialized array
1086
- */
1087
- export declare function empty(shape: number[], dtype?: DType): NDArray;
1088
- /**
1089
- * Create array filled with a constant value
1090
- * @param shape - Shape of the array
1091
- * @param fill_value - Value to fill the array with
1092
- * @param dtype - Data type (optional, inferred from fill_value if not provided)
1093
- * @returns Array filled with the constant value
1094
- */
1095
- export declare function full(shape: number[], fill_value: number | bigint | boolean, dtype?: DType): NDArray;
1096
- /**
1097
- * Create a square identity matrix
1098
- * @param n - Size of the square matrix
1099
- * @param dtype - Data type (default: float64)
1100
- * @returns n×n identity matrix
1101
- */
1102
- export declare function identity(n: number, dtype?: DType): NDArray;
1103
- /**
1104
- * Convert input to an ndarray
1105
- * @param a - Input data (array-like or NDArray)
1106
- * @param dtype - Data type (optional)
1107
- * @returns NDArray representation of the input
1108
- */
1109
- export declare function asarray(a: NDArray | any, dtype?: DType): NDArray;
1110
- /**
1111
- * Create a deep copy of an array
1112
- * @param a - Array to copy
1113
- * @returns Deep copy of the array
1114
- */
1115
- export declare function copy(a: NDArray): NDArray;
1116
- /**
1117
- * Create array of zeros with the same shape as another array
1118
- * @param a - Array to match shape from
1119
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1120
- * @returns Array of zeros
1121
- */
1122
- export declare function zeros_like(a: NDArray, dtype?: DType): NDArray;
1123
- /**
1124
- * Create array of ones with the same shape as another array
1125
- * @param a - Array to match shape from
1126
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1127
- * @returns Array of ones
1128
- */
1129
- export declare function ones_like(a: NDArray, dtype?: DType): NDArray;
1130
- /**
1131
- * Create uninitialized array with the same shape as another array
1132
- * @param a - Array to match shape from
1133
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1134
- * @returns Uninitialized array
1135
- */
1136
- export declare function empty_like(a: NDArray, dtype?: DType): NDArray;
1137
- /**
1138
- * Create array filled with a constant value, same shape as another array
1139
- * @param a - Array to match shape from
1140
- * @param fill_value - Value to fill with
1141
- * @param dtype - Data type (optional, uses a's dtype if not provided)
1142
- * @returns Filled array
1143
- */
1144
- export declare function full_like(a: NDArray, fill_value: number | bigint | boolean, dtype?: DType): NDArray;
1145
- /**
1146
- * Convert input to an ndarray (alias for asarray for compatibility)
1147
- * In numpy-ts, this behaves the same as asarray since we don't have subclasses
1148
- * @param a - Input data
1149
- * @param dtype - Data type (optional)
1150
- * @returns NDArray
1151
- */
1152
- export declare function asanyarray(a: NDArray | any, dtype?: DType): NDArray;
1153
- /**
1154
- * Return a contiguous array (ndim >= 1) in memory (C order)
1155
- * Since our arrays are already C-contiguous in memory, this either
1156
- * returns the input unchanged or creates a contiguous copy
1157
- * @param a - Input data
1158
- * @param dtype - Data type (optional)
1159
- * @returns Contiguous array in C order
1160
- */
1161
- export declare function ascontiguousarray(a: NDArray | any, dtype?: DType): NDArray;
1162
- /**
1163
- * Return an array laid out in Fortran order in memory
1164
- * Note: numpy-ts uses C-order internally, so this creates a copy
1165
- * that is equivalent to the Fortran-ordered layout
1166
- * @param a - Input data
1167
- * @param dtype - Data type (optional)
1168
- * @returns Array (copy in C order, as Fortran order is not supported)
1169
- */
1170
- export declare function asfortranarray(a: NDArray | any, dtype?: DType): NDArray;
1171
- /**
1172
- * Extract a diagonal or construct a diagonal array
1173
- * @param v - Input array (if 2D, extract diagonal; if 1D, construct diagonal matrix)
1174
- * @param k - Diagonal offset (default 0 is main diagonal, positive above, negative below)
1175
- * @returns Diagonal elements as 1D array, or 2D diagonal matrix
1176
- */
1177
- export declare function diag(v: NDArray, k?: number): NDArray;
1178
- /**
1179
- * Create a 2-D array with the flattened input as a diagonal
1180
- * @param v - Input array (will be flattened)
1181
- * @param k - Diagonal offset (default 0)
1182
- * @returns 2D diagonal matrix
1183
- */
1184
- export declare function diagflat(v: NDArray, k?: number): NDArray;
1185
- /**
1186
- * Construct an array by executing a function over each coordinate
1187
- * @param fn - Function that takes coordinate indices and returns value
1188
- * @param shape - Shape of output array
1189
- * @param dtype - Data type (default: float64)
1190
- * @returns Array with values computed from function
1191
- */
1192
- export declare function fromfunction(fn: (...indices: number[]) => number | bigint | boolean, shape: number[], dtype?: DType): NDArray;
1193
- /**
1194
- * Return coordinate matrices from coordinate vectors
1195
- * @param arrays - 1D coordinate arrays
1196
- * @param indexing - 'xy' (Cartesian, default) or 'ij' (matrix indexing)
1197
- * @returns Array of coordinate grids
1198
- */
1199
- export declare function meshgrid(...args: (NDArray | {
1200
- indexing?: 'xy' | 'ij';
1201
- })[]): NDArray[];
1202
- /**
1203
- * An array with ones at and below the given diagonal and zeros elsewhere
1204
- * @param N - Number of rows
1205
- * @param M - Number of columns (default: N)
1206
- * @param k - Diagonal offset (default 0)
1207
- * @param dtype - Data type (default: float64)
1208
- * @returns Triangular array
1209
- */
1210
- export declare function tri(N: number, M?: number, k?: number, dtype?: DType): NDArray;
1211
- /**
1212
- * Lower triangle of an array
1213
- * @param m - Input array
1214
- * @param k - Diagonal above which to zero elements (default 0)
1215
- * @returns Copy with upper triangle zeroed
1216
- */
1217
- export declare function tril(m: NDArray, k?: number): NDArray;
1218
- /**
1219
- * Upper triangle of an array
1220
- * @param m - Input array
1221
- * @param k - Diagonal below which to zero elements (default 0)
1222
- * @returns Copy with lower triangle zeroed
1223
- */
1224
- export declare function triu(m: NDArray, k?: number): NDArray;
1225
- /**
1226
- * Generate a Vandermonde matrix
1227
- * @param x - Input 1D array
1228
- * @param N - Number of columns (default: length of x)
1229
- * @param increasing - Order of powers (default: false, highest powers first)
1230
- * @returns Vandermonde matrix
1231
- */
1232
- export declare function vander(x: NDArray, N?: number, increasing?: boolean): NDArray;
1233
- /**
1234
- * Interpret a buffer as a 1-dimensional array
1235
- * @param buffer - Buffer-like object (ArrayBuffer, TypedArray, or DataView)
1236
- * @param dtype - Data type (default: float64)
1237
- * @param count - Number of items to read (-1 means all)
1238
- * @param offset - Start reading from this byte offset
1239
- * @returns NDArray from buffer data
1240
- */
1241
- export declare function frombuffer(buffer: ArrayBuffer | ArrayBufferView, dtype?: DType, count?: number, offset?: number): NDArray;
1242
- /**
1243
- * Construct an array by executing a function over each coordinate.
1244
- * Note: This is a JS implementation - fromfile for actual files isn't directly applicable in browser JS.
1245
- * This function creates an array from an iterable or callable.
1246
- * @param file - In JS context, this is an iterable yielding values
1247
- * @param dtype - Data type
1248
- * @param count - Number of items to read (-1 means all)
1249
- * @returns NDArray from the iterable
1250
- */
1251
- export declare function fromfile(file: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
1252
- /**
1253
- * Create a new 1-dimensional array from an iterable object
1254
- * @param iter - Iterable object
1255
- * @param dtype - Data type
1256
- * @param count - Number of items to read (-1 means all)
1257
- * @returns NDArray from the iterable
1258
- */
1259
- export declare function fromiter(iter: Iterable<number | bigint>, dtype?: DType, count?: number): NDArray;
1260
- /**
1261
- * Create a new 1-dimensional array from text string
1262
- * @param string - Input string containing numbers separated by whitespace or separator
1263
- * @param dtype - Data type (default: float64)
1264
- * @param count - Number of items to read (-1 means all)
1265
- * @param sep - Separator between values (default: any whitespace)
1266
- * @returns NDArray from parsed string
1267
- */
1268
- export declare function fromstring(string: string, dtype?: DType, count?: number, sep?: string): NDArray;
1269
- /**
1270
- * Element-wise square root
1271
- * @param x - Input array
1272
- * @returns Array of square roots
1273
- */
1274
- export declare function sqrt(x: NDArray): NDArray;
1275
- /**
1276
- * Element-wise power
1277
- * @param x - Base array
1278
- * @param exponent - Exponent (array or scalar)
1279
- * @returns Array of x raised to exponent
1280
- */
1281
- export declare function power(x: NDArray, exponent: NDArray | number): NDArray;
1282
- export { power as pow };
1283
- /**
1284
- * Element-wise natural exponential (e^x)
1285
- * @param x - Input array
1286
- * @returns Array of e^x values
1287
- */
1288
- export declare function exp(x: NDArray): NDArray;
1289
- /**
1290
- * Element-wise base-2 exponential (2^x)
1291
- * @param x - Input array
1292
- * @returns Array of 2^x values
1293
- */
1294
- export declare function exp2(x: NDArray): NDArray;
1295
- /**
1296
- * Element-wise exponential minus one (e^x - 1)
1297
- * More accurate than exp(x) - 1 for small x
1298
- * @param x - Input array
1299
- * @returns Array of expm1 values
1300
- */
1301
- export declare function expm1(x: NDArray): NDArray;
1302
- /**
1303
- * Element-wise natural logarithm (ln)
1304
- * @param x - Input array
1305
- * @returns Array of log values
1306
- */
1307
- export declare function log(x: NDArray): NDArray;
1308
- /**
1309
- * Element-wise base-2 logarithm
1310
- * @param x - Input array
1311
- * @returns Array of log2 values
1312
- */
1313
- export declare function log2(x: NDArray): NDArray;
1314
- /**
1315
- * Element-wise base-10 logarithm
1316
- * @param x - Input array
1317
- * @returns Array of log10 values
1318
- */
1319
- export declare function log10(x: NDArray): NDArray;
1320
- /**
1321
- * Element-wise natural logarithm of (1 + x)
1322
- * More accurate than log(1 + x) for small x
1323
- * @param x - Input array
1324
- * @returns Array of log1p values
1325
- */
1326
- export declare function log1p(x: NDArray): NDArray;
1327
- /**
1328
- * Logarithm of the sum of exponentials: log(exp(x1) + exp(x2))
1329
- * More numerically stable than computing the expression directly
1330
- * @param x1 - First input array
1331
- * @param x2 - Second input array or scalar
1332
- * @returns Array of logaddexp values
1333
- */
1334
- export declare function logaddexp(x1: NDArray, x2: NDArray | number): NDArray;
1335
- /**
1336
- * Logarithm base 2 of the sum of exponentials: log2(2^x1 + 2^x2)
1337
- * More numerically stable than computing the expression directly
1338
- * @param x1 - First input array
1339
- * @param x2 - Second input array or scalar
1340
- * @returns Array of logaddexp2 values
1341
- */
1342
- export declare function logaddexp2(x1: NDArray, x2: NDArray | number): NDArray;
1343
- /**
1344
- * Element-wise absolute value
1345
- * @param x - Input array
1346
- * @returns Array of absolute values
1347
- */
1348
- export declare function absolute(x: NDArray): NDArray;
1349
- export { absolute as abs };
1350
- /**
1351
- * Element-wise negation
1352
- * @param x - Input array
1353
- * @returns Array of negated values
1354
- */
1355
- export declare function negative(x: NDArray): NDArray;
1356
- /**
1357
- * Element-wise sign (-1, 0, or 1)
1358
- * @param x - Input array
1359
- * @returns Array of signs
1360
- */
1361
- export declare function sign(x: NDArray): NDArray;
1362
- /**
1363
- * Element-wise modulo
1364
- * @param x - Dividend array
1365
- * @param divisor - Divisor (array or scalar)
1366
- * @returns Remainder after division
1367
- */
1368
- export declare function mod(x: NDArray, divisor: NDArray | number): NDArray;
1369
- /**
1370
- * Element-wise division
1371
- * @param x - Dividend array
1372
- * @param divisor - Divisor (array or scalar)
1373
- * @returns Array of quotients
1374
- */
1375
- export declare function divide(x: NDArray, divisor: NDArray | number): NDArray;
1376
- export { divide as true_divide };
1377
- /**
1378
- * Element-wise floor division
1379
- * @param x - Dividend array
1380
- * @param divisor - Divisor (array or scalar)
1381
- * @returns Floor of the quotient
1382
- */
1383
- export declare function floor_divide(x: NDArray, divisor: NDArray | number): NDArray;
1384
- /**
1385
- * Element-wise positive (unary +)
1386
- * @param x - Input array
1387
- * @returns Copy of the array
1388
- */
1389
- export declare function positive(x: NDArray): NDArray;
1390
- /**
1391
- * Element-wise reciprocal (1/x)
1392
- * @param x - Input array
1393
- * @returns Array of reciprocals
1394
- */
1395
- export declare function reciprocal(x: NDArray): NDArray;
1396
- /**
1397
- * Dot product of two arrays
1398
- *
1399
- * Fully NumPy-compatible. Behavior depends on input dimensions:
1400
- * - 0D · 0D: Multiply scalars → scalar
1401
- * - 0D · ND or ND · 0D: Element-wise multiply → ND
1402
- * - 1D · 1D: Inner product → scalar
1403
- * - 2D · 2D: Matrix multiplication → 2D
1404
- * - 2D · 1D: Matrix-vector product → 1D
1405
- * - 1D · 2D: Vector-matrix product → 1D
1406
- * - ND · 1D (N>2): Sum over last axis → (N-1)D
1407
- * - 1D · ND (N>2): Sum over first axis → (N-1)D
1408
- * - ND · MD (N,M≥2): Tensor contraction → (N+M-2)D
1409
- *
1410
- * @param a - First array
1411
- * @param b - Second array
1412
- * @returns Result of dot product (Complex for complex arrays)
1413
- */
1414
- export declare function dot(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1415
- /**
1416
- * Sum of diagonal elements
1417
- *
1418
- * @param a - Input 2D array
1419
- * @returns Sum of diagonal elements (Complex for complex arrays)
1420
- */
1421
- export declare function trace(a: NDArray): number | bigint | Complex;
1422
- /**
1423
- * Extract a diagonal from a matrix or N-D array
1424
- *
1425
- * @param a - Input array (must be at least 2D)
1426
- * @param offset - Offset of the diagonal from the main diagonal (default: 0)
1427
- * @param axis1 - First axis (default: 0)
1428
- * @param axis2 - Second axis (default: 1)
1429
- * @returns Array containing the diagonal elements
1430
- */
1431
- export declare function diagonal(a: NDArray, offset?: number, axis1?: number, axis2?: number): NDArray;
1432
- /**
1433
- * Kronecker product of two arrays
1434
- *
1435
- * @param a - First input array
1436
- * @param b - Second input array
1437
- * @returns Kronecker product of a and b
1438
- */
1439
- export declare function kron(a: NDArray, b: NDArray): NDArray;
1440
- /**
1441
- * Permute array dimensions
1442
- *
1443
- * @param a - Input array
1444
- * @param axes - Optional permutation of axes (defaults to reverse order)
1445
- * @returns Transposed view
1446
- */
1447
- export declare function transpose(a: NDArray, axes?: number[]): NDArray;
1448
- /**
1449
- * Inner product of two arrays
1450
- *
1451
- * Contracts over last axes of both arrays.
1452
- * Result shape: (*a.shape[:-1], *b.shape[:-1])
1453
- *
1454
- * @param a - First array
1455
- * @param b - Second array
1456
- * @returns Inner product result (Complex for complex arrays)
1457
- */
1458
- export declare function inner(a: NDArray, b: NDArray): NDArray | number | bigint | Complex;
1459
- /**
1460
- * Outer product of two arrays
1461
- *
1462
- * Flattens inputs then computes result[i,j] = a[i] * b[j]
1463
- *
1464
- * @param a - First array
1465
- * @param b - Second array
1466
- * @returns 2D outer product matrix
1467
- */
1468
- export declare function outer(a: NDArray, b: NDArray): NDArray;
1469
- /**
1470
- * Tensor dot product along specified axes
1471
- *
1472
- * @param a - First array
1473
- * @param b - Second array
1474
- * @param axes - Axes to contract (integer or [a_axes, b_axes])
1475
- * @returns Tensor dot product
1476
- */
1477
- export declare function tensordot(a: NDArray, b: NDArray, axes?: number | [number[], number[]]): NDArray | number | bigint | Complex;
1478
- /**
1479
- * Element-wise sine
1480
- * @param x - Input array (angles in radians)
1481
- * @returns Array of sine values
1482
- */
1483
- export declare function sin(x: NDArray): NDArray;
1484
- /**
1485
- * Element-wise cosine
1486
- * @param x - Input array (angles in radians)
1487
- * @returns Array of cosine values
1488
- */
1489
- export declare function cos(x: NDArray): NDArray;
1490
- /**
1491
- * Element-wise tangent
1492
- * @param x - Input array (angles in radians)
1493
- * @returns Array of tangent values
1494
- */
1495
- export declare function tan(x: NDArray): NDArray;
1496
- /**
1497
- * Element-wise inverse sine
1498
- * @param x - Input array (values in range [-1, 1])
1499
- * @returns Array of angles in radians
1500
- */
1501
- export declare function arcsin(x: NDArray): NDArray;
1502
- export { arcsin as asin };
1503
- /**
1504
- * Element-wise inverse cosine
1505
- * @param x - Input array (values in range [-1, 1])
1506
- * @returns Array of angles in radians
1507
- */
1508
- export declare function arccos(x: NDArray): NDArray;
1509
- export { arccos as acos };
1510
- /**
1511
- * Element-wise inverse tangent
1512
- * @param x - Input array
1513
- * @returns Array of angles in radians
1514
- */
1515
- export declare function arctan(x: NDArray): NDArray;
1516
- export { arctan as atan };
1517
- /**
1518
- * Element-wise arc tangent of x1/x2 choosing the quadrant correctly
1519
- * @param x1 - y-coordinates
1520
- * @param x2 - x-coordinates (array or scalar)
1521
- * @returns Angles in radians between -π and π
1522
- */
1523
- export declare function arctan2(x1: NDArray, x2: NDArray | number): NDArray;
1524
- export { arctan2 as atan2 };
1525
- /**
1526
- * Given the "legs" of a right triangle, return its hypotenuse
1527
- * Equivalent to sqrt(x1**2 + x2**2), element-wise
1528
- * @param x1 - First leg
1529
- * @param x2 - Second leg (array or scalar)
1530
- * @returns Hypotenuse values
1531
- */
1532
- export declare function hypot(x1: NDArray, x2: NDArray | number): NDArray;
1533
- /**
1534
- * Convert angles from radians to degrees
1535
- * @param x - Input array (angles in radians)
1536
- * @returns Angles in degrees
1537
- */
1538
- export declare function degrees(x: NDArray): NDArray;
1539
- /**
1540
- * Convert angles from degrees to radians
1541
- * @param x - Input array (angles in degrees)
1542
- * @returns Angles in radians
1543
- */
1544
- export declare function radians(x: NDArray): NDArray;
1545
- /**
1546
- * Convert angles from degrees to radians (alias for radians)
1547
- * @param x - Input array (angles in degrees)
1548
- * @returns Angles in radians
1549
- */
1550
- export declare function deg2rad(x: NDArray): NDArray;
1551
- /**
1552
- * Convert angles from radians to degrees (alias for degrees)
1553
- * @param x - Input array (angles in radians)
1554
- * @returns Angles in degrees
1555
- */
1556
- export declare function rad2deg(x: NDArray): NDArray;
1557
- /**
1558
- * Element-wise hyperbolic sine
1559
- * @param x - Input array
1560
- * @returns Array of sinh values
1561
- */
1562
- export declare function sinh(x: NDArray): NDArray;
1563
- /**
1564
- * Element-wise hyperbolic cosine
1565
- * @param x - Input array
1566
- * @returns Array of cosh values
1567
- */
1568
- export declare function cosh(x: NDArray): NDArray;
1569
- /**
1570
- * Element-wise hyperbolic tangent
1571
- * @param x - Input array
1572
- * @returns Array of tanh values
1573
- */
1574
- export declare function tanh(x: NDArray): NDArray;
1575
- /**
1576
- * Element-wise inverse hyperbolic sine
1577
- * @param x - Input array
1578
- * @returns Array of arcsinh values
1579
- */
1580
- export declare function arcsinh(x: NDArray): NDArray;
1581
- export { arcsinh as asinh };
1582
- /**
1583
- * Element-wise inverse hyperbolic cosine
1584
- * @param x - Input array (values >= 1)
1585
- * @returns Array of arccosh values
1586
- */
1587
- export declare function arccosh(x: NDArray): NDArray;
1588
- export { arccosh as acosh };
1589
- /**
1590
- * Element-wise inverse hyperbolic tangent
1591
- * @param x - Input array (values in range (-1, 1))
1592
- * @returns Array of arctanh values
1593
- */
1594
- export declare function arctanh(x: NDArray): NDArray;
1595
- export { arctanh as atanh };
1596
- /**
1597
- * Swap two axes of an array
1598
- *
1599
- * @param a - Input array
1600
- * @param axis1 - First axis
1601
- * @param axis2 - Second axis
1602
- * @returns View with axes swapped
1603
- */
1604
- export declare function swapaxes(a: NDArray, axis1: number, axis2: number): NDArray;
1605
- /**
1606
- * Move axes to new positions
1607
- *
1608
- * @param a - Input array
1609
- * @param source - Original positions of axes to move
1610
- * @param destination - New positions for axes
1611
- * @returns View with axes moved
1612
- */
1613
- export declare function moveaxis(a: NDArray, source: number | number[], destination: number | number[]): NDArray;
1614
- /**
1615
- * Concatenate arrays along an existing axis
1616
- *
1617
- * @param arrays - Arrays to concatenate
1618
- * @param axis - Axis along which to concatenate (default: 0)
1619
- * @returns Concatenated array
1620
- */
1621
- export declare function concatenate(arrays: NDArray[], axis?: number): NDArray;
1622
- /**
1623
- * Stack arrays along a new axis
1624
- *
1625
- * @param arrays - Arrays to stack (must have same shape)
1626
- * @param axis - Axis in the result array along which to stack (default: 0)
1627
- * @returns Stacked array
1628
- */
1629
- export declare function stack(arrays: NDArray[], axis?: number): NDArray;
1630
- /**
1631
- * Stack arrays vertically (row-wise)
1632
- *
1633
- * @param arrays - Arrays to stack
1634
- * @returns Vertically stacked array
1635
- */
1636
- export declare function vstack(arrays: NDArray[]): NDArray;
1637
- /**
1638
- * Stack arrays horizontally (column-wise)
1639
- *
1640
- * @param arrays - Arrays to stack
1641
- * @returns Horizontally stacked array
1642
- */
1643
- export declare function hstack(arrays: NDArray[]): NDArray;
1644
- /**
1645
- * Stack arrays depth-wise (along third axis)
1646
- *
1647
- * @param arrays - Arrays to stack
1648
- * @returns Depth-stacked array
1649
- */
1650
- export declare function dstack(arrays: NDArray[]): NDArray;
1651
- /**
1652
- * Split array into multiple sub-arrays
1653
- *
1654
- * @param a - Array to split
1655
- * @param indicesOrSections - Number of equal sections or indices where to split
1656
- * @param axis - Axis along which to split (default: 0)
1657
- * @returns List of sub-arrays
1658
- */
1659
- export declare function split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
1660
- /**
1661
- * Split array into multiple sub-arrays (allows unequal splits)
1662
- *
1663
- * @param a - Array to split
1664
- * @param indicesOrSections - Number of sections or indices where to split
1665
- * @param axis - Axis along which to split (default: 0)
1666
- * @returns List of sub-arrays
1667
- */
1668
- export declare function array_split(a: NDArray, indicesOrSections: number | number[], axis?: number): NDArray[];
1669
- /**
1670
- * Split array vertically (row-wise)
1671
- *
1672
- * @param a - Array to split
1673
- * @param indicesOrSections - Number of sections or indices where to split
1674
- * @returns List of sub-arrays
1675
- */
1676
- export declare function vsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
1677
- /**
1678
- * Split array horizontally (column-wise)
1679
- *
1680
- * @param a - Array to split
1681
- * @param indicesOrSections - Number of sections or indices where to split
1682
- * @returns List of sub-arrays
1683
- */
1684
- export declare function hsplit(a: NDArray, indicesOrSections: number | number[]): NDArray[];
1685
- /**
1686
- * Tile array by repeating along each axis
1687
- *
1688
- * @param a - Input array
1689
- * @param reps - Number of repetitions along each axis
1690
- * @returns Tiled array
1691
- */
1692
- export declare function tile(a: NDArray, reps: number | number[]): NDArray;
1693
- /**
1694
- * Repeat elements of an array
1695
- *
1696
- * @param a - Input array
1697
- * @param repeats - Number of repetitions for each element
1698
- * @param axis - Axis along which to repeat (if undefined, flattens first)
1699
- * @returns Array with repeated elements
1700
- */
1701
- export declare function repeat(a: NDArray, repeats: number | number[], axis?: number): NDArray;
1702
- /**
1703
- * Return a contiguous flattened array
1704
- *
1705
- * @param a - Input array
1706
- * @returns Flattened 1-D array (view if possible)
1707
- */
1708
- export declare function ravel(a: NDArray): NDArray;
1709
- /**
1710
- * Reshape array to new shape
1711
- *
1712
- * @param a - Input array
1713
- * @param newShape - New shape
1714
- * @returns Reshaped array (view if possible)
1715
- */
1716
- export declare function reshape(a: NDArray, newShape: number[]): NDArray;
1717
- /**
1718
- * Remove axes of length 1
1719
- *
1720
- * @param a - Input array
1721
- * @param axis - Axis to squeeze (optional, squeezes all if not specified)
1722
- * @returns Squeezed array (view)
1723
- */
1724
- export declare function squeeze(a: NDArray, axis?: number): NDArray;
1725
- /**
1726
- * Expand the shape of an array by inserting a new axis
1727
- *
1728
- * @param a - Input array
1729
- * @param axis - Position where new axis should be inserted
1730
- * @returns Array with expanded shape (view)
1731
- */
1732
- export declare function expand_dims(a: NDArray, axis: number): NDArray;
1733
- /**
1734
- * Reverse the order of elements along the given axis
1735
- *
1736
- * @param m - Input array
1737
- * @param axis - Axis or axes to flip (flips all if undefined)
1738
- * @returns Flipped array
1739
- */
1740
- export declare function flip(m: NDArray, axis?: number | number[]): NDArray;
1741
- /**
1742
- * Flip array in the left/right direction (reverse along axis 1)
1743
- *
1744
- * @param m - Input array (must be at least 2-D)
1745
- * @returns Flipped array
1746
- */
1747
- export declare function fliplr(m: NDArray): NDArray;
1748
- /**
1749
- * Flip array in the up/down direction (reverse along axis 0)
1750
- *
1751
- * @param m - Input array (must be at least 2-D)
1752
- * @returns Flipped array
1753
- */
1754
- export declare function flipud(m: NDArray): NDArray;
1755
- /**
1756
- * Rotate array by 90 degrees
1757
- *
1758
- * @param m - Input array
1759
- * @param k - Number of times to rotate (default 1)
1760
- * @param axes - The axes to rotate in (default [0, 1])
1761
- * @returns Rotated array
1762
- */
1763
- export declare function rot90(m: NDArray, k?: number, axes?: [number, number]): NDArray;
1764
- /**
1765
- * Roll array elements along a given axis
1766
- *
1767
- * @param a - Input array
1768
- * @param shift - Number of positions to shift
1769
- * @param axis - Axis along which to roll (rolls flattened array if undefined)
1770
- * @returns Rolled array
1771
- */
1772
- export declare function roll(a: NDArray, shift: number | number[], axis?: number | number[]): NDArray;
1773
- /**
1774
- * Roll the specified axis backwards until it lies in a given position
1775
- *
1776
- * @param a - Input array
1777
- * @param axis - The axis to roll backwards
1778
- * @param start - Position to roll to (default 0)
1779
- * @returns Array with rolled axis (view)
1780
- */
1781
- export declare function rollaxis(a: NDArray, axis: number, start?: number): NDArray;
1782
- /**
1783
- * Convert inputs to arrays with at least 1 dimension
1784
- *
1785
- * @param arrays - Input arrays
1786
- * @returns Arrays with at least 1 dimension
1787
- */
1788
- export declare function atleast_1d(...arrays: NDArray[]): NDArray | NDArray[];
1789
- /**
1790
- * Convert inputs to arrays with at least 2 dimensions
1791
- *
1792
- * @param arrays - Input arrays
1793
- * @returns Arrays with at least 2 dimensions
1794
- */
1795
- export declare function atleast_2d(...arrays: NDArray[]): NDArray | NDArray[];
1796
- /**
1797
- * Convert inputs to arrays with at least 3 dimensions
1798
- *
1799
- * @param arrays - Input arrays
1800
- * @returns Arrays with at least 3 dimensions
1801
- */
1802
- export declare function atleast_3d(...arrays: NDArray[]): NDArray | NDArray[];
1803
- /**
1804
- * Split array along third axis (depth)
1805
- *
1806
- * @param ary - Input array (must be at least 3-D)
1807
- * @param indices_or_sections - Number of sections or indices where to split
1808
- * @returns List of sub-arrays
1809
- */
1810
- export declare function dsplit(ary: NDArray, indices_or_sections: number | number[]): NDArray[];
1811
- /**
1812
- * Stack 1-D arrays as columns into a 2-D array
1813
- *
1814
- * @param arrays - 1-D arrays to stack
1815
- * @returns 2-D array with inputs as columns
1816
- */
1817
- export declare function column_stack(arrays: NDArray[]): NDArray;
1818
- /**
1819
- * Stack arrays in sequence vertically (alias for vstack)
1820
- *
1821
- * @param arrays - Arrays to stack
1822
- * @returns Vertically stacked array
1823
- */
1824
- export declare function row_stack(arrays: NDArray[]): NDArray;
1825
- /**
1826
- * Return a new array with the given shape (repeating data if needed)
1827
- *
1828
- * @param a - Input array
1829
- * @param new_shape - New shape
1830
- * @returns Resized array
1831
- */
1832
- export declare function resize(a: NDArray, new_shape: number[]): NDArray;
1833
- /**
1834
- * Append values to the end of an array
1835
- *
1836
- * @param arr - Input array
1837
- * @param values - Values to append
1838
- * @param axis - Axis along which to append (flattens if undefined)
1839
- * @returns Array with values appended
1840
- */
1841
- export declare function append(arr: NDArray, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
1842
- /**
1843
- * Return a new array with sub-arrays along an axis deleted
1844
- *
1845
- * @param arr - Input array
1846
- * @param obj - Indices to delete
1847
- * @param axis - Axis along which to delete (flattens if undefined)
1848
- * @returns Array with elements deleted
1849
- */
1850
- export declare function delete_(arr: NDArray, obj: number | number[], axis?: number): NDArray;
1851
- /**
1852
- * Insert values along the given axis before the given indices
1853
- *
1854
- * @param arr - Input array
1855
- * @param obj - Index before which to insert
1856
- * @param values - Values to insert
1857
- * @param axis - Axis along which to insert (flattens if undefined)
1858
- * @returns Array with values inserted
1859
- */
1860
- export declare function insert(arr: NDArray, obj: number, values: NDArray | ArrayLike<number | bigint> | number, axis?: number): NDArray;
1861
- /**
1862
- * Pad an array
1863
- *
1864
- * @param array - Input array
1865
- * @param pad_width - Number of values padded to edges of each axis
1866
- * @param mode - Padding mode ('constant', 'edge', 'reflect', 'symmetric', 'wrap')
1867
- * @param constant_values - Value for constant padding (default 0)
1868
- * @returns Padded array
1869
- */
1870
- export declare function pad(arr: NDArray, pad_width: number | [number, number] | Array<[number, number]>, mode?: 'constant' | 'edge' | 'reflect' | 'symmetric' | 'wrap', constant_values?: number): NDArray;
1871
- /**
1872
- * Broadcast an array to a given shape
1873
- *
1874
- * @param a - Input array
1875
- * @param shape - Target shape
1876
- * @returns View broadcast to target shape
1877
- */
1878
- export declare function broadcast_to(a: NDArray, shape: number[]): NDArray;
1879
- /**
1880
- * Broadcast arrays to a common shape
1881
- *
1882
- * @param arrays - Arrays to broadcast
1883
- * @returns Arrays broadcast to common shape
1884
- */
1885
- export declare function broadcast_arrays(...arrays: NDArray[]): NDArray[];
1886
- /**
1887
- * Compute the broadcast shape for multiple shapes
1888
- *
1889
- * Returns the resulting shape if all shapes are broadcast-compatible.
1890
- * Throws an error if shapes are not broadcast-compatible.
1891
- *
1892
- * @param shapes - Variable number of shapes to broadcast
1893
- * @returns The broadcast output shape
1894
- * @throws Error if shapes are not broadcast-compatible
1895
- */
1896
- export declare function broadcast_shapes(...shapes: number[][]): number[];
1897
- /**
1898
- * Take elements from an array along an axis
1899
- *
1900
- * @param a - Input array
1901
- * @param indices - Indices of elements to take
1902
- * @param axis - Axis along which to take (if undefined, flattens first)
1903
- * @returns Array with selected elements
1904
- */
1905
- export declare function take(a: NDArray, indices: number[], axis?: number): NDArray;
1906
- /**
1907
- * Put values at specified indices (modifies array in-place)
1908
- *
1909
- * @param a - Target array
1910
- * @param indices - Indices at which to place values
1911
- * @param values - Values to put
1912
- */
1913
- export declare function put(a: NDArray, indices: number[], values: NDArray | number | bigint): void;
1914
- /**
1915
- * Integer array indexing (fancy indexing)
1916
- *
1917
- * Select elements from an array using an array of indices.
1918
- * NumPy equivalent: `arr[[0, 2, 4]]`
1919
- *
1920
- * @param a - Input array
1921
- * @param indices - Array of integer indices (as number[], NDArray, or nested arrays)
1922
- * @param axis - Axis along which to index (default: 0)
1923
- * @returns New array with selected elements
1924
- *
1925
- * @example
1926
- * ```typescript
1927
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
1928
- * np.iindex(arr, [0, 2]); // [[1, 2, 3], [7, 8, 9]]
1929
- * np.iindex(arr, [0, 2], 1); // [[1, 3], [4, 6], [7, 9]]
1930
- * ```
1931
- */
1932
- export declare function iindex(a: NDArray, indices: NDArray | number[] | number[][], axis?: number): NDArray;
1933
- /**
1934
- * Boolean array indexing (fancy indexing with mask)
1935
- *
1936
- * Select elements from an array where a boolean mask is true.
1937
- * NumPy equivalent: `arr[arr > 5]`
1938
- *
1939
- * @param a - Input array
1940
- * @param mask - Boolean NDArray mask
1941
- * @param axis - Axis along which to apply the mask (default: flattens array)
1942
- * @returns New array with selected elements
1943
- *
1944
- * @example
1945
- * ```typescript
1946
- * const arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
1947
- * const mask = arr.greater(5);
1948
- * np.bindex(arr, mask); // [6, 7, 8, 9]
1949
- * ```
1950
- */
1951
- export declare function bindex(a: NDArray, mask: NDArray, axis?: number): NDArray;
1952
- /**
1953
- * Copy values from one array to another, broadcasting as necessary.
1954
- *
1955
- * @param dst - Destination array (modified in-place)
1956
- * @param src - Source array or scalar
1957
- * @param where - Optional boolean array. Only copy where True (not yet implemented)
1958
- * @throws Error if shapes are not broadcastable
1959
- *
1960
- * @example
1961
- * ```typescript
1962
- * const dst = np.zeros([3, 3]);
1963
- * const src = np.array([1, 2, 3]);
1964
- * np.copyto(dst, src); // Each row of dst becomes [1, 2, 3]
1965
- * ```
1966
- */
1967
- export declare function copyto(dst: NDArray, src: NDArray | number | bigint, where?: NDArray): void;
1968
- /**
1969
- * Construct array from index array and choices
1970
- *
1971
- * @param a - Index array (integer indices into choices)
1972
- * @param choices - Arrays to choose from
1973
- * @returns Array constructed from choices
1974
- */
1975
- export declare function choose(a: NDArray, choices: NDArray[]): NDArray;
1976
- /**
1977
- * Check if two arrays are element-wise equal
1978
- *
1979
- * @param a - First array
1980
- * @param b - Second array
1981
- * @param equal_nan - Whether to consider NaN equal to NaN (default: false)
1982
- * @returns True if arrays are equal element-wise
1983
- */
1984
- export declare function array_equal(a: NDArray, b: NDArray, equal_nan?: boolean): boolean;
1985
- /**
1986
- * Returns True if two arrays are element-wise equal within a tolerance.
1987
- * Unlike array_equal, this function broadcasts the arrays before comparison.
1988
- *
1989
- * @param a1 - First input array
1990
- * @param a2 - Second input array
1991
- * @returns True if arrays are equivalent (after broadcasting)
1992
- */
1993
- export declare function array_equiv(a1: NDArray, a2: NDArray): boolean;
1994
- /**
1995
- * Return the cumulative sum of the elements along a given axis.
1996
- * @param a - Input array
1997
- * @param axis - Axis along which to compute. If undefined, flattened array is used.
1998
- * @returns Array with cumulative sums
1999
- */
2000
- export declare function cumsum(a: NDArray, axis?: number): NDArray;
2001
- export { cumsum as cumulative_sum };
2002
- /**
2003
- * Return the cumulative product of the elements along a given axis.
2004
- * @param a - Input array
2005
- * @param axis - Axis along which to compute. If undefined, flattened array is used.
2006
- * @returns Array with cumulative products
2007
- */
2008
- export declare function cumprod(a: NDArray, axis?: number): NDArray;
2009
- export { cumprod as cumulative_prod };
2010
- /**
2011
- * Return the maximum along a given axis.
2012
- * @param a - Input array
2013
- * @param axis - Axis along which to compute. If undefined, use all elements.
2014
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2015
- * @returns Maximum value(s)
2016
- */
2017
- export declare function max(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2018
- export { max as amax };
2019
- /**
2020
- * Return the minimum along a given axis.
2021
- * @param a - Input array
2022
- * @param axis - Axis along which to compute. If undefined, use all elements.
2023
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2024
- * @returns Minimum value(s)
2025
- */
2026
- export declare function min(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2027
- export { min as amin };
2028
- /**
2029
- * Peak to peak (maximum - minimum) value along a given axis.
2030
- * @param a - Input array
2031
- * @param axis - Axis along which to compute. If undefined, use all elements.
2032
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2033
- * @returns Peak to peak value(s)
2034
- */
2035
- export declare function ptp(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2036
- /**
2037
- * Compute the median along the specified axis.
2038
- * @param a - Input array
2039
- * @param axis - Axis along which to compute. If undefined, use all elements.
2040
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2041
- * @returns Median value(s)
2042
- */
2043
- export declare function median(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2044
- /**
2045
- * Compute the q-th percentile of the data along the specified axis.
2046
- * @param a - Input array
2047
- * @param q - Percentile (0-100)
2048
- * @param axis - Axis along which to compute. If undefined, use all elements.
2049
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2050
- * @returns Percentile value(s)
2051
- */
2052
- export declare function percentile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2053
- /**
2054
- * Compute the q-th quantile of the data along the specified axis.
2055
- * @param a - Input array
2056
- * @param q - Quantile (0-1)
2057
- * @param axis - Axis along which to compute. If undefined, use all elements.
2058
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2059
- * @returns Quantile value(s)
2060
- */
2061
- export declare function quantile(a: NDArray, q: number, axis?: number, keepdims?: boolean): NDArray | number;
2062
- /**
2063
- * Compute the weighted average along the specified axis.
2064
- * @param a - Input array
2065
- * @param axis - Axis along which to compute. If undefined, use all elements.
2066
- * @param weights - Array of weights (must be same shape as array along specified axis)
2067
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2068
- * @returns Weighted average value(s)
2069
- */
2070
- export declare function average(a: NDArray, axis?: number, weights?: NDArray, keepdims?: boolean): NDArray | number | Complex;
2071
- /**
2072
- * Return the sum of array elements over a given axis, treating NaNs as zero.
2073
- * @param a - Input array
2074
- * @param axis - Axis along which to compute. If undefined, use all elements.
2075
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2076
- * @returns Sum value(s)
2077
- */
2078
- export declare function nansum(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2079
- /**
2080
- * Return the product of array elements over a given axis, treating NaNs as one.
2081
- * @param a - Input array
2082
- * @param axis - Axis along which to compute. If undefined, use all elements.
2083
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2084
- * @returns Product value(s)
2085
- */
2086
- export declare function nanprod(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2087
- /**
2088
- * Compute the arithmetic mean along the specified axis, ignoring NaNs.
2089
- * @param a - Input array
2090
- * @param axis - Axis along which to compute. If undefined, use all elements.
2091
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2092
- * @returns Mean value(s)
2093
- */
2094
- export declare function nanmean(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2095
- /**
2096
- * Compute the variance along the specified axis, ignoring NaNs.
2097
- * @param a - Input array
2098
- * @param axis - Axis along which to compute. If undefined, use all elements.
2099
- * @param ddof - Delta degrees of freedom (default 0)
2100
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2101
- * @returns Variance value(s)
2102
- */
2103
- export declare function nanvar(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
2104
- /**
2105
- * Compute the standard deviation along the specified axis, ignoring NaNs.
2106
- * @param a - Input array
2107
- * @param axis - Axis along which to compute. If undefined, use all elements.
2108
- * @param ddof - Delta degrees of freedom (default 0)
2109
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2110
- * @returns Standard deviation value(s)
2111
- */
2112
- export declare function nanstd(a: NDArray, axis?: number, ddof?: number, keepdims?: boolean): NDArray | number;
2113
- /**
2114
- * Return minimum of an array, ignoring NaNs.
2115
- * @param a - Input array
2116
- * @param axis - Axis along which to compute. If undefined, use all elements.
2117
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2118
- * @returns Minimum value(s)
2119
- */
2120
- export declare function nanmin(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2121
- /**
2122
- * Return maximum of an array, ignoring NaNs.
2123
- * @param a - Input array
2124
- * @param axis - Axis along which to compute. If undefined, use all elements.
2125
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2126
- * @returns Maximum value(s)
2127
- */
2128
- export declare function nanmax(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number | Complex;
2129
- /**
2130
- * Return indices of the minimum value, ignoring NaNs.
2131
- * @param a - Input array
2132
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2133
- * @returns Index/indices of minimum value(s)
2134
- */
2135
- export declare function nanargmin(a: NDArray, axis?: number): NDArray | number;
2136
- /**
2137
- * Return indices of the maximum value, ignoring NaNs.
2138
- * @param a - Input array
2139
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2140
- * @returns Index/indices of maximum value(s)
2141
- */
2142
- export declare function nanargmax(a: NDArray, axis?: number): NDArray | number;
2143
- /**
2144
- * Return cumulative sum of elements, treating NaNs as zero.
2145
- * @param a - Input array
2146
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2147
- * @returns Array with cumulative sums
2148
- */
2149
- export declare function nancumsum(a: NDArray, axis?: number): NDArray;
2150
- /**
2151
- * Return cumulative product of elements, treating NaNs as one.
2152
- * @param a - Input array
2153
- * @param axis - Axis along which to compute. If undefined, use flattened array.
2154
- * @returns Array with cumulative products
2155
- */
2156
- export declare function nancumprod(a: NDArray, axis?: number): NDArray;
2157
- /**
2158
- * Compute the median, ignoring NaNs.
2159
- * @param a - Input array
2160
- * @param axis - Axis along which to compute. If undefined, use all elements.
2161
- * @param keepdims - If true, reduced axes are left as dimensions with size 1
2162
- * @returns Median value(s)
2163
- */
2164
- export declare function nanmedian(a: NDArray, axis?: number, keepdims?: boolean): NDArray | number;
2165
- /**
2166
- * Element-wise cube root
2167
- *
2168
- * @param x - Input array
2169
- * @returns Array with cube root of each element
2170
- */
2171
- export declare function cbrt(x: NDArray): NDArray;
2172
- /**
2173
- * Element-wise absolute value (always returns float)
2174
- *
2175
- * @param x - Input array
2176
- * @returns Array with absolute values as float
2177
- */
2178
- export declare function fabs(x: NDArray): NDArray;
2179
- /**
2180
- * Returns both quotient and remainder (floor divide and modulo)
2181
- *
2182
- * @param x - Dividend array
2183
- * @param y - Divisor (array or scalar)
2184
- * @returns Tuple of [quotient, remainder] arrays
2185
- */
2186
- export declare function divmod(x: NDArray, y: NDArray | number): [NDArray, NDArray];
2187
- /**
2188
- * Element-wise square (x**2)
2189
- *
2190
- * @param x - Input array
2191
- * @returns Array with squared values
2192
- */
2193
- export declare function square(x: NDArray): NDArray;
2194
- /**
2195
- * Element-wise remainder (same as mod)
2196
- *
2197
- * @param x - Dividend array
2198
- * @param y - Divisor (array or scalar)
2199
- * @returns Array with remainder values
2200
- */
2201
- export declare function remainder(x: NDArray, y: NDArray | number): NDArray;
2202
- /**
2203
- * Heaviside step function
2204
- *
2205
- * @param x1 - Input array
2206
- * @param x2 - Value to use when x1 is 0
2207
- * @returns Array with heaviside values (0 if x1 < 0, x2 if x1 == 0, 1 if x1 > 0)
2208
- */
2209
- export declare function heaviside(x1: NDArray, x2: NDArray | number): NDArray;
2210
- /**
2211
- * First array raised to power of second, always promoting to float
2212
- * @param x1 - Base values
2213
- * @param x2 - Exponent values
2214
- * @returns Result in float64
2215
- */
2216
- export declare function float_power(x1: NDArray, x2: NDArray | number): NDArray;
2217
- /**
2218
- * Element-wise remainder of division (fmod)
2219
- * Unlike mod/remainder, fmod matches C fmod behavior
2220
- * @param x1 - Dividend
2221
- * @param x2 - Divisor
2222
- * @returns Remainder
2223
- */
2224
- export declare function fmod(x1: NDArray, x2: NDArray | number): NDArray;
2225
- /**
2226
- * Decompose floating point numbers into mantissa and exponent
2227
- * Returns [mantissa, exponent] where x = mantissa * 2^exponent
2228
- * @param x - Input array
2229
- * @returns Tuple of [mantissa, exponent] arrays
2230
- */
2231
- export declare function frexp(x: NDArray): [NDArray, NDArray];
2232
- /**
2233
- * Greatest common divisor
2234
- * @param x1 - First array
2235
- * @param x2 - Second array or scalar
2236
- * @returns GCD
2237
- */
2238
- export declare function gcd(x1: NDArray, x2: NDArray | number): NDArray;
2239
- /**
2240
- * Least common multiple
2241
- * @param x1 - First array
2242
- * @param x2 - Second array or scalar
2243
- * @returns LCM
2244
- */
2245
- export declare function lcm(x1: NDArray, x2: NDArray | number): NDArray;
2246
- /**
2247
- * Returns x1 * 2^x2, element-wise
2248
- * @param x1 - Mantissa
2249
- * @param x2 - Exponent
2250
- * @returns Result
2251
- */
2252
- export declare function ldexp(x1: NDArray, x2: NDArray | number): NDArray;
2253
- /**
2254
- * Return fractional and integral parts of array
2255
- * @param x - Input array
2256
- * @returns Tuple of [fractional, integral] arrays
2257
- */
2258
- export declare function modf(x: NDArray): [NDArray, NDArray];
2259
- /**
2260
- * Bitwise AND element-wise
2261
- *
2262
- * @param x1 - First input array (must be integer type)
2263
- * @param x2 - Second input array or scalar (must be integer type)
2264
- * @returns Result of bitwise AND
2265
- */
2266
- export declare function bitwise_and(x1: NDArray, x2: NDArray | number): NDArray;
2267
- /**
2268
- * Bitwise OR element-wise
2269
- *
2270
- * @param x1 - First input array (must be integer type)
2271
- * @param x2 - Second input array or scalar (must be integer type)
2272
- * @returns Result of bitwise OR
2273
- */
2274
- export declare function bitwise_or(x1: NDArray, x2: NDArray | number): NDArray;
2275
- /**
2276
- * Bitwise XOR element-wise
2277
- *
2278
- * @param x1 - First input array (must be integer type)
2279
- * @param x2 - Second input array or scalar (must be integer type)
2280
- * @returns Result of bitwise XOR
2281
- */
2282
- export declare function bitwise_xor(x1: NDArray, x2: NDArray | number): NDArray;
2283
- /**
2284
- * Bitwise NOT (inversion) element-wise
2285
- *
2286
- * @param x - Input array (must be integer type)
2287
- * @returns Result of bitwise NOT
2288
- */
2289
- export declare function bitwise_not(x: NDArray): NDArray;
2290
- /**
2291
- * Invert (bitwise NOT) element-wise
2292
- * Alias for bitwise_not
2293
- *
2294
- * @param x - Input array (must be integer type)
2295
- * @returns Result of bitwise inversion
2296
- */
2297
- export declare function invert(x: NDArray): NDArray;
2298
- /**
2299
- * Left shift elements by positions
2300
- *
2301
- * @param x1 - Input array (must be integer type)
2302
- * @param x2 - Shift amount (array or scalar)
2303
- * @returns Result of left shift
2304
- */
2305
- export declare function left_shift(x1: NDArray, x2: NDArray | number): NDArray;
2306
- /**
2307
- * Right shift elements by positions
2308
- *
2309
- * @param x1 - Input array (must be integer type)
2310
- * @param x2 - Shift amount (array or scalar)
2311
- * @returns Result of right shift
2312
- */
2313
- export declare function right_shift(x1: NDArray, x2: NDArray | number): NDArray;
2314
- /**
2315
- * Pack binary values into uint8 array
2316
- *
2317
- * Packs the elements of a binary-valued array into bits in a uint8 array.
2318
- *
2319
- * @param a - Input array (values are interpreted as binary: 0 or non-zero)
2320
- * @param axis - The dimension over which bit-packing is done (default: -1)
2321
- * @param bitorder - Order of bits: 'big' or 'little' (default: 'big')
2322
- * @returns Packed uint8 array
2323
- */
2324
- export declare function packbits(a: NDArray, axis?: number, bitorder?: 'big' | 'little'): NDArray;
2325
- /**
2326
- * Unpack uint8 array into binary values
2327
- *
2328
- * Unpacks elements of a uint8 array into a binary-valued output array.
2329
- *
2330
- * @param a - Input uint8 array
2331
- * @param axis - The dimension over which bit-unpacking is done (default: -1)
2332
- * @param count - Number of elements to unpack, or -1 for all (default: -1)
2333
- * @param bitorder - Order of bits: 'big' or 'little' (default: 'big')
2334
- * @returns Unpacked uint8 array of 0s and 1s
2335
- */
2336
- export declare function unpackbits(a: NDArray, axis?: number, count?: number, bitorder?: 'big' | 'little'): NDArray;
2337
- /**
2338
- * Logical AND element-wise
2339
- *
2340
- * Returns a boolean array where each element is the logical AND
2341
- * of corresponding elements (non-zero = true, zero = false).
2342
- *
2343
- * @param x1 - First input array
2344
- * @param x2 - Second input array or scalar
2345
- * @returns Boolean result array
2346
- */
2347
- export declare function logical_and(x1: NDArray, x2: NDArray | number): NDArray;
2348
- /**
2349
- * Logical OR element-wise
2350
- *
2351
- * Returns a boolean array where each element is the logical OR
2352
- * of corresponding elements (non-zero = true, zero = false).
2353
- *
2354
- * @param x1 - First input array
2355
- * @param x2 - Second input array or scalar
2356
- * @returns Boolean result array
2357
- */
2358
- export declare function logical_or(x1: NDArray, x2: NDArray | number): NDArray;
2359
- /**
2360
- * Logical NOT element-wise
2361
- *
2362
- * Returns a boolean array where each element is the logical NOT
2363
- * of the input (non-zero = false, zero = true).
2364
- *
2365
- * @param x - Input array
2366
- * @returns Boolean result array
2367
- */
2368
- export declare function logical_not(x: NDArray): NDArray;
2369
- /**
2370
- * Logical XOR element-wise
2371
- *
2372
- * Returns a boolean array where each element is the logical XOR
2373
- * of corresponding elements (non-zero = true, zero = false).
2374
- *
2375
- * @param x1 - First input array
2376
- * @param x2 - Second input array or scalar
2377
- * @returns Boolean result array
2378
- */
2379
- export declare function logical_xor(x1: NDArray, x2: NDArray | number): NDArray;
2380
- /**
2381
- * Test element-wise for finiteness (not infinity and not NaN)
2382
- *
2383
- * @param x - Input array
2384
- * @returns Boolean array where True means finite
2385
- */
2386
- export declare function isfinite(x: NDArray): NDArray;
2387
- /**
2388
- * Test element-wise for positive or negative infinity
2389
- *
2390
- * @param x - Input array
2391
- * @returns Boolean array where True means infinite
2392
- */
2393
- export declare function isinf(x: NDArray): NDArray;
2394
- /**
2395
- * Test element-wise for NaN (Not a Number)
2396
- *
2397
- * @param x - Input array
2398
- * @returns Boolean array where True means NaN
2399
- */
2400
- export declare function isnan(x: NDArray): NDArray;
2401
- /**
2402
- * Test element-wise for NaT (Not a Time)
2403
- *
2404
- * @param x - Input array
2405
- * @returns Boolean array (always false without datetime support)
2406
- */
2407
- export declare function isnat(x: NDArray): NDArray;
2408
- /**
2409
- * Change the sign of x1 to that of x2, element-wise
2410
- *
2411
- * Returns a value with the magnitude of x1 and the sign of x2.
2412
- *
2413
- * @param x1 - Values to change sign of (magnitude source)
2414
- * @param x2 - Values whose sign is used (sign source)
2415
- * @returns Array with magnitude from x1 and sign from x2
2416
- */
2417
- export declare function copysign(x1: NDArray, x2: NDArray | number): NDArray;
2418
- /**
2419
- * Returns element-wise True where signbit is set (less than zero)
2420
- *
2421
- * @param x - Input array
2422
- * @returns Boolean array where True means signbit is set
2423
- */
2424
- export declare function signbit(x: NDArray): NDArray;
2425
- /**
2426
- * Return the next floating-point value after x1 towards x2, element-wise
2427
- *
2428
- * @param x1 - Values to find the next representable value of
2429
- * @param x2 - Direction to look for the next representable value
2430
- * @returns Array of next representable values
2431
- */
2432
- export declare function nextafter(x1: NDArray, x2: NDArray | number): NDArray;
2433
- /**
2434
- * Return the distance between x and the nearest adjacent number
2435
- *
2436
- * @param x - Input array
2437
- * @returns Array of spacing values
2438
- */
2439
- export declare function spacing(x: NDArray): NDArray;
2440
- /**
2441
- * Test element-wise for complex number.
2442
- *
2443
- * For complex arrays, returns true for elements with non-zero imaginary part.
2444
- * For real arrays, always returns false.
2445
- *
2446
- * @param x - Input array
2447
- * @returns Boolean array
2448
- */
2449
- export declare function iscomplex(x: NDArray): NDArray;
2450
- /**
2451
- * Check whether array is complex type.
2452
- *
2453
- * @param x - Input array
2454
- * @returns true if dtype is complex64 or complex128
2455
- */
2456
- export declare function iscomplexobj(x: NDArray): boolean;
2457
- /**
2458
- * Test element-wise for real number (not complex).
2459
- *
2460
- * For complex arrays, returns true for elements with zero imaginary part.
2461
- * For real arrays, always returns true.
2462
- *
2463
- * @param x - Input array
2464
- * @returns Boolean array
2465
- */
2466
- export declare function isreal(x: NDArray): NDArray;
2467
- /**
2468
- * Check whether array is real type (not complex).
2469
- *
2470
- * @param x - Input array
2471
- * @returns true if dtype is NOT complex64 or complex128
2472
- */
2473
- export declare function isrealobj(x: NDArray): boolean;
2474
- /**
2475
- * Return the real part of complex argument.
2476
- *
2477
- * For complex arrays, returns the real components.
2478
- * For real arrays, returns a copy of the input.
2479
- *
2480
- * @param x - Input array
2481
- * @returns Array with real parts
2482
- */
2483
- export declare function real(x: NDArray): NDArray;
2484
- /**
2485
- * Return the imaginary part of complex argument.
2486
- *
2487
- * For complex arrays, returns the imaginary components.
2488
- * For real arrays, returns zeros.
2489
- *
2490
- * @param x - Input array
2491
- * @returns Array with imaginary parts
2492
- */
2493
- export declare function imag(x: NDArray): NDArray;
2494
- /**
2495
- * Return the complex conjugate.
2496
- *
2497
- * For complex arrays, negates the imaginary part: (a + bi) -> (a - bi)
2498
- * For real arrays, returns a copy of the input.
2499
- *
2500
- * @param x - Input array
2501
- * @returns Complex conjugate array
2502
- */
2503
- export declare function conj(x: NDArray): NDArray;
2504
- export declare const conjugate: typeof conj;
2505
- /**
2506
- * Return the angle (phase) of complex argument.
2507
- *
2508
- * angle(z) = arctan2(imag(z), real(z))
2509
- *
2510
- * For real arrays, returns 0 for positive, pi for negative.
2511
- *
2512
- * @param x - Input array
2513
- * @param deg - Return angle in degrees if true (default: false, returns radians)
2514
- * @returns Array with angles in radians (or degrees)
2515
- */
2516
- export declare function angle(x: NDArray, deg?: boolean): NDArray;
2517
- /**
2518
- * Test element-wise for negative infinity
2519
- * @param x - Input array
2520
- * @returns Boolean array
2521
- */
2522
- export declare function isneginf(x: NDArray): NDArray;
2523
- /**
2524
- * Test element-wise for positive infinity
2525
- * @param x - Input array
2526
- * @returns Boolean array
2527
- */
2528
- export declare function isposinf(x: NDArray): NDArray;
2529
- /**
2530
- * Check if array is Fortran contiguous (column-major order)
2531
- * @param x - Input array
2532
- * @returns true if F-contiguous
2533
- */
2534
- export declare function isfortran(x: NDArray): boolean;
2535
- /**
2536
- * Returns array with complex parts close to zero set to real
2537
- * Since numpy-ts doesn't support complex numbers, returns copy
2538
- * @param x - Input array
2539
- * @param tol - Tolerance
2540
- * @returns Copy of input array
2541
- */
2542
- export declare function real_if_close(x: NDArray, tol?: number): NDArray;
2543
- /**
2544
- * Check if element is a scalar type
2545
- * @param val - Value to check
2546
- * @returns true if scalar
2547
- */
2548
- export declare function isscalar(val: unknown): boolean;
2549
- /**
2550
- * Check if object is iterable
2551
- * @param obj - Object to check
2552
- * @returns true if iterable
2553
- */
2554
- export declare function iterable(obj: unknown): boolean;
2555
- /**
2556
- * Check if dtype meets specified criteria
2557
- * @param dtype - Dtype to check
2558
- * @param kind - Kind of dtype ('b' bool, 'i' int, 'u' uint, 'f' float)
2559
- * @returns true if dtype matches kind
2560
- */
2561
- export declare function isdtype(dtype: DType, kind: string): boolean;
2562
- /**
2563
- * Find the dtype that can represent both input dtypes
2564
- * @param dtype1 - First dtype
2565
- * @param dtype2 - Second dtype
2566
- * @returns Promoted dtype
2567
- */
2568
- export declare function promote_types(dtype1: DType, dtype2: DType): DType;
2569
- /**
2570
- * Einstein summation convention
2571
- *
2572
- * Performs tensor contractions and reductions using Einstein notation.
2573
- *
2574
- * @param subscripts - Einstein summation subscripts (e.g., 'ij,jk->ik')
2575
- * @param operands - Input arrays
2576
- * @returns Result of the Einstein summation
2577
- *
2578
- * @example
2579
- * // Matrix multiplication
2580
- * einsum('ij,jk->ik', a, b)
2581
- *
2582
- * @example
2583
- * // Inner product
2584
- * einsum('i,i->', a, b)
2585
- *
2586
- * @example
2587
- * // Trace
2588
- * einsum('ii->', a)
2589
- */
2590
- export declare function einsum(subscripts: string, ...operands: NDArray[]): NDArray | number | bigint | Complex;
2591
- /**
2592
- * numpy.linalg module - Linear algebra functions
2593
- */
2594
- export declare const linalg: {
2595
- /**
2596
- * Cross product of two vectors.
2597
- */
2598
- cross: (a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number, axis?: number) => NDArray | number;
2599
- /**
2600
- * Compute the norm of a vector or matrix.
2601
- */
2602
- norm: (x: NDArray, ord?: number | "fro" | "nuc" | null, axis?: number | [number, number] | null, keepdims?: boolean) => NDArray | number;
2603
- /**
2604
- * Compute the vector norm.
2605
- */
2606
- vector_norm: (x: NDArray, ord?: number, axis?: number | null, keepdims?: boolean) => NDArray | number;
2607
- /**
2608
- * Compute the matrix norm.
2609
- */
2610
- matrix_norm: (x: NDArray, ord?: number | "fro" | "nuc", keepdims?: boolean) => NDArray | number;
2611
- /**
2612
- * QR decomposition.
2613
- */
2614
- qr: (a: NDArray, mode?: "reduced" | "complete" | "r" | "raw") => {
2615
- q: NDArray;
2616
- r: NDArray;
2617
- } | NDArray | {
2618
- h: NDArray;
2619
- tau: NDArray;
2620
- };
2621
- /**
2622
- * Cholesky decomposition.
2623
- */
2624
- cholesky: (a: NDArray, upper?: boolean) => NDArray;
2625
- /**
2626
- * Singular Value Decomposition.
2627
- */
2628
- svd: (a: NDArray, full_matrices?: boolean, compute_uv?: boolean) => {
2629
- u: NDArray;
2630
- s: NDArray;
2631
- vt: NDArray;
2632
- } | NDArray;
2633
- /**
2634
- * Compute the determinant of a matrix.
2635
- */
2636
- det: (a: NDArray) => number;
2637
- /**
2638
- * Compute the matrix inverse.
2639
- */
2640
- inv: (a: NDArray) => NDArray;
2641
- /**
2642
- * Solve a linear system.
2643
- */
2644
- solve: (a: NDArray, b: NDArray) => NDArray;
2645
- /**
2646
- * Least-squares solution to a linear matrix equation.
2647
- */
2648
- lstsq: (a: NDArray, b: NDArray, rcond?: number | null) => {
2649
- x: NDArray;
2650
- residuals: NDArray;
2651
- rank: number;
2652
- s: NDArray;
2653
- };
2654
- /**
2655
- * Compute the condition number.
2656
- */
2657
- cond: (a: NDArray, p?: number | "fro" | "nuc") => number;
2658
- /**
2659
- * Compute the matrix rank.
2660
- */
2661
- matrix_rank: (a: NDArray, tol?: number) => number;
2662
- /**
2663
- * Raise a square matrix to an integer power.
2664
- */
2665
- matrix_power: (a: NDArray, n: number) => NDArray;
2666
- /**
2667
- * Compute the Moore-Penrose pseudo-inverse.
2668
- */
2669
- pinv: (a: NDArray, rcond?: number) => NDArray;
2670
- /**
2671
- * Compute eigenvalues and eigenvectors.
2672
- */
2673
- eig: (a: NDArray) => {
2674
- w: NDArray;
2675
- v: NDArray;
2676
- };
2677
- /**
2678
- * Compute eigenvalues and eigenvectors of a Hermitian matrix.
2679
- */
2680
- eigh: (a: NDArray, UPLO?: "L" | "U") => {
2681
- w: NDArray;
2682
- v: NDArray;
2683
- };
2684
- /**
2685
- * Compute eigenvalues of a matrix.
2686
- */
2687
- eigvals: (a: NDArray) => NDArray;
2688
- /**
2689
- * Compute eigenvalues of a Hermitian matrix.
2690
- */
2691
- eigvalsh: (a: NDArray, UPLO?: "L" | "U") => NDArray;
2692
- };
2693
- /**
2694
- * Take values from the input array by matching 1d index and data slices along axis.
2695
- *
2696
- * @param arr - Input array
2697
- * @param indices - Index array with same ndim as arr
2698
- * @param axis - The axis along which to select values
2699
- * @returns Array of values taken along the axis
2700
- */
2701
- export declare function take_along_axis(arr: NDArray, indices: NDArray, axis: number): NDArray;
2702
- /**
2703
- * Put values into the destination array using 1d index and data slices along axis.
2704
- *
2705
- * @param arr - Destination array (modified in-place)
2706
- * @param indices - Index array with same ndim as arr
2707
- * @param values - Values to put
2708
- * @param axis - The axis along which to put values
2709
- */
2710
- export declare function put_along_axis(arr: NDArray, indices: NDArray, values: NDArray, axis: number): void;
2711
- /**
2712
- * Change elements of array based on conditional mask.
2713
- *
2714
- * @param a - Array to modify (in-place)
2715
- * @param mask - Boolean mask array
2716
- * @param values - Values to put where mask is True
2717
- */
2718
- export declare function putmask(a: NDArray, mask: NDArray, values: NDArray | number | bigint): void;
2719
- /**
2720
- * Return selected slices of array along given axis.
2721
- *
2722
- * @param condition - Boolean array for selecting
2723
- * @param a - Array from which to select
2724
- * @param axis - Axis along which to select (if undefined, works on flattened array)
2725
- * @returns Compressed array
2726
- */
2727
- export declare function compress(condition: NDArray, a: NDArray, axis?: number): NDArray;
2728
- /**
2729
- * Return an array drawn from elements in choicelist, depending on conditions.
2730
- *
2731
- * @param condlist - List of boolean arrays (conditions)
2732
- * @param choicelist - List of arrays to choose from
2733
- * @param defaultVal - Default value when no condition is met (default 0)
2734
- * @returns Array with selected values
2735
- */
2736
- export declare function select(condlist: NDArray[], choicelist: NDArray[], defaultVal?: number | bigint): NDArray;
2737
- /**
2738
- * Change elements of an array based on conditional and input values.
2739
- *
2740
- * @param arr - Array to modify (in-place)
2741
- * @param mask - Boolean mask array
2742
- * @param vals - Values to place where mask is True (cycles if shorter)
2743
- */
2744
- export declare function place(arr: NDArray, mask: NDArray, vals: NDArray): void;
2745
- /**
2746
- * Fill the main diagonal of a given array (modifies in-place)
2747
- * @param a - Array (at least 2D)
2748
- * @param val - Value or array of values to fill diagonal with
2749
- * @param wrap - Whether to wrap for tall matrices
2750
- */
2751
- export declare function fill_diagonal(a: NDArray, val: NDArray | number, wrap?: boolean): void;
2752
- /**
2753
- * Return the indices to access the main diagonal of an array.
2754
- *
2755
- * @param n - Size of arrays for which indices are returned
2756
- * @param ndim - Number of dimensions (default 2)
2757
- * @returns Tuple of index arrays
2758
- */
2759
- export declare function diag_indices(n: number, ndim?: number): NDArray[];
2760
- /**
2761
- * Return the indices to access the main diagonal of an n-dimensional array.
2762
- *
2763
- * @param arr - Input array (must have all equal dimensions)
2764
- * @returns Tuple of index arrays
2765
- */
2766
- export declare function diag_indices_from(arr: NDArray): NDArray[];
2767
- /**
2768
- * Return the indices for the lower-triangle of an (n, m) array.
2769
- *
2770
- * @param n - Number of rows
2771
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
2772
- * @param m - Number of columns (default n)
2773
- * @returns Tuple of row and column index arrays
2774
- */
2775
- export declare function tril_indices(n: number, k?: number, m?: number): NDArray[];
2776
- /**
2777
- * Return the indices for the lower-triangle of arr.
2778
- *
2779
- * @param arr - Input 2-D array
2780
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
2781
- * @returns Tuple of row and column index arrays
2782
- */
2783
- export declare function tril_indices_from(arr: NDArray, k?: number): NDArray[];
2784
- /**
2785
- * Return the indices for the upper-triangle of an (n, m) array.
2786
- *
2787
- * @param n - Number of rows
2788
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
2789
- * @param m - Number of columns (default n)
2790
- * @returns Tuple of row and column index arrays
2791
- */
2792
- export declare function triu_indices(n: number, k?: number, m?: number): NDArray[];
2793
- /**
2794
- * Return the indices for the upper-triangle of arr.
2795
- *
2796
- * @param arr - Input 2-D array
2797
- * @param k - Diagonal offset (0 = main, positive = above, negative = below)
2798
- * @returns Tuple of row and column index arrays
2799
- */
2800
- export declare function triu_indices_from(arr: NDArray, k?: number): NDArray[];
2801
- /**
2802
- * Return the indices to access (n, n) arrays, given a masking function.
2803
- *
2804
- * @param n - The returned indices will be valid to access arrays of shape (n, n)
2805
- * @param mask_func - A function that generates an (n, n) boolean mask
2806
- * @param k - Optional diagonal offset passed to mask_func
2807
- * @returns Tuple of row and column index arrays
2808
- */
2809
- export declare function mask_indices(n: number, mask_func: (n: number, k: number) => NDArray, k?: number): NDArray[];
2810
- /**
2811
- * Return an array representing the indices of a grid.
2812
- *
2813
- * @param dimensions - The shape of the grid
2814
- * @param dtype - Data type of result (default 'int32')
2815
- * @returns Array of shape (len(dimensions), *dimensions)
2816
- */
2817
- export declare function indices(dimensions: number[], dtype?: 'int32' | 'int64' | 'float64'): NDArray;
2818
- /**
2819
- * Construct an open mesh from multiple sequences.
2820
- *
2821
- * This function returns a list of arrays with shapes suitable for broadcasting.
2822
- *
2823
- * @param args - 1-D sequences
2824
- * @returns Tuple of arrays for open mesh
2825
- */
2826
- export declare function ix_(...args: NDArray[]): NDArray[];
2827
- /**
2828
- * Convert a tuple of index arrays into an array of flat indices.
2829
- *
2830
- * @param multi_index - Tuple of index arrays
2831
- * @param dims - Shape of array into which indices apply
2832
- * @param mode - How to handle out-of-bounds indices ('raise', 'wrap', 'clip')
2833
- * @returns Flattened indices
2834
- */
2835
- export declare function ravel_multi_index(multi_index: NDArray[], dims: number[], mode?: 'raise' | 'wrap' | 'clip'): NDArray;
2836
- /**
2837
- * Convert a flat index or array of flat indices into a tuple of coordinate arrays.
2838
- *
2839
- * @param indices - Array of indices or single index
2840
- * @param shape - Shape of the array to index into
2841
- * @param order - Row-major ('C') or column-major ('F') order
2842
- * @returns Tuple of coordinate arrays
2843
- */
2844
- export declare function unravel_index(indices: NDArray | number, shape: number[], order?: 'C' | 'F'): NDArray[];
2845
- /**
2846
- * Return a sorted copy of an array
2847
- * @param a - Input array
2848
- * @param axis - Axis along which to sort. Default is -1 (last axis)
2849
- * @returns Sorted array
2850
- */
2851
- export declare function sort(a: NDArray, axis?: number): NDArray;
2852
- /**
2853
- * Returns the indices that would sort an array
2854
- * @param a - Input array
2855
- * @param axis - Axis along which to sort. Default is -1 (last axis)
2856
- * @returns Array of indices that sort the input array
2857
- */
2858
- export declare function argsort(a: NDArray, axis?: number): NDArray;
2859
- /**
2860
- * Perform an indirect stable sort using a sequence of keys
2861
- * @param keys - Array of NDArrays, the last key is the primary sort key
2862
- * @returns Array of indices that would sort the keys
2863
- */
2864
- export declare function lexsort(keys: NDArray[]): NDArray;
2865
- /**
2866
- * Partially sort an array
2867
- * @param a - Input array
2868
- * @param kth - Element index to partition by
2869
- * @param axis - Axis along which to sort. Default is -1 (last axis)
2870
- * @returns Partitioned array
2871
- */
2872
- export declare function partition(a: NDArray, kth: number, axis?: number): NDArray;
2873
- /**
2874
- * Returns indices that would partition an array
2875
- * @param a - Input array
2876
- * @param kth - Element index to partition by
2877
- * @param axis - Axis along which to sort. Default is -1 (last axis)
2878
- * @returns Array of indices
2879
- */
2880
- export declare function argpartition(a: NDArray, kth: number, axis?: number): NDArray;
2881
- /**
2882
- * Sort a complex array using the real part first, then the imaginary part
2883
- * For real arrays, returns a sorted 1D array
2884
- * @param a - Input array
2885
- * @returns Sorted 1D array
2886
- */
2887
- export declare function sort_complex(a: NDArray): NDArray;
2888
- /**
2889
- * Return the indices of the elements that are non-zero
2890
- * @param a - Input array
2891
- * @returns Tuple of arrays, one for each dimension
2892
- */
2893
- export declare function nonzero(a: NDArray): NDArray[];
2894
- /**
2895
- * Find the indices of array elements that are non-zero, grouped by element
2896
- * Returns a 2D array where each row is the index of a non-zero element.
2897
- * This is equivalent to transpose(nonzero(a)).
2898
- * @param a - Input array
2899
- * @returns 2D array of shape (N, ndim) where N is number of non-zero elements
2900
- */
2901
- export declare function argwhere(a: NDArray): NDArray;
2902
- /**
2903
- * Return indices of non-zero elements in flattened array
2904
- * @param a - Input array
2905
- * @returns Array of indices
2906
- */
2907
- export declare function flatnonzero(a: NDArray): NDArray;
2908
- /**
2909
- * Return elements from x or y depending on condition
2910
- * If only condition is given, returns indices where condition is true (like nonzero)
2911
- * @param condition - Boolean array or condition
2912
- * @param x - Values where condition is true (optional)
2913
- * @param y - Values where condition is false (optional)
2914
- * @returns Array with elements chosen from x or y, or indices if only condition given
2915
- */
2916
- export declare function where(condition: NDArray, x?: NDArray, y?: NDArray): NDArray | NDArray[];
2917
- /**
2918
- * Find indices where elements should be inserted to maintain order
2919
- * @param a - Input array (must be sorted in ascending order)
2920
- * @param v - Values to insert
2921
- * @param side - 'left' or 'right' side to insert
2922
- * @returns Indices where values should be inserted
2923
- */
2924
- export declare function searchsorted(a: NDArray, v: NDArray, side?: 'left' | 'right'): NDArray;
2925
- /**
2926
- * Return the elements of an array that satisfy some condition
2927
- * @param condition - Boolean array
2928
- * @param a - Input array
2929
- * @returns 1D array of elements where condition is true
2930
- */
2931
- export declare function extract(condition: NDArray, a: NDArray): NDArray;
2932
- /**
2933
- * Count number of non-zero values in the array
2934
- * @param a - Input array
2935
- * @param axis - Axis along which to count (optional)
2936
- * @returns Count of non-zero values
2937
- */
2938
- export declare function count_nonzero(a: NDArray, axis?: number): NDArray | number;
2939
- /**
2940
- * Round an array to the given number of decimals
2941
- * @param a - Input array
2942
- * @param decimals - Number of decimal places to round to (default: 0)
2943
- * @returns Rounded array
2944
- */
2945
- export declare function around(a: NDArray, decimals?: number): NDArray;
2946
- export { around as round_ };
2947
- /**
2948
- * Return the ceiling of the input, element-wise
2949
- * @param x - Input array
2950
- * @returns Element-wise ceiling
2951
- */
2952
- export declare function ceil(x: NDArray): NDArray;
2953
- /**
2954
- * Round to nearest integer towards zero
2955
- * @param x - Input array
2956
- * @returns Array with values truncated towards zero
2957
- */
2958
- export declare function fix(x: NDArray): NDArray;
2959
- /**
2960
- * Return the floor of the input, element-wise
2961
- * @param x - Input array
2962
- * @returns Element-wise floor
2963
- */
2964
- export declare function floor(x: NDArray): NDArray;
2965
- /**
2966
- * Round elements of the array to the nearest integer
2967
- * @param x - Input array
2968
- * @returns Array with rounded integer values
2969
- */
2970
- export declare function rint(x: NDArray): NDArray;
2971
- /**
2972
- * Evenly round to the given number of decimals (alias for around)
2973
- * @param a - Input array
2974
- * @param decimals - Number of decimal places to round to (default: 0)
2975
- * @returns Rounded array
2976
- */
2977
- export { around as round };
2978
- /**
2979
- * Return the truncated value of the input, element-wise
2980
- * @param x - Input array
2981
- * @returns Element-wise truncated values
2982
- */
2983
- export declare function trunc(x: NDArray): NDArray;
2984
- /**
2985
- * Find the unique elements of an array
2986
- * @param ar - Input array
2987
- * @param returnIndex - If True, also return the indices of the first occurrences
2988
- * @param returnInverse - If True, also return the indices to reconstruct the original array
2989
- * @param returnCounts - If True, also return the number of times each unique value appears
2990
- * @returns Unique sorted values, and optionally indices/inverse/counts
2991
- */
2992
- export declare function unique(ar: NDArray, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): NDArray | {
2993
- values: NDArray;
2994
- indices?: NDArray;
2995
- inverse?: NDArray;
2996
- counts?: NDArray;
2997
- };
2998
- /**
2999
- * Test whether each element of a 1-D array is also present in a second array
3000
- * @param ar1 - Input array
3001
- * @param ar2 - Test values
3002
- * @returns Boolean array indicating membership
3003
- */
3004
- export declare function in1d(ar1: NDArray, ar2: NDArray): NDArray;
3005
- /**
3006
- * Find the intersection of two arrays
3007
- * @param ar1 - First input array
3008
- * @param ar2 - Second input array
3009
- * @returns Sorted 1D array of common and unique elements
3010
- */
3011
- export declare function intersect1d(ar1: NDArray, ar2: NDArray): NDArray;
3012
- /**
3013
- * Test whether each element of an ND array is also present in a second array
3014
- * @param element - Input array
3015
- * @param testElements - Test values
3016
- * @returns Boolean array indicating membership (same shape as element)
3017
- */
3018
- export declare function isin(element: NDArray, testElements: NDArray): NDArray;
3019
- /**
3020
- * Find the set difference of two arrays
3021
- * @param ar1 - First input array
3022
- * @param ar2 - Second input array
3023
- * @returns Sorted 1D array of values in ar1 that are not in ar2
3024
- */
3025
- export declare function setdiff1d(ar1: NDArray, ar2: NDArray): NDArray;
3026
- /**
3027
- * Find the set exclusive-or of two arrays
3028
- * @param ar1 - First input array
3029
- * @param ar2 - Second input array
3030
- * @returns Sorted 1D array of values that are in only one array
3031
- */
3032
- export declare function setxor1d(ar1: NDArray, ar2: NDArray): NDArray;
3033
- /**
3034
- * Find the union of two arrays
3035
- * @param ar1 - First input array
3036
- * @param ar2 - Second input array
3037
- * @returns Sorted 1D array of unique values from both arrays
3038
- */
3039
- export declare function union1d(ar1: NDArray, ar2: NDArray): NDArray;
3040
- /**
3041
- * Calculate the n-th discrete difference along the given axis
3042
- * @param a - Input array
3043
- * @param n - Number of times values are differenced (default: 1)
3044
- * @param axis - Axis along which to compute difference (default: -1)
3045
- * @returns Array of differences
3046
- */
3047
- export declare function diff(a: NDArray, n?: number, axis?: number): NDArray;
3048
- /**
3049
- * The differences between consecutive elements of a flattened array
3050
- * @param ary - Input array
3051
- * @param to_end - Number(s) to append at the end
3052
- * @param to_begin - Number(s) to prepend at the beginning
3053
- * @returns Array of differences
3054
- */
3055
- export declare function ediff1d(ary: NDArray, to_end?: number[] | null, to_begin?: number[] | null): NDArray;
3056
- /**
3057
- * Return the gradient of an N-dimensional array
3058
- * The gradient is computed using second order accurate central differences
3059
- * in the interior and first order accurate one-sided differences at the boundaries.
3060
- * @param f - Input array
3061
- * @param varargs - Spacing between values (scalar or array per dimension)
3062
- * @param axis - Axis or axes along which to compute gradient
3063
- * @returns Array of gradients (one per axis) or single gradient
3064
- */
3065
- export declare function gradient(f: NDArray, varargs?: number | number[], axis?: number | number[] | null): NDArray | NDArray[];
3066
- /**
3067
- * Return the cross product of two (arrays of) vectors
3068
- * @param a - First input array
3069
- * @param b - Second input array
3070
- * @param axisa - Axis of a that defines the vector(s) (default: -1)
3071
- * @param axisb - Axis of b that defines the vector(s) (default: -1)
3072
- * @param axisc - Axis of c containing the cross product (default: -1)
3073
- * @returns Cross product array
3074
- */
3075
- export declare function cross(a: NDArray, b: NDArray, axisa?: number, axisb?: number, axisc?: number): NDArray;
3076
- /**
3077
- * Count number of occurrences of each value in array of non-negative ints.
3078
- *
3079
- * @param x - Input array (must contain non-negative integers)
3080
- * @param weights - Optional weights, same shape as x
3081
- * @param minlength - Minimum number of bins for output (default: 0)
3082
- * @returns Array of bin counts
3083
- */
3084
- export declare function bincount(x: NDArray, weights?: NDArray, minlength?: number): NDArray;
3085
- /**
3086
- * Return the indices of the bins to which each value in input array belongs.
3087
- *
3088
- * @param x - Input array to be binned
3089
- * @param bins - Array of bins (monotonically increasing or decreasing)
3090
- * @param right - If true, intervals are closed on the right (default: false)
3091
- * @returns Array of bin indices
3092
- */
3093
- export declare function digitize(x: NDArray, bins: NDArray, right?: boolean): NDArray;
3094
- /**
3095
- * Compute the histogram of a set of data.
3096
- *
3097
- * @param a - Input data (flattened if not 1D)
3098
- * @param bins - Number of bins (default: 10) or array of bin edges
3099
- * @param range - Lower and upper range of bins
3100
- * @param density - If true, return probability density function (default: false)
3101
- * @param weights - Optional weights for each data point
3102
- * @returns Tuple of [hist, bin_edges]
3103
- */
3104
- export declare function histogram(a: NDArray, bins?: number | NDArray, range?: [number, number], density?: boolean, weights?: NDArray): [NDArray, NDArray];
3105
- /**
3106
- * Compute the bi-dimensional histogram of two data samples.
3107
- *
3108
- * @param x - Array of x coordinates
3109
- * @param y - Array of y coordinates (must have same length as x)
3110
- * @param bins - Number of bins or [nx, ny] or [x_edges, y_edges]
3111
- * @param range - [[xmin, xmax], [ymin, ymax]]
3112
- * @param density - If true, return probability density function
3113
- * @param weights - Optional weights for each data point
3114
- * @returns Tuple of [hist, x_edges, y_edges]
3115
- */
3116
- export declare function histogram2d(x: NDArray, y: NDArray, bins?: number | [number, number] | [NDArray, NDArray], range?: [[number, number], [number, number]], density?: boolean, weights?: NDArray): [NDArray, NDArray, NDArray];
3117
- /**
3118
- * Compute the multidimensional histogram of some data.
3119
- *
3120
- * @param sample - Array of shape (N, D) where N is number of samples and D is number of dimensions
3121
- * @param bins - Number of bins for all axes, or array of bin counts per axis
3122
- * @param range - Array of [min, max] for each dimension
3123
- * @param density - If true, return probability density function
3124
- * @param weights - Optional weights for each sample
3125
- * @returns Tuple of [hist, edges (array of edge arrays)]
3126
- */
3127
- export declare function histogramdd(sample: NDArray, bins?: number | number[], range?: [number, number][], density?: boolean, weights?: NDArray): [NDArray, NDArray[]];
3128
- /**
3129
- * Cross-correlation of two 1-dimensional sequences.
3130
- *
3131
- * @param a - First input sequence
3132
- * @param v - Second input sequence
3133
- * @param mode - 'full', 'same', or 'valid' (default: 'full')
3134
- * @returns Cross-correlation of a and v
3135
- */
3136
- export declare function correlate(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
3137
- /**
3138
- * Discrete, linear convolution of two one-dimensional sequences.
3139
- *
3140
- * @param a - First input sequence
3141
- * @param v - Second input sequence
3142
- * @param mode - 'full', 'same', or 'valid' (default: 'full')
3143
- * @returns Convolution of a and v
3144
- */
3145
- export declare function convolve(a: NDArray, v: NDArray, mode?: 'full' | 'same' | 'valid'): NDArray;
3146
- /**
3147
- * Estimate a covariance matrix.
3148
- *
3149
- * @param m - Input array (1D or 2D). Each row represents a variable, columns are observations.
3150
- * @param y - Optional second array (for 2 variable case)
3151
- * @param rowvar - If true, each row is a variable (default: true)
3152
- * @param bias - If true, use N for normalization; if false, use N-1 (default: false)
3153
- * @param ddof - Delta degrees of freedom (overrides bias if provided)
3154
- * @returns Covariance matrix
3155
- */
3156
- export declare function cov(m: NDArray, y?: NDArray, rowvar?: boolean, bias?: boolean, ddof?: number): NDArray;
3157
- /**
3158
- * Return Pearson product-moment correlation coefficients.
3159
- *
3160
- * @param x - Input array (1D or 2D)
3161
- * @param y - Optional second array (for 2 variable case)
3162
- * @param rowvar - If true, each row is a variable (default: true)
3163
- * @returns Correlation coefficient matrix
3164
- */
3165
- export declare function corrcoef(x: NDArray, y?: NDArray, rowvar?: boolean): NDArray;
3166
- //# sourceMappingURL=ndarray.d.ts.map