Blaze 3.9
SMatFixExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_SMATFIXEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_SMATFIXEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
50
51
52namespace blaze {
53
54//=================================================================================================
55//
56// CLASS SMATFIXEXPR
57//
58//=================================================================================================
59
60//*************************************************************************************************
67template< typename MT // Type of the sparse matrix
68 , bool SO > // Storage order
70{
71 public:
72 //**Constructor*********************************************************************************
77 explicit inline SMatFixExpr( MT& sm ) noexcept
78 : sm_( sm ) // The sparse matrix operand
79 {}
80 //**********************************************************************************************
81
82 //**********************************************************************************************
93 template< typename Type > // Type of the initializer list elements
94 SMatFixExpr& operator=( initializer_list< initializer_list<Type> > list )
95 {
96 if( sm_.rows() != list.size() || sm_.columns() != determineColumns( list ) ) {
97 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
98 }
99
100 sm_ = list;
101
102 return *this;
103 }
104 //**********************************************************************************************
105
106 //**********************************************************************************************
117 template< typename MT2 // Type of the right-hand side matrix
118 , bool SO2 > // Storage order of the right-hand side matrix
120 {
121 if( sm_.rows() != (*rhs).rows() || sm_.columns() != (*rhs).columns() ) {
122 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to fixed-size matrix" );
123 }
124
125 sm_ = *rhs;
126
127 return *this;
128 }
129 //**********************************************************************************************
130
131 private:
132 //**Member variables****************************************************************************
133 MT& sm_;
134 //**********************************************************************************************
135
136 //**Compile time checks*************************************************************************
142 //**********************************************************************************************
143};
144//*************************************************************************************************
145
146
147
148
149//=================================================================================================
150//
151// GLOBAL OPERATORS
152//
153//=================================================================================================
154
155//*************************************************************************************************
171template< typename MT // Type of the sparse matrix
172 , bool SO > // Storage order
173decltype(auto) fix( SparseMatrix<MT,SO>& sm ) noexcept
174{
175 return SMatFixExpr<MT,SO>( *sm );
176}
177//*************************************************************************************************
178
179} // namespace blaze
180
181#endif
Deactivation of problematic macros.
Base class for matrices.
Definition: Matrix.h:85
Expression object for fixing the size of a sparse matrix.
Definition: SMatFixExpr.h:70
SMatFixExpr & operator=(const Matrix< MT2, SO2 > &rhs)
Assignment operator for different matrices.
Definition: SMatFixExpr.h:119
SMatFixExpr(MT &sm) noexcept
Constructor for the SMatTransposer class.
Definition: SMatFixExpr.h:77
SMatFixExpr & operator=(initializer_list< initializer_list< Type > > list)
List assignment to all matrix elements.
Definition: SMatFixExpr.h:94
MT & sm_
The sparse matrix operand.
Definition: SMatFixExpr.h:133
Base class for sparse matrices.
Definition: SparseMatrix.h:77
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix 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_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.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
decltype(auto) fix(SparseMatrix< MT, SO > &sm) noexcept
Fixing the size of the given sparse matrix.
Definition: SMatFixExpr.h:173
#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.