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 {
98  private:
99  //**Type definitions****************************************************************************
102  //**********************************************************************************************
103 
104  public:
105  //**Type definitions****************************************************************************
107  typedef size_t IndexType;
111  //**********************************************************************************************
112 
113  //**Constructor*********************************************************************************
116  inline UniLowerElement( IteratorType pos, bool diagonal );
118  //**********************************************************************************************
119 
120  //**Assignment operators************************************************************************
123  template< typename T > inline UniLowerElement& operator= ( const T& v );
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 );
129  //**********************************************************************************************
130 
131  //**Access operators****************************************************************************
134  inline Pointer operator->() noexcept;
136  //**********************************************************************************************
137 
138  //**Utility functions***************************************************************************
141  inline Reference value() const;
142  inline IndexType index() const;
144  //**********************************************************************************************
145 
146  private:
147  //**Member variables****************************************************************************
148  IteratorType pos_;
149  bool diagonal_;
150  //**********************************************************************************************
151 
152  //**Compile time checks*************************************************************************
166  //**********************************************************************************************
167 };
168 //*************************************************************************************************
169 
170 
171 
172 
173 //=================================================================================================
174 //
175 // CONSTRUCTORS
176 //
177 //=================================================================================================
178 
179 //*************************************************************************************************
185 template< typename MT > // Type of the adapted matrix
186 inline UniLowerElement<MT>::UniLowerElement( IteratorType pos, bool diagonal )
187  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
188  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
189 {}
190 //*************************************************************************************************
191 
192 
193 
194 
195 //=================================================================================================
196 //
197 // OPERATORS
198 //
199 //=================================================================================================
200 
201 //*************************************************************************************************
208 template< typename MT > // Type of the adapted matrix
209 template< typename T > // Type of the right-hand side value
211 {
212  if( diagonal_ ) {
213  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
214  }
215 
216  *pos_ = v;
217 
218  return *this;
219 }
220 //*************************************************************************************************
221 
222 
223 //*************************************************************************************************
230 template< typename MT > // Type of the adapted matrix
231 template< typename T > // Type of the right-hand side value
233 {
234  if( diagonal_ ) {
235  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
236  }
237 
238  *pos_ += v;
239 
240  return *this;
241 }
242 //*************************************************************************************************
243 
244 
245 //*************************************************************************************************
252 template< typename MT > // Type of the adapted matrix
253 template< typename T > // Type of the right-hand side value
255 {
256  if( diagonal_ ) {
257  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
258  }
259 
260  *pos_ -= v;
261 
262  return *this;
263 }
264 //*************************************************************************************************
265 
266 
267 //*************************************************************************************************
274 template< typename MT > // Type of the adapted matrix
275 template< typename T > // Type of the right-hand side value
277 {
278  if( diagonal_ ) {
279  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
280  }
281 
282  *pos_ *= v;
283 
284  return *this;
285 }
286 //*************************************************************************************************
287 
288 
289 //*************************************************************************************************
296 template< typename MT > // Type of the adapted matrix
297 template< typename T > // Type of the right-hand side value
299 {
300  if( diagonal_ ) {
301  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
302  }
303 
304  *pos_ /= v;
305 
306  return *this;
307 }
308 //*************************************************************************************************
309 
310 
311 
312 
313 //=================================================================================================
314 //
315 // ACCESS OPERATORS
316 //
317 //=================================================================================================
318 
319 //*************************************************************************************************
324 template< typename MT > // Type of the adapted matrix
326 {
327  return this;
328 }
329 //*************************************************************************************************
330 
331 
332 
333 
334 //=================================================================================================
335 //
336 // UTILITY FUNCTIONS
337 //
338 //=================================================================================================
339 
340 //*************************************************************************************************
345 template< typename MT > // Type of the adapted matrix
347 {
348  return Reference( pos_->value(), diagonal_ );
349 }
350 //*************************************************************************************************
351 
352 
353 //*************************************************************************************************
358 template< typename MT > // Type of the adapted matrix
360 {
361  return pos_->index();
362 }
363 //*************************************************************************************************
364 
365 } // namespace blaze
366 
367 #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:325
Constraint on the data type.
size_t IndexType
The index type of the value-index-pair.
Definition: UniLowerElement.h:107
#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.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Iterator_< MT > IteratorType
Type of the underlying sparse matrix iterators.
Definition: UniLowerElement.h:101
#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
UniLowerElement * Pointer
Pointer return type.
Definition: UniLowerElement.h:110
Reference value() const
Access to the current value of the unilower element.
Definition: UniLowerElement.h:346
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Constraint on the data type.
Header file for the SparseElement base class.
UniLowerValue< MT > Reference
Reference return type.
Definition: UniLowerElement.h:108
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
IndexType index() const
Access to the current index of the unilower element.
Definition: UniLowerElement.h:359
Header file for the UniLowerValue class.
const UniLowerValue< MT > ConstReference
Reference-to-const return type.
Definition: UniLowerElement.h:109
#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
Constraint on the data type.
Constraint on the data type.
#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:148
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
typename T::Iterator Iterator_
Alias declaration for nested Iterator type definitions.The Iterator_ alias declaration provides a con...
Definition: Aliases.h:183
UniLowerElement(IteratorType pos, bool diagonal)
Constructor for the UniLowerElement class.
Definition: UniLowerElement.h:186
UniLowerValue< MT > ValueType
The value type of the value-index-pair.
Definition: UniLowerElement.h:106
#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:149
ElementType_< MT > ElementType
Type of the represented matrix element.
Definition: UniLowerElement.h:100
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