All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMatTransposer.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTRANSPOSER_H_
23 #define _BLAZE_MATH_EXPRESSIONS_DMATTRANSPOSER_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
34 #include <blaze/util/Assert.h>
35 #include <blaze/util/Types.h>
36 
37 
38 namespace blaze {
39 
40 //=================================================================================================
41 //
42 // CLASS DMATTRANSPOSER
43 //
44 //=================================================================================================
45 
46 //*************************************************************************************************
52 template< typename MT // Type of the dense matrix
53  , bool SO > // Storage order
54 class DMatTransposer : public DenseMatrix< DMatTransposer<MT,SO>, SO >
55 {
56  public:
57  //**Type definitions****************************************************************************
59  typedef typename MT::TransposeType ResultType;
60  typedef typename MT::OppositeType OppositeType;
61  typedef typename MT::ResultType TransposeType;
62  typedef typename MT::ElementType ElementType;
63  typedef typename MT::ReturnType ReturnType;
64  typedef const This& CompositeType;
65  typedef typename MT::Reference Reference;
66  typedef typename MT::ConstReference ConstReference;
67  //**********************************************************************************************
68 
69  //**Compilation flags***************************************************************************
71 
74  enum { vectorizable = MT::vectorizable };
75  //**********************************************************************************************
76 
77  //**Constructor*********************************************************************************
82  explicit inline DMatTransposer( MT& dm )
83  : dm_( dm ) // The dense matrix operand
84  {}
85  //**********************************************************************************************
86 
87  //**Access operator*****************************************************************************
94  inline Reference operator()( size_t i, size_t j ) {
95  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
96  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
97  return dm_(j,i);
98  }
99  //**********************************************************************************************
100 
101  //**Low-level data access***********************************************************************
106  inline ElementType* data() {
107  return dm_.data();
108  }
109  //**********************************************************************************************
110 
111  //**Rows function*******************************************************************************
116  inline size_t rows() const {
117  return dm_.columns();
118  }
119  //**********************************************************************************************
120 
121  //**Columns function****************************************************************************
126  inline size_t columns() const {
127  return dm_.rows();
128  }
129  //**********************************************************************************************
130 
131  //**Spacing function****************************************************************************
136  inline size_t spacing() const {
137  return dm_.spacing();
138  }
139  //**********************************************************************************************
140 
141  //**Reset function******************************************************************************
146  inline void reset() {
147  return dm_.reset();
148  }
149  //**********************************************************************************************
150 
151  //**********************************************************************************************
157  template< typename Other > // Data type of the foreign expression
158  inline bool canAlias( const Other* alias ) const
159  {
160  return dm_.canAlias( alias );
161  }
162  //**********************************************************************************************
163 
164  //**********************************************************************************************
170  template< typename Other > // Data type of the foreign expression
171  inline bool isAliased( const Other* alias ) const
172  {
173  return dm_.isAliased( alias );
174  }
175  //**********************************************************************************************
176 
177  //**Transpose assignment of row-major dense matrices********************************************
188  template< typename MT2 > // Type of the right-hand side dense matrix
189  inline void assign( const DenseMatrix<MT2,SO>& rhs )
190  {
192 
193  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
194  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
195 
196  const size_t m( rows() );
197  const size_t n( columns() );
198 
199  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
200  const size_t end( n & size_t(-2) );
201 
202  for( size_t i=0UL; i<m; ++i ) {
203  for( size_t j=0UL; j<end; j+=2UL ) {
204  dm_(j ,i) = (~rhs)(i,j );
205  dm_(j+1UL,i) = (~rhs)(i,j+1UL);
206  }
207  if( end < n ) {
208  dm_(end,i) = (~rhs)(i,end);
209  }
210  }
211  }
212  //**********************************************************************************************
213 
214  //**Transpose assignment of column-major dense matrices*****************************************
225  template< typename MT2 > // Type of the right-hand side dense matrix
226  inline void assign( const DenseMatrix<MT2,!SO>& rhs )
227  {
229 
230  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
231  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
232 
233  const size_t m( rows() );
234  const size_t n( columns() );
235  const size_t block( 16UL );
236 
237  for( size_t ii=0UL; ii<m; ii+=block ) {
238  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
239  for( size_t jj=0UL; jj<n; jj+=block ) {
240  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
241  for( size_t i=ii; i<iend; ++i ) {
242  for( size_t j=jj; j<jend; ++j ) {
243  dm_(j,i) = (~rhs)(i,j);
244  }
245  }
246  }
247  }
248  }
249  //**********************************************************************************************
250 
251  //**Transpose assignment of row-major sparse matrices*******************************************
262  template< typename MT2 > // Type of the right-hand side sparse matrix
263  inline void assign( const SparseMatrix<MT2,SO>& rhs )
264  {
266 
267  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
268  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
269 
270  typedef typename MT2::ConstIterator ConstIterator;
271 
272  for( size_t i=0UL; i<(~rhs).rows(); ++i )
273  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
274  dm_(element->index(),i) = element->value();
275  }
276  //**********************************************************************************************
277 
278  //**Transpose assignment of column-major sparse matrices****************************************
289  template< typename MT2 > // Type of the right-hand side sparse matrix
290  inline void assign( const SparseMatrix<MT2,!SO>& rhs )
291  {
293 
294  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
295  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
296 
297  typedef typename MT2::ConstIterator ConstIterator;
298 
299  for( size_t j=0UL; j<(~rhs).columns(); ++j )
300  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
301  dm_(j,element->index()) = element->value();
302  }
303  //**********************************************************************************************
304 
305  //**Transpose addition assignment of row-major dense matrices***********************************
316  template< typename MT2 > // Type of the right-hand side dense matrix
317  inline void addAssign( const DenseMatrix<MT2,SO>& rhs )
318  {
320 
321  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
322  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
323 
324  const size_t m( rows() );
325  const size_t n( columns() );
326 
327  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
328  const size_t end( n & size_t(-2) );
329 
330  for( size_t i=0UL; i<m; ++i ) {
331  for( size_t j=0UL; j<end; j+=2UL ) {
332  dm_(j ,i) += (~rhs)(i,j );
333  dm_(j+1UL,i) += (~rhs)(i,j+1UL);
334 
335  }
336  if( end < n ) {
337  dm_(end,i) += (~rhs)(i,end);
338  }
339  }
340  }
341  //**********************************************************************************************
342 
343  //**Transpose addition assignment of column-major dense matrices********************************
354  template< typename MT2 > // Type of the right-hand side dense matrix
355  inline void addAssign( const DenseMatrix<MT2,!SO>& rhs )
356  {
358 
359  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
360  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
361 
362  const size_t m( rows() );
363  const size_t n( columns() );
364  const size_t block( 16UL );
365 
366  for( size_t ii=0UL; ii<m; ii+=block ) {
367  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
368  for( size_t jj=0UL; jj<n; jj+=block ) {
369  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
370  for( size_t i=ii; i<iend; ++i ) {
371  for( size_t j=jj; j<jend; ++j ) {
372  dm_(j,i) += (~rhs)(i,j);
373  }
374  }
375  }
376  }
377  }
378  //**********************************************************************************************
379 
380  //**Transpose addition assignment of row-major sparse matrices**********************************
391  template< typename MT2 > // Type of the right-hand side sparse matrix
392  inline void addAssign( const SparseMatrix<MT2,SO>& rhs )
393  {
395 
396  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
397  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
398 
399  typedef typename MT2::ConstIterator ConstIterator;
400 
401  for( size_t i=0UL; i<(~rhs).rows(); ++i )
402  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
403  dm_(element->index(),i) += element->value();
404  }
405  //**********************************************************************************************
406 
407  //**Transpose addition assignment of column-major sparse matrices*******************************
418  template< typename MT2 > // Type of the right-hand side sparse matrix
419  inline void addAssign( const SparseMatrix<MT2,!SO>& rhs )
420  {
422 
423  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
424  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
425 
426  typedef typename MT2::ConstIterator ConstIterator;
427 
428  for( size_t j=0UL; j<(~rhs).columns(); ++j )
429  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
430  dm_(j,element->index()) += element->value();
431  }
432  //**********************************************************************************************
433 
434  //**Transpose subtraction assignment of row-major dense matrices********************************
445  template< typename MT2 > // Type of the right-hand side dense matrix
446  inline void subAssign( const DenseMatrix<MT2,SO>& rhs )
447  {
449 
450  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
451  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
452 
453  const size_t m( rows() );
454  const size_t n( columns() );
455 
456  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
457  const size_t end( n & size_t(-2) );
458 
459  for( size_t i=0UL; i<m; ++i ) {
460  for( size_t j=0UL; j<end; j+=2UL ) {
461  dm_(j ,i) -= (~rhs)(i,j );
462  dm_(j+1UL,i) -= (~rhs)(i,j+1UL);
463 
464  }
465  if( end < n ) {
466  dm_(end,i) -= (~rhs)(i,end);
467  }
468  }
469  }
470  //**********************************************************************************************
471 
472  //**Transpose subtraction assignment of column-major dense matrices*****************************
483  template< typename MT2 > // Type of the right-hand side dense matrix
484  inline void subAssign( const DenseMatrix<MT2,!SO>& rhs )
485  {
487 
488  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
489  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
490 
491  const size_t m( rows() );
492  const size_t n( columns() );
493  const size_t block( 16UL );
494 
495  for( size_t ii=0UL; ii<m; ii+=block ) {
496  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
497  for( size_t jj=0UL; jj<n; jj+=block ) {
498  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
499  for( size_t i=ii; i<iend; ++i ) {
500  for( size_t j=jj; j<jend; ++j ) {
501  dm_(j,i) -= (~rhs)(i,j);
502  }
503  }
504  }
505  }
506  }
507  //**********************************************************************************************
508 
509  //**Transpose subtraction assignment of row-major sparse matrices*******************************
520  template< typename MT2 > // Type of the right-hand side sparse matrix
521  inline void subAssign( const SparseMatrix<MT2,SO>& rhs )
522  {
524 
525  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
526  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
527 
528  typedef typename MT2::ConstIterator ConstIterator;
529 
530  for( size_t i=0UL; i<(~rhs).rows(); ++i )
531  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
532  dm_(element->index(),i) -= element->value();
533  }
534  //**********************************************************************************************
535 
536  //**Transpose subtraction assignment of column-major dense matrices*****************************
547  template< typename MT2 > // Type of the right-hand side sparse matrix
548  inline void subAssign( const SparseMatrix<MT2,!SO>& rhs )
549  {
551 
552  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
553  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
554 
555  typedef typename MT2::ConstIterator ConstIterator;
556 
557  for( size_t j=0UL; j<(~rhs).columns(); ++j )
558  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
559  dm_(j,element->index()) -= element->value();
560  }
561  //**********************************************************************************************
562 
563  private:
564  //**Member variables****************************************************************************
565  MT& dm_;
566  //**********************************************************************************************
567 
568  //**Compile time checks*************************************************************************
574  //**********************************************************************************************
575 };
576 //*************************************************************************************************
577 
578 
579 
580 
581 //=================================================================================================
582 //
583 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR MATRICES
584 //
585 //=================================================================================================
586 
587 //*************************************************************************************************
595 template< typename MT > // Type of the dense matrix
596 class DMatTransposer<MT,true> : public DenseMatrix< DMatTransposer<MT,true>, true >
597 {
598  public:
599  //**Type definitions****************************************************************************
600  typedef DMatTransposer<MT,true> This;
601  typedef typename MT::TransposeType ResultType;
602  typedef typename MT::OppositeType OppositeType;
603  typedef typename MT::ResultType TransposeType;
604  typedef typename MT::ElementType ElementType;
605  typedef typename MT::ReturnType ReturnType;
606  typedef const This& CompositeType;
607  typedef typename MT::Reference Reference;
608  typedef typename MT::ConstReference ConstReference;
609  //**********************************************************************************************
610 
611  //**Compilation flags***************************************************************************
613 
616  enum { vectorizable = MT::vectorizable };
617  //**********************************************************************************************
618 
619  //**Constructor*********************************************************************************
624  explicit inline DMatTransposer( MT& dm )
625  : dm_( dm ) // The dense matrix operand
626  {}
627  //**********************************************************************************************
628 
629  //**Access operator*****************************************************************************
636  inline Reference operator()( size_t i, size_t j ) {
637  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
638  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
639  return dm_(j,i);
640  }
641  //**********************************************************************************************
642 
643  //**Low-level data access***********************************************************************
648  inline ElementType* data() {
649  return dm_.data();
650  }
651  //**********************************************************************************************
652 
653  //**Rows function*******************************************************************************
658  inline size_t rows() const {
659  return dm_.columns();
660  }
661  //**********************************************************************************************
662 
663  //**Columns function****************************************************************************
668  inline size_t columns() const {
669  return dm_.rows();
670  }
671  //**********************************************************************************************
672 
673  //**Spacing function****************************************************************************
678  inline size_t spacing() const {
679  return dm_.spacing();
680  }
681  //**********************************************************************************************
682 
683  //**Reset function******************************************************************************
688  inline void reset() {
689  return dm_.reset();
690  }
691  //**********************************************************************************************
692 
693  //**********************************************************************************************
699  template< typename Other > // Data type of the foreign expression
700  inline bool isAliased( const Other* alias ) const
701  {
702  return dm_.isAliased( alias );
703  }
704  //**********************************************************************************************
705 
706  //**Transpose assignment of column-major dense matrices*****************************************
717  template< typename MT2 > // Type of the right-hand side dense matrix
718  inline void assign( const DenseMatrix<MT2,true>& rhs )
719  {
721 
722  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
723  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
724 
725  const size_t m( rows() );
726  const size_t n( columns() );
727 
728  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
729  const size_t end( m & size_t(-2) );
730 
731  for( size_t j=0UL; j<n; ++j ) {
732  for( size_t i=0UL; i<end; i+=2UL ) {
733  dm_(j,i ) = (~rhs)(i ,j);
734  dm_(j,i+1UL) = (~rhs)(i+1UL,j);
735  }
736  if( end < m ) {
737  dm_(j,end) = (~rhs)(end,j);
738  }
739  }
740  }
741  //**********************************************************************************************
742 
743  //**Transpose assignment of row-major dense matrices********************************************
754  template< typename MT2 > // Type of the right-hand side dense matrix
755  inline void assign( const DenseMatrix<MT2,false>& rhs )
756  {
758 
759  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
760  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
761 
762  const size_t m( rows() );
763  const size_t n( columns() );
764  const size_t block( 16UL );
765 
766  for( size_t jj=0UL; jj<n; jj+=block ) {
767  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
768  for( size_t ii=0UL; ii<m; ii+=block ) {
769  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
770  for( size_t j=jj; j<jend; ++j ) {
771  for( size_t i=ii; i<iend; ++i ) {
772  dm_(j,i) = (~rhs)(i,j);
773  }
774  }
775  }
776  }
777  }
778  //**********************************************************************************************
779 
780  //**Transpose assignment of column-major sparse matrices****************************************
791  template< typename MT2 > // Type of the right-hand side sparse matrix
792  inline void assign( const SparseMatrix<MT2,true>& rhs )
793  {
795 
796  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
797  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
798 
799  typedef typename MT2::ConstIterator ConstIterator;
800 
801  for( size_t j=0UL; j<(~rhs).columns(); ++j )
802  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
803  dm_(j,element->index()) = element->value();
804  }
805  //**********************************************************************************************
806 
807  //**Transpose assignment of row-major sparse matrices*******************************************
818  template< typename MT2 > // Type of the right-hand side sparse matrix
819  inline void assign( const SparseMatrix<MT2,false>& rhs )
820  {
822 
823  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
824  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
825 
826  typedef typename MT2::ConstIterator ConstIterator;
827 
828  for( size_t i=0UL; i<(~rhs).rows(); ++i )
829  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
830  dm_(element->index(),i) = element->value();
831  }
832  //**********************************************************************************************
833 
834  //**Transpose addition assignment of column-major dense matrices********************************
845  template< typename MT2 > // Type of the right-hand side dense matrix
846  inline void addAssign( const DenseMatrix<MT2,true>& rhs )
847  {
849 
850  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
851  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
852 
853  const size_t m( rows() );
854  const size_t n( columns() );
855 
856  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
857  const size_t end( m & size_t(-2) );
858 
859  for( size_t j=0UL; j<n; ++j ) {
860  for( size_t i=0UL; i<end; i+=2UL ) {
861  dm_(j,i ) += (~rhs)(i ,j);
862  dm_(j,i+1UL) += (~rhs)(i+1UL,j);
863  }
864  if( end < m ) {
865  dm_(j,end) += (~rhs)(end,j);
866  }
867  }
868  }
869  //**********************************************************************************************
870 
871  //**Transpose addition assignment of row-major dense matrices***********************************
882  template< typename MT2 > // Type of the right-hand side dense matrix
883  inline void addAssign( const DenseMatrix<MT2,false>& rhs )
884  {
886 
887  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
888  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
889 
890  const size_t m( rows() );
891  const size_t n( columns() );
892  const size_t block( 16UL );
893 
894  for( size_t jj=0UL; jj<n; jj+=block ) {
895  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
896  for( size_t ii=0UL; ii<m; ii+=block ) {
897  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
898  for( size_t j=jj; j<jend; ++j ) {
899  for( size_t i=ii; i<iend; ++i ) {
900  dm_(j,i) += (~rhs)(i,j);
901  }
902  }
903  }
904  }
905  }
906  //**********************************************************************************************
907 
908  //**Transpose addition assignment of column-major sparse matrices*******************************
919  template< typename MT2 > // Type of the right-hand side sparse matrix
920  inline void addAssign( const SparseMatrix<MT2,true>& rhs )
921  {
923 
924  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
925  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
926 
927  typedef typename MT2::ConstIterator ConstIterator;
928 
929  for( size_t j=0UL; j<(~rhs).columns(); ++j )
930  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
931  dm_(j,element->index()) += element->value();
932  }
933  //**********************************************************************************************
934 
935  //**Transpose addition assignment of row-major sparse matrices**********************************
946  template< typename MT2 > // Type of the right-hand side sparse matrix
947  inline void addAssign( const SparseMatrix<MT2,false>& rhs )
948  {
950 
951  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
952  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
953 
954  typedef typename MT2::ConstIterator ConstIterator;
955 
956  for( size_t i=0UL; i<(~rhs).rows(); ++i )
957  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
958  dm_(element->index(),i) += element->value();
959  }
960  //**********************************************************************************************
961 
962  //**Transpose subtraction assignment of column-major dense matrices*****************************
973  template< typename MT2 > // Type of the right-hand side dense matrix
974  inline void subAssign( const DenseMatrix<MT2,true>& rhs )
975  {
977 
978  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
979  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
980 
981  const size_t m( rows() );
982  const size_t n( columns() );
983 
984  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
985  const size_t end( m & size_t(-2) );
986 
987  for( size_t j=0UL; j<n; ++j ) {
988  for( size_t i=0UL; i<end; i+=2UL ) {
989  dm_(j,i ) -= (~rhs)(i ,j);
990  dm_(j,i+1UL) -= (~rhs)(i+1UL,j);
991  }
992  if( end < m ) {
993  dm_(j,end) -= (~rhs)(end,j);
994  }
995  }
996  }
997  //**********************************************************************************************
998 
999  //**Transpose subtraction assignment of row-major dense matrices********************************
1010  template< typename MT2 > // Type of the right-hand side dense matrix
1011  inline void subAssign( const DenseMatrix<MT2,false>& rhs )
1012  {
1014 
1015  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1016  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1017 
1018  const size_t m( rows() );
1019  const size_t n( columns() );
1020  const size_t block( 16UL );
1021 
1022  for( size_t jj=0UL; jj<n; jj+=block ) {
1023  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
1024  for( size_t ii=0UL; ii<m; ii+=block ) {
1025  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
1026  for( size_t j=jj; j<jend; ++j ) {
1027  for( size_t i=ii; i<iend; ++i ) {
1028  dm_(j,i) -= (~rhs)(i,j);
1029  }
1030  }
1031  }
1032  }
1033  }
1034  //**********************************************************************************************
1035 
1036  //**Transpose subtraction assignment of column-major sparse matrices****************************
1047  template< typename MT2 > // Type of the right-hand side sparse matrix
1048  inline void subAssign( const SparseMatrix<MT2,true>& rhs )
1049  {
1051 
1052  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1053  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1054 
1055  typedef typename MT2::ConstIterator ConstIterator;
1056 
1057  for( size_t j=0UL; j<(~rhs).columns(); ++j )
1058  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
1059  dm_(j,element->index()) -= element->value();
1060  }
1061  //**********************************************************************************************
1062 
1063  //**Transpose subtraction assignment of row-major dense matrices********************************
1074  template< typename MT2 > // Type of the right-hand side sparse matrix
1075  inline void subAssign( const SparseMatrix<MT2,false>& rhs )
1076  {
1078 
1079  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1080  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1081 
1082  typedef typename MT2::ConstIterator ConstIterator;
1083 
1084  for( size_t i=0UL; i<(~rhs).rows(); ++i )
1085  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
1086  dm_(element->index(),i) -= element->value();
1087  }
1088  //**********************************************************************************************
1089 
1090  //**Transpose multiplication assignment of dense matrices***************************************
1091  // No special implementation for the transpose multiplication assignment of dense matrices.
1092  //**********************************************************************************************
1093 
1094  //**Transpose multiplication assignment of sparse matrices**************************************
1095  // No special implementation for the transpose multiplication assignment of sparse matrices.
1096  //**********************************************************************************************
1097 
1098  private:
1099  //**Member variables****************************************************************************
1100  MT& dm_;
1101  //**********************************************************************************************
1102 
1103  //**Compile time checks*************************************************************************
1109  //**********************************************************************************************
1110 };
1112 //*************************************************************************************************
1113 
1114 
1115 
1116 
1117 //=================================================================================================
1118 //
1119 // GLOBAL OPERATORS
1120 //
1121 //=================================================================================================
1122 
1123 //*************************************************************************************************
1131 template< typename MT // Type of the dense matrix
1132  , bool SO > // Storage order
1133 inline void reset( DMatTransposer<MT,SO>& m )
1134 {
1135  m.reset();
1136 }
1138 //*************************************************************************************************
1139 
1140 } // namespace blaze
1141 
1142 #endif