Skip to main content

GenericCsrOp

Struct GenericCsrOp 

Source
pub struct GenericCsrOp<S: KrystScalar> { /* private fields */ }
Available on crate feature backend-faer only.
Expand description

Scalar-generic CSR linear operator backed by ScalarCsrMatrix.

This wrapper tracks StructureId/ValuesId so callers can mutate the owned matrix and keep format caches valid. After any in-place edits, call mark_structure_changed or mark_values_changed before reusing the operator in cached conversions.

The operator wires the scalar-polymorphic sparse matrix storage into the LinOp trait by constructing an SpmvPlan at creation time. Real builds continue to select SIMD kernels when available while complex builds transparently fall back to the portable scalar path.

Implementations§

Source§

impl<S: KrystScalar> GenericCsrOp<S>

Source

pub fn new(matrix: Arc<ScalarCsrMatrix<S>>, tuning: &SpmvTuning) -> Self

Wraps an Arc around the provided matrix and builds an SpMV plan using the supplied tuning parameters.

Source

pub fn from_matrix(matrix: ScalarCsrMatrix<S>, tuning: &SpmvTuning) -> Self

Builds an operator from an owned matrix by first wrapping it in an Arc for cheap cloning.

Source

pub fn from_real_csr(real: &CsrMatrix<f64>, tuning: &SpmvTuning) -> Self
where S: KrystScalar<Real = f64>,

Lifts a real-valued CSR matrix into the active scalar domain.

This clones the underlying structure and converts the numeric values through KrystScalar::from_real, enabling solvers in complex builds to reuse pre-existing f64 sparsity patterns without reassembly.

Source

pub fn matrix(&self) -> &ScalarCsrMatrix<S>

Returns the underlying CSR matrix.

Source

pub fn plan(&self) -> &ScalarSpmvPlan<S>

Returns a reference to the cached SpMV plan.

Source

pub fn rebuild_plan(&mut self, tuning: &SpmvTuning)

Rebuilds the internal SpMV plan using the latest tuning parameters.

Source

pub fn with_comm(self, comm: UniverseComm) -> Self

Attaches a communicator to the operator, mirroring the legacy API.

Source

pub fn with_layout(self, layout: DistLayout) -> Self

Attach a distributed layout to this operator.

Source

pub fn mark_structure_changed(&self)

Marks the sparsity pattern as changed for cache bookkeeping.

Source

pub fn mark_values_changed(&self)

Marks only the numeric values as changed.

Trait Implementations§

Source§

impl KLinOp for GenericCsrOp<Complex64>

Available on crate feature complex only.
Source§

type Scalar = Complex<f64>

Source§

fn dims(&self) -> (usize, usize)

Dimensions of the operator (nrows, ncols).
Source§

fn matvec_s( &self, x: &[Complex64], y: &mut [Complex64], _scratch: &mut BridgeScratch, )

Perform y <- A x. Read more
Source§

fn supports_t_matvec_s(&self) -> bool

Whether the operator exposes a transpose/adjoint matvec.
Source§

fn t_matvec_s( &self, x: &[Complex64], y: &mut [Complex64], _scratch: &mut BridgeScratch, )

Perform y <- A^T x (or A^H x in complex builds). Read more
Source§

impl<S: KrystScalar> LinOp for GenericCsrOp<S>

Source§

type S = S

Source§

fn dims(&self) -> (usize, usize)

Dimensions (rows, cols).
Source§

fn matvec(&self, x: &[S], y: &mut [S])

Compute y = A x.
Source§

fn try_matvec(&self, x: &[S], y: &mut [S]) -> Result<(), KError>

Fallible matvec. Default delegates to matvec and returns Ok(()). Implementations that can detect/return errors should override this.
Source§

fn as_any(&self) -> &dyn Any

Downcast hook for specialized solvers/preconditioners.
Source§

fn structure_id(&self) -> StructureId

Changes when the nonzero pattern / shape changes. Default 0 -> unknown; higher layers may fall back to pointer identity.
Source§

fn values_id(&self) -> ValuesId

Changes when only numerical values change. Default 0 -> unknown.
Source§

fn comm(&self) -> UniverseComm

Parallel communicator for this operator. Read more
Source§

fn dist_layout(&self) -> Option<&DistLayout>

Optional distributed layout metadata for MPI-enabled operators.
Source§

fn format(&self) -> OpFormat

Operator storage format, if known.
Source§

fn supports_transpose(&self) -> bool

Whether this operator supports t_matvec.
Source§

fn t_matvec(&self, _x: &[Self::S], _y: &mut [Self::S])

Optional transpose/adjoint matvec. Default panics if unsupported.
Source§

fn halo_exchange(&self) -> Option<&dyn HaloExchange<Self::S>>

Optional halo exchange support for operator-aligned vectors.
Source§

impl LinOpF64 for GenericCsrOp<f64>

Source§

fn dims(&self) -> (usize, usize)

Source§

fn matvec(&self, x: &[f64], y: &mut [f64])

Auto Trait Implementations§

§

impl<S> !Freeze for GenericCsrOp<S>

§

impl<S> RefUnwindSafe for GenericCsrOp<S>
where S: RefUnwindSafe,

§

impl<S> Send for GenericCsrOp<S>

§

impl<S> Sync for GenericCsrOp<S>

§

impl<S> Unpin for GenericCsrOp<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for GenericCsrOp<S>

§

impl<S> UnwindSafe for GenericCsrOp<S>

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<Src, Scheme> ApproxFrom<Src, Scheme> for Src
where Scheme: ApproxScheme,

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>

Convert the given value into an approximately equivalent representation.
Source§

impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src
where Dst: ApproxFrom<Src, Scheme>, Scheme: ApproxScheme,

Source§

type Err = <Dst as ApproxFrom<Src, Scheme>>::Err

The error type produced by a failed conversion.
Source§

fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>

Convert the subject into an approximately equivalent representation.
Source§

impl<T> BlockOp for T
where T: LinOp<S = f64> + ?Sized,

Source§

fn apply(&self, x: &[f64], y: &mut [f64]) -> Result<(), KError>

Apply the operator to a single column.
Source§

fn apply_t(&self, x: &[f64], y: &mut [f64]) -> Result<(), KError>

Apply the transpose of the operator if available.
Source§

fn apply_many(&self, x: &BlockVec, y: &mut BlockVec) -> Result<(), KError>

Apply the operator to multiple columns at once. Default implementation calls apply per column to remain format agnostic.
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<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T, Dst> ConvAsUtil<Dst> for T

Source§

fn approx(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject with the default scheme.
Source§

fn approx_by<Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject with a specific scheme.
Source§

impl<T> ConvUtil for T

Source§

fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst>,

Approximate the subject to a given type with the default scheme.
Source§

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>, Scheme: ApproxScheme,

Approximate the subject to a given type with a specific scheme.
Source§

fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst>,

Convert the subject to a given type.
Source§

fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst>,

Attempt to convert the subject to a given type.
Source§

fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst>,

Attempt a value conversion of the subject to a given type.
Source§

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

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> KLinOp for T
where T: LinOpF64 + LinOp<S = f64> + Send + Sync,

Source§

type Scalar = f64

Source§

fn dims(&self) -> (usize, usize)

Dimensions of the operator (nrows, ncols).
Source§

fn matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)

Perform y <- A x. Read more
Source§

fn supports_t_matvec_s(&self) -> bool

Whether the operator exposes a transpose/adjoint matvec.
Source§

fn t_matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)

Perform y <- A^T x (or A^H x in complex builds). Read more
Source§

impl<L> MatTransVec<Vec<Complex<f64>>> for L
where L: LinOp<S = Complex<f64>> + ?Sized,

Source§

fn mattransvec(&self, x: &Vec<Complex<f64>>, y: &mut Vec<Complex<f64>>)

Compute y = Aᵗ · x (or A^H · x in complex builds).
Source§

impl<L> MatTransVec<Vec<f64>> for L
where L: LinOp<S = f64> + ?Sized,

Source§

fn mattransvec(&self, x: &Vec<f64>, y: &mut Vec<f64>)

Compute y = Aᵗ · x (or A^H · x in complex builds).
Source§

impl<L> MatVec<Vec<Complex<f64>>> for L
where L: LinOp<S = Complex<f64>> + ?Sized,

Source§

fn matvec(&self, x: &Vec<Complex<f64>>, y: &mut Vec<Complex<f64>>)

Compute y = A · x.
Source§

impl<L> MatVec<Vec<f64>> for L
where L: LinOp<S = f64> + ?Sized,

Source§

fn matvec(&self, x: &Vec<f64>, y: &mut Vec<f64>)

Compute y = A · x.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ShellContext for T
where T: Send + Sync + Any,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

unsafe fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<Src> TryFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>

Convert the given value into the subject type.
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<Src, Dst> TryInto<Dst> for Src
where Dst: TryFrom<Src>,

Source§

type Err = <Dst as TryFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>

Convert the subject into the destination type.
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Src> ValueFrom<Src> for Src

Source§

type Err = NoError

The error type produced by a failed conversion.
Source§

fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>

Convert the given value into an exactly equivalent representation.
Source§

impl<Src, Dst> ValueInto<Dst> for Src
where Dst: ValueFrom<Src>,

Source§

type Err = <Dst as ValueFrom<Src>>::Err

The error type produced by a failed conversion.
Source§

fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>

Convert the subject into an exactly equivalent representation.