44 #ifndef ROL_ATOMVECTOR_H 45 #define ROL_ATOMVECTOR_H 72 const int numMySamples,
const int dimension)
76 ROL::Ptr<const std::vector<Real> >
getAtom(
const int i)
const {
77 ROL_TEST_FOR_EXCEPTION((i < 0 || i >
numMySamples_), std::invalid_argument,
78 ">>> ERROR (ROL::AtomVector): index out of bounds in getAtom!");
80 std::vector<Real> pt(dim,0);
82 for (
uint j = 0; j < dim; ++j) {
83 pt[j] = yval[I*dim + j];
85 return ROL::makePtr<std::vector<Real>>(pt);
88 void setAtom(
const int i,
const std::vector<Real> &pt) {
89 ROL_TEST_FOR_EXCEPTION((i < 0 || i >
numMySamples_), std::invalid_argument,
90 ">>> ERROR (ROL::AtomVector): index out of bounds in setAtom!");
93 for (
uint j = 0; j < dim; ++j) {
94 yval[I*dim + j] = pt[j];
108 class PrimalAtomVector :
public AtomVector<Real> {
111 const ROL::Ptr<std::vector<Real> >
scale_;
118 const int numMySamples,
const int dimension,
119 const ROL::Ptr<std::vector<Real> > &
scale)
126 uint ysize = yval.size();
127 ROL_TEST_FOR_EXCEPTION( xval.size() != ysize, std::invalid_argument,
128 "Error: Vectors must have the same dimension." );
132 Real val(0), sum_val(0);
133 for (
uint i = 0; i < numMySamples; i++) {
136 val += xval[index] * (*scale_)[index] * yval[index];
144 ROL::Ptr<Vector<Real> >
clone(
void)
const {
147 return ROL::makePtr<PrimalAtomVector>(
148 ROL::makePtr<std::vector<Real>>(numMySamples*
dimension),
157 dual_vec_ = ROL::makePtr<DualAtomVector<Real>>(
158 ROL::makePtr<std::vector<Real>>(numMySamples*
dimension),
164 for (
uint i = 0; i < numMySamples; i++) {
176 class DualAtomVector :
public AtomVector<Real> {
179 const ROL::Ptr<std::vector<Real> >
scale_;
186 const int numMySamples,
const int dimension,
187 const ROL::Ptr<std::vector<Real> > &
scale)
194 uint ysize = yval.size();
195 ROL_TEST_FOR_EXCEPTION( xval.size() != ysize, std::invalid_argument,
196 "Error: Vectors must have the same dimension." );
200 Real val(0), sum_val(0);
201 for (
uint i = 0; i < numMySamples; i++) {
204 val += xval[index] * yval[index] / (*scale_)[index];
212 ROL::Ptr<Vector<Real> >
clone(
void)
const {
215 return ROL::makePtr<DualAtomVector>(
216 ROL::makePtr<std::vector<Real>>(numMySamples*
dimension),
225 primal_vec_ = ROL::makePtr<PrimalAtomVector<Real>>(
226 ROL::makePtr<std::vector<Real>>(numMySamples*
dimension),
232 for (
uint i = 0; i < numMySamples; i++) {
const ROL::Ptr< std::vector< Real > > scale_
std::vector< Real >::size_type uint
typename PV< Real >::size_type size_type
void scale(const Real alpha)
int getNumMyAtoms(void) const
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Provides the std::vector implementation of the ROL::Vector interface.
int dimension(void) const
Return dimension of the vector space.
Provides the std::vector implementation of the ROL::Vector interface.
void setAtom(const int i, const std::vector< Real > &pt)
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Ptr< const std::vector< Element > > getVector() const
const ROL::Ptr< BatchManager< Real > > getBatchManager(void) const
Defines the linear algebra or vector space interface.
Real dot(const Vector< Real > &x) const
Compute where .
std::vector< Real >::size_type uint
AtomVector(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BatchManager< Real > > &bman, const int numMySamples, const int dimension)
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
int getDimension(void) const
Real dot(const Vector< Real > &x) const
Compute where .
DualAtomVector(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BatchManager< Real > > &bman, const int numMySamples, const int dimension, const ROL::Ptr< std::vector< Real > > &scale)
PrimalAtomVector(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BatchManager< Real > > &bman, const int numMySamples, const int dimension, const ROL::Ptr< std::vector< Real > > &scale)
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
ROL::Ptr< const std::vector< Real > > getAtom(const int i) const
const ROL::Ptr< std::vector< Real > > scale_
std::vector< Real >::size_type uint
ROL::Ptr< PrimalAtomVector< Real > > primal_vec_
ROL::Ptr< DualAtomVector< Real > > dual_vec_