44 #ifndef ROL_PROBABILITYVECTOR_H
45 #define ROL_PROBABILITYVECTOR_H
72 int numMySamples =
static_cast<int>(yval.size());
73 ROL_TEST_FOR_EXCEPTION((i < 0 || i >= numMySamples), std::invalid_argument,
74 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in getProbability!");
80 int numMySamples =
static_cast<int>(yval.size());
81 ROL_TEST_FOR_EXCEPTION((i < 0 || i >= numMySamples), std::invalid_argument,
82 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in setProbability!");
91 ROL::Ptr<Vector<Real> >
clone(
void)
const {
93 uint numMySamples = yval.size();
94 return ROL::makePtr<ProbabilityVector>(
100 class PrimalProbabilityVector :
public ProbabilityVector<Real> {
104 mutable ROL::Ptr<DualProbabilityVector<Real> >
dual_vec_;
110 const ROL::Ptr<std::vector<Real> > &
scale)
117 uint numMySamples =
static_cast<uint>(yval.size());
118 ROL_TEST_FOR_EXCEPTION( xval.size() != numMySamples, std::invalid_argument,
119 "Error: Vectors must have the same dimension." );
120 Real val(0), sum_val(0);
121 for (
uint i = 0; i < numMySamples; i++) {
122 val += xval[i] * (*scale_)[i] * yval[i];
129 ROL::Ptr<Vector<Real> >
clone(
void)
const {
131 return ROL::makePtr<PrimalProbabilityVector>(
132 ROL::makePtr<std::vector<Real>>(numMySamples),
139 dual_vec_ = ROL::makePtr<DualProbabilityVector<Real>>(
140 ROL::makePtr<std::vector<Real>>(numMySamples),
144 for (
uint i = 0; i < numMySamples; ++i) {
153 class DualProbabilityVector :
public ProbabilityVector<Real> {
163 const ROL::Ptr<std::vector<Real> > &
scale)
170 uint numMySamples =
static_cast<uint>(yval.size());
171 ROL_TEST_FOR_EXCEPTION( xval.size() != numMySamples, std::invalid_argument,
172 "Error: Vectors must have the same dimension." );
173 Real val(0), sum_val(0);
174 for (
uint i = 0; i < numMySamples; i++) {
175 val += xval[i] * yval[i] / (*scale_)[i];
182 ROL::Ptr<Vector<Real> >
clone(
void)
const {
184 return ROL::makePtr<DualProbabilityVector>(
185 ROL::makePtr<std::vector<Real>>(numMySamples),
192 primal_vec_ = ROL::makePtr<PrimalProbabilityVector<Real>>(
193 ROL::makePtr<std::vector<Real>>(numMySamples),
197 for (
uint i = 0; i < numMySamples; i++) {
std::vector< Real >::size_type uint
typename PV< Real >::size_type size_type
void scale(const Real alpha)
Compute where .
PrimalProbabilityVector(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BatchManager< Real > > &bman, const ROL::Ptr< std::vector< Real > > &scale)
const Real getProbability(const int i) const
ROL::Ptr< DualProbabilityVector< Real > > dual_vec_
Provides the std::vector implementation of the ROL::Vector interface.
Ptr< const std::vector< Element > > getVector() const
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ProbabilityVector(const ROL::Ptr< std::vector< Real >> &vec, const ROL::Ptr< BatchManager< Real >> &bman)
Defines the linear algebra or vector space interface.
Real dot(const Vector< Real > &x) const
Compute where .
ROL::Ptr< std::vector< Real > > scale_
std::vector< Real >::size_type uint
ROL::Ptr< 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...
DualProbabilityVector(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BatchManager< Real > > &bman, const ROL::Ptr< std::vector< Real > > &scale)
void setProbability(const int i, const Real wt)
ROL::Ptr< PrimalProbabilityVector< Real > > primal_vec_
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
Provides the std::vector implementation of the ROL::Vector interface.
const Ptr< BatchManager< Real > > getBatchManager(void) const
std::vector< Real >::size_type uint
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
std::vector< Real >::size_type uint
Real dot(const Vector< Real > &x) const
Compute where .
ROL::Ptr< std::vector< Real > > scale_
int getNumMyAtoms(void) const