import * as tf from '../backend/adapter'; export interface LanczosOptions { /** Maximum Lanczos subspace size before restart. Default: min(max(2k+20, 4k), n, 200) */ max_subspace_size?: number; max_restarts?: number; convergence_tol?: number; /** Random seed for deterministic starting vector. Default: 42 */ random_seed?: number; /** Whether the matrix is PSD (clamp negative eigenvalues to 0). Default: true */ is_psd?: boolean; } export interface LanczosResult { eigenvalues: number[]; eigenvectors: number[][]; } export interface LanczosOperator { n: number; matvec: (vector: Float64Array) => Float64Array; } /** * Computes the k smallest eigenpairs of a symmetric matrix using the * Lanczos algorithm with full reorthogonalization. * * Standard Lanczos: applies A*v directly and extracts the k smallest * Ritz values from the tridiagonal eigenproblem. Uses simple restart * (best Ritz vector as new starting point) when the subspace reaches * its maximum size without convergence. * * Complexity: O(n² · m) where m is the Lanczos subspace size (typically 30–100), * versus O(n³) for Jacobi. For n=5000, k=5, this is ~1000x faster. * * @param matrix Symmetric n×n matrix (typically a normalized Laplacian) */ export declare function lanczos_smallest_eigenpairs(matrix: tf.Tensor2D | LanczosOperator, k: number, options?: LanczosOptions): LanczosResult;