43 for (
Index i=3; i<10; ++i)
50 cout <<
"\nM = \n" <<
M;
181 cout <<
"Testing the new simplified Sparse matrices:\n";
184 cout <<
"Empty A: " << A <<
"\n";
189 cout <<
"Diagonal A:\n" << A <<
"\n";
192 cout <<
"b:\n" << b <<
"\n";
195 cout <<
"c = A*b (should be [11,44,99]):\n" << c <<
"\n";
201 cout <<
"D:\n" << D <<
"\n";
205 cout <<
"E = A*D (should be [11,22],[44,88],[99,198]):\n" << E <<
"\n";
210 cout <<
"Testing transpose for the new simplified sparse matrices:\n";
213 Index r[] = {0, 1, 1, 2, 2, 2, 3, 1, 3};
214 Index c[] = {0, 0, 1, 1, 2, 3, 3, 4, 4};
215 for (
Index i=0; i<9; i++ )
218 cout <<
"B:\n" << B <<
"\n";
224 cout <<
"A:\n" << A <<
"\n";
226 cout <<
"Testing with a fully occupied matrix:\n";
228 for (
Index ri=0; ri<4; ri++ )
229 for (
Index ci=0; ci<5; ci++ )
234 cout <<
"B:\n" << B <<
"\n";
236 cout <<
"A:\n" << A <<
"\n";
241 cout <<
"Testing sparse-sparse matrix multiplication:\n";
244 Index r[] = {0, 1, 1, 2, 2, 2, 3, 1, 3};
245 Index c[] = {0, 0, 1, 1, 2, 3, 3, 4, 4};
246 for (
Index i=0; i<9; i++ )
253 cout <<
"A:\n" << A <<
"\n";
258 cout <<
"Testing sparse copying:\n";
261 Index r[] = {0, 1, 1, 2, 2, 2, 3, 1, 3};
262 Index c[] = {0, 0, 1, 1, 2, 3, 3, 4, 4};
263 for (
Index i=0; i<9; i++ )
266 cout <<
"B:\n" << B <<
"\n";
272 cout <<
"A:\n" << A <<
"\n";
274 for (
Index i=0; i<100; ++i )
280 cout <<
"A now:\n" << A <<
"\n";
285 cout <<
"Test to insert row in sparse:\n";
290 Index r[] = {0, 1, 1, 2, 2, 2, 3, 1, 3};
291 Index c[] = {0, 0, 1, 1, 2, 3, 3, 4, 4};
292 for (
Index i=0; i<9; i++ )
295 cout <<
"B["<<B.
nrows()<<
","<<B.
ncols()<<
"]:\n" << B <<
"\n";
296 cout <<
"v:\n" << v <<
"\n";
300 cout <<
"B (after insertion):\n" << B <<
"\n";
305 cout <<
"Test Sparse-Sparse multiplication reading matrices from xml "
313 cout <<
" Reading " << a <<
"...";
315 cout <<
"done.\n Reading " << b <<
"...";
318 }
catch (runtime_error e) {
319 cerr << e.what () << endl;
323 cout <<
" Performing multiplication...";
329 cout <<
" Writing product to file: test45.xml...";
332 }
catch (runtime_error e) {
333 cerr << e.what () << endl;
339 cout <<
"Test transpose with large matrix read from xml file:\n";
345 cout <<
" Reading " << a <<
"...";
348 }
catch (runtime_error e) {
349 cerr << e.what () << endl;
358 cout <<
" Writing transpose(A) to file test46.xml" << endl;
360 }
catch (runtime_error e) {
361 cerr << e.what () << endl;
369 cout <<
"Test make Identity matrix:\n";
375 cout <<
"A:\n" << A << endl;
380 cout <<
"Test absolute values of sparse matrix:\n";
383 Index r[] = {0, 1, 1, 2, 2, 2, 3, 1, 3};
384 Index c[] = {0, 0, 1, 1, 2, 3, 3, 4, 4};
385 for (
Index i=0; i<9; i++ )
387 cout <<
"B:\n" << B << endl;
392 cout <<
"abs(B):\n" << A << endl;
398 cout <<
"Testing sparse adding:\n";
403 for (
Index i=0; i<2; i++ )
407 Index rc[] = {0, 1, 2};
408 Index cc[] = {0, 1, 2};
409 for (
Index i=0; i<3; i++ )
412 cout <<
"B:\n" << B <<
"\n";
413 cout <<
"C:\n" << C <<
"\n";
417 cout <<
"A=B+C:\n" << A <<
"\n";
420 cout <<
"D=B-C:\n" << D <<
"\n";