10 #ifndef ROL_PROBABILITYVECTOR_H
11 #define ROL_PROBABILITYVECTOR_H
38 int numMySamples =
static_cast<int>(yval.size());
39 ROL_TEST_FOR_EXCEPTION((i < 0 || i >= numMySamples), std::invalid_argument,
40 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in getProbability!");
46 int numMySamples =
static_cast<int>(yval.size());
47 ROL_TEST_FOR_EXCEPTION((i < 0 || i >= numMySamples), std::invalid_argument,
48 ">>> ERROR (ROL::ProbabilityVector): index out of bounds in setProbability!");
57 ROL::Ptr<Vector<Real> >
clone(
void)
const {
59 uint numMySamples = yval.size();
60 return ROL::makePtr<ProbabilityVector>(
66 class PrimalProbabilityVector :
public ProbabilityVector<Real> {
70 mutable ROL::Ptr<DualProbabilityVector<Real> >
dual_vec_;
76 const ROL::Ptr<std::vector<Real> > &
scale)
83 uint numMySamples =
static_cast<uint>(yval.size());
84 ROL_TEST_FOR_EXCEPTION( xval.size() != numMySamples, std::invalid_argument,
85 "Error: Vectors must have the same dimension." );
86 Real val(0), sum_val(0);
87 for (
uint i = 0; i < numMySamples; i++) {
88 val += xval[i] * (*scale_)[i] * yval[i];
95 ROL::Ptr<Vector<Real> >
clone(
void)
const {
97 return ROL::makePtr<PrimalProbabilityVector>(
98 ROL::makePtr<std::vector<Real>>(numMySamples),
105 dual_vec_ = ROL::makePtr<DualProbabilityVector<Real>>(
106 ROL::makePtr<std::vector<Real>>(numMySamples),
110 for (
uint i = 0; i < numMySamples; ++i) {
119 class DualProbabilityVector :
public ProbabilityVector<Real> {
129 const ROL::Ptr<std::vector<Real> > &
scale)
136 uint numMySamples =
static_cast<uint>(yval.size());
137 ROL_TEST_FOR_EXCEPTION( xval.size() != numMySamples, std::invalid_argument,
138 "Error: Vectors must have the same dimension." );
139 Real val(0), sum_val(0);
140 for (
uint i = 0; i < numMySamples; i++) {
141 val += xval[i] * yval[i] / (*scale_)[i];
148 ROL::Ptr<Vector<Real> >
clone(
void)
const {
150 return ROL::makePtr<DualProbabilityVector>(
151 ROL::makePtr<std::vector<Real>>(numMySamples),
158 primal_vec_ = ROL::makePtr<PrimalProbabilityVector<Real>>(
159 ROL::makePtr<std::vector<Real>>(numMySamples),
163 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