Blaze 3.9
SVecFixExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_SVECFIXEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SVECFIXEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
50
51
52namespace blaze {
53
54//=================================================================================================
55//
56// CLASS SVECFIXEXPR
57//
58//=================================================================================================
59
60//*************************************************************************************************
67template< typename VT // Type of the sparse vector
68 , bool TF > // Transpose flag
70{
71 public:
72 //**Constructor*********************************************************************************
77 explicit inline SVecFixExpr( VT& sv ) noexcept
78 : sv_( sv ) // The sparse vector operand
79 {}
80 //**********************************************************************************************
81
82 //**********************************************************************************************
93 template< typename Type > // Type of the initializer list elements
94 SVecFixExpr& operator=( initializer_list<Type> list )
95 {
96 if( sv_.size() != list.size() ) {
97 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
98 }
99
100 sv_ = list;
101
102 return *this;
103 }
104 //**********************************************************************************************
105
106 //**********************************************************************************************
117 template< typename VT2 > // Type of the right-hand side vector
119 {
120 if( sv_.size() != (*rhs).size() ) {
121 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
122 }
123
124 sv_ = *rhs;
125
126 return *this;
127 }
128 //**********************************************************************************************
129
130 private:
131 //**Member variables****************************************************************************
132 VT& sv_;
133 //**********************************************************************************************
134
135 //**Compile time checks*************************************************************************
141 //**********************************************************************************************
142};
143//*************************************************************************************************
144
145
146
147
148//=================================================================================================
149//
150// GLOBAL OPERATORS
151//
152//=================================================================================================
153
154//*************************************************************************************************
170template< typename VT // Type of the sparse vector
171 , bool TF > // Transpose flag
172decltype(auto) fix( SparseVector<VT,TF>& sv ) noexcept
173{
174 return SVecFixExpr<VT,TF>( *sv );
175}
176//*************************************************************************************************
177
178} // namespace blaze
179
180#endif
Deactivation of problematic macros.
Expression object for fixing the size of a sparse vector.
Definition: SVecFixExpr.h:70
SVecFixExpr(VT &sv) noexcept
Constructor for the SVecTransposer class.
Definition: SVecFixExpr.h:77
SVecFixExpr & operator=(const Vector< VT2, TF > &rhs)
Assignment operator for different vectors.
Definition: SVecFixExpr.h:118
VT & sv_
The sparse vector operand.
Definition: SVecFixExpr.h:132
SVecFixExpr & operator=(initializer_list< Type > list)
List assignment to all vector elements.
Definition: SVecFixExpr.h:94
Base class for sparse vectors.
Definition: SparseVector.h:72
Base class for N-dimensional vectors.
Definition: Vector.h:82
Constraint on the data type.
Constraint on the data type.
Header file for the SparseVector base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.
Definition: Expression.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: SparseVector.h:61
decltype(auto) fix(SparseVector< VT, TF > &sv) noexcept
Fixing the size of the given sparse vector.
Definition: SVecFixExpr.h:172
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Constraint on the data type.