44 #ifndef ROL_PROBABILITYVECTOR_H 45 #define ROL_PROBABILITYVECTOR_H 65 typedef typename std::vector<Real>::size_type
uint;
71 :
StdVector<Real>(vec), numMySamples_(vec->size()) {}
74 if ( i >= 0 && i < (
int)numMySamples_ ) {
79 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
80 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in getProbability!");
86 if ( i >= 0 && i < (
int)numMySamples_ ) {
91 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
92 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in setProbability!");
103 typedef typename std::vector<Real>::size_type
uint;
107 Teuchos::RCP<BatchManager<Real> >
bman_;
109 mutable Teuchos::RCP<DualProbabilityVector<Real> >
dual_vec_;
113 const Teuchos::RCP<std::vector<Real> > &
scale,
116 scale_(
scale), bman_(bman) {}
120 const std::vector<Real> &xval = *(ex.
getVector());
124 val += xval[i] * (*scale_)[i] * yval[i];
128 bman_->sumAll(&val,&sum_val,1);
132 Teuchos::RCP<Vector<Real> >
clone(
void)
const {
134 Teuchos::rcp(
new std::vector<Real>(numMySamples_)),scale_,bman_));
139 std::vector<Real> tmp(yval);
141 tmp[i] *= (*scale_)[i];
144 Teuchos::rcp(
new std::vector<Real>(tmp)),scale_,bman_));
151 bman_->sumAll(&dim,&sum,1);
155 Real
reduce(
const Elementwise::ReductionOp<Real> &r)
const {
157 Real result = r.initialValue();
159 r.reduce(yval[i],result);
163 bman_->reduceAll(&result,&sum,r);
170 typedef typename std::vector<Real>::size_type
uint;
174 Teuchos::RCP<BatchManager<Real> >
bman_;
176 mutable Teuchos::RCP<PrimalProbabilityVector<Real> >
dual_vec_;
180 const Teuchos::RCP<std::vector<Real> > &
scale,
183 scale_(
scale), bman_(bman) {}
187 const std::vector<Real> &xval = *(ex.
getVector());
191 val += xval[i] * yval[i] / (*scale_)[i];
195 bman_->sumAll(&val,&sum_val,1);
199 Teuchos::RCP<Vector<Real> >
clone(
void)
const {
201 Teuchos::rcp(
new std::vector<Real>(numMySamples_)),scale_,bman_));
206 std::vector<Real> tmp(yval);
208 tmp[i] /= (*scale_)[i];
211 Teuchos::rcp(
new std::vector<Real>(tmp)),scale_,bman_));
218 bman_->sumAll(&dim,&sum,1);
222 Real
reduce(
const Elementwise::ReductionOp<Real> &r)
const {
224 Real result = r.initialValue();
226 r.reduce(yval[i],result);
230 bman_->reduceAll(&result,&sum,r);
Teuchos::RCP< DualProbabilityVector< Real > > dual_vec_
Teuchos::RCP< std::vector< Real > > scale_
std::vector< Real >::size_type uint
void scale(const Real alpha)
Real reduce(const Elementwise::ReductionOp< Real > &r) const
Teuchos::RCP< const std::vector< Element > > getVector() const
Teuchos::RCP< BatchManager< Real > > bman_
const Real getProbability(const int i) const
DualProbabilityVector(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< std::vector< Real > > &scale, const Teuchos::RCP< BatchManager< Real > > &bman)
Teuchos::RCP< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< PrimalProbabilityVector< Real > > dual_vec_
Defines the linear algebra or vector space interface.
Real dot(const Vector< Real > &x) const
Compute where .
std::vector< Real >::size_type uint
Provides the std::vector implementation of the ROL::Vector interface.
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< BatchManager< Real > > bman_
void setProbability(const int i, const Real wt)
Real reduce(const Elementwise::ReductionOp< Real > &r) const
Provides the std::vector implementation of the ROL::Vector interface.
PrimalProbabilityVector(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< std::vector< Real > > &scale, const Teuchos::RCP< BatchManager< Real > > &bman)
int dimension(void) const
Return dimension of the vector space.
std::vector< Real >::size_type uint
int dimension(void) const
Return dimension of the vector space.
Teuchos::RCP< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
Real dot(const Vector< Real > &x) const
Compute where .
ProbabilityVector(const Teuchos::RCP< std::vector< Real > > &vec)
int getNumMyAtoms(void) const
Teuchos::RCP< std::vector< Real > > scale_