ROL
Public Member Functions | Private Attributes | List of all members
ROL::CArrayVector< Real, Element > Class Template Reference

Provides the C array implementation of the ROL::Vector interface for use with NumPy->C Array passing by pointer. This class in intended to be used with the Python ROL interface. More...

#include <ROL_CArrayVector.hpp>

+ Inheritance diagram for ROL::CArrayVector< Real, Element >:

Public Member Functions

 CArrayVector (Element *array, unsigned int dim)
 
 CArrayVector (const Teuchos::ArrayRCP< Element > array)
 
 CArrayVector (unsigned int dim)
 
Teuchos::ArrayRCP< Element > getVector () const
 
Teuchos::ArrayRCP< Element > getVector ()
 
void plus (const Vector< Real > &x)
 Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\). More...
 
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...
 
void scale (const Real alpha)
 Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\). More...
 
int dimension () const
 Return dimension of the vector space. More...
 
Teuchos::RCP< Vector< Real > > clone () const
 Clone to make a new (uninitialized) vector. More...
 
Teuchos::RCP< Vector< Real > > basis (const int i) const
 Return i-th basis vector. More...
 
- Public Member Functions inherited from ROL::Vector< Real >
virtual ~Vector ()
 
virtual void axpy (const Real alpha, const Vector &x)
 Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\). More...
 
virtual void zero ()
 Set to zero vector. More...
 
virtual void set (const Vector &x)
 Set \(y \leftarrow x\) where \(y = \mathtt{*this}\). More...
 
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 void applyUnary (const Elementwise::UnaryFunction< Real > &f)
 
virtual void applyBinary (const Elementwise::BinaryFunction< Real > &f, const Vector &x)
 
virtual Real reduce (const Elementwise::ReductionOp< Real > &r) const
 
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...
 

Private Attributes

unsigned int dim_
 
Teuchos::ArrayRCP< Element > array_
 

Detailed Description

template<class Real, class Element = Real>
class ROL::CArrayVector< Real, Element >

Provides the C array implementation of the ROL::Vector interface for use with NumPy->C Array passing by pointer. This class in intended to be used with the Python ROL interface.

See https://github.com/cython/cython/wiki/tutorials-NumpyPointerToC

Author
Greg von Winckel (gvonw.nosp@m.in@s.nosp@m.andia.nosp@m..gov)

Definition at line 56 of file ROL_CArrayVector.hpp.

Constructor & Destructor Documentation

◆ CArrayVector() [1/3]

template<class Real, class Element = Real>
ROL::CArrayVector< Real, Element >::CArrayVector ( Element *  array,
unsigned int  dim 
)
inline

◆ CArrayVector() [2/3]

template<class Real, class Element = Real>
ROL::CArrayVector< Real, Element >::CArrayVector ( const Teuchos::ArrayRCP< Element >  array)
inline

Definition at line 67 of file ROL_CArrayVector.hpp.

◆ CArrayVector() [3/3]

template<class Real, class Element = Real>
ROL::CArrayVector< Real, Element >::CArrayVector ( unsigned int  dim)
inline

Definition at line 71 of file ROL_CArrayVector.hpp.

Member Function Documentation

◆ getVector() [1/2]

template<class Real, class Element = Real>
Teuchos::ArrayRCP<Element> ROL::CArrayVector< Real, Element >::getVector ( ) const
inline

◆ getVector() [2/2]

template<class Real, class Element = Real>
Teuchos::ArrayRCP<Element> ROL::CArrayVector< Real, Element >::getVector ( )
inline

Definition at line 78 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::array_.

◆ plus()

template<class Real, class Element = Real>
void ROL::CArrayVector< Real, Element >::plus ( const Vector< Real > &  x)
inlinevirtual

Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\).

Parameters
[in]xis the vector to be added to \(\mathtt{*this}\).

On return \(\mathtt{*this} = \mathtt{*this} + x\).


Implements ROL::Vector< Real >.

Definition at line 82 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::array_, ROL::CArrayVector< Real, Element >::dim_, and ROL::CArrayVector< Real, Element >::getVector().

◆ dot()

template<class Real, class Element = Real>
Real ROL::CArrayVector< Real, Element >::dot ( const Vector< Real > &  x) const
inlinevirtual

Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\).

Parameters
[in]xis the vector that forms the dot product with \(\mathtt{*this}\).
Returns
The number equal to \(\langle \mathtt{*this}, x \rangle\).

Implements ROL::Vector< Real >.

Definition at line 92 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::array_, ROL::CArrayVector< Real, Element >::dim_, and ROL::CArrayVector< Real, Element >::getVector().

Referenced by ROL::CArrayVector< Real, Element >::norm().

◆ norm()

template<class Real, class Element = Real>
Real ROL::CArrayVector< Real, Element >::norm ( ) const
inlinevirtual

Returns \( \| y \| \) where \(y = \mathtt{*this}\).

Returns
A nonnegative number equal to the norm of \(\mathtt{*this}\).

Implements ROL::Vector< Real >.

Definition at line 103 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::dot().

◆ scale()

template<class Real, class Element = Real>
void ROL::CArrayVector< Real, Element >::scale ( const Real  alpha)
inlinevirtual

Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\).

Parameters
[in]alphais the scaling of \(\mathtt{*this}\).

On return \(\mathtt{*this} = \alpha (\mathtt{*this}) \).


Implements ROL::Vector< Real >.

Definition at line 109 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::array_, and ROL::CArrayVector< Real, Element >::dim_.

Referenced by main().

◆ dimension()

template<class Real, class Element = Real>
int ROL::CArrayVector< Real, Element >::dimension ( void  ) const
inlinevirtual

Return dimension of the vector space.

   @return The dimension of the vector space, i.e., the total number of basis vectors.

   Overload if the basis is overloaded.

   ---

Reimplemented from ROL::Vector< Real >.

Definition at line 115 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::dim_.

◆ clone()

template<class Real, class Element = Real>
Teuchos::RCP<Vector<Real> > ROL::CArrayVector< Real, Element >::clone ( ) const
inlinevirtual

Clone to make a new (uninitialized) vector.

   @return         A reference-counted pointer to the cloned vector.

   Provides the means of allocating temporary memory in ROL.

   ---             

Implements ROL::Vector< Real >.

Definition at line 119 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::CArrayVector(), and ROL::CArrayVector< Real, Element >::dim_.

Referenced by main().

◆ basis()

template<class Real, class Element = Real>
Teuchos::RCP<Vector<Real> > ROL::CArrayVector< Real, Element >::basis ( const int  i) const
inlinevirtual

Return i-th basis vector.

   @param[in] i is the index of the basis function.
   @return A reference-counted pointer to the basis vector with index @b i.

   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 123 of file ROL_CArrayVector.hpp.

References ROL::CArrayVector< Real, Element >::CArrayVector(), and ROL::CArrayVector< Real, Element >::dim_.

Referenced by main().

Member Data Documentation

◆ dim_

template<class Real, class Element = Real>
unsigned int ROL::CArrayVector< Real, Element >::dim_
private

◆ array_

template<class Real, class Element = Real>
Teuchos::ArrayRCP<Element> ROL::CArrayVector< Real, Element >::array_
private

The documentation for this class was generated from the following file: