Blaze  3.6
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>
53 #include <blaze/math/Exception.h>
60 #include <blaze/util/Types.h>
61 
62 
63 namespace blaze {
64 
65 //=================================================================================================
66 //
67 // CLASS DEFINITION
68 //
69 //=================================================================================================
70 
71 //*************************************************************************************************
97 template< typename MT > // Type of the adapted matrix
99  : private SparseElement
100 {
101  private:
102  //**Type definitions****************************************************************************
105  //**********************************************************************************************
106 
107  public:
108  //**Type definitions****************************************************************************
110  using IndexType = size_t;
114  //**********************************************************************************************
115 
116  //**Constructor*********************************************************************************
119  inline UniLowerElement( IteratorType pos, bool diagonal );
121  //**********************************************************************************************
122 
123  //**Assignment operators************************************************************************
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 );
129  template< typename T > inline UniLowerElement& operator*=( const T& v );
130  template< typename T > inline UniLowerElement& operator/=( const T& v );
132  //**********************************************************************************************
133 
134  //**Access operators****************************************************************************
137  inline Pointer operator->() noexcept;
139  //**********************************************************************************************
140 
141  //**Utility functions***************************************************************************
144  inline Reference value() const;
145  inline IndexType index() const;
147  //**********************************************************************************************
148 
149  private:
150  //**Member variables****************************************************************************
152  bool diagonal_;
153  //**********************************************************************************************
154 
155  //**Compile time checks*************************************************************************
171  //**********************************************************************************************
172 };
173 //*************************************************************************************************
174 
175 
176 
177 
178 //=================================================================================================
179 //
180 // CONSTRUCTORS
181 //
182 //=================================================================================================
183 
184 //*************************************************************************************************
190 template< typename MT > // Type of the adapted matrix
192  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
193  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
194 {}
195 //*************************************************************************************************
196 
197 
198 
199 
200 //=================================================================================================
201 //
202 // OPERATORS
203 //
204 //=================================================================================================
205 
206 //*************************************************************************************************
213 template< typename MT > // Type of the adapted matrix
214 template< typename T > // Type of the right-hand side value
216 {
217  if( diagonal_ ) {
218  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
219  }
220 
221  *pos_ = v;
222 
223  return *this;
224 }
225 //*************************************************************************************************
226 
227 
228 //*************************************************************************************************
235 template< typename MT > // Type of the adapted matrix
236 template< typename T > // Type of the right-hand side value
238 {
239  if( diagonal_ ) {
240  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
241  }
242 
243  *pos_ += v;
244 
245  return *this;
246 }
247 //*************************************************************************************************
248 
249 
250 //*************************************************************************************************
257 template< typename MT > // Type of the adapted matrix
258 template< typename T > // Type of the right-hand side value
260 {
261  if( diagonal_ ) {
262  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
263  }
264 
265  *pos_ -= v;
266 
267  return *this;
268 }
269 //*************************************************************************************************
270 
271 
272 //*************************************************************************************************
279 template< typename MT > // Type of the adapted matrix
280 template< typename T > // Type of the right-hand side value
282 {
283  if( diagonal_ ) {
284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
285  }
286 
287  *pos_ *= v;
288 
289  return *this;
290 }
291 //*************************************************************************************************
292 
293 
294 //*************************************************************************************************
301 template< typename MT > // Type of the adapted matrix
302 template< typename T > // Type of the right-hand side value
304 {
305  if( diagonal_ ) {
306  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
307  }
308 
309  *pos_ /= v;
310 
311  return *this;
312 }
313 //*************************************************************************************************
314 
315 
316 
317 
318 //=================================================================================================
319 //
320 // ACCESS OPERATORS
321 //
322 //=================================================================================================
323 
324 //*************************************************************************************************
329 template< typename MT > // Type of the adapted matrix
331 {
332  return this;
333 }
334 //*************************************************************************************************
335 
336 
337 
338 
339 //=================================================================================================
340 //
341 // UTILITY FUNCTIONS
342 //
343 //=================================================================================================
344 
345 //*************************************************************************************************
350 template< typename MT > // Type of the adapted matrix
352 {
353  return Reference( pos_->value(), diagonal_ );
354 }
355 //*************************************************************************************************
356 
357 
358 //*************************************************************************************************
363 template< typename MT > // Type of the adapted matrix
365 {
366  return pos_->index();
367 }
368 //*************************************************************************************************
369 
370 } // namespace blaze
371 
372 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
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
Constraint on the data type.
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:98
Representation of a value within a sparse lower unitriangular matrix.The UniLowerValue class represen...
Definition: UniLowerValue.h:107
Constraint on the data type.
Header file for basic type definitions.
Pointer operator->() noexcept
Direct access to the unilower element.
Definition: UniLowerElement.h:330
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
ElementType_t< MT > ElementType
Type of the represented matrix element.
Definition: UniLowerElement.h:103
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
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:111
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:364
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:377
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,...
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:104
#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,...
Definition: Reference.h:79
IteratorType pos_
Iterator to the current lower unitriangular matrix element.
Definition: UniLowerElement.h:151
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
UniLowerElement(IteratorType pos, bool diagonal)
Constructor for the UniLowerElement class.
Definition: UniLowerElement.h:191
#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,...
Definition: Hermitian.h:79
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerElement.h:152
Constraint on the data type.
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:351