DMatScalarDivExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DMATSCALARDIVEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DMATSCALARDIVEXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <blaze/math/Aliases.h>
49 #include <blaze/math/Exception.h>
55 #include <blaze/math/SIMD.h>
70 #include <blaze/system/Inline.h>
72 #include <blaze/util/Assert.h>
76 #include <blaze/util/EnableIf.h>
78 #include <blaze/util/mpl/If.h>
79 #include <blaze/util/Types.h>
84 
85 
86 namespace blaze {
87 
88 //=================================================================================================
89 //
90 // CLASS DMATSCALARDIVEXPR
91 //
92 //=================================================================================================
93 
94 //*************************************************************************************************
101 template< typename MT // Type of the left-hand side dense matrix
102  , typename ST // Type of the right-hand side scalar value
103  , bool SO > // Storage order
105  : public MatScalarDivExpr< DenseMatrix< DMatScalarDivExpr<MT,ST,SO>, SO > >
106  , private Computation
107 {
108  private:
109  //**Type definitions****************************************************************************
114  //**********************************************************************************************
115 
116  //**Return type evaluation**********************************************************************
118 
123  static constexpr bool returnExpr = !IsTemporary_v<RN>;
124 
126  using ExprReturnType = decltype( std::declval<RN>() / std::declval<ST>() );
127  //**********************************************************************************************
128 
129  //**Serial evaluation strategy******************************************************************
131 
137  static constexpr bool useAssign = IsComputation_v<MT> && RequiresEvaluation_v<MT>;
138 
140  template< typename MT2 >
142  static constexpr bool UseAssign_v = useAssign;
144  //**********************************************************************************************
145 
146  //**Parallel evaluation strategy****************************************************************
148 
154  template< typename MT2 >
155  static constexpr bool UseSMPAssign_v =
158  //**********************************************************************************************
159 
160  public:
161  //**Type definitions****************************************************************************
168 
171 
174 
176  using LeftOperand = If_t< IsExpression_v<MT>, const MT, const MT& >;
177 
179  using RightOperand = ST;
180  //**********************************************************************************************
181 
182  //**ConstIterator class definition**************************************************************
186  {
187  public:
188  //**Type definitions*************************************************************************
189  using IteratorCategory = std::random_access_iterator_tag;
194 
195  // STL iterator requirements
201 
204  //*******************************************************************************************
205 
206  //**Constructor******************************************************************************
212  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
213  : iterator_( iterator ) // Iterator to the current element
214  , scalar_ ( scalar ) // Scalar of the multiplication expression
215  {}
216  //*******************************************************************************************
217 
218  //**Addition assignment operator*************************************************************
224  inline ConstIterator& operator+=( size_t inc ) {
225  iterator_ += inc;
226  return *this;
227  }
228  //*******************************************************************************************
229 
230  //**Subtraction assignment operator**********************************************************
236  inline ConstIterator& operator-=( size_t dec ) {
237  iterator_ -= dec;
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Prefix increment operator****************************************************************
248  ++iterator_;
249  return *this;
250  }
251  //*******************************************************************************************
252 
253  //**Postfix increment operator***************************************************************
258  inline const ConstIterator operator++( int ) {
259  return ConstIterator( iterator_++ );
260  }
261  //*******************************************************************************************
262 
263  //**Prefix decrement operator****************************************************************
269  --iterator_;
270  return *this;
271  }
272  //*******************************************************************************************
273 
274  //**Postfix decrement operator***************************************************************
279  inline const ConstIterator operator--( int ) {
280  return ConstIterator( iterator_-- );
281  }
282  //*******************************************************************************************
283 
284  //**Element access operator******************************************************************
289  inline ReturnType operator*() const {
290  return *iterator_ / scalar_;
291  }
292  //*******************************************************************************************
293 
294  //**Load function****************************************************************************
299  inline auto load() const noexcept {
300  return iterator_.load() / set( scalar_ );
301  }
302  //*******************************************************************************************
303 
304  //**Equality operator************************************************************************
310  inline bool operator==( const ConstIterator& rhs ) const {
311  return iterator_ == rhs.iterator_;
312  }
313  //*******************************************************************************************
314 
315  //**Inequality operator**********************************************************************
321  inline bool operator!=( const ConstIterator& rhs ) const {
322  return iterator_ != rhs.iterator_;
323  }
324  //*******************************************************************************************
325 
326  //**Less-than operator***********************************************************************
332  inline bool operator<( const ConstIterator& rhs ) const {
333  return iterator_ < rhs.iterator_;
334  }
335  //*******************************************************************************************
336 
337  //**Greater-than operator********************************************************************
343  inline bool operator>( const ConstIterator& rhs ) const {
344  return iterator_ > rhs.iterator_;
345  }
346  //*******************************************************************************************
347 
348  //**Less-or-equal-than operator**************************************************************
354  inline bool operator<=( const ConstIterator& rhs ) const {
355  return iterator_ <= rhs.iterator_;
356  }
357  //*******************************************************************************************
358 
359  //**Greater-or-equal-than operator***********************************************************
365  inline bool operator>=( const ConstIterator& rhs ) const {
366  return iterator_ >= rhs.iterator_;
367  }
368  //*******************************************************************************************
369 
370  //**Subtraction operator*********************************************************************
376  inline DifferenceType operator-( const ConstIterator& rhs ) const {
377  return iterator_ - rhs.iterator_;
378  }
379  //*******************************************************************************************
380 
381  //**Addition operator************************************************************************
388  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
389  return ConstIterator( it.iterator_ + inc, it.scalar_ );
390  }
391  //*******************************************************************************************
392 
393  //**Addition operator************************************************************************
400  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
401  return ConstIterator( it.iterator_ + inc, it.scalar_ );
402  }
403  //*******************************************************************************************
404 
405  //**Subtraction operator*********************************************************************
412  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
413  return ConstIterator( it.iterator_ - dec, it.scalar_ );
414  }
415  //*******************************************************************************************
416 
417  private:
418  //**Member variables*************************************************************************
421  //*******************************************************************************************
422  };
423  //**********************************************************************************************
424 
425  //**Compilation flags***************************************************************************
427  static constexpr bool simdEnabled =
428  ( MT::simdEnabled && IsNumeric_v<ET> &&
429  ( HasSIMDDiv_v<ET,ST> || HasSIMDDiv_v<UnderlyingElement_t<ET>,ST> ) );
430 
432  static constexpr bool smpAssignable = MT::smpAssignable;
433  //**********************************************************************************************
434 
435  //**SIMD properties*****************************************************************************
437  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
438  //**********************************************************************************************
439 
440  //**Constructor*********************************************************************************
446  explicit inline DMatScalarDivExpr( const MT& matrix, ST scalar ) noexcept
447  : matrix_( matrix ) // Left-hand side dense matrix of the division expression
448  , scalar_( scalar ) // Right-hand side scalar of the division expression
449  {}
450  //**********************************************************************************************
451 
452  //**Access operator*****************************************************************************
459  inline ReturnType operator()( size_t i, size_t j ) const {
460  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
461  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
462  return matrix_(i,j) / scalar_;
463  }
464  //**********************************************************************************************
465 
466  //**At function*********************************************************************************
474  inline ReturnType at( size_t i, size_t j ) const {
475  if( i >= matrix_.rows() ) {
476  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
477  }
478  if( j >= matrix_.columns() ) {
479  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
480  }
481  return (*this)(i,j);
482  }
483  //**********************************************************************************************
484 
485  //**Load function*******************************************************************************
492  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
493  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
494  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
495  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
496  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
497  return matrix_.load(i,j) / set( scalar_ );
498  }
499  //**********************************************************************************************
500 
501  //**Begin function******************************************************************************
507  inline ConstIterator begin( size_t i ) const {
508  return ConstIterator( matrix_.begin(i), scalar_ );
509  }
510  //**********************************************************************************************
511 
512  //**End function********************************************************************************
518  inline ConstIterator end( size_t i ) const {
519  return ConstIterator( matrix_.end(i), scalar_ );
520  }
521  //**********************************************************************************************
522 
523  //**Rows function*******************************************************************************
528  inline size_t rows() const noexcept {
529  return matrix_.rows();
530  }
531  //**********************************************************************************************
532 
533  //**Columns function****************************************************************************
538  inline size_t columns() const noexcept {
539  return matrix_.columns();
540  }
541  //**********************************************************************************************
542 
543  //**Left operand access*************************************************************************
548  inline LeftOperand leftOperand() const noexcept {
549  return matrix_;
550  }
551  //**********************************************************************************************
552 
553  //**Right operand access************************************************************************
558  inline RightOperand rightOperand() const noexcept {
559  return scalar_;
560  }
561  //**********************************************************************************************
562 
563  //**********************************************************************************************
569  template< typename T >
570  inline bool canAlias( const T* alias ) const noexcept {
571  return IsExpression_v<MT> && matrix_.canAlias( alias );
572  }
573  //**********************************************************************************************
574 
575  //**********************************************************************************************
581  template< typename T >
582  inline bool isAliased( const T* alias ) const noexcept {
583  return matrix_.isAliased( alias );
584  }
585  //**********************************************************************************************
586 
587  //**********************************************************************************************
592  inline bool isAligned() const noexcept {
593  return matrix_.isAligned();
594  }
595  //**********************************************************************************************
596 
597  //**********************************************************************************************
602  inline bool canSMPAssign() const noexcept {
603  return matrix_.canSMPAssign() ||
604  ( rows() * columns() >= SMP_DMATSCALARMULT_THRESHOLD );
605  }
606  //**********************************************************************************************
607 
608  private:
609  //**Member variables****************************************************************************
612  //**********************************************************************************************
613 
614  //**Assignment to dense matrices****************************************************************
628  template< typename MT2 // Type of the target dense matrix
629  , bool SO2 > // Storage order of the target dense matrix
630  friend inline auto assign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
632  {
634 
635  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
636  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
637 
638  assign( ~lhs, rhs.matrix_ );
639  assign( ~lhs, (~lhs) / rhs.scalar_ );
640  }
642  //**********************************************************************************************
643 
644  //**Assignment to sparse matrices***************************************************************
658  template< typename MT2 // Type of the target sparse matrix
659  , bool SO2 > // Storage order of the target sparse matrix
660  friend inline auto assign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
662  {
664 
665  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
666  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
667 
668  assign( ~lhs, rhs.matrix_ );
669  (~lhs) /= rhs.scalar_;
670  }
672  //**********************************************************************************************
673 
674  //**Addition assignment to dense matrices*******************************************************
688  template< typename MT2 // Type of the target dense matrix
689  , bool SO2 > // Storage order of the target dense matrix
690  friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
691  -> EnableIf_t< UseAssign_v<MT2> >
692  {
694 
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  const ResultType tmp( serial( rhs ) );
703  addAssign( ~lhs, tmp );
704  }
706  //**********************************************************************************************
707 
708  //**Addition assignment to sparse matrices******************************************************
709  // No special implementation for the addition assignment to sparse matrices.
710  //**********************************************************************************************
711 
712  //**Subtraction assignment to dense matrices****************************************************
726  template< typename MT2 // Type of the target dense matrix
727  , bool SO2 > // Storage order of the target dense matrix
728  friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
729  -> EnableIf_t< UseAssign_v<MT2> >
730  {
732 
736 
737  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
738  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
739 
740  const ResultType tmp( serial( rhs ) );
741  subAssign( ~lhs, tmp );
742  }
744  //**********************************************************************************************
745 
746  //**Subtraction assignment to sparse matrices***************************************************
747  // No special implementation for the subtraction assignment to sparse matrices.
748  //**********************************************************************************************
749 
750  //**Schur product assignment to dense matrices**************************************************
764  template< typename MT2 // Type of the target dense matrix
765  , bool SO2 > // Storage order of the target dense matrix
766  friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
767  -> EnableIf_t< UseAssign_v<MT2> >
768  {
770 
774 
775  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
776  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
777 
778  const ResultType tmp( serial( rhs ) );
779  schurAssign( ~lhs, tmp );
780  }
782  //**********************************************************************************************
783 
784  //**Schur product assignment to sparse matrices*************************************************
785  // No special implementation for the Schur product assignment to sparse matrices.
786  //**********************************************************************************************
787 
788  //**Multiplication assignment to dense matrices*************************************************
789  // No special implementation for the multiplication assignment to dense matrices.
790  //**********************************************************************************************
791 
792  //**Multiplication assignment to sparse matrices************************************************
793  // No special implementation for the multiplication assignment to sparse matrices.
794  //**********************************************************************************************
795 
796  //**SMP assignment to dense matrices************************************************************
810  template< typename MT2 // Type of the target dense matrix
811  , bool SO2 > // Storage order of the target dense matrix
812  friend inline auto smpAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
813  -> EnableIf_t< UseSMPAssign_v<MT2> >
814  {
816 
817  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
818  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
819 
820  smpAssign( ~lhs, rhs.matrix_ );
821  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
822  }
824  //**********************************************************************************************
825 
826  //**SMP assignment to sparse matrices***********************************************************
840  template< typename MT2 // Type of the target sparse matrix
841  , bool SO2 > // Storage order of the target sparse matrix
842  friend inline auto smpAssign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
843  -> EnableIf_t< UseSMPAssign_v<MT2> >
844  {
846 
847  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
848  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
849 
850  smpAssign( ~lhs, rhs.matrix_ );
851  (~lhs) /= rhs.scalar_;
852  }
854  //**********************************************************************************************
855 
856  //**SMP addition assignment to dense matrices***************************************************
870  template< typename MT2 // Type of the target dense matrix
871  , bool SO2 > // Storage order of the target dense matrix
872  friend inline auto smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
873  -> EnableIf_t< UseSMPAssign_v<MT2> >
874  {
876 
880 
881  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
882  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
883 
884  const ResultType tmp( rhs );
885  smpAddAssign( ~lhs, tmp );
886  }
888  //**********************************************************************************************
889 
890  //**SMP addition assignment to sparse matrices**************************************************
891  // No special implementation for the SMP addition assignment to sparse matrices.
892  //**********************************************************************************************
893 
894  //**SMP subtraction assignment to dense matrices************************************************
908  template< typename MT2 // Type of the target dense matrix
909  , bool SO2 > // Storage order of the target dense matrix
910  friend inline auto smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
911  -> EnableIf_t< UseSMPAssign_v<MT2> >
912  {
914 
918 
919  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
920  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
921 
922  const ResultType tmp( rhs );
923  smpSubAssign( ~lhs, tmp );
924  }
926  //**********************************************************************************************
927 
928  //**SMP subtraction assignment to sparse matrices***********************************************
929  // No special implementation for the SMP subtraction assignment to sparse matrices.
930  //**********************************************************************************************
931 
932  //**SMP Schur product assignment to dense matrices**********************************************
946  template< typename MT2 // Type of the target dense matrix
947  , bool SO2 > // Storage order of the target dense matrix
948  friend inline auto smpSchurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
949  -> EnableIf_t< UseSMPAssign_v<MT2> >
950  {
952 
956 
957  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
958  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
959 
960  const ResultType tmp( rhs );
961  smpSchurAssign( ~lhs, tmp );
962  }
964  //**********************************************************************************************
965 
966  //**SMP Schur product assignment to sparse matrices*********************************************
967  // No special implementation for the SMP Schur product assignment to sparse matrices.
968  //**********************************************************************************************
969 
970  //**SMP multiplication assignment to dense matrices*********************************************
971  // No special implementation for the SMP multiplication assignment to dense matrices.
972  //**********************************************************************************************
973 
974  //**SMP multiplication assignment to sparse matrices********************************************
975  // No special implementation for the SMP multiplication assignment to sparse matrices.
976  //**********************************************************************************************
977 
978  //**Compile time checks*************************************************************************
987  //**********************************************************************************************
988 };
989 //*************************************************************************************************
990 
991 
992 
993 
994 //=================================================================================================
995 //
996 // GLOBAL BINARY ARITHMETIC OPERATORS
997 //
998 //=================================================================================================
999 
1000 //*************************************************************************************************
1005 template< typename MT // Type of the left-hand side dense matrix
1006  , typename ST // Type of the right-hand side scalar
1007  , bool SO > // Storage order
1008 struct DMatScalarDivExprHelper
1009 {
1010  private:
1011  //**********************************************************************************************
1012  using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<MT> > ||
1013  IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
1014  , If_t< IsComplex_v< UnderlyingNumeric_t<MT> > && IsBuiltin_v<ST>
1015  , DivTrait_t< UnderlyingBuiltin_t<MT>, ST >
1016  , DivTrait_t< UnderlyingNumeric_t<MT>, ST > >
1017  , ST >;
1018  //**********************************************************************************************
1019 
1020  public:
1021  //**********************************************************************************************
1022  using Type = If_t< IsInvertible_v<ScalarType>
1023  , DMatScalarMultExpr<MT,ScalarType,SO>
1024  , DMatScalarDivExpr<MT,ScalarType,SO> >;
1025  //**********************************************************************************************
1026 };
1028 //*************************************************************************************************
1029 
1030 
1031 //*************************************************************************************************
1053 template< typename MT // Type of the left-hand side dense matrix
1054  , bool SO // Storage order of the left-hand side dense matrix
1055  , typename ST // Type of the right-hand side scalar
1056  , EnableIf_t< IsNumeric_v<ST> >* = nullptr >
1057 inline decltype(auto) operator/( const DenseMatrix<MT,SO>& mat, ST scalar )
1058 {
1060 
1061  BLAZE_USER_ASSERT( scalar != ST(0), "Division by zero detected" );
1062 
1063  using ReturnType = typename DMatScalarDivExprHelper<MT,ST,SO>::Type;
1064  using ScalarType = RightOperand_t<ReturnType>;
1065 
1066  if( IsMultExpr_v<ReturnType> ) {
1067  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
1068  }
1069  else {
1070  return ReturnType( ~mat, scalar );
1071  }
1072 }
1073 //*************************************************************************************************
1074 
1075 
1076 
1077 
1078 //=================================================================================================
1079 //
1080 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
1081 //
1082 //=================================================================================================
1083 
1084 //*************************************************************************************************
1097 template< typename MT // Type of the dense matrix of the left-hand side expression
1098  , typename ST1 // Type of the scalar of the left-hand side expression
1099  , bool SO // Storage order of the dense matrix
1100  , typename ST2 // Type of the right-hand side scalar
1101  , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* = nullptr >
1102 inline decltype(auto) operator*( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1103 {
1105 
1106  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1107 }
1109 //*************************************************************************************************
1110 
1111 
1112 //*************************************************************************************************
1125 template< typename ST1 // Type of the left-hand side scalar
1126  , typename MT // Type of the dense matrix of the right-hand side expression
1127  , typename ST2 // Type of the scalar of the right-hand side expression
1128  , bool SO // Storage order of the dense matrix
1129  , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* = nullptr >
1130 inline decltype(auto) operator*( ST1 scalar, const DMatScalarDivExpr<MT,ST2,SO>& mat )
1131 {
1133 
1134  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1135 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1153 template< typename MT // Type of the dense matrix of the left-hand side expression
1154  , typename ST1 // Type of the scalar of the left-hand side expression
1155  , bool SO // Storage order of the dense matrix
1156  , typename ST2 // Type of the right-hand side scalar
1157  , EnableIf_t< IsNumeric_v<ST2> >* = nullptr >
1158 inline decltype(auto) operator/( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1159 {
1161 
1162  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1163 
1164  using MultType = MultTrait_t<ST1,ST2>;
1165  using ReturnType = typename DMatScalarDivExprHelper<MT,MultType,SO>::Type;
1166  using ScalarType = RightOperand_t<ReturnType>;
1167 
1168  if( IsMultExpr_v<ReturnType> ) {
1169  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
1170  }
1171  else {
1172  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
1173  }
1174 }
1176 //*************************************************************************************************
1177 
1178 
1179 
1180 
1181 //=================================================================================================
1182 //
1183 // ISALIGNED SPECIALIZATIONS
1184 //
1185 //=================================================================================================
1186 
1187 //*************************************************************************************************
1189 template< typename MT, typename ST, bool SO >
1190 struct IsAligned< DMatScalarDivExpr<MT,ST,SO> >
1191  : public IsAligned<MT>
1192 {};
1194 //*************************************************************************************************
1195 
1196 
1197 
1198 
1199 //=================================================================================================
1200 //
1201 // ISPADDED SPECIALIZATIONS
1202 //
1203 //=================================================================================================
1204 
1205 //*************************************************************************************************
1207 template< typename MT, typename ST, bool SO >
1208 struct IsPadded< DMatScalarDivExpr<MT,ST,SO> >
1209  : public IsPadded<MT>
1210 {};
1212 //*************************************************************************************************
1213 
1214 } // namespace blaze
1215 
1216 #endif
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatScalarDivExpr.h:193
Header file for the UnderlyingNumeric type trait.
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatScalarDivExpr.h:570
Pointer difference type of the Blaze library.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatScalarDivExpr.h:165
Header file for auxiliary alias declarations.
Data type constraint.
Constraint on the data type.
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:332
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatScalarDivExpr.h:538
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatScalarDivExpr.h:548
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:343
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatScalarDivExpr.h:528
Header file for basic type definitions.
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatScalarDivExpr.h:376
Base class for all matrix/scalar division expression templates.The MatScalarDivExpr class serves as a...
Definition: MatScalarDivExpr.h:66
ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatScalarDivExpr.h:268
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
typename DivTrait< T1, T2 >::Type DivTrait_t
Auxiliary alias declaration for the DivTrait class template.The DivTrait_t alias declaration provides...
Definition: DivTrait.h:239
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row i.
Definition: DMatScalarDivExpr.h:507
#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
decltype(std::declval< RN >()/std::declval< ST >()) ExprReturnType
Expression return type for the subscript operator.
Definition: DMatScalarDivExpr.h:126
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatScalarDivExpr.h:602
ElementType ValueType
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:190
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
Iterator over the elements of the dense matrix.
Definition: DMatScalarDivExpr.h:185
Expression object for divisions of a dense matrix by a scalar.The DMatScalarDivExpr class represents ...
Definition: DMatScalarDivExpr.h:104
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatScalarDivExpr.h:224
Header file for the Computation base class.
CompositeType_t< MT > CT
Composite type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:113
Header file for the UnderlyingElement type trait.
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatScalarDivExpr.h:299
Header file for the RequiresEvaluation type trait.
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.The ReturnType_t alias declaration provides ...
Definition: Aliases.h:410
RightOperand rightOperand() const noexcept
Returns the right-hand side scalar operand.
Definition: DMatScalarDivExpr.h:558
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:80
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:137
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatScalarDivExpr.h:236
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: DMatScalarDivExpr.h:592
ElementType * PointerType
Pointer return type.
Definition: DMatScalarDivExpr.h:191
Header file for the IsTemporary type trait class.
Header file for the multiplication trait.
DivTrait_t< RT, ST > ResultType
Result type for expression template evaluations.
Definition: DMatScalarDivExpr.h:164
If_t< useAssign, const ResultType, const DMatScalarDivExpr &> CompositeType
Data type for composite expression templates.
Definition: DMatScalarDivExpr.h:173
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
Header file for the UnderlyingBuiltin type trait.
Header file for the IsMultExpr type trait class.
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatScalarDivExpr.h:167
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: DMatScalarDivExpr.h:289
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:365
#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
ReferenceType reference
Reference return type.
Definition: DMatScalarDivExpr.h:199
Header file for the DenseMatrix base class.
ElementType_t< MT > ET
Element type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:112
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
DMatScalarDivExpr(const MT &matrix, ST scalar) noexcept
Constructor for the DMatScalarDivExpr class.
Definition: DMatScalarDivExpr.h:446
Header file for all SIMD functionality.
ElementType & ReferenceType
Reference return type.
Definition: DMatScalarDivExpr.h:192
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DMatScalarDivExpr.h:179
#define BLAZE_CONSTRAINT_MUST_BE_SAME_TYPE(A, B)
Data type constraint.In case the two types A and B are not the same (ignoring all cv-qualifiers of bo...
Definition: SameType.h:71
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatScalarDivExpr.h:432
Header file for the IsAligned type trait.
IteratorType iterator_
Iterator to the current element.
Definition: DMatScalarDivExpr.h:419
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatScalarDivExpr.h:437
const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatScalarDivExpr.h:258
ReturnType_t< MT > RN
Return type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:111
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatScalarDivExpr.h:170
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatScalarDivExpr.h:189
const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatScalarDivExpr.h:279
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE auto load(size_t i, size_t j) const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatScalarDivExpr.h:492
RightOperand scalar_
Scalar of the multiplication expression.
Definition: DMatScalarDivExpr.h:420
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatScalarDivExpr.h:427
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: DMatScalarDivExpr.h:247
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
ReturnType operator()(size_t i, size_t j) const
2D-access to the matrix elements.
Definition: DMatScalarDivExpr.h:459
Header file for the IsNumeric type trait.
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row i.
Definition: DMatScalarDivExpr.h:518
LeftOperand matrix_
Left-hand side dense matrix of the division expression.
Definition: DMatScalarDivExpr.h:610
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DMatScalarDivExpr.h:611
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DMatScalarDivExpr.h:212
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatScalarDivExpr.h:123
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
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
Header file for the division trait.
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: DMatScalarDivExpr.h:412
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
#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
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
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: DMatScalarDivExpr.h:166
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:310
IteratorCategory iterator_category
The iterator category.
Definition: DMatScalarDivExpr.h:196
ValueType value_type
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:197
Header file for the IsInvertible type trait.
PointerType pointer
Pointer return type.
Definition: DMatScalarDivExpr.h:198
#define BLAZE_CONSTRAINT_MUST_NOT_BE_FLOATING_POINT_TYPE(T)
Constraint on the data type.In case the given data type T is a floating point data type...
Definition: FloatingPoint.h:81
ResultType_t< MT > RT
Result type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:110
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
Header file for the HasSIMDDiv type trait.
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: DMatScalarDivExpr.h:388
Header file for the IsComplex type trait.
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: DMatScalarDivExpr.h:400
ConstIterator_t< MT > IteratorType
ConstIterator type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:203
typename T::RightOperand RightOperand_t
Alias declaration for nested RightOperand type definitions.The RightOperand_t alias declaration provi...
Definition: Aliases.h:430
static constexpr bool useAssign
Compilation switch for the serial evaluation strategy of the division expression. ...
Definition: DMatScalarDivExpr.h:137
Header file for the MatScalarDivExpr base class.
If_t< IsExpression_v< MT >, const MT, const MT &> LeftOperand
Composite type of the left-hand side dense matrix expression.
Definition: DMatScalarDivExpr.h:176
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatScalarDivExpr.h:474
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:354
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:321
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatScalarDivExpr.h:582