Blaze  3.6
DMatDMatKronExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATDMATKRONEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATDMATKRONEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
56 #include <blaze/math/shims/Reset.h>
65 #include <blaze/util/Assert.h>
67 #include <blaze/util/MaybeUnused.h>
68 #include <blaze/util/mpl/If.h>
69 #include <blaze/util/Types.h>
70 
71 
72 namespace blaze {
73 
74 //=================================================================================================
75 //
76 // CLASS DMATDMATKRONEXPR
77 //
78 //=================================================================================================
79 
80 //*************************************************************************************************
87 template< typename MT1 // Type of the left-hand side dense matrix
88  , typename MT2 // Type of the right-hand side dense matrix
89  , bool SO > // Storage order
91  : public MatMatKronExpr< DenseMatrix< DMatDMatKronExpr<MT1,MT2,SO>, SO > >
92  , private Computation
93 {
94  private:
95  //**Type definitions****************************************************************************
104  //**********************************************************************************************
105 
106  //**Return type evaluation**********************************************************************
108 
113  static constexpr bool returnExpr = ( !IsTemporary_v<RN1> && !IsTemporary_v<RN2> );
114 
116  using ExprReturnType = decltype( std::declval<RN1>() * std::declval<RN2>() );
117  //**********************************************************************************************
118 
119  public:
120  //**Type definitions****************************************************************************
127 
130 
132  using CompositeType = const ResultType;
133 
135  using LeftOperand = If_t< IsExpression_v<MT1>, const MT1, const MT1& >;
136 
138  using RightOperand = If_t< IsExpression_v<MT2>, const MT2, const MT2& >;
139  //**********************************************************************************************
140 
141  //**Compilation flags***************************************************************************
143  static constexpr bool simdEnabled = false;
144 
146  static constexpr bool smpAssignable = false;
147  //**********************************************************************************************
148 
149  //**Constructor*********************************************************************************
155  explicit inline DMatDMatKronExpr( const MT1& lhs, const MT2& rhs ) noexcept
156  : lhs_( lhs ) // Left-hand side dense matrix of the Kronecker product expression
157  , rhs_( rhs ) // Right-hand side dense matrix of the Kronecker product expression
158  {}
159  //**********************************************************************************************
160 
161  //**Access operator*****************************************************************************
168  inline ReturnType operator()( size_t i, size_t j ) const {
169  BLAZE_INTERNAL_ASSERT( i < rows() , "Invalid row access index" );
170  BLAZE_INTERNAL_ASSERT( j < columns(), "Invalid column access index" );
171  return lhs_( i/rhs_.rows(), j/rhs_.columns() ) * rhs_( i%rhs_.rows(), j%rhs_.columns() );
172  }
173  //**********************************************************************************************
174 
175  //**At function*********************************************************************************
183  inline ReturnType at( size_t i, size_t j ) const {
184  if( i >= rows() ) {
185  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
186  }
187  if( j >= columns() ) {
188  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
189  }
190  return (*this)(i,j);
191  }
192  //**********************************************************************************************
193 
194  //**Rows function*******************************************************************************
199  inline size_t rows() const noexcept {
200  return lhs_.rows() * rhs_.rows();
201  }
202  //**********************************************************************************************
203 
204  //**Columns function****************************************************************************
209  inline size_t columns() const noexcept {
210  return lhs_.columns() * rhs_.columns();
211  }
212  //**********************************************************************************************
213 
214  //**Left operand access*************************************************************************
219  inline LeftOperand leftOperand() const noexcept {
220  return lhs_;
221  }
222  //**********************************************************************************************
223 
224  //**Right operand access************************************************************************
229  inline RightOperand rightOperand() const noexcept {
230  return rhs_;
231  }
232  //**********************************************************************************************
233 
234  //**********************************************************************************************
240  template< typename T >
241  inline bool canAlias( const T* alias ) const noexcept {
242  return ( lhs_.canAlias( alias ) || rhs_.canAlias( alias ) );
243  }
244  //**********************************************************************************************
245 
246  //**********************************************************************************************
252  template< typename T >
253  inline bool isAliased( const T* alias ) const noexcept {
254  return ( lhs_.isAliased( alias ) || rhs_.isAliased( alias ) );
255  }
256  //**********************************************************************************************
257 
258  //**********************************************************************************************
263  inline bool isAligned() const noexcept {
264  return rhs_.isAligned();
265  }
266  //**********************************************************************************************
267 
268  //**********************************************************************************************
273  inline bool canSMPAssign() const noexcept {
274  return false;
275  }
276  //**********************************************************************************************
277 
278  private:
279  //**Member variables****************************************************************************
282  //**********************************************************************************************
283 
284  //**Assignment to row-major dense matrices******************************************************
297  template< typename MT > // Type of the target dense matrix
298  friend inline void assign( DenseMatrix<MT,false>& lhs, const DMatDMatKronExpr& rhs )
299  {
301 
302  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
303  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
304 
305  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
306  return;
307  }
308 
309  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
310  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
311 
312  const size_t M( B.rows() );
313  const size_t N( B.columns() );
314 
315  if( SO )
316  {
317  for( size_t i=0UL; i<A.rows(); ++i ) {
318  for( size_t j=0UL; j<A.columns(); ++j ) {
319  if( !isDefault( A(i,j) ) ) {
320  for( size_t l=0UL; l<N; ++l )
321  for( size_t k=0UL; k<M; ++k )
322  (~lhs)(i*M+k,j*N+l) = A(i,j) * B(k,l);
323  }
324  else {
325  for( size_t l=0UL; l<N; ++l )
326  for( size_t k=0UL; k<M; ++k )
327  reset( (~lhs)(i*M+k,j*N+l) );
328  }
329  }
330  }
331  }
332  else
333  {
334  for( size_t i=0UL; i<A.rows(); ++i ) {
335  for( size_t k=0UL; k<M; ++k ) {
336  for( size_t j=0UL; j<A.columns(); ++j ) {
337  if( !isDefault( A(i,j) ) ) {
338  for( size_t l=0UL; l<N; ++l )
339  (~lhs)(i*M+k,j*N+l) = A(i,j) * B(k,l);
340  }
341  else {
342  for( size_t l=0UL; l<N; ++l )
343  reset( (~lhs)(i*M+k,j*N+l) );
344  }
345  }
346  }
347  }
348  }
349  }
351  //**********************************************************************************************
352 
353  //**Assignment to column-major dense matrices***************************************************
366  template< typename MT > // Type of the target dense matrix
367  friend inline void assign( DenseMatrix<MT,true>& lhs, const DMatDMatKronExpr& rhs )
368  {
370 
371  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
372  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
373 
374  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
375  return;
376  }
377 
378  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
379  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
380 
381  const size_t M( B.rows() );
382  const size_t N( B.columns() );
383 
384  if( SO )
385  {
386  for( size_t j=0UL; j<A.columns(); ++j ) {
387  for( size_t l=0UL; l<N; ++l ) {
388  for( size_t i=0UL; i<A.rows(); ++i ) {
389  if( !isDefault( A(i,j) ) ) {
390  for( size_t k=0UL; k<M; ++k )
391  (~lhs)(i*M+k,j*N+l) = A(i,j) * B(k,l);
392  }
393  else {
394  for( size_t k=0UL; k<M; ++k )
395  reset( (~lhs)(i*M+k,j*N+l) );
396  }
397  }
398  }
399  }
400  }
401  else
402  {
403  for( size_t j=0UL; j<A.columns(); ++j ) {
404  for( size_t i=0UL; i<A.rows(); ++i ) {
405  if( !isDefault( A(i,j) ) ) {
406  for( size_t k=0UL; k<M; ++k )
407  for( size_t l=0UL; l<N; ++l )
408  (~lhs)(i*M+k,j*N+l) = A(i,j) * B(k,l);
409  }
410  else {
411  for( size_t k=0UL; k<M; ++k )
412  for( size_t l=0UL; l<N; ++l )
413  reset( (~lhs)(i*M+k,j*N+l) );
414  }
415  }
416  }
417  }
418  }
420  //**********************************************************************************************
421 
422  //**Assignment to sparse matrices***************************************************************
434  template< typename MT // Type of the target sparse matrix
435  , bool SO2 > // Storage order of the target sparse matrix
436  friend inline void assign( SparseMatrix<MT,SO2>& lhs, const DMatDMatKronExpr& rhs )
437  {
439 
440  using TmpType = If_t< SO == SO2, ResultType, OppositeType >;
441 
448 
449  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
450  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
451 
452  const TmpType tmp( serial( rhs ) );
453  assign( ~lhs, tmp );
454  }
456  //**********************************************************************************************
457 
458  //**Addition assignment to row-major dense matrices*********************************************
471  template< typename MT > // Type of the target dense matrix
472  friend inline void addAssign( DenseMatrix<MT,false>& lhs, const DMatDMatKronExpr& rhs )
473  {
475 
476  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
477  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
478 
479  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
480  return;
481  }
482 
483  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
484  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
485 
486  const size_t M( B.rows() );
487  const size_t N( B.columns() );
488 
489  if( SO )
490  {
491  for( size_t i=0UL; i<A.rows(); ++i )
492  for( size_t j=0UL; j<A.columns(); ++j )
493  if( !isDefault( A(i,j) ) )
494  for( size_t l=0UL; l<N; ++l )
495  {
496  const size_t kbegin( ( IsLower_v<MT2> )
497  ?( ( IsStrictlyLower_v<MT2> ? l+1UL : l ) )
498  :( 0UL ) );
499  const size_t kend( ( IsUpper_v<MT2> )
500  ?( IsStrictlyUpper_v<MT2> ? l : l+1UL )
501  :( M ) );
502  BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" );
503 
504  for( size_t k=kbegin; k<kend; ++k )
505  (~lhs)(i*M+k,j*N+l) += A(i,j) * B(k,l);
506  }
507  }
508  else
509  {
510  for( size_t i=0UL; i<A.rows(); ++i )
511  for( size_t k=0UL; k<M; ++k )
512  {
513  const size_t lbegin( ( IsUpper_v<MT2> )
514  ?( ( IsStrictlyUpper_v<MT2> ? k+1UL : k ) )
515  :( 0UL ) );
516  const size_t lend( ( IsLower_v<MT2> )
517  ?( IsStrictlyLower_v<MT2> ? k : k+1UL )
518  :( N ) );
519  BLAZE_INTERNAL_ASSERT( lbegin <= lend, "Invalid loop indices detected" );
520 
521  for( size_t j=0UL; j<A.columns(); ++j )
522  if( !isDefault( A(i,j) ) )
523  for( size_t l=lbegin; l<lend; ++l )
524  (~lhs)(i*M+k,j*N+l) += A(i,j) * B(k,l);
525  }
526  }
527  }
529  //**********************************************************************************************
530 
531  //**Addition assignment to column-major dense matrices******************************************
544  template< typename MT > // Type of the target dense matrix
545  friend inline void addAssign( DenseMatrix<MT,true>& lhs, const DMatDMatKronExpr& rhs )
546  {
548 
549  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
550  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
551 
552  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
553  return;
554  }
555 
556  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
557  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
558 
559  const size_t M( B.rows() );
560  const size_t N( B.columns() );
561 
562  if( SO )
563  {
564  for( size_t j=0UL; j<A.columns(); ++j )
565  for( size_t l=0UL; l<N; ++l )
566  {
567  const size_t kbegin( ( IsLower_v<MT2> )
568  ?( ( IsStrictlyLower_v<MT2> ? l+1UL : l ) )
569  :( 0UL ) );
570  const size_t kend( ( IsUpper_v<MT2> )
571  ?( IsStrictlyUpper_v<MT2> ? l : l+1UL )
572  :( M ) );
573  BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" );
574 
575  for( size_t i=0UL; i<A.rows(); ++i )
576  if( !isDefault( A(i,j) ) )
577  for( size_t k=kbegin; k<kend; ++k )
578  (~lhs)(i*M+k,j*N+l) += A(i,j) * B(k,l);
579  }
580  }
581  else
582  {
583  for( size_t j=0UL; j<A.columns(); ++j )
584  for( size_t i=0UL; i<A.rows(); ++i )
585  if( !isDefault( A(i,j) ) )
586  for( size_t k=0UL; k<M; ++k )
587  {
588  const size_t lbegin( ( IsUpper_v<MT2> )
589  ?( ( IsStrictlyUpper_v<MT2> ? k+1UL : k ) )
590  :( 0UL ) );
591  const size_t lend( ( IsLower_v<MT2> )
592  ?( IsStrictlyLower_v<MT2> ? k : k+1UL )
593  :( N ) );
594  BLAZE_INTERNAL_ASSERT( lbegin <= lend, "Invalid loop indices detected" );
595 
596  for( size_t l=lbegin; l<lend; ++l )
597  (~lhs)(i*M+k,j*N+l) += A(i,j) * B(k,l);
598  }
599  }
600  }
602  //**********************************************************************************************
603 
604  //**Addition assignment to sparse matrices******************************************************
605  // No special implementation for the addition assignment to sparse matrices.
606  //**********************************************************************************************
607 
608  //**Subtraction assignment to row-major dense matrices******************************************
621  template< typename MT > // Type of the target dense matrix
622  friend inline void subAssign( DenseMatrix<MT,false>& lhs, const DMatDMatKronExpr& rhs )
623  {
625 
626  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
627  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
628 
629  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
630  return;
631  }
632 
633  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
634  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
635 
636  const size_t M( B.rows() );
637  const size_t N( B.columns() );
638 
639  if( SO )
640  {
641  for( size_t i=0UL; i<A.rows(); ++i )
642  for( size_t j=0UL; j<A.columns(); ++j )
643  if( !isDefault( A(i,j) ) )
644  for( size_t l=0UL; l<N; ++l )
645  {
646  const size_t kbegin( ( IsLower_v<MT2> )
647  ?( ( IsStrictlyLower_v<MT2> ? l+1UL : l ) )
648  :( 0UL ) );
649  const size_t kend( ( IsUpper_v<MT2> )
650  ?( IsStrictlyUpper_v<MT2> ? l : l+1UL )
651  :( M ) );
652  BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" );
653 
654  for( size_t k=kbegin; k<kend; ++k )
655  (~lhs)(i*M+k,j*N+l) -= A(i,j) * B(k,l);
656  }
657  }
658  else
659  {
660  for( size_t i=0UL; i<A.rows(); ++i )
661  for( size_t k=0UL; k<M; ++k )
662  {
663  const size_t lbegin( ( IsUpper_v<MT2> )
664  ?( ( IsStrictlyUpper_v<MT2> ? k+1UL : k ) )
665  :( 0UL ) );
666  const size_t lend( ( IsLower_v<MT2> )
667  ?( IsStrictlyLower_v<MT2> ? k : k+1UL )
668  :( N ) );
669  BLAZE_INTERNAL_ASSERT( lbegin <= lend, "Invalid loop indices detected" );
670 
671  for( size_t j=0UL; j<A.columns(); ++j )
672  if( !isDefault( A(i,j) ) )
673  for( size_t l=lbegin; l<lend; ++l )
674  (~lhs)(i*M+k,j*N+l) -= A(i,j) * B(k,l);
675  }
676  }
677  }
679  //**********************************************************************************************
680 
681  //**Subtraction assignment to column-major dense matrices***************************************
694  template< typename MT > // Type of the target dense matrix
695  friend inline void subAssign( DenseMatrix<MT,true>& lhs, const DMatDMatKronExpr& rhs )
696  {
698 
699  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
700  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
701 
702  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
703  return;
704  }
705 
706  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
707  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
708 
709  const size_t M( B.rows() );
710  const size_t N( B.columns() );
711 
712  if( SO )
713  {
714  for( size_t j=0UL; j<A.columns(); ++j )
715  for( size_t l=0UL; l<N; ++l )
716  {
717  const size_t kbegin( ( IsLower_v<MT2> )
718  ?( ( IsStrictlyLower_v<MT2> ? l+1UL : l ) )
719  :( 0UL ) );
720  const size_t kend( ( IsUpper_v<MT2> )
721  ?( IsStrictlyUpper_v<MT2> ? l : l+1UL )
722  :( M ) );
723  BLAZE_INTERNAL_ASSERT( kbegin <= kend, "Invalid loop indices detected" );
724 
725  for( size_t i=0UL; i<A.rows(); ++i )
726  if( !isDefault( A(i,j) ) )
727  for( size_t k=kbegin; k<kend; ++k )
728  (~lhs)(i*M+k,j*N+l) -= A(i,j) * B(k,l);
729  }
730  }
731  else
732  {
733  for( size_t j=0UL; j<A.columns(); ++j )
734  for( size_t i=0UL; i<A.rows(); ++i )
735  if( !isDefault( A(i,j) ) )
736  for( size_t k=0UL; k<M; ++k )
737  {
738  const size_t lbegin( ( IsUpper_v<MT2> )
739  ?( ( IsStrictlyUpper_v<MT2> ? k+1UL : k ) )
740  :( 0UL ) );
741  const size_t lend( ( IsLower_v<MT2> )
742  ?( IsStrictlyLower_v<MT2> ? k : k+1UL )
743  :( N ) );
744  BLAZE_INTERNAL_ASSERT( lbegin <= lend, "Invalid loop indices detected" );
745 
746  for( size_t l=lbegin; l<lend; ++l )
747  (~lhs)(i*M+k,j*N+l) -= A(i,j) * B(k,l);
748  }
749  }
750  }
752  //**********************************************************************************************
753 
754  //**Subtraction assignment to sparse matrices***************************************************
755  // No special implementation for the subtraction assignment to sparse matrices.
756  //**********************************************************************************************
757 
758  //**Schur product assignment to row-major dense matrices****************************************
771  template< typename MT > // Type of the target dense matrix
772  friend inline void schurAssign( DenseMatrix<MT,false>& lhs, const DMatDMatKronExpr& rhs )
773  {
775 
776  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
777  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
778 
779  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
780  return;
781  }
782 
783  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
784  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
785 
786  const size_t M( B.rows() );
787  const size_t N( B.columns() );
788 
789  if( SO )
790  {
791  for( size_t i=0UL; i<A.rows(); ++i ) {
792  for( size_t j=0UL; j<A.columns(); ++j ) {
793  if( !isDefault( A(i,j) ) ) {
794  for( size_t l=0UL; l<N; ++l )
795  for( size_t k=0UL; k<M; ++k )
796  (~lhs)(i*M+k,j*N+l) *= A(i,j) * B(k,l);
797  }
798  else {
799  for( size_t l=0UL; l<N; ++l )
800  for( size_t k=0UL; k<M; ++k )
801  reset( (~lhs)(i*M+k,j*N+l) );
802  }
803  }
804  }
805  }
806  else
807  {
808  for( size_t i=0UL; i<A.rows(); ++i ) {
809  for( size_t k=0UL; k<M; ++k ) {
810  for( size_t j=0UL; j<A.columns(); ++j ) {
811  if( !isDefault( A(i,j) ) ) {
812  for( size_t l=0UL; l<N; ++l )
813  (~lhs)(i*M+k,j*N+l) *= A(i,j) * B(k,l);
814  }
815  else {
816  for( size_t l=0UL; l<N; ++l )
817  reset( (~lhs)(i*M+k,j*N+l) );
818  }
819  }
820  }
821  }
822  }
823  }
825  //**********************************************************************************************
826 
827  //**Schur product assignment to column-major dense matrices*************************************
840  template< typename MT > // Type of the target dense matrix
841  friend inline void schurAssign( DenseMatrix<MT,true>& lhs, const DMatDMatKronExpr& rhs )
842  {
844 
845  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
846  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
847 
848  if( rhs.rows() == 0UL || rhs.columns() == 0UL ) {
849  return;
850  }
851 
852  CT1 A( serial( rhs.lhs_ ) ); // Evaluation of the left-hand side dense matrix operand
853  CT2 B( serial( rhs.rhs_ ) ); // Evaluation of the right-hand side dense matrix operand
854 
855  const size_t M( B.rows() );
856  const size_t N( B.columns() );
857 
858  if( SO )
859  {
860  for( size_t j=0UL; j<A.columns(); ++j ) {
861  for( size_t l=0UL; l<N; ++l ) {
862  for( size_t i=0UL; i<A.rows(); ++i ) {
863  if( !isDefault( A(i,j) ) ) {
864  for( size_t k=0UL; k<M; ++k )
865  (~lhs)(i*M+k,j*N+l) *= A(i,j) * B(k,l);
866  }
867  else {
868  for( size_t k=0UL; k<M; ++k )
869  reset( (~lhs)(i*M+k,j*N+l) );
870  }
871  }
872  }
873  }
874  }
875  else
876  {
877  for( size_t j=0UL; j<A.columns(); ++j ) {
878  for( size_t i=0UL; i<A.rows(); ++i ) {
879  if( !isDefault( A(i,j) ) ) {
880  for( size_t k=0UL; k<M; ++k )
881  for( size_t l=0UL; l<N; ++l )
882  (~lhs)(i*M+k,j*N+l) *= A(i,j) * B(k,l);
883  }
884  else {
885  for( size_t k=0UL; k<M; ++k )
886  for( size_t l=0UL; l<N; ++l )
887  reset( (~lhs)(i*M+k,j*N+l) );
888  }
889  }
890  }
891  }
892  }
894  //**********************************************************************************************
895 
896  //**Schur product assignment to sparse matrices*************************************************
897  // No special implementation for the Schur product assignment to sparse matrices.
898  //**********************************************************************************************
899 
900  //**Multiplication assignment to dense matrices*************************************************
901  // No special implementation for the multiplication assignment to dense matrices.
902  //**********************************************************************************************
903 
904  //**Multiplication assignment to sparse matrices************************************************
905  // No special implementation for the multiplication assignment to sparse matrices.
906  //**********************************************************************************************
907 
908  //**Compile time checks*************************************************************************
915  //**********************************************************************************************
916 };
917 //*************************************************************************************************
918 
919 
920 
921 
922 //=================================================================================================
923 //
924 // GLOBAL FUNCTIONS
925 //
926 //=================================================================================================
927 
928 //*************************************************************************************************
949 template< typename MT1 // Type of the left-hand side dense matrix
950  , bool SO1 // Storage order of the left-hand side dense matrix
951  , typename MT2 // Type of the right-hand side dense matrix
952  , bool SO2 > // Storage order of the right-hand side dense matrix
953 inline decltype(auto)
954  kron( const DenseMatrix<MT1,SO1>& lhs, const DenseMatrix<MT2,SO2>& rhs )
955 {
957 
958  using ReturnType = const DMatDMatKronExpr<MT1,MT2,SO2>;
959  return ReturnType( ~lhs, ~rhs );
960 }
961 //*************************************************************************************************
962 
963 } // namespace blaze
964 
965 #endif
Expression object for dense matrix-dense matrix Kronecker products.The DMatDMatKronExpr class represe...
Definition: DMatDMatKronExpr.h:90
ResultType_t< MT2 > RT2
Result type of the right-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:97
Header file for auxiliary alias declarations.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatDMatKronExpr.h:253
Header file for the alignment flag values.
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
Definition: If.h:109
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatDMatKronExpr.h:126
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatDMatKronExpr.h:219
ElementType_t< MT1 > ET1
Element type of the left-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:102
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
Header file for the serial shim.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
#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:61
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatDMatKronExpr.h:129
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatDMatKronExpr.h:143
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Header file for the MAYBE_UNUSED function template.
Header file for the Computation base class.
Header file for the reset shim.
ReturnType_t< MT2 > RN2
Return type of the right-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:99
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
decltype(auto) kron(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the Kronecker product of two dense matrices ( ).
Definition: DMatDMatKronExpr.h:954
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatDMatKronExpr.h:273
Header file for the MatMatKronExpr base class.
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Base class for all matrix/matrix Kronecker expression templates.The MatMatKronExpr class serves as a ...
Definition: MatMatKronExpr.h:67
Constraint on the data type.
CompositeType_t< MT2 > CT2
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:101
decltype(std::declval< RN1 >() *std::declval< RN2 >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatDMatKronExpr.h:116
Header file for the IsTemporary type trait class.
Header file for the IsStrictlyUpper type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatDMatKronExpr.h:209
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatDMatKronExpr.h:146
typename KronTrait< T1, T2 >::Type KronTrait_t
Auxiliary alias declaration for the KronTrait class template.The KronTrait_t alias declaration provid...
Definition: KronTrait.h:163
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
Header file for the IsLower type trait.
RightOperand rightOperand() const noexcept
Returns the right-hand side dense matrix operand.
Definition: DMatDMatKronExpr.h:229
Header file for the Kron product trait.
Constraints on the storage order of matrix types.
ElementType_t< MT2 > ET2
Element type of the right-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:103
Header file for the exception macros of the math module.
Constraint on the data type.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatDMatKronExpr.h:199
Constraint on the data type.
Header file for the IsStrictlyLower type trait.
If_t< IsExpression_v< MT2 >, const MT2, const MT2 & > RightOperand
Composite type of the right-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:138
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
If_t< IsExpression_v< MT1 >, const MT1, const MT1 & > LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:135
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatDMatKronExpr.h:132
ReturnType_t< MT1 > RN1
Return type of the left-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:98
RightOperand rhs_
Right-hand side dense matrix of the Kronecker product expression.
Definition: DMatDMatKronExpr.h:281
DMatDMatKronExpr(const MT1 &lhs, const MT2 &rhs) noexcept
Constructor for the DMatDMatKronExpr class.
Definition: DMatDMatKronExpr.h:155
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.The TransposeType_t alias declaration pro...
Definition: Aliases.h:470
Header file for run time assertion macros.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatDMatKronExpr.h:183
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
Header file for all forward declarations for expression class templates.
Header file for the isDefault shim.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatDMatKronExpr.h:125
#define BLAZE_CONSTRAINT_MATRICES_MUST_HAVE_SAME_STORAGE_ORDER(T1, T2)
Constraint on the data type.In case either of the two given data types T1 or T2 is not a matrix type ...
Definition: StorageOrder.h:84
KronTrait_t< RT1, RT2 > ResultType
Result type for expression template evaluations.
Definition: DMatDMatKronExpr.h:123
LeftOperand lhs_
Left-hand side dense matrix of the Kronecker product expression.
Definition: DMatDMatKronExpr.h:280
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatDMatKronExpr.h:168
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatDMatKronExpr.h:263
#define BLAZE_CONSTRAINT_MUST_FORM_VALID_MATMATKRONEXPR(T1, T2)
Constraint on the data type.In case the given data types T1 and T2 do not form a valid matrix/matrix ...
Definition: MatMatKronExpr.h:102
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ResultType_t< MT1 > RT1
Result type of the left-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:96
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatDMatKronExpr.h:241
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
Header file for the IsUpper type trait.
CompositeType_t< MT1 > CT1
Composite type of the left-hand side dense matrix expression.
Definition: DMatDMatKronExpr.h:100
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatDMatKronExpr.h:113
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatDMatKronExpr.h:124