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,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array printing and formatting operations
|
|
3
|
+
*
|
|
4
|
+
* Functions for converting arrays and numbers to string representations.
|
|
5
|
+
* @module ops/formatting
|
|
6
|
+
*/
|
|
7
|
+
import { ArrayStorage } from '../storage';
|
|
8
|
+
/**
|
|
9
|
+
* Print options configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface PrintOptions {
|
|
12
|
+
/** Total number of array elements that trigger summarization (default: 1000) */
|
|
13
|
+
threshold: number;
|
|
14
|
+
/** Number of elements to print at edges when summarizing (default: 3) */
|
|
15
|
+
edgeitems: number;
|
|
16
|
+
/** Number of digits of precision for floating point output (default: 8) */
|
|
17
|
+
precision: number;
|
|
18
|
+
/** Characters per line for array output (default: 75) */
|
|
19
|
+
linewidth: number;
|
|
20
|
+
/** If true, always use exponential format; if false, never; if null, auto (default: null) */
|
|
21
|
+
floatmode: 'fixed' | 'unique' | 'maxprec' | 'maxprec_equal';
|
|
22
|
+
/** If true, suppress printing of small floating point values (default: true) */
|
|
23
|
+
suppress: boolean;
|
|
24
|
+
/** String inserted between elements (default: ' ') */
|
|
25
|
+
separator: string;
|
|
26
|
+
/** Prefix for array string */
|
|
27
|
+
prefix: string;
|
|
28
|
+
/** Suffix for array string */
|
|
29
|
+
suffix: string;
|
|
30
|
+
/** String representation of nan (default: 'nan') */
|
|
31
|
+
nanstr: string;
|
|
32
|
+
/** String representation of inf (default: 'inf') */
|
|
33
|
+
infstr: string;
|
|
34
|
+
/** If true, use legacy printing mode (default: false) */
|
|
35
|
+
legacy: string | false;
|
|
36
|
+
/** Whether to print the sign of positive values (default: false) */
|
|
37
|
+
sign: ' ' | '+' | '-';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Set printing options for array output
|
|
41
|
+
*
|
|
42
|
+
* These options determine how arrays are converted to strings.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Options to set
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* set_printoptions({ precision: 4, threshold: 100 });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function set_printoptions(options: Partial<PrintOptions>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get current print options
|
|
54
|
+
*
|
|
55
|
+
* @returns Current print options
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const opts = get_printoptions();
|
|
60
|
+
* console.log(opts.precision); // 8
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export declare function get_printoptions(): PrintOptions;
|
|
64
|
+
/**
|
|
65
|
+
* Context manager for temporarily setting print options
|
|
66
|
+
*
|
|
67
|
+
* In JavaScript, this returns an object with enter/exit methods
|
|
68
|
+
* that can be used with try/finally.
|
|
69
|
+
*
|
|
70
|
+
* @param options - Options to set temporarily
|
|
71
|
+
* @returns Object with enter() and exit() methods
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const ctx = printoptions({ precision: 2 });
|
|
76
|
+
* ctx.enter();
|
|
77
|
+
* try {
|
|
78
|
+
* console.log(array2string(arr));
|
|
79
|
+
* } finally {
|
|
80
|
+
* ctx.exit();
|
|
81
|
+
* }
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export declare function printoptions(options: Partial<PrintOptions>): {
|
|
85
|
+
enter: () => void;
|
|
86
|
+
exit: () => void;
|
|
87
|
+
apply: <T>(fn: () => T) => T;
|
|
88
|
+
_savedOptions: PrintOptions | null;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Format a floating-point number in positional notation
|
|
92
|
+
*
|
|
93
|
+
* @param x - Value to format
|
|
94
|
+
* @param precision - Number of digits after decimal point (default: from printoptions)
|
|
95
|
+
* @param unique - If true, use shortest representation (default: true)
|
|
96
|
+
* @param fractional - If true, always include fractional part (default: true)
|
|
97
|
+
* @param trim - Trim trailing zeros: 'k' (keep), '.' (trim after decimal), '0' (trim zeros), '-' (trim point and zeros)
|
|
98
|
+
* @param sign - Sign handling: '-' (only negative), '+' (always), ' ' (space for positive)
|
|
99
|
+
* @param pad_left - Pad left with spaces to this width
|
|
100
|
+
* @param pad_right - Pad right with zeros to this width
|
|
101
|
+
* @param min_digits - Minimum digits after decimal point
|
|
102
|
+
* @returns Formatted string
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* format_float_positional(3.14159265, 4); // '3.1416'
|
|
107
|
+
* format_float_positional(1000.0, 2); // '1000.00'
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function format_float_positional(x: number, precision?: number | null, unique?: boolean, fractional?: boolean, trim?: 'k' | '.' | '0' | '-', sign?: '-' | '+' | ' ', pad_left?: number | null, pad_right?: number | null, min_digits?: number | null): string;
|
|
111
|
+
/**
|
|
112
|
+
* Format a floating-point number in scientific notation
|
|
113
|
+
*
|
|
114
|
+
* @param x - Value to format
|
|
115
|
+
* @param precision - Number of digits after decimal point (default: from printoptions)
|
|
116
|
+
* @param unique - If true, use shortest representation (default: true)
|
|
117
|
+
* @param trim - Trim trailing zeros: 'k' (keep), '.' (trim after decimal), '0' (trim zeros), '-' (trim point and zeros)
|
|
118
|
+
* @param sign - Sign handling: '-' (only negative), '+' (always), ' ' (space for positive)
|
|
119
|
+
* @param pad_left - Pad left with spaces to this width
|
|
120
|
+
* @param exp_digits - Minimum digits in exponent
|
|
121
|
+
* @param min_digits - Minimum digits after decimal point
|
|
122
|
+
* @returns Formatted string
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* format_float_scientific(3.14159265, 4); // '3.1416e+00'
|
|
127
|
+
* format_float_scientific(12345.0, 2); // '1.23e+04'
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function format_float_scientific(x: number, precision?: number | null, _unique?: boolean, trim?: 'k' | '.' | '0' | '-', sign?: '-' | '+' | ' ', pad_left?: number | null, exp_digits?: number, min_digits?: number | null): string;
|
|
131
|
+
/**
|
|
132
|
+
* Return a string representation of a number in the given base
|
|
133
|
+
*
|
|
134
|
+
* For base 2, -36. Negative numbers are represented using two's complement
|
|
135
|
+
* if padding is specified, otherwise prefixed with '-'.
|
|
136
|
+
*
|
|
137
|
+
* @param number - Number to convert
|
|
138
|
+
* @param base - Base for representation (2-36, default: 2)
|
|
139
|
+
* @param padding - Minimum number of digits (pads with zeros)
|
|
140
|
+
* @returns String representation in the given base
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* base_repr(10, 2); // '1010'
|
|
145
|
+
* base_repr(10, 16); // 'A'
|
|
146
|
+
* base_repr(-10, 2, 8); // '11110110' (two's complement)
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare function base_repr(number: number, base?: number, padding?: number): string;
|
|
150
|
+
/**
|
|
151
|
+
* Return the binary representation of the input number as a string
|
|
152
|
+
*
|
|
153
|
+
* For negative numbers, two's complement is used if width is specified,
|
|
154
|
+
* otherwise a minus sign is prefixed.
|
|
155
|
+
*
|
|
156
|
+
* @param num - Integer to convert
|
|
157
|
+
* @param width - Minimum width of the result (pads with zeros, uses two's complement for negatives)
|
|
158
|
+
* @returns Binary string representation
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* binary_repr(10); // '1010'
|
|
163
|
+
* binary_repr(-10); // '-1010'
|
|
164
|
+
* binary_repr(-10, 8); // '11110110' (two's complement)
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare function binary_repr(num: number, width?: number | null): string;
|
|
168
|
+
/**
|
|
169
|
+
* Convert an array to a string representation
|
|
170
|
+
*
|
|
171
|
+
* @param a - Input array storage
|
|
172
|
+
* @param max_line_width - Maximum line width (default: from printoptions)
|
|
173
|
+
* @param precision - Number of digits of precision (default: from printoptions)
|
|
174
|
+
* @param suppress_small - Suppress small floating point values (default: from printoptions)
|
|
175
|
+
* @param separator - Separator between elements (default: from printoptions)
|
|
176
|
+
* @param prefix - Prefix string (default: '')
|
|
177
|
+
* @param suffix - Suffix string (default: '')
|
|
178
|
+
* @param threshold - Threshold for summarization (default: from printoptions)
|
|
179
|
+
* @param edgeitems - Number of edge items when summarizing (default: from printoptions)
|
|
180
|
+
* @returns String representation of the array
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const arr = array([[1, 2, 3], [4, 5, 6]]);
|
|
185
|
+
* console.log(array2string(arr.storage));
|
|
186
|
+
* // [[1 2 3]
|
|
187
|
+
* // [4 5 6]]
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function array2string(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null, separator?: string, prefix?: string, suffix?: string, threshold?: number | null, edgeitems?: number | null): string;
|
|
191
|
+
/**
|
|
192
|
+
* Return the string representation of an array
|
|
193
|
+
*
|
|
194
|
+
* Similar to array2string but includes the 'array(' prefix.
|
|
195
|
+
*
|
|
196
|
+
* @param a - Input array storage
|
|
197
|
+
* @param max_line_width - Maximum line width
|
|
198
|
+
* @param precision - Number of digits of precision
|
|
199
|
+
* @param suppress_small - Suppress small floating point values
|
|
200
|
+
* @returns String representation
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const arr = array([1, 2, 3]);
|
|
205
|
+
* console.log(array_repr(arr.storage));
|
|
206
|
+
* // array([1, 2, 3])
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export declare function array_repr(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null): string;
|
|
210
|
+
/**
|
|
211
|
+
* Return a string representation of the data in an array
|
|
212
|
+
*
|
|
213
|
+
* Similar to array2string but returns just the data without array() wrapper.
|
|
214
|
+
*
|
|
215
|
+
* @param a - Input array storage
|
|
216
|
+
* @param max_line_width - Maximum line width
|
|
217
|
+
* @param precision - Number of digits of precision
|
|
218
|
+
* @param suppress_small - Suppress small floating point values
|
|
219
|
+
* @returns String representation of the data
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const arr = array([1, 2, 3]);
|
|
224
|
+
* console.log(array_str(arr.storage));
|
|
225
|
+
* // [1 2 3]
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function array_str(a: ArrayStorage, max_line_width?: number | null, precision?: number | null, suppress_small?: boolean | null): string;
|
|
229
|
+
//# sourceMappingURL=formatting.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
|
* Calculate the n-th discrete difference along the given axis.
|
|
13
13
|
*
|
|
@@ -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
|
* Hyperbolic sine of each element (element-wise)
|
|
13
13
|
* NumPy behavior: Always promotes to float64 for integer types
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Pure functions for matrix operations (matmul, etc.).
|
|
5
5
|
* @module ops/linalg
|
|
6
6
|
*/
|
|
7
|
-
import { ArrayStorage } from '../
|
|
8
|
-
import { Complex } from '../
|
|
7
|
+
import { ArrayStorage } from '../storage';
|
|
8
|
+
import { Complex } from '../complex';
|
|
9
9
|
/**
|
|
10
10
|
* Dot product of two arrays (fully NumPy-compatible)
|
|
11
11
|
*
|
|
@@ -158,7 +158,7 @@ export declare function kron(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
|
|
|
158
158
|
* @param axis - If defined, the axis of a, b and c that defines the vectors
|
|
159
159
|
* @returns Cross product of a and b
|
|
160
160
|
*/
|
|
161
|
-
export declare function cross(a: ArrayStorage, b: ArrayStorage, axisa?: number, axisb?: number, axisc?: number, axis?: number): ArrayStorage | number;
|
|
161
|
+
export declare function cross(a: ArrayStorage, b: ArrayStorage, axisa?: number, axisb?: number, axisc?: number, axis?: number): ArrayStorage | number | Complex;
|
|
162
162
|
/**
|
|
163
163
|
* Vector norm.
|
|
164
164
|
*
|
|
@@ -364,4 +364,149 @@ export declare function eigvals(a: ArrayStorage): ArrayStorage;
|
|
|
364
364
|
* @returns Array of eigenvalues (sorted ascending)
|
|
365
365
|
*/
|
|
366
366
|
export declare function eigvalsh(a: ArrayStorage, UPLO?: 'L' | 'U'): ArrayStorage;
|
|
367
|
+
/**
|
|
368
|
+
* Return the dot product of two vectors (flattened).
|
|
369
|
+
*
|
|
370
|
+
* Unlike dot(), vdot flattens both inputs before computing the dot product.
|
|
371
|
+
* For complex numbers, vdot uses the complex conjugate of the first argument.
|
|
372
|
+
*
|
|
373
|
+
* @param a - First input array (will be flattened)
|
|
374
|
+
* @param b - Second input array (will be flattened)
|
|
375
|
+
* @returns Scalar dot product
|
|
376
|
+
*/
|
|
377
|
+
export declare function vdot(a: ArrayStorage, b: ArrayStorage): number | bigint | Complex;
|
|
378
|
+
/**
|
|
379
|
+
* Vector dot product along the last axis.
|
|
380
|
+
*
|
|
381
|
+
* Computes the dot product of vectors along the last axis of both inputs.
|
|
382
|
+
* The last dimensions of a and b must match.
|
|
383
|
+
*
|
|
384
|
+
* @param a - First input array
|
|
385
|
+
* @param b - Second input array
|
|
386
|
+
* @param axis - Axis along which to compute (default: -1, meaning last axis)
|
|
387
|
+
* @returns Result with last dimension removed
|
|
388
|
+
*/
|
|
389
|
+
export declare function vecdot(a: ArrayStorage, b: ArrayStorage, axis?: number): ArrayStorage | number | bigint | Complex;
|
|
390
|
+
/**
|
|
391
|
+
* Transpose the last two axes of an array.
|
|
392
|
+
*
|
|
393
|
+
* Equivalent to swapaxes(a, -2, -1) or transpose with axes that swap the last two.
|
|
394
|
+
* For a 2D array, this is the same as transpose.
|
|
395
|
+
*
|
|
396
|
+
* @param a - Input array with at least 2 dimensions
|
|
397
|
+
* @returns Array with last two axes transposed
|
|
398
|
+
*/
|
|
399
|
+
export declare function matrix_transpose(a: ArrayStorage): ArrayStorage;
|
|
400
|
+
/**
|
|
401
|
+
* Permute the dimensions of an array.
|
|
402
|
+
*
|
|
403
|
+
* This is an alias for transpose to match the Array API standard.
|
|
404
|
+
*
|
|
405
|
+
* @param a - Input array
|
|
406
|
+
* @param axes - Permutation of axes. If not specified, reverses the axes.
|
|
407
|
+
* @returns Transposed array
|
|
408
|
+
*/
|
|
409
|
+
export declare function permute_dims(a: ArrayStorage, axes?: number[]): ArrayStorage;
|
|
410
|
+
/**
|
|
411
|
+
* Matrix-vector multiplication.
|
|
412
|
+
*
|
|
413
|
+
* Computes the matrix-vector product over the last two axes of x1 and
|
|
414
|
+
* the last axis of x2.
|
|
415
|
+
*
|
|
416
|
+
* @param x1 - First input array (matrix) with shape (..., M, N)
|
|
417
|
+
* @param x2 - Second input array (vector) with shape (..., N)
|
|
418
|
+
* @returns Result with shape (..., M)
|
|
419
|
+
*/
|
|
420
|
+
export declare function matvec(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
|
|
421
|
+
/**
|
|
422
|
+
* Vector-matrix multiplication.
|
|
423
|
+
*
|
|
424
|
+
* Computes the vector-matrix product over the last axis of x1 and
|
|
425
|
+
* the second-to-last axis of x2.
|
|
426
|
+
*
|
|
427
|
+
* @param x1 - First input array (vector) with shape (..., M)
|
|
428
|
+
* @param x2 - Second input array (matrix) with shape (..., M, N)
|
|
429
|
+
* @returns Result with shape (..., N)
|
|
430
|
+
*/
|
|
431
|
+
export declare function vecmat(x1: ArrayStorage, x2: ArrayStorage): ArrayStorage;
|
|
432
|
+
/**
|
|
433
|
+
* Compute sign and (natural) logarithm of the determinant.
|
|
434
|
+
*
|
|
435
|
+
* Returns (sign, logabsdet) where sign is the sign of the determinant
|
|
436
|
+
* and logabsdet is the natural log of the absolute value of the determinant.
|
|
437
|
+
*
|
|
438
|
+
* This is useful for computing determinants of large matrices where the
|
|
439
|
+
* determinant itself might overflow or underflow.
|
|
440
|
+
*
|
|
441
|
+
* @param a - Square matrix
|
|
442
|
+
* @returns { sign, logabsdet }
|
|
443
|
+
*/
|
|
444
|
+
export declare function slogdet(a: ArrayStorage): {
|
|
445
|
+
sign: number;
|
|
446
|
+
logabsdet: number;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Compute singular values of a matrix.
|
|
450
|
+
*
|
|
451
|
+
* This is equivalent to svd(a, compute_uv=False) but more efficient
|
|
452
|
+
* as it doesn't compute the U and V matrices.
|
|
453
|
+
*
|
|
454
|
+
* @param a - Input matrix (m x n)
|
|
455
|
+
* @returns 1D array of singular values in descending order
|
|
456
|
+
*/
|
|
457
|
+
export declare function svdvals(a: ArrayStorage): ArrayStorage;
|
|
458
|
+
/**
|
|
459
|
+
* Compute the dot product of two or more arrays in a single function call.
|
|
460
|
+
*
|
|
461
|
+
* Optimizes the order of multiplications to minimize computation.
|
|
462
|
+
* For example, for three arrays A, B, C with shapes (10, 100), (100, 5), (5, 50),
|
|
463
|
+
* it's more efficient to compute (A @ B) @ C than A @ (B @ C).
|
|
464
|
+
*
|
|
465
|
+
* @param arrays - List of arrays to multiply
|
|
466
|
+
* @returns Result of multiplying all arrays
|
|
467
|
+
*/
|
|
468
|
+
export declare function multi_dot(arrays: ArrayStorage[]): ArrayStorage;
|
|
469
|
+
/**
|
|
470
|
+
* Compute the 'inverse' of an N-dimensional array.
|
|
471
|
+
*
|
|
472
|
+
* The inverse is defined such that tensordot(tensorinv(a), a, ind) == I
|
|
473
|
+
* where I is the identity operator.
|
|
474
|
+
*
|
|
475
|
+
* @param a - Input array to invert
|
|
476
|
+
* @param ind - Number of first indices that are involved in the inverse sum (default: 2)
|
|
477
|
+
* @returns Tensor inverse
|
|
478
|
+
*/
|
|
479
|
+
export declare function tensorinv(a: ArrayStorage, ind?: number): ArrayStorage;
|
|
480
|
+
/**
|
|
481
|
+
* Solve the tensor equation a x = b for x.
|
|
482
|
+
*
|
|
483
|
+
* This is equivalent to solve after reshaping a and b appropriately.
|
|
484
|
+
*
|
|
485
|
+
* @param a - Coefficient tensor
|
|
486
|
+
* @param b - Target tensor
|
|
487
|
+
* @param axes - Axes of a to be summed over in the contraction (default based on b.ndim)
|
|
488
|
+
* @returns Solution tensor x
|
|
489
|
+
*/
|
|
490
|
+
export declare function tensorsolve(a: ArrayStorage, b: ArrayStorage, axes?: number[] | null): ArrayStorage;
|
|
491
|
+
/**
|
|
492
|
+
* Evaluate the lowest cost contraction order for an einsum expression
|
|
493
|
+
*
|
|
494
|
+
* This function analyzes an einsum expression and finds an optimized contraction
|
|
495
|
+
* path that minimizes the total number of operations (FLOPs).
|
|
496
|
+
*
|
|
497
|
+
* @param subscripts - Einsum subscript string (e.g., 'ij,jk,kl->il')
|
|
498
|
+
* @param operands - Input arrays (or their shapes)
|
|
499
|
+
* @param optimize - Optimization strategy: 'greedy' (default), 'optimal', or false for no optimization
|
|
500
|
+
* @returns A tuple of [path, string_representation] where path is an array of index pairs
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const a = ones([10, 10]);
|
|
505
|
+
* const b = ones([10, 10]);
|
|
506
|
+
* const c = ones([10, 10]);
|
|
507
|
+
* const [path, info] = einsum_path('ij,jk,kl->il', a.storage, b.storage, c.storage);
|
|
508
|
+
* // path: [[0, 1], [0, 1]] - contract first two, then result with third
|
|
509
|
+
* ```
|
|
510
|
+
*/
|
|
511
|
+
export declare function einsum_path(subscripts: string, ...operands: (ArrayStorage | number[])[]): [Array<[number, number] | number[]>, string];
|
|
367
512
|
//# sourceMappingURL=linalg.d.ts.map
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* These operations convert values to boolean (non-zero = true, zero = false)
|
|
9
9
|
* and return boolean arrays (dtype: 'bool').
|
|
10
10
|
*/
|
|
11
|
-
import { ArrayStorage } from '../
|
|
12
|
-
import { type DType } from '../
|
|
11
|
+
import { ArrayStorage } from '../storage';
|
|
12
|
+
import { type DType } from '../dtype';
|
|
13
13
|
/**
|
|
14
14
|
* Logical AND of two arrays or array and scalar
|
|
15
15
|
*
|