#include <packaged_operation_for_mg.h>
Public Member Functions | |
PackagedOperationMG () | |
PackagedOperationMG (const PackagedOperationMG< Range > &)=default | |
PackagedOperationMG (const Range &u) | |
PackagedOperationMG< Range > & | operator= (const PackagedOperationMG< Range > &)=default |
PackagedOperationMG< Range > & | operator= (const Range &u) |
operator Range () const | |
Related Symbols | |
(Note that these are not member symbols.) | |
Vector space operations | |
template<typename Range > | |
PackagedOperationMG< Range > | operator+ (const PackagedOperationMG< Range > &first_comp, const PackagedOperationMG< Range > &second_comp) |
template<typename Range > | |
PackagedOperationMG< Range > | operator- (const PackagedOperationMG< Range > &first_comp, const PackagedOperationMG< Range > &second_comp) |
template<typename Range > | |
PackagedOperationMG< Range > | operator* (const PackagedOperationMG< Range > &comp, typename Range::value_type number) |
template<typename Range > | |
PackagedOperationMG< Range > | operator* (typename Range::value_type number, const PackagedOperationMG< Range > &comp) |
template<typename Range > | |
PackagedOperationMG< Range > | operator+ (const PackagedOperationMG< Range > &comp, const Range &offset) |
template<typename Range > | |
PackagedOperationMG< Range > | operator+ (const Range &offset, const PackagedOperationMG< Range > &comp) |
template<typename Range > | |
PackagedOperationMG< Range > | operator- (const PackagedOperationMG< Range > &comp, const Range &offset) |
template<typename Range > | |
PackagedOperationMG< Range > | operator- (const Range &offset, const PackagedOperationMG< Range > &comp) |
Creation of a PackagedOperationMG object | |
template<typename Range , typename = typename std::enable_if< internal::PackagedOperationImplementation::has_vector_interface< Range>::type::value>::type> | |
PackagedOperationMG< Range > | operator+ (const Range &u, const Range &v) |
template<typename Range , typename = typename std::enable_if< internal::PackagedOperationImplementation::has_vector_interface< Range>::type::value>::type> | |
PackagedOperationMG< Range > | operator- (const Range &u, const Range &v) |
template<typename Range , typename = typename std::enable_if< internal::PackagedOperationImplementation::has_vector_interface< Range>::type::value>::type> | |
PackagedOperationMG< Range > | operator* (const Range &u, typename Range::value_type number) |
template<typename Range , typename = typename std::enable_if< internal::PackagedOperationImplementation::has_vector_interface< Range>::type::value>::type> | |
PackagedOperationMG< Range > | operator* (typename Range::value_type number, const Range &u) |
template<typename Range , typename Domain , typename Payload > | |
PackagedOperationMG< Range > | operator* (const LinearOperatorMG< Range, Domain, Payload > &op, const Domain &u) |
template<typename Range , typename Domain , typename Payload > | |
PackagedOperationMG< Domain > | operator* (const Range &u, const LinearOperatorMG< Range, Domain, Payload > &op) |
template<typename Range , typename Domain , typename Payload > | |
PackagedOperationMG< Range > | operator* (const LinearOperatorMG< Range, Domain, Payload > &op, const PackagedOperationMG< Domain > &comp) |
template<typename Range , typename Domain , typename Payload > | |
PackagedOperationMG< Domain > | operator* (const PackagedOperationMG< Range > &comp, const LinearOperatorMG< Range, Domain, Payload > &op) |
In-place vector space operations | |
std::function< void(Range &v)> | apply |
std::function< void(Range &v)> | apply_add |
std::function< void(Range &v, bool omit_zeroing_entries)> | reinit_vector |
PackagedOperationMG< Range > & | operator+= (const PackagedOperationMG< Range > &second_comp) |
PackagedOperationMG< Range > & | operator-= (const PackagedOperationMG< Range > &second_comp) |
PackagedOperationMG< Range > & | operator+= (const Range &offset) |
PackagedOperationMG< Range > & | operator-= (const Range &offset) |
PackagedOperationMG< Range > & | operator*= (typename Range::value_type number) |
A class to store a computation.
The PackagedOperationMG class allows lazy evaluation of expressions involving vectors and linear operators. This is done by storing the computational expression and only performing the computation when either the object is implicitly converted to a vector object, or apply
(or apply_add
) is invoked by hand. This avoids unnecessary temporary storage of intermediate results.
The class essentially consists of std::function
objects that store the knowledge of how to generate the result of a computation and store it in a vector:
Similar to the LinearOperatorMG class it also has knowledge about how to initialize a vector of the Range
space:
As an example consider the addition of multiple vectors
or the computation of a residual $b-Ax$:
The expression residual
is of type PackagedOperationMG<Vector<double>>
. It stores references to A
, b
and x
and defers the actual computation until apply
, or apply_add
are explicitly invoked,
or until the PackagedOperationMG
object is implicitly converted:
Definition at line 105 of file packaged_operation_for_mg.h.
|
inline |
Create an empty PackagedOperationMG object. All std::function
member objects are initialized with default variants that throw an exception upon invocation.
Definition at line 113 of file packaged_operation_for_mg.h.
References PackagedOperationMG< Range >::apply, PackagedOperationMG< Range >::apply_add, Assert, and PackagedOperationMG< Range >::reinit_vector.
Referenced by PackagedOperationMG< Range >::operator+=(), and PackagedOperationMG< Range >::operator-=().
|
default |
Default copy constructor.
|
inline |
Constructor that creates a PackagedOperationMG object from a reference vector u
. The PackagedOperationMG returns u
.
The PackagedOperationMG object that is created stores a reference to u
. Thus, the vector must remain a valid reference for the whole lifetime of the PackagedOperationMG object. All changes made on u
after the creation of the PackagedOperationMG object are reflected by the operator object.
Definition at line 149 of file packaged_operation_for_mg.h.
|
inline |
Convert a PackagedOperationMG to its result.
This conversion operator creates a vector of the Range space and calls apply()
on it.
Definition at line 189 of file packaged_operation_for_mg.h.
References PackagedOperationMG< Range >::apply, and PackagedOperationMG< Range >::reinit_vector.
|
inline |
Scalar multiplication of the PackagedOperationMG with a number
.
Definition at line 251 of file packaged_operation_for_mg.h.
|
inline |
Addition with a PackagedOperationMG second_comp
with the same Range
.
Definition at line 208 of file packaged_operation_for_mg.h.
|
inline |
Add a constant offset
(of the Range
space) to the result of a PackagedOperationMG.
Definition at line 230 of file packaged_operation_for_mg.h.
References PackagedOperationMG< Range >::PackagedOperationMG().
|
inline |
Subtraction with a PackagedOperationMG second_comp
with the same Range
.
Definition at line 219 of file packaged_operation_for_mg.h.
|
inline |
Subtract a constant offset
(of the Range
space) from the result of a PackagedOperationMG.
Definition at line 241 of file packaged_operation_for_mg.h.
References PackagedOperationMG< Range >::PackagedOperationMG().
|
default |
Default copy assignment operator.
|
inline |
Copy assignment operator that creates a PackagedOperationMG object from a reference vector u
. The PackagedOperationMG returns u
.
The PackagedOperationMG object that is created stores a reference to u
. Thus, the vector must remain a valid reference for the whole lifetime of the PackagedOperationMG object. All changes made on u
after the creation of the PackagedOperationMG object are reflected by the operator object.
Definition at line 170 of file packaged_operation_for_mg.h.
References PackagedOperationMG< Range >::apply, PackagedOperationMG< Range >::apply_add, and PackagedOperationMG< Range >::reinit_vector.
std::function<void(Range &v)> PackagedOperationMG< Range >::apply |
Store the result of the PackagedOperationMG in a vector v of the Range
space.
Definition at line 262 of file packaged_operation_for_mg.h.
Referenced by PackagedOperationMG< Range >::operator Range(), PackagedOperationMG< Range >::operator=(), and PackagedOperationMG< Range >::PackagedOperationMG().
std::function<void(Range &v)> PackagedOperationMG< Range >::apply_add |
Add the result of the PackagedOperationMG to a vector v of the Range
space.
Definition at line 268 of file packaged_operation_for_mg.h.
Referenced by PackagedOperationMG< Range >::operator=(), and PackagedOperationMG< Range >::PackagedOperationMG().
std::function<void(Range &v, bool omit_zeroing_entries)> PackagedOperationMG< Range >::reinit_vector |
Initializes a vector v of the Range space to be directly usable as the destination parameter in an application of apply, or apply_add. Similar to the reinit functions of the vector classes, the boolean determines whether a fast initialization is done, i.e., if it is set to false the content of the vector is set to 0.
Definition at line 277 of file packaged_operation_for_mg.h.
Referenced by PackagedOperationMG< Range >::operator Range(), PackagedOperationMG< Range >::operator=(), and PackagedOperationMG< Range >::PackagedOperationMG().