So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
SparseBlockMatrix.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_SPARSEBLOCKMATRIX_HPP
13 #define BOGUS_SPARSEBLOCKMATRIX_HPP
14 
15 #include "SparseBlockMatrixBase.hpp"
16 
17 namespace bogus
18 {
19 
21 template < typename BlockT, int Flags >
22 struct BlockMatrixTraits< SparseBlockMatrix< BlockT, Flags > >
23  : public BlockMatrixTraits< BlockObjectBase< SparseBlockMatrix< BlockT, Flags > > >
24 {
26  typedef typename BaseTraits::Index Index;
27  typedef typename BlockTraits< BlockT >::Scalar Scalar ;
28 
29  enum {
30  is_symmetric = !!( Flags & flags::SYMMETRIC ),
33  } ;
34 
35 
36  typedef BOGUS_DEFAULT_BLOCK_PTR_TYPE BlockPtr ;
37  typedef BlockT BlockType ;
38  typedef typename ResizableSequenceContainer< BlockType >::Type BlocksArrayType ;
39 
40  enum {
41  is_compressed = !!( ~Flags & flags::UNCOMPRESSED ),
42  is_col_major = !!( Flags & flags::COL_MAJOR ),
43  flags = Flags
44  } ;
45 
47 
48 } ;
49 
51 
56 template < typename BlockT, int Flags >
57 class SparseBlockMatrix : public SparseBlockMatrixBase< SparseBlockMatrix< BlockT, Flags > >
58 {
59 public:
61 
63  {
64  }
65 
66  template < typename Index >
67  SparseBlockMatrix( Index rowsOfBlocks, Index colsOfBlocks )
68  : Base()
69  {
70  BOGUS_STATIC_ASSERT( Base::has_fixed_size_blocks,
71  BLOCKS_MUST_HAVE_FIXED_DIMENSIONS
72  ) ;
73  Base::setRows( rowsOfBlocks ) ;
74  Base::setCols( colsOfBlocks ) ;
75  }
76 
77  template < typename RhsT >
79  {
80  Base::operator= ( rhs.derived() ) ;
81  }
82 
83  template < typename RhsT >
84  SparseBlockMatrix& operator=( const BlockObjectBase< RhsT >& rhs )
85  {
86  return ( Base::operator= ( rhs.derived() ) ).derived() ;
87  }
88 
89 } ;
90 
91 // Specialization for block matrix of MappedSparseBlockMatrix
92 template < typename BlockT, int Flags >
93 struct BlockTraits< SparseBlockMatrix< BlockT, Flags > >
94 {
96 
97  typedef typename BlockType::Scalar Scalar ;
98  typedef SparseBlockMatrix
99  < typename BlockType::TransposeBlockType, Flags ^ flags::COL_MAJOR >
101 
102  enum {
103  RowsAtCompileTime = internal::DYNAMIC,
104  ColsAtCompileTime = internal::DYNAMIC,
105  uses_plain_array_storage = 0,
108  } ;
109 } ;
110 
111 }
112 
113 #endif // SPARSEBLOCKMATRIX_HH
Definition: Traits.hpp:19
Uncompressed sparse block index.
Definition: SparseBlockIndex.hpp:86
const Derived & derived() const
Returns a const reference to the implementation.
Definition: BlockObjectBase.hpp:25
Sparse Block Matrix.
Definition: SparseBlockMatrix.hpp:57
Base class for matrix-like objects that define a block structure, but not a block type...
Definition: IterableBlockObject.hpp:22
Definition: Traits.hpp:29
Store only half the matrix, or rather the triangular part for which inner &lt;= outer,.
Definition: Constants.hpp:64
Base class for anything block.
Definition: BlockObjectBase.hpp:22
Use an uncompressed index.
Definition: Constants.hpp:56
Store and index blocks in a column major way.
Definition: Constants.hpp:58
Base class for SparseBlockMatrix.
Definition: SparseBlockMatrixBase.hpp:36