Loading...
Searching...
No Matches
linear_form.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <concepts>
4
5#include "vector.hpp"
6
7namespace terra::linalg {
8
9/// @brief Concept for types that behave like linear forms.
10///
11/// Evaluates a linear form into a vector.
12///
13/// This could be something like
14///
15/// \f[ L(v_h) = \int f v_h \f]
16///
17/// evaluated into the entries \f$q_k\f$ of a coefficient vector \f$q\f$:
18///
19/// \f[ q_k = \int f \phi_k \f].
20///
21template < typename T >
22concept LinearFormLike = requires( T& self, typename T::DstVectorType& dst ) {
23 // Requires exposing the vector types.
24 typename T::DstVectorType;
25
26 // Require that dst vector type satisfies VectorLike
28
29 // Required evaluation implementation
30 { self.apply_impl( dst ) } -> std::same_as< void >;
31};
32
33/// @brief Apply a linear form and write to a destination vector.
34/// @param L Linear form to apply.
35/// @param dst Destination vector.
36template < LinearFormLike LinearForm >
37void apply( LinearForm& L, typename LinearForm::DstVectorType& dst )
38{
39 L.apply_impl( dst );
40}
41
42} // namespace terra::linalg
Concept for types that behave like linear forms.
Definition linear_form.hpp:22
Concept for types that behave like vectors. Requires exposing ScalarType and implementations for line...
Definition vector.hpp:8
Contains linear algebra utilities and functions for the Terra project.
Definition diagonally_scaled_operator.hpp:8
void apply(LinearForm &L, typename LinearForm::DstVectorType &dst)
Apply a linear form and write to a destination vector.
Definition linear_form.hpp:37