44 #ifndef ROL_SAMPLEGENERATOR_HPP
45 #define ROL_SAMPLEGENERATOR_HPP
57 ROL::Ptr<BatchManager<Real> >
bman_;
62 void setPoints(std::vector<std::vector<Real> > &p) {
64 points_.assign(p.begin(),p.end());
118 return bman_->batchID();
122 return bman_->numBatches();
125 void sumAll(Real *input, Real *output,
int dim)
const {
126 bman_->sumAll(input, output, dim);
130 bman_->sumAll(input,output);
134 bman_->broadcast(input,cnt,root);
145 void print(
const std::string &filename =
"samples",
146 const int prec = 12)
const {
147 int width = prec + 5 + 4;
148 std::stringstream name;
149 name << filename <<
"_" <<
batchID() <<
".txt";
150 std::ofstream file(name.str().c_str());
151 if (file.is_open()) {
152 file << std::scientific << std::setprecision(prec);
156 for (
int j = 0; j < static_cast<int>(pt.size()); ++j) {
157 file << std::setw(width) << std::left << pt[j];
159 file << std::setw(width) << std::left << wt << std::endl;
164 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
165 ">>> (ROL::SampleGenerator::print): Unable to open file!");
virtual ~SampleGenerator()
void sumAll(Vector< Real > &input, Vector< Real > &output) const
virtual void update(const Vector< Real > &x)
virtual int numGlobalSamples(void) const
virtual void setSamples(bool inConstructor=false)
virtual std::vector< Real > getMyPoint(const int i) const
void broadcast(Real *input, int cnt, int root) const
virtual Real getMyWeight(const int i) const
Defines the linear algebra or vector space interface.
virtual int numMySamples(void) const
void sumAll(Real *input, Real *output, int dim) const
void print(const std::string &filename="samples", const int prec=12) const
ROL::Ptr< BatchManager< Real > > bman_
virtual void refine(void)
virtual Real computeError(std::vector< ROL::Ptr< Vector< Real > > > &vals, const Vector< Real > &x)
std::vector< Real > weights_
const ROL::Ptr< BatchManager< Real > > getBatchManager(void) const
SampleGenerator(const SampleGenerator< Real > &sampler)
std::vector< std::vector< Real > > points_
int numBatches(void) const
virtual Real computeError(std::vector< Real > &vals)
void setPoints(std::vector< std::vector< Real > > &p)
void setWeights(std::vector< Real > &w)
SampleGenerator(const ROL::Ptr< BatchManager< Real > > &bman)