SparseMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SPARSEMATRIX_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SPARSEMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
47 #include <blaze/util/DisableIf.h>
48 #include <blaze/util/EnableIf.h>
49 #include <blaze/util/Unused.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
74 template< typename MT // Type of the sparse matrix
75  , bool SO > // Storage order
76 struct SparseMatrix
77  : public Matrix<MT,SO>
78 {};
79 //*************************************************************************************************
80 
81 
82 
83 
84 //=================================================================================================
85 //
86 // GLOBAL FUNCTIONS
87 //
88 //=================================================================================================
89 
90 //*************************************************************************************************
101 template< typename MT > // Type of the matrix
102 inline DisableIf_< IsUpper<MT> > resetLower_backend( SparseMatrix<MT,false>& dm )
103 {
104  const size_t m( (~dm).rows() );
105 
106  for( size_t i=1UL; i<m; ++i ) {
107  (~dm).erase( i, (~dm).begin( i ), (~dm).lowerBound( i, i ) );
108  }
109 }
111 //*************************************************************************************************
112 
113 
114 //*************************************************************************************************
125 template< typename MT > // Type of the matrix
126 inline DisableIf_< IsUpper<MT> > resetLower_backend( SparseMatrix<MT,true>& dm )
127 {
128  const size_t m ( (~dm).rows() );
129  const size_t n ( (~dm).columns() );
130  const size_t jend( min( m, n ) );
131 
132  for( size_t j=0UL; j<jend; ++j ) {
133  (~dm).erase( j, (~dm).lowerBound( j+1UL, j ), (~dm).end( j ) );
134  }
135 }
137 //*************************************************************************************************
138 
139 
140 //*************************************************************************************************
150 template< typename MT // Type of the matrix
151  , bool SO > // Storage order of the matrix
152 inline EnableIf_< IsUpper<MT> > resetLower_backend( SparseMatrix<MT,SO>& dm )
153 {
154  UNUSED_PARAMETER( dm );
155 }
157 //*************************************************************************************************
158 
159 
160 //*************************************************************************************************
170 template< typename MT // Type of the matrix
171  , bool SO > // Storage order of the matrix
172 inline void resetLower( SparseMatrix<MT,SO>& dm )
173 {
174  resetLower_backend( ~dm );
175 }
177 //*************************************************************************************************
178 
179 
180 //*************************************************************************************************
191 template< typename MT > // Type of the matrix
192 inline DisableIf_< IsLower<MT> > resetUpper_backend( SparseMatrix<MT,false>& dm )
193 {
194  const size_t m ( (~dm).rows() );
195  const size_t n ( (~dm).columns() );
196  const size_t iend( min( m, n ) );
197 
198  for( size_t i=0UL; i<iend; ++i ) {
199  (~dm).erase( i, (~dm).lowerBound( i, i+1UL ), (~dm).end( i ) );
200  }
201 }
203 //*************************************************************************************************
204 
205 
206 //*************************************************************************************************
217 template< typename MT > // Type of the matrix
218 inline DisableIf_< IsLower<MT> > resetUpper_backend( SparseMatrix<MT,true>& dm )
219 {
220  const size_t n( (~dm).columns() );
221 
222  for( size_t j=1UL; j<n; ++j ) {
223  (~dm).erase( j, (~dm).begin( j ), (~dm).lowerBound( j, j ) );
224  }
225 }
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
240 template< typename MT // Type of the matrix
241  , bool SO > // Storage order of the matrix
242 inline EnableIf_< IsLower<MT> > resetUpper_backend( SparseMatrix<MT,SO>& dm )
243 {
244  UNUSED_PARAMETER( dm );
245 }
247 //*************************************************************************************************
248 
249 
250 //*************************************************************************************************
260 template< typename MT // Type of the matrix
261  , bool SO > // Storage order of the matrix
262 inline void resetUpper( SparseMatrix<MT,SO>& dm )
263 {
264  resetUpper_backend( ~dm );
265 }
267 //*************************************************************************************************
268 
269 } // namespace blaze
270 
271 #endif
Headerfile for the generic min algorithm.
Header file for the UNUSED_PARAMETER function template.
const ElementType_< MT > min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1762
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:264
Header file for the EnableIf class template.
Header file for the Matrix base class.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
Header file for the IsUpper type trait.
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81