StrictlyLowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_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>
60 #include <blaze/util/Types.h>
61 
62 
63 namespace blaze {
64 
65 //=================================================================================================
66 //
67 // CLASS DEFINITION
68 //
69 //=================================================================================================
70 
71 //*************************************************************************************************
93 template< typename MT > // Type of the adapted matrix
94 class StrictlyLowerProxy : public Proxy< StrictlyLowerProxy<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 StrictlyLowerProxy( MT& matrix, size_t row, size_t column );
115  inline StrictlyLowerProxy( const StrictlyLowerProxy& ulp );
117  //**********************************************************************************************
118 
119  //**Destructor**********************************************************************************
120  // No explicitly declared destructor.
121  //**********************************************************************************************
122 
123  //**Assignment operators************************************************************************
126  inline const StrictlyLowerProxy& operator= ( const StrictlyLowerProxy& ulp ) const;
127  template< typename T > inline const StrictlyLowerProxy& operator= ( const T& value ) const;
128  template< typename T > inline const StrictlyLowerProxy& operator+=( const T& value ) const;
129  template< typename T > inline const StrictlyLowerProxy& operator-=( const T& value ) const;
130  template< typename T > inline const StrictlyLowerProxy& operator*=( const T& value ) const;
131  template< typename T > inline const StrictlyLowerProxy& operator/=( const T& value ) const;
133  //**********************************************************************************************
134 
135  //**Utility functions***************************************************************************
138  inline RawReference get() const;
139  inline bool isRestricted() const;
141  //**********************************************************************************************
142 
143  //**Conversion operator*************************************************************************
146  inline operator RawReference() const;
148  //**********************************************************************************************
149 
150  private:
151  //**Member variables****************************************************************************
154  ReferenceType value_;
155  const bool restricted_;
156 
160  //**********************************************************************************************
161 
162  //**Compile time checks*************************************************************************
174  //**********************************************************************************************
175 };
176 //*************************************************************************************************
177 
178 
179 
180 
181 //=================================================================================================
182 //
183 // CONSTRUCTORS
184 //
185 //=================================================================================================
186 
187 //*************************************************************************************************
194 template< typename MT > // Type of the adapted matrix
195 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
196  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
197  , restricted_( row <= column ) // Access flag for the accessed matrix element
198 {}
199 //*************************************************************************************************
200 
201 
202 //*************************************************************************************************
207 template< typename MT > // Type of the adapted matrix
209  : value_ ( slp.value_ ) // Reference to the accessed matrix element
210  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
211 {}
212 //*************************************************************************************************
213 
214 
215 
216 
217 //=================================================================================================
218 //
219 // OPERATORS
220 //
221 //=================================================================================================
222 
223 //*************************************************************************************************
229 template< typename MT > // Type of the adapted matrix
231 {
232  value_ = slp.value_;
233 
234  return *this;
235 }
236 //*************************************************************************************************
237 
238 
239 //*************************************************************************************************
249 template< typename MT > // Type of the adapted matrix
250 template< typename T > // Type of the right-hand side value
251 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
252 {
253  if( restricted_ )
254  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
255 
256  value_ = value;
257 
258  return *this;
259 }
260 //*************************************************************************************************
261 
262 
263 //*************************************************************************************************
273 template< typename MT > // Type of the adapted matrix
274 template< typename T > // Type of the right-hand side value
275 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
276 {
277  if( restricted_ )
278  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
279 
280  value_ += value;
281 
282  return *this;
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
297 template< typename MT > // Type of the adapted matrix
298 template< typename T > // Type of the right-hand side value
299 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
300 {
301  if( restricted_ )
302  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
303 
304  value_ -= value;
305 
306  return *this;
307 }
308 //*************************************************************************************************
309 
310 
311 //*************************************************************************************************
321 template< typename MT > // Type of the adapted matrix
322 template< typename T > // Type of the right-hand side value
323 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
324 {
325  if( restricted_ )
326  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
327 
328  value_ *= value;
329 
330  return *this;
331 }
332 //*************************************************************************************************
333 
334 
335 //*************************************************************************************************
345 template< typename MT > // Type of the adapted matrix
346 template< typename T > // Type of the right-hand side value
347 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
348 {
349  if( restricted_ )
350  throw std::invalid_argument( "Invalid assignment to diagonal or upper matrix element" );
351 
352  value_ /= value;
353 
354  return *this;
355 }
356 //*************************************************************************************************
357 
358 
359 
360 
361 //=================================================================================================
362 //
363 // UTILITY FUNCTIONS
364 //
365 //=================================================================================================
366 
367 //*************************************************************************************************
372 template< typename MT > // Type of the adapted matrix
374 {
375  return value_;
376 }
377 //*************************************************************************************************
378 
379 
380 //*************************************************************************************************
385 template< typename MT > // Type of the adapted matrix
387 {
388  return restricted_;
389 }
390 //*************************************************************************************************
391 
392 
393 
394 
395 //=================================================================================================
396 //
397 // CONVERSION OPERATOR
398 //
399 //=================================================================================================
400 
401 //*************************************************************************************************
406 template< typename MT > // Type of the adapted matrix
408 {
409  return get();
410 }
411 //*************************************************************************************************
412 
413 
414 
415 
416 //=================================================================================================
417 //
418 // GLOBAL OPERATORS
419 //
420 //=================================================================================================
421 
422 //*************************************************************************************************
425 template< typename MT1, typename MT2 >
426 inline bool operator==( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
427 
428 template< typename MT, typename T >
429 inline bool operator==( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
430 
431 template< typename T, typename MT >
432 inline bool operator==( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
433 
434 template< typename MT1, typename MT2 >
435 inline bool operator!=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
436 
437 template< typename MT, typename T >
438 inline bool operator!=( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
439 
440 template< typename T, typename MT >
441 inline bool operator!=( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
442 
443 template< typename MT1, typename MT2 >
444 inline bool operator<( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
445 
446 template< typename MT, typename T >
447 inline bool operator<( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
448 
449 template< typename T, typename MT >
450 inline bool operator<( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
451 
452 template< typename MT1, typename MT2 >
453 inline bool operator>( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
454 
455 template< typename MT, typename T >
456 inline bool operator>( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
457 
458 template< typename T, typename MT >
459 inline bool operator>( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
460 
461 template< typename MT1, typename MT2 >
462 inline bool operator<=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
463 
464 template< typename MT, typename T >
465 inline bool operator<=( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
466 
467 template< typename T, typename MT >
468 inline bool operator<=( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
469 
470 template< typename MT1, typename MT2 >
471 inline bool operator>=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs );
472 
473 template< typename MT, typename T >
474 inline bool operator>=( const StrictlyLowerProxy<MT>& lhs, const T& rhs );
475 
476 template< typename T, typename MT >
477 inline bool operator>=( const T& lhs, const StrictlyLowerProxy<MT>& rhs );
478 
479 template< typename MT >
480 inline std::ostream& operator<<( std::ostream& os, const StrictlyLowerProxy<MT>& proxy );
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
493 template< typename MT1, typename MT2 >
494 inline bool operator==( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
495 {
496  return ( lhs.get() == rhs.get() );
497 }
498 //*************************************************************************************************
499 
500 
501 //*************************************************************************************************
509 template< typename MT, typename T >
510 inline bool operator==( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
511 {
512  return ( lhs.get() == rhs );
513 }
514 //*************************************************************************************************
515 
516 
517 //*************************************************************************************************
525 template< typename T, typename MT >
526 inline bool operator==( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
527 {
528  return ( lhs == rhs.get() );
529 }
530 //*************************************************************************************************
531 
532 
533 //*************************************************************************************************
541 template< typename MT1, typename MT2 >
542 inline bool operator!=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
543 {
544  return ( lhs.get() != rhs.get() );
545 }
546 //*************************************************************************************************
547 
548 
549 //*************************************************************************************************
557 template< typename MT, typename T >
558 inline bool operator!=( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
559 {
560  return ( lhs.get() != rhs );
561 }
562 //*************************************************************************************************
563 
564 
565 //*************************************************************************************************
573 template< typename T, typename MT >
574 inline bool operator!=( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
575 {
576  return ( lhs != rhs.get() );
577 }
578 //*************************************************************************************************
579 
580 
581 //*************************************************************************************************
589 template< typename MT1, typename MT2 >
590 inline bool operator<( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
591 {
592  return ( lhs.get() < rhs.get() );
593 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
605 template< typename MT, typename T >
606 inline bool operator<( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
607 {
608  return ( lhs.get() < rhs );
609 }
610 //*************************************************************************************************
611 
612 
613 //*************************************************************************************************
621 template< typename T, typename MT >
622 inline bool operator<( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
623 {
624  return ( lhs < rhs.get() );
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
637 template< typename MT1, typename MT2 >
638 inline bool operator>( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
639 {
640  return ( lhs.get() > rhs.get() );
641 }
642 //*************************************************************************************************
643 
644 
645 //*************************************************************************************************
653 template< typename MT, typename T >
654 inline bool operator>( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
655 {
656  return ( lhs.get() > rhs );
657 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
669 template< typename T, typename MT >
670 inline bool operator>( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
671 {
672  return ( lhs > rhs.get() );
673 }
674 //*************************************************************************************************
675 
676 
677 //*************************************************************************************************
685 template< typename MT1, typename MT2 >
686 inline bool operator<=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
687 {
688  return ( lhs.get() <= rhs.get() );
689 }
690 //*************************************************************************************************
691 
692 
693 //*************************************************************************************************
701 template< typename MT, typename T >
702 inline bool operator<=( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
703 {
704  return ( lhs.get() <= rhs );
705 }
706 //*************************************************************************************************
707 
708 
709 //*************************************************************************************************
717 template< typename T, typename MT >
718 inline bool operator<=( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
719 {
720  return ( lhs <= rhs.get() );
721 }
722 //*************************************************************************************************
723 
724 
725 //*************************************************************************************************
733 template< typename MT1, typename MT2 >
734 inline bool operator>=( const StrictlyLowerProxy<MT1>& lhs, const StrictlyLowerProxy<MT2>& rhs )
735 {
736  return ( lhs.get() >= rhs.get() );
737 }
738 //*************************************************************************************************
739 
740 
741 //*************************************************************************************************
750 template< typename MT, typename T >
751 inline bool operator>=( const StrictlyLowerProxy<MT>& lhs, const T& rhs )
752 {
753  return ( lhs.get() >= rhs );
754 }
755 //*************************************************************************************************
756 
757 
758 //*************************************************************************************************
767 template< typename T, typename MT >
768 inline bool operator>=( const T& lhs, const StrictlyLowerProxy<MT>& rhs )
769 {
770  return ( lhs >= rhs.get() );
771 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
783 template< typename MT >
784 inline std::ostream& operator<<( std::ostream& os, const StrictlyLowerProxy<MT>& proxy )
785 {
786  return os << proxy.get();
787 }
788 //*************************************************************************************************
789 
790 
791 
792 
793 //=================================================================================================
794 //
795 // GLOBAL FUNCTIONS
796 //
797 //=================================================================================================
798 
799 //*************************************************************************************************
802 template< typename MT >
803 inline void reset( const StrictlyLowerProxy<MT>& proxy );
804 
805 template< typename MT >
806 inline void clear( const StrictlyLowerProxy<MT>& proxy );
807 
808 template< typename MT >
809 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy );
811 //*************************************************************************************************
812 
813 
814 //*************************************************************************************************
824 template< typename MT >
825 inline void reset( const StrictlyLowerProxy<MT>& proxy )
826 {
827  using blaze::reset;
828 
829  reset( proxy.get() );
830 }
831 //*************************************************************************************************
832 
833 
834 //*************************************************************************************************
844 template< typename MT >
845 inline void clear( const StrictlyLowerProxy<MT>& proxy )
846 {
847  using blaze::clear;
848 
849  clear( proxy.get() );
850 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
864 template< typename MT >
865 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
866 {
867  using blaze::isDefault;
868 
869  return isDefault( proxy.get() );
870 }
871 //*************************************************************************************************
872 
873 } // namespace blaze
874 
875 #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.
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
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
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
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
#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
bool isRestricted() const
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:386
Constraint on the data type.
Access proxy for strictly lower triangular matrices.The StrictlyLowerProxy provides controlled access...
Definition: StrictlyLowerProxy.h:94
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyLowerProxy.h:155
AddConst< typename MT::Reference >::Type ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyLowerProxy.h:99
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
AddReference< ReferenceType >::Type RawReference
Reference to the represented element.
Definition: StrictlyLowerProxy.h:108
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.
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
const StrictlyLowerProxy & operator=(const StrictlyLowerProxy &ulp) const
Copy assignment operator for StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:230
#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.
RawReference get() const
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:373
#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
MT::ElementType RepresentedType
Type of the represented matrix element.
Definition: StrictlyLowerProxy.h:105
#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
StrictlyLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:195
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:154