Blaze  3.6
SMatVarExpr.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_EXPRESSIONS_SMATVAREXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_SMATVAREXPR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <blaze/math/Aliases.h>
47 #include <blaze/math/Exception.h>
56 #include <blaze/math/shims/Pow2.h>
63 #include <blaze/math/views/Check.h>
64 #include <blaze/util/Assert.h>
65 #include <blaze/util/EnableIf.h>
68 #include <blaze/util/MaybeUnused.h>
69 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/Types.h>
72 
73 
74 namespace blaze {
75 
76 //=================================================================================================
77 //
78 // CLASS DEFINITION
79 //
80 //=================================================================================================
81 
82 //*************************************************************************************************
89 template< typename MT // Type of the sparse matrix
90  , size_t RF > // Reduction flag
92 {};
93 //*************************************************************************************************
94 
95 
96 
97 
98 //=================================================================================================
99 //
100 // CLASS TEMPLATE SPECIALIZATION FOR THE COLUMN-WISE VARIANCE FUNCTION ON ROW-MAJOR MATRICES
101 //
102 //=================================================================================================
103 
104 //*************************************************************************************************
111 template< typename MT > // Type of the sparse matrix
113  : public MatReduceExpr< DenseVector< SMatVarExpr<MT,columnwise>, true >, columnwise >
114  , private Computation
115 {
116  private:
117  //**Type definitions****************************************************************************
121  //**********************************************************************************************
122 
123  public:
124  //**Type definitions****************************************************************************
130  using ReturnType = const ElementType;
131  using CompositeType = const ResultType;
132 
134  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
135  //**********************************************************************************************
136 
137  //**Compilation flags***************************************************************************
139  static constexpr bool simdEnabled = false;
140 
142  static constexpr bool smpAssignable = false;
143  //**********************************************************************************************
144 
145  //**Constructor*********************************************************************************
150  explicit inline SMatVarExpr( const MT& sm ) noexcept
151  : sm_( sm ) // Sparse matrix of the variance expression
152  {}
153  //**********************************************************************************************
154 
155  //**Subscript operator**************************************************************************
161  inline ReturnType operator[]( size_t index ) const {
162  BLAZE_INTERNAL_ASSERT( index < sm_.columns(), "Invalid vector access index" );
163  return var( column( sm_, index, unchecked ) );
164  }
165  //**********************************************************************************************
166 
167  //**At function*********************************************************************************
174  inline ReturnType at( size_t index ) const {
175  if( index >= sm_.columns() ) {
176  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
177  }
178  return (*this)[index];
179  }
180  //**********************************************************************************************
181 
182  //**Size function*******************************************************************************
187  inline size_t size() const noexcept {
188  return sm_.columns();
189  }
190  //**********************************************************************************************
191 
192  //**Operand access******************************************************************************
197  inline Operand operand() const noexcept {
198  return sm_;
199  }
200  //**********************************************************************************************
201 
202  //**********************************************************************************************
208  template< typename T >
209  inline bool canAlias( const T* alias ) const noexcept {
210  return ( sm_.isAliased( alias ) );
211  }
212  //**********************************************************************************************
213 
214  //**********************************************************************************************
220  template< typename T >
221  inline bool isAliased( const T* alias ) const noexcept {
222  return ( sm_.isAliased( alias ) );
223  }
224  //**********************************************************************************************
225 
226  //**********************************************************************************************
231  inline bool isAligned() const noexcept {
232  return false;
233  }
234  //**********************************************************************************************
235 
236  private:
237  //**Member variables****************************************************************************
239  //**********************************************************************************************
240 
241  //**Assignment to dense vectors*****************************************************************
253  template< typename VT1 > // Type of the target dense vector
254  friend inline void assign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
255  {
257 
261 
262  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
263 
264  const OT tmp( serial( rhs.sm_ ) );
265  assign( ~lhs, var<columnwise>( tmp ) );
266  }
268  //**********************************************************************************************
269 
270  //**Assignment to sparse vectors****************************************************************
283  template< typename VT1 > // Type of the target dense vector
284  friend inline void assign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
285  {
287 
291 
292  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
293 
294  const ResultType tmp( serial( rhs ) );
295  assign( ~lhs, tmp );
296  }
298  //**********************************************************************************************
299 
300  //**Addition assignment to dense vectors********************************************************
313  template< typename VT1 > // Type of the target dense vector
314  friend inline void addAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
315  {
317 
321 
322  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
323 
324  const OT tmp( serial( rhs.sm_ ) );
325  addAssign( ~lhs, var<columnwise>( tmp ) );
326  }
328  //**********************************************************************************************
329 
330  //**Addition assignment to sparse vectors*******************************************************
343  template< typename VT1 > // Type of the target dense vector
344  friend inline void addAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
345  {
347 
351 
352  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
353 
354  const ResultType tmp( serial( rhs ) );
355  addAssign( ~lhs, tmp );
356  }
358  //**********************************************************************************************
359 
360  //**Subtraction assignment to dense vectors*****************************************************
373  template< typename VT1 > // Type of the target dense vector
374  friend inline void subAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
375  {
377 
381 
382  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
383 
384  const OT tmp( serial( rhs.sm_ ) );
385  subAssign( ~lhs, var<columnwise>( tmp ) );
386  }
388  //**********************************************************************************************
389 
390  //**Subtraction assignment to sparse vectors****************************************************
403  template< typename VT1 > // Type of the target dense vector
404  friend inline void subAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
405  {
407 
411 
412  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
413 
414  const ResultType tmp( serial( rhs ) );
415  subAssign( ~lhs, tmp );
416  }
418  //**********************************************************************************************
419 
420  //**Multiplication assignment to dense vectors**************************************************
433  template< typename VT1 > // Type of the target dense vector
434  friend inline void multAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
435  {
437 
441 
442  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
443 
444  const OT tmp( serial( rhs.sm_ ) );
445  multAssign( ~lhs, var<columnwise>( tmp ) );
446  }
448  //**********************************************************************************************
449 
450  //**Multiplication assignment to sparse vectors*************************************************
463  template< typename VT1 > // Type of the target dense vector
464  friend inline void multAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
465  {
467 
471 
472  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
473 
474  const ResultType tmp( serial( rhs ) );
475  multAssign( ~lhs, tmp );
476  }
478  //**********************************************************************************************
479 
480  //**Division assignment to dense vectors********************************************************
493  template< typename VT1 > // Type of the target dense vector
494  friend inline void divAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
495  {
497 
501 
502  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
503 
504  const OT tmp( serial( rhs.sm_ ) );
505  divAssign( ~lhs, var<columnwise>( tmp ) );
506  }
508  //**********************************************************************************************
509 
510  //**Division assignment to sparse vectors*******************************************************
523  template< typename VT1 > // Type of the target dense vector
524  friend inline void divAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
525  {
527 
531 
532  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
533 
534  const ResultType tmp( serial( rhs ) );
535  divAssign( ~lhs, tmp );
536  }
538  //**********************************************************************************************
539 
540  //**Compile time checks*************************************************************************
545  //**********************************************************************************************
546 };
547 //*************************************************************************************************
548 
549 
550 
551 
552 //=================================================================================================
553 //
554 // CLASS TEMPLATE SPECIALIZATION FOR THE ROW-WISE VARIANCE FUNCTION ON ROW-MAJOR MATRICES
555 //
556 //=================================================================================================
557 
558 //*************************************************************************************************
565 template< typename MT > // Type of the sparse matrix
567  : public MatReduceExpr< DenseVector< SMatVarExpr<MT,rowwise>, false >, rowwise >
568  , private Computation
569 {
570  private:
571  //**Type definitions****************************************************************************
573  //**********************************************************************************************
574 
575  //**Serial evaluation strategy******************************************************************
577 
583  static constexpr bool useAssign = RequiresEvaluation_v<MT>;
584 
586  template< typename VT >
588  static constexpr bool UseAssign_v = useAssign;
590  //**********************************************************************************************
591 
592  public:
593  //**Type definitions****************************************************************************
599  using ReturnType = const ElementType;
600 
603 
605  using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
606  //**********************************************************************************************
607 
608  //**ConstIterator class definition**************************************************************
611  class ConstIterator
612  {
613  public:
614  //**Type definitions*************************************************************************
615  using IteratorCategory = std::random_access_iterator_tag;
620 
621  // STL iterator requirements
627  //*******************************************************************************************
628 
629  //**Constructor******************************************************************************
635  explicit inline ConstIterator( Operand sm, size_t index )
636  : sm_ ( sm ) // Sparse matrix of the variance expression
637  , index_( index ) // Index to the current matrix row
638  {}
639  //*******************************************************************************************
640 
641  //**Addition assignment operator*************************************************************
647  inline ConstIterator& operator+=( size_t inc ) {
648  index_ += inc;
649  return *this;
650  }
651  //*******************************************************************************************
652 
653  //**Subtraction assignment operator**********************************************************
659  inline ConstIterator& operator-=( size_t dec ) {
660  index_ -= dec;
661  return *this;
662  }
663  //*******************************************************************************************
664 
665  //**Prefix increment operator****************************************************************
670  inline ConstIterator& operator++() {
671  ++index_;
672  return *this;
673  }
674  //*******************************************************************************************
675 
676  //**Postfix increment operator***************************************************************
681  inline const ConstIterator operator++( int ) {
682  return ConstIterator( index_++ );
683  }
684  //*******************************************************************************************
685 
686  //**Prefix decrement operator****************************************************************
691  inline ConstIterator& operator--() {
692  --index_;
693  return *this;
694  }
695  //*******************************************************************************************
696 
697  //**Postfix decrement operator***************************************************************
702  inline const ConstIterator operator--( int ) {
703  return ConstIterator( index_-- );
704  }
705  //*******************************************************************************************
706 
707  //**Element access operator******************************************************************
712  inline ReturnType operator*() const {
713  return var( row( sm_, index_, unchecked ) );
714  }
715  //*******************************************************************************************
716 
717  //**Equality operator************************************************************************
723  inline bool operator==( const ConstIterator& rhs ) const {
724  return index_ == rhs.index_;
725  }
726  //*******************************************************************************************
727 
728  //**Inequality operator**********************************************************************
734  inline bool operator!=( const ConstIterator& rhs ) const {
735  return index_ != rhs.index_;
736  }
737  //*******************************************************************************************
738 
739  //**Less-than operator***********************************************************************
745  inline bool operator<( const ConstIterator& rhs ) const {
746  return index_ < rhs.index_;
747  }
748  //*******************************************************************************************
749 
750  //**Greater-than operator********************************************************************
756  inline bool operator>( const ConstIterator& rhs ) const {
757  return index_ > rhs.index_;
758  }
759  //*******************************************************************************************
760 
761  //**Less-or-equal-than operator**************************************************************
767  inline bool operator<=( const ConstIterator& rhs ) const {
768  return index_ <= rhs.index_;
769  }
770  //*******************************************************************************************
771 
772  //**Greater-or-equal-than operator***********************************************************
778  inline bool operator>=( const ConstIterator& rhs ) const {
779  return index_ >= rhs.index_;
780  }
781  //*******************************************************************************************
782 
783  //**Subtraction operator*********************************************************************
789  inline DifferenceType operator-( const ConstIterator& rhs ) const {
790  return index_ - rhs.index_;
791  }
792  //*******************************************************************************************
793 
794  //**Addition operator************************************************************************
801  friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
802  return ConstIterator( it.index_ + inc );
803  }
804  //*******************************************************************************************
805 
806  //**Addition operator************************************************************************
813  friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
814  return ConstIterator( it.index_ + inc );
815  }
816  //*******************************************************************************************
817 
818  //**Subtraction operator*********************************************************************
825  friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
826  return ConstIterator( it.index_ - dec );
827  }
828  //*******************************************************************************************
829 
830  private:
831  //**Member variables*************************************************************************
833  size_t index_;
834  //*******************************************************************************************
835  };
836  //**********************************************************************************************
837 
838  //**Compilation flags***************************************************************************
840  static constexpr bool simdEnabled = false;
841 
843  static constexpr bool smpAssignable = false;
844  //**********************************************************************************************
845 
846  //**Constructor*********************************************************************************
851  explicit inline SMatVarExpr( const MT& sm ) noexcept
852  : sm_( sm ) // Sparse matrix of the variance expression
853  {}
854  //**********************************************************************************************
855 
856  //**Subscript operator**************************************************************************
862  inline ReturnType operator[]( size_t index ) const {
863  BLAZE_INTERNAL_ASSERT( index < sm_.rows(), "Invalid vector access index" );
864  return var( row( sm_, index, unchecked ) );
865  }
866  //**********************************************************************************************
867 
868  //**At function*********************************************************************************
875  inline ReturnType at( size_t index ) const {
876  if( index >= sm_.rows() ) {
877  BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
878  }
879  return (*this)[index];
880  }
881  //**********************************************************************************************
882 
883  //**Begin function******************************************************************************
888  inline ConstIterator begin() const {
889  return ConstIterator( sm_, 0UL );
890  }
891  //**********************************************************************************************
892 
893  //**End function********************************************************************************
898  inline ConstIterator end() const {
899  return ConstIterator( sm_, size() );
900  }
901  //**********************************************************************************************
902 
903  //**Size function*******************************************************************************
908  inline size_t size() const noexcept {
909  return sm_.rows();
910  }
911  //**********************************************************************************************
912 
913  //**Operand access******************************************************************************
918  inline Operand operand() const noexcept {
919  return sm_;
920  }
921  //**********************************************************************************************
922 
923  //**********************************************************************************************
929  template< typename T >
930  inline bool canAlias( const T* alias ) const noexcept {
931  return ( sm_.isAliased( alias ) );
932  }
933  //**********************************************************************************************
934 
935  //**********************************************************************************************
941  template< typename T >
942  inline bool isAliased( const T* alias ) const noexcept {
943  return ( sm_.isAliased( alias ) );
944  }
945  //**********************************************************************************************
946 
947  //**********************************************************************************************
952  inline bool isAligned() const noexcept {
953  return false;
954  }
955  //**********************************************************************************************
956 
957  private:
958  //**Member variables****************************************************************************
960  //**********************************************************************************************
961 
962  //**Assignment to vectors***********************************************************************
976  template< typename VT1 > // Type of the target vector
977  friend inline auto assign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
979  {
981 
982  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
983 
984  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
985  assign( ~lhs, var<rowwise>( tmp ) );
986  }
988  //**********************************************************************************************
989 
990  //**Addition assignment to vectors**************************************************************
1004  template< typename VT1 > // Type of the target vector
1005  friend inline auto addAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1007  {
1009 
1010  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1011 
1012  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1013  addAssign( ~lhs, var<rowwise>( tmp ) );
1014  }
1016  //**********************************************************************************************
1017 
1018  //**Subtraction assignment to vectors***********************************************************
1033  template< typename VT1 > // Type of the target vector
1034  friend inline auto subAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1035  -> EnableIf_t< UseAssign_v<VT1> >
1036  {
1038 
1039  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1040 
1041  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1042  subAssign( ~lhs, var<rowwise>( tmp ) );
1043  }
1045  //**********************************************************************************************
1046 
1047  //**Multiplication assignment to vectors********************************************************
1062  template< typename VT1 > // Type of the target vector
1063  friend inline auto multAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1064  -> EnableIf_t< UseAssign_v<VT1> >
1065  {
1067 
1068  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1069 
1070  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1071  multAssign( ~lhs, var<rowwise>( tmp ) );
1072  }
1074  //**********************************************************************************************
1075 
1076  //**Division assignment to vectors**************************************************************
1090  template< typename VT1 > // Type of the target vector
1091  friend inline auto divAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1092  -> EnableIf_t< UseAssign_v<VT1> >
1093  {
1095 
1096  BLAZE_INTERNAL_ASSERT( (~lhs).size() == rhs.size(), "Invalid vector sizes" );
1097 
1098  const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1099  divAssign( ~lhs, var<rowwise>( tmp ) );
1100  }
1102  //**********************************************************************************************
1103 
1104  //**Compile time checks*************************************************************************
1109  //**********************************************************************************************
1110 };
1111 //*************************************************************************************************
1112 
1113 
1114 
1115 
1116 //=================================================================================================
1117 //
1118 // GLOBAL FUNCTIONS
1119 //
1120 //=================================================================================================
1121 
1122 //*************************************************************************************************
1130 template< typename MT // Type of the sparse matrix
1131  , bool SO > // Storage order
1132 inline decltype(auto) var_backend( const SparseMatrix<MT,SO>& sm, FalseType )
1133 {
1134  using BT = UnderlyingBuiltin_t<MT>;
1135 
1136  const size_t n ( size( ~sm ) );
1137  const size_t nz( nonZeros( ~sm ) );
1138 
1139  BLAZE_INTERNAL_ASSERT( n > 1UL, "Invalid matrix size detected" );
1140  BLAZE_INTERNAL_ASSERT( n >= nz, "Invalid number of non-zero elements detected" );
1141 
1142  const auto meanValue( mean( ~sm ) );
1143  auto variance( ( n - nz ) * pow2( meanValue ) );
1144 
1145  const size_t iend( SO ? (~sm).columns() : (~sm).rows() );
1146  for( size_t i=0UL; i<iend; ++i ) {
1147  const auto end( (~sm).end(i) );
1148  for( auto element=(~sm).begin(i); element!=end; ++element ) {
1149  variance += pow2( element->value() - meanValue );
1150  }
1151  }
1152 
1153  return variance * inv( BT( n-1UL ) );
1154 }
1156 //*************************************************************************************************
1157 
1158 
1159 //*************************************************************************************************
1167 template< typename MT // Type of the sparse matrix
1168  , bool SO > // Storage order
1169 inline decltype(auto) var_backend( const SparseMatrix<MT,SO>& sm, TrueType )
1170 {
1171  MAYBE_UNUSED( sm );
1172 
1173  BLAZE_INTERNAL_ASSERT( size( ~sm ) > 1UL, "Invalid matrix size detected" );
1174 
1175  return ElementType_t<MT>();
1176 }
1178 //*************************************************************************************************
1179 
1180 
1181 //*************************************************************************************************
1205 template< typename MT // Type of the sparse matrix
1206  , bool SO > // Storage order
1207 inline decltype(auto) var( const SparseMatrix<MT,SO>& sm )
1208 {
1210 
1211  if( size( ~sm ) < 2UL ) {
1212  BLAZE_THROW_INVALID_ARGUMENT( "Invalid input matrix" );
1213  }
1214 
1215  return var_backend( ~sm, IsZero<MT>() );
1216 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1228 template< size_t RF // Reduction flag
1229  , typename MT > // Type of the sparse matrix
1230 inline const SMatVarExpr<MT,RF> var_backend( const SparseMatrix<MT,false>& sm )
1231 {
1232  using ReturnType = const SMatVarExpr<MT,RF>;
1233  return ReturnType( ~sm );
1234 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1247 template< size_t RF // Reduction flag
1248  , typename MT > // Type of the sparse matrix
1249 inline decltype(auto) var_backend( const SparseMatrix<MT,true>& sm )
1250 {
1251  return trans( var<1UL-RF>( trans( ~sm ) ) );
1252 }
1254 //*************************************************************************************************
1255 
1256 
1257 //*************************************************************************************************
1293 template< size_t RF // Reduction flag
1294  , typename MT // Type of the sparse matrix
1295  , bool SO > // Storage order
1296 inline decltype(auto) var( const SparseMatrix<MT,SO>& sm )
1297 {
1299 
1300  BLAZE_STATIC_ASSERT_MSG( RF < 2UL, "Invalid reduction flag" );
1301 
1302  return var_backend<RF>( ~sm );
1303 }
1304 //*************************************************************************************************
1305 
1306 } // namespace blaze
1307 
1308 #endif
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: IntegralConstant.h:121
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatVarExpr.h:128
Pointer difference type of the Blaze library.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for the blaze::checked and blaze::unchecked instances.
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
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatVarExpr.h:209
ConstIterator(Operand sm, size_t index)
Constructor for the ConstIterator class.
Definition: SMatVarExpr.h:635
Header file for the MatReduceExpr base class.
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.
Base class for all matrix reduction expression templates.The MatReduceExpr class serves as a tag for ...
Definition: MatReduceExpr.h:67
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatVarExpr.h:130
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
ConstIterator & operator--()
Pre-decrement operator.
Definition: SMatVarExpr.h:691
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:756
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatVarExpr.h:120
constexpr Unchecked unchecked
Global Unchecked instance.The blaze::unchecked instance is an optional token for the creation of view...
Definition: Check.h:138
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatVarExpr.h:908
Header file for the DenseVector base class.
const ConstIterator operator--(int)
Post-decrement operator.
Definition: SMatVarExpr.h:702
Header file for the MAYBE_UNUSED function template.
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatVarExpr.h:231
Header file for the invert shim.
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Header file for the Computation base class.
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: SMatVarExpr.h:801
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatVarExpr.h:221
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Constraints on the storage order of matrix types.
Header file for the RequiresEvaluation type trait.
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: SMatVarExpr.h:789
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:123
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:238
Base template for the row-/column-wise variance computations on row-major sparse matrices....
Definition: SMatVarExpr.h:91
Header file for the reduce trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatVarExpr.h:129
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: SMatVarExpr.h:647
const ConstIterator operator++(int)
Post-increment operator.
Definition: SMatVarExpr.h:681
Compile time check for zero vectors or matrices.This type trait tests whether or not the given templa...
Definition: IsZero.h:107
If_t< useAssign, const ResultType, const SMatVarExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatVarExpr.h:602
Header file for the SparseMatrix base class.
ReduceTrait_t< RT, InvAdd, rowwise > ResultType
Result type for expression template evaluations.
Definition: SMatVarExpr.h:596
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
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:832
ElementType & ReferenceType
Reference return type.
Definition: SMatVarExpr.h:618
IteratorCategory iterator_category
The iterator category.
Definition: SMatVarExpr.h:622
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:767
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatVarExpr.h:862
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: SMatVarExpr.h:888
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatVarExpr.h:161
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Compile time assertion.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: ColumnMajorMatrix.h:61
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: SMatVarExpr.h:898
decltype(auto) operator *(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9091
Header file for the UnderlyingBuiltin type trait.
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatVarExpr.h:670
ElementType * PointerType
Pointer return type.
Definition: SMatVarExpr.h:617
Expression object for the row-wise variance function on row-major sparse matrices....
Definition: SMatVarExpr.h:566
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatVarExpr.h:131
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatVarExpr.h:952
#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
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatVarExpr.h:597
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: SMatVarExpr.h:813
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:423
SMatVarExpr(const MT &sm) noexcept
Constructor for the SMatVarExpr class.
Definition: SMatVarExpr.h:851
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:76
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatVarExpr.h:134
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatVarExpr.h:605
Header file for the pow2 shim.
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: SMatVarExpr.h:615
Header file for the exception macros of the math module.
OppositeType_t< MT > OT
Opposite type of the sparse matrix expression.
Definition: SMatVarExpr.h:119
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatVarExpr.h:875
Header file for the EnableIf class template.
decltype(auto) mean(const DenseMatrix< MT, SO > &dm)
Computes the (arithmetic) mean for the given dense matrix.
Definition: DMatMeanExpr.h:134
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.The OppositeType_t alias declaration provi...
Definition: Aliases.h:270
size_t index_
Index to the current matrix row.
Definition: SMatVarExpr.h:833
constexpr size_t columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:90
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: RowMajorMatrix.h:61
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.The ReduceTrait_t alias declaration pr...
Definition: ReduceTrait.h:173
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatVarExpr.h:599
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.
Header file for the InvAdd functor.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.The CompositeType_t alias declaration pro...
Definition: Aliases.h:90
decltype(auto) var(const DenseMatrix< MT, SO > &dm)
Computes the variance for the given dense matrix.
Definition: DMatVarExpr.h:137
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatVarExpr.h:187
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
ReferenceType reference
Reference return type.
Definition: SMatVarExpr.h:625
Header file for the IsZero type trait.
decltype(auto) pow2(const Proxy< PT, RT > &proxy)
Computing the square value of the represented element.
Definition: Proxy.h:1384
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatVarExpr.h:197
#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.
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:959
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:734
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:808
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatVarExpr.h:942
#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
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:723
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatVarExpr.h:174
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatVarExpr.h:598
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type,...
Definition: DenseVector.h:61
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:745
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatVarExpr.h:572
constexpr size_t rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:70
SMatVarExpr(const MT &sm) noexcept
Constructor for the SMatVarExpr class.
Definition: SMatVarExpr.h:150
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:778
Base class for all compute expression templates.The Computation class serves as a tag for all computa...
Definition: Computation.h:66
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: SMatVarExpr.h:659
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
Expression object for the column-wise variance function on row-major sparse matrices....
Definition: SMatVarExpr.h:112
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatVarExpr.h:118
Header file for the IntegralConstant class template.
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: SMatVarExpr.h:825
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a row dense or sparse vector type (i...
Definition: RowVector.h:61
ValueType value_type
Type of the underlying elements.
Definition: SMatVarExpr.h:623
ElementType ValueType
Type of the underlying elements.
Definition: SMatVarExpr.h:616
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatVarExpr.h:930
#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
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatVarExpr.h:918
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type,...
Definition: SparseMatrix.h:61
Header file for the reduction flags.
PointerType pointer
Pointer return type.
Definition: SMatVarExpr.h:624
Header file for the IsExpression type trait class.
Header file for the function trace functionality.
ReduceTrait_t< RT, InvAdd, columnwise > ResultType
Result type for expression template evaluations.
Definition: SMatVarExpr.h:127