UniUpperElement.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UNIUPPERELEMENT_H_
36 #define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UNIUPPERELEMENT_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
56 #include <blaze/util/Exception.h>
57 #include <blaze/util/Types.h>
58 
59 
60 namespace blaze {
61 
62 //=================================================================================================
63 //
64 // CLASS DEFINITION
65 //
66 //=================================================================================================
67 
68 //*************************************************************************************************
94 template< typename MT > // Type of the adapted matrix
96 {
97  private:
98  //**Type definitions****************************************************************************
99  typedef typename MT::ElementType ElementType;
100  typedef typename MT::Iterator IteratorType;
101  //**********************************************************************************************
102 
103  public:
104  //**Type definitions****************************************************************************
106  typedef size_t IndexType;
110  //**********************************************************************************************
111 
112  //**Constructor*********************************************************************************
115  inline UniUpperElement( IteratorType pos, bool diagonal );
117  //**********************************************************************************************
118 
119  //**Assignment operators************************************************************************
122  template< typename T > inline UniUpperElement& operator= ( const T& v );
123  template< typename T > inline UniUpperElement& operator+=( const T& v );
124  template< typename T > inline UniUpperElement& operator-=( const T& v );
125  template< typename T > inline UniUpperElement& operator*=( const T& v );
126  template< typename T > inline UniUpperElement& operator/=( const T& v );
128  //**********************************************************************************************
129 
130  //**Access operators****************************************************************************
133  inline Pointer operator->();
135  //**********************************************************************************************
136 
137  //**Utility functions***************************************************************************
140  inline Reference value() const;
141  inline IndexType index() const;
143  //**********************************************************************************************
144 
145  private:
146  //**Member variables****************************************************************************
147  IteratorType pos_;
148  bool diagonal_;
149  //**********************************************************************************************
150 
151  //**Compile time checks*************************************************************************
165  //**********************************************************************************************
166 };
167 //*************************************************************************************************
168 
169 
170 
171 
172 //=================================================================================================
173 //
174 // CONSTRUCTORS
175 //
176 //=================================================================================================
177 
178 //*************************************************************************************************
184 template< typename MT > // Type of the adapted matrix
186  : pos_ ( pos ) // Iterator to the current upper unitriangular matrix element
187  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
188 {}
189 //*************************************************************************************************
190 
191 
192 
193 
194 //=================================================================================================
195 //
196 // OPERATORS
197 //
198 //=================================================================================================
199 
200 //*************************************************************************************************
207 template< typename MT > // Type of the adapted matrix
208 template< typename T > // Type of the right-hand side value
210 {
211  if( diagonal_ ) {
212  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
213  }
214 
215  *pos_ = v;
216 
217  return *this;
218 }
219 //*************************************************************************************************
220 
221 
222 //*************************************************************************************************
229 template< typename MT > // Type of the adapted matrix
230 template< typename T > // Type of the right-hand side value
232 {
233  if( diagonal_ ) {
234  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
235  }
236 
237  *pos_ += v;
238 
239  return *this;
240 }
241 //*************************************************************************************************
242 
243 
244 //*************************************************************************************************
251 template< typename MT > // Type of the adapted matrix
252 template< typename T > // Type of the right-hand side value
254 {
255  if( diagonal_ ) {
256  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
257  }
258 
259  *pos_ -= v;
260 
261  return *this;
262 }
263 //*************************************************************************************************
264 
265 
266 //*************************************************************************************************
273 template< typename MT > // Type of the adapted matrix
274 template< typename T > // Type of the right-hand side value
276 {
277  if( diagonal_ ) {
278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
279  }
280 
281  *pos_ *= v;
282 
283  return *this;
284 }
285 //*************************************************************************************************
286 
287 
288 //*************************************************************************************************
295 template< typename MT > // Type of the adapted matrix
296 template< typename T > // Type of the right-hand side value
298 {
299  if( diagonal_ ) {
300  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
301  }
302 
303  *pos_ /= v;
304 
305  return *this;
306 }
307 //*************************************************************************************************
308 
309 
310 
311 
312 //=================================================================================================
313 //
314 // ACCESS OPERATORS
315 //
316 //=================================================================================================
317 
318 //*************************************************************************************************
323 template< typename MT > // Type of the adapted matrix
325 {
326  return this;
327 }
328 //*************************************************************************************************
329 
330 
331 
332 
333 //=================================================================================================
334 //
335 // UTILITY FUNCTIONS
336 //
337 //=================================================================================================
338 
339 //*************************************************************************************************
344 template< typename MT > // Type of the adapted matrix
346 {
347  return Reference( pos_->value(), diagonal_ );
348 }
349 //*************************************************************************************************
350 
351 
352 //*************************************************************************************************
357 template< typename MT > // Type of the adapted matrix
359 {
360  return pos_->index();
361 }
362 //*************************************************************************************************
363 
364 } // namespace blaze
365 
366 #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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Constraint on the data type.
Header file for basic type definitions.
IteratorType pos_
Iterator to the current upper unitriangular matrix element.
Definition: UniUpperElement.h:147
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:116
const UniUpperValue< MT > ConstReference
Reference-to-const return type.
Definition: UniUpperElement.h:108
Constraint on the data type.
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniUpperElement.h:148
UniUpperValue< MT > Reference
Reference return type.
Definition: UniUpperElement.h:107
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
MT::ElementType ElementType
Type of the represented matrix element.
Definition: UniUpperElement.h:99
#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:116
Constraint on the data type.
size_t IndexType
The index type of the value-index-pair.
Definition: UniUpperElement.h:106
Header file for the SparseElement base class.
Reference value() const
Access to the current value of the uniupper element.
Definition: UniUpperElement.h:345
#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:118
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
IndexType index() const
Access to the current index of the uniupper element.
Definition: UniUpperElement.h:358
Header file for the UniUpperValue 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:116
Constraint on the data type.
Constraint on the data type.
UniUpperElement * Pointer
Pointer return type.
Definition: UniUpperElement.h:109
Representation of an element within a sparse upper unitriangular matrix.The UniUpperElement class rep...
Definition: UniUpperElement.h:95
#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:79
#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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
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
UniUpperValue< MT > ValueType
The value type of the value-index-pair.
Definition: UniUpperElement.h:105
MT::Iterator IteratorType
Type of the underlying sparse matrix iterators.
Definition: UniUpperElement.h:100
Pointer operator->()
Direct access to the uniupper element.
Definition: UniUpperElement.h:324
#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:118
UniUpperElement(IteratorType pos, bool diagonal)
Constructor for the UniUpperElement class.
Definition: UniUpperElement.h:185
Representation of a value within a sparse upper unitriangular matrix.The UniUpperValue class represen...
Definition: UniUpperValue.h:107
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for exception macros.
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:79