67 <<
"\n*****************************************************************"
68 <<
"\n*** Testing input/output operators and functions for DVector, ***"
69 <<
"\n*** DVectorSlice, DMatrix and DMatrixSlice. ***"
70 <<
"\n*** Must be run with TestDenseLinAlgPackIO.in as input ***"
71 <<
"\n*****************************************************************\n";
74 _out <<
"\n format f(_in);\n"
75 <<
" f.setw(15).showpoint().setprecision(6);\n";
77 f.setw(15).showpoint().setprecision(6);
80 _out <<
"\nTest Eating comment lines.\n"
81 <<
" eat_comment_lines(_in,'*');\n";
86 _out <<
"\nTest inputing Vectors and VectorSlices (eat_comment_lines(_in,'*') called inbetween)\n"
87 <<
" DVector v1, v2(4), v3, v4(4);\n"
91 _out <<
"\n _out << cbind(f,v1);\n";
96 _out <<
"\n _in >> v2;\n";
98 _out <<
"\n _out << cbind(f,v2);\n";
103 _out <<
"\n _in >> v3;\n";
105 _out <<
"\n _out << cbind(f,v3());\n";
106 _out <<
cbind(f,v3());
110 _out <<
"\n _in >> v4();\n";
112 _out <<
"\n _out << cbind(f,v4());\n";
113 _out <<
cbind(f,v4());
117 _out <<
" v1.resize(0); v3.resize(0);\n"
118 <<
"\n _in >> bind(f,v1);\n";
119 v1.resize(0); v3.resize(0);
121 _out <<
"\n _out << cbind(f,v1);\n";
126 _out <<
"\n _in >> bind(f,v2);\n";
128 _out <<
"\n _out << cbind(f,v2);\n";
133 _out <<
"\n _in >> bind(f,v3);\n";
135 _out <<
"\n _out << cbind(f,v3());\n";
136 _out <<
cbind(f,v3());
140 _out <<
"\n _in >> bind(f,v4());\n";
142 _out <<
"\n _out << cbind(f,v4());\n";
143 _out <<
cbind(f,v4());
147 _out <<
"\n _in >> bind(f.ignore_dim(),v1);\n";
148 _in >>
bind(f.ignore_dim(),v1);
149 _out <<
"\n _out << cbind(f,v1);\n";
154 _out <<
"\n _in >> bind(f,v2);\n";
156 _out <<
"\n _out << cbind(f,v2);\n";
161 _out <<
"\n _in >> bind(f,v3());\n";
163 _out <<
"\n _out << cbind(f,v3());\n";
164 _out <<
cbind(f,v3());
168 _out <<
"\n _in >> bind(f,v4());\n";
170 _out <<
"\n _out << cbind(f,v4());\n";
171 _out <<
cbind(f,v4());
175 _out <<
"\nTest variations of outputing for Vectors and VectorSlices\n";
177 _out <<
"\n _out << cbind(f.ignore_dim(),v1);\n";
178 _out <<
cbind(f.ignore_dim(),v1);
180 _out <<
"\n _out << cbind(f.no_ignore_dim(), const_cast<const DVectorSlice&>(v1()) );\n";
183 _out <<
"\n _out << cbind(f.ignore_dim().no_insert_newlines(),v1) << cbind(f,v1) << endl;\n";
184 _out <<
cbind(f.ignore_dim().no_insert_newlines(),v1) <<
cbind(f,v1) << endl;
190 _out <<
"\nTest inputing and outputing DMatrix and DMatrixSlice objects (eat_comment_lines(_in,'*') called inbetween)\n"
191 <<
" DMatrix m1, m2(2,2), m3, m4(2,2);\n"
192 <<
"\n _in >> m1;\n";
193 DMatrix m1, m2(2,2), m3, m4(2,2);
195 _out <<
"\n _out << cbind(f.no_ignore_dim().insert_newlines(),m1);\n";
196 _out <<
cbind(f.no_ignore_dim().insert_newlines(),m1);
200 _out <<
"\n _in >> m2;\n";
202 _out <<
"\n _out << cbind(f,m2);\n";
207 _out <<
"\n _in >> m3;\n";
209 _out <<
"\n _out << cbind(f,m3());\n";
210 _out <<
cbind(f,m3());
214 _out <<
"\n _in >> m4();\n";
216 _out <<
"\n _out << cbind(f,m4());\n";
217 _out <<
cbind(f,m4());
221 _out <<
" m1.resize(0,0); m3.resize(0,0);\n"
222 <<
"\n _in >> bind(f,m1);\n";
223 m1.resize(0,0); m3.resize(0,0);
225 _out <<
"\n _out << cbind(f,m1);\n";
230 _out <<
"\n _in >> bind(f,m2);\n";
232 _out <<
"\n _out << cbind(f,m2);\n";
237 _out <<
"\n _in >> bind(f,m3);\n";
239 _out <<
"\n _out << cbind(f,m3());\n";
240 _out <<
cbind(f,m3());
244 _out <<
"\n _in >> bind(f,m4());\n";
246 _out <<
"\n _out << cbind(f,m4());\n";
247 _out <<
cbind(f,m4());
251 _out <<
"\n _in >> bind(f.ignore_dim(),m1);\n";
252 _in >>
bind(f.ignore_dim(),m1);
253 _out <<
"\n _out << cbind(f,m1);\n";
258 _out <<
"\n _in >> bind(f,m2);\n";
260 _out <<
"\n _out << cbind(f,m2);\n";
265 _out <<
"\n _in >> bind(f,m3);\n";
267 _out <<
"\n _out << cbind(f,m3());\n";
268 _out <<
cbind(f,m3());
272 _out <<
"\n _in >> bind(f,m4());\n";
274 _out <<
"\n _out << cbind(f,m4());\n";
275 _out <<
cbind(f,m4());
279 _out <<
"\nTest variations of outputing for DMatrix and DMatrixSlice objects\n";
281 _out <<
"\n _out << cbind(f.ignore_dim(),m1);\n";
282 _out <<
cbind(f.ignore_dim(),m1);
284 _out <<
"\n _out << cbind(f.no_ignore_dim(), const_cast<const DMatrixSlice&>(m1()) );\n";
287 _out <<
"\n _out << 2*m1.rows() << ' ' << m1.cols() << endl << cbind(f.ignore_dim(),m1) << cbind(f,m1);\n";
288 _out << 2*m1.rows() <<
' ' << m1.cols() << endl <<
cbind(f.ignore_dim(),m1) <<
cbind(f,m1);
290 _out <<
"\nIf you read this then no unexpected exceptions occured.\n";
293 catch(
const std::exception& excpt) {
294 _out <<
"\nCaught a std::exception: " << excpt.what() << endl;
297 _out <<
"\nCaught and unknown exception\n";
bound_format< T > bind(const format &f, T &obj)
const_bound_format< T > cbind(const format &f, const T &obj)
void TestDenseLinAlgPackIO(std::istream &in, std::ostream &out)