52 #include "Teuchos_GlobalMPISession.hpp"
59 int main(
int argc,
char *argv[]) {
61 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
64 int iprint = argc - 1;
65 ROL::Ptr<std::ostream> outStream;
68 outStream = ROL::makePtrFromRef(std::cout);
70 outStream = ROL::makePtrFromRef(bhs);
74 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
81 ROL::Ptr<std::vector<ElementT> > x_ptr = ROL::makePtr<std::vector<ElementT>>(dim, 0.0);
82 ROL::Ptr<std::vector<ElementT> > y_ptr = ROL::makePtr<std::vector<ElementT>>(dim, 0.0);
83 ROL::Ptr<std::vector<ElementT> > z_ptr = ROL::makePtr<std::vector<ElementT>>(dim, 0.0);
88 RealT left = -1e0, right = 1e0;
91 for (
int i=0; i<dim; i++) {
92 (*x_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
93 (*y_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
94 (*z_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
98 std::vector<RealT> consistency = x.
checkVector(y, z,
true, *outStream);
100 if (checkvec.
norm() > std::sqrt(ROL::ROL_EPSILON<RealT>())) {
106 ROL::Ptr<ROL::Vector<RealT> > zp = x.
clone();
108 RealT znorm = zp->norm();
109 *outStream <<
"Norm of ROL::Vector z (first basis vector): " << znorm <<
"\n";
110 if ( std::abs(znorm-1.0) > errtol ) {
111 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
117 *outStream <<
"\nNorm of ROL::Vector z ('middle' basis vector): " << znorm <<
"\n";
118 if ( std::abs(znorm-1.0) > errtol ) {
119 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
125 *outStream <<
"\nNorm of ROL::Vector z (last basis vector): " << znorm <<
"\n";
126 if ( std::abs(znorm-1.0) > errtol ) {
127 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
133 consistency = x.
checkVector(x, x,
true, *outStream);
134 if (checkvec.
norm() > 0.0) {
139 catch (std::logic_error err) {
140 *outStream << err.what() <<
"\n";
145 std::cout <<
"End Result: TEST FAILED\n";
147 std::cout <<
"End Result: TEST PASSED\n";
void scale(const Real alpha)
Compute where .
Ptr< Vector< Real > > basis(const int i) const
Return i-th basis vector.
Contains definitions of custom data types in ROL.
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...
Real norm() const
Returns where .
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
virtual Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])