deal.II version GIT relicensing-2291-g668cd86249 2024-12-24 11:30:00+00:00
|
#include <deal.II/optimization/rol/vector_adaptor.h>
Public Member Functions | |
VectorAdaptor (const Teuchos::RCP< VectorType > &vector_ptr) | |
Teuchos::RCP< VectorType > | getVector () |
Teuchos::RCP< const VectorType > | getVector () const |
int | dimension () const |
void | set (const ROL::Vector< value_type > &rol_vector) |
void | plus (const ROL::Vector< value_type > &rol_vector) |
void | axpy (const value_type alpha, const ROL::Vector< value_type > &rol_vector) |
void | scale (const value_type alpha) |
value_type | dot (const ROL::Vector< value_type > &rol_vector) const |
value_type | norm () const |
Teuchos::RCP< ROL::Vector< value_type > > | clone () const |
Teuchos::RCP< ROL::Vector< value_type > > | basis (const int i) const |
void | applyUnary (const ROL::Elementwise::UnaryFunction< value_type > &f) |
void | applyBinary (const ROL::Elementwise::BinaryFunction< value_type > &f, const ROL::Vector< value_type > &rol_vector) |
value_type | reduce (const ROL::Elementwise::ReductionOp< value_type > &r) const |
void | print (std::ostream &outStream) const |
Private Types | |
using | size_type = typename VectorType::size_type |
using | value_type = typename VectorType::value_type |
using | real_type = typename VectorType::real_type |
Private Attributes | |
Teuchos::RCP< VectorType > | vector_ptr |
An adaptor that provides the implementation of the ROL::Vector interface for vectors of type VectorType
.
This class supports vectors that satisfy the following requirements:
The VectorType
should contain the following types.
However, ROL doesn't distinguish VectorAdaptor::value_type from VectorAdaptor::real_type. This is due to ROL's assumption that the VectorAdaptor::value_type itself is a type for real-valued numbers. Therefore, VectorAdaptor supports vectors whose real_type is convertible to value_type in the sense that std::is_convertible_v<real_type, value_type>
yields true
.
The VectorType
should contain the following methods.
Definition at line 110 of file vector_adaptor.h.
|
private |
An alias for size type of VectorType
.
Definition at line 115 of file vector_adaptor.h.
|
private |
An alias for element type stored in the VectorType
.
Definition at line 120 of file vector_adaptor.h.
|
private |
An alias for real-valued numbers.
Definition at line 125 of file vector_adaptor.h.
Rol::VectorAdaptor< VectorType >::VectorAdaptor | ( | const Teuchos::RCP< VectorType > & | vector_ptr | ) |
Constructor.
Teuchos::RCP< VectorType > Rol::VectorAdaptor< VectorType >::getVector | ( | ) |
Return the Teuchos smart reference counting pointer to the wrapper vector, vector_ptr.
Teuchos::RCP< const VectorType > Rol::VectorAdaptor< VectorType >::getVector | ( | ) | const |
Return the Teuchos smart reference counting pointer to const vector.
int Rol::VectorAdaptor< VectorType >::dimension | ( | ) | const |
Return the dimension (global vector size) of the wrapped vector.
void Rol::VectorAdaptor< VectorType >::set | ( | const ROL::Vector< value_type > & | rol_vector | ) |
Set the wrapper vector to a given ROL::Vector rol_vector
by overwriting its contents.
If the current wrapper vector has ghost elements, then VectorType::operator=(const VectorType&)
should still be allowed on it.
void Rol::VectorAdaptor< VectorType >::plus | ( | const ROL::Vector< value_type > & | rol_vector | ) |
Perform addition.
void Rol::VectorAdaptor< VectorType >::axpy | ( | const value_type | alpha, |
const ROL::Vector< value_type > & | rol_vector | ||
) |
Scale the wrapper vector by alpha
and add ROL::Vector rol_vector
to it.
void Rol::VectorAdaptor< VectorType >::scale | ( | const value_type | alpha | ) |
Scale the wrapper vector.
value_type Rol::VectorAdaptor< VectorType >::dot | ( | const ROL::Vector< value_type > & | rol_vector | ) | const |
Return the dot product with a given ROL::Vector rol_vector
.
value_type Rol::VectorAdaptor< VectorType >::norm | ( | ) | const |
Return the \(L^{2}\) norm of the wrapped vector.
The returned type is of VectorAdaptor::value_type so as to maintain consistency with ROL::Vector<VectorAdaptor::value_type> and more importantly to not to create an overloaded version namely, VectorAdaptor::real_type norm() const;
if real_type and value_type are not of the same type.
Teuchos::RCP< ROL::Vector< value_type > > Rol::VectorAdaptor< VectorType >::clone | ( | ) | const |
Return a clone of the wrapped vector.
Teuchos::RCP< ROL::Vector< value_type > > Rol::VectorAdaptor< VectorType >::basis | ( | const int | i | ) | const |
Create and return a Teuchos smart reference counting pointer to the basis vector corresponding to the i
\({}^{th}\) element of the wrapper vector.
void Rol::VectorAdaptor< VectorType >::applyUnary | ( | const ROL::Elementwise::UnaryFunction< value_type > & | f | ) |
Apply unary function f
to all the elements of the wrapped vector.
void Rol::VectorAdaptor< VectorType >::applyBinary | ( | const ROL::Elementwise::BinaryFunction< value_type > & | f, |
const ROL::Vector< value_type > & | rol_vector | ||
) |
Apply binary function f
along with ROL::Vector rol_vector
to all the elements of the wrapped vector.
value_type Rol::VectorAdaptor< VectorType >::reduce | ( | const ROL::Elementwise::ReductionOp< value_type > & | r | ) | const |
Return the accumulated value on applying reduction operation r
on all the elements of the wrapped vector.
void Rol::VectorAdaptor< VectorType >::print | ( | std::ostream & | outStream | ) | const |
Print the wrapped vector to the output stream outStream
.
|
private |
Teuchos smart reference counting pointer to the underlying vector of type VectorType
.
Definition at line 136 of file vector_adaptor.h.