clustering-tfjs
Version:
High-performance TypeScript clustering algorithms (K-Means, Spectral, Agglomerative) with TensorFlow.js acceleration and scikit-learn compatibility
33 lines • 1.2 kB
TypeScript
import * as tf from '../tf-adapter';
/**
* QR Algorithm-based eigendecomposition for symmetric matrices.
*
* The QR algorithm is more numerically stable than Jacobi iteration
* and converges faster for most matrices. This implementation uses
* TensorFlow.js's built-in QR decomposition.
*
* Algorithm:
* 1. Start with A₀ = A
* 2. For each iteration:
* - Compute QR decomposition: Aᵢ = QᵢRᵢ
* - Form Aᵢ₊₁ = RᵢQᵢ
* 3. As i → ∞, Aᵢ converges to a diagonal matrix of eigenvalues
* 4. The product Q₀Q₁...Qᵢ gives the eigenvectors
*/
export declare function qr_eigen_decomposition(matrix: tf.Tensor2D, { maxIterations, tolerance, }?: {
maxIterations?: number;
tolerance?: number;
}): {
eigenvalues: number[];
eigenvectors: number[][];
};
/**
* Specialized QR algorithm for tridiagonal matrices.
* Since normalized Laplacians are often nearly tridiagonal after
* similarity transformations, this can be more efficient.
*/
export declare function tridiagonal_qr_eigen(diagonal: number[], offDiagonal: number[], computeVectors?: boolean): {
eigenvalues: number[];
eigenvectors?: number[][];
};
//# sourceMappingURL=eigen_qr.d.ts.map