Blaze  3.6
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>
50 #include <blaze/system/Inline.h>
52 #include <blaze/util/DisableIf.h>
53 #include <blaze/util/EnableIf.h>
54 #include <blaze/util/MaybeUnused.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // CLASS DEFINITION
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
79 template< typename MT // Type of the dense matrix
80  , bool SO > // Storage order
82  : public Matrix<MT,SO>
83 {};
84 //*************************************************************************************************
85 
86 
87 
88 
89 //=================================================================================================
90 //
91 // GLOBAL FUNCTIONS
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
98 template< typename MT, bool SO >
99 typename MT::ElementType* data( DenseMatrix<MT,SO>& dm ) noexcept;
100 
101 template< typename MT, bool SO >
102 const typename MT::ElementType* data( const DenseMatrix<MT,SO>& dm ) noexcept;
103 
104 template< typename MT, bool SO >
105 size_t spacing( const DenseMatrix<MT,SO>& dm ) noexcept;
107 //*************************************************************************************************
108 
109 
110 //*************************************************************************************************
121 template< typename MT // Type of the matrix
122  , bool SO > // Storage order of the matrix
123 BLAZE_ALWAYS_INLINE auto data_backend( DenseMatrix<MT,SO>& dm ) noexcept
124  -> DisableIf_t< HasMutableDataAccess_v<MT>, typename MT::ElementType* >
125 {
126  MAYBE_UNUSED( dm );
127 
128  return nullptr;
129 }
131 //*************************************************************************************************
132 
133 
134 //*************************************************************************************************
144 template< typename MT // Type of the matrix
145  , bool SO > // Storage order of the matrix
146 BLAZE_ALWAYS_INLINE auto data_backend( DenseMatrix<MT,SO>& dm ) noexcept
147  -> EnableIf_t< HasMutableDataAccess_v<MT>, typename MT::ElementType* >
148 {
149  return (~dm).data();
150 }
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
168 template< typename MT // Type of the matrix
169  , bool SO > // Storage order of the matrix
170 BLAZE_ALWAYS_INLINE typename MT::ElementType* data( DenseMatrix<MT,SO>& dm ) noexcept
171 {
172  return data_backend( ~dm );
173 }
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
188 template< typename MT // Type of the matrix
189  , bool SO > // Storage order of the matrix
190 BLAZE_ALWAYS_INLINE auto data_backend( const DenseMatrix<MT,SO>& dm ) noexcept
191  -> DisableIf_t< HasConstDataAccess_v<MT>, const typename MT::ElementType* >
192 {
193  MAYBE_UNUSED( dm );
194 
195  return nullptr;
196 }
198 //*************************************************************************************************
199 
200 
201 //*************************************************************************************************
211 template< typename MT // Type of the matrix
212  , bool SO > // Storage order of the matrix
213 BLAZE_ALWAYS_INLINE auto data_backend( const DenseMatrix<MT,SO>& dm ) noexcept
214  -> EnableIf_t< HasConstDataAccess_v<MT>, const typename MT::ElementType* >
215 {
216  return (~dm).data();
217 }
219 //*************************************************************************************************
220 
221 
222 //*************************************************************************************************
235 template< typename MT // Type of the matrix
236  , bool SO > // Storage order of the matrix
237 BLAZE_ALWAYS_INLINE const typename MT::ElementType* data( const DenseMatrix<MT,SO>& dm ) noexcept
238 {
239  return data_backend( ~dm );
240 }
241 //*************************************************************************************************
242 
243 
244 //*************************************************************************************************
251 template< typename MT // Type of the matrix
252  , bool SO > // Storage order of the matrix
253 BLAZE_ALWAYS_INLINE size_t spacing( const DenseMatrix<MT,SO>& dm ) noexcept
254 {
255  return (~dm).spacing();
256 }
257 //*************************************************************************************************
258 
259 
260 //*************************************************************************************************
271 template< typename MT > // Type of the matrix
272 inline auto resetLower_backend( DenseMatrix<MT,false>& dm )
273  -> DisableIf_t< IsUniform_v<MT> || IsUpper_v<MT> >
274 {
275  using blaze::reset;
276 
277  const size_t m( (~dm).rows() );
278  const size_t n( (~dm).columns() );
279 
280  for( size_t i=1UL; i<m; ++i ) {
281  const size_t jend( min( i, n ) );
282  for( size_t j=0UL; j<jend; ++j ) {
283  reset( (~dm)(i,j) );
284  }
285  }
286 }
288 //*************************************************************************************************
289 
290 
291 //*************************************************************************************************
302 template< typename MT > // Type of the matrix
303 inline auto resetLower_backend( DenseMatrix<MT,true>& dm )
304  -> DisableIf_t< IsUniform_v<MT> || IsUpper_v<MT> >
305 {
306  using blaze::reset;
307 
308  const size_t m ( (~dm).rows() );
309  const size_t n ( (~dm).columns() );
310  const size_t jend( min( m, n ) );
311 
312  for( size_t j=0UL; j<jend; ++j ) {
313  for( size_t i=j+1UL; i<m; ++i ) {
314  reset( (~dm)(i,j) );
315  }
316  }
317 }
319 //*************************************************************************************************
320 
321 
322 //*************************************************************************************************
332 template< typename MT // Type of the matrix
333  , bool SO > // Storage order of the matrix
334 inline auto resetLower_backend( DenseMatrix<MT,SO>& dm )
335  -> EnableIf_t< IsUniform_v<MT> && !IsUpper_v<MT> >
336 {
337  using blaze::reset;
338 
339  reset( ~dm );
340 }
342 //*************************************************************************************************
343 
344 
345 //*************************************************************************************************
355 template< typename MT // Type of the matrix
356  , bool SO > // Storage order of the matrix
357 inline auto resetLower_backend( DenseMatrix<MT,SO>& dm )
358  -> EnableIf_t< IsUpper_v<MT> >
359 {
360  MAYBE_UNUSED( dm );
361 }
363 //*************************************************************************************************
364 
365 
366 //*************************************************************************************************
376 template< typename MT // Type of the matrix
377  , bool SO > // Storage order of the matrix
378 inline void resetLower( DenseMatrix<MT,SO>& dm )
379 {
380  resetLower_backend( ~dm );
381 }
383 //*************************************************************************************************
384 
385 
386 //*************************************************************************************************
397 template< typename MT > // Type of the matrix
398 inline auto resetUpper_backend( DenseMatrix<MT,false>& dm )
399  -> DisableIf_t< IsUniform_v<MT> || IsLower_v<MT> >
400 {
401  using blaze::reset;
402 
403  const size_t m ( (~dm).rows() );
404  const size_t n ( (~dm).columns() );
405  const size_t iend( min( m, n ) );
406 
407  for( size_t i=0UL; i<iend; ++i ) {
408  for( size_t j=i+1UL; j<n; ++j ) {
409  reset( (~dm)(i,j) );
410  }
411  }
412 }
414 //*************************************************************************************************
415 
416 
417 //*************************************************************************************************
428 template< typename MT > // Type of the matrix
429 inline auto resetUpper_backend( DenseMatrix<MT,true>& dm )
430  -> DisableIf_t< IsUniform_v<MT> || IsLower_v<MT> >
431 {
432  using blaze::reset;
433 
434  const size_t m( (~dm).rows() );
435  const size_t n( (~dm).columns() );
436 
437  for( size_t j=1UL; j<n; ++j ) {
438  const size_t iend( min( j, m ) );
439  for( size_t i=0UL; i<iend; ++i ) {
440  reset( (~dm)(i,j) );
441  }
442  }
443 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
458 template< typename MT // Type of the matrix
459  , bool SO > // Storage order of the matrix
460 inline auto resetUpper_backend( DenseMatrix<MT,SO>& dm )
461  -> EnableIf_t< IsUniform_v<MT> || !IsLower_v<MT> >
462 {
463  using blaze::reset;
464 
465  reset( ~dm );
466 }
468 //*************************************************************************************************
469 
470 
471 //*************************************************************************************************
481 template< typename MT // Type of the matrix
482  , bool SO > // Storage order of the matrix
483 inline auto resetUpper_backend( DenseMatrix<MT,SO>& dm )
484  -> EnableIf_t< IsLower_v<MT> >
485 {
486  MAYBE_UNUSED( dm );
487 }
489 //*************************************************************************************************
490 
491 
492 //*************************************************************************************************
502 template< typename MT // Type of the matrix
503  , bool SO > // Storage order of the matrix
504 inline void resetUpper( DenseMatrix<MT,SO>& dm )
505 {
506  resetUpper_backend( ~dm );
507 }
509 //*************************************************************************************************
510 
511 } // namespace blaze
512 
513 #endif
Headerfile for the generic min algorithm.
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:170
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the MAYBE_UNUSED function template.
Header file for the reset shim.
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:81
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:253
Header file for the DisableIf class template.
Header file for the IsUniform type trait.
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
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:1162
Header file for the IsLower type trait.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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:114
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.