52 #include "Teuchos_GlobalMPISession.hpp"
57 int main(
int argc,
char *argv[]) {
59 Teuchos::GlobalMPISession mpiSession(&argc, &argv,0);
61 int iprint = argc - 1;
63 std::ostream& outStream = (iprint > 0) ? std::cout : bhs;
67 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
75 ROL::Ptr<std::vector<ElementT> > x_ptr
76 = ROL::makePtr<std::vector<ElementT>>(
dim);
77 ROL::Ptr<std::vector<ElementT> > y_ptr
78 = ROL::makePtr<std::vector<ElementT>>(
dim);
79 ROL::Ptr<std::vector<ElementT> > W_ptr
80 = ROL::makePtr<std::vector<ElementT>>(
dim,
static_cast<ElementT>(2));
83 for (
int i = 0; i <
dim; i++) {
84 (*x_ptr)[i] =
static_cast<ElementT>(rand())/static_cast<ElementT>(RAND_MAX);
85 (*y_ptr)[i] =
static_cast<ElementT>(rand())/static_cast<ElementT>(RAND_MAX);
95 outStream <<
"\nAbsolute error between x.dot(y.dual()) and y.dot(x.dual()): "
96 << std::abs(xy-yx) <<
"\n";
97 outStream <<
"x.dot(y.dual()): " << xy <<
"\n";
98 outStream <<
"y.dot(x.dual()): " << yx <<
"\n";
99 if ( std::abs(xy-yx) > errtol ) {
100 outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
107 outStream <<
"\nAbsolute error between sqrt(x.dot(x)) and x.norm(): "
108 << std::abs(xx-xnorm) <<
"\n";
109 outStream <<
"sqrt(x.dot(x)): " << xx <<
"\n";
110 outStream <<
"x.norm(): " << xnorm <<
"\n";
111 if ( std::abs(xx-xnorm) > errtol ) {
112 outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
116 outStream <<
"\nAbsolute error between sqrt(y.dot(y)) and y.norm(): "
117 << std::abs(yy-ynorm) <<
"\n";
118 outStream <<
"sqrt(y.dot(y)): " << yy <<
"\n";
119 outStream <<
"y.norm(): " << ynorm <<
"\n";
120 if ( std::abs(yy-ynorm) > errtol ) {
121 outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
126 ROL::Ptr<ROL::Vector<RealT> > z = x.
clone();
128 RealT znorm = z->norm();
129 outStream <<
"\nNorm of ROL::Vector z (clone of x): " << znorm <<
"\n";
130 if ( std::abs(xnorm - znorm) > errtol ) {
131 outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
134 ROL::Ptr<ROL::Vector<RealT> > w = y.
clone();
137 RealT wnorm = w->norm();
138 outStream <<
"\nNorm of ROL::Vector w (clone of y): " << wnorm <<
"\n";
139 if ( std::abs(ynorm - wnorm) > errtol ) {
140 outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
145 ROL::Ptr<std::vector<ElementT> > x1_ptr
146 = ROL::makePtr<std::vector<ElementT>>(
dim);
147 ROL::Ptr<std::vector<ElementT> > y1_ptr
148 = ROL::makePtr<std::vector<ElementT>>(
dim);
149 ROL::Ptr<std::vector<ElementT> > z1_ptr
150 = ROL::makePtr<std::vector<ElementT>>(
dim);
153 for (
int i = 0; i <
dim; i++) {
154 (*x1_ptr)[i] =
static_cast<ElementT>(rand())/static_cast<ElementT>(RAND_MAX);
155 (*y1_ptr)[i] =
static_cast<ElementT>(rand())/static_cast<ElementT>(RAND_MAX);
156 (*z1_ptr)[i] =
static_cast<ElementT>(rand())/static_cast<ElementT>(RAND_MAX);
164 std::vector<RealT> consistency = x1.
checkVector(y1, z1,
true, outStream);
166 if (checkvec.
norm() > std::sqrt(errtol)) {
172 catch (std::logic_error& err) {
173 outStream << err.what() <<
"\n";
178 std::cout <<
"End Result: TEST FAILED\n";
180 std::cout <<
"End Result: TEST PASSED\n";
Provides the std::vector implementation of the ROL::Vector interface that handles scalings in the inn...
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 dot(const Vector< Real > &x) const
Compute where .
Real dot(const Vector< Real > &x) const
Compute where .
Real norm() const
Returns where .
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Ptr< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Provides the std::vector implementation of the ROL::Vector interface that handles scalings in the inn...
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])
const Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
const Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...