Blaze  3.6
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>
71 #include <blaze/system/Inline.h>
73 #include <blaze/util/Assert.h>
77 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/mpl/If.h>
80 #include <blaze/util/Types.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS DMATSCALARDIVEXPR
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
102 template< typename MT // Type of the left-hand side dense matrix
103  , typename ST // Type of the right-hand side scalar value
104  , bool SO > // Storage order
106  : public MatScalarDivExpr< DenseMatrix< DMatScalarDivExpr<MT,ST,SO>, SO > >
107  , private Computation
108 {
109  private:
110  //**Type definitions****************************************************************************
115  //**********************************************************************************************
116 
117  //**Return type evaluation**********************************************************************
119 
124  static constexpr bool returnExpr = !IsTemporary_v<RN>;
125 
127  using ExprReturnType = decltype( std::declval<RN>() / std::declval<ST>() );
128  //**********************************************************************************************
129 
130  //**Serial evaluation strategy******************************************************************
132 
138  static constexpr bool useAssign = IsComputation_v<MT> && RequiresEvaluation_v<MT>;
139 
141  template< typename MT2 >
143  static constexpr bool UseAssign_v = useAssign;
145  //**********************************************************************************************
146 
147  //**Parallel evaluation strategy****************************************************************
149 
155  template< typename MT2 >
156  static constexpr bool UseSMPAssign_v =
157  ( ( !MT2::smpAssignable || !MT::smpAssignable ) && useAssign );
159  //**********************************************************************************************
160 
161  public:
162  //**Type definitions****************************************************************************
169 
172 
175 
177  using LeftOperand = If_t< IsExpression_v<MT>, const MT, const MT& >;
178 
180  using RightOperand = ST;
181  //**********************************************************************************************
182 
183  //**ConstIterator class definition**************************************************************
187  {
188  public:
189  //**Type definitions*************************************************************************
190  using IteratorCategory = std::random_access_iterator_tag;
195 
196  // STL iterator requirements
202 
205  //*******************************************************************************************
206 
207  //**Constructor******************************************************************************
213  explicit inline ConstIterator( IteratorType iterator, RightOperand scalar )
214  : iterator_( iterator ) // Iterator to the current element
215  , scalar_ ( scalar ) // Scalar of the multiplication expression
216  {}
217  //*******************************************************************************************
218 
219  //**Addition assignment operator*************************************************************
226  iterator_ += inc;
227  return *this;
228  }
229  //*******************************************************************************************
230 
231  //**Subtraction assignment operator**********************************************************
238  iterator_ -= dec;
239  return *this;
240  }
241  //*******************************************************************************************
242 
243  //**Prefix increment operator****************************************************************
249  ++iterator_;
250  return *this;
251  }
252  //*******************************************************************************************
253 
254  //**Postfix increment operator***************************************************************
260  return ConstIterator( iterator_++, scalar_ );
261  }
262  //*******************************************************************************************
263 
264  //**Prefix decrement operator****************************************************************
270  --iterator_;
271  return *this;
272  }
273  //*******************************************************************************************
274 
275  //**Postfix decrement operator***************************************************************
281  return ConstIterator( iterator_--, scalar_ );
282  }
283  //*******************************************************************************************
284 
285  //**Element access operator******************************************************************
290  inline ReturnType operator*() const {
291  return *iterator_ / scalar_;
292  }
293  //*******************************************************************************************
294 
295  //**Load function****************************************************************************
300  inline auto load() const noexcept {
301  return iterator_.load() / set( scalar_ );
302  }
303  //*******************************************************************************************
304 
305  //**Equality operator************************************************************************
311  inline bool operator==( const ConstIterator& rhs ) const {
312  return iterator_ == rhs.iterator_;
313  }
314  //*******************************************************************************************
315 
316  //**Inequality operator**********************************************************************
322  inline bool operator!=( const ConstIterator& rhs ) const {
323  return iterator_ != rhs.iterator_;
324  }
325  //*******************************************************************************************
326 
327  //**Less-than operator***********************************************************************
333  inline bool operator<( const ConstIterator& rhs ) const {
334  return iterator_ < rhs.iterator_;
335  }
336  //*******************************************************************************************
337 
338  //**Greater-than operator********************************************************************
344  inline bool operator>( const ConstIterator& rhs ) const {
345  return iterator_ > rhs.iterator_;
346  }
347  //*******************************************************************************************
348 
349  //**Less-or-equal-than operator**************************************************************
355  inline bool operator<=( const ConstIterator& rhs ) const {
356  return iterator_ <= rhs.iterator_;
357  }
358  //*******************************************************************************************
359 
360  //**Greater-or-equal-than operator***********************************************************
366  inline bool operator>=( const ConstIterator& rhs ) const {
367  return iterator_ >= rhs.iterator_;
368  }
369  //*******************************************************************************************
370 
371  //**Subtraction operator*********************************************************************
377  inline DifferenceType operator-( const ConstIterator& rhs ) const {
378  return iterator_ - rhs.iterator_;
379  }
380  //*******************************************************************************************
381 
382  //**Addition operator************************************************************************
389  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
390  return ConstIterator( it.iterator_ + inc, it.scalar_ );
391  }
392  //*******************************************************************************************
393 
394  //**Addition operator************************************************************************
401  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
402  return ConstIterator( it.iterator_ + inc, it.scalar_ );
403  }
404  //*******************************************************************************************
405 
406  //**Subtraction operator*********************************************************************
413  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
414  return ConstIterator( it.iterator_ - dec, it.scalar_ );
415  }
416  //*******************************************************************************************
417 
418  private:
419  //**Member variables*************************************************************************
422  //*******************************************************************************************
423  };
424  //**********************************************************************************************
425 
426  //**Compilation flags***************************************************************************
428  static constexpr bool simdEnabled =
429  ( MT::simdEnabled && IsNumeric_v<ET> &&
430  ( HasSIMDDiv_v<ET,ST> || HasSIMDDiv_v<UnderlyingElement_t<ET>,ST> ) );
431 
433  static constexpr bool smpAssignable = MT::smpAssignable;
434  //**********************************************************************************************
435 
436  //**SIMD properties*****************************************************************************
438  static constexpr size_t SIMDSIZE = SIMDTrait<ElementType>::size;
439  //**********************************************************************************************
440 
441  //**Constructor*********************************************************************************
447  explicit inline DMatScalarDivExpr( const MT& matrix, ST scalar ) noexcept
448  : matrix_( matrix ) // Left-hand side dense matrix of the division expression
449  , scalar_( scalar ) // Right-hand side scalar of the division expression
450  {}
451  //**********************************************************************************************
452 
453  //**Access operator*****************************************************************************
460  inline ReturnType operator()( size_t i, size_t j ) const {
461  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
462  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
463  return matrix_(i,j) / scalar_;
464  }
465  //**********************************************************************************************
466 
467  //**At function*********************************************************************************
475  inline ReturnType at( size_t i, size_t j ) const {
476  if( i >= matrix_.rows() ) {
477  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
478  }
479  if( j >= matrix_.columns() ) {
480  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
481  }
482  return (*this)(i,j);
483  }
484  //**********************************************************************************************
485 
486  //**Load function*******************************************************************************
493  BLAZE_ALWAYS_INLINE auto load( size_t i, size_t j ) const noexcept {
494  BLAZE_INTERNAL_ASSERT( i < matrix_.rows() , "Invalid row access index" );
495  BLAZE_INTERNAL_ASSERT( j < matrix_.columns(), "Invalid column access index" );
496  BLAZE_INTERNAL_ASSERT( !SO || ( i % SIMDSIZE == 0UL ), "Invalid row access index" );
497  BLAZE_INTERNAL_ASSERT( SO || ( j % SIMDSIZE == 0UL ), "Invalid column access index" );
498  return matrix_.load(i,j) / set( scalar_ );
499  }
500  //**********************************************************************************************
501 
502  //**Begin function******************************************************************************
508  inline ConstIterator begin( size_t i ) const {
509  return ConstIterator( matrix_.begin(i), scalar_ );
510  }
511  //**********************************************************************************************
512 
513  //**End function********************************************************************************
519  inline ConstIterator end( size_t i ) const {
520  return ConstIterator( matrix_.end(i), scalar_ );
521  }
522  //**********************************************************************************************
523 
524  //**Rows function*******************************************************************************
529  inline size_t rows() const noexcept {
530  return matrix_.rows();
531  }
532  //**********************************************************************************************
533 
534  //**Columns function****************************************************************************
539  inline size_t columns() const noexcept {
540  return matrix_.columns();
541  }
542  //**********************************************************************************************
543 
544  //**Left operand access*************************************************************************
549  inline LeftOperand leftOperand() const noexcept {
550  return matrix_;
551  }
552  //**********************************************************************************************
553 
554  //**Right operand access************************************************************************
559  inline RightOperand rightOperand() const noexcept {
560  return scalar_;
561  }
562  //**********************************************************************************************
563 
564  //**********************************************************************************************
570  template< typename T >
571  inline bool canAlias( const T* alias ) const noexcept {
572  return IsExpression_v<MT> && matrix_.canAlias( alias );
573  }
574  //**********************************************************************************************
575 
576  //**********************************************************************************************
582  template< typename T >
583  inline bool isAliased( const T* alias ) const noexcept {
584  return matrix_.isAliased( alias );
585  }
586  //**********************************************************************************************
587 
588  //**********************************************************************************************
593  inline bool isAligned() const noexcept {
594  return matrix_.isAligned();
595  }
596  //**********************************************************************************************
597 
598  //**********************************************************************************************
603  inline bool canSMPAssign() const noexcept {
604  return matrix_.canSMPAssign() ||
605  ( rows() * columns() >= SMP_DMATSCALARMULT_THRESHOLD );
606  }
607  //**********************************************************************************************
608 
609  private:
610  //**Member variables****************************************************************************
613  //**********************************************************************************************
614 
615  //**Assignment to dense matrices****************************************************************
629  template< typename MT2 // Type of the target dense matrix
630  , bool SO2 > // Storage order of the target dense matrix
631  friend inline auto assign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
633  {
635 
636  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
637  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
638 
639  assign( ~lhs, rhs.matrix_ );
640  assign( ~lhs, (~lhs) / rhs.scalar_ );
641  }
643  //**********************************************************************************************
644 
645  //**Assignment to sparse matrices***************************************************************
659  template< typename MT2 // Type of the target sparse matrix
660  , bool SO2 > // Storage order of the target sparse matrix
661  friend inline auto assign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
663  {
665 
666  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
667  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
668 
669  assign( ~lhs, rhs.matrix_ );
670  (~lhs) /= rhs.scalar_;
671  }
673  //**********************************************************************************************
674 
675  //**Addition assignment to dense matrices*******************************************************
689  template< typename MT2 // Type of the target dense matrix
690  , bool SO2 > // Storage order of the target dense matrix
691  friend inline auto addAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
692  -> EnableIf_t< UseAssign_v<MT2> >
693  {
695 
699 
700  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
701  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
702 
703  const ResultType tmp( serial( rhs ) );
704  addAssign( ~lhs, tmp );
705  }
707  //**********************************************************************************************
708 
709  //**Addition assignment to sparse matrices******************************************************
710  // No special implementation for the addition assignment to sparse matrices.
711  //**********************************************************************************************
712 
713  //**Subtraction assignment to dense matrices****************************************************
727  template< typename MT2 // Type of the target dense matrix
728  , bool SO2 > // Storage order of the target dense matrix
729  friend inline auto subAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
730  -> EnableIf_t< UseAssign_v<MT2> >
731  {
733 
737 
738  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
739  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
740 
741  const ResultType tmp( serial( rhs ) );
742  subAssign( ~lhs, tmp );
743  }
745  //**********************************************************************************************
746 
747  //**Subtraction assignment to sparse matrices***************************************************
748  // No special implementation for the subtraction assignment to sparse matrices.
749  //**********************************************************************************************
750 
751  //**Schur product assignment to dense matrices**************************************************
765  template< typename MT2 // Type of the target dense matrix
766  , bool SO2 > // Storage order of the target dense matrix
767  friend inline auto schurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
768  -> EnableIf_t< UseAssign_v<MT2> >
769  {
771 
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  const ResultType tmp( serial( rhs ) );
780  schurAssign( ~lhs, tmp );
781  }
783  //**********************************************************************************************
784 
785  //**Schur product assignment to sparse matrices*************************************************
786  // No special implementation for the Schur product assignment to sparse matrices.
787  //**********************************************************************************************
788 
789  //**Multiplication assignment to dense matrices*************************************************
790  // No special implementation for the multiplication assignment to dense matrices.
791  //**********************************************************************************************
792 
793  //**Multiplication assignment to sparse matrices************************************************
794  // No special implementation for the multiplication assignment to sparse matrices.
795  //**********************************************************************************************
796 
797  //**SMP assignment to dense matrices************************************************************
811  template< typename MT2 // Type of the target dense matrix
812  , bool SO2 > // Storage order of the target dense matrix
813  friend inline auto smpAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
814  -> EnableIf_t< UseSMPAssign_v<MT2> >
815  {
817 
818  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
819  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
820 
821  smpAssign( ~lhs, rhs.matrix_ );
822  smpAssign( ~lhs, (~lhs) / rhs.scalar_ );
823  }
825  //**********************************************************************************************
826 
827  //**SMP assignment to sparse matrices***********************************************************
841  template< typename MT2 // Type of the target sparse matrix
842  , bool SO2 > // Storage order of the target sparse matrix
843  friend inline auto smpAssign( SparseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
844  -> EnableIf_t< UseSMPAssign_v<MT2> >
845  {
847 
848  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
849  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
850 
851  smpAssign( ~lhs, rhs.matrix_ );
852  (~lhs) /= rhs.scalar_;
853  }
855  //**********************************************************************************************
856 
857  //**SMP addition assignment to dense matrices***************************************************
871  template< typename MT2 // Type of the target dense matrix
872  , bool SO2 > // Storage order of the target dense matrix
873  friend inline auto smpAddAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
874  -> EnableIf_t< UseSMPAssign_v<MT2> >
875  {
877 
881 
882  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
883  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
884 
885  const ResultType tmp( rhs );
886  smpAddAssign( ~lhs, tmp );
887  }
889  //**********************************************************************************************
890 
891  //**SMP addition assignment to sparse matrices**************************************************
892  // No special implementation for the SMP addition assignment to sparse matrices.
893  //**********************************************************************************************
894 
895  //**SMP subtraction assignment to dense matrices************************************************
909  template< typename MT2 // Type of the target dense matrix
910  , bool SO2 > // Storage order of the target dense matrix
911  friend inline auto smpSubAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
912  -> EnableIf_t< UseSMPAssign_v<MT2> >
913  {
915 
919 
920  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
921  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
922 
923  const ResultType tmp( rhs );
924  smpSubAssign( ~lhs, tmp );
925  }
927  //**********************************************************************************************
928 
929  //**SMP subtraction assignment to sparse matrices***********************************************
930  // No special implementation for the SMP subtraction assignment to sparse matrices.
931  //**********************************************************************************************
932 
933  //**SMP Schur product assignment to dense matrices**********************************************
947  template< typename MT2 // Type of the target dense matrix
948  , bool SO2 > // Storage order of the target dense matrix
949  friend inline auto smpSchurAssign( DenseMatrix<MT2,SO2>& lhs, const DMatScalarDivExpr& rhs )
950  -> EnableIf_t< UseSMPAssign_v<MT2> >
951  {
953 
957 
958  BLAZE_INTERNAL_ASSERT( (~lhs).rows() == rhs.rows() , "Invalid number of rows" );
959  BLAZE_INTERNAL_ASSERT( (~lhs).columns() == rhs.columns(), "Invalid number of columns" );
960 
961  const ResultType tmp( rhs );
962  smpSchurAssign( ~lhs, tmp );
963  }
965  //**********************************************************************************************
966 
967  //**SMP Schur product assignment to sparse matrices*********************************************
968  // No special implementation for the SMP Schur product assignment to sparse matrices.
969  //**********************************************************************************************
970 
971  //**SMP multiplication assignment to dense matrices*********************************************
972  // No special implementation for the SMP multiplication assignment to dense matrices.
973  //**********************************************************************************************
974 
975  //**SMP multiplication assignment to sparse matrices********************************************
976  // No special implementation for the SMP multiplication assignment to sparse matrices.
977  //**********************************************************************************************
978 
979  //**Compile time checks*************************************************************************
988  //**********************************************************************************************
989 };
990 //*************************************************************************************************
991 
992 
993 
994 
995 //=================================================================================================
996 //
997 // GLOBAL BINARY ARITHMETIC OPERATORS
998 //
999 //=================================================================================================
1000 
1001 //*************************************************************************************************
1006 template< typename MT // Type of the left-hand side dense matrix
1007  , typename ST // Type of the right-hand side scalar
1008  , bool SO > // Storage order
1009 struct DMatScalarDivExprHelper
1010 {
1011  private:
1012  //**********************************************************************************************
1013  using ScalarType = If_t< IsFloatingPoint_v< UnderlyingBuiltin_t<MT> > ||
1014  IsFloatingPoint_v< UnderlyingBuiltin_t<ST> >
1015  , If_t< IsComplex_v< UnderlyingNumeric_t<MT> > && IsBuiltin_v<ST>
1016  , DivTrait_t< UnderlyingBuiltin_t<MT>, ST >
1017  , DivTrait_t< UnderlyingNumeric_t<MT>, ST > >
1018  , ST >;
1019  //**********************************************************************************************
1020 
1021  public:
1022  //**********************************************************************************************
1023  using Type = If_t< IsInvertible_v<ScalarType>
1024  , DMatScalarMultExpr<MT,ScalarType,SO>
1025  , DMatScalarDivExpr<MT,ScalarType,SO> >;
1026  //**********************************************************************************************
1027 };
1029 //*************************************************************************************************
1030 
1031 
1032 //*************************************************************************************************
1054 template< typename MT // Type of the left-hand side dense matrix
1055  , bool SO // Storage order of the left-hand side dense matrix
1056  , typename ST // Type of the right-hand side scalar
1057  , EnableIf_t< IsNumeric_v<ST> >* = nullptr >
1058 inline decltype(auto) operator/( const DenseMatrix<MT,SO>& mat, ST scalar )
1059 {
1061 
1062  BLAZE_USER_ASSERT( scalar != ST(0), "Division by zero detected" );
1063 
1064  using ReturnType = typename DMatScalarDivExprHelper<MT,ST,SO>::Type;
1065  using ScalarType = RightOperand_t<ReturnType>;
1066 
1067  if( IsMultExpr_v<ReturnType> ) {
1068  return ReturnType( ~mat, ScalarType(1)/ScalarType(scalar) );
1069  }
1070  else {
1071  return ReturnType( ~mat, scalar );
1072  }
1073 }
1074 //*************************************************************************************************
1075 
1076 
1077 
1078 
1079 //=================================================================================================
1080 //
1081 // GLOBAL RESTRUCTURING BINARY ARITHMETIC OPERATORS
1082 //
1083 //=================================================================================================
1084 
1085 //*************************************************************************************************
1098 template< typename MT // Type of the dense matrix of the left-hand side expression
1099  , typename ST1 // Type of the scalar of the left-hand side expression
1100  , bool SO // Storage order of the dense matrix
1101  , typename ST2 // Type of the right-hand side scalar
1102  , EnableIf_t< IsNumeric_v<ST2> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* = nullptr >
1103 inline decltype(auto) operator*( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1104 {
1106 
1107  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1108 }
1110 //*************************************************************************************************
1111 
1112 
1113 //*************************************************************************************************
1126 template< typename ST1 // Type of the left-hand side scalar
1127  , typename MT // Type of the dense matrix of the right-hand side expression
1128  , typename ST2 // Type of the scalar of the right-hand side expression
1129  , bool SO // Storage order of the dense matrix
1130  , EnableIf_t< IsNumeric_v<ST1> && ( IsInvertible_v<ST1> || IsInvertible_v<ST2> ) >* = nullptr >
1131 inline decltype(auto) operator*( ST1 scalar, const DMatScalarDivExpr<MT,ST2,SO>& mat )
1132 {
1134 
1135  return mat.leftOperand() * ( scalar / mat.rightOperand() );
1136 }
1138 //*************************************************************************************************
1139 
1140 
1141 //*************************************************************************************************
1154 template< typename MT // Type of the dense matrix of the left-hand side expression
1155  , typename ST1 // Type of the scalar of the left-hand side expression
1156  , bool SO // Storage order of the dense matrix
1157  , typename ST2 // Type of the right-hand side scalar
1158  , EnableIf_t< IsNumeric_v<ST2> >* = nullptr >
1159 inline decltype(auto) operator/( const DMatScalarDivExpr<MT,ST1,SO>& mat, ST2 scalar )
1160 {
1162 
1163  BLAZE_USER_ASSERT( scalar != ST2(0), "Division by zero detected" );
1164 
1165  using MultType = MultTrait_t<ST1,ST2>;
1166  using ReturnType = typename DMatScalarDivExprHelper<MT,MultType,SO>::Type;
1167  using ScalarType = RightOperand_t<ReturnType>;
1168 
1169  if( IsMultExpr_v<ReturnType> ) {
1170  return ReturnType( mat.leftOperand(), ScalarType(1)/( mat.rightOperand() * scalar ) );
1171  }
1172  else {
1173  return ReturnType( mat.leftOperand(), mat.rightOperand() * scalar );
1174  }
1175 }
1177 //*************************************************************************************************
1178 
1179 
1180 
1181 
1182 //=================================================================================================
1183 //
1184 // ISALIGNED SPECIALIZATIONS
1185 //
1186 //=================================================================================================
1187 
1188 //*************************************************************************************************
1190 template< typename MT, typename ST, bool SO >
1191 struct IsAligned< DMatScalarDivExpr<MT,ST,SO> >
1192  : public IsAligned<MT>
1193 {};
1195 //*************************************************************************************************
1196 
1197 
1198 
1199 
1200 //=================================================================================================
1201 //
1202 // ISPADDED SPECIALIZATIONS
1203 //
1204 //=================================================================================================
1205 
1206 //*************************************************************************************************
1208 template< typename MT, typename ST, bool SO >
1209 struct IsPadded< DMatScalarDivExpr<MT,ST,SO> >
1210  : public IsPadded<MT>
1211 {};
1213 //*************************************************************************************************
1214 
1215 } // namespace blaze
1216 
1217 #endif
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: DMatScalarDivExpr.h:194
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:571
Pointer difference type of the Blaze library.
OppositeType_t< ResultType > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DMatScalarDivExpr.h:166
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:333
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DMatScalarDivExpr.h:539
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
LeftOperand leftOperand() const noexcept
Returns the left-hand side dense matrix operand.
Definition: DMatScalarDivExpr.h:549
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:344
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DMatScalarDivExpr.h:529
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DMatScalarDivExpr.h:237
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
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DMatScalarDivExpr.h:377
Base class for all matrix/scalar division expression templates.The MatScalarDivExpr class serves as a...
Definition: MatScalarDivExpr.h:66
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:508
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition: DMatScalarDivExpr.h:269
#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:127
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition: DMatScalarDivExpr.h:603
ElementType ValueType
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:191
Iterator over the elements of the dense matrix.
Definition: DMatScalarDivExpr.h:186
Expression object for divisions of a dense matrix by a scalar.The DMatScalarDivExpr class represents ...
Definition: DMatScalarDivExpr.h:105
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition: DMatScalarDivExpr.h:259
Header file for the Computation base class.
CompositeType_t< MT > CT
Composite type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:114
Header file for the UnderlyingElement type trait.
auto load() const noexcept
Access to the SIMD elements of the matrix.
Definition: DMatScalarDivExpr.h:300
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:559
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
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:593
ElementType * PointerType
Pointer return type.
Definition: DMatScalarDivExpr.h:192
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:165
If_t< useAssign, const ResultType, const DMatScalarDivExpr & > CompositeType
Data type for composite expression templates.
Definition: DMatScalarDivExpr.h:174
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:168
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DMatScalarDivExpr.h:225
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:366
#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:200
Header file for the DenseMatrix base class.
ElementType_t< MT > ET
Element type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:113
DMatScalarDivExpr(const MT &matrix, ST scalar) noexcept
Constructor for the DMatScalarDivExpr class.
Definition: DMatScalarDivExpr.h:447
Header file for all SIMD functionality.
ElementType & ReferenceType
Reference return type.
Definition: DMatScalarDivExpr.h:193
ST RightOperand
Composite type of the right-hand side scalar value.
Definition: DMatScalarDivExpr.h:180
#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:433
Header file for the IsAligned type trait.
IteratorType iterator_
Iterator to the current element.
Definition: DMatScalarDivExpr.h:420
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DMatScalarDivExpr.h:438
ReturnType_t< MT > RN
Return type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:112
const If_t< returnExpr, ExprReturnType, ElementType > ReturnType
Return type for expression template evaluations.
Definition: DMatScalarDivExpr.h:171
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: DMatScalarDivExpr.h:190
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:493
RightOperand scalar_
Scalar of the multiplication expression.
Definition: DMatScalarDivExpr.h:421
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatScalarDivExpr.h:428
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsPadded type trait.
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:460
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:519
LeftOperand matrix_
Left-hand side dense matrix of the division expression.
Definition: DMatScalarDivExpr.h:611
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition: DMatScalarDivExpr.h:248
RightOperand scalar_
Right-hand side scalar of the division expression.
Definition: DMatScalarDivExpr.h:612
ConstIterator(IteratorType iterator, RightOperand scalar)
Constructor for the ConstIterator class.
Definition: DMatScalarDivExpr.h:213
static constexpr bool returnExpr
Compilation switch for the selection of the subscript operator return type.
Definition: DMatScalarDivExpr.h:124
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:413
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
Header file for all forward declarations for expression class templates.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
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:167
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:311
IteratorCategory iterator_category
The iterator category.
Definition: DMatScalarDivExpr.h:197
ValueType value_type
Type of the underlying elements.
Definition: DMatScalarDivExpr.h:198
Header file for the IsInvertible type trait.
PointerType pointer
Pointer return type.
Definition: DMatScalarDivExpr.h:199
#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:111
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
Macro for CUDA compatibility.
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:389
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:401
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition: DMatScalarDivExpr.h:280
ConstIterator_t< MT > IteratorType
ConstIterator type of the dense matrix expression.
Definition: DMatScalarDivExpr.h:204
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:138
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition: HostDevice.h:94
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:177
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition: DMatScalarDivExpr.h:475
ReturnType operator *() const
Direct access to the element at the current iterator position.
Definition: DMatScalarDivExpr.h:290
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:355
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,...
Definition: Assert.h:101
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: DMatScalarDivExpr.h:322
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:583