Blaze 3.9
DVecFixExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECFIXEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECFIXEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <array>
51#include <blaze/util/Types.h>
52
53
54namespace blaze {
55
56//=================================================================================================
57//
58// CLASS DVECFIXEXPR
59//
60//=================================================================================================
61
62//*************************************************************************************************
69template< typename VT // Type of the dense vector
70 , bool TF > // Transpose flag
72{
73 public:
74 //**Constructor*********************************************************************************
79 explicit inline DVecFixExpr( VT& dv ) noexcept
80 : dv_( dv ) // The dense vector operand
81 {}
82 //**********************************************************************************************
83
84 //**********************************************************************************************
95 template< typename Type > // Type of the initializer list elements
96 DVecFixExpr& operator=( initializer_list<Type> list )
97 {
98 if( dv_.size() != list.size() ) {
99 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
100 }
101
102 dv_ = list;
103
104 return *this;
105 }
106 //**********************************************************************************************
107
108 //**********************************************************************************************
119 template< typename Other // Data type of the static array
120 , size_t Dim > // Dimension of the static array
121 DVecFixExpr& operator=( const Other (&array)[Dim] )
122 {
123 if( dv_.size() != Dim ) {
124 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
125 }
126
127 dv_ = array;
128
129 return *this;
130 }
131 //**********************************************************************************************
132
133 //**********************************************************************************************
144 template< typename Other // Data type of the std::array
145 , size_t Dim > // Dimension of the std::array
146 DVecFixExpr& operator=( const std::array<Other,Dim>& array )
147 {
148 if( dv_.size() != Dim ) {
149 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
150 }
151
152 dv_ = array;
153
154 return *this;
155 }
156 //**********************************************************************************************
157
158 //**********************************************************************************************
169 template< typename VT2 > // Type of the right-hand side vector
171 {
172 if( dv_.size() != (*rhs).size() ) {
173 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size vector" );
174 }
175
176 dv_ = *rhs;
177
178 return *this;
179 }
180 //**********************************************************************************************
181
182 private:
183 //**Member variables****************************************************************************
184 VT& dv_;
185 //**********************************************************************************************
186
187 //**Compile time checks*************************************************************************
193 //**********************************************************************************************
194};
195//*************************************************************************************************
196
197
198
199
200//=================================================================================================
201//
202// GLOBAL OPERATORS
203//
204//=================================================================================================
205
206//*************************************************************************************************
222template< typename VT // Type of the dense vector
223 , bool TF > // Transpose flag
224decltype(auto) fix( DenseVector<VT,TF>& dv ) noexcept
225{
226 return DVecFixExpr<VT,TF>( *dv );
227}
228//*************************************************************************************************
229
230} // namespace blaze
231
232#endif
Deactivation of problematic macros.
Expression object for fixing the size of a dense vector.
Definition: DVecFixExpr.h:72
DVecFixExpr & operator=(const Vector< VT2, TF > &rhs)
Assignment operator for different vectors.
Definition: DVecFixExpr.h:170
VT & dv_
The dense vector operand.
Definition: DVecFixExpr.h:184
DVecFixExpr & operator=(initializer_list< Type > list)
List assignment to all vector elements.
Definition: DVecFixExpr.h:96
DVecFixExpr & operator=(const Other(&array)[Dim])
Array assignment to all vector elements.
Definition: DVecFixExpr.h:121
DVecFixExpr(VT &dv) noexcept
Constructor for the DVecTransposer class.
Definition: DVecFixExpr.h:79
DVecFixExpr & operator=(const std::array< Other, Dim > &array)
Array assignment to all vector elements.
Definition: DVecFixExpr.h:146
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for N-dimensional vectors.
Definition: Vector.h:82
Constraint on the data type.
Constraint on the data type.
Header file for the DenseVector base class.
decltype(auto) fix(DenseVector< VT, TF > &dv) noexcept
Fixing the size of the given dense vector.
Definition: DVecFixExpr.h:224
#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_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#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.
Header file for basic type definitions.