pub struct DiagonalOperator<Input, Output> {
pub diagonal: DVector<f64>,
/* private fields */
}Expand description
A diagonal matrix operator.
See MatrixOperator and the crate-level docs for more details.
Fields§
§diagonal: DVector<f64>The diagonal values of the matrix, stored as a vector.
Modifying the dimension of this vector will result in runtime errors.
Values of the diagonal can also be accessed by indexing
with SimplexViews / DualCellViews
corresponding to the output type of the operator:
type P = Cochain<1, Primal>;
type D = Cochain<2, Dual>;
let star: DiagonalOperator<P, D> = mesh_3d.star();
let star_dual: DiagonalOperator<D, P> = mesh_3d.star();
for edge in mesh_3d.simplices::<1>() {
// these stars are inverses of each other so they should multiply to 1
assert!((star_dual[edge] * star[edge.dual()] - 1.).abs() < 1e-6);
}This can be handy to e.g. retrieve values of material parameters
stored in an operator created with
SimplicialMesh::scaling.
Implementations§
Source§impl<Input, Output> DiagonalOperator<Input, Output>
impl<Input, Output> DiagonalOperator<Input, Output>
Sourcepub fn exclude_subset(
self,
set: &SubsetImpl<<<Self as Operator>::Output as Operand>::Dimension, <<Self as Operator>::Output as Operand>::Primality>,
) -> Self
pub fn exclude_subset( self, set: &SubsetImpl<<<Self as Operator>::Output as Operand>::Dimension, <<Self as Operator>::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). useful for boundary conditions.
Sourcepub fn restrict_to_subset(
self,
set: &SubsetImpl<<<Self as Operator>::Output as Operand>::Dimension, <<Self as Operator>::Output as Operand>::Primality>,
) -> Self
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.
Sourcepub fn inverse(&self) -> DiagonalOperator<Output, Input>
pub fn inverse(&self) -> DiagonalOperator<Output, Input>
The matrix inverse of this diagonal operator (i.e. simply the reciprocals of the elements).
At the type level, this swaps the input and output types.
If you need the types to remain the same,
use recip instead.
Note also that this is not always the same as the dual Hodge star,
since it can differ from the matrix inverse by a sign.
Sourcepub fn recip(&self) -> Self
pub fn recip(&self) -> Self
The matrix inverse of this operator,
but unlike inverse,
keeping the input and output types unchanged.
This and inverse are both simply more convenient ways
to write DiagonalOperator::from(my_op.diagonal.map(|el| 1. / el)),
which is still a useful pattern
if you need more esoteric manipulations than simple scalings or inverses.
Sourcepub fn inner_product(&self, lhs: &Input, rhs: &Input) -> f64
pub fn inner_product(&self, lhs: &Input, rhs: &Input) -> f64
Compute the inner product between two cochains defined by this operator,
i.e. the matrix product a^T D b, where D is this operator
and a,b are cochains of its input type.
Note: this does not check that the operator is positive definite, so the operation may not actually be an inner product.
Sourcepub fn norm(&self, c: &Input) -> f64
pub fn norm(&self, c: &Input) -> f64
Compute the norm of a cochain defined by this operator,
i.e. its inner_product with itself.
The same caveat applies as to inner_product:
this does not check that the operator is positive definite,
so the operation may not actually be a norm.
Trait Implementations§
Source§impl<Input: Clone, Output: Clone> Clone for DiagonalOperator<Input, Output>
impl<Input: Clone, Output: Clone> Clone for DiagonalOperator<Input, Output>
Source§fn clone(&self) -> DiagonalOperator<Input, Output>
fn clone(&self) -> DiagonalOperator<Input, Output>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<Input, Output> From<DiagonalOperator<Input, Output>> for MatrixOperator<Input, Output>where
DiagonalOperator<Input, Output>: Operator,
impl<Input, Output> From<DiagonalOperator<Input, Output>> for MatrixOperator<Input, Output>where
DiagonalOperator<Input, Output>: Operator,
Source§fn from(s: DiagonalOperator<Input, Output>) -> Self
fn from(s: DiagonalOperator<Input, Output>) -> Self
Source§impl<Input, Output> From<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>> for DiagonalOperator<Input, Output>
impl<Input, Output> From<Matrix<f64, Dyn, Const<1>, VecStorage<f64, Dyn, Const<1>>>> for DiagonalOperator<Input, Output>
Source§impl<'a, In, OutDim, const MESH_DIM: usize> Index<DualCellView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Dual>>
impl<'a, In, OutDim, const MESH_DIM: usize> Index<DualCellView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Dual>>
Source§impl<'a, In, OutDim, const MESH_DIM: usize> Index<SimplexView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Primal>>
impl<'a, In, OutDim, const MESH_DIM: usize> Index<SimplexView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Primal>>
Source§impl<'a, In, OutDim, const MESH_DIM: usize> IndexMut<DualCellView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Dual>>
impl<'a, In, OutDim, const MESH_DIM: usize> IndexMut<DualCellView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Dual>>
Source§impl<'a, In, OutDim, const MESH_DIM: usize> IndexMut<SimplexView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Primal>>
impl<'a, In, OutDim, const MESH_DIM: usize> IndexMut<SimplexView<'a, OutDim, MESH_DIM>> for DiagonalOperator<In, CochainImpl<OutDim, Primal>>
Source§impl<Out, D, P> Mul<&CochainImpl<D, P>> for &DiagonalOperator<CochainImpl<D, P>, Out>where
Out: Operand,
impl<Out, D, P> Mul<&CochainImpl<D, P>> for &DiagonalOperator<CochainImpl<D, P>, Out>where
Out: Operand,
Source§impl<Out, D, P> Mul<&CochainImpl<D, P>> for DiagonalOperator<CochainImpl<D, P>, Out>where
Out: Operand,
impl<Out, D, P> Mul<&CochainImpl<D, P>> for DiagonalOperator<CochainImpl<D, P>, Out>where
Out: Operand,
Source§impl<Input, Output> Mul<DiagonalOperator<Input, Output>> for f64
impl<Input, Output> Mul<DiagonalOperator<Input, Output>> for f64
Source§type Output = DiagonalOperator<Input, Output>
type Output = DiagonalOperator<Input, Output>
* operator.Source§impl<In, Out, OtherIn> Mul<DiagonalOperator<OtherIn, In>> for DiagonalOperator<In, Out>
impl<In, Out, OtherIn> Mul<DiagonalOperator<OtherIn, In>> for DiagonalOperator<In, Out>
Source§type Output = DiagonalOperator<OtherIn, Out>
type Output = DiagonalOperator<OtherIn, Out>
* operator.Source§impl<In, Out, OtherIn> Mul<MatrixOperator<OtherIn, In>> for DiagonalOperator<In, Out>
impl<In, Out, OtherIn> Mul<MatrixOperator<OtherIn, In>> for DiagonalOperator<In, Out>
Source§type Output = MatrixOperator<OtherIn, Out>
type Output = MatrixOperator<OtherIn, Out>
* operator.Source§impl<Input, Output> Neg for DiagonalOperator<Input, Output>
impl<Input, Output> Neg for DiagonalOperator<Input, Output>
Source§impl<Input, Output> Operator for DiagonalOperator<Input, Output>
impl<Input, Output> Operator for DiagonalOperator<Input, Output>
Source§impl<Input, Output> PartialEq for DiagonalOperator<Input, Output>
impl<Input, Output> PartialEq for DiagonalOperator<Input, Output>
Auto Trait Implementations§
impl<Input, Output> Freeze for DiagonalOperator<Input, Output>
impl<Input, Output> RefUnwindSafe for DiagonalOperator<Input, Output>where
Input: RefUnwindSafe,
Output: RefUnwindSafe,
impl<Input, Output> Send for DiagonalOperator<Input, Output>
impl<Input, Output> Sync for DiagonalOperator<Input, Output>
impl<Input, Output> Unpin for DiagonalOperator<Input, Output>
impl<Input, Output> UnsafeUnpin for DiagonalOperator<Input, Output>
impl<Input, Output> UnwindSafe for DiagonalOperator<Input, Output>where
Input: UnwindSafe,
Output: UnwindSafe,
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.