Blaze 3.9
DMatFixExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATFIXEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATFIXEXPR_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 DMATFIXEXPR
59//
60//=================================================================================================
61
62//*************************************************************************************************
69template< typename MT // Type of the dense matrix
70 , bool SO > // Storage order
72{
73 public:
74 //**Constructor*********************************************************************************
79 explicit inline DMatFixExpr( MT& dm ) noexcept
80 : dm_( dm ) // The dense matrix operand
81 {}
82 //**********************************************************************************************
83
84 //**********************************************************************************************
95 template< typename Type > // Type of the initializer list elements
96 DMatFixExpr& operator=( initializer_list< initializer_list<Type> > list )
97 {
98 if( dm_.rows() != list.size() || dm_.columns() != determineColumns( list ) ) {
99 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
100 }
101
102 dm_ = list;
103
104 return *this;
105 }
106 //**********************************************************************************************
107
108 //**********************************************************************************************
119 template< typename Other // Data type of the static array
120 , size_t Rows // Number of rows of the static array
121 , size_t Cols > // Number of columns of the static array
122 DMatFixExpr& operator=( const Other (&array)[Rows][Cols] )
123 {
124 if( dm_.rows() != Rows || dm_.columns() != Cols ) {
125 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
126 }
127
128 dm_ = array;
129
130 return *this;
131 }
132 //**********************************************************************************************
133
134 //**********************************************************************************************
145 template< typename Other // Data type of the std::array
146 , size_t Rows // Number of rows of the std::array
147 , size_t Cols > // Number of columns of the std::array
148 DMatFixExpr& operator=( const std::array<std::array<Other,Cols>,Rows>& array )
149 {
150 if( dm_.rows() != Rows || dm_.columns() != Cols ) {
151 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
152 }
153
154 dm_ = array;
155
156 return *this;
157 }
158 //**********************************************************************************************
159
160 //**********************************************************************************************
171 template< typename MT2 // Type of the right-hand side matrix
172 , bool SO2 > // Storage order of the right-hand side matrix
174 {
175 if( dm_.rows() != (*rhs).rows() || dm_.columns() != (*rhs).columns() ) {
176 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
177 }
178
179 dm_ = *rhs;
180
181 return *this;
182 }
183 //**********************************************************************************************
184
185 private:
186 //**Member variables****************************************************************************
187 MT& dm_;
188 //**********************************************************************************************
189
190 //**Compile time checks*************************************************************************
196 //**********************************************************************************************
197};
198//*************************************************************************************************
199
200
201
202
203//=================================================================================================
204//
205// GLOBAL OPERATORS
206//
207//=================================================================================================
208
209//*************************************************************************************************
225template< typename MT // Type of the dense matrix
226 , bool SO > // Storage order
227decltype(auto) fix( DenseMatrix<MT,SO>& dm ) noexcept
228{
229 return DMatFixExpr<MT,SO>( *dm );
230}
231//*************************************************************************************************
232
233} // namespace blaze
234
235#endif
Deactivation of problematic macros.
Expression object for fixing the size of a dense matrix.
Definition: DMatFixExpr.h:72
MT & dm_
The dense matrix operand.
Definition: DMatFixExpr.h:187
DMatFixExpr & operator=(initializer_list< initializer_list< Type > > list)
List assignment to all matrix elements.
Definition: DMatFixExpr.h:96
DMatFixExpr & operator=(const Matrix< MT2, SO2 > &rhs)
Assignment operator for different matrices.
Definition: DMatFixExpr.h:173
DMatFixExpr & operator=(const Other(&array)[Rows][Cols])
Array assignment to all matrix elements.
Definition: DMatFixExpr.h:122
DMatFixExpr & operator=(const std::array< std::array< Other, Cols >, Rows > &array)
Array assignment to all matrix elements.
Definition: DMatFixExpr.h:148
DMatFixExpr(MT &dm) noexcept
Constructor for the DMatTransposer class.
Definition: DMatFixExpr.h:79
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for matrices.
Definition: Matrix.h:85
Constraint on the data type.
Constraint on the data type.
Header file for the DenseMatrix base class.
decltype(auto) fix(DenseMatrix< MT, SO > &dm) noexcept
Fixing the size of the given dense matrix.
Definition: DMatFixExpr.h:227
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.
Definition: Expression.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
constexpr size_t determineColumns(initializer_list< initializer_list< Type > > list) noexcept
Determines the maximum number of columns specified by the given initializer list.
Definition: InitializerList.h:107
#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.
Constraints on the storage order of matrix types.
Header file for basic type definitions.