44 #ifndef ROL_VECTORPROFILER_H
45 #define ROL_VECTORPROFILER_H
69 template<
class Ordinal>
99 template<
class Ordinal,
class Real>
102 template<
class Ordinal,
class Real>
107 template<
class Ordinal,
class Real>
109 outStream <<
"Total Vector Function Calls" << std::endl;
110 outStream <<
"---------------------------" << std::endl;
111 outStream <<
"Constructor : " << x.
functionCalls_.constructor_ << std::endl;
112 outStream <<
"Destructor : " << x.
functionCalls_.destructor_ << std::endl;
124 outStream <<
"dimension : " << x.
functionCalls_.dimension_ << std::endl;
125 outStream <<
"applyUnary : " << x.
functionCalls_.applyUnary_ << std::endl;
126 outStream <<
"applyBinary : " << x.
functionCalls_.applyBinary_ << std::endl;
127 outStream <<
"reduce : " << x.
functionCalls_.reduce_ << std::endl;
128 outStream <<
"setScalar : " << x.
functionCalls_.setScalar_ << std::endl;
129 outStream <<
"randomize : " << x.
functionCalls_.randomize_ << std::endl;
134 template<
class Ordinal,
class Real>
135 class ProfiledVector :
public Vector<Real> {
140 ROL::Ptr<Vector<Real> >
v_;
146 ROL::Ptr<ProfiledVector> pv = ROL::nullPtr;
147 pv = ROL::dynamicPtrCast<ProfiledVector>(v);
148 ROL_TEST_FOR_EXCEPTION( pv != ROL::nullPtr, std::logic_error,
"ProfiledVector class "
149 "cannot encapsulate a ProfiledVector object!");
183 ROL::Ptr<Vector<Real> >
clone()
const {
185 return ROL::makePtr<ProfiledVector>(
v_->clone() );
191 return v_->axpy(alpha,*xp);
199 ROL::Ptr<Vector<Real> >
basis(
const int i )
const {
201 return ROL::makePtr<ProfiledVector>(
v_->basis(i) );
206 return v_->dimension();
234 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
241 v_->applyBinary(f,x);
244 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
246 return v_->reduce(r);
259 void print( std::ostream &outStream )
const {
260 v_->print(outStream);
271 #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 .