@thi.ng/tensors
Version:
1D/2D/3D/4D tensors with extensible polymorphic operations and customizable storage
33 lines • 1.12 kB
TypeScript
import { type Tensor2 } from "./tensor.js";
/**
* Singular value matrix decomposition. Takes an MxN matrix `mat` and decomposes
* it into `{u, v, d}`, where `u`, `v` are left and right orthogonal
* transformation matrices, and `d` is a diagonal matrix of singular values (as
* 1D tensor). Does not modify original matrix.
*
* @remarks
* Throws an error if the matrix has fewer rows than columns or if there's no
* convergence after `maxIter` iterations.
*
* Adapted from Numerical Recipes by Luke Tierney and David Betz. C version
* linked below by Dianne Cook.
*
* Updates/changes:
* - Use flat arrays, add index calculations
* - Update loops
* - Minor other refactoring/optimizations
*
* Reference:
*
* - https://web.archive.org/web/20181206055037/http://www.public.iastate.edu/~dicook/JSS/paper/code/svd.c
* - https://github.com/bitanath/pca/blob/master/pca.js
*
* @param mat
* @param maxIter
*/
export declare const svd: (mat: Tensor2, maxIter?: number) => {
u: Tensor2<number>;
v: Tensor2<number>;
d: import("./tensor.js").Tensor1<number>;
};
//# sourceMappingURL=svd.d.ts.map