DenseMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DENSEMATRIX_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DENSEMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
44 #include <blaze/math/shims/Reset.h>
49 #include <blaze/system/Inline.h>
51 #include <blaze/util/DisableIf.h>
52 #include <blaze/util/EnableIf.h>
53 #include <blaze/util/Unused.h>
54 
55 
56 namespace blaze {
57 
58 //=================================================================================================
59 //
60 // CLASS DEFINITION
61 //
62 //=================================================================================================
63 
64 //*************************************************************************************************
78 template< typename MT // Type of the dense matrix
79  , bool SO > // Storage order
81  : public Matrix<MT,SO>
82 {};
83 //*************************************************************************************************
84 
85 
86 
87 
88 //=================================================================================================
89 //
90 // GLOBAL FUNCTIONS
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
97 template< typename MT, bool SO >
98 typename MT::ElementType* data( DenseMatrix<MT,SO>& dm ) noexcept;
99 
100 template< typename MT, bool SO >
101 typename MT::ElementType* data( const DenseMatrix<MT,SO>& dm ) noexcept;
102 
103 template< typename MT, bool SO >
104 size_t spacing( const DenseMatrix<MT,SO>& dm ) noexcept;
106 //*************************************************************************************************
107 
108 
109 //*************************************************************************************************
120 template< typename MT // Type of the matrix
121  , bool SO > // Storage order of the matrix
122 BLAZE_ALWAYS_INLINE auto data_backend( DenseMatrix<MT,SO>& dm ) noexcept
124 {
125  UNUSED_PARAMETER( dm );
126 
127  return nullptr;
128 }
130 //*************************************************************************************************
131 
132 
133 //*************************************************************************************************
143 template< typename MT // Type of the matrix
144  , bool SO > // Storage order of the matrix
145 BLAZE_ALWAYS_INLINE auto data_backend( DenseMatrix<MT,SO>& dm ) noexcept
146  -> EnableIf_t< HasMutableDataAccess_v<MT>, typename MT::ElementType* >
147 {
148  return (~dm).data();
149 }
151 //*************************************************************************************************
152 
153 
154 //*************************************************************************************************
167 template< typename MT // Type of the matrix
168  , bool SO > // Storage order of the matrix
170 {
171  return data_backend( ~dm );
172 }
173 //*************************************************************************************************
174 
175 
176 //*************************************************************************************************
187 template< typename MT // Type of the matrix
188  , bool SO > // Storage order of the matrix
189 BLAZE_ALWAYS_INLINE auto data_backend( const DenseMatrix<MT,SO>& dm ) noexcept
190  -> DisableIf_t< HasConstDataAccess_v<MT>, typename MT::ElementType* >
191 {
192  UNUSED_PARAMETER( dm );
193 
194  return nullptr;
195 }
197 //*************************************************************************************************
198 
199 
200 //*************************************************************************************************
210 template< typename MT // Type of the matrix
211  , bool SO > // Storage order of the matrix
212 BLAZE_ALWAYS_INLINE auto data_backend( const DenseMatrix<MT,SO>& dm ) noexcept
213  -> EnableIf_t< HasConstDataAccess_v<MT>, typename MT::ElementType* >
214 {
215  return (~dm).data();
216 }
218 //*************************************************************************************************
219 
220 
221 //*************************************************************************************************
234 template< typename MT // Type of the matrix
235  , bool SO > // Storage order of the matrix
237 {
238  return data_backend( ~dm );
239 }
240 //*************************************************************************************************
241 
242 
243 //*************************************************************************************************
250 template< typename MT // Type of the matrix
251  , bool SO > // Storage order of the matrix
252 BLAZE_ALWAYS_INLINE size_t spacing( const DenseMatrix<MT,SO>& dm ) noexcept
253 {
254  return (~dm).spacing();
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
270 template< typename MT > // Type of the matrix
271 inline auto resetLower_backend( DenseMatrix<MT,false>& dm ) -> DisableIf_t< IsUpper_v<MT> >
272 {
273  const size_t m( (~dm).rows() );
274  const size_t n( (~dm).columns() );
275 
276  for( size_t i=1UL; i<m; ++i ) {
277  const size_t jend( min( i, n ) );
278  for( size_t j=0UL; j<jend; ++j ) {
279  reset( (~dm)(i,j) );
280  }
281  }
282 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
298 template< typename MT > // Type of the matrix
299 inline auto resetLower_backend( DenseMatrix<MT,true>& dm ) -> DisableIf_t< IsUpper_v<MT> >
300 {
301  const size_t m ( (~dm).rows() );
302  const size_t n ( (~dm).columns() );
303  const size_t jend( min( m, n ) );
304 
305  for( size_t j=0UL; j<jend; ++j ) {
306  for( size_t i=j+1UL; i<m; ++i ) {
307  reset( (~dm)(i,j) );
308  }
309  }
310 }
312 //*************************************************************************************************
313 
314 
315 //*************************************************************************************************
325 template< typename MT // Type of the matrix
326  , bool SO > // Storage order of the matrix
327 inline auto resetLower_backend( DenseMatrix<MT,SO>& dm ) -> EnableIf_t< IsUpper_v<MT> >
328 {
329  UNUSED_PARAMETER( dm );
330 }
332 //*************************************************************************************************
333 
334 
335 //*************************************************************************************************
345 template< typename MT // Type of the matrix
346  , bool SO > // Storage order of the matrix
347 inline void resetLower( DenseMatrix<MT,SO>& dm )
348 {
349  resetLower_backend( ~dm );
350 }
352 //*************************************************************************************************
353 
354 
355 //*************************************************************************************************
366 template< typename MT > // Type of the matrix
367 inline auto resetUpper_backend( DenseMatrix<MT,false>& dm ) -> DisableIf_t< IsLower_v<MT> >
368 {
369  const size_t m ( (~dm).rows() );
370  const size_t n ( (~dm).columns() );
371  const size_t iend( min( m, n ) );
372 
373  for( size_t i=0UL; i<iend; ++i ) {
374  for( size_t j=i+1UL; j<n; ++j ) {
375  reset( (~dm)(i,j) );
376  }
377  }
378 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
394 template< typename MT > // Type of the matrix
395 inline auto resetUpper_backend( DenseMatrix<MT,true>& dm ) -> DisableIf_t< IsLower_v<MT> >
396 {
397  const size_t m( (~dm).rows() );
398  const size_t n( (~dm).columns() );
399 
400  for( size_t j=1UL; j<n; ++j ) {
401  const size_t iend( min( j, m ) );
402  for( size_t i=0UL; i<iend; ++i ) {
403  reset( (~dm)(i,j) );
404  }
405  }
406 }
408 //*************************************************************************************************
409 
410 
411 //*************************************************************************************************
421 template< typename MT // Type of the matrix
422  , bool SO > // Storage order of the matrix
423 inline auto resetUpper_backend( DenseMatrix<MT,SO>& dm ) -> EnableIf_t< IsLower_v<MT> >
424 {
425  UNUSED_PARAMETER( dm );
426 }
428 //*************************************************************************************************
429 
430 
431 //*************************************************************************************************
441 template< typename MT // Type of the matrix
442  , bool SO > // Storage order of the matrix
443 inline void resetUpper( DenseMatrix<MT,SO>& dm )
444 {
445  resetUpper_backend( ~dm );
446 }
448 //*************************************************************************************************
449 
450 } // namespace blaze
451 
452 #endif
Headerfile for the generic min algorithm.
Header file for the UNUSED_PARAMETER function template.
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
Header file for the reset shim.
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
Header file for the IsLower type trait.
Header file for the EnableIf class template.
Header file for the HasConstDataAccess type trait.
Header file for the Matrix base class.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:109
Header file for the HasMutableDataAccess type trait.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the IsUpper type trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
System settings for the inline keywords.