44 #ifndef ROL_VECTORPROFILER_H
45 #define ROL_VECTORPROFILER_H
69 template<
class Ordinal>
98 template<
class Ordinal,
class Real>
101 template<
class Ordinal,
class Real>
106 template<
class Ordinal,
class Real>
108 outStream <<
"Total Vector Function Calls" << std::endl;
109 outStream <<
"---------------------------" << std::endl;
110 outStream <<
"Constructor : " << x.
functionCalls_.constructor_ << std::endl;
111 outStream <<
"Destructor : " << x.
functionCalls_.destructor_ << std::endl;
122 outStream <<
"dimension : " << x.
functionCalls_.dimension_ << std::endl;
123 outStream <<
"applyUnary : " << x.
functionCalls_.applyUnary_ << std::endl;
124 outStream <<
"applyBinary : " << x.
functionCalls_.applyBinary_ << std::endl;
125 outStream <<
"reduce : " << x.
functionCalls_.reduce_ << std::endl;
126 outStream <<
"setScalar : " << x.
functionCalls_.setScalar_ << std::endl;
127 outStream <<
"randomize : " << x.
functionCalls_.randomize_ << std::endl;
132 template<
class Ordinal,
class Real>
133 class ProfiledVector :
public Vector<Real> {
138 ROL::Ptr<Vector<Real> >
v_;
144 ROL::Ptr<ProfiledVector> pv = ROL::nullPtr;
145 pv = ROL::dynamicPtrCast<ProfiledVector>(v);
146 ROL_TEST_FOR_EXCEPTION( pv != ROL::nullPtr, std::logic_error,
"ProfiledVector class "
147 "cannot encapsulate a ProfiledVector object!");
181 ROL::Ptr<Vector<Real> >
clone()
const {
183 return ROL::makePtr<ProfiledVector>(
v_->clone() );
189 return v_->axpy(alpha,*xp);
197 ROL::Ptr<Vector<Real> >
basis(
const int i )
const {
199 return ROL::makePtr<ProfiledVector>(
v_->basis(i) );
204 return v_->dimension();
227 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
234 v_->applyBinary(f,x);
237 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
239 return v_->reduce(r);
252 void print( std::ostream &outStream )
const {
253 v_->print(outStream);
264 #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.
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 .