Skip to main content

ArnoldiPlan

Struct ArnoldiPlan 

Source
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:

  1. SpMV: w = A * v_j (delegated to the SpMV module)
  2. Modified Gram-Schmidt: for i = 0..j: h_{i,j} = w . v_i, w = w - h_{i,j} * v_i
  3. 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

Source

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 == 0
  • num_eigenvalues == 0
  • max_iterations < num_eigenvalues
  • max_iterations > n
  • tolerance <= 0
Source

pub fn config(&self) -> &ArnoldiConfig

Returns the configuration for this plan.

Source

pub fn dimension(&self) -> usize

Returns the matrix dimension.

Source

pub fn workspace_bytes_f64(&self) -> usize

Returns the workspace size in bytes needed for f64 Arnoldi vectors.

The workspace must hold:

  • max_iterations + 1 Arnoldi vectors of dimension n
  • 1 work vector w of dimension n
  • (max_iterations + 1) x max_iterations Hessenberg matrix H
Source

pub fn workspace_bytes_f32(&self) -> usize

Returns the workspace size in bytes needed for f32 Arnoldi vectors.

Source

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-place
  • v_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.

Source

pub fn generate_arnoldi_step_ptx_f32(&self) -> SparseResult<String>

Generates PTX for a single Arnoldi step kernel (f32).

Source

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 j
  • n: vector length
§Errors

Returns SparseError::PtxGeneration if kernel generation fails.

Source

pub fn generate_gram_schmidt_ptx_f32(&self) -> SparseResult<String>

Generates PTX for modified Gram-Schmidt orthogonalization kernel (f32).

Source

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.

Source

pub fn generate_dot_product_ptx_f32(&self) -> SparseResult<String>

Generates PTX for the dot product reduction kernel (f32).

Source

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).

Source

pub fn generate_norm_sq_ptx_f32(&self) -> SparseResult<String>

Generates PTX for the vector norm-squared reduction kernel (f32).

Trait Implementations§

Source§

impl Debug for ArnoldiPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more