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 isAliased( const Other* alias ) const
159  {
160  return dm_.isAliased( alias );
161  }
162  //**********************************************************************************************
163 
164  //**Transpose assignment of row-major dense matrices********************************************
175  template< typename MT2 > // Type of the right-hand side dense matrix
176  inline void assign( const DenseMatrix<MT2,SO>& rhs )
177  {
179 
180  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
181  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
182 
183  const size_t m( rows() );
184  const size_t n( columns() );
185 
186  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
187  const size_t end( n & size_t(-2) );
188 
189  for( size_t i=0UL; i<m; ++i ) {
190  for( size_t j=0UL; j<end; j+=2UL ) {
191  dm_(j ,i) = (~rhs)(i,j );
192  dm_(j+1UL,i) = (~rhs)(i,j+1UL);
193  }
194  if( end < n ) {
195  dm_(end,i) = (~rhs)(i,end);
196  }
197  }
198  }
199  //**********************************************************************************************
200 
201  //**Transpose assignment of column-major dense matrices*****************************************
212  template< typename MT2 > // Type of the right-hand side dense matrix
213  inline void assign( const DenseMatrix<MT2,!SO>& rhs )
214  {
216 
217  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
218  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
219 
220  const size_t m( rows() );
221  const size_t n( columns() );
222  const size_t block( 16UL );
223 
224  for( size_t ii=0UL; ii<m; ii+=block ) {
225  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
226  for( size_t jj=0UL; jj<n; jj+=block ) {
227  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
228  for( size_t i=ii; i<iend; ++i ) {
229  for( size_t j=jj; j<jend; ++j ) {
230  dm_(j,i) = (~rhs)(i,j);
231  }
232  }
233  }
234  }
235  }
236  //**********************************************************************************************
237 
238  //**Transpose assignment of row-major sparse matrices*******************************************
249  template< typename MT2 > // Type of the right-hand side sparse matrix
250  inline void assign( const SparseMatrix<MT2,SO>& rhs )
251  {
253 
254  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
255  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
256 
257  typedef typename MT2::ConstIterator ConstIterator;
258 
259  for( size_t i=0UL; i<(~rhs).rows(); ++i )
260  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
261  dm_(element->index(),i) = element->value();
262  }
263  //**********************************************************************************************
264 
265  //**Transpose assignment of column-major sparse matrices****************************************
276  template< typename MT2 > // Type of the right-hand side sparse matrix
277  inline void assign( const SparseMatrix<MT2,!SO>& rhs )
278  {
280 
281  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
282  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
283 
284  typedef typename MT2::ConstIterator ConstIterator;
285 
286  for( size_t j=0UL; j<(~rhs).columns(); ++j )
287  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
288  dm_(j,element->index()) = element->value();
289  }
290  //**********************************************************************************************
291 
292  //**Transpose addition assignment of row-major dense matrices***********************************
303  template< typename MT2 > // Type of the right-hand side dense matrix
304  inline void addAssign( const DenseMatrix<MT2,SO>& rhs )
305  {
307 
308  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
309  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
310 
311  const size_t m( rows() );
312  const size_t n( columns() );
313 
314  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
315  const size_t end( n & size_t(-2) );
316 
317  for( size_t i=0UL; i<m; ++i ) {
318  for( size_t j=0UL; j<end; j+=2UL ) {
319  dm_(j ,i) += (~rhs)(i,j );
320  dm_(j+1UL,i) += (~rhs)(i,j+1UL);
321 
322  }
323  if( end < n ) {
324  dm_(end,i) += (~rhs)(i,end);
325  }
326  }
327  }
328  //**********************************************************************************************
329 
330  //**Transpose addition assignment of column-major dense matrices********************************
341  template< typename MT2 > // Type of the right-hand side dense matrix
342  inline void addAssign( const DenseMatrix<MT2,!SO>& rhs )
343  {
345 
346  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
347  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
348 
349  const size_t m( rows() );
350  const size_t n( columns() );
351  const size_t block( 16UL );
352 
353  for( size_t ii=0UL; ii<m; ii+=block ) {
354  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
355  for( size_t jj=0UL; jj<n; jj+=block ) {
356  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
357  for( size_t i=ii; i<iend; ++i ) {
358  for( size_t j=jj; j<jend; ++j ) {
359  dm_(j,i) += (~rhs)(i,j);
360  }
361  }
362  }
363  }
364  }
365  //**********************************************************************************************
366 
367  //**Transpose addition assignment of row-major sparse matrices**********************************
378  template< typename MT2 > // Type of the right-hand side sparse matrix
379  inline void addAssign( const SparseMatrix<MT2,SO>& rhs )
380  {
382 
383  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
384  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
385 
386  typedef typename MT2::ConstIterator ConstIterator;
387 
388  for( size_t i=0UL; i<(~rhs).rows(); ++i )
389  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
390  dm_(element->index(),i) += element->value();
391  }
392  //**********************************************************************************************
393 
394  //**Transpose addition assignment of column-major sparse matrices*******************************
405  template< typename MT2 > // Type of the right-hand side sparse matrix
406  inline void addAssign( const SparseMatrix<MT2,!SO>& rhs )
407  {
409 
410  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
411  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
412 
413  typedef typename MT2::ConstIterator ConstIterator;
414 
415  for( size_t j=0UL; j<(~rhs).columns(); ++j )
416  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
417  dm_(j,element->index()) += element->value();
418  }
419  //**********************************************************************************************
420 
421  //**Transpose subtraction assignment of row-major dense matrices********************************
432  template< typename MT2 > // Type of the right-hand side dense matrix
433  inline void subAssign( const DenseMatrix<MT2,SO>& rhs )
434  {
436 
437  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
438  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
439 
440  const size_t m( rows() );
441  const size_t n( columns() );
442 
443  BLAZE_INTERNAL_ASSERT( ( n - ( n % 2UL ) ) == ( n & size_t(-2) ), "Invalid end calculation" );
444  const size_t end( n & size_t(-2) );
445 
446  for( size_t i=0UL; i<m; ++i ) {
447  for( size_t j=0UL; j<end; j+=2UL ) {
448  dm_(j ,i) -= (~rhs)(i,j );
449  dm_(j+1UL,i) -= (~rhs)(i,j+1UL);
450 
451  }
452  if( end < n ) {
453  dm_(end,i) -= (~rhs)(i,end);
454  }
455  }
456  }
457  //**********************************************************************************************
458 
459  //**Transpose subtraction assignment of column-major dense matrices*****************************
470  template< typename MT2 > // Type of the right-hand side dense matrix
471  inline void subAssign( const DenseMatrix<MT2,!SO>& rhs )
472  {
474 
475  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
476  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
477 
478  const size_t m( rows() );
479  const size_t n( columns() );
480  const size_t block( 16UL );
481 
482  for( size_t ii=0UL; ii<m; ii+=block ) {
483  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
484  for( size_t jj=0UL; jj<n; jj+=block ) {
485  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
486  for( size_t i=ii; i<iend; ++i ) {
487  for( size_t j=jj; j<jend; ++j ) {
488  dm_(j,i) -= (~rhs)(i,j);
489  }
490  }
491  }
492  }
493  }
494  //**********************************************************************************************
495 
496  //**Transpose subtraction assignment of row-major sparse matrices*******************************
507  template< typename MT2 > // Type of the right-hand side sparse matrix
508  inline void subAssign( const SparseMatrix<MT2,SO>& rhs )
509  {
511 
512  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
513  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
514 
515  typedef typename MT2::ConstIterator ConstIterator;
516 
517  for( size_t i=0UL; i<(~rhs).rows(); ++i )
518  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
519  dm_(element->index(),i) -= element->value();
520  }
521  //**********************************************************************************************
522 
523  //**Transpose subtraction assignment of column-major dense matrices*****************************
534  template< typename MT2 > // Type of the right-hand side sparse matrix
535  inline void subAssign( const SparseMatrix<MT2,!SO>& rhs )
536  {
538 
539  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
540  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
541 
542  typedef typename MT2::ConstIterator ConstIterator;
543 
544  for( size_t j=0UL; j<(~rhs).columns(); ++j )
545  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
546  dm_(j,element->index()) -= element->value();
547  }
548  //**********************************************************************************************
549 
550  private:
551  //**Member variables****************************************************************************
552  MT& dm_;
553  //**********************************************************************************************
554 
555  //**Compile time checks*************************************************************************
561  //**********************************************************************************************
562 };
563 //*************************************************************************************************
564 
565 
566 
567 
568 //=================================================================================================
569 //
570 // CLASS TEMPLATE SPECIALIZATION FOR ROW-MAJOR MATRICES
571 //
572 //=================================================================================================
573 
574 //*************************************************************************************************
582 template< typename MT > // Type of the dense matrix
583 class DMatTransposer<MT,true> : public DenseMatrix< DMatTransposer<MT,true>, true >
584 {
585  public:
586  //**Type definitions****************************************************************************
587  typedef DMatTransposer<MT,true> This;
588  typedef typename MT::TransposeType ResultType;
589  typedef typename MT::OppositeType OppositeType;
590  typedef typename MT::ResultType TransposeType;
591  typedef typename MT::ElementType ElementType;
592  typedef typename MT::ReturnType ReturnType;
593  typedef const This& CompositeType;
594  typedef typename MT::Reference Reference;
595  typedef typename MT::ConstReference ConstReference;
596  //**********************************************************************************************
597 
598  //**Compilation flags***************************************************************************
600 
603  enum { vectorizable = MT::vectorizable };
604  //**********************************************************************************************
605 
606  //**Constructor*********************************************************************************
611  explicit inline DMatTransposer( MT& dm )
612  : dm_( dm ) // The dense matrix operand
613  {}
614  //**********************************************************************************************
615 
616  //**Access operator*****************************************************************************
623  inline Reference operator()( size_t i, size_t j ) {
624  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
625  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
626  return dm_(j,i);
627  }
628  //**********************************************************************************************
629 
630  //**Low-level data access***********************************************************************
635  inline ElementType* data() {
636  return dm_.data();
637  }
638  //**********************************************************************************************
639 
640  //**Rows function*******************************************************************************
645  inline size_t rows() const {
646  return dm_.columns();
647  }
648  //**********************************************************************************************
649 
650  //**Columns function****************************************************************************
655  inline size_t columns() const {
656  return dm_.rows();
657  }
658  //**********************************************************************************************
659 
660  //**Spacing function****************************************************************************
665  inline size_t spacing() const {
666  return dm_.spacing();
667  }
668  //**********************************************************************************************
669 
670  //**Reset function******************************************************************************
675  inline void reset() {
676  return dm_.reset();
677  }
678  //**********************************************************************************************
679 
680  //**********************************************************************************************
686  template< typename Other > // Data type of the foreign expression
687  inline bool isAliased( const Other* alias ) const
688  {
689  return dm_.isAliased( alias );
690  }
691  //**********************************************************************************************
692 
693  //**Transpose assignment of column-major dense matrices*****************************************
704  template< typename MT2 > // Type of the right-hand side dense matrix
705  inline void assign( const DenseMatrix<MT2,true>& rhs )
706  {
708 
709  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
710  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
711 
712  const size_t m( rows() );
713  const size_t n( columns() );
714 
715  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
716  const size_t end( m & size_t(-2) );
717 
718  for( size_t j=0UL; j<n; ++j ) {
719  for( size_t i=0UL; i<end; i+=2UL ) {
720  dm_(j,i ) = (~rhs)(i ,j);
721  dm_(j,i+1UL) = (~rhs)(i+1UL,j);
722  }
723  if( end < m ) {
724  dm_(j,end) = (~rhs)(end,j);
725  }
726  }
727  }
728  //**********************************************************************************************
729 
730  //**Transpose assignment of row-major dense matrices********************************************
741  template< typename MT2 > // Type of the right-hand side dense matrix
742  inline void assign( const DenseMatrix<MT2,false>& rhs )
743  {
745 
746  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
747  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
748 
749  const size_t m( rows() );
750  const size_t n( columns() );
751  const size_t block( 16UL );
752 
753  for( size_t jj=0UL; jj<n; jj+=block ) {
754  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
755  for( size_t ii=0UL; ii<m; ii+=block ) {
756  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
757  for( size_t j=jj; j<jend; ++j ) {
758  for( size_t i=ii; i<iend; ++i ) {
759  dm_(j,i) = (~rhs)(i,j);
760  }
761  }
762  }
763  }
764  }
765  //**********************************************************************************************
766 
767  //**Transpose assignment of column-major sparse matrices****************************************
778  template< typename MT2 > // Type of the right-hand side sparse matrix
779  inline void assign( const SparseMatrix<MT2,true>& rhs )
780  {
782 
783  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
784  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
785 
786  typedef typename MT2::ConstIterator ConstIterator;
787 
788  for( size_t j=0UL; j<(~rhs).columns(); ++j )
789  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
790  dm_(j,element->index()) = element->value();
791  }
792  //**********************************************************************************************
793 
794  //**Transpose assignment of row-major sparse matrices*******************************************
805  template< typename MT2 > // Type of the right-hand side sparse matrix
806  inline void assign( const SparseMatrix<MT2,false>& rhs )
807  {
809 
810  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
811  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
812 
813  typedef typename MT2::ConstIterator ConstIterator;
814 
815  for( size_t i=0UL; i<(~rhs).rows(); ++i )
816  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
817  dm_(element->index(),i) = element->value();
818  }
819  //**********************************************************************************************
820 
821  //**Transpose addition assignment of column-major dense matrices********************************
832  template< typename MT2 > // Type of the right-hand side dense matrix
833  inline void addAssign( const DenseMatrix<MT2,true>& rhs )
834  {
836 
837  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
838  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
839 
840  const size_t m( rows() );
841  const size_t n( columns() );
842 
843  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
844  const size_t end( m & size_t(-2) );
845 
846  for( size_t j=0UL; j<n; ++j ) {
847  for( size_t i=0UL; i<end; i+=2UL ) {
848  dm_(j,i ) += (~rhs)(i ,j);
849  dm_(j,i+1UL) += (~rhs)(i+1UL,j);
850  }
851  if( end < m ) {
852  dm_(j,end) += (~rhs)(end,j);
853  }
854  }
855  }
856  //**********************************************************************************************
857 
858  //**Transpose addition assignment of row-major dense matrices***********************************
869  template< typename MT2 > // Type of the right-hand side dense matrix
870  inline void addAssign( const DenseMatrix<MT2,false>& rhs )
871  {
873 
874  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
875  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
876 
877  const size_t m( rows() );
878  const size_t n( columns() );
879  const size_t block( 16UL );
880 
881  for( size_t jj=0UL; jj<n; jj+=block ) {
882  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
883  for( size_t ii=0UL; ii<m; ii+=block ) {
884  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
885  for( size_t j=jj; j<jend; ++j ) {
886  for( size_t i=ii; i<iend; ++i ) {
887  dm_(j,i) += (~rhs)(i,j);
888  }
889  }
890  }
891  }
892  }
893  //**********************************************************************************************
894 
895  //**Transpose addition assignment of column-major sparse matrices*******************************
906  template< typename MT2 > // Type of the right-hand side sparse matrix
907  inline void addAssign( const SparseMatrix<MT2,true>& rhs )
908  {
910 
911  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
912  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
913 
914  typedef typename MT2::ConstIterator ConstIterator;
915 
916  for( size_t j=0UL; j<(~rhs).columns(); ++j )
917  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
918  dm_(j,element->index()) += element->value();
919  }
920  //**********************************************************************************************
921 
922  //**Transpose addition assignment of row-major sparse matrices**********************************
933  template< typename MT2 > // Type of the right-hand side sparse matrix
934  inline void addAssign( const SparseMatrix<MT2,false>& rhs )
935  {
937 
938  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
939  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
940 
941  typedef typename MT2::ConstIterator ConstIterator;
942 
943  for( size_t i=0UL; i<(~rhs).rows(); ++i )
944  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
945  dm_(element->index(),i) += element->value();
946  }
947  //**********************************************************************************************
948 
949  //**Transpose subtraction assignment of column-major dense matrices*****************************
960  template< typename MT2 > // Type of the right-hand side dense matrix
961  inline void subAssign( const DenseMatrix<MT2,true>& rhs )
962  {
964 
965  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
966  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
967 
968  const size_t m( rows() );
969  const size_t n( columns() );
970 
971  BLAZE_INTERNAL_ASSERT( ( m - ( m % 2UL ) ) == ( m & size_t(-2) ), "Invalid end calculation" );
972  const size_t end( m & size_t(-2) );
973 
974  for( size_t j=0UL; j<n; ++j ) {
975  for( size_t i=0UL; i<end; i+=2UL ) {
976  dm_(j,i ) -= (~rhs)(i ,j);
977  dm_(j,i+1UL) -= (~rhs)(i+1UL,j);
978  }
979  if( end < m ) {
980  dm_(j,end) -= (~rhs)(end,j);
981  }
982  }
983  }
984  //**********************************************************************************************
985 
986  //**Transpose subtraction assignment of row-major dense matrices********************************
997  template< typename MT2 > // Type of the right-hand side dense matrix
998  inline void subAssign( const DenseMatrix<MT2,false>& rhs )
999  {
1001 
1002  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1003  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1004 
1005  const size_t m( rows() );
1006  const size_t n( columns() );
1007  const size_t block( 16UL );
1008 
1009  for( size_t jj=0UL; jj<n; jj+=block ) {
1010  const size_t jend( ( n < jj+block )?( n ):( jj+block ) );
1011  for( size_t ii=0UL; ii<m; ii+=block ) {
1012  const size_t iend( ( m < ii+block )?( m ):( ii+block ) );
1013  for( size_t j=jj; j<jend; ++j ) {
1014  for( size_t i=ii; i<iend; ++i ) {
1015  dm_(j,i) -= (~rhs)(i,j);
1016  }
1017  }
1018  }
1019  }
1020  }
1021  //**********************************************************************************************
1022 
1023  //**Transpose subtraction assignment of column-major sparse matrices****************************
1034  template< typename MT2 > // Type of the right-hand side sparse matrix
1035  inline void subAssign( const SparseMatrix<MT2,true>& rhs )
1036  {
1038 
1039  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1040  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1041 
1042  typedef typename MT2::ConstIterator ConstIterator;
1043 
1044  for( size_t j=0UL; j<(~rhs).columns(); ++j )
1045  for( ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
1046  dm_(j,element->index()) -= element->value();
1047  }
1048  //**********************************************************************************************
1049 
1050  //**Transpose subtraction assignment of row-major dense matrices********************************
1061  template< typename MT2 > // Type of the right-hand side sparse matrix
1062  inline void subAssign( const SparseMatrix<MT2,false>& rhs )
1063  {
1065 
1066  BLAZE_INTERNAL_ASSERT( dm_.columns() == (~rhs).rows(), "Invalid number of rows" );
1067  BLAZE_INTERNAL_ASSERT( dm_.rows() == (~rhs).columns(), "Invalid number of columns" );
1068 
1069  typedef typename MT2::ConstIterator ConstIterator;
1070 
1071  for( size_t i=0UL; i<(~rhs).rows(); ++i )
1072  for( ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
1073  dm_(element->index(),i) -= element->value();
1074  }
1075  //**********************************************************************************************
1076 
1077  //**Transpose multiplication assignment of dense matrices***************************************
1078  // No special implementation for the transpose multiplication assignment of dense matrices.
1079  //**********************************************************************************************
1080 
1081  //**Transpose multiplication assignment of sparse matrices**************************************
1082  // No special implementation for the transpose multiplication assignment of sparse matrices.
1083  //**********************************************************************************************
1084 
1085  private:
1086  //**Member variables****************************************************************************
1087  MT& dm_;
1088  //**********************************************************************************************
1089 
1090  //**Compile time checks*************************************************************************
1096  //**********************************************************************************************
1097 };
1099 //*************************************************************************************************
1100 
1101 
1102 
1103 
1104 //=================================================================================================
1105 //
1106 // GLOBAL OPERATORS
1107 //
1108 //=================================================================================================
1109 
1110 //*************************************************************************************************
1118 template< typename MT // Type of the dense matrix
1119  , bool SO > // Storage order
1120 inline void reset( DMatTransposer<MT,SO>& m )
1121 {
1122  m.reset();
1123 }
1125 //*************************************************************************************************
1126 
1127 } // namespace blaze
1128 
1129 #endif