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)
120 :
AtomVector<Real>(vec,bman,numMySamples,dimension),
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++) {
135 index = i*dimension + j;
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++) {
166 index = i*dimension + j;
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)
188 :
AtomVector<Real>(vec,bman,numMySamples,dimension),
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++) {
203 index = i*dimension + j;
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++) {
234 index = i*dimension + j;
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)
Compute where .
Provides the std::vector implementation of the ROL::Vector interface.
const ROL::Ptr< BatchManager< Real > > getBatchManager(void) const
int getDimension(void) const
ROL::Ptr< const std::vector< Real > > getAtom(const int i) const
Provides the std::vector implementation of the ROL::Vector interface.
void setAtom(const int i, const std::vector< Real > &pt)
Real dot(const Vector< Real > &x) const
Compute where .
Ptr< const std::vector< Element > > getVector() const
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
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.
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Real dot(const Vector< Real > &x) const
Compute where .
int getNumMyAtoms(void) const
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)
const ROL::Ptr< std::vector< Real > > scale_
std::vector< Real >::size_type uint
ROL::Ptr< PrimalAtomVector< Real > > primal_vec_
int dimension(void) const
Return dimension of the vector space.
ROL::Ptr< DualAtomVector< Real > > dual_vec_