Skip to main content

MatrixOperator

Struct MatrixOperator 

Source
pub struct MatrixOperator<Input, Output> {
    pub mat: CsrMatrix<f64>,
    /* private fields */
}
Expand description

A general sparse matrix operator, parameterized with the cochain types it consumes and produces.

This can be a composition of one or more MatrixOperators and DiagonalOperators. Composition can be done using multiplication syntax:

let op: MatrixOperator<_, _> = mesh.star() * mesh.d::<1, Primal>();

A free function compose is also provided for the same purpose.

There is also a DiagonalOperator type for operators which are specifically diagonal matrices, which stores them in a somewhat more efficient format. When you don’t need the efficiency and prefer notational convenience, these can also be converted into a MatrixOperator using the std From trait. This enables writing all your operator types as MatrixOperator<Input, Output>, a convenient pattern which can be written more concisely with the type alias Op. See the crate-level docs and examples for details.

Fields§

§mat: CsrMatrix<f64>

The underlying matrix, exposed for potential use cases that need to modify or read matrix values directly.

Modifying the dimensions of this matrix will result in runtime errors.

Implementations§

Source§

impl<Input, Output> MatrixOperator<Input, Output>
where Input: Operand, Output: Operand,

Source

pub fn exclude_subset( self, set: &SubsetImpl<<Output as Operand>::Dimension, <Output as Operand>::Primality>, ) -> Self

Set a subset of elements in the output cochain to zero when this operator is applied (i.e. set a subset of rows in the operator matrix to zero).

Source

pub fn restrict_to_subset( self, set: &SubsetImpl<<<Self as Operator>::Output as Operand>::Dimension, <<Self as Operator>::Output as Operand>::Primality>, ) -> Self

Set all output elements that aren’t part of the given subset to zero.

Trait Implementations§

Source§

impl<Input: Clone, Output: Clone> Clone for MatrixOperator<Input, Output>

Source§

fn clone(&self) -> MatrixOperator<Input, Output>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Input: Debug, Output: Debug> Debug for MatrixOperator<Input, Output>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<Input, Output> From<CsrMatrix<f64>> for MatrixOperator<Input, Output>

Source§

fn from(mat: CsrMatrix<f64>) -> Self

Converts to this type from the input type.
Source§

impl<Input, Output> From<DiagonalOperator<Input, Output>> for MatrixOperator<Input, Output>
where DiagonalOperator<Input, Output>: Operator,

Source§

fn from(s: DiagonalOperator<Input, Output>) -> Self

Converts to this type from the input type.
Source§

impl<O, D, P> Mul<&CochainImpl<D, P>> for &MatrixOperator<CochainImpl<D, P>, O>
where O: Operand,

Source§

type Output = O

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &CochainImpl<D, P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<O, D, P> Mul<&CochainImpl<D, P>> for MatrixOperator<CochainImpl<D, P>, O>
where O: Operand,

Source§

type Output = <MatrixOperator<CochainImpl<D, P>, O> as Operator>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &CochainImpl<D, P>) -> Self::Output

Performs the * operation. Read more
Source§

impl<L, R> Mul<MatrixOperator<L, R>> for f64

Source§

type Output = MatrixOperator<L, R>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: MatrixOperator<L, R>) -> Self::Output

Performs the * operation. Read more
Source§

impl<In, Out, OtherIn> Mul<MatrixOperator<OtherIn, In>> for DiagonalOperator<In, Out>
where In: Operand, Out: Operand, OtherIn: Operand,

Source§

type Output = MatrixOperator<OtherIn, Out>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: MatrixOperator<OtherIn, In>) -> Self::Output

Performs the * operation. Read more
Source§

impl<In, Out, Op> Mul<Op> for MatrixOperator<In, Out>
where In: Operand, Out: Operand, Op: Operator<Output = <Self as Operator>::Input>,

Source§

type Output = MatrixOperator<<Op as Operator>::Input, <MatrixOperator<In, Out> as Operator>::Output>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Op) -> Self::Output

Performs the * operation. Read more
Source§

impl<Input, Output> Neg for MatrixOperator<Input, Output>

Source§

type Output = MatrixOperator<Input, Output>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<Input, Output> Operator for MatrixOperator<Input, Output>
where Input: Operand, Output: Operand,

Source§

type Input = Input

The type of cochain this operator takes as an input.
Source§

type Output = Output

The type of cochain this operator produces as an output.
Source§

fn apply(&self, input: &Self::Input) -> Self::Output

Apply this operator to an input cochain.
Source§

fn into_csr(self) -> CsrMatrix<f64>

Convert this operator into a CSR matrix.
Source§

impl<L, R> PartialEq for MatrixOperator<L, R>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<Input, Output> Freeze for MatrixOperator<Input, Output>

§

impl<Input, Output> RefUnwindSafe for MatrixOperator<Input, Output>
where Input: RefUnwindSafe, Output: RefUnwindSafe,

§

impl<Input, Output> Send for MatrixOperator<Input, Output>
where Input: Send, Output: Send,

§

impl<Input, Output> Sync for MatrixOperator<Input, Output>
where Input: Sync, Output: Sync,

§

impl<Input, Output> Unpin for MatrixOperator<Input, Output>
where Input: Unpin, Output: Unpin,

§

impl<Input, Output> UnsafeUnpin for MatrixOperator<Input, Output>

§

impl<Input, Output> UnwindSafe for MatrixOperator<Input, Output>
where Input: UnwindSafe, Output: UnwindSafe,

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Output = T

Should always be Self
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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,