UniLowerElement.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_UNILOWERELEMENT_H_
36 #define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_UNILOWERELEMENT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
51 #include <blaze/math/Exception.h>
58 #include <blaze/util/Types.h>
59 
60 
61 namespace blaze {
62 
63 //=================================================================================================
64 //
65 // CLASS DEFINITION
66 //
67 //=================================================================================================
68 
69 //*************************************************************************************************
95 template< typename MT > // Type of the adapted matrix
97  : private SparseElement
98 {
99  private:
100  //**Type definitions****************************************************************************
103  //**********************************************************************************************
104 
105  public:
106  //**Type definitions****************************************************************************
108  using IndexType = size_t;
112  //**********************************************************************************************
113 
114  //**Constructor*********************************************************************************
117  inline UniLowerElement( IteratorType pos, bool diagonal );
119  //**********************************************************************************************
120 
121  //**Assignment operators************************************************************************
124  template< typename T > inline UniLowerElement& operator= ( const T& v );
125  template< typename T > inline UniLowerElement& operator+=( const T& v );
126  template< typename T > inline UniLowerElement& operator-=( const T& v );
127  template< typename T > inline UniLowerElement& operator*=( const T& v );
128  template< typename T > inline UniLowerElement& operator/=( const T& v );
130  //**********************************************************************************************
131 
132  //**Access operators****************************************************************************
135  inline Pointer operator->() noexcept;
137  //**********************************************************************************************
138 
139  //**Utility functions***************************************************************************
142  inline Reference value() const;
143  inline IndexType index() const;
145  //**********************************************************************************************
146 
147  private:
148  //**Member variables****************************************************************************
150  bool diagonal_;
151  //**********************************************************************************************
152 
153  //**Compile time checks*************************************************************************
167  //**********************************************************************************************
168 };
169 //*************************************************************************************************
170 
171 
172 
173 
174 //=================================================================================================
175 //
176 // CONSTRUCTORS
177 //
178 //=================================================================================================
179 
180 //*************************************************************************************************
186 template< typename MT > // Type of the adapted matrix
188  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
189  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
190 {}
191 //*************************************************************************************************
192 
193 
194 
195 
196 //=================================================================================================
197 //
198 // OPERATORS
199 //
200 //=================================================================================================
201 
202 //*************************************************************************************************
209 template< typename MT > // Type of the adapted matrix
210 template< typename T > // Type of the right-hand side value
212 {
213  if( diagonal_ ) {
214  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
215  }
216 
217  *pos_ = v;
218 
219  return *this;
220 }
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
231 template< typename MT > // Type of the adapted matrix
232 template< typename T > // Type of the right-hand side value
234 {
235  if( diagonal_ ) {
236  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
237  }
238 
239  *pos_ += v;
240 
241  return *this;
242 }
243 //*************************************************************************************************
244 
245 
246 //*************************************************************************************************
253 template< typename MT > // Type of the adapted matrix
254 template< typename T > // Type of the right-hand side value
256 {
257  if( diagonal_ ) {
258  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
259  }
260 
261  *pos_ -= v;
262 
263  return *this;
264 }
265 //*************************************************************************************************
266 
267 
268 //*************************************************************************************************
275 template< typename MT > // Type of the adapted matrix
276 template< typename T > // Type of the right-hand side value
278 {
279  if( diagonal_ ) {
280  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
281  }
282 
283  *pos_ *= v;
284 
285  return *this;
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
297 template< typename MT > // Type of the adapted matrix
298 template< typename T > // Type of the right-hand side value
300 {
301  if( diagonal_ ) {
302  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
303  }
304 
305  *pos_ /= v;
306 
307  return *this;
308 }
309 //*************************************************************************************************
310 
311 
312 
313 
314 //=================================================================================================
315 //
316 // ACCESS OPERATORS
317 //
318 //=================================================================================================
319 
320 //*************************************************************************************************
325 template< typename MT > // Type of the adapted matrix
327 {
328  return this;
329 }
330 //*************************************************************************************************
331 
332 
333 
334 
335 //=================================================================================================
336 //
337 // UTILITY FUNCTIONS
338 //
339 //=================================================================================================
340 
341 //*************************************************************************************************
346 template< typename MT > // Type of the adapted matrix
348 {
349  return Reference( pos_->value(), diagonal_ );
350 }
351 //*************************************************************************************************
352 
353 
354 //*************************************************************************************************
359 template< typename MT > // Type of the adapted matrix
361 {
362  return pos_->index();
363 }
364 //*************************************************************************************************
365 
366 } // namespace blaze
367 
368 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Constraint on the data type.
Representation of an element within a sparse lower unitriangular matrix.The UniLowerElement class rep...
Definition: UniLowerElement.h:96
Representation of a value within a sparse lower unitriangular matrix.The UniLowerValue class represen...
Definition: UniLowerValue.h:105
Header file for basic type definitions.
Pointer operator->() noexcept
Direct access to the unilower element.
Definition: UniLowerElement.h:326
ElementType_t< MT > ElementType
Type of the represented matrix element.
Definition: UniLowerElement.h:101
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
Constraint on the data type.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
UniLowerValue< MT > Reference
Reference return type.
Definition: UniLowerElement.h:109
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
IndexType index() const
Access to the current index of the unilower element.
Definition: UniLowerElement.h:360
Constraint on the data type.
Header file for the SparseElement base class.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:375
Header file for the UniLowerValue class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
typename T::Iterator Iterator_t
Alias declaration for nested Iterator type definitions.The Iterator_t alias declaration provides a co...
Definition: Aliases.h:190
Constraint on the data type.
Constraint on the data type.
Iterator_t< MT > IteratorType
Type of the underlying sparse matrix iterators.
Definition: UniLowerElement.h:102
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
IteratorType pos_
Iterator to the current lower unitriangular matrix element.
Definition: UniLowerElement.h:149
Constraint on the data type.
Constraint on the data type.
Base class for all sparse element types.The SparseElement class is the base class for all sparse elem...
Definition: SparseElement.h:57
UniLowerElement(IteratorType pos, bool diagonal)
Constructor for the UniLowerElement class.
Definition: UniLowerElement.h:187
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerElement.h:150
Size type of the Blaze library.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Reference value() const
Access to the current value of the unilower element.
Definition: UniLowerElement.h:347