UniLowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_UNILOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_UNILOWERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <ostream>
44 #include <stdexcept>
50 #include <blaze/math/proxy/Proxy.h>
51 #include <blaze/math/shims/Clear.h>
53 #include <blaze/math/shims/Reset.h>
61 #include <blaze/util/Types.h>
62 
63 
64 namespace blaze {
65 
66 //=================================================================================================
67 //
68 // CLASS DEFINITION
69 //
70 //=================================================================================================
71 
72 //*************************************************************************************************
93 template< typename MT > // Type of the adapted matrix
94 class UniLowerProxy : public Proxy< UniLowerProxy<MT>, typename MT::ElementType >
95 {
96  private:
97  //**Type definitions****************************************************************************
100  //**********************************************************************************************
101 
102  public:
103  //**Type definitions****************************************************************************
106 
109  //**********************************************************************************************
110 
111  //**Constructors********************************************************************************
114  explicit inline UniLowerProxy( MT& matrix, size_t row, size_t column );
115  inline UniLowerProxy( const UniLowerProxy& ulp );
117  //**********************************************************************************************
118 
119  //**Destructor**********************************************************************************
120  // No explicitly declared destructor.
121  //**********************************************************************************************
122 
123  //**Assignment operators************************************************************************
126  inline const UniLowerProxy& operator= ( const UniLowerProxy& ulp ) const;
127  template< typename T > inline const UniLowerProxy& operator= ( const T& value ) const;
128  template< typename T > inline const UniLowerProxy& operator+=( const T& value ) const;
129  template< typename T > inline const UniLowerProxy& operator-=( const T& value ) const;
130  template< typename T > inline const UniLowerProxy& operator*=( const T& value ) const;
131  template< typename T > inline const UniLowerProxy& operator/=( const T& value ) const;
133  //**********************************************************************************************
134 
135  //**Utility functions***************************************************************************
138  inline size_t rowIndex() const;
139  inline size_t columnIndex() const;
140  inline RawReference get() const;
141  inline bool isRestricted() const;
143  //**********************************************************************************************
144 
145  //**Conversion operator*************************************************************************
148  inline operator RawReference() const;
150  //**********************************************************************************************
151 
152  private:
153  //**Member variables****************************************************************************
156  ReferenceType value_;
157  size_t row_;
158  size_t column_;
159 
160  //**********************************************************************************************
161 
162  //**Compile time checks*************************************************************************
173  BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE( RepresentedType );
175  //**********************************************************************************************
176 };
177 //*************************************************************************************************
178 
179 
180 
181 
182 //=================================================================================================
183 //
184 // CONSTRUCTORS
185 //
186 //=================================================================================================
187 
188 //*************************************************************************************************
195 template< typename MT > // Type of the adapted matrix
196 inline UniLowerProxy<MT>::UniLowerProxy( MT& matrix, size_t row, size_t column )
197  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
198  , row_ ( row ) // Row index of the accessed matrix element
199  , column_( column ) // Column index of the accessed matrix element
200 {}
201 //*************************************************************************************************
202 
203 
204 //*************************************************************************************************
209 template< typename MT > // Type of the adapted matrix
211  : value_ ( ulp.value_ ) // Reference to the accessed matrix element
212  , row_ ( ulp.row_ ) // Row index of the accessed matrix element
213  , column_( ulp.column_ ) // Column index of the accessed matrix element
214 {}
215 //*************************************************************************************************
216 
217 
218 
219 
220 //=================================================================================================
221 //
222 // OPERATORS
223 //
224 //=================================================================================================
225 
226 //*************************************************************************************************
232 template< typename MT > // Type of the adapted matrix
234 {
235  value_ = ulp.value_;
236 
237  return *this;
238 }
239 //*************************************************************************************************
240 
241 
242 //*************************************************************************************************
252 template< typename MT > // Type of the adapted matrix
253 template< typename T > // Type of the right-hand side value
254 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator=( const T& value ) const
255 {
256  if( isRestricted() )
257  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
258 
259  value_ = value;
260 
261  return *this;
262 }
263 //*************************************************************************************************
264 
265 
266 //*************************************************************************************************
276 template< typename MT > // Type of the adapted matrix
277 template< typename T > // Type of the right-hand side value
278 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator+=( const T& value ) const
279 {
280  if( isRestricted() )
281  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
282 
283  value_ += value;
284 
285  return *this;
286 }
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
300 template< typename MT > // Type of the adapted matrix
301 template< typename T > // Type of the right-hand side value
302 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator-=( const T& value ) const
303 {
304  if( isRestricted() )
305  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
306 
307  value_ -= value;
308 
309  return *this;
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
324 template< typename MT > // Type of the adapted matrix
325 template< typename T > // Type of the right-hand side value
326 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator*=( const T& value ) const
327 {
328  if( isRestricted() )
329  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
330 
331  value_ *= value;
332 
333  return *this;
334 }
335 //*************************************************************************************************
336 
337 
338 //*************************************************************************************************
348 template< typename MT > // Type of the adapted matrix
349 template< typename T > // Type of the right-hand side value
350 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator/=( const T& value ) const
351 {
352  if( isRestricted() )
353  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
354 
355  value_ /= value;
356 
357  return *this;
358 }
359 //*************************************************************************************************
360 
361 
362 
363 
364 //=================================================================================================
365 //
366 // UTILITY FUNCTIONS
367 //
368 //=================================================================================================
369 
370 //*************************************************************************************************
375 template< typename MT > // Type of the adapted matrix
376 inline size_t UniLowerProxy<MT>::rowIndex() const
377 {
378  return row_;
379 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
388 template< typename MT > // Type of the adapted matrix
389 inline size_t UniLowerProxy<MT>::columnIndex() const
390 {
391  return column_;
392 }
393 //*************************************************************************************************
394 
395 
396 //*************************************************************************************************
401 template< typename MT > // Type of the adapted matrix
403 {
404  return value_;
405 }
406 //*************************************************************************************************
407 
408 
409 //*************************************************************************************************
414 template< typename MT > // Type of the adapted matrix
416 {
417  return row_ <= column_;
418 }
419 //*************************************************************************************************
420 
421 
422 
423 
424 //=================================================================================================
425 //
426 // CONVERSION OPERATOR
427 //
428 //=================================================================================================
429 
430 //*************************************************************************************************
435 template< typename MT > // Type of the adapted matrix
437 {
438  return get();
439 }
440 //*************************************************************************************************
441 
442 
443 
444 
445 //=================================================================================================
446 //
447 // GLOBAL OPERATORS
448 //
449 //=================================================================================================
450 
451 //*************************************************************************************************
454 template< typename MT1, typename MT2 >
455 inline bool operator==( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
456 
457 template< typename MT, typename T >
458 inline bool operator==( const UniLowerProxy<MT>& lhs, const T& rhs );
459 
460 template< typename T, typename MT >
461 inline bool operator==( const T& lhs, const UniLowerProxy<MT>& rhs );
462 
463 template< typename MT1, typename MT2 >
464 inline bool operator!=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
465 
466 template< typename MT, typename T >
467 inline bool operator!=( const UniLowerProxy<MT>& lhs, const T& rhs );
468 
469 template< typename T, typename MT >
470 inline bool operator!=( const T& lhs, const UniLowerProxy<MT>& rhs );
471 
472 template< typename MT1, typename MT2 >
473 inline bool operator<( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
474 
475 template< typename MT, typename T >
476 inline bool operator<( const UniLowerProxy<MT>& lhs, const T& rhs );
477 
478 template< typename T, typename MT >
479 inline bool operator<( const T& lhs, const UniLowerProxy<MT>& rhs );
480 
481 template< typename MT1, typename MT2 >
482 inline bool operator>( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
483 
484 template< typename MT, typename T >
485 inline bool operator>( const UniLowerProxy<MT>& lhs, const T& rhs );
486 
487 template< typename T, typename MT >
488 inline bool operator>( const T& lhs, const UniLowerProxy<MT>& rhs );
489 
490 template< typename MT1, typename MT2 >
491 inline bool operator<=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
492 
493 template< typename MT, typename T >
494 inline bool operator<=( const UniLowerProxy<MT>& lhs, const T& rhs );
495 
496 template< typename T, typename MT >
497 inline bool operator<=( const T& lhs, const UniLowerProxy<MT>& rhs );
498 
499 template< typename MT1, typename MT2 >
500 inline bool operator>=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs );
501 
502 template< typename MT, typename T >
503 inline bool operator>=( const UniLowerProxy<MT>& lhs, const T& rhs );
504 
505 template< typename T, typename MT >
506 inline bool operator>=( const T& lhs, const UniLowerProxy<MT>& rhs );
507 
508 template< typename MT >
509 inline std::ostream& operator<<( std::ostream& os, const UniLowerProxy<MT>& proxy );
511 //*************************************************************************************************
512 
513 
514 //*************************************************************************************************
522 template< typename MT1, typename MT2 >
523 inline bool operator==( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
524 {
525  return ( lhs.get() == rhs.get() );
526 }
527 //*************************************************************************************************
528 
529 
530 //*************************************************************************************************
538 template< typename MT, typename T >
539 inline bool operator==( const UniLowerProxy<MT>& lhs, const T& rhs )
540 {
541  return ( lhs.get() == rhs );
542 }
543 //*************************************************************************************************
544 
545 
546 //*************************************************************************************************
554 template< typename T, typename MT >
555 inline bool operator==( const T& lhs, const UniLowerProxy<MT>& rhs )
556 {
557  return ( lhs == rhs.get() );
558 }
559 //*************************************************************************************************
560 
561 
562 //*************************************************************************************************
570 template< typename MT1, typename MT2 >
571 inline bool operator!=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
572 {
573  return ( lhs.get() != rhs.get() );
574 }
575 //*************************************************************************************************
576 
577 
578 //*************************************************************************************************
586 template< typename MT, typename T >
587 inline bool operator!=( const UniLowerProxy<MT>& lhs, const T& rhs )
588 {
589  return ( lhs.get() != rhs );
590 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
602 template< typename T, typename MT >
603 inline bool operator!=( const T& lhs, const UniLowerProxy<MT>& rhs )
604 {
605  return ( lhs != rhs.get() );
606 }
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
618 template< typename MT1, typename MT2 >
619 inline bool operator<( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
620 {
621  return ( lhs.get() < rhs.get() );
622 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
634 template< typename MT, typename T >
635 inline bool operator<( const UniLowerProxy<MT>& lhs, const T& rhs )
636 {
637  return ( lhs.get() < rhs );
638 }
639 //*************************************************************************************************
640 
641 
642 //*************************************************************************************************
650 template< typename T, typename MT >
651 inline bool operator<( const T& lhs, const UniLowerProxy<MT>& rhs )
652 {
653  return ( lhs < rhs.get() );
654 }
655 //*************************************************************************************************
656 
657 
658 //*************************************************************************************************
666 template< typename MT1, typename MT2 >
667 inline bool operator>( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
668 {
669  return ( lhs.get() > rhs.get() );
670 }
671 //*************************************************************************************************
672 
673 
674 //*************************************************************************************************
682 template< typename MT, typename T >
683 inline bool operator>( const UniLowerProxy<MT>& lhs, const T& rhs )
684 {
685  return ( lhs.get() > rhs );
686 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
698 template< typename T, typename MT >
699 inline bool operator>( const T& lhs, const UniLowerProxy<MT>& rhs )
700 {
701  return ( lhs > rhs.get() );
702 }
703 //*************************************************************************************************
704 
705 
706 //*************************************************************************************************
714 template< typename MT1, typename MT2 >
715 inline bool operator<=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
716 {
717  return ( lhs.get() <= rhs.get() );
718 }
719 //*************************************************************************************************
720 
721 
722 //*************************************************************************************************
730 template< typename MT, typename T >
731 inline bool operator<=( const UniLowerProxy<MT>& lhs, const T& rhs )
732 {
733  return ( lhs.get() <= rhs );
734 }
735 //*************************************************************************************************
736 
737 
738 //*************************************************************************************************
746 template< typename T, typename MT >
747 inline bool operator<=( const T& lhs, const UniLowerProxy<MT>& rhs )
748 {
749  return ( lhs <= rhs.get() );
750 }
751 //*************************************************************************************************
752 
753 
754 //*************************************************************************************************
762 template< typename MT1, typename MT2 >
763 inline bool operator>=( const UniLowerProxy<MT1>& lhs, const UniLowerProxy<MT2>& rhs )
764 {
765  return ( lhs.get() >= rhs.get() );
766 }
767 //*************************************************************************************************
768 
769 
770 //*************************************************************************************************
778 template< typename MT, typename T >
779 inline bool operator>=( const UniLowerProxy<MT>& lhs, const T& rhs )
780 {
781  return ( lhs.get() >= rhs );
782 }
783 //*************************************************************************************************
784 
785 
786 //*************************************************************************************************
794 template< typename T, typename MT >
795 inline bool operator>=( const T& lhs, const UniLowerProxy<MT>& rhs )
796 {
797  return ( lhs >= rhs.get() );
798 }
799 //*************************************************************************************************
800 
801 
802 //*************************************************************************************************
810 template< typename MT >
811 inline std::ostream& operator<<( std::ostream& os, const UniLowerProxy<MT>& proxy )
812 {
813  return os << proxy.get();
814 }
815 //*************************************************************************************************
816 
817 
818 
819 
820 //=================================================================================================
821 //
822 // GLOBAL FUNCTIONS
823 //
824 //=================================================================================================
825 
826 //*************************************************************************************************
829 template< typename MT >
830 inline void reset( const UniLowerProxy<MT>& proxy );
831 
832 template< typename MT >
833 inline void clear( const UniLowerProxy<MT>& proxy );
834 
835 template< typename MT >
836 inline bool isDefault( const UniLowerProxy<MT>& proxy );
838 //*************************************************************************************************
839 
840 
841 //*************************************************************************************************
851 template< typename MT >
852 inline void reset( const UniLowerProxy<MT>& proxy )
853 {
854  using blaze::reset;
855 
856  if( proxy.rowIndex() != proxy.columnIndex() )
857  reset( proxy.get() );
858 }
859 //*************************************************************************************************
860 
861 
862 //*************************************************************************************************
872 template< typename MT >
873 inline void clear( const UniLowerProxy<MT>& proxy )
874 {
875  using blaze::clear;
876 
877  if( proxy.rowIndex() != proxy.columnIndex() )
878  clear( proxy.get() );
879 }
880 //*************************************************************************************************
881 
882 
883 //*************************************************************************************************
893 template< typename MT >
894 inline bool isDefault( const UniLowerProxy<MT>& proxy )
895 {
896  using blaze::isDefault;
897 
898  return isDefault( proxy.get() );
899 }
900 //*************************************************************************************************
901 
902 } // namespace blaze
903 
904 #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
Header file for the AddConst type trait.
Constraint on the data type.
bool isRestricted() const
Returns whether the proxy represents a restricted matrix element..
Definition: UniLowerProxy.h:415
Header file for basic type definitions.
Addition of a top level 'const' qualifier.The AddConst type trait adds a top level 'const' qualifier ...
Definition: AddConst.h:69
Proxy base class.The Proxy class is a base class for all proxy classes within the Blaze library that ...
Definition: Proxy.h:99
ReferenceType value_
Reference to the accessed matrix element.
Definition: UniLowerProxy.h:156
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
RawReference get() const
Returning the value of the accessed matrix element.
Definition: UniLowerProxy.h:402
AddConst< typename MT::Reference >::Type ReferenceType
Reference type of the underlying matrix type.
Definition: UniLowerProxy.h:99
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
const UniLowerProxy & operator=(const UniLowerProxy &ulp) const
Copy assignment operator for UniLowerProxy.
Definition: UniLowerProxy.h:233
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#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
Constraint on the data type.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
Addition of a top level reference.In case the given type T is not a reference type, the AddReference type trait adds a top level reference to the given type T. Else the resulting type Type is T.
Definition: AddReference.h:69
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
MT::ElementType RepresentedType
Type of the represented matrix element.
Definition: UniLowerProxy.h:105
#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.
Constraint on the data type.
#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:2505
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
#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
Header file for the Proxy class.
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:79
Header file for the reset shim.
#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
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
size_t row_
Row index of the accessed matrix element.
Definition: UniLowerProxy.h:157
UniLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an UniLowerProxy.
Definition: UniLowerProxy.h:196
size_t column_
Column index of the accessed matrix element.
Definition: UniLowerProxy.h:158
#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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
Header file for the AddReference type trait.
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional matrix type...
Definition: Matrix.h:79
Access proxy for lower unitriangular matrices.The UniLowerProxy provides controlled access to the ele...
Definition: UniLowerProxy.h:94
AddReference< ReferenceType >::Type RawReference
Reference to the represented element.
Definition: UniLowerProxy.h:108
size_t rowIndex() const
Returns the row index of the represented matrix element.
Definition: UniLowerProxy.h:376
size_t columnIndex() const
Returns the column index of the represented matrix element.
Definition: UniLowerProxy.h:389