All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseMatrixProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROXY_DENSEMATRIXPROXY_H_
36 #define _BLAZE_MATH_PROXY_DENSEMATRIXPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
45 #include <blaze/math/shims/Clear.h>
46 #include <blaze/math/shims/Reset.h>
48 #include <blaze/system/Inline.h>
49 #include <blaze/util/Types.h>
50 
51 
52 namespace blaze {
53 
54 //=================================================================================================
55 //
56 // CLASS DEFINITION
57 //
58 //=================================================================================================
59 
60 //*************************************************************************************************
68 template< typename PT // Type of the proxy
69  , typename MT > // Type of the dense matrix
70 class DenseMatrixProxy : public DenseMatrix< PT, IsColumnMajorMatrix<MT>::value >
71 {
72  public:
73  //**Type definitions****************************************************************************
74  typedef typename MT::Reference Reference;
76  typedef typename MT::Pointer Pointer;
77  typedef typename MT::ConstPointer ConstPointer;
78  typedef typename MT::Iterator Iterator;
79  typedef typename MT::ConstIterator ConstIterator;
80  //**********************************************************************************************
81 
82  //**Data access functions***********************************************************************
85  inline Reference operator()( size_t i, size_t j ) const;
86 
87  inline Pointer data () const;
88  inline Pointer data ( size_t i ) const;
89  inline Iterator begin ( size_t i ) const;
90  inline ConstIterator cbegin( size_t i ) const;
91  inline Iterator end ( size_t i ) const;
92  inline ConstIterator cend ( size_t i ) const;
94  //**********************************************************************************************
95 
96  //**Utility functions***************************************************************************
99  inline size_t rows() const;
100  inline size_t columns() const;
101  inline size_t spacing() const;
102  inline size_t capacity() const;
103  inline size_t capacity( size_t i ) const;
104  inline size_t nonZeros() const;
105  inline size_t nonZeros( size_t i ) const;
106  inline void reset() const;
107  inline void reset( size_t i ) const;
108  inline void clear() const;
109  inline void resize( size_t m, size_t n, bool preserve=true ) const;
110  inline void extend( size_t m, size_t n, bool preserve=true ) const;
111  inline void reserve( size_t n ) const;
112  inline void transpose() const;
113 
114  template< typename Other > inline void scale( const Other& scalar ) const;
116  //**********************************************************************************************
117 
118  private:
119  //**Compile time checks*************************************************************************
123  //**********************************************************************************************
124 };
125 //*************************************************************************************************
126 
127 
128 
129 
130 //=================================================================================================
131 //
132 // DATA ACCESS FUNCTIONS
133 //
134 //=================================================================================================
135 
136 //*************************************************************************************************
143 template< typename PT // Type of the proxy
144  , typename MT > // Type of the dense matrix
146  DenseMatrixProxy<PT,MT>::operator()( size_t i, size_t j ) const
147 {
148  return (~*this).get()(i,j);
149 }
150 //*************************************************************************************************
151 
152 
153 //*************************************************************************************************
164 template< typename PT // Type of the proxy
165  , typename MT > // Type of the dense matrix
167 {
168  return (~*this).get().data();
169 }
170 //*************************************************************************************************
171 
172 
173 //*************************************************************************************************
180 template< typename PT // Type of the proxy
181  , typename MT > // Type of the dense matrix
183 {
184  return (~*this).get().data(i);
185 }
186 //*************************************************************************************************
187 
188 
189 //*************************************************************************************************
200 template< typename PT // Type of the proxy
201  , typename MT > // Type of the dense matrix
202 inline typename DenseMatrixProxy<PT,MT>::Iterator
204 {
205  return (~*this).get().begin(i);
206 }
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
221 template< typename PT // Type of the proxy
222  , typename MT > // Type of the dense matrix
225 {
226  return (~*this).get().cbegin(i);
227 }
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
242 template< typename PT // Type of the proxy
243  , typename MT > // Type of the dense matrix
244 inline typename DenseMatrixProxy<PT,MT>::Iterator
246 {
247  return (~*this).get().end(i);
248 }
249 //*************************************************************************************************
250 
251 
252 //*************************************************************************************************
263 template< typename PT // Type of the proxy
264  , typename MT > // Type of the dense matrix
267 {
268  return (~*this).get().cend(i);
269 }
270 //*************************************************************************************************
271 
272 
273 
274 
275 //=================================================================================================
276 //
277 // UTILITY FUNCTIONS
278 //
279 //=================================================================================================
280 
281 //*************************************************************************************************
286 template< typename PT // Type of the proxy
287  , typename MT > // Type of the dense matrix
288 inline size_t DenseMatrixProxy<PT,MT>::rows() const
289 {
290  return (~*this).get().rows();
291 }
292 //*************************************************************************************************
293 
294 
295 //*************************************************************************************************
300 template< typename PT // Type of the proxy
301  , typename MT > // Type of the dense matrix
302 inline size_t DenseMatrixProxy<PT,MT>::columns() const
303 {
304  return (~*this).get().columns();
305 }
306 //*************************************************************************************************
307 
308 
309 //*************************************************************************************************
319 template< typename PT // Type of the proxy
320  , typename MT > // Type of the dense matrix
321 inline size_t DenseMatrixProxy<PT,MT>::spacing() const
322 {
323  return (~*this).get().spacing();
324 }
325 //*************************************************************************************************
326 
327 
328 //*************************************************************************************************
333 template< typename PT // Type of the proxy
334  , typename MT > // Type of the dense matrix
336 {
337  return (~*this).get().capacity();
338 }
339 //*************************************************************************************************
340 
341 
342 //*************************************************************************************************
353 template< typename PT // Type of the proxy
354  , typename MT > // Type of the dense matrix
355 inline size_t DenseMatrixProxy<PT,MT>::capacity( size_t i ) const
356 {
357  return (~*this).get().capacity(i);
358 }
359 //*************************************************************************************************
360 
361 
362 //*************************************************************************************************
367 template< typename PT // Type of the proxy
368  , typename MT > // Type of the dense matrix
370 {
371  return (~*this).get().nonZeros();
372 }
373 //*************************************************************************************************
374 
375 
376 //*************************************************************************************************
387 template< typename PT // Type of the proxy
388  , typename MT > // Type of the dense matrix
389 inline size_t DenseMatrixProxy<PT,MT>::nonZeros( size_t i ) const
390 {
391  return (~*this).get().nonZeros(i);
392 }
393 //*************************************************************************************************
394 
395 
396 //*************************************************************************************************
403 template< typename PT // Type of the proxy
404  , typename MT > // Type of the dense matrix
406 {
407  using blaze::reset;
408 
409  reset( (~*this).get() );
410 }
411 //*************************************************************************************************
412 
413 
414 //*************************************************************************************************
425 template< typename PT // Type of the proxy
426  , typename MT > // Type of the dense matrix
427 inline void DenseMatrixProxy<PT,MT>::reset( size_t i ) const
428 {
429  using blaze::reset;
430 
431  reset( (~*this).get(), i );
432 }
433 //*************************************************************************************************
434 
435 
436 //*************************************************************************************************
443 template< typename PT // Type of the proxy
444  , typename MT > // Type of the dense matrix
446 {
447  using blaze::clear;
448 
449  clear( (~*this).get() );
450 }
451 //*************************************************************************************************
452 
453 
454 //*************************************************************************************************
470 template< typename PT // Type of the proxy
471  , typename MT > // Type of the dense matrix
472 inline void DenseMatrixProxy<PT,MT>::resize( size_t m, size_t n, bool preserve ) const
473 {
474  (~*this).get().resize( m, n, preserve );
475 }
476 //*************************************************************************************************
477 
478 
479 //*************************************************************************************************
494 template< typename PT // Type of the proxy
495  , typename MT > // Type of the dense matrix
496 inline void DenseMatrixProxy<PT,MT>::extend( size_t m, size_t n, bool preserve ) const
497 {
498  (~*this).get().extend( m, n, preserve );
499 }
500 //*************************************************************************************************
501 
502 
503 //*************************************************************************************************
512 template< typename PT // Type of the proxy
513  , typename MT > // Type of the dense matrix
514 inline void DenseMatrixProxy<PT,MT>::reserve( size_t n ) const
515 {
516  (~*this).get().reserve( n );
517 }
518 //*************************************************************************************************
519 
520 
521 //*************************************************************************************************
526 template< typename PT // Type of the proxy
527  , typename MT > // Type of the dense matrix
529 {
530  (~*this).get().transpose();
531 }
532 //*************************************************************************************************
533 
534 
535 //*************************************************************************************************
541 template< typename PT // Type of the proxy
542  , typename MT > // Type of the dense matrix
543 template< typename Other > // Data type of the scalar value
544 inline void DenseMatrixProxy<PT,MT>::scale( const Other& scalar ) const
545 {
546  (~*this).get().scale( scalar );
547 }
548 //*************************************************************************************************
549 
550 
551 
552 
553 //=================================================================================================
554 //
555 // GLOBAL FUNCTIONS
556 //
557 //=================================================================================================
558 
559 //*************************************************************************************************
562 template< typename PT, typename MT >
564  begin( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
565 
566 template< typename PT, typename MT >
568  cbegin( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
569 
570 template< typename PT, typename MT >
572  end( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
573 
574 template< typename PT, typename MT >
576  cend( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
577 
578 template< typename PT, typename MT >
579 BLAZE_ALWAYS_INLINE size_t rows( const DenseMatrixProxy<PT,MT>& proxy );
580 
581 template< typename PT, typename MT >
583 
584 template< typename PT, typename MT >
586 
587 template< typename PT, typename MT >
588 BLAZE_ALWAYS_INLINE size_t capacity( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
589 
590 template< typename PT, typename MT >
592 
593 template< typename PT, typename MT >
594 BLAZE_ALWAYS_INLINE size_t nonZeros( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
595 
596 template< typename PT, typename MT >
598 
599 template< typename PT, typename MT >
600 BLAZE_ALWAYS_INLINE void reset( const DenseMatrixProxy<PT,MT>& proxy, size_t i );
601 
602 template< typename PT, typename MT >
605 //*************************************************************************************************
606 
607 
608 //*************************************************************************************************
621 template< typename PT // Type of the proxy
622  , typename MT > // Type of the dense matrix
624  begin( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
625 {
626  return proxy.begin(i);
627 }
628 //*************************************************************************************************
629 
630 
631 //*************************************************************************************************
644 template< typename PT // Type of the proxy
645  , typename MT > // Type of the dense matrix
647  cbegin( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
648 {
649  return proxy.cbegin(i);
650 }
651 //*************************************************************************************************
652 
653 
654 //*************************************************************************************************
668 template< typename PT // Type of the proxy
669  , typename MT > // Type of the dense matrix
671  end( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
672 {
673  return proxy.end(i);
674 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
692 template< typename PT // Type of the proxy
693  , typename MT > // Type of the dense matrix
695  cend( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
696 {
697  return proxy.cend(i);
698 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
709 template< typename PT // Type of the proxy
710  , typename MT > // Type of the dense matrix
712 {
713  return proxy.rows();
714 }
715 //*************************************************************************************************
716 
717 
718 //*************************************************************************************************
725 template< typename PT // Type of the proxy
726  , typename MT > // Type of the dense matrix
728 {
729  return proxy.columns();
730 }
731 //*************************************************************************************************
732 
733 
734 //*************************************************************************************************
741 template< typename PT // Type of the proxy
742  , typename MT > // Type of the dense matrix
744 {
745  return proxy.capacity();
746 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
763 template< typename PT // Type of the proxy
764  , typename MT > // Type of the dense matrix
765 BLAZE_ALWAYS_INLINE size_t capacity( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
766 {
767  return proxy.capacity(i);
768 }
769 //*************************************************************************************************
770 
771 
772 //*************************************************************************************************
779 template< typename PT // Type of the proxy
780  , typename MT > // Type of the dense matrix
782 {
783  return proxy.nonZeros();
784 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
801 template< typename PT // Type of the proxy
802  , typename MT > // Type of the dense matrix
803 BLAZE_ALWAYS_INLINE size_t nonZeros( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
804 {
805  return proxy.nonZeros(i);
806 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
819 template< typename PT // Type of the proxy
820  , typename MT > // Type of the dense matrix
822 {
823  proxy.reset();
824 }
825 //*************************************************************************************************
826 
827 
828 //*************************************************************************************************
841 template< typename PT // Type of the proxy
842  , typename MT > // Type of the dense matrix
843 BLAZE_ALWAYS_INLINE void reset( const DenseMatrixProxy<PT,MT>& proxy, size_t i )
844 {
845  proxy.reset(i);
846 }
847 //*************************************************************************************************
848 
849 
850 //*************************************************************************************************
859 template< typename PT // Type of the proxy
860  , typename MT > // Type of the dense matrix
862 {
863  proxy.clear();
864 }
865 //*************************************************************************************************
866 
867 } // namespace blaze
868 
869 #endif
MT::ConstIterator ConstIterator
Iterator over constant elements.
Definition: DenseMatrixProxy.h:79
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:237
size_t rows() const
Returns the current number of rows of the represented matrix.
Definition: DenseMatrixProxy.h:288
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:300
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:258
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
void extend(size_t m, size_t n, bool preserve=true) const
Extending the size of the represented matrix.
Definition: DenseMatrixProxy.h:496
Header file for the IsColumnMajorMatrix type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
Iterator begin(size_t i) const
Returns an iterator to the first element of row/column i of the represented matrix.
Definition: DenseMatrixProxy.h:203
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:386
void scale(const Other &scalar) const
Scaling of the matrix by the scalar value scalar ( ).
Definition: DenseMatrixProxy.h:544
Proxy backend for dense matrix types.The DenseMatrixProxy class serves as a backend for the Proxy cla...
Definition: DenseMatrixProxy.h:70
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
Iterator end(size_t i) const
Returns an iterator just past the last element of row/column i of the represented matrix...
Definition: DenseMatrixProxy.h:245
size_t columns() const
Returns the current number of columns of the represented matrix.
Definition: DenseMatrixProxy.h:302
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i of the represented matrix.
Definition: DenseMatrixProxy.h:224
Constraint on the data type.
MT::Iterator Iterator
Iterator over non-constant elements.
Definition: DenseMatrixProxy.h:78
Reference operator()(size_t i, size_t j) const
Function call operator for the direct access to matrix elements.
Definition: DenseMatrixProxy.h:146
void transpose() const
Transposing the represented matrix.
Definition: DenseMatrixProxy.h:528
Header file for the clear shim.
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
Header file for the DenseMatrix base class.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns of the represented matrix.
Definition: DenseMatrixProxy.h:321
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
RawReference get() const
Returning the value of the accessed sparse matrix element.
Definition: MatrixAccessProxy.h:360
size_t capacity() const
Returns the maximum capacity of the represented matrix.
Definition: DenseMatrixProxy.h:335
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
void clear() const
Clearing the represented matrix.
Definition: DenseMatrixProxy.h:445
MT::Reference Reference
Reference to a non-constant matrix value.
Definition: DenseMatrixProxy.h:74
Header file for the reset shim.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
void reserve(size_t n) const
Setting the minimum capacity of the represented matrix.
Definition: DenseMatrixProxy.h:514
Pointer data() const
Low-level data access to matrix elements.
Definition: DenseMatrixProxy.h:166
MT::ConstReference ConstReference
Reference to a constant matrix value.
Definition: DenseMatrixProxy.h:75
MT::Pointer Pointer
Pointer to a non-constant matrix value.
Definition: DenseMatrixProxy.h:76
MT::ConstPointer ConstPointer
Pointer to a constant matrix value.
Definition: DenseMatrixProxy.h:77
void resize(size_t m, size_t n, bool preserve=true) const
Changing the size of the represented matrix.
Definition: DenseMatrixProxy.h:472
size_t nonZeros() const
Returns the number of non-zero elements in the represented matrix.
Definition: DenseMatrixProxy.h:369
void reset() const
Reset to the default initial value.
Definition: DenseMatrixProxy.h:405
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Header file for basic type definitions.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i of the represented matrix...
Definition: DenseMatrixProxy.h:266
System settings for the inline keywords.