10 #ifndef ROL_BATCHSTDVECTOR_H
11 #define ROL_BATCHSTDVECTOR_H
27 const Ptr<BatchManager<Real>>
bman_;
37 uint numMySamples = yval.size();
38 ROL_TEST_FOR_EXCEPTION( xval.size() != numMySamples, std::invalid_argument,
39 "Error: Vectors must have the same dimension." );
40 Real val(0), sum_val(0);
41 for (
uint i = 0; i < numMySamples; ++i) {
42 val += xval[i] * yval[i];
45 bman_->sumAll(&val,&sum_val,1);
49 virtual Ptr<Vector<Real>>
clone(
void)
const {
51 uint numMySamples = yval.size();
52 return makePtr<BatchStdVector>(
53 makePtr<std::vector<Real>>(numMySamples),
bman_);
59 bman_->sumAll(&dim,&sum,1);
63 Real
reduce(
const Elementwise::ReductionOp<Real> &r)
const {
65 uint numMySamples = yval.size();
66 Real result = r.initialValue();
67 for (
uint i = 0; i < numMySamples; i++) {
68 r.reduce(yval[i],result);
72 bman_->reduceAll(&result,&sum,1,r);
typename PV< Real >::size_type size_type
virtual Real dot(const Vector< Real > &x) const
Compute where .
Provides the std::vector implementation of the ROL::Vector interface.
Ptr< const std::vector< Real > > getVector() const
Defines the linear algebra or vector space interface.
virtual Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
const Ptr< BatchManager< Real > > bman_
BatchStdVector(const Ptr< std::vector< Real >> &vec, const Ptr< BatchManager< Real >> &bman)
const Ptr< BatchManager< Real > > getBatchManager(void) const
std::vector< Real >::size_type uint
Real reduce(const Elementwise::ReductionOp< Real > &r) const
int dimension(void) const
Return dimension of the vector space.