52 #include "Teuchos_GlobalMPISession.hpp"
65 const PV eb =
dynamic_cast<const PV&
>(x);
66 size_type n = eb.numVectors();
68 for(size_type k=0; k<n; ++k) {
69 std::cout <<
"[subvector " << k <<
"]" << std::endl;
70 ROL::Ptr<const V> vec = eb.get(k);
71 ROL::Ptr<const std::vector<Real> > vp =
72 dynamic_cast<const SV&
>(*vec).getVector();
73 for(size_type i=0;i<vp->size();++i) {
74 std::cout << (*vp)[i] << std::endl;
80 int main(
int argc,
char *argv[]) {
82 using namespace Teuchos;
88 GlobalMPISession mpiSession(&argc, &argv);
90 int iprint = argc - 1;
92 ROL::Ptr<std::ostream> outStream;
96 outStream = ROL::makePtrFromRef(std::cout);
98 outStream = ROL::makePtrFromRef(bhs);
102 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
107 std::vector<int>
dim;
115 RealT left = -1e0, right = 1e0;
117 std::vector<ROL::Ptr<V> > x_ptr;
118 std::vector<ROL::Ptr<V> > y_ptr;
119 std::vector<ROL::Ptr<V> > z_ptr;
122 ROL::Ptr<std::vector<RealT> > xk_ptr = ROL::makePtr<std::vector<RealT>>(dim[k]);
123 ROL::Ptr<std::vector<RealT> > yk_ptr = ROL::makePtr<std::vector<RealT>>(dim[k]);
124 ROL::Ptr<std::vector<RealT> > zk_ptr = ROL::makePtr<std::vector<RealT>>(dim[k]);
126 for(
int i=0; i<dim[k]; ++i ) {
127 (*xk_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
128 (*yk_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
129 (*zk_ptr)[i] = ( (
RealT)rand() / (
RealT)RAND_MAX ) * (right - left) + left;
132 ROL::Ptr<V> xk = ROL::makePtr<SV>( xk_ptr );
133 ROL::Ptr<V> yk = ROL::makePtr<SV>( yk_ptr );
134 ROL::Ptr<V> zk = ROL::makePtr<SV>( zk_ptr );
144 ROL::Ptr<V> y = ROL::CreatePartitionedVector<RealT>(y_ptr[0],y_ptr[1],y_ptr[2]);
148 std::vector<RealT> consistency = x.checkVector(*y, z,
true, *outStream);
150 if (checkvec.
norm() > std::sqrt(errtol)) {
156 ROL::Ptr<ROL::Vector<RealT> > zp = x.clone();
158 RealT znorm = zp->norm();
159 *outStream <<
"Norm of ROL::Vector z (first basis vector): " << znorm <<
"\n";
160 if ( std::abs(znorm-1.0) > errtol ) {
161 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
165 zp = x.basis(total_dim/2);
167 *outStream <<
"\nNorm of ROL::Vector z ('middle' basis vector): " << znorm <<
"\n";
168 if ( std::abs(znorm-1.0) > errtol ) {
169 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
173 zp = x.basis(total_dim-1);
175 *outStream <<
"\nNorm of ROL::Vector z (last basis vector): " << znorm <<
"\n";
176 if ( std::abs(znorm-1.0) > errtol ) {
177 *outStream <<
"---> POSSIBLE ERROR ABOVE!\n";
183 consistency = x.checkVector(x, x,
true, *outStream);
184 if (checkvec.
norm() > 0.0) {
189 int m = atoi(argv[1]);
198 catch (std::logic_error& err) {
199 *outStream << err.what() <<
"\n";
204 std::cout <<
"End Result: TEST FAILED\n";
206 std::cout <<
"End Result: TEST PASSED\n";
PartitionedVector< Real > PV
typename PV< Real >::size_type size_type
Defines the linear algebra of vector space on a generic partitioned vector.
Contains definitions of custom data types in ROL.
Defines the linear algebra or vector space interface.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
void print_vector(const ROL::Vector< Real > &x)
Real norm() const
Returns where .
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])