44 #ifndef ROL_SAMPLEGENERATOR_HPP 45 #define ROL_SAMPLEGENERATOR_HPP 47 #include "Teuchos_RefCountPtr.hpp" 57 Teuchos::RCP<BatchManager<Real> >
bman_;
62 void setPoints(std::vector<std::vector<Real> > &p) {
64 points_.assign(p.begin(),p.end());
68 weights_.assign(w.begin(),w.end());
74 : begin_(0), bman_(bman) {}
76 : begin_(sampler.begin_), bman_(sampler.bman_),
77 points_(sampler.points_), weights_(sampler.weights_) {}
102 return weights_.size();
114 return bman_->batchID();
118 return bman_->numBatches();
121 void sumAll(Real *input, Real *output,
int dim)
const {
122 bman_->sumAll(input, output, dim);
126 bman_->sumAll(input,output);
130 bman_->broadcast(input,cnt,root);
137 void print(
const std::string &filename =
"samples",
138 const int prec = 12)
const {
139 int width = prec + 5 + 4;
140 std::stringstream name;
141 name << filename <<
"_" <<
batchID() <<
".txt";
142 std::ofstream file(name.str().c_str());
143 if (file.is_open()) {
144 file << std::scientific << std::setprecision(prec);
148 for (
int j = 0; j < static_cast<int>(pt.size()); ++j) {
149 file << std::setw(width) << std::left << pt[j];
151 file << std::setw(width) << std::left << wt << std::endl;
156 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
157 ">>> (ROL::SampleGenerator::print): Unable to open file!");
virtual ~SampleGenerator()
virtual std::vector< Real > getMyPoint(const int i) const
virtual void update(const Vector< Real > &x)
Teuchos::RCP< BatchManager< Real > > bman_
void sumAll(Vector< Real > &input, Vector< Real > &output) const
virtual void setSamples(bool inConstructor=false)
void sumAll(Real *input, Real *output, int dim) const
Defines the linear algebra or vector space interface.
virtual Real getMyWeight(const int i) const
virtual void refine(void)
std::vector< Real > weights_
virtual int numMySamples(void) const
SampleGenerator(const SampleGenerator< Real > &sampler)
std::vector< std::vector< Real > > points_
int numBatches(void) const
SampleGenerator(const Teuchos::RCP< BatchManager< Real > > &bman)
virtual Real computeError(std::vector< Teuchos::RCP< Vector< Real > > > &vals, const Vector< Real > &x)
void print(const std::string &filename="samples", const int prec=12) const
virtual Real computeError(std::vector< Real > &vals)
void setPoints(std::vector< std::vector< Real > > &p)
void broadcast(Real *input, int cnt, int root) const
void setWeights(std::vector< Real > &w)