So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Streams.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2013 Gilles Daviet <gdaviet@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
10 
11 
12 #ifndef BOGUS_BLOCK_STREAMS_HPP
13 #define BOGUS_BLOCK_STREAMS_HPP
14 
15 #include <iostream>
16 #include "SparseBlockMatrix.hpp"
17 #include "SparseBlockIndexComputer.hpp"
18 
19 template < typename Derived >
20 std::ostream& operator<<( std::ostream &out, const bogus::SparseBlockMatrixBase< Derived > &sbm )
21 {
22 
24  IndexComputerType indexComputer( sbm ) ;
25  typedef typename IndexComputerType::ReturnType SourceIndexType ;
26  const SourceIndexType &sourceIndex = indexComputer.get() ;
27 
28  out << " Total rows: " << sbm.rows() << " / cols: " << sbm.cols() << std::endl ;
29  for ( unsigned i = 0 ; i < (unsigned) sourceIndex.outerSize() ; ++ i )
30  {
31  out << "Row " << i << ": " ;
32  for( typename SourceIndexType::InnerIterator it( sourceIndex, i ) ;
33  it ; ++ it )
34  {
35  out << " " << it.inner() << "@" << it.ptr() << "; " ;
36  }
37  out << std::endl ;
38  }
39  out << " Blocks (" << sbm.nBlocks() << ")" << std::endl ;
40  for ( unsigned i = 0 ; i < sbm.nBlocks() ; ++ i )
41  {
42  out << sbm.block(i) << std::endl ;
43  out << "^-- " << i << std::endl ;
44  }
45  return out ;
46 }
47 
48 #endif
Definition: SparseBlockIndexComputer.hpp:75