10 #ifndef ROL_VECTORPROFILER_H
11 #define ROL_VECTORPROFILER_H
35 template<
class Ordinal>
65 template<
class Ordinal,
class Real>
68 template<
class Ordinal,
class Real>
73 template<
class Ordinal,
class Real>
75 outStream <<
"Total Vector Function Calls" << std::endl;
76 outStream <<
"---------------------------" << std::endl;
77 outStream <<
"Constructor : " << x.
functionCalls_.constructor_ << std::endl;
78 outStream <<
"Destructor : " << x.
functionCalls_.destructor_ << std::endl;
90 outStream <<
"dimension : " << x.
functionCalls_.dimension_ << std::endl;
91 outStream <<
"applyUnary : " << x.
functionCalls_.applyUnary_ << std::endl;
92 outStream <<
"applyBinary : " << x.
functionCalls_.applyBinary_ << std::endl;
94 outStream <<
"setScalar : " << x.
functionCalls_.setScalar_ << std::endl;
95 outStream <<
"randomize : " << x.
functionCalls_.randomize_ << std::endl;
100 template<
class Ordinal,
class Real>
101 class ProfiledVector :
public Vector<Real> {
106 ROL::Ptr<Vector<Real> >
v_;
112 ROL::Ptr<ProfiledVector> pv = ROL::nullPtr;
113 pv = ROL::dynamicPtrCast<ProfiledVector>(v);
114 ROL_TEST_FOR_EXCEPTION( pv != ROL::nullPtr, std::logic_error,
"ProfiledVector class "
115 "cannot encapsulate a ProfiledVector object!");
149 ROL::Ptr<Vector<Real> >
clone()
const {
151 return ROL::makePtr<ProfiledVector>(
v_->clone() );
157 return v_->axpy(alpha,*xp);
165 ROL::Ptr<Vector<Real> >
basis(
const int i )
const {
167 return ROL::makePtr<ProfiledVector>(
v_->basis(i) );
172 return v_->dimension();
200 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
207 v_->applyBinary(f,x);
210 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
212 return v_->reduce(r);
225 void print( std::ostream &outStream )
const {
226 v_->print(outStream);
237 #endif // ROL_RANDOMVECTOR_H
void print(std::ostream &outStream) const
Real reduce(const Elementwise::ReductionOp< Real > &r) const
ROL::VectorFunctionCalls< int > functionCalls_
Real norm() const
Returns where .
ROL::Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Real apply(const Vector< Real > &x) const
Apply to a dual vector. This is equivalent to the call .
Defines the linear algebra or vector space interface.
void scale(const Real alpha)
Compute where .
ROL::Ptr< Vector< Real > > getVector()
int dimension() const
Return dimension of the vector space.
ProfiledVector(const ROL::Ptr< Vector< Real > > &v)
static VectorFunctionCalls< Ordinal > functionCalls_
ROL::Ptr< Vector< Real > > basis(const int i) const
Return i-th basis vector.
void zero()
Set to zero vector.
void randomize(const Real l=0.0, const Real u=1.0)
Set vector to be uniform random between [l,u].
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
ROL::Ptr< Vector< Real > > v_
void printVectorFunctionCalls(const ProfiledVector< Ordinal, Real > &x, std::ostream &outStream=std::cout)
virtual ~ProfiledVector()
By keeping a pointer to this in a derived Vector class, a tally of all methods is kept for profiling ...
void set(const Vector< Real > &x)
Set where .
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
void plus(const Vector< Real > &x)
Compute , where .
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
const Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
VectorFunctionCalls< Ordinal > getVectorFunctionCalls(const ProfiledVector< Ordinal, Real > &x)
void setScalar(const Real C)
Set where .
ROL::Ptr< const Vector< Real > > getVector() const
Real dot(const Vector< Real > &x) const
Compute where .