numpy-ts 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -24
- package/dist/numpy-ts.browser.js +2 -2
- package/dist/numpy-ts.esm.js +2 -2
- package/dist/numpy-ts.node-io.cjs +3 -3
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +3 -3
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +2 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/core/complex.d.ts +94 -0
- package/dist/types/core/dtype.d.ts +62 -3
- package/dist/types/core/ndarray.d.ts +950 -52
- package/dist/types/core/storage.d.ts +15 -4
- package/dist/types/index.d.ts +6 -5
- package/dist/types/ops/advanced.d.ts +65 -0
- package/dist/types/ops/arithmetic.d.ts +103 -0
- package/dist/types/ops/bitwise.d.ts +30 -0
- package/dist/types/ops/comparison.d.ts +6 -0
- package/dist/types/ops/complex.d.ts +65 -0
- package/dist/types/ops/exponential.d.ts +9 -0
- package/dist/types/ops/hyperbolic.d.ts +6 -0
- package/dist/types/ops/linalg.d.ts +130 -5
- package/dist/types/ops/logic.d.ts +35 -17
- package/dist/types/ops/reduction.d.ts +34 -18
- package/dist/types/ops/rounding.d.ts +3 -0
- package/dist/types/ops/sets.d.ts +49 -0
- package/dist/types/ops/shape.d.ts +13 -0
- package/dist/types/ops/statistics.d.ts +22 -0
- package/dist/types/ops/trig.d.ts +6 -0
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @internal - This is not part of the public API
|
|
7
7
|
*/
|
|
8
8
|
import { type DType, type TypedArray } from './dtype';
|
|
9
|
+
import { Complex } from './complex';
|
|
9
10
|
/**
|
|
10
11
|
* Internal storage for NDArray data
|
|
11
12
|
* Manages the underlying TypedArray and metadata
|
|
@@ -55,20 +56,30 @@ export declare class ArrayStorage {
|
|
|
55
56
|
get isFContiguous(): boolean;
|
|
56
57
|
/**
|
|
57
58
|
* Get element at linear index (respects strides and offset)
|
|
59
|
+
* For complex dtypes, returns a Complex object.
|
|
58
60
|
*/
|
|
59
|
-
iget(linearIndex: number): number | bigint;
|
|
61
|
+
iget(linearIndex: number): number | bigint | Complex;
|
|
60
62
|
/**
|
|
61
63
|
* Set element at linear index (respects strides and offset)
|
|
64
|
+
* For complex dtypes, value can be a Complex object, {re, im} object, or number.
|
|
62
65
|
*/
|
|
63
|
-
iset(linearIndex: number, value: number | bigint
|
|
66
|
+
iset(linearIndex: number, value: number | bigint | Complex | {
|
|
67
|
+
re: number;
|
|
68
|
+
im: number;
|
|
69
|
+
}): void;
|
|
64
70
|
/**
|
|
65
71
|
* Get element at multi-index position
|
|
72
|
+
* For complex dtypes, returns a Complex object.
|
|
66
73
|
*/
|
|
67
|
-
get(...indices: number[]): number | bigint;
|
|
74
|
+
get(...indices: number[]): number | bigint | Complex;
|
|
68
75
|
/**
|
|
69
76
|
* Set element at multi-index position
|
|
77
|
+
* For complex dtypes, value can be a Complex object, {re, im} object, or number.
|
|
70
78
|
*/
|
|
71
|
-
set(indices: number[], value: number | bigint
|
|
79
|
+
set(indices: number[], value: number | bigint | Complex | {
|
|
80
|
+
re: number;
|
|
81
|
+
im: number;
|
|
82
|
+
}): void;
|
|
72
83
|
/**
|
|
73
84
|
* Create a deep copy of this storage
|
|
74
85
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module numpy-ts
|
|
5
5
|
*/
|
|
6
|
-
export {
|
|
6
|
+
export { Complex, type ComplexInput } from './core/complex';
|
|
7
|
+
export { NDArray, zeros, ones, array, arange, linspace, logspace, geomspace, eye, empty, full, identity, asarray, copy, zeros_like, ones_like, empty_like, full_like, asanyarray, asarray_chkfinite, ascontiguousarray, asfortranarray, require, diag, diagflat, frombuffer, fromfile, fromfunction, fromiter, fromstring, meshgrid, tri, tril, triu, vander, sqrt, power, pow, // alias for power
|
|
7
8
|
exp, exp2, expm1, log, log2, log10, log1p, logaddexp, logaddexp2, absolute, abs, // alias for absolute
|
|
8
9
|
negative, sign, mod, divide, true_divide, // alias for divide
|
|
9
|
-
floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, float_power, fmod, frexp, gcd, lcm, ldexp, modf, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, linalg, sin, cos, tan, arcsin, asin, // alias for arcsin
|
|
10
|
+
floor_divide, positive, reciprocal, cbrt, fabs, divmod, square, remainder, heaviside, float_power, fmod, frexp, gcd, lcm, ldexp, modf, clip, maximum, minimum, fmax, fmin, nan_to_num, interp, unwrap, sinc, i0, dot, trace, diagonal, kron, transpose, inner, outer, tensordot, einsum, vdot, vecdot, matrix_transpose, permute_dims, matvec, vecmat, linalg, sin, cos, tan, arcsin, asin, // alias for arcsin
|
|
10
11
|
arccos, acos, // alias for arccos
|
|
11
12
|
arctan, atan, // alias for arctan
|
|
12
13
|
arctan2, atan2, // alias for arctan2
|
|
13
14
|
hypot, degrees, radians, deg2rad, rad2deg, sinh, cosh, tanh, arcsinh, asinh, // alias for arcsinh
|
|
14
15
|
arccosh, acosh, // alias for arccosh
|
|
15
16
|
arctanh, atanh, // alias for arctanh
|
|
16
|
-
swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, split, array_split, vsplit, hsplit, tile, repeat, ravel, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, copyto, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, fill_diagonal, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumulative_sum, // alias for cumsum
|
|
17
|
+
swapaxes, moveaxis, concatenate, stack, vstack, hstack, dstack, concat, unstack, block, split, array_split, vsplit, hsplit, tile, repeat, ravel, flatten, fill, item, tolist, tobytes, byteswap, view, tofile, reshape, squeeze, expand_dims, flip, fliplr, flipud, rot90, roll, rollaxis, atleast_1d, atleast_2d, atleast_3d, dsplit, column_stack, row_stack, resize, append, delete_ as delete, insert, pad, broadcast_to, broadcast_arrays, broadcast_shapes, take, put, iindex, bindex, copyto, choose, array_equal, array_equiv, take_along_axis, put_along_axis, putmask, compress, select, place, fill_diagonal, diag_indices, diag_indices_from, tril_indices, tril_indices_from, triu_indices, triu_indices_from, mask_indices, indices, ix_, ravel_multi_index, unravel_index, cumsum, cumulative_sum, // alias for cumsum
|
|
17
18
|
cumprod, cumulative_prod, // alias for cumprod
|
|
18
19
|
max, amax, // alias for max
|
|
19
20
|
min, amin, // alias for min
|
|
20
|
-
ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, logical_and, logical_or, logical_not, logical_xor, isfinite, isinf, isnan, isnat, iscomplex, iscomplexobj, isreal, isrealobj, isneginf, isposinf, isfortran, real_if_close, isscalar, iterable, isdtype, promote_types, copysign, signbit, nextafter, spacing, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, argwhere, flatnonzero, where, searchsorted, extract, count_nonzero, around, round_, // alias for around
|
|
21
|
-
ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, diff, ediff1d, gradient, cross, bincount, digitize, histogram, histogram2d, histogramdd, correlate, convolve, cov, corrcoef, } from './core/ndarray';
|
|
21
|
+
ptp, median, percentile, quantile, average, nansum, nanprod, nanmean, nanvar, nanstd, nanmin, nanmax, nanargmin, nanargmax, nancumsum, nancumprod, nanmedian, nanquantile, nanpercentile, bitwise_and, bitwise_or, bitwise_xor, bitwise_not, invert, left_shift, right_shift, packbits, unpackbits, bitwise_count, bitwise_invert, bitwise_left_shift, bitwise_right_shift, logical_and, logical_or, logical_not, logical_xor, isfinite, isinf, isnan, isnat, iscomplex, iscomplexobj, isreal, isrealobj, real, imag, conj, conjugate, angle, isneginf, isposinf, isfortran, real_if_close, isscalar, iterable, isdtype, promote_types, copysign, signbit, nextafter, spacing, sort, argsort, lexsort, partition, argpartition, sort_complex, nonzero, argwhere, flatnonzero, where, searchsorted, extract, count_nonzero, around, round_, // alias for around
|
|
22
|
+
ceil, fix, floor, rint, round, trunc, unique, in1d, intersect1d, isin, setdiff1d, setxor1d, union1d, trim_zeros, unique_all, unique_counts, unique_inverse, unique_values, diff, ediff1d, gradient, cross, bincount, digitize, histogram, histogram2d, histogramdd, correlate, convolve, cov, corrcoef, histogram_bin_edges, trapezoid, apply_along_axis, apply_over_axes, may_share_memory, shares_memory, ndim, shape, size, geterr, seterr, can_cast, common_type, result_type, min_scalar_type, issubdtype, typename, mintypecode, poly, polyadd, polyder, polydiv, polyfit, polyint, polymul, polysub, polyval, roots, } from './core/ndarray';
|
|
22
23
|
export { parseNpy, serializeNpy, parseNpyHeader, parseNpyData, UnsupportedDTypeError, InvalidNpyError, SUPPORTED_DTYPES, DTYPE_TO_DESCR, type NpyHeader, type NpyMetadata, type NpyVersion, parseNpz, parseNpzSync, loadNpz, loadNpzSync, serializeNpz, serializeNpzSync, type NpzParseOptions, type NpzParseResult, type NpzSerializeOptions, } from './io';
|
|
23
24
|
import * as randomOps from './ops/random';
|
|
24
25
|
import { ArrayStorage } from './core/storage';
|
|
@@ -112,4 +112,69 @@ export declare function unravel_index(indices: ArrayStorage | number, shape: num
|
|
|
112
112
|
* @param wrap - Whether to wrap for tall matrices
|
|
113
113
|
*/
|
|
114
114
|
export declare function fill_diagonal(a: ArrayStorage, val: ArrayStorage | number, wrap?: boolean): void;
|
|
115
|
+
/**
|
|
116
|
+
* Apply a function along a given axis.
|
|
117
|
+
*
|
|
118
|
+
* @param arr - Input array storage
|
|
119
|
+
* @param axis - Axis along which to apply the function
|
|
120
|
+
* @param func1d - Function that takes a 1D array and returns a 1D array or scalar
|
|
121
|
+
* @returns Result array
|
|
122
|
+
*/
|
|
123
|
+
export declare function apply_along_axis(arr: ArrayStorage, axis: number, func1d: (slice: ArrayStorage) => ArrayStorage | number): ArrayStorage;
|
|
124
|
+
/**
|
|
125
|
+
* Apply a function over multiple axes.
|
|
126
|
+
*
|
|
127
|
+
* @param arr - Input array storage
|
|
128
|
+
* @param func - Function that operates on an array
|
|
129
|
+
* @param axes - Axes over which to apply the function
|
|
130
|
+
* @returns Result array
|
|
131
|
+
*/
|
|
132
|
+
export declare function apply_over_axes(arr: ArrayStorage, func: (a: ArrayStorage, axis: number) => ArrayStorage, axes: number[]): ArrayStorage;
|
|
133
|
+
/**
|
|
134
|
+
* Check if two arrays may share memory.
|
|
135
|
+
*
|
|
136
|
+
* In JavaScript, we can't directly check memory sharing like in Python.
|
|
137
|
+
* This is a conservative implementation that returns true if they share
|
|
138
|
+
* the same underlying buffer.
|
|
139
|
+
*
|
|
140
|
+
* @param a - First array storage
|
|
141
|
+
* @param b - Second array storage
|
|
142
|
+
* @returns True if arrays may share memory
|
|
143
|
+
*/
|
|
144
|
+
export declare function may_share_memory(a: ArrayStorage, b: ArrayStorage): boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Check if two arrays share memory.
|
|
147
|
+
*
|
|
148
|
+
* This is the same as may_share_memory in our implementation since
|
|
149
|
+
* JavaScript doesn't have the same memory model as Python/NumPy.
|
|
150
|
+
*
|
|
151
|
+
* @param a - First array storage
|
|
152
|
+
* @param b - Second array storage
|
|
153
|
+
* @returns True if arrays share memory
|
|
154
|
+
*/
|
|
155
|
+
export declare function shares_memory(a: ArrayStorage, b: ArrayStorage): boolean;
|
|
156
|
+
type ErrorMode = 'ignore' | 'warn' | 'raise' | 'call' | 'print' | 'log';
|
|
157
|
+
export interface FloatErrorState {
|
|
158
|
+
divide: ErrorMode;
|
|
159
|
+
over: ErrorMode;
|
|
160
|
+
under: ErrorMode;
|
|
161
|
+
invalid: ErrorMode;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get the current floating-point error handling.
|
|
165
|
+
*
|
|
166
|
+
* @returns Current error handling settings
|
|
167
|
+
*/
|
|
168
|
+
export declare function geterr(): FloatErrorState;
|
|
169
|
+
/**
|
|
170
|
+
* Set how floating-point errors are handled.
|
|
171
|
+
*
|
|
172
|
+
* @param all - Set all error modes at once (optional)
|
|
173
|
+
* @param divide - Treatment for division by zero
|
|
174
|
+
* @param over - Treatment for floating-point overflow
|
|
175
|
+
* @param under - Treatment for floating-point underflow
|
|
176
|
+
* @param invalid - Treatment for invalid floating-point operation
|
|
177
|
+
* @returns Previous error handling settings
|
|
178
|
+
*/
|
|
179
|
+
export declare function seterr(all?: ErrorMode, divide?: ErrorMode, over?: ErrorMode, under?: ErrorMode, invalid?: ErrorMode): FloatErrorState;
|
|
115
180
|
//# sourceMappingURL=advanced.d.ts.map
|
|
@@ -37,6 +37,8 @@ export declare function multiply(a: ArrayStorage, b: ArrayStorage | number): Arr
|
|
|
37
37
|
*
|
|
38
38
|
* NumPy behavior: Integer division always promotes to float
|
|
39
39
|
* Type promotion rules:
|
|
40
|
+
* - complex128 + anything → complex128
|
|
41
|
+
* - complex64 + float32/int → complex64
|
|
40
42
|
* - float64 + anything → float64
|
|
41
43
|
* - float32 + integer → float32
|
|
42
44
|
* - integer + integer → float64
|
|
@@ -100,6 +102,7 @@ export declare function positive(a: ArrayStorage): ArrayStorage;
|
|
|
100
102
|
/**
|
|
101
103
|
* Reciprocal (1/x) of each element
|
|
102
104
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
105
|
+
* For complex: 1/z = z̄/|z|² = (re - i*im) / (re² + im²)
|
|
103
106
|
*
|
|
104
107
|
* @param a - Input array storage
|
|
105
108
|
* @returns Result storage with reciprocal values
|
|
@@ -133,6 +136,7 @@ export declare function divmod(a: ArrayStorage, b: ArrayStorage | number): [Arra
|
|
|
133
136
|
/**
|
|
134
137
|
* Element-wise square of each element
|
|
135
138
|
* NumPy behavior: x**2
|
|
139
|
+
* For complex: z² = (re + i*im)² = (re² - im²) + i*(2*re*im)
|
|
136
140
|
*
|
|
137
141
|
* @param a - Input array storage
|
|
138
142
|
* @returns Result storage with squared values
|
|
@@ -208,4 +212,103 @@ export declare function ldexp(x1: ArrayStorage, x2: ArrayStorage | number): Arra
|
|
|
208
212
|
* @returns Tuple of [fractional, integral] arrays
|
|
209
213
|
*/
|
|
210
214
|
export declare function modf(x: ArrayStorage): [ArrayStorage, ArrayStorage];
|
|
215
|
+
/**
|
|
216
|
+
* Clip (limit) the values in an array
|
|
217
|
+
* Given an interval, values outside the interval are clipped to the interval edges.
|
|
218
|
+
*
|
|
219
|
+
* @param a - Input array storage
|
|
220
|
+
* @param a_min - Minimum value (null to not clip minimum)
|
|
221
|
+
* @param a_max - Maximum value (null to not clip maximum)
|
|
222
|
+
* @returns Clipped array storage
|
|
223
|
+
*/
|
|
224
|
+
export declare function clip(a: ArrayStorage, a_min: number | ArrayStorage | null, a_max: number | ArrayStorage | null): ArrayStorage;
|
|
225
|
+
/**
|
|
226
|
+
* Element-wise maximum of array elements
|
|
227
|
+
*
|
|
228
|
+
* @param x1 - First array storage
|
|
229
|
+
* @param x2 - Second array storage or scalar
|
|
230
|
+
* @returns Element-wise maximum
|
|
231
|
+
*/
|
|
232
|
+
export declare function maximum(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
233
|
+
/**
|
|
234
|
+
* Element-wise minimum of array elements
|
|
235
|
+
*
|
|
236
|
+
* @param x1 - First array storage
|
|
237
|
+
* @param x2 - Second array storage or scalar
|
|
238
|
+
* @returns Element-wise minimum
|
|
239
|
+
*/
|
|
240
|
+
export declare function minimum(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
241
|
+
/**
|
|
242
|
+
* Element-wise maximum of array elements, ignoring NaNs
|
|
243
|
+
*
|
|
244
|
+
* @param x1 - First array storage
|
|
245
|
+
* @param x2 - Second array storage or scalar
|
|
246
|
+
* @returns Element-wise maximum, NaN-aware
|
|
247
|
+
*/
|
|
248
|
+
export declare function fmax(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
249
|
+
/**
|
|
250
|
+
* Element-wise minimum of array elements, ignoring NaNs
|
|
251
|
+
*
|
|
252
|
+
* @param x1 - First array storage
|
|
253
|
+
* @param x2 - Second array storage or scalar
|
|
254
|
+
* @returns Element-wise minimum, NaN-aware
|
|
255
|
+
*/
|
|
256
|
+
export declare function fmin(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
257
|
+
/**
|
|
258
|
+
* Replace NaN with zero and Inf with large finite numbers
|
|
259
|
+
*
|
|
260
|
+
* @param x - Input array storage
|
|
261
|
+
* @param nan - Value to replace NaN (default: 0.0)
|
|
262
|
+
* @param posinf - Value to replace positive infinity (default: largest finite)
|
|
263
|
+
* @param neginf - Value to replace negative infinity (default: most negative finite)
|
|
264
|
+
* @returns Array with replacements
|
|
265
|
+
*/
|
|
266
|
+
export declare function nan_to_num(x: ArrayStorage, nan?: number, posinf?: number, neginf?: number): ArrayStorage;
|
|
267
|
+
/**
|
|
268
|
+
* One-dimensional linear interpolation
|
|
269
|
+
*
|
|
270
|
+
* Returns the one-dimensional piecewise linear interpolant to a function
|
|
271
|
+
* with given discrete data points (xp, fp), evaluated at x.
|
|
272
|
+
*
|
|
273
|
+
* @param x - The x-coordinates at which to evaluate the interpolated values
|
|
274
|
+
* @param xp - The x-coordinates of the data points (must be increasing)
|
|
275
|
+
* @param fp - The y-coordinates of the data points
|
|
276
|
+
* @param left - Value for x < xp[0] (default: fp[0])
|
|
277
|
+
* @param right - Value for x > xp[-1] (default: fp[-1])
|
|
278
|
+
* @returns Interpolated values
|
|
279
|
+
*/
|
|
280
|
+
export declare function interp(x: ArrayStorage, xp: ArrayStorage, fp: ArrayStorage, left?: number, right?: number): ArrayStorage;
|
|
281
|
+
/**
|
|
282
|
+
* Unwrap by changing deltas between values to 2*pi complement
|
|
283
|
+
*
|
|
284
|
+
* Unwrap radian phase p by changing absolute jumps greater than
|
|
285
|
+
* discont to their 2*pi complement along the given axis.
|
|
286
|
+
*
|
|
287
|
+
* @param p - Input array of phase angles in radians
|
|
288
|
+
* @param discont - Maximum discontinuity between values (default: pi)
|
|
289
|
+
* @param axis - Axis along which to unwrap (default: -1, last axis)
|
|
290
|
+
* @param period - Size of the range over which the input wraps (default: 2*pi)
|
|
291
|
+
* @returns Unwrapped array
|
|
292
|
+
*/
|
|
293
|
+
export declare function unwrap(p: ArrayStorage, discont?: number, axis?: number, period?: number): ArrayStorage;
|
|
294
|
+
/**
|
|
295
|
+
* Return the normalized sinc function
|
|
296
|
+
*
|
|
297
|
+
* sinc(x) = sin(pi*x) / (pi*x)
|
|
298
|
+
*
|
|
299
|
+
* The sinc function is 1 at x = 0, and sin(pi*x)/(pi*x) otherwise.
|
|
300
|
+
*
|
|
301
|
+
* @param x - Input array
|
|
302
|
+
* @returns Array of sinc values
|
|
303
|
+
*/
|
|
304
|
+
export declare function sinc(x: ArrayStorage): ArrayStorage;
|
|
305
|
+
/**
|
|
306
|
+
* Modified Bessel function of the first kind, order 0
|
|
307
|
+
*
|
|
308
|
+
* Uses polynomial approximation.
|
|
309
|
+
*
|
|
310
|
+
* @param x - Input array
|
|
311
|
+
* @returns Array of I0 values
|
|
312
|
+
*/
|
|
313
|
+
export declare function i0(x: ArrayStorage): ArrayStorage;
|
|
211
314
|
//# sourceMappingURL=arithmetic.d.ts.map
|
|
@@ -88,4 +88,34 @@ export declare function packbits(a: ArrayStorage, axis?: number, bitorder?: 'big
|
|
|
88
88
|
* @returns Unpacked uint8 array of 0s and 1s
|
|
89
89
|
*/
|
|
90
90
|
export declare function unpackbits(a: ArrayStorage, axis?: number, count?: number, bitorder?: 'big' | 'little'): ArrayStorage;
|
|
91
|
+
/**
|
|
92
|
+
* Count the number of 1-bits in each element (population count).
|
|
93
|
+
*
|
|
94
|
+
* @param x - Input array (must be integer type)
|
|
95
|
+
* @returns Array with population count for each element
|
|
96
|
+
*/
|
|
97
|
+
export declare function bitwise_count(x: ArrayStorage): ArrayStorage;
|
|
98
|
+
/**
|
|
99
|
+
* Bitwise invert (alias for bitwise_not)
|
|
100
|
+
*
|
|
101
|
+
* @param x - Input array (must be integer type)
|
|
102
|
+
* @returns Result storage with bitwise NOT values
|
|
103
|
+
*/
|
|
104
|
+
export declare function bitwise_invert(x: ArrayStorage): ArrayStorage;
|
|
105
|
+
/**
|
|
106
|
+
* Bitwise left shift (alias for left_shift)
|
|
107
|
+
*
|
|
108
|
+
* @param x1 - Input array (must be integer type)
|
|
109
|
+
* @param x2 - Shift amount (array or scalar)
|
|
110
|
+
* @returns Result storage with left-shifted values
|
|
111
|
+
*/
|
|
112
|
+
export declare function bitwise_left_shift(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
113
|
+
/**
|
|
114
|
+
* Bitwise right shift (alias for right_shift)
|
|
115
|
+
*
|
|
116
|
+
* @param x1 - Input array (must be integer type)
|
|
117
|
+
* @param x2 - Shift amount (array or scalar)
|
|
118
|
+
* @returns Result storage with right-shifted values
|
|
119
|
+
*/
|
|
120
|
+
export declare function bitwise_right_shift(x1: ArrayStorage, x2: ArrayStorage | number): ArrayStorage;
|
|
91
121
|
//# sourceMappingURL=bitwise.d.ts.map
|
|
@@ -8,26 +8,32 @@
|
|
|
8
8
|
import { ArrayStorage } from '../core/storage';
|
|
9
9
|
/**
|
|
10
10
|
* Element-wise greater than comparison (a > b)
|
|
11
|
+
* For complex: uses lexicographic ordering (real first, then imaginary)
|
|
11
12
|
*/
|
|
12
13
|
export declare function greater(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
13
14
|
/**
|
|
14
15
|
* Element-wise greater than or equal comparison (a >= b)
|
|
16
|
+
* For complex: uses lexicographic ordering (real first, then imaginary)
|
|
15
17
|
*/
|
|
16
18
|
export declare function greaterEqual(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
17
19
|
/**
|
|
18
20
|
* Element-wise less than comparison (a < b)
|
|
21
|
+
* For complex: uses lexicographic ordering (real first, then imaginary)
|
|
19
22
|
*/
|
|
20
23
|
export declare function less(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
21
24
|
/**
|
|
22
25
|
* Element-wise less than or equal comparison (a <= b)
|
|
26
|
+
* For complex: uses lexicographic ordering (real first, then imaginary)
|
|
23
27
|
*/
|
|
24
28
|
export declare function lessEqual(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
25
29
|
/**
|
|
26
30
|
* Element-wise equality comparison (a == b)
|
|
31
|
+
* For complex: both real and imaginary parts must be equal
|
|
27
32
|
*/
|
|
28
33
|
export declare function equal(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
29
34
|
/**
|
|
30
35
|
* Element-wise inequality comparison (a != b)
|
|
36
|
+
* For complex: either real or imaginary parts must differ
|
|
31
37
|
*/
|
|
32
38
|
export declare function notEqual(a: ArrayStorage, b: ArrayStorage | number): ArrayStorage;
|
|
33
39
|
/**
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complex number operations
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for complex array operations:
|
|
5
|
+
* real, imag, conj, angle
|
|
6
|
+
*
|
|
7
|
+
* @module ops/complex
|
|
8
|
+
*/
|
|
9
|
+
import { ArrayStorage } from '../core/storage';
|
|
10
|
+
/**
|
|
11
|
+
* Return the real part of complex argument.
|
|
12
|
+
*
|
|
13
|
+
* For complex arrays, returns the real components.
|
|
14
|
+
* For real arrays, returns a copy of the input.
|
|
15
|
+
*
|
|
16
|
+
* @param a - Input array storage
|
|
17
|
+
* @returns Array with real parts (float64 or float32 for complex, same dtype for real)
|
|
18
|
+
*/
|
|
19
|
+
export declare function real(a: ArrayStorage): ArrayStorage;
|
|
20
|
+
/**
|
|
21
|
+
* Return the imaginary part of complex argument.
|
|
22
|
+
*
|
|
23
|
+
* For complex arrays, returns the imaginary components.
|
|
24
|
+
* For real arrays, returns zeros.
|
|
25
|
+
*
|
|
26
|
+
* @param a - Input array storage
|
|
27
|
+
* @returns Array with imaginary parts
|
|
28
|
+
*/
|
|
29
|
+
export declare function imag(a: ArrayStorage): ArrayStorage;
|
|
30
|
+
/**
|
|
31
|
+
* Return the complex conjugate.
|
|
32
|
+
*
|
|
33
|
+
* For complex arrays, negates the imaginary part: (a + bi) -> (a - bi)
|
|
34
|
+
* For real arrays, returns a copy of the input.
|
|
35
|
+
*
|
|
36
|
+
* @param a - Input array storage
|
|
37
|
+
* @returns Complex conjugate array
|
|
38
|
+
*/
|
|
39
|
+
export declare function conj(a: ArrayStorage): ArrayStorage;
|
|
40
|
+
export declare const conjugate: typeof conj;
|
|
41
|
+
/**
|
|
42
|
+
* Return the angle (phase) of complex argument.
|
|
43
|
+
*
|
|
44
|
+
* angle(z) = arctan2(imag(z), real(z))
|
|
45
|
+
*
|
|
46
|
+
* For real arrays, returns 0 for positive, pi for negative.
|
|
47
|
+
*
|
|
48
|
+
* @param a - Input array storage
|
|
49
|
+
* @param deg - Return angle in degrees if true (default: false, returns radians)
|
|
50
|
+
* @returns Array with angles in radians (or degrees)
|
|
51
|
+
*/
|
|
52
|
+
export declare function angle(a: ArrayStorage, deg?: boolean): ArrayStorage;
|
|
53
|
+
/**
|
|
54
|
+
* Return the absolute value (magnitude) for complex arrays.
|
|
55
|
+
*
|
|
56
|
+
* For complex: |z| = sqrt(re² + im²)
|
|
57
|
+
* For real: |x| = abs(x)
|
|
58
|
+
*
|
|
59
|
+
* This is a helper that can be called from arithmetic.absolute
|
|
60
|
+
*
|
|
61
|
+
* @param a - Input array storage
|
|
62
|
+
* @returns Array with magnitudes
|
|
63
|
+
*/
|
|
64
|
+
export declare function complexAbs(a: ArrayStorage): ArrayStorage;
|
|
65
|
+
//# sourceMappingURL=complex.d.ts.map
|
|
@@ -11,6 +11,7 @@ import { ArrayStorage } from '../core/storage';
|
|
|
11
11
|
/**
|
|
12
12
|
* Square root of each element
|
|
13
13
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
14
|
+
* For complex: sqrt(a+bi) = sqrt((|z|+a)/2) + sign(b)*i*sqrt((|z|-a)/2)
|
|
14
15
|
*
|
|
15
16
|
* @param a - Input array storage
|
|
16
17
|
* @returns Result storage with sqrt applied
|
|
@@ -19,6 +20,7 @@ export declare function sqrt(a: ArrayStorage): ArrayStorage;
|
|
|
19
20
|
/**
|
|
20
21
|
* Raise elements to power
|
|
21
22
|
* NumPy behavior: Promotes to float64 for integer types with non-integer exponents
|
|
23
|
+
* For complex: z^n = |z|^n * (cos(n*θ) + i*sin(n*θ)) where θ = atan2(im, re)
|
|
22
24
|
*
|
|
23
25
|
* @param a - Base array storage
|
|
24
26
|
* @param b - Exponent (array storage or scalar)
|
|
@@ -28,6 +30,7 @@ export declare function power(a: ArrayStorage, b: ArrayStorage | number): ArrayS
|
|
|
28
30
|
/**
|
|
29
31
|
* Natural exponential function (e^x) for each element
|
|
30
32
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
33
|
+
* For complex: exp(a+bi) = e^a * (cos(b) + i*sin(b))
|
|
31
34
|
*
|
|
32
35
|
* @param a - Input array storage
|
|
33
36
|
* @returns Result storage with exp applied
|
|
@@ -36,6 +39,7 @@ export declare function exp(a: ArrayStorage): ArrayStorage;
|
|
|
36
39
|
/**
|
|
37
40
|
* Base-2 exponential function (2^x) for each element
|
|
38
41
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
42
|
+
* For complex: 2^z = exp(z * ln(2))
|
|
39
43
|
*
|
|
40
44
|
* @param a - Input array storage
|
|
41
45
|
* @returns Result storage with 2^x applied
|
|
@@ -45,6 +49,7 @@ export declare function exp2(a: ArrayStorage): ArrayStorage;
|
|
|
45
49
|
* Exponential minus one (e^x - 1) for each element
|
|
46
50
|
* More accurate than exp(x) - 1 for small x
|
|
47
51
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
52
|
+
* For complex: expm1(z) = exp(z) - 1
|
|
48
53
|
*
|
|
49
54
|
* @param a - Input array storage
|
|
50
55
|
* @returns Result storage with expm1 applied
|
|
@@ -53,6 +58,7 @@ export declare function expm1(a: ArrayStorage): ArrayStorage;
|
|
|
53
58
|
/**
|
|
54
59
|
* Natural logarithm (ln) for each element
|
|
55
60
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
61
|
+
* For complex: log(a+bi) = ln|z| + i*arg(z) = ln(sqrt(a²+b²)) + i*atan2(b,a)
|
|
56
62
|
*
|
|
57
63
|
* @param a - Input array storage
|
|
58
64
|
* @returns Result storage with log applied
|
|
@@ -61,6 +67,7 @@ export declare function log(a: ArrayStorage): ArrayStorage;
|
|
|
61
67
|
/**
|
|
62
68
|
* Base-2 logarithm for each element
|
|
63
69
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
70
|
+
* For complex: log2(z) = log(z) / ln(2)
|
|
64
71
|
*
|
|
65
72
|
* @param a - Input array storage
|
|
66
73
|
* @returns Result storage with log2 applied
|
|
@@ -69,6 +76,7 @@ export declare function log2(a: ArrayStorage): ArrayStorage;
|
|
|
69
76
|
/**
|
|
70
77
|
* Base-10 logarithm for each element
|
|
71
78
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
79
|
+
* For complex: log10(z) = log(z) / ln(10)
|
|
72
80
|
*
|
|
73
81
|
* @param a - Input array storage
|
|
74
82
|
* @returns Result storage with log10 applied
|
|
@@ -78,6 +86,7 @@ export declare function log10(a: ArrayStorage): ArrayStorage;
|
|
|
78
86
|
* Natural logarithm of (1 + x) for each element
|
|
79
87
|
* More accurate than log(1 + x) for small x
|
|
80
88
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
89
|
+
* For complex: log1p(z) = log(1 + z)
|
|
81
90
|
*
|
|
82
91
|
* @param a - Input array storage
|
|
83
92
|
* @returns Result storage with log1p applied
|
|
@@ -11,6 +11,7 @@ import { ArrayStorage } from '../core/storage';
|
|
|
11
11
|
/**
|
|
12
12
|
* Hyperbolic sine of each element (element-wise)
|
|
13
13
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
14
|
+
* For complex: sinh(a+bi) = sinh(a)cos(b) + i*cosh(a)sin(b)
|
|
14
15
|
*
|
|
15
16
|
* @param a - Input array storage
|
|
16
17
|
* @returns Result storage with sinh applied
|
|
@@ -19,6 +20,7 @@ export declare function sinh(a: ArrayStorage): ArrayStorage;
|
|
|
19
20
|
/**
|
|
20
21
|
* Hyperbolic cosine of each element (element-wise)
|
|
21
22
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
23
|
+
* For complex: cosh(a+bi) = cosh(a)cos(b) + i*sinh(a)sin(b)
|
|
22
24
|
*
|
|
23
25
|
* @param a - Input array storage
|
|
24
26
|
* @returns Result storage with cosh applied
|
|
@@ -27,6 +29,7 @@ export declare function cosh(a: ArrayStorage): ArrayStorage;
|
|
|
27
29
|
/**
|
|
28
30
|
* Hyperbolic tangent of each element (element-wise)
|
|
29
31
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
32
|
+
* For complex: tanh(z) = (sinh(2a) + i*sin(2b)) / (cosh(2a) + cos(2b))
|
|
30
33
|
*
|
|
31
34
|
* @param a - Input array storage
|
|
32
35
|
* @returns Result storage with tanh applied
|
|
@@ -35,6 +38,7 @@ export declare function tanh(a: ArrayStorage): ArrayStorage;
|
|
|
35
38
|
/**
|
|
36
39
|
* Inverse hyperbolic sine of each element (element-wise)
|
|
37
40
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
41
|
+
* For complex: arcsinh(z) = log(z + sqrt(z² + 1))
|
|
38
42
|
*
|
|
39
43
|
* @param a - Input array storage
|
|
40
44
|
* @returns Result storage with arcsinh applied
|
|
@@ -43,6 +47,7 @@ export declare function arcsinh(a: ArrayStorage): ArrayStorage;
|
|
|
43
47
|
/**
|
|
44
48
|
* Inverse hyperbolic cosine of each element (element-wise)
|
|
45
49
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
50
|
+
* For complex: arccosh(z) = log(z + sqrt(z - 1) * sqrt(z + 1))
|
|
46
51
|
*
|
|
47
52
|
* @param a - Input array storage (values >= 1)
|
|
48
53
|
* @returns Result storage with arccosh applied
|
|
@@ -51,6 +56,7 @@ export declare function arccosh(a: ArrayStorage): ArrayStorage;
|
|
|
51
56
|
/**
|
|
52
57
|
* Inverse hyperbolic tangent of each element (element-wise)
|
|
53
58
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
59
|
+
* For complex: arctanh(z) = (1/2) * log((1+z)/(1-z))
|
|
54
60
|
*
|
|
55
61
|
* @param a - Input array storage (values in range (-1, 1))
|
|
56
62
|
* @returns Result storage with arctanh applied
|