pub struct GenericCsrOp<S: KrystScalar> { /* private fields */ }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>
impl<S: KrystScalar> GenericCsrOp<S>
Sourcepub fn new(matrix: Arc<ScalarCsrMatrix<S>>, tuning: &SpmvTuning) -> Self
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.
Sourcepub fn from_matrix(matrix: ScalarCsrMatrix<S>, tuning: &SpmvTuning) -> Self
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.
Sourcepub fn from_real_csr(real: &CsrMatrix<f64>, tuning: &SpmvTuning) -> Selfwhere
S: KrystScalar<Real = f64>,
pub fn from_real_csr(real: &CsrMatrix<f64>, tuning: &SpmvTuning) -> Selfwhere
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.
Sourcepub fn matrix(&self) -> &ScalarCsrMatrix<S>
pub fn matrix(&self) -> &ScalarCsrMatrix<S>
Returns the underlying CSR matrix.
Sourcepub fn plan(&self) -> &ScalarSpmvPlan<S>
pub fn plan(&self) -> &ScalarSpmvPlan<S>
Returns a reference to the cached SpMV plan.
Sourcepub fn rebuild_plan(&mut self, tuning: &SpmvTuning)
pub fn rebuild_plan(&mut self, tuning: &SpmvTuning)
Rebuilds the internal SpMV plan using the latest tuning parameters.
Sourcepub fn with_comm(self, comm: UniverseComm) -> Self
pub fn with_comm(self, comm: UniverseComm) -> Self
Attaches a communicator to the operator, mirroring the legacy API.
Sourcepub fn with_layout(self, layout: DistLayout) -> Self
pub fn with_layout(self, layout: DistLayout) -> Self
Attach a distributed layout to this operator.
Sourcepub fn mark_structure_changed(&self)
pub fn mark_structure_changed(&self)
Marks the sparsity pattern as changed for cache bookkeeping.
Sourcepub fn mark_values_changed(&self)
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.
impl KLinOp for GenericCsrOp<Complex64>
complex only.type Scalar = Complex<f64>
Source§fn matvec_s(
&self,
x: &[Complex64],
y: &mut [Complex64],
_scratch: &mut BridgeScratch,
)
fn matvec_s( &self, x: &[Complex64], y: &mut [Complex64], _scratch: &mut BridgeScratch, )
y <- A x. Read moreSource§fn supports_t_matvec_s(&self) -> bool
fn supports_t_matvec_s(&self) -> bool
Source§fn t_matvec_s(
&self,
x: &[Complex64],
y: &mut [Complex64],
_scratch: &mut BridgeScratch,
)
fn t_matvec_s( &self, x: &[Complex64], y: &mut [Complex64], _scratch: &mut BridgeScratch, )
Source§impl<S: KrystScalar> LinOp for GenericCsrOp<S>
impl<S: KrystScalar> LinOp for GenericCsrOp<S>
type S = S
Source§fn try_matvec(&self, x: &[S], y: &mut [S]) -> Result<(), KError>
fn try_matvec(&self, x: &[S], y: &mut [S]) -> Result<(), KError>
matvec and returns Ok(()).
Implementations that can detect/return errors should override this.Source§fn structure_id(&self) -> StructureId
fn structure_id(&self) -> StructureId
Source§fn values_id(&self) -> ValuesId
fn values_id(&self) -> ValuesId
Source§fn comm(&self) -> UniverseComm
fn comm(&self) -> UniverseComm
Source§fn dist_layout(&self) -> Option<&DistLayout>
fn dist_layout(&self) -> Option<&DistLayout>
Source§fn supports_transpose(&self) -> bool
fn supports_transpose(&self) -> bool
t_matvec.Source§fn t_matvec(&self, _x: &[Self::S], _y: &mut [Self::S])
fn t_matvec(&self, _x: &[Self::S], _y: &mut [Self::S])
Source§fn halo_exchange(&self) -> Option<&dyn HaloExchange<Self::S>>
fn halo_exchange(&self) -> Option<&dyn HaloExchange<Self::S>>
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>where
S: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> BlockOp for T
impl<T> BlockOp for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> KLinOp for T
impl<T> KLinOp for T
type Scalar = f64
Source§fn matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)
fn matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)
y <- A x. Read moreSource§fn supports_t_matvec_s(&self) -> bool
fn supports_t_matvec_s(&self) -> bool
Source§fn t_matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)
fn t_matvec_s(&self, x: &[f64], y: &mut [f64], _scratch: &mut BridgeScratch)
Source§impl<L> MatTransVec<Vec<f64>> for L
impl<L> MatTransVec<Vec<f64>> for L
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> ShellContext for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.