So-Bogus
A c++ sparse block matrix library aimed at Second Order cone problems
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Zero.hpp
1 /*
2  * This file is part of bogus, a C++ sparse block matrix library.
3  *
4  * Copyright 2016 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 #ifndef BOGUS_BLOCK_ZERO_HPP
12 #define BOGUS_BLOCK_ZERO_HPP
13 
14 #include "IterableBlockObject.hpp"
15 
16 namespace bogus {
17 
19 
20 template< typename Scalar >
21 class Zero : public IterableBlockObject<Zero<Scalar> > {
22 public:
24 
25  typedef typename Base::Index Index ;
26  typedef typename Base::ConstTransposeReturnType ConstTransposeReturnType ;
27 
28  explicit Zero( Index rows = 0, Index cols = 0 )
29  : m_rows(rows), m_cols(cols)
30  {
31  m_rowOffsets[0] = 0 ;
32  m_rowOffsets[1] = rows ;
33  m_colOffsets[0] = 0 ;
34  m_colOffsets[1] = cols ;
35  }
36 
37  Index rows() const { return m_rows ; }
38  Index cols() const { return m_cols ; }
39 
40  Index blockRows( Index ) const { return rows() ; }
41  Index blockCols( Index ) const { return cols() ; }
42 
43  Index rowsOfBlocks() const { return 1 ; }
44  Index colsOfBlocks() const { return 1 ; }
45 
46  const Index *rowOffsets( ) const { return &m_rowOffsets ; }
47  const Index *colOffsets( ) const { return &m_colOffsets ; }
48 
49  ConstTransposeReturnType transpose() const { *this; }
50 
51  template < bool DoTranspose, typename RhsT, typename ResT >
52  void multiply( const RhsT& , ResT& res, Scalar = 1, Scalar beta = 0 ) const ;
53 
54  // IterableBlockObject
55 
56  Index size() const { return 0 ; }
57 
58  template <typename Func>
59  void eachBlockOfRow( const Index, Func ) {}
60  template <typename Func>
61  void eachBlockOfCol( const Index, Func ) {}
62 
63  template < bool DoTranspose, typename RhsT, typename ResT, typename PreOp >
64  void rowMultiplyPrecompose( const Index, const RhsT&, ResT&, const PreOp &) const
65  {}
66  template < bool DoTranspose, typename RhsT, typename ResT, typename PostOp >
67  void colMultiplyPostcompose( const Index, const RhsT&, ResT&, const PostOp &) const
68  {}
69 
70 private:
71  const Index m_rows ;
72  const Index m_cols ;
73  Index m_rowOffsets[2] ;
74  Index m_colOffsets[2] ;
75 
76 };
77 
78 template < typename Scalar_ >
79 struct BlockMatrixTraits< Zero< Scalar_ > >
80  : public BlockMatrixTraits< BlockObjectBase< Zero< Scalar_ > > >
81 {
82  typedef Scalar_ Scalar ;
83 
84  enum {
85  is_symmetric = 1,
86  } ;
87 
91 } ;
92 
93 
94 } //bogus
95 
96 #endif
Definition: Traits.hpp:19
Base class for matrix-like objects that define a block structure, but not a block type...
Definition: IterableBlockObject.hpp:22
Representation of the null matrix.
Definition: Zero.hpp:21