Boost logo

Ublas :

From: Gunter Winkler (guwi17_at_[hidden])
Date: 2006-12-19 03:42:56


Hello,

i added another example to my page: I/O of sparse matrices using triplets.

http://www.bauv.unibw-muenchen.de/~winkler/ublas/examples/index.html

The basic syntax is:

  cout << io::sparse(RM) << endl;
  cin >> io::sparse(RM);

(Should we add this to io.hpp?)

Below is a sample output.

$ echo '[1,1]((0,0:2))[2,2]((1,0:1),(2,0:1))' | ./sparse_io
[5,5]((0,0:1),(0,2:1);(1,0:1);(2,4:1);(4,4:1))
[5,5]((0,0:1),(1,0:1);(0,2:1);(2,4:1),(4,4:1))
[1,1]((2))
[2,2]((0,0),(1,0))
$ echo '' | ./sparse_io | ./sparse_io
[5,5]((0,0:1),(0,2:1);(1,0:1);(2,4:1);(4,4:1))
[5,5]((0,0:1),(1,0:1);(0,2:1);(2,4:1),(4,4:1))
[5,5]((1,0,1,0,0),(1,0,0,0,0),(0,0,0,0,1),(0,0,0,0,0),(0,0,0,0,1))
[5,5]((1,0,1,0,0),(1,0,0,0,0),(0,0,0,0,1),(0,0,0,0,0),(0,0,0,0,1))
$ echo '[1,1]((0,0:2))[2,2]((1,1:1),(2,0:1))' | ./sparse_io
[5,5]((0,0:1),(0,2:1);(1,0:1);(2,4:1);(4,4:1))
[5,5]((0,0:1),(1,0:1);(0,2:1);(2,4:1),(4,4:1))
Check failed in file boost/numeric/ublas/matrix_sparse.hpp at line 3081:
(filled1_ == element1 + 2 && (filled2_ == zero_based (index1_data_ [filled1_ -
2]) || index2_data_ [filled2_ - 1] < k_based (element2)))
terminate called after throwing an instance
of 'boost::numeric::ublas::external_logic'
  what(): external logic
Abgebrochen
(The error was expected because the data was row major, but container was
column major)

mfg
Gunter