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.
- package/README.md +29 -25
- package/dist/esm/common/broadcasting.js +1 -0
- package/dist/esm/common/complex.js +1 -0
- package/dist/esm/common/dtype.js +1 -0
- package/dist/esm/common/internal/compute.js +1 -0
- package/dist/esm/common/internal/indexing.js +1 -0
- package/dist/esm/common/ndarray-core.js +1 -0
- package/dist/esm/common/ops/advanced.js +1 -0
- package/dist/esm/common/ops/arithmetic.js +1 -0
- package/dist/esm/common/ops/bitwise.js +1 -0
- package/dist/esm/common/ops/comparison.js +1 -0
- package/dist/esm/common/ops/complex.js +1 -0
- package/dist/esm/common/ops/exponential.js +1 -0
- package/dist/esm/common/ops/fft.js +1 -0
- package/dist/esm/common/ops/formatting.js +2 -0
- package/dist/esm/common/ops/gradient.js +1 -0
- package/dist/esm/common/ops/hyperbolic.js +1 -0
- package/dist/esm/common/ops/linalg.js +2 -0
- package/dist/esm/common/ops/logic.js +1 -0
- package/dist/esm/common/ops/random.js +1 -0
- package/dist/esm/common/ops/reduction.js +1 -0
- package/dist/esm/common/ops/rounding.js +1 -0
- package/dist/esm/common/ops/sets.js +1 -0
- package/dist/esm/common/ops/shape.js +1 -0
- package/dist/esm/common/ops/sorting.js +1 -0
- package/dist/esm/common/ops/statistics.js +1 -0
- package/dist/esm/common/ops/trig.js +1 -0
- package/dist/esm/common/slicing.js +1 -0
- package/dist/esm/common/storage.js +1 -0
- package/dist/esm/core/advanced.js +1 -0
- package/dist/esm/core/arithmetic.js +1 -0
- package/dist/esm/core/bitwise.js +1 -0
- package/dist/esm/core/complex.js +1 -0
- package/dist/esm/core/creation.js +1 -0
- package/dist/esm/core/formatting.js +1 -0
- package/dist/esm/core/gradient.js +1 -0
- package/dist/esm/core/index.js +1 -0
- package/dist/esm/core/linalg.js +1 -0
- package/dist/esm/core/logic.js +1 -0
- package/dist/esm/core/polynomial.js +1 -0
- package/dist/esm/core/reduction.js +1 -0
- package/dist/esm/core/rounding.js +1 -0
- package/dist/esm/core/sets.js +1 -0
- package/dist/esm/core/shape-extra.js +1 -0
- package/dist/esm/core/shape.js +1 -0
- package/dist/esm/core/sorting.js +1 -0
- package/dist/esm/core/statistics.js +1 -0
- package/dist/esm/core/trig.js +1 -0
- package/dist/esm/core/typechecking.js +1 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/core/utility.js +1 -0
- package/dist/esm/core.js +1 -0
- package/dist/esm/full/index.js +1 -0
- package/dist/esm/full/ndarray.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/io/index.js +1 -0
- package/dist/esm/io/npy/format.js +1 -0
- package/dist/esm/io/npy/index.js +1 -0
- package/dist/esm/io/npy/parser.js +1 -0
- package/dist/esm/io/npy/serializer.js +2 -0
- package/dist/esm/io/npz/index.js +1 -0
- package/dist/esm/io/npz/parser.js +1 -0
- package/dist/esm/io/npz/serializer.js +1 -0
- package/dist/esm/io/txt/index.js +1 -0
- package/dist/esm/io/txt/parser.js +1 -0
- package/dist/esm/io/txt/serializer.js +2 -0
- package/dist/esm/io/zip/index.js +1 -0
- package/dist/esm/io/zip/reader.js +1 -0
- package/dist/esm/io/zip/types.js +1 -0
- package/dist/esm/io/zip/writer.js +1 -0
- package/dist/esm/node.js +1 -0
- package/dist/numpy-ts.browser.js +5 -2
- package/dist/numpy-ts.node-io.cjs +5 -3
- package/dist/numpy-ts.node-io.cjs.map +4 -4
- package/dist/numpy-ts.node-io.mjs +5 -3
- package/dist/numpy-ts.node-io.mjs.map +4 -4
- package/dist/numpy-ts.node.cjs +5 -2
- package/dist/numpy-ts.node.cjs.map +4 -4
- package/dist/types/common/complex.d.ts +94 -0
- package/dist/types/{internal → common/internal}/compute.d.ts +1 -1
- package/dist/types/{internal → common/internal}/indexing.d.ts +6 -0
- package/dist/types/common/ndarray-core.d.ts +126 -0
- package/dist/types/{ops → common/ops}/advanced.d.ts +67 -2
- package/dist/types/{ops → common/ops}/arithmetic.d.ts +100 -1
- package/dist/types/{ops → common/ops}/bitwise.d.ts +31 -1
- package/dist/types/{ops → common/ops}/comparison.d.ts +1 -1
- package/dist/types/{ops → common/ops}/complex.d.ts +1 -1
- package/dist/types/{ops → common/ops}/exponential.d.ts +1 -1
- package/dist/types/common/ops/fft.d.ts +166 -0
- package/dist/types/common/ops/formatting.d.ts +229 -0
- package/dist/types/{ops → common/ops}/gradient.d.ts +1 -1
- package/dist/types/{ops → common/ops}/hyperbolic.d.ts +1 -1
- package/dist/types/{ops → common/ops}/linalg.d.ts +148 -3
- package/dist/types/{ops → common/ops}/logic.d.ts +2 -2
- package/dist/types/common/ops/random.d.ts +376 -0
- package/dist/types/{ops → common/ops}/reduction.d.ts +10 -2
- package/dist/types/{ops → common/ops}/rounding.d.ts +1 -1
- package/dist/types/common/ops/sets.d.ts +87 -0
- package/dist/types/{ops → common/ops}/shape.d.ts +14 -1
- package/dist/types/{ops → common/ops}/sorting.d.ts +1 -1
- package/dist/types/{ops → common/ops}/statistics.d.ts +23 -1
- package/dist/types/{ops → common/ops}/trig.d.ts +1 -1
- package/dist/types/{core → common}/storage.d.ts +1 -0
- package/dist/types/core/advanced.d.ts +54 -0
- package/dist/types/core/arithmetic.d.ts +110 -0
- package/dist/types/core/bitwise.d.ts +34 -0
- package/dist/types/core/complex.d.ts +15 -90
- package/dist/types/core/creation.d.ts +98 -0
- package/dist/types/core/formatting.d.ts +29 -0
- package/dist/types/core/gradient.d.ts +14 -0
- package/dist/types/core/index.d.ts +40 -0
- package/dist/types/core/linalg.d.ts +141 -0
- package/dist/types/core/logic.d.ts +72 -0
- package/dist/types/core/polynomial.d.ts +50 -0
- package/dist/types/core/reduction.d.ts +82 -0
- package/dist/types/core/rounding.d.ts +24 -0
- package/dist/types/core/sets.d.ts +48 -0
- package/dist/types/core/shape-extra.d.ts +24 -0
- package/dist/types/core/shape.d.ts +77 -0
- package/dist/types/core/sorting.d.ts +34 -0
- package/dist/types/core/statistics.d.ts +32 -0
- package/dist/types/core/trig.d.ts +58 -0
- package/dist/types/core/typechecking.d.ts +50 -0
- package/dist/types/core/types.d.ts +43 -0
- package/dist/types/core/utility.d.ts +30 -0
- package/dist/types/core.d.ts +30 -0
- package/dist/types/full/index.d.ts +603 -0
- package/dist/types/full/ndarray.d.ts +880 -0
- package/dist/types/index.d.ts +140 -26
- package/dist/types/io/npy/format.d.ts +1 -1
- package/dist/types/io/npy/parser.d.ts +3 -3
- package/dist/types/io/npy/serializer.d.ts +2 -2
- package/dist/types/io/npz/parser.d.ts +4 -4
- package/dist/types/io/npz/serializer.d.ts +6 -6
- package/dist/types/io/txt/parser.d.ts +5 -5
- package/dist/types/io/txt/serializer.d.ts +2 -2
- package/dist/types/node.d.ts +12 -8
- package/package.json +31 -30
- package/dist/numpy-ts.esm.js +0 -2
- package/dist/types/core/ndarray.d.ts +0 -3166
- package/dist/types/ops/random.d.ts +0 -136
- package/dist/types/ops/sets.d.ts +0 -38
- /package/dist/types/{core → common}/broadcasting.d.ts +0 -0
- /package/dist/types/{core → common}/dtype.d.ts +0 -0
- /package/dist/types/{core → common}/slicing.d.ts +0 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complex number class for numpy-ts
|
|
3
|
+
*
|
|
4
|
+
* Represents complex numbers in JavaScript, similar to Python's complex type.
|
|
5
|
+
* Used when converting complex arrays to JavaScript values via toArray().
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Represents a complex number with real and imaginary parts.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const z = new Complex(1, 2); // 1 + 2i
|
|
13
|
+
* console.log(z.re); // 1
|
|
14
|
+
* console.log(z.im); // 2
|
|
15
|
+
* console.log(z.toString()); // "(1+2j)"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class Complex {
|
|
19
|
+
/** Real part */
|
|
20
|
+
readonly re: number;
|
|
21
|
+
/** Imaginary part */
|
|
22
|
+
readonly im: number;
|
|
23
|
+
constructor(re: number, im?: number);
|
|
24
|
+
/**
|
|
25
|
+
* Returns the magnitude (absolute value) of the complex number.
|
|
26
|
+
* |z| = sqrt(re² + im²)
|
|
27
|
+
*/
|
|
28
|
+
abs(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the phase angle (argument) of the complex number in radians.
|
|
31
|
+
* arg(z) = atan2(im, re)
|
|
32
|
+
*/
|
|
33
|
+
angle(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the complex conjugate.
|
|
36
|
+
* conj(a + bi) = a - bi
|
|
37
|
+
*/
|
|
38
|
+
conj(): Complex;
|
|
39
|
+
/**
|
|
40
|
+
* Add another complex number or real number.
|
|
41
|
+
*/
|
|
42
|
+
add(other: Complex | number): Complex;
|
|
43
|
+
/**
|
|
44
|
+
* Subtract another complex number or real number.
|
|
45
|
+
*/
|
|
46
|
+
sub(other: Complex | number): Complex;
|
|
47
|
+
/**
|
|
48
|
+
* Multiply by another complex number or real number.
|
|
49
|
+
* (a + bi)(c + di) = (ac - bd) + (ad + bc)i
|
|
50
|
+
*/
|
|
51
|
+
mul(other: Complex | number): Complex;
|
|
52
|
+
/**
|
|
53
|
+
* Divide by another complex number or real number.
|
|
54
|
+
* (a + bi) / (c + di) = ((ac + bd) + (bc - ad)i) / (c² + d²)
|
|
55
|
+
*/
|
|
56
|
+
div(other: Complex | number): Complex;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the negation of this complex number.
|
|
59
|
+
*/
|
|
60
|
+
neg(): Complex;
|
|
61
|
+
/**
|
|
62
|
+
* Check equality with another complex number.
|
|
63
|
+
*/
|
|
64
|
+
equals(other: Complex): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* String representation matching NumPy/Python format: "(a+bj)"
|
|
67
|
+
*/
|
|
68
|
+
toString(): string;
|
|
69
|
+
/**
|
|
70
|
+
* Create a Complex from various input formats.
|
|
71
|
+
* Accepts:
|
|
72
|
+
* - Complex instance
|
|
73
|
+
* - {re, im} object
|
|
74
|
+
* - [re, im] array
|
|
75
|
+
* - number (creates re + 0i)
|
|
76
|
+
*/
|
|
77
|
+
static from(value: ComplexInput): Complex;
|
|
78
|
+
/**
|
|
79
|
+
* Check if a value is a complex number representation.
|
|
80
|
+
*/
|
|
81
|
+
static isComplex(value: unknown): value is ComplexInput;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Input types that can be converted to Complex.
|
|
85
|
+
*/
|
|
86
|
+
export type ComplexInput = Complex | {
|
|
87
|
+
re: number;
|
|
88
|
+
im?: number;
|
|
89
|
+
} | [number, number] | number;
|
|
90
|
+
/**
|
|
91
|
+
* Helper to check if a value looks like a complex number input.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isComplexLike(value: unknown): value is ComplexInput;
|
|
94
|
+
//# sourceMappingURL=complex.d.ts.map
|
|
@@ -10,6 +10,12 @@ export declare function computeStrides(shape: readonly number[]): number[];
|
|
|
10
10
|
* Convert multi-index to linear index in row-major order
|
|
11
11
|
*/
|
|
12
12
|
export declare function multiIndexToLinear(indices: number[], shape: readonly number[]): number;
|
|
13
|
+
/**
|
|
14
|
+
* Convert multi-index to buffer position using actual strides and offset.
|
|
15
|
+
* Unlike multiIndexToLinear (which assumes C-contiguous layout),
|
|
16
|
+
* this works correctly for non-contiguous views/slices.
|
|
17
|
+
*/
|
|
18
|
+
export declare function multiIndexToBuffer(indices: number[], strides: readonly number[], offset: number): number;
|
|
13
19
|
/**
|
|
14
20
|
* Convert outer index and axis index to full multi-index
|
|
15
21
|
* Used in reductions along a specific axis
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NDArray Core - Minimal NDArray class for tree-shaking
|
|
3
|
+
*
|
|
4
|
+
* This module contains the minimal NDArray class without operation methods.
|
|
5
|
+
* It only depends on core modules (storage, dtype, slicing, complex) and
|
|
6
|
+
* does NOT import any ops modules.
|
|
7
|
+
*
|
|
8
|
+
* For the full NDArray with all methods, use ndarray-full.ts
|
|
9
|
+
*/
|
|
10
|
+
import { type DType, type TypedArray } from './dtype';
|
|
11
|
+
import { Complex } from './complex';
|
|
12
|
+
import { ArrayStorage } from './storage';
|
|
13
|
+
/**
|
|
14
|
+
* Minimal NDArray class - core functionality without operation methods
|
|
15
|
+
*
|
|
16
|
+
* This class provides:
|
|
17
|
+
* - Array properties (shape, dtype, data, etc.)
|
|
18
|
+
* - Element access (get, set, iget, iset)
|
|
19
|
+
* - Basic methods (copy, astype, fill, slice)
|
|
20
|
+
* - Conversion methods (toArray, tolist, tobytes)
|
|
21
|
+
*
|
|
22
|
+
* Operation methods (add, sin, reshape, etc.) are NOT included.
|
|
23
|
+
* Use NDArray from ndarray-full.ts for the complete API.
|
|
24
|
+
*/
|
|
25
|
+
export declare class NDArrayCore {
|
|
26
|
+
protected _storage: ArrayStorage;
|
|
27
|
+
protected _base?: NDArrayCore;
|
|
28
|
+
constructor(storage: ArrayStorage, base?: NDArrayCore);
|
|
29
|
+
/**
|
|
30
|
+
* Get internal storage (for ops modules)
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
get storage(): ArrayStorage;
|
|
34
|
+
/**
|
|
35
|
+
* Create NDArray from storage (for ops modules)
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
static fromStorage(storage: ArrayStorage, base?: NDArrayCore): NDArrayCore;
|
|
39
|
+
get shape(): readonly number[];
|
|
40
|
+
get ndim(): number;
|
|
41
|
+
get size(): number;
|
|
42
|
+
get dtype(): string;
|
|
43
|
+
get data(): TypedArray;
|
|
44
|
+
get strides(): readonly number[];
|
|
45
|
+
/**
|
|
46
|
+
* Array flags (similar to NumPy's flags)
|
|
47
|
+
*/
|
|
48
|
+
get flags(): {
|
|
49
|
+
C_CONTIGUOUS: boolean;
|
|
50
|
+
F_CONTIGUOUS: boolean;
|
|
51
|
+
OWNDATA: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Base array if this is a view, null if this array owns its data
|
|
55
|
+
*/
|
|
56
|
+
get base(): NDArrayCore | null;
|
|
57
|
+
/**
|
|
58
|
+
* Size of one array element in bytes
|
|
59
|
+
*/
|
|
60
|
+
get itemsize(): number;
|
|
61
|
+
/**
|
|
62
|
+
* Total bytes consumed by the elements of the array
|
|
63
|
+
*/
|
|
64
|
+
get nbytes(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Fill the array with a scalar value (in-place)
|
|
67
|
+
*/
|
|
68
|
+
fill(value: number | bigint): void;
|
|
69
|
+
/**
|
|
70
|
+
* Iterator protocol - iterate over the first axis
|
|
71
|
+
*/
|
|
72
|
+
[Symbol.iterator](): Iterator<NDArrayCore | number | bigint | Complex>;
|
|
73
|
+
/**
|
|
74
|
+
* Get a single element from the array
|
|
75
|
+
*/
|
|
76
|
+
get(indices: number[]): number | bigint | Complex;
|
|
77
|
+
/**
|
|
78
|
+
* Set a single element in the array
|
|
79
|
+
*/
|
|
80
|
+
set(indices: number[], value: number | bigint | Complex | {
|
|
81
|
+
re: number;
|
|
82
|
+
im: number;
|
|
83
|
+
}): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get element by flat index
|
|
86
|
+
*/
|
|
87
|
+
iget(flatIndex: number): number | bigint | Complex;
|
|
88
|
+
/**
|
|
89
|
+
* Set element by flat index
|
|
90
|
+
*/
|
|
91
|
+
iset(flatIndex: number, value: number | bigint | Complex): void;
|
|
92
|
+
/**
|
|
93
|
+
* Return a deep copy of the array
|
|
94
|
+
*/
|
|
95
|
+
copy(): NDArrayCore;
|
|
96
|
+
/**
|
|
97
|
+
* Cast array to a different dtype
|
|
98
|
+
*/
|
|
99
|
+
astype(dtype: DType, copy?: boolean): NDArrayCore;
|
|
100
|
+
/**
|
|
101
|
+
* Slice the array
|
|
102
|
+
*/
|
|
103
|
+
slice(...sliceStrs: string[]): NDArrayCore;
|
|
104
|
+
/**
|
|
105
|
+
* String representation
|
|
106
|
+
*/
|
|
107
|
+
toString(): string;
|
|
108
|
+
/**
|
|
109
|
+
* Convert to nested JavaScript array
|
|
110
|
+
*/
|
|
111
|
+
toArray(): unknown;
|
|
112
|
+
/**
|
|
113
|
+
* Return the array as a nested list (same as toArray)
|
|
114
|
+
*/
|
|
115
|
+
tolist(): unknown;
|
|
116
|
+
/**
|
|
117
|
+
* Return the raw bytes of the array data
|
|
118
|
+
*/
|
|
119
|
+
tobytes(): ArrayBuffer;
|
|
120
|
+
/**
|
|
121
|
+
* Copy an element of an array to a standard scalar and return it
|
|
122
|
+
*/
|
|
123
|
+
item(...args: number[]): number | bigint | Complex;
|
|
124
|
+
}
|
|
125
|
+
export type { DType, TypedArray };
|
|
126
|
+
//# sourceMappingURL=ndarray-core.d.ts.map
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Broadcasting, indexing, and comparison functions.
|
|
5
5
|
* @module ops/advanced
|
|
6
6
|
*/
|
|
7
|
-
import { ArrayStorage } from '../
|
|
8
|
-
import { broadcastShapes } from '../
|
|
7
|
+
import { ArrayStorage } from '../storage';
|
|
8
|
+
import { broadcastShapes } from '../broadcasting';
|
|
9
9
|
/**
|
|
10
10
|
* Broadcast an array to a given shape
|
|
11
11
|
* Returns a read-only view on the original array
|
|
@@ -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
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* These functions are used by NDArray methods but are separated
|
|
8
8
|
* to keep the codebase modular and testable.
|
|
9
9
|
*/
|
|
10
|
-
import { ArrayStorage } from '../
|
|
10
|
+
import { ArrayStorage } from '../storage';
|
|
11
11
|
/**
|
|
12
12
|
* Add two arrays or array and scalar
|
|
13
13
|
*
|
|
@@ -212,4 +212,103 @@ export declare function ldexp(x1: ArrayStorage, x2: ArrayStorage | number): Arra
|
|
|
212
212
|
* @returns Tuple of [fractional, integral] arrays
|
|
213
213
|
*/
|
|
214
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;
|
|
215
314
|
//# sourceMappingURL=arithmetic.d.ts.map
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* These operations only work on integer types.
|
|
9
9
|
*/
|
|
10
|
-
import { ArrayStorage } from '../
|
|
10
|
+
import { ArrayStorage } from '../storage';
|
|
11
11
|
/**
|
|
12
12
|
* Bitwise AND of two arrays or array and scalar
|
|
13
13
|
*
|
|
@@ -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
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* greater, greater_equal, less, less_equal, equal, not_equal,
|
|
6
6
|
* isclose, allclose
|
|
7
7
|
*/
|
|
8
|
-
import { ArrayStorage } from '../
|
|
8
|
+
import { ArrayStorage } from '../storage';
|
|
9
9
|
/**
|
|
10
10
|
* Element-wise greater than comparison (a > b)
|
|
11
11
|
* For complex: uses lexicographic ordering (real first, then imaginary)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* These functions are used by NDArray methods but are separated
|
|
8
8
|
* to keep the codebase modular and testable.
|
|
9
9
|
*/
|
|
10
|
-
import { ArrayStorage } from '../
|
|
10
|
+
import { ArrayStorage } from '../storage';
|
|
11
11
|
/**
|
|
12
12
|
* Square root of each element
|
|
13
13
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FFT (Fast Fourier Transform) operations
|
|
3
|
+
*
|
|
4
|
+
* Implements NumPy's np.fft module:
|
|
5
|
+
* - fft, ifft: 1D FFT
|
|
6
|
+
* - fft2, ifft2: 2D FFT
|
|
7
|
+
* - fftn, ifftn: N-dimensional FFT
|
|
8
|
+
* - rfft, irfft: Real FFT
|
|
9
|
+
* - rfft2, irfft2: 2D Real FFT
|
|
10
|
+
* - rfftn, irfftn: N-dimensional Real FFT
|
|
11
|
+
* - hfft, ihfft: Hermitian FFT
|
|
12
|
+
* - fftfreq, rfftfreq: FFT frequencies
|
|
13
|
+
* - fftshift, ifftshift: Shift zero-frequency to center
|
|
14
|
+
*
|
|
15
|
+
* @module ops/fft
|
|
16
|
+
*/
|
|
17
|
+
import { ArrayStorage } from '../storage';
|
|
18
|
+
/**
|
|
19
|
+
* Compute the 1-D discrete Fourier Transform.
|
|
20
|
+
*
|
|
21
|
+
* @param a - Input array storage
|
|
22
|
+
* @param n - Length of the transformed axis (default: length of a)
|
|
23
|
+
* @param axis - Axis along which to compute the FFT (default: -1, last axis)
|
|
24
|
+
* @param norm - Normalization mode: 'backward', 'ortho', or 'forward' (default: 'backward')
|
|
25
|
+
* @returns Complex array containing the FFT result
|
|
26
|
+
*/
|
|
27
|
+
export declare function fft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
28
|
+
/**
|
|
29
|
+
* Compute the 1-D inverse discrete Fourier Transform.
|
|
30
|
+
*
|
|
31
|
+
* @param a - Input array storage
|
|
32
|
+
* @param n - Length of the transformed axis (default: length of a)
|
|
33
|
+
* @param axis - Axis along which to compute the IFFT (default: -1, last axis)
|
|
34
|
+
* @param norm - Normalization mode: 'backward', 'ortho', or 'forward' (default: 'backward')
|
|
35
|
+
* @returns Complex array containing the IFFT result
|
|
36
|
+
*/
|
|
37
|
+
export declare function ifft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
38
|
+
/**
|
|
39
|
+
* Compute the 2-D discrete Fourier Transform.
|
|
40
|
+
*
|
|
41
|
+
* @param a - Input array storage
|
|
42
|
+
* @param s - Shape of the output (default: shape of input along axes)
|
|
43
|
+
* @param axes - Axes along which to compute the FFT (default: [-2, -1])
|
|
44
|
+
* @param norm - Normalization mode
|
|
45
|
+
* @returns Complex array containing the FFT result
|
|
46
|
+
*/
|
|
47
|
+
export declare function fft2(a: ArrayStorage, s?: [number, number], axes?: [number, number], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
48
|
+
/**
|
|
49
|
+
* Compute the 2-D inverse discrete Fourier Transform.
|
|
50
|
+
*
|
|
51
|
+
* @param a - Input array storage
|
|
52
|
+
* @param s - Shape of the output
|
|
53
|
+
* @param axes - Axes along which to compute the IFFT
|
|
54
|
+
* @param norm - Normalization mode
|
|
55
|
+
* @returns Complex array containing the IFFT result
|
|
56
|
+
*/
|
|
57
|
+
export declare function ifft2(a: ArrayStorage, s?: [number, number], axes?: [number, number], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
58
|
+
/**
|
|
59
|
+
* Compute the N-D discrete Fourier Transform.
|
|
60
|
+
*
|
|
61
|
+
* @param a - Input array storage
|
|
62
|
+
* @param s - Shape of the output along transform axes
|
|
63
|
+
* @param axes - Axes along which to compute the FFT
|
|
64
|
+
* @param norm - Normalization mode
|
|
65
|
+
* @returns Complex array containing the FFT result
|
|
66
|
+
*/
|
|
67
|
+
export declare function fftn(a: ArrayStorage, s?: number[], axes?: number[], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
68
|
+
/**
|
|
69
|
+
* Compute the N-D inverse discrete Fourier Transform.
|
|
70
|
+
*
|
|
71
|
+
* @param a - Input array storage
|
|
72
|
+
* @param s - Shape of the output along transform axes
|
|
73
|
+
* @param axes - Axes along which to compute the IFFT
|
|
74
|
+
* @param norm - Normalization mode
|
|
75
|
+
* @returns Complex array containing the IFFT result
|
|
76
|
+
*/
|
|
77
|
+
export declare function ifftn(a: ArrayStorage, s?: number[], axes?: number[], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
78
|
+
/**
|
|
79
|
+
* Compute the 1-D FFT of a real-valued array.
|
|
80
|
+
*
|
|
81
|
+
* @param a - Input array storage (real-valued)
|
|
82
|
+
* @param n - Length of the transformed axis
|
|
83
|
+
* @param axis - Axis along which to compute the FFT
|
|
84
|
+
* @param norm - Normalization mode
|
|
85
|
+
* @returns Complex array with length n//2 + 1 along the transformed axis
|
|
86
|
+
*/
|
|
87
|
+
export declare function rfft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
88
|
+
/**
|
|
89
|
+
* Compute the inverse of rfft.
|
|
90
|
+
*
|
|
91
|
+
* @param a - Input array storage (from rfft)
|
|
92
|
+
* @param n - Length of the output along the transformed axis
|
|
93
|
+
* @param axis - Axis along which to compute the IFFT
|
|
94
|
+
* @param norm - Normalization mode
|
|
95
|
+
* @returns Real array
|
|
96
|
+
*/
|
|
97
|
+
export declare function irfft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
98
|
+
/**
|
|
99
|
+
* Compute the 2-D FFT of a real-valued array.
|
|
100
|
+
*/
|
|
101
|
+
export declare function rfft2(a: ArrayStorage, s?: [number, number], axes?: [number, number], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
102
|
+
/**
|
|
103
|
+
* Compute the inverse of rfft2.
|
|
104
|
+
*/
|
|
105
|
+
export declare function irfft2(a: ArrayStorage, s?: [number, number], axes?: [number, number], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
106
|
+
/**
|
|
107
|
+
* Compute the N-D FFT of a real-valued array.
|
|
108
|
+
*/
|
|
109
|
+
export declare function rfftn(a: ArrayStorage, s?: number[], axes?: number[], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
110
|
+
/**
|
|
111
|
+
* Compute the inverse of rfftn.
|
|
112
|
+
*/
|
|
113
|
+
export declare function irfftn(a: ArrayStorage, s?: number[], axes?: number[], norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
114
|
+
/**
|
|
115
|
+
* Compute the FFT of a signal with Hermitian symmetry (real spectrum).
|
|
116
|
+
*
|
|
117
|
+
* @param a - Input array with Hermitian symmetry
|
|
118
|
+
* @param n - Length of the output
|
|
119
|
+
* @param axis - Axis along which to compute
|
|
120
|
+
* @param norm - Normalization mode
|
|
121
|
+
* @returns Real array
|
|
122
|
+
*/
|
|
123
|
+
export declare function hfft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
124
|
+
/**
|
|
125
|
+
* Compute the inverse of hfft.
|
|
126
|
+
*
|
|
127
|
+
* @param a - Input real array
|
|
128
|
+
* @param n - Length of the Hermitian output
|
|
129
|
+
* @param axis - Axis along which to compute
|
|
130
|
+
* @param norm - Normalization mode
|
|
131
|
+
* @returns Complex array with Hermitian symmetry
|
|
132
|
+
*/
|
|
133
|
+
export declare function ihfft(a: ArrayStorage, n?: number, axis?: number, norm?: 'backward' | 'ortho' | 'forward'): ArrayStorage;
|
|
134
|
+
/**
|
|
135
|
+
* Return the Discrete Fourier Transform sample frequencies.
|
|
136
|
+
*
|
|
137
|
+
* @param n - Window length
|
|
138
|
+
* @param d - Sample spacing (default: 1.0)
|
|
139
|
+
* @returns Array of length n containing the sample frequencies
|
|
140
|
+
*/
|
|
141
|
+
export declare function fftfreq(n: number, d?: number): ArrayStorage;
|
|
142
|
+
/**
|
|
143
|
+
* Return the Discrete Fourier Transform sample frequencies for rfft.
|
|
144
|
+
*
|
|
145
|
+
* @param n - Window length
|
|
146
|
+
* @param d - Sample spacing (default: 1.0)
|
|
147
|
+
* @returns Array of length n//2 + 1 containing the sample frequencies
|
|
148
|
+
*/
|
|
149
|
+
export declare function rfftfreq(n: number, d?: number): ArrayStorage;
|
|
150
|
+
/**
|
|
151
|
+
* Shift the zero-frequency component to the center of the spectrum.
|
|
152
|
+
*
|
|
153
|
+
* @param a - Input array
|
|
154
|
+
* @param axes - Axes over which to shift (default: all axes)
|
|
155
|
+
* @returns Shifted array
|
|
156
|
+
*/
|
|
157
|
+
export declare function fftshift(a: ArrayStorage, axes?: number | number[]): ArrayStorage;
|
|
158
|
+
/**
|
|
159
|
+
* Inverse of fftshift.
|
|
160
|
+
*
|
|
161
|
+
* @param a - Input array
|
|
162
|
+
* @param axes - Axes over which to shift (default: all axes)
|
|
163
|
+
* @returns Shifted array
|
|
164
|
+
*/
|
|
165
|
+
export declare function ifftshift(a: ArrayStorage, axes?: number | number[]): ArrayStorage;
|
|
166
|
+
//# sourceMappingURL=fft.d.ts.map
|