Loading...
Searching...
No Matches
diagonally_scaled_operator.hpp
Go to the documentation of this file.
1#pragma once
2
4#include "linalg/operator.hpp"
5#include "linalg/vector.hpp"
7
8namespace terra::linalg {
9
10/// @brief Given some operator \f$K\f$ and a vector \f$v\f$, this operator is equivalent to an operator \f$A\f$ defined as
11///
12/// \f[ A = \mathrm{diag}(v) K \f]
13///
14template < OperatorLike OperatorT >
16{
17 public:
18 using OperatorType = OperatorT;
22
23 private:
24 OperatorT& op_;
25 SrcVectorType& diag_;
26
27 public:
28 explicit DiagonallyScaledOperator( OperatorT& op, SrcVectorType& diag )
29 : op_( op )
30 , diag_( diag ) {};
31
32 void apply_impl( const SrcVectorType& src, DstVectorType& dst )
33 {
34 apply( op_, src, dst );
35 scale_in_place( dst, diag_ );
36 }
37};
38
39static_assert(
41
42} // namespace terra::linalg
Given some operator and a vector , this operator is equivalent to an operator defined as.
Definition diagonally_scaled_operator.hpp:16
OperatorT OperatorType
Definition diagonally_scaled_operator.hpp:18
SrcOf< OperatorT > SrcVectorType
Definition diagonally_scaled_operator.hpp:19
DstOf< OperatorT > DstVectorType
Definition diagonally_scaled_operator.hpp:20
void apply_impl(const SrcVectorType &src, DstVectorType &dst)
Definition diagonally_scaled_operator.hpp:32
DiagonallyScaledOperator(OperatorT &op, SrcVectorType &diag)
Definition diagonally_scaled_operator.hpp:28
ScalarOf< DstVectorType > ScalarType
Definition diagonally_scaled_operator.hpp:21
Concept for types that behave like linear operators.
Definition operator.hpp:57
Contains linear algebra utilities and functions for the Terra project.
Definition diagonally_scaled_operator.hpp:8
Operator::SrcVectorType SrcOf
Alias for the source vector type of an operator.
Definition operator.hpp:145
void apply(LinearForm &L, typename LinearForm::DstVectorType &dst)
Apply a linear form and write to a destination vector.
Definition linear_form.hpp:37
Operator::DstVectorType DstOf
Alias for the destination vector type of an operator.
Definition operator.hpp:149
void scale_in_place(Vector &y, const Vector &x)
Scale a vector in place with another vector. For each entry , computes .
Definition vector.hpp:137
typename Vector::ScalarType ScalarOf
Alias for the scalar type of a vector.
Definition vector.hpp:63