44 #ifndef ROL_VECTORPROFILER_H 45 #define ROL_VECTORPROFILER_H 69 template<
class Ordinal>
88 constructor_(0), destructor_(0), plus_(0), scale_(0), dot_(0), norm_(0), clone_(0),
89 axpy_(0), zero_(0), basis_(0), dimension_(0), set_(0), dual_(0), applyUnary_(0),
90 applyBinary_(0), reduce_(0) {}
96 template<
class Ordinal,
class Real>
99 template<
class Ordinal,
class Real>
104 template<
class Ordinal,
class Real>
106 outStream <<
"Total Vector Function Calls" << std::endl;
107 outStream <<
"---------------------------" << std::endl;
108 outStream <<
"Constructor : " << x.
functionCalls_.constructor_ << std::endl;
109 outStream <<
"Destructor : " << x.
functionCalls_.destructor_ << std::endl;
120 outStream <<
"dimension : " << x.
functionCalls_.dimension_ << std::endl;
121 outStream <<
"applyUnary : " << x.
functionCalls_.applyUnary_ << std::endl;
122 outStream <<
"applyBinary : " << x.
functionCalls_.applyBinary_ << std::endl;
123 outStream <<
"reduce : " << x.
functionCalls_.reduce_ << std::endl;
128 template<
class Ordinal,
class Real>
131 template <
typename T>
using RCP = Teuchos::RCP<T>;
135 Teuchos::RCP<Vector<Real> >
v_;
141 Teuchos::RCP<ProfiledVector> pv = Teuchos::null;
143 TEUCHOS_TEST_FOR_EXCEPTION( pv != Teuchos::null, std::logic_error,
"ProfiledVector class " 144 "cannot encapsulate a ProfiledVector object!");
158 functionCalls_.
plus_++;
169 functionCalls_.
dot_++;
174 functionCalls_.
norm_++;
178 Teuchos::RCP<Vector<Real> >
clone()
const {
185 functionCalls_.
axpy_++;
186 return v_->axpy(alpha,*xp);
190 functionCalls_.
zero_++;
194 Teuchos::RCP<Vector<Real> >
basis(
const int i )
const {
201 return v_->dimension();
206 functionCalls_.
set_++;
212 functionCalls_.
dual_++;
224 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
231 v_->applyBinary(f,x);
234 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
236 return v_->reduce(r);
239 void print( std::ostream &outStream )
const {
240 v_->print(outStream);
251 #endif // ROL_RANDOMVECTOR_H
Teuchos::RCP< Vector< Real > > getVector()
const Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Real dot(const Vector< Real > &x) const
Compute where .
void print(std::ostream &outStream) const
Real norm() const
Returns where .
Defines the linear algebra or vector space interface.
void scale(const Real alpha)
Compute where .
Teuchos::RCP< Vector< Real > > basis(const int i) const
Return i-th basis vector.
static VectorFunctionCalls< Ordinal > functionCalls_
ProfiledVector(const Teuchos::RCP< Vector< Real > > &v)
void zero()
Set to zero vector.
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
Teuchos::RCP< 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 ...
Real reduce(const Elementwise::ReductionOp< Real > &r) const
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
void plus(const Vector< Real > &x)
Compute , where .
Teuchos::RCP< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
VectorFunctionCalls< Ordinal > getVectorFunctionCalls(const ProfiledVector< Ordinal, Real > &x)
Teuchos::RCP< const Vector< Real > > getVector() const
int dimension() const
Return dimension of the vector space.