All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DMatTransExpr.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATTRANSEXPR_H_
23 #define _BLAZE_MATH_EXPRESSIONS_DMATTRANSEXPR_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
40 #include <blaze/util/Assert.h>
42 #include <blaze/util/EmptyType.h>
43 #include <blaze/util/EnableIf.h>
44 #include <blaze/util/SelectType.h>
45 #include <blaze/util/Types.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // CLASS DMATTRANSEXPR
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
63 template< typename MT // Type of the dense matrix
64  , bool SO > // Storage order
65 class DMatTransExpr : public DenseMatrix< DMatTransExpr<MT,SO>, SO >
66  , private Expression
67  , private SelectType< IsComputation<MT>::value, Computation, EmptyType >::Type
68 {
69  private:
70  //**Type definitions****************************************************************************
71  typedef typename MT::ResultType RT;
72  typedef typename MT::CompositeType CT;
73  //**********************************************************************************************
74 
75  //**********************************************************************************************
77 
83  enum { useAssign = RequiresEvaluation<MT>::value };
84  //**********************************************************************************************
85 
86  //**********************************************************************************************
88 
89  template< typename MT2 >
90  struct UseAssign {
91  enum { value = useAssign };
92  };
94  //**********************************************************************************************
95 
96  public:
97  //**Type definitions****************************************************************************
99  typedef typename MT::TransposeType ResultType;
100  typedef typename ResultType::OppositeType OppositeType;
101  typedef typename MT::ResultType TransposeType;
102  typedef typename MT::ElementType ElementType;
103  typedef typename MT::ReturnType ReturnType;
104 
107 
109  typedef typename SelectType< IsExpression<MT>::value, const MT, const MT& >::Type Operand;
110  //**********************************************************************************************
111 
112  //**Compilation flags***************************************************************************
114  enum { vectorizable = 0 };
115 
117  enum { canAlias = 1 };
118  //**********************************************************************************************
119 
120  //**Constructor*********************************************************************************
125  explicit inline DMatTransExpr( const MT& dm )
126  : dm_( dm ) // Dense matrix of the transposition expression
127  {}
128  //**********************************************************************************************
129 
130  //**Access operator*****************************************************************************
137  inline ReturnType operator()( size_t i, size_t j ) const {
138  BLAZE_INTERNAL_ASSERT( i < dm_.columns(), "Invalid row access index" );
139  BLAZE_INTERNAL_ASSERT( j < dm_.rows() , "Invalid column access index" );
140  return dm_(j,i);
141  }
142  //**********************************************************************************************
143 
144  //**Low-level data access***********************************************************************
149  inline const ElementType* data() const {
150  return dm_.data();
151  }
152  //**********************************************************************************************
153 
154  //**Rows function*******************************************************************************
159  inline size_t rows() const {
160  return dm_.columns();
161  }
162  //**********************************************************************************************
163 
164  //**Columns function****************************************************************************
169  inline size_t columns() const {
170  return dm_.rows();
171  }
172  //**********************************************************************************************
173 
174  //**Spacing function****************************************************************************
179  inline size_t spacing() const {
180  return dm_.spacing();
181  }
182  //**********************************************************************************************
183 
184  //**Operand access******************************************************************************
189  inline Operand operand() const {
190  return dm_;
191  }
192  //**********************************************************************************************
193 
194  //**********************************************************************************************
200  template< typename T >
201  inline bool isAliased( const T* alias ) const {
202  return dm_.isAliased( alias );
203  }
204  //**********************************************************************************************
205 
206  private:
207  //**Member variables****************************************************************************
209  //**********************************************************************************************
210 
211  //**Assignment to dense matrices****************************************************************
225  template< typename MT2 // Type of the target dense matrix
226  , bool SO2 > // Storage order of the target dense matrix
227  friend inline typename EnableIf< UseAssign<MT2> >::Type
228  assign( DenseMatrix<MT2,SO2>& lhs, const DMatTransExpr& rhs )
229  {
230  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
231  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
232 
233  DMatTransposer<MT2,!SO2> tmp( ~lhs );
234  assign( tmp, rhs.dm_ );
235  }
237  //**********************************************************************************************
238 
239  //**Assignment to sparse matrices***************************************************************
253  template< typename MT2 // Type of the target sparse matrix
254  , bool SO2 > // Storage order of the target sparse matrix
255  friend inline typename EnableIf< UseAssign<MT2> >::Type
256  assign( SparseMatrix<MT2,SO2>& lhs, const DMatTransExpr& rhs )
257  {
259 
265  BLAZE_CONSTRAINT_MUST_BE_REFERENCE_TYPE( typename TmpType::CompositeType );
266 
267  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
268  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
269 
270  const TmpType tmp( rhs );
271  assign( ~lhs, tmp );
272  }
274  //**********************************************************************************************
275 
276  //**Addition assignment to dense matrices*******************************************************
290  template< typename MT2 // Type of the target dense matrix
291  , bool SO2 > // Storage order of the target dense matrix
292  friend inline typename EnableIf< UseAssign<MT2> >::Type
293  addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatTransExpr& rhs )
294  {
295  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
296  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
297 
298  DMatTransposer<MT2,!SO2> tmp( ~lhs );
299  addAssign( tmp, rhs.dm_ );
300  }
302  //**********************************************************************************************
303 
304  //**Addition assignment to sparse matrices******************************************************
305  // No special implementation for the addition assignment to sparse matrices.
306  //**********************************************************************************************
307 
308  //**Subtraction assignment to dense matrices****************************************************
322  template< typename MT2 // Type of the target dense matrix
323  , bool SO2 > // Storage order of the target dense matrix
324  friend inline typename EnableIf< UseAssign<MT2> >::Type
325  subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatTransExpr& rhs )
326  {
327  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
328  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
329 
330  DMatTransposer<MT2,!SO2> tmp( ~lhs );
331  subAssign( tmp, rhs.dm_ );
332  }
334  //**********************************************************************************************
335 
336  //**Subtraction assignment to sparse matrices***************************************************
337  // No special implementation for the subtraction assignment to sparse matrices.
338  //**********************************************************************************************
339 
340  //**Multiplication assignment to dense matrices*************************************************
341  // No special implementation for the multiplication assignment to dense matrices.
342  //**********************************************************************************************
343 
344  //**Multiplication assignment to sparse matrices************************************************
345  // No special implementation for the multiplication assignment to sparse matrices.
346  //**********************************************************************************************
347 
348  //**Trans function******************************************************************************
364  template< typename MT2 // Type of the dense matrix
365  , bool SO2 > // Storage order of the dense matrix
366  friend inline Operand trans( const DMatTransExpr<MT2,SO2>& dm )
367  {
368  return dm.dm_;
369  }
371  //**********************************************************************************************
372 
373  //**Compile time checks*************************************************************************
378  //**********************************************************************************************
379 };
380 //*************************************************************************************************
381 
382 
383 
384 
385 //=================================================================================================
386 //
387 // GLOBAL OPERATORS
388 //
389 //=================================================================================================
390 
391 //*************************************************************************************************
407 template< typename MT // Type of the dense matrix
408  , bool SO > // Storage order
410 {
411  return DMatTransExpr<MT,!SO>( ~dm );
412 }
413 //*************************************************************************************************
414 
415 } // namespace blaze
416 
417 #endif