numpy-ts 0.8.0 → 0.9.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.
@@ -143,4 +143,224 @@ export declare function einsum(subscripts: string, ...operands: ArrayStorage[]):
143
143
  * @returns Kronecker product of a and b
144
144
  */
145
145
  export declare function kron(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
146
+ /**
147
+ * Cross product of two vectors.
148
+ *
149
+ * For 3D vectors: returns the cross product vector
150
+ * For 2D vectors: returns the scalar z-component of the cross product
151
+ *
152
+ * @param a - First input array
153
+ * @param b - Second input array
154
+ * @param axisa - Axis of a that defines the vectors (default: -1)
155
+ * @param axisb - Axis of b that defines the vectors (default: -1)
156
+ * @param axisc - Axis of c containing the cross product vectors (default: -1)
157
+ * @param axis - If defined, the axis of a, b and c that defines the vectors
158
+ * @returns Cross product of a and b
159
+ */
160
+ export declare function cross(a: ArrayStorage, b: ArrayStorage, axisa?: number, axisb?: number, axisc?: number, axis?: number): ArrayStorage | number;
161
+ /**
162
+ * Vector norm.
163
+ *
164
+ * @param x - Input vector or array
165
+ * @param ord - Order of the norm (default: 2)
166
+ * - Infinity: max(abs(x))
167
+ * - -Infinity: min(abs(x))
168
+ * - 0: sum(x != 0)
169
+ * - Other: sum(abs(x)^ord)^(1/ord)
170
+ * @param axis - Axis along which to compute (flattened if not specified)
171
+ * @param keepdims - Keep reduced dimensions
172
+ * @returns Vector norm
173
+ */
174
+ export declare function vector_norm(x: ArrayStorage, ord?: number | 'fro' | 'nuc', axis?: number | null, keepdims?: boolean): ArrayStorage | number;
175
+ /**
176
+ * Matrix norm.
177
+ *
178
+ * @param x - Input 2D array
179
+ * @param ord - Order of the norm:
180
+ * - 'fro': Frobenius norm (default)
181
+ * - 'nuc': Nuclear norm (sum of singular values)
182
+ * - 1: Max column sum (max(sum(abs(x), axis=0)))
183
+ * - -1: Min column sum (min(sum(abs(x), axis=0)))
184
+ * - 2: Largest singular value
185
+ * - -2: Smallest singular value
186
+ * - Infinity: Max row sum (max(sum(abs(x), axis=1)))
187
+ * - -Infinity: Min row sum (min(sum(abs(x), axis=1)))
188
+ * @param keepdims - Keep reduced dimensions
189
+ * @returns Matrix norm
190
+ */
191
+ export declare function matrix_norm(x: ArrayStorage, ord?: number | 'fro' | 'nuc', keepdims?: boolean): ArrayStorage | number;
192
+ /**
193
+ * General norm function (for both vectors and matrices).
194
+ *
195
+ * @param x - Input array
196
+ * @param ord - Order of the norm (default: 'fro' for 2D, 2 for 1D)
197
+ * @param axis - Axis or axes along which to compute
198
+ * @param keepdims - Keep reduced dimensions
199
+ * @returns Norm
200
+ */
201
+ export declare function norm(x: ArrayStorage, ord?: number | 'fro' | 'nuc' | null, axis?: number | [number, number] | null, keepdims?: boolean): ArrayStorage | number;
202
+ /**
203
+ * QR decomposition using Householder reflections.
204
+ *
205
+ * @param a - Input matrix (m x n)
206
+ * @param mode - 'reduced' (default), 'complete', 'r', or 'raw'
207
+ * @returns { q, r } where A = Q @ R
208
+ */
209
+ export declare function qr(a: ArrayStorage, mode?: 'reduced' | 'complete' | 'r' | 'raw'): {
210
+ q: ArrayStorage;
211
+ r: ArrayStorage;
212
+ } | ArrayStorage | {
213
+ h: ArrayStorage;
214
+ tau: ArrayStorage;
215
+ };
216
+ /**
217
+ * Cholesky decomposition.
218
+ *
219
+ * Returns the lower triangular matrix L such that A = L @ L^T
220
+ * for a symmetric positive-definite matrix A.
221
+ *
222
+ * @param a - Symmetric positive-definite matrix
223
+ * @param upper - If true, return upper triangular U such that A = U^T @ U
224
+ * @returns Lower (or upper) triangular Cholesky factor
225
+ */
226
+ export declare function cholesky(a: ArrayStorage, upper?: boolean): ArrayStorage;
227
+ /**
228
+ * Singular Value Decomposition.
229
+ *
230
+ * @param a - Input matrix (m x n)
231
+ * @param full_matrices - If true, return full U and V^T, otherwise reduced
232
+ * @param compute_uv - If true, return U, S, V^T; if false, return only S
233
+ * @returns { u, s, vt } or just s depending on compute_uv
234
+ */
235
+ export declare function svd(a: ArrayStorage, full_matrices?: boolean, compute_uv?: boolean): {
236
+ u: ArrayStorage;
237
+ s: ArrayStorage;
238
+ vt: ArrayStorage;
239
+ } | ArrayStorage;
240
+ /**
241
+ * Compute the determinant of a square matrix.
242
+ *
243
+ * Uses LU decomposition for numerical stability.
244
+ *
245
+ * @param a - Square matrix
246
+ * @returns Determinant
247
+ */
248
+ export declare function det(a: ArrayStorage): number;
249
+ /**
250
+ * Compute the matrix inverse - optimized to do LU decomposition once.
251
+ *
252
+ * @param a - Square matrix
253
+ * @returns Inverse matrix
254
+ */
255
+ export declare function inv(a: ArrayStorage): ArrayStorage;
256
+ /**
257
+ * Solve a linear system A @ x = b.
258
+ *
259
+ * @param a - Coefficient matrix (n x n)
260
+ * @param b - Right-hand side (n,) or (n, k)
261
+ * @returns Solution x with same shape as b
262
+ */
263
+ export declare function solve(a: ArrayStorage, b: ArrayStorage): ArrayStorage;
264
+ /**
265
+ * Compute the least-squares solution to a linear matrix equation.
266
+ *
267
+ * @param a - Coefficient matrix (m x n)
268
+ * @param b - Right-hand side (m,) or (m, k)
269
+ * @param rcond - Cutoff for small singular values (default: machine precision * max(m, n))
270
+ * @returns { x, residuals, rank, s } - Solution, residuals, effective rank, singular values
271
+ */
272
+ export declare function lstsq(a: ArrayStorage, b: ArrayStorage, rcond?: number | null): {
273
+ x: ArrayStorage;
274
+ residuals: ArrayStorage;
275
+ rank: number;
276
+ s: ArrayStorage;
277
+ };
278
+ /**
279
+ * Compute the condition number of a matrix.
280
+ *
281
+ * @param a - Input matrix
282
+ * @param p - Order of the norm (default: 2, -2, 'fro', or inf)
283
+ * @returns Condition number
284
+ */
285
+ export declare function cond(a: ArrayStorage, p?: number | 'fro' | 'nuc'): number;
286
+ /**
287
+ * Compute the rank of a matrix using SVD.
288
+ *
289
+ * @param a - Input matrix
290
+ * @param tol - Threshold below which singular values are considered zero
291
+ * @returns Matrix rank
292
+ */
293
+ export declare function matrix_rank(a: ArrayStorage, tol?: number): number;
294
+ /**
295
+ * Raise a square matrix to an integer power.
296
+ *
297
+ * @param a - Input square matrix
298
+ * @param n - Integer power (can be negative)
299
+ * @returns Matrix raised to power n
300
+ */
301
+ export declare function matrix_power(a: ArrayStorage, n: number): ArrayStorage;
302
+ /**
303
+ * Compute the Moore-Penrose pseudo-inverse using SVD.
304
+ *
305
+ * @param a - Input matrix
306
+ * @param rcond - Cutoff for small singular values
307
+ * @returns Pseudo-inverse of a
308
+ */
309
+ export declare function pinv(a: ArrayStorage, rcond?: number): ArrayStorage;
310
+ /**
311
+ * Compute eigenvalues and right eigenvectors of a square matrix.
312
+ *
313
+ * For general matrices, uses iterative methods.
314
+ * For symmetric matrices, use eigh for better performance.
315
+ *
316
+ * **Limitation**: Complex eigenvalues are not supported. For non-symmetric matrices,
317
+ * this function returns only the real parts of eigenvalues. If your matrix has
318
+ * complex eigenvalues (e.g., rotation matrices), results will be incorrect.
319
+ * Use eigh() for symmetric matrices where eigenvalues are guaranteed to be real.
320
+ *
321
+ * @param a - Input square matrix
322
+ * @returns { w, v } - Eigenvalues (real only) and eigenvector matrix
323
+ */
324
+ export declare function eig(a: ArrayStorage): {
325
+ w: ArrayStorage;
326
+ v: ArrayStorage;
327
+ };
328
+ /**
329
+ * Compute eigenvalues and eigenvectors of a real symmetric matrix.
330
+ *
331
+ * Note: Named "Hermitian" for NumPy compatibility, but only real symmetric
332
+ * matrices are supported (complex Hermitian matrices require complex dtype support).
333
+ * Symmetric matrices always have real eigenvalues, so results are exact.
334
+ *
335
+ * @param a - Real symmetric matrix
336
+ * @param UPLO - 'L' or 'U' to use lower or upper triangle (default: 'L')
337
+ * @returns { w, v } - Eigenvalues (sorted ascending) and eigenvector matrix
338
+ */
339
+ export declare function eigh(a: ArrayStorage, UPLO?: 'L' | 'U'): {
340
+ w: ArrayStorage;
341
+ v: ArrayStorage;
342
+ };
343
+ /**
344
+ * Compute eigenvalues of a general square matrix.
345
+ *
346
+ * **Limitation**: Complex eigenvalues are not supported. For non-symmetric matrices,
347
+ * this function returns only real approximations. Use eigvalsh() for symmetric
348
+ * matrices where eigenvalues are guaranteed to be real.
349
+ *
350
+ * @param a - Input square matrix
351
+ * @returns Array of eigenvalues (real only)
352
+ */
353
+ export declare function eigvals(a: ArrayStorage): ArrayStorage;
354
+ /**
355
+ * Compute eigenvalues of a real symmetric matrix.
356
+ *
357
+ * Note: Named "Hermitian" for NumPy compatibility, but only real symmetric
358
+ * matrices are supported (complex Hermitian matrices require complex dtype support).
359
+ * Symmetric matrices always have real eigenvalues, so results are exact.
360
+ *
361
+ * @param a - Real symmetric matrix
362
+ * @param UPLO - 'L' or 'U' to use lower or upper triangle
363
+ * @returns Array of eigenvalues (sorted ascending)
364
+ */
365
+ export declare function eigvalsh(a: ArrayStorage, UPLO?: 'L' | 'U'): ArrayStorage;
146
366
  //# sourceMappingURL=linalg.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Rounding operations
3
+ *
4
+ * Pure functions for element-wise rounding operations:
5
+ * around, ceil, fix, floor, rint, round, trunc
6
+ */
7
+ import { ArrayStorage } from '../core/storage';
8
+ /**
9
+ * Round an array to the given number of decimals
10
+ */
11
+ export declare function around(a: ArrayStorage, decimals?: number): ArrayStorage;
12
+ /**
13
+ * Return the ceiling of the input, element-wise
14
+ */
15
+ export declare function ceil(a: ArrayStorage): ArrayStorage;
16
+ /**
17
+ * Round to nearest integer towards zero
18
+ */
19
+ export declare function fix(a: ArrayStorage): ArrayStorage;
20
+ /**
21
+ * Return the floor of the input, element-wise
22
+ */
23
+ export declare function floor(a: ArrayStorage): ArrayStorage;
24
+ /**
25
+ * Round elements of the array to the nearest integer (banker's rounding)
26
+ */
27
+ export declare function rint(a: ArrayStorage): ArrayStorage;
28
+ /**
29
+ * Alias for around
30
+ */
31
+ export declare function round(a: ArrayStorage, decimals?: number): ArrayStorage;
32
+ /**
33
+ * Return the truncated value of the input, element-wise
34
+ */
35
+ export declare function trunc(a: ArrayStorage): ArrayStorage;
36
+ //# sourceMappingURL=rounding.d.ts.map
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Set operations
3
+ */
4
+ import { ArrayStorage } from '../core/storage';
5
+ /**
6
+ * Find the unique elements of an array
7
+ */
8
+ export declare function unique(a: ArrayStorage, returnIndex?: boolean, returnInverse?: boolean, returnCounts?: boolean): ArrayStorage | {
9
+ values: ArrayStorage;
10
+ indices?: ArrayStorage;
11
+ inverse?: ArrayStorage;
12
+ counts?: ArrayStorage;
13
+ };
14
+ /**
15
+ * Test whether each element of a 1-D array is also present in a second array
16
+ */
17
+ export declare function in1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
18
+ /**
19
+ * Find the intersection of two arrays
20
+ */
21
+ export declare function intersect1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
22
+ /**
23
+ * Test whether each element of an ND array is also present in a second array
24
+ */
25
+ export declare function isin(element: ArrayStorage, testElements: ArrayStorage): ArrayStorage;
26
+ /**
27
+ * Find the set difference of two arrays
28
+ */
29
+ export declare function setdiff1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
30
+ /**
31
+ * Find the set exclusive-or of two arrays
32
+ */
33
+ export declare function setxor1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
34
+ /**
35
+ * Find the union of two arrays
36
+ */
37
+ export declare function union1d(ar1: ArrayStorage, ar2: ArrayStorage): ArrayStorage;
38
+ //# sourceMappingURL=sets.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "numpy-ts",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Complete NumPy implementation for TypeScript and JavaScript (under construction)",
5
5
  "main": "dist/numpy-ts.node.cjs",
6
6
  "browser": "dist/numpy-ts.browser.js",