Blaze 3.9
UniUpperProxy.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UPPERPROXY_H_
36#define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UPPERPROXY_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
68#include <blaze/util/mpl/If.h>
69#include <blaze/util/Types.h>
71
72
73namespace blaze {
74
75//=================================================================================================
76//
77// CLASS DEFINITION
78//
79//=================================================================================================
80
81//*************************************************************************************************
102template< typename MT > // Type of the adapted matrix
104 : public Proxy< UniUpperProxy<MT> >
105{
106 private:
107 //**Type definitions****************************************************************************
109 using ReferenceType = typename MT::Reference;
110 //**********************************************************************************************
111
112 //**struct BuiltinType**************************************************************************
116 template< typename T >
117 struct BuiltinType { using Type = INVALID_TYPE; };
119 //**********************************************************************************************
120
121 //**struct ComplexType**************************************************************************
125 template< typename T >
126 struct ComplexType { using Type = typename T::value_type; };
128 //**********************************************************************************************
129
130 public:
131 //**Type definitions****************************************************************************
134
137 , ComplexType<RepresentedType>
138 , BuiltinType<RepresentedType> >::Type;
139
141 //**********************************************************************************************
142
143 //**Constructors********************************************************************************
146 inline UniUpperProxy( MT& matrix, size_t row, size_t column );
147
148 UniUpperProxy( const UniUpperProxy& ) = default;
150 //**********************************************************************************************
151
152 //**Destructor**********************************************************************************
155 ~UniUpperProxy() = default;
157 //**********************************************************************************************
158
159 //**Assignment operators************************************************************************
162 inline const UniUpperProxy& operator= ( const UniUpperProxy& uup ) const;
163 template< typename T > inline const UniUpperProxy& operator= ( const T& value ) const;
164 template< typename T > inline const UniUpperProxy& operator+=( const T& value ) const;
165 template< typename T > inline const UniUpperProxy& operator-=( const T& value ) const;
166 template< typename T > inline const UniUpperProxy& operator*=( const T& value ) const;
167 template< typename T > inline const UniUpperProxy& operator/=( const T& value ) const;
168 template< typename T > inline const UniUpperProxy& operator%=( const T& value ) const;
170 //**********************************************************************************************
171
172 //**Access operators****************************************************************************
175 inline const UniUpperProxy* operator->() const noexcept;
177 //**********************************************************************************************
178
179 //**Utility functions***************************************************************************
182 inline void invert() const;
183
184 inline RepresentedType get() const noexcept;
185 inline bool isRestricted() const noexcept;
187 //**********************************************************************************************
188
189 //**Conversion operator*************************************************************************
192 inline operator RepresentedType() const noexcept;
194 //**********************************************************************************************
195
196 //**Complex data access functions***************************************************************
199 inline ValueType real() const;
200 inline void real( ValueType value ) const;
201 inline ValueType imag() const;
202 inline void imag( ValueType value ) const;
204 //**********************************************************************************************
205
206 private:
207 //**Member variables****************************************************************************
211 size_t row_;
212 size_t column_;
214 //**********************************************************************************************
215
216 //**Compile time checks*************************************************************************
232 //**********************************************************************************************
233
234 //**********************************************************************************************
245 friend inline void reset( const UniUpperProxy& proxy )
246 {
247 using blaze::reset;
248
249 if( proxy.row_ < proxy.column_ ) {
250 reset( proxy.value_ );
251 }
252 }
254 //**********************************************************************************************
255
256 //**********************************************************************************************
267 friend inline void clear( const UniUpperProxy& proxy )
268 {
269 using blaze::clear;
270
271 if( proxy.row_ < proxy.column_ ) {
272 clear( proxy.value_ );
273 }
274 }
276 //**********************************************************************************************
277};
278//*************************************************************************************************
279
280
281
282
283//=================================================================================================
284//
285// CONSTRUCTORS
286//
287//=================================================================================================
288
289//*************************************************************************************************
296template< typename MT > // Type of the adapted matrix
297inline UniUpperProxy<MT>::UniUpperProxy( MT& matrix, size_t row, size_t column )
298 : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
299 , row_ ( row ) // Row index of the accessed matrix element
300 , column_( column ) // Column index of the accessed matrix element
301{}
302//*************************************************************************************************
303
304
305
306
307//=================================================================================================
308//
309// OPERATORS
310//
311//=================================================================================================
312
313//*************************************************************************************************
323template< typename MT > // Type of the adapted matrix
325{
326 if( isRestricted() ) {
327 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
328 }
329
330 value_ = uup.value_;
331
332 return *this;
333}
334//*************************************************************************************************
335
336
337//*************************************************************************************************
347template< typename MT > // Type of the adapted matrix
348template< typename T > // Type of the right-hand side value
349inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator=( const T& value ) const
350{
351 if( isRestricted() ) {
352 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
353 }
354
355 value_ = value;
356
357 return *this;
358}
359//*************************************************************************************************
360
361
362//*************************************************************************************************
372template< typename MT > // Type of the adapted matrix
373template< typename T > // Type of the right-hand side value
374inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator+=( const T& value ) const
375{
376 if( isRestricted() ) {
377 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
378 }
379
380 value_ += value;
381
382 return *this;
383}
384//*************************************************************************************************
385
386
387//*************************************************************************************************
397template< typename MT > // Type of the adapted matrix
398template< typename T > // Type of the right-hand side value
399inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator-=( const T& value ) const
400{
401 if( isRestricted() ) {
402 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
403 }
404
405 value_ -= value;
406
407 return *this;
408}
409//*************************************************************************************************
410
411
412//*************************************************************************************************
422template< typename MT > // Type of the adapted matrix
423template< typename T > // Type of the right-hand side value
424inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator*=( const T& value ) const
425{
426 if( isRestricted() ) {
427 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
428 }
429
430 value_ *= value;
431
432 return *this;
433}
434//*************************************************************************************************
435
436
437//*************************************************************************************************
447template< typename MT > // Type of the adapted matrix
448template< typename T > // Type of the right-hand side value
449inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator/=( const T& value ) const
450{
451 if( isRestricted() ) {
452 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
453 }
454
455 value_ /= value;
456
457 return *this;
458}
459//*************************************************************************************************
460
461
462//*************************************************************************************************
472template< typename MT > // Type of the adapted matrix
473template< typename T > // Type of the right-hand side value
474inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator%=( const T& value ) const
475{
476 if( isRestricted() ) {
477 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
478 }
479
480 value_ %= value;
481
482 return *this;
483}
484//*************************************************************************************************
485
486
487
488
489//=================================================================================================
490//
491// ACCESS OPERATORS
492//
493//=================================================================================================
494
495//*************************************************************************************************
500template< typename MT > // Type of the adapted matrix
502{
503 return this;
504}
505//*************************************************************************************************
506
507
508
509
510//=================================================================================================
511//
512// UTILITY FUNCTIONS
513//
514//=================================================================================================
515
516//*************************************************************************************************
524template< typename MT > // Type of the adapted matrix
525inline void UniUpperProxy<MT>::invert() const
526{
527 using blaze::invert;
528
529 if( column_ < row_ ) {
530 BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of lower matrix element" );
531 }
532
533 if( row_ < column_ )
534 invert( value_ );
535}
536//*************************************************************************************************
537
538
539//*************************************************************************************************
544template< typename MT > // Type of the adapted matrix
546{
547 return value_;
548}
549//*************************************************************************************************
550
551
552//*************************************************************************************************
557template< typename MT > // Type of the adapted matrix
558inline bool UniUpperProxy<MT>::isRestricted() const noexcept
559{
560 return column_ <= row_;
561}
562//*************************************************************************************************
563
564
565
566
567//=================================================================================================
568//
569// CONVERSION OPERATOR
570//
571//=================================================================================================
572
573//*************************************************************************************************
578template< typename MT > // Type of the adapted matrix
580{
581 return get();
582}
583//*************************************************************************************************
584
585
586
587
588//=================================================================================================
589//
590// COMPLEX DATA ACCESS FUNCTIONS
591//
592//=================================================================================================
593
594//*************************************************************************************************
602template< typename MT > // Type of the adapted matrix
604{
605 return value_.real();
606}
607//*************************************************************************************************
608
609
610//*************************************************************************************************
621template< typename MT > // Type of the adapted matrix
622inline void UniUpperProxy<MT>::real( ValueType value ) const
623{
624 if( isRestricted() ) {
625 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or lower matrix element" );
626 }
627
628 value_.real( value );
629}
630//*************************************************************************************************
631
632
633//*************************************************************************************************
641template< typename MT > // Type of the adapted matrix
643{
644 return value_.imag();
645}
646//*************************************************************************************************
647
648
649//*************************************************************************************************
660template< typename MT > // Type of the adapted matrix
661inline void UniUpperProxy<MT>::imag( ValueType value ) const
662{
663 if( isRestricted() ) {
664 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or lower matrix element" );
665 }
666
667 value_.imag( value );
668}
669//*************************************************************************************************
670
671
672
673
674//=================================================================================================
675//
676// GLOBAL FUNCTIONS
677//
678//=================================================================================================
679
680//*************************************************************************************************
683template< typename MT >
684void invert( const UniUpperProxy<MT>& proxy );
686//*************************************************************************************************
687
688
689//*************************************************************************************************
696template< typename MT >
697inline void invert( const UniUpperProxy<MT>& proxy )
698{
699 proxy.invert();
700}
701//*************************************************************************************************
702
703} // namespace blaze
704
705#endif
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Constraint on the data type.
Constraint on the data type.
Header file for the If class template.
Utility type for generic codes.
Header file for the invert shim.
Header file for the IsComplex type trait.
Header file for the isDefault shim.
Header file for the isOne shim.
Header file for the isReal shim.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Proxy base class.
Definition: Proxy.h:169
Access proxy for upper unitriangular matrices.
Definition: UniUpperProxy.h:105
ValueType value_type
Value type of the represented complex element.
Definition: UniUpperProxy.h:140
void invert() const
In-place inversion of the represented element.
Definition: UniUpperProxy.h:525
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: UniUpperProxy.h:558
size_t column_
Column index of the accessed matrix element.
Definition: UniUpperProxy.h:212
const UniUpperProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: UniUpperProxy.h:501
typename MT::Reference ReferenceType
Reference type of the underlying matrix type.
Definition: UniUpperProxy.h:109
ReferenceType value_
Reference to the accessed matrix element.
Definition: UniUpperProxy.h:210
size_t row_
Row index of the accessed matrix element.
Definition: UniUpperProxy.h:211
const UniUpperProxy & operator=(const UniUpperProxy &uup) const
Copy assignment operator for UniUpperProxy.
Definition: UniUpperProxy.h:324
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniUpperProxy.h:642
typename If_t< IsComplex_v< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type ValueType
Value type of the represented complex element.
Definition: UniUpperProxy.h:138
RepresentedType get() const noexcept
Returning the value of the accessed matrix element.
Definition: UniUpperProxy.h:545
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniUpperProxy.h:133
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniUpperProxy.h:603
UniUpperProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a UniUpperProxy.
Definition: UniUpperProxy.h:297
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Matrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.
Definition: View.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
constexpr Type & get(StaticVector< Type, N, TF, AF, PF, Tag > &v) noexcept
Tuple-like index-based access the contents of a static vector.
Definition: StaticVector.h:3052
void invert(const UniUpperProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: UniUpperProxy.h:697
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#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 Proxy class.
Header file for the clear shim.
Header file for the isZero shim.
Header file for the reset shim.
Header file for basic type definitions.