pub struct ArnoldiPlan { /* private fields */ }Expand description
Arnoldi iteration plan for general sparse eigenvalue problems.
Generates PTX kernels for each phase of the Arnoldi recurrence:
- SpMV:
w = A * v_j(delegated to the SpMV module) - Modified Gram-Schmidt: for i = 0..j:
h_{i,j} = w . v_i,w = w - h_{i,j} * v_i - Norm and normalize:
h_{j+1,j} = ||w||,v_{j+1} = w / h_{j+1,j}
Unlike Lanczos (which only orthogonalizes against 2 vectors), Arnoldi orthogonalizes against all previous basis vectors at every step.
Implementations§
Source§impl ArnoldiPlan
impl ArnoldiPlan
Sourcepub fn new(config: ArnoldiConfig, n: usize) -> SparseResult<Self>
pub fn new(config: ArnoldiConfig, n: usize) -> SparseResult<Self>
Creates a new Arnoldi plan for an n x n general matrix.
§Errors
Returns SparseError::InvalidArgument if configuration is invalid:
n == 0num_eigenvalues == 0max_iterations < num_eigenvaluesmax_iterations > ntolerance <= 0
Sourcepub fn config(&self) -> &ArnoldiConfig
pub fn config(&self) -> &ArnoldiConfig
Returns the configuration for this plan.
Sourcepub fn workspace_bytes_f64(&self) -> usize
pub fn workspace_bytes_f64(&self) -> usize
Returns the workspace size in bytes needed for f64 Arnoldi vectors.
The workspace must hold:
max_iterations + 1Arnoldi vectors of dimensionn- 1 work vector
wof dimensionn (max_iterations + 1) x max_iterationsHessenberg matrix H
Sourcepub fn workspace_bytes_f32(&self) -> usize
pub fn workspace_bytes_f32(&self) -> usize
Returns the workspace size in bytes needed for f32 Arnoldi vectors.
Sourcepub fn generate_arnoldi_step_ptx(&self) -> SparseResult<String>
pub fn generate_arnoldi_step_ptx(&self) -> SparseResult<String>
Generates PTX for a single Arnoldi step kernel (f64).
The kernel performs the modified Gram-Schmidt orthogonalization and normalization of one Arnoldi iteration step:
// Input: w = A * v_j (SpMV already done)
for i in 0..j:
h_{i,j} = dot(w, v_i)
w = w - h_{i,j} * v_i
h_{j+1,j} = ||w||
v_{j+1} = w / h_{j+1,j}§Kernel Parameters
w_ptr: device pointer to work vector w (length n), modified in-placev_basis_ptr: device pointer to basis matrix V column-major (n x (j+1))h_col_ptr: device pointer to Hessenberg column h_{:,j} (length j+1)v_jp1_ptr: device pointer to output vector v_{j+1} (length n)j: current iteration index (number of existing basis vectors)n: vector length
§Errors
Returns SparseError::PtxGeneration if kernel generation fails.
Sourcepub fn generate_arnoldi_step_ptx_f32(&self) -> SparseResult<String>
pub fn generate_arnoldi_step_ptx_f32(&self) -> SparseResult<String>
Generates PTX for a single Arnoldi step kernel (f32).
Sourcepub fn generate_gram_schmidt_ptx(&self) -> SparseResult<String>
pub fn generate_gram_schmidt_ptx(&self) -> SparseResult<String>
Generates PTX for modified Gram-Schmidt orthogonalization kernel (f64).
This is the inner loop of Arnoldi: orthogonalize w against all
existing basis vectors using modified Gram-Schmidt. This kernel
uses warp-level reductions for the dot products.
§Kernel Parameters
w_ptr: device pointer to vector to orthogonalize (length n)v_basis_ptr: device pointer to basis matrix V column-major (n x j)coeffs_ptr: device pointer to output coefficients h_{i,j} (length j)num_vecs: number of basis vectors jn: vector length
§Errors
Returns SparseError::PtxGeneration if kernel generation fails.
Sourcepub fn generate_gram_schmidt_ptx_f32(&self) -> SparseResult<String>
pub fn generate_gram_schmidt_ptx_f32(&self) -> SparseResult<String>
Generates PTX for modified Gram-Schmidt orthogonalization kernel (f32).
Sourcepub fn generate_dot_product_ptx(&self) -> SparseResult<String>
pub fn generate_dot_product_ptx(&self) -> SparseResult<String>
Generates PTX for the dot product reduction kernel (f64).
Used to compute h_{i,j} = dot(w, v_i) in the Arnoldi recurrence.
Sourcepub fn generate_dot_product_ptx_f32(&self) -> SparseResult<String>
pub fn generate_dot_product_ptx_f32(&self) -> SparseResult<String>
Generates PTX for the dot product reduction kernel (f32).
Sourcepub fn generate_norm_sq_ptx(&self) -> SparseResult<String>
pub fn generate_norm_sq_ptx(&self) -> SparseResult<String>
Generates PTX for the vector norm-squared reduction kernel (f64).
Used to compute h_{j+1,j} = ||w|| (caller takes sqrt of the result).
Sourcepub fn generate_norm_sq_ptx_f32(&self) -> SparseResult<String>
pub fn generate_norm_sq_ptx_f32(&self) -> SparseResult<String>
Generates PTX for the vector norm-squared reduction kernel (f32).