ROL
|
Provides the std::array implementation of the ROL::Vector interface. More...
#include <ROL_StdArray.hpp>
Public Types | |
using | data_type = std::array< Real, array_size > |
Public Member Functions | |
StdArray () | |
Real & | operator[] (std::size_t i) |
const Real & | operator[] (std::size_t i) const |
std::array< Real, array_size > & | get_array () |
const std::array< Real, array_size > & | get_array () const |
void | set (const Vector< Real > &x) |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\). More... | |
void | plus (const Vector< Real > &x) |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\). More... | |
void | axpy (const Real alpha, const Vector< Real > &x) |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\). More... | |
void | scale (const Real alpha) |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\). More... | |
virtual Real | dot (const Vector< Real > &x) const |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\). More... | |
Real | norm () const |
Returns \( \| y \| \) where \(y = \mathtt{*this}\). More... | |
virtual Ptr< Vector< Real > > | clone () const |
Clone to make a new (uninitialized) vector. More... | |
Ptr< Vector< Real > > | basis (const int i) const |
Return i-th basis vector. More... | |
int | dimension () const |
Return dimension of the vector space. More... | |
void | zero () |
Set to zero vector. More... | |
void | applyUnary (const Elementwise::UnaryFunction< Real > &f) |
void | applyBinary (const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x) |
Real | reduce (const Elementwise::ReductionOp< Real > &r) const |
void | setScalar (const Real alpha) |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\). More... | |
void | randomize (const Real l=-1.0, const Real u=1.0) |
Set vector to be uniform random between [l,u]. More... | |
virtual void | print (std::ostream &outStream) const |
Public Member Functions inherited from ROL::Vector< Real > | |
virtual | ~Vector () |
virtual const Vector & | dual () const |
Return dual representation of \(\mathtt{*this}\), for example, the result of applying a Riesz map, or change of basis, or change of memory layout. More... | |
virtual std::vector< Real > | checkVector (const Vector< Real > &x, const Vector< Real > &y, const bool printToStream=true, std::ostream &outStream=std::cout) const |
Verify vector-space methods. More... | |
Static Public Member Functions | |
static void | initialize_pool () |
static std::size_t | pool_count () |
Private Member Functions | |
StdArray (Ptr< std::array< Real, array_size >> p) | |
const std::array< Real, array_size > & | _array (const Vector< Real > &x) const |
Private Attributes | |
Ptr< std::array< Real, array_size > > | data |
Static Private Attributes | |
static std::array< std::array < Real, array_size > , pool_size > | pool |
static std::array< Ptr < std::array< Real, array_size > >, pool_size > | pool_ptr |
Provides the std::array implementation of the ROL::Vector interface.
Definition at line 61 of file ROL_StdArray.hpp.
using ROL::StdArray< Real, array_size, pool_size >::data_type = std::array<Real,array_size> |
Definition at line 64 of file ROL_StdArray.hpp.
|
inline |
Definition at line 66 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data, and ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
|
inlineprivate |
Definition at line 177 of file ROL_StdArray.hpp.
|
inline |
Definition at line 79 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inline |
Definition at line 80 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inline |
Definition at line 82 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by ROL::StdArray< Real, array_size, pool_size >::_array().
|
inline |
Definition at line 83 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\).
[in] | x | is a vector. |
On return \(\mathtt{*this} = x\). Uses zero and plus methods for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 85 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\).
[in] | x | is the vector to be added to \(\mathtt{*this}\). |
On return \(\mathtt{*this} = \mathtt{*this} + x\).
Implements ROL::Vector< Real >.
Definition at line 90 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\).
[in] | alpha | is the scaling of x. |
[in] | x | is a vector. |
On return \(\mathtt{*this} = \mathtt{*this} + \alpha x \). Uses clone, set, scale and plus for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 95 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\).
[in] | alpha | is the scaling of \(\mathtt{*this}\). |
On return \(\mathtt{*this} = \alpha (\mathtt{*this}) \).
Implements ROL::Vector< Real >.
Definition at line 100 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by main().
|
inlinevirtual |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\).
[in] | x | is the vector that forms the dot product with \(\mathtt{*this}\). |
Implements ROL::Vector< Real >.
Definition at line 104 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Returns \( \| y \| \) where \(y = \mathtt{*this}\).
Implements ROL::Vector< Real >.
Definition at line 111 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Clone to make a new (uninitialized) vector.
Provides the means of allocating temporary memory in ROL.
Implements ROL::Vector< Real >.
Definition at line 117 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::basis(), and main().
|
inlinevirtual |
Return i-th basis vector.
[in] | i | is the index of the basis function. |
Overloading the basis is only required if the default gradient implementation is used, which computes a finite-difference approximation.
Reimplemented from ROL::Vector< Real >.
Definition at line 121 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::clone(), and ROL::StdArray< Real, array_size, pool_size >::zero().
Referenced by main().
|
inlinevirtual |
Return dimension of the vector space.
Overload if the basis is overloaded.
Reimplemented from ROL::Vector< Real >.
Definition at line 129 of file ROL_StdArray.hpp.
|
inlinevirtual |
Set to zero vector.
Uses scale by zero for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 131 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by ROL::StdArray< Real, array_size, pool_size >::basis().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 133 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 137 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 144 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\).
[in] | C | is a scalar. |
On return \(\mathtt{*this} = C\). Uses applyUnary methods for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 150 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Set vector to be uniform random between [l,u].
[in] | l | is a the lower bound. |
[in] | u | is a the upper bound. |
On return the components of \(\mathtt{*this}\) are uniform random numbers on the interval \([l,u]\). The default implementation uses applyUnary methods for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 152 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by main().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 159 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinestatic |
Definition at line 164 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::pool, and ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
Referenced by main().
|
inlinestatic |
Definition at line 169 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
Referenced by main().
|
inlineprivate |
Definition at line 179 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::get_array().
Referenced by ROL::StdArray< Real, array_size, pool_size >::applyBinary(), ROL::StdArray< Real, array_size, pool_size >::axpy(), ROL::StdArray< Real, array_size, pool_size >::dot(), ROL::StdArray< Real, array_size, pool_size >::plus(), and ROL::StdArray< Real, array_size, pool_size >::set().
|
private |
Definition at line 183 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::applyBinary(), ROL::StdArray< Real, array_size, pool_size >::applyUnary(), ROL::StdArray< Real, array_size, pool_size >::axpy(), ROL::StdArray< Real, array_size, pool_size >::dot(), ROL::StdArray< Real, array_size, pool_size >::get_array(), ROL::StdArray< Real, array_size, pool_size >::norm(), ROL::StdArray< Real, array_size, pool_size >::operator[](), ROL::StdArray< Real, array_size, pool_size >::plus(), ROL::StdArray< Real, array_size, pool_size >::print(), ROL::StdArray< Real, array_size, pool_size >::randomize(), ROL::StdArray< Real, array_size, pool_size >::reduce(), ROL::StdArray< Real, array_size, pool_size >::scale(), ROL::StdArray< Real, array_size, pool_size >::set(), ROL::StdArray< Real, array_size, pool_size >::setScalar(), ROL::StdArray< Real, array_size, pool_size >::StdArray(), and ROL::StdArray< Real, array_size, pool_size >::zero().
|
staticprivate |
Definition at line 186 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::initialize_pool().
|
staticprivate |
Definition at line 187 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::initialize_pool(), ROL::StdArray< Real, array_size, pool_size >::pool_count(), and ROL::StdArray< Real, array_size, pool_size >::StdArray().