Blaze 3.9
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>
65#include <blaze/util/Assert.h>
66#include <blaze/util/EnableIf.h>
70#include <blaze/util/mpl/If.h>
72#include <blaze/util/Types.h>
73
74
75namespace blaze {
76
77//=================================================================================================
78//
79// CLASS DEFINITION
80//
81//=================================================================================================
82
83//*************************************************************************************************
90template< typename MT // Type of the sparse matrix
91 , ReductionFlag RF > // Reduction flag
93{};
94//*************************************************************************************************
95
96
97
98
99//=================================================================================================
100//
101// CLASS TEMPLATE SPECIALIZATION FOR THE COLUMN-WISE VARIANCE FUNCTION ON ROW-MAJOR MATRICES
102//
103//=================================================================================================
104
105//*************************************************************************************************
112template< typename MT > // Type of the sparse matrix
114 : public MatReduceExpr< DenseVector< SMatVarExpr<MT,columnwise>, true >, columnwise >
115 , private Computation
116{
117 private:
118 //**Type definitions****************************************************************************
122 //**********************************************************************************************
123
124 public:
125 //**Type definitions****************************************************************************
128
131
135 using ReturnType = const ElementType;
136 using CompositeType = const ResultType;
137
139 using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
140 //**********************************************************************************************
141
142 //**Compilation flags***************************************************************************
144 static constexpr bool simdEnabled = false;
145
147 static constexpr bool smpAssignable = false;
148 //**********************************************************************************************
149
150 //**Constructor*********************************************************************************
155 explicit inline SMatVarExpr( const MT& sm ) noexcept
156 : sm_( sm ) // Sparse matrix of the variance expression
157 {}
158 //**********************************************************************************************
159
160 //**Subscript operator**************************************************************************
166 inline ReturnType operator[]( size_t index ) const {
167 BLAZE_INTERNAL_ASSERT( index < sm_.columns(), "Invalid vector access index" );
168 return var( column( sm_, index, unchecked ) );
169 }
170 //**********************************************************************************************
171
172 //**At function*********************************************************************************
179 inline ReturnType at( size_t index ) const {
180 if( index >= sm_.columns() ) {
181 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
182 }
183 return (*this)[index];
184 }
185 //**********************************************************************************************
186
187 //**Size function*******************************************************************************
192 inline size_t size() const noexcept {
193 return sm_.columns();
194 }
195 //**********************************************************************************************
196
197 //**Operand access******************************************************************************
202 inline Operand operand() const noexcept {
203 return sm_;
204 }
205 //**********************************************************************************************
206
207 //**********************************************************************************************
213 template< typename T >
214 inline bool canAlias( const T* alias ) const noexcept {
215 return ( sm_.isAliased( alias ) );
216 }
217 //**********************************************************************************************
218
219 //**********************************************************************************************
225 template< typename T >
226 inline bool isAliased( const T* alias ) const noexcept {
227 return ( sm_.isAliased( alias ) );
228 }
229 //**********************************************************************************************
230
231 //**********************************************************************************************
236 inline bool isAligned() const noexcept {
237 return false;
238 }
239 //**********************************************************************************************
240
241 private:
242 //**Member variables****************************************************************************
244 //**********************************************************************************************
245
246 //**Assignment to dense vectors*****************************************************************
258 template< typename VT1 > // Type of the target dense vector
259 friend inline void assign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
260 {
262
266
267 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
268
269 const OT tmp( serial( rhs.sm_ ) );
270 assign( *lhs, var<columnwise>( tmp ) );
271 }
273 //**********************************************************************************************
274
275 //**Assignment to sparse vectors****************************************************************
288 template< typename VT1 > // Type of the target dense vector
289 friend inline void assign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
290 {
292
296
297 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
298
299 const ResultType tmp( serial( rhs ) );
300 assign( *lhs, tmp );
301 }
303 //**********************************************************************************************
304
305 //**Addition assignment to dense vectors********************************************************
318 template< typename VT1 > // Type of the target dense vector
319 friend inline void addAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
320 {
322
326
327 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
328
329 const OT tmp( serial( rhs.sm_ ) );
330 addAssign( *lhs, var<columnwise>( tmp ) );
331 }
333 //**********************************************************************************************
334
335 //**Addition assignment to sparse vectors*******************************************************
348 template< typename VT1 > // Type of the target dense vector
349 friend inline void addAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
350 {
352
356
357 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
358
359 const ResultType tmp( serial( rhs ) );
360 addAssign( *lhs, tmp );
361 }
363 //**********************************************************************************************
364
365 //**Subtraction assignment to dense vectors*****************************************************
378 template< typename VT1 > // Type of the target dense vector
379 friend inline void subAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
380 {
382
386
387 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
388
389 const OT tmp( serial( rhs.sm_ ) );
390 subAssign( *lhs, var<columnwise>( tmp ) );
391 }
393 //**********************************************************************************************
394
395 //**Subtraction assignment to sparse vectors****************************************************
408 template< typename VT1 > // Type of the target dense vector
409 friend inline void subAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
410 {
412
416
417 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
418
419 const ResultType tmp( serial( rhs ) );
420 subAssign( *lhs, tmp );
421 }
423 //**********************************************************************************************
424
425 //**Multiplication assignment to dense vectors**************************************************
438 template< typename VT1 > // Type of the target dense vector
439 friend inline void multAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
440 {
442
446
447 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
448
449 const OT tmp( serial( rhs.sm_ ) );
450 multAssign( *lhs, var<columnwise>( tmp ) );
451 }
453 //**********************************************************************************************
454
455 //**Multiplication assignment to sparse vectors*************************************************
468 template< typename VT1 > // Type of the target dense vector
469 friend inline void multAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
470 {
472
476
477 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
478
479 const ResultType tmp( serial( rhs ) );
480 multAssign( *lhs, tmp );
481 }
483 //**********************************************************************************************
484
485 //**Division assignment to dense vectors********************************************************
498 template< typename VT1 > // Type of the target dense vector
499 friend inline void divAssign( DenseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
500 {
502
506
507 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
508
509 const OT tmp( serial( rhs.sm_ ) );
510 divAssign( *lhs, var<columnwise>( tmp ) );
511 }
513 //**********************************************************************************************
514
515 //**Division assignment to sparse vectors*******************************************************
528 template< typename VT1 > // Type of the target dense vector
529 friend inline void divAssign( SparseVector<VT1,true>& lhs, const SMatVarExpr& rhs )
530 {
532
536
537 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
538
539 const ResultType tmp( serial( rhs ) );
540 divAssign( *lhs, tmp );
541 }
543 //**********************************************************************************************
544
545 //**Compile time checks*************************************************************************
550 //**********************************************************************************************
551};
552//*************************************************************************************************
553
554
555
556
557//=================================================================================================
558//
559// CLASS TEMPLATE SPECIALIZATION FOR THE ROW-WISE VARIANCE FUNCTION ON ROW-MAJOR MATRICES
560//
561//=================================================================================================
562
563//*************************************************************************************************
570template< typename MT > // Type of the sparse matrix
572 : public MatReduceExpr< DenseVector< SMatVarExpr<MT,rowwise>, false >, rowwise >
573 , private Computation
574{
575 private:
576 //**Type definitions****************************************************************************
578 //**********************************************************************************************
579
580 //**Serial evaluation strategy******************************************************************
582
588 static constexpr bool useAssign = RequiresEvaluation_v<MT>;
589
592 template< typename VT >
593 static constexpr bool UseAssign_v = useAssign;
595 //**********************************************************************************************
596
597 public:
598 //**Type definitions****************************************************************************
601
604
608 using ReturnType = const ElementType;
609
612
614 using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
615 //**********************************************************************************************
616
617 //**ConstIterator class definition**************************************************************
620 class ConstIterator
621 {
622 public:
623 //**Type definitions*************************************************************************
624 using IteratorCategory = std::random_access_iterator_tag;
628 using DifferenceType = ptrdiff_t;
629
630 // STL iterator requirements
636 //*******************************************************************************************
637
638 //**Constructor******************************************************************************
644 inline ConstIterator( Operand sm, size_t index )
645 : sm_ ( sm ) // Sparse matrix of the variance expression
646 , index_( index ) // Index to the current matrix row
647 {}
648 //*******************************************************************************************
649
650 //**Addition assignment operator*************************************************************
656 inline ConstIterator& operator+=( size_t inc ) {
657 index_ += inc;
658 return *this;
659 }
660 //*******************************************************************************************
661
662 //**Subtraction assignment operator**********************************************************
668 inline ConstIterator& operator-=( size_t dec ) {
669 index_ -= dec;
670 return *this;
671 }
672 //*******************************************************************************************
673
674 //**Prefix increment operator****************************************************************
679 inline ConstIterator& operator++() {
680 ++index_;
681 return *this;
682 }
683 //*******************************************************************************************
684
685 //**Postfix increment operator***************************************************************
690 inline const ConstIterator operator++( int ) {
691 return ConstIterator( index_++ );
692 }
693 //*******************************************************************************************
694
695 //**Prefix decrement operator****************************************************************
700 inline ConstIterator& operator--() {
701 --index_;
702 return *this;
703 }
704 //*******************************************************************************************
705
706 //**Postfix decrement operator***************************************************************
711 inline const ConstIterator operator--( int ) {
712 return ConstIterator( index_-- );
713 }
714 //*******************************************************************************************
715
716 //**Element access operator******************************************************************
721 inline ReturnType operator*() const {
722 return var( row( sm_, index_, unchecked ) );
723 }
724 //*******************************************************************************************
725
726 //**Equality operator************************************************************************
732 inline bool operator==( const ConstIterator& rhs ) const {
733 return index_ == rhs.index_;
734 }
735 //*******************************************************************************************
736
737 //**Inequality operator**********************************************************************
743 inline bool operator!=( const ConstIterator& rhs ) const {
744 return index_ != rhs.index_;
745 }
746 //*******************************************************************************************
747
748 //**Less-than operator***********************************************************************
754 inline bool operator<( const ConstIterator& rhs ) const {
755 return index_ < rhs.index_;
756 }
757 //*******************************************************************************************
758
759 //**Greater-than operator********************************************************************
765 inline bool operator>( const ConstIterator& rhs ) const {
766 return index_ > rhs.index_;
767 }
768 //*******************************************************************************************
769
770 //**Less-or-equal-than operator**************************************************************
776 inline bool operator<=( const ConstIterator& rhs ) const {
777 return index_ <= rhs.index_;
778 }
779 //*******************************************************************************************
780
781 //**Greater-or-equal-than operator***********************************************************
787 inline bool operator>=( const ConstIterator& rhs ) const {
788 return index_ >= rhs.index_;
789 }
790 //*******************************************************************************************
791
792 //**Subtraction operator*********************************************************************
798 inline DifferenceType operator-( const ConstIterator& rhs ) const {
799 return index_ - rhs.index_;
800 }
801 //*******************************************************************************************
802
803 //**Addition operator************************************************************************
810 friend inline const ConstIterator operator+( const ConstIterator& it, size_t inc ) {
811 return ConstIterator( it.index_ + inc );
812 }
813 //*******************************************************************************************
814
815 //**Addition operator************************************************************************
822 friend inline const ConstIterator operator+( size_t inc, const ConstIterator& it ) {
823 return ConstIterator( it.index_ + inc );
824 }
825 //*******************************************************************************************
826
827 //**Subtraction operator*********************************************************************
834 friend inline const ConstIterator operator-( const ConstIterator& it, size_t dec ) {
835 return ConstIterator( it.index_ - dec );
836 }
837 //*******************************************************************************************
838
839 private:
840 //**Member variables*************************************************************************
842 size_t index_;
843 //*******************************************************************************************
844 };
845 //**********************************************************************************************
846
847 //**Compilation flags***************************************************************************
849 static constexpr bool simdEnabled = false;
850
852 static constexpr bool smpAssignable = false;
853 //**********************************************************************************************
854
855 //**Constructor*********************************************************************************
860 explicit inline SMatVarExpr( const MT& sm ) noexcept
861 : sm_( sm ) // Sparse matrix of the variance expression
862 {}
863 //**********************************************************************************************
864
865 //**Subscript operator**************************************************************************
871 inline ReturnType operator[]( size_t index ) const {
872 BLAZE_INTERNAL_ASSERT( index < sm_.rows(), "Invalid vector access index" );
873 return var( row( sm_, index, unchecked ) );
874 }
875 //**********************************************************************************************
876
877 //**At function*********************************************************************************
884 inline ReturnType at( size_t index ) const {
885 if( index >= sm_.rows() ) {
886 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
887 }
888 return (*this)[index];
889 }
890 //**********************************************************************************************
891
892 //**Begin function******************************************************************************
897 inline ConstIterator begin() const {
898 return ConstIterator( sm_, 0UL );
899 }
900 //**********************************************************************************************
901
902 //**End function********************************************************************************
907 inline ConstIterator end() const {
908 return ConstIterator( sm_, size() );
909 }
910 //**********************************************************************************************
911
912 //**Size function*******************************************************************************
917 inline size_t size() const noexcept {
918 return sm_.rows();
919 }
920 //**********************************************************************************************
921
922 //**Operand access******************************************************************************
927 inline Operand operand() const noexcept {
928 return sm_;
929 }
930 //**********************************************************************************************
931
932 //**********************************************************************************************
938 template< typename T >
939 inline bool canAlias( const T* alias ) const noexcept {
940 return ( sm_.isAliased( alias ) );
941 }
942 //**********************************************************************************************
943
944 //**********************************************************************************************
950 template< typename T >
951 inline bool isAliased( const T* alias ) const noexcept {
952 return ( sm_.isAliased( alias ) );
953 }
954 //**********************************************************************************************
955
956 //**********************************************************************************************
961 inline bool isAligned() const noexcept {
962 return false;
963 }
964 //**********************************************************************************************
965
966 private:
967 //**Member variables****************************************************************************
969 //**********************************************************************************************
970
971 //**Assignment to vectors***********************************************************************
985 template< typename VT1 > // Type of the target vector
986 friend inline auto assign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
988 {
990
991 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
992
993 const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
994 assign( *lhs, var<rowwise>( tmp ) );
995 }
997 //**********************************************************************************************
998
999 //**Addition assignment to vectors**************************************************************
1013 template< typename VT1 > // Type of the target vector
1014 friend inline auto addAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1016 {
1018
1019 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
1020
1021 const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1022 addAssign( *lhs, var<rowwise>( tmp ) );
1023 }
1025 //**********************************************************************************************
1026
1027 //**Subtraction assignment to vectors***********************************************************
1042 template< typename VT1 > // Type of the target vector
1043 friend inline auto subAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1044 -> EnableIf_t< UseAssign_v<VT1> >
1045 {
1047
1048 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
1049
1050 const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1051 subAssign( *lhs, var<rowwise>( tmp ) );
1052 }
1054 //**********************************************************************************************
1055
1056 //**Multiplication assignment to vectors********************************************************
1071 template< typename VT1 > // Type of the target vector
1072 friend inline auto multAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1073 -> EnableIf_t< UseAssign_v<VT1> >
1074 {
1076
1077 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
1078
1079 const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1080 multAssign( *lhs, var<rowwise>( tmp ) );
1081 }
1083 //**********************************************************************************************
1084
1085 //**Division assignment to vectors**************************************************************
1099 template< typename VT1 > // Type of the target vector
1100 friend inline auto divAssign( Vector<VT1,false>& lhs, const SMatVarExpr& rhs )
1101 -> EnableIf_t< UseAssign_v<VT1> >
1102 {
1104
1105 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
1106
1107 const RT tmp( serial( rhs.sm_ ) ); // Evaluation of the sparse matrix operand
1108 divAssign( *lhs, var<rowwise>( tmp ) );
1109 }
1111 //**********************************************************************************************
1112
1113 //**Compile time checks*************************************************************************
1118 //**********************************************************************************************
1119};
1120//*************************************************************************************************
1121
1122
1123
1124
1125//=================================================================================================
1126//
1127// GLOBAL FUNCTIONS
1128//
1129//=================================================================================================
1130
1131//*************************************************************************************************
1139template< typename MT // Type of the sparse matrix
1140 , bool SO > // Storage order
1141inline decltype(auto) var_backend( const SparseMatrix<MT,SO>& sm, FalseType )
1142{
1143 using BT = UnderlyingBuiltin_t<MT>;
1144
1145 const size_t n ( size( *sm ) );
1146 const size_t nz( nonZeros( *sm ) );
1147
1148 BLAZE_INTERNAL_ASSERT( n > 1UL, "Invalid matrix size detected" );
1149 BLAZE_INTERNAL_ASSERT( n >= nz, "Invalid number of non-zero elements detected" );
1150
1151 const auto meanValue( mean( *sm ) );
1152 auto variance( ( n - nz ) * pow2( meanValue ) );
1153
1154 const size_t iend( SO ? (*sm).columns() : (*sm).rows() );
1155 for( size_t i=0UL; i<iend; ++i ) {
1156 const auto end( (*sm).end(i) );
1157 for( auto element=(*sm).begin(i); element!=end; ++element ) {
1158 variance += pow2( element->value() - meanValue );
1159 }
1160 }
1161
1162 return variance * inv( BT( n-1UL ) );
1163}
1165//*************************************************************************************************
1166
1167
1168//*************************************************************************************************
1176template< typename MT // Type of the sparse matrix
1177 , bool SO > // Storage order
1178inline decltype(auto) var_backend( const SparseMatrix<MT,SO>& sm, TrueType )
1179{
1180 MAYBE_UNUSED( sm );
1181
1182 BLAZE_INTERNAL_ASSERT( size( *sm ) > 1UL, "Invalid matrix size detected" );
1183
1184 return ElementType_t<MT>();
1185}
1187//*************************************************************************************************
1188
1189
1190//*************************************************************************************************
1214template< typename MT // Type of the sparse matrix
1215 , bool SO > // Storage order
1216inline decltype(auto) var( const SparseMatrix<MT,SO>& sm )
1217{
1219
1220 if( size( *sm ) < 2UL ) {
1221 BLAZE_THROW_INVALID_ARGUMENT( "Invalid input matrix" );
1222 }
1223
1224 return var_backend( *sm, IsZero<MT>() );
1225}
1226//*************************************************************************************************
1227
1228
1229//*************************************************************************************************
1237template< ReductionFlag RF // Reduction flag
1238 , typename MT > // Type of the sparse matrix
1239inline const SMatVarExpr<MT,RF> var_backend( const SparseMatrix<MT,false>& sm )
1240{
1241 using ReturnType = const SMatVarExpr<MT,RF>;
1242 return ReturnType( *sm );
1243}
1245//*************************************************************************************************
1246
1247
1248//*************************************************************************************************
1256template< ReductionFlag RF // Reduction flag
1257 , typename MT > // Type of the sparse matrix
1258inline decltype(auto) var_backend( const SparseMatrix<MT,true>& sm )
1259{
1260 constexpr ReductionFlag RF2( RF == rowwise ? columnwise : rowwise );
1261 return trans( var<RF2>( trans( *sm ) ) );
1262}
1264//*************************************************************************************************
1265
1266
1267//*************************************************************************************************
1303template< ReductionFlag RF // Reduction flag
1304 , typename MT // Type of the sparse matrix
1305 , bool SO > // Storage order
1306inline decltype(auto) var( const SparseMatrix<MT,SO>& sm )
1307{
1309
1310 BLAZE_STATIC_ASSERT_MSG( RF < 2UL, "Invalid reduction flag" );
1311
1312 return var_backend<RF>( *sm );
1313}
1314//*************************************************************************************************
1315
1316} // namespace blaze
1317
1318#endif
Header file for auxiliary alias declarations.
typename T::CompositeType CompositeType_t
Alias declaration for nested CompositeType type definitions.
Definition: Aliases.h:110
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.
Definition: Aliases.h:450
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::OppositeType OppositeType_t
Alias declaration for nested OppositeType type definitions.
Definition: Aliases.h:310
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IntegralConstant class template.
Header file for the InvAdd functor.
Header file for the invert shim.
Header file for the IsExpression type trait class.
Deactivation of problematic macros.
Header file for the MAYBE_UNUSED function template.
Header file for the reduce trait.
Header file for the reduction flags.
constexpr ReductionFlag columnwise
Reduction flag for column-wise reduction operations.
Definition: ReductionFlag.h:97
constexpr ReductionFlag rowwise
Reduction flag for row-wise reduction operations.
Definition: ReductionFlag.h:77
size_t ReductionFlag
Type of the reduction flags.
Definition: ReductionFlag.h:57
Constraints on the storage order of matrix types.
Compile time assertion.
Header file for the UnderlyingBuiltin type trait.
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Expression object for the column-wise variance function on row-major sparse matrices.
Definition: SMatVarExpr.h:116
SMatVarExpr(const MT &sm) noexcept
Constructor for the SMatVarExpr class.
Definition: SMatVarExpr.h:155
const ResultType CompositeType
Data type for composite expression templates.
Definition: SMatVarExpr.h:136
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatVarExpr.h:214
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatVarExpr.h:202
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:243
ReduceTrait_t< RT, InvAdd, columnwise > ResultType
Result type for expression template evaluations.
Definition: SMatVarExpr.h:132
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatVarExpr.h:133
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatVarExpr.h:226
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatVarExpr.h:179
OppositeType_t< MT > OT
Opposite type of the sparse matrix expression.
Definition: SMatVarExpr.h:120
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatVarExpr.h:139
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatVarExpr.h:166
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatVarExpr.h:236
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatVarExpr.h:119
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatVarExpr.h:192
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatVarExpr.h:134
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatVarExpr.h:135
CompositeType_t< MT > CT
Composite type of the sparse matrix expression.
Definition: SMatVarExpr.h:121
const ConstIterator operator--(int)
Post-decrement operator.
Definition: SMatVarExpr.h:711
IteratorCategory iterator_category
The iterator category.
Definition: SMatVarExpr.h:631
ptrdiff_t DifferenceType
Difference between two iterators.
Definition: SMatVarExpr.h:628
ConstIterator(Operand sm, size_t index)
Constructor for the ConstIterator class.
Definition: SMatVarExpr.h:644
ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: SMatVarExpr.h:668
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:841
ValueType value_type
Type of the underlying elements.
Definition: SMatVarExpr.h:632
bool operator>=(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:787
ElementType ValueType
Type of the underlying elements.
Definition: SMatVarExpr.h:625
size_t index_
Index to the current matrix row.
Definition: SMatVarExpr.h:842
bool operator<=(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:776
bool operator==(const ConstIterator &rhs) const
Equality comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:732
const ConstIterator operator++(int)
Post-increment operator.
Definition: SMatVarExpr.h:690
ConstIterator & operator--()
Pre-decrement operator.
Definition: SMatVarExpr.h:700
DifferenceType difference_type
Difference between two iterators.
Definition: SMatVarExpr.h:635
bool operator<(const ConstIterator &rhs) const
Less-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:754
ElementType & ReferenceType
Reference return type.
Definition: SMatVarExpr.h:627
friend const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition: SMatVarExpr.h:810
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition: SMatVarExpr.h:624
ReferenceType reference
Reference return type.
Definition: SMatVarExpr.h:634
bool operator!=(const ConstIterator &rhs) const
Inequality comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:743
ConstIterator & operator++()
Pre-increment operator.
Definition: SMatVarExpr.h:679
friend const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition: SMatVarExpr.h:834
ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition: SMatVarExpr.h:721
friend const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition: SMatVarExpr.h:822
DifferenceType operator-(const ConstIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: SMatVarExpr.h:798
ElementType * PointerType
Pointer return type.
Definition: SMatVarExpr.h:626
PointerType pointer
Pointer return type.
Definition: SMatVarExpr.h:633
bool operator>(const ConstIterator &rhs) const
Greater-than comparison between two ConstIterator objects.
Definition: SMatVarExpr.h:765
ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: SMatVarExpr.h:656
Expression object for the row-wise variance function on row-major sparse matrices.
Definition: SMatVarExpr.h:574
ReduceTrait_t< RT, InvAdd, rowwise > ResultType
Result type for expression template evaluations.
Definition: SMatVarExpr.h:605
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition: SMatVarExpr.h:907
Operand sm_
Sparse matrix of the variance expression.
Definition: SMatVarExpr.h:968
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: SMatVarExpr.h:606
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: SMatVarExpr.h:939
If_t< useAssign, const ResultType, const SMatVarExpr & > CompositeType
Data type for composite expression templates.
Definition: SMatVarExpr.h:611
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition: SMatVarExpr.h:897
Operand operand() const noexcept
Returns the sparse matrix operand.
Definition: SMatVarExpr.h:927
SMatVarExpr(const MT &sm) noexcept
Constructor for the SMatVarExpr class.
Definition: SMatVarExpr.h:860
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: SMatVarExpr.h:917
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: SMatVarExpr.h:951
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition: SMatVarExpr.h:884
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition: SMatVarExpr.h:871
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition: SMatVarExpr.h:961
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: SMatVarExpr.h:607
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite type of the left-hand side sparse matrix expression.
Definition: SMatVarExpr.h:614
const ElementType ReturnType
Return type for expression template evaluations.
Definition: SMatVarExpr.h:608
ResultType_t< MT > RT
Result type of the sparse matrix expression.
Definition: SMatVarExpr.h:577
Base template for the row-/column-wise variance computations on row-major sparse matrices.
Definition: SMatVarExpr.h:93
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
Base class for N-dimensional vectors.
Definition: Vector.h:82
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseVector base class.
Header file for the MatReduceExpr base class.
Header file for the SparseMatrix base class.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) mean(const DenseMatrix< MT, SO > &dm)
Computes the (arithmetic) mean for the given dense matrix.
Definition: DMatMeanExpr.h:134
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:405
decltype(auto) var(const DenseMatrix< MT, SO > &dm)
Computes the variance for the given dense matrix.
Definition: DMatVarExpr.h:138
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: RowMajorMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_ROW_VECTOR_TYPE(T)
Constraint on the data type.
Definition: RowVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: ColumnMajorMatrix.h:61
typename ReduceTrait< T, OP, RF... >::Type ReduceTrait_t
Auxiliary alias declaration for the ReduceTrait class template.
Definition: ReduceTrait.h:150
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
decltype(auto) pow2(const Matrix< MT, SO > &m)
Computes the square for each single element of the matrix m.
Definition: Matrix.h:686
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:584
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.
Definition: StaticAssert.h:123
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
BoolConstant< false > FalseType
Type/value traits base class.
Definition: IntegralConstant.h:121
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Header file for all forward declarations for expression class templates.
Header file for the pow2 shim.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Compile time check for zero vectors or matrices.
Definition: IsZero.h:109
Base class for all matrix reduction expression templates.
Definition: MatReduceExpr.h:70
Header file for the IsZero type trait.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.