17 #include "Teuchos_GlobalMPISession.hpp"
23 constexpr
auto dim = 100u;
25 int main(
int argc,
char *argv[]) {
27 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
31 int iprint = argc - 1;
32 ROL::Ptr<std::ostream> outStream;
34 if (iprint > 0) outStream = ROL::makePtrFromRef(std::cout);
35 else outStream = ROL::makePtrFromRef(bhs);
37 auto print_pool_count = [&outStream]() {
39 <<
" Vectors from the pool" << std::endl;
44 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
62 auto consistency = x.
checkVector(y, z,
true, *outStream);
65 if (checkvec.
norm() > std::sqrt(ROL::ROL_EPSILON<RealT>())) errorFlag++;
71 RealT znorm = zp->norm();
72 *outStream <<
"Norm of ROL::Vector z (first basis vector): " << znorm <<
"\n";
73 if ( std::abs(znorm-1.0) > errtol ) {
74 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
81 *outStream <<
"\nNorm of ROL::Vector z ('middle' basis vector): " << znorm <<
"\n";
82 if ( std::abs(znorm-1.0) > errtol ) {
83 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
90 *outStream <<
"\nNorm of ROL::Vector z (last basis vector): " << znorm <<
"\n";
91 if ( std::abs(znorm-1.0) > errtol ) {
92 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
98 consistency = x.
checkVector(x, x,
true, *outStream);
99 if (checkvec.
norm() > 0.0) {
105 catch (std::logic_error& err) {
106 *outStream << err.what() <<
"\n";
112 if (errorFlag != 0) std::cout <<
"End Result: TEST FAILED\n";
113 else std::cout <<
"End Result: TEST PASSED\n";
static std::size_t pool_count()
virtual std::vector< Real > checkVector(const Vector< Real > &x, const Vector< Real > &y, const bool printToStream=true, std::ostream &outStream=std::cout) const
Verify vector-space methods.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
virtual Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Provides the std::array implementation of the ROL::Vector interface.
void scale(const Real alpha)
Compute where .
Real norm() const
Returns where .
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
static void initialize_pool()
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])
void randomize(const Real l=-1.0, const Real u=1.0)
Set vector to be uniform random between [l,u].
Ptr< Vector< Real > > basis(const int i) const
Return i-th basis vector.