Blaze 3.9
DenseNonScalar.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONSCALAR_H_
36#define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONSCALAR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <utility>
46#include <blaze/math/Aliases.h>
76#include <blaze/util/Assert.h>
81#include <blaze/util/EnableIf.h>
83#include <blaze/util/mpl/If.h>
85#include <blaze/util/Types.h>
87
88
89namespace blaze {
90
91//=================================================================================================
92//
93// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NON-SCALAR ELEMENT TYPE
94//
95//=================================================================================================
96
97//*************************************************************************************************
105template< typename MT // Type of the adapted dense matrix
106 , bool SO > // Storage order of the adapted dense matrix
107class SymmetricMatrix<MT,SO,true,false>
108 : public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
109{
110 private:
111 //**Type definitions****************************************************************************
112 using OT = OppositeType_t<MT>;
113 using TT = TransposeType_t<MT>;
114 using ET = ElementType_t<MT>;
115 //**********************************************************************************************
116
117 public:
118 //**Type definitions****************************************************************************
119 using This = SymmetricMatrix<MT,SO,true,false>;
120 using BaseType = DenseMatrix<This,SO>;
121 using ResultType = This;
122 using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
123 using TransposeType = SymmetricMatrix<TT,!SO,true,false>;
124 using ElementType = ET;
125 using TagType = TagType_t<MT>;
126 using ReturnType = ReturnType_t<MT>;
127 using CompositeType = const This&;
128 using Reference = Reference_t<MT>;
129 using ConstReference = ConstReference_t<MT>;
130 using Pointer = Pointer_t<MT>;
131 using ConstPointer = ConstPointer_t<MT>;
132 //**********************************************************************************************
133
134 //**Rebind struct definition********************************************************************
137 template< typename NewType > // Data type of the other matrix
138 struct Rebind {
140 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
141 };
142 //**********************************************************************************************
143
144 //**Resize struct definition********************************************************************
147 template< size_t NewM // Number of rows of the other matrix
148 , size_t NewN > // Number of columns of the other matrix
149 struct Resize {
151 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
152 };
153 //**********************************************************************************************
154
155 //**MatrixIterator class definition*************************************************************
158 template< typename MatrixType > // Type of the adapted dense matrix
159 class MatrixIterator
160 {
161 public:
162 //**Type definitions*************************************************************************
164 using Reference = If_t< IsConst_v<MatrixType>
165 , ConstReference_t<MatrixType>
166 , Reference_t<MatrixType> >;
167
168 using IteratorCategory = std::random_access_iterator_tag;
169 using ValueType = RemoveReference_t<Reference>;
170 using PointerType = ValueType*;
171 using ReferenceType = Reference;
172 using DifferenceType = ptrdiff_t;
173
174 // STL iterator requirements
175 using iterator_category = IteratorCategory;
176 using value_type = ValueType;
177 using pointer = PointerType;
178 using reference = ReferenceType;
179 using difference_type = DifferenceType;
180 //*******************************************************************************************
181
182 //**Constructor******************************************************************************
185 inline MatrixIterator() noexcept
186 : matrix_( nullptr ) // Reference to the adapted dense matrix
187 , row_ ( 0UL ) // The current row index of the iterator
188 , column_( 0UL ) // The current column index of the iterator
189 {}
190 //*******************************************************************************************
191
192 //**Constructor******************************************************************************
199 inline MatrixIterator( MatrixType& matrix, size_t row, size_t column ) noexcept
200 : matrix_( &matrix ) // Reference to the adapted dense matrix
201 , row_ ( row ) // The current row index of the iterator
202 , column_( column ) // The current column index of the iterator
203 {}
204 //*******************************************************************************************
205
206 //**Conversion constructor*******************************************************************
211 template< typename MatrixType2 >
212 inline MatrixIterator( const MatrixIterator<MatrixType2>& it ) noexcept
213 : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
214 , row_ ( it.row_ ) // The current row index of the iterator
215 , column_( it.column_ ) // The current column index of the iterator
216 {}
217 //*******************************************************************************************
218
219 //**Addition assignment operator*************************************************************
225 inline MatrixIterator& operator+=( size_t inc ) noexcept {
226 ( SO )?( row_ += inc ):( column_ += inc );
227 return *this;
228 }
229 //*******************************************************************************************
230
231 //**Subtraction assignment operator**********************************************************
237 inline MatrixIterator& operator-=( size_t dec ) noexcept {
238 ( SO )?( row_ -= dec ):( column_ -= dec );
239 return *this;
240 }
241 //*******************************************************************************************
242
243 //**Prefix increment operator****************************************************************
248 inline MatrixIterator& operator++() noexcept {
249 ( SO )?( ++row_ ):( ++column_ );
250 return *this;
251 }
252 //*******************************************************************************************
253
254 //**Postfix increment operator***************************************************************
259 inline const MatrixIterator operator++( int ) noexcept {
260 const MatrixIterator tmp( *this );
261 ++(*this);
262 return tmp;
263 }
264 //*******************************************************************************************
265
266 //**Prefix decrement operator****************************************************************
271 inline MatrixIterator& operator--() noexcept {
272 ( SO )?( --row_ ):( --column_ );
273 return *this;
274 }
275 //*******************************************************************************************
276
277 //**Postfix decrement operator***************************************************************
282 inline const MatrixIterator operator--( int ) noexcept {
283 const MatrixIterator tmp( *this );
284 --(*this);
285 return tmp;
286 }
287 //*******************************************************************************************
288
289 //**Element access operator******************************************************************
294 inline ReferenceType operator*() const {
295 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
296 return (*matrix_)(row_,column_);
297 else
298 return (*matrix_)(column_,row_);
299 }
300 //*******************************************************************************************
301
302 //**Element access operator******************************************************************
307 inline PointerType operator->() const {
308 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
309 return &(*matrix_)(row_,column_);
310 else
311 return &(*matrix_)(column_,row_);
312 }
313 //*******************************************************************************************
314
315 //**Equality operator************************************************************************
321 template< typename MatrixType2 >
322 inline bool operator==( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
323 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
324 }
325 //*******************************************************************************************
326
327 //**Inequality operator**********************************************************************
333 template< typename MatrixType2 >
334 inline bool operator!=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
335 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
336 }
337 //*******************************************************************************************
338
339 //**Less-than operator***********************************************************************
345 template< typename MatrixType2 >
346 inline bool operator<( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
347 return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
348 return ( column_ < rhs.column_ );
349 }
350 //*******************************************************************************************
351
352 //**Greater-than operator********************************************************************
358 template< typename MatrixType2 >
359 inline bool operator>( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
360 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
361 return ( column_ > rhs.column_ );
362 }
363 //*******************************************************************************************
364
365 //**Less-or-equal-than operator**************************************************************
371 template< typename MatrixType2 >
372 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
373 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
374 }
375 //*******************************************************************************************
376
377 //**Greater-or-equal-than operator***********************************************************
383 template< typename MatrixType2 >
384 inline bool operator>=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
385 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
386 }
387 //*******************************************************************************************
388
389 //**Subtraction operator*********************************************************************
395 inline DifferenceType operator-( const MatrixIterator& rhs ) const noexcept {
396 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
397 }
398 //*******************************************************************************************
399
400 //**Addition operator************************************************************************
407 friend inline const MatrixIterator operator+( const MatrixIterator& it, size_t inc ) noexcept {
408 if( SO )
409 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
410 else
411 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
412 }
413 //*******************************************************************************************
414
415 //**Addition operator************************************************************************
422 friend inline const MatrixIterator operator+( size_t inc, const MatrixIterator& it ) noexcept {
423 if( SO )
424 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
425 else
426 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
427 }
428 //*******************************************************************************************
429
430 //**Subtraction operator*********************************************************************
437 friend inline const MatrixIterator operator-( const MatrixIterator& it, size_t dec ) noexcept {
438 if( SO )
439 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
440 else
441 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
442 }
443 //*******************************************************************************************
444
445 private:
446 //**Member variables*************************************************************************
447 MatrixType* matrix_;
448 size_t row_;
449 size_t column_;
450 //*******************************************************************************************
451
452 //**Friend declarations**********************************************************************
453 template< typename MatrixType2 > friend class MatrixIterator;
454 //*******************************************************************************************
455 };
456 //**********************************************************************************************
457
458 //**Type definitions****************************************************************************
459 using Iterator = MatrixIterator<MT>;
460 using ConstIterator = MatrixIterator<const MT>;
461 //**********************************************************************************************
462
463 //**Compilation flags***************************************************************************
465 static constexpr bool simdEnabled = false;
466
468 static constexpr bool smpAssignable = ( MT::smpAssignable && !IsSMPAssignable_v<ET> );
469 //**********************************************************************************************
470
471 //**Constructors********************************************************************************
474 inline SymmetricMatrix();
475 explicit inline SymmetricMatrix( size_t n );
476
477 inline SymmetricMatrix( ElementType* ptr, size_t n );
478 inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn );
479
480 inline SymmetricMatrix( const SymmetricMatrix& m );
481 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
482
483 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
484 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
486 //**********************************************************************************************
487
488 //**Destructor**********************************************************************************
491 ~SymmetricMatrix() = default;
493 //**********************************************************************************************
494
495 //**Data access functions***********************************************************************
498 inline Reference operator()( size_t i, size_t j );
499 inline ConstReference operator()( size_t i, size_t j ) const;
500 inline Reference at( size_t i, size_t j );
501 inline ConstReference at( size_t i, size_t j ) const;
502 inline ConstPointer data () const noexcept;
503 inline ConstPointer data ( size_t i ) const noexcept;
504 inline Iterator begin ( size_t i );
505 inline ConstIterator begin ( size_t i ) const;
506 inline ConstIterator cbegin( size_t i ) const;
507 inline Iterator end ( size_t i );
508 inline ConstIterator end ( size_t i ) const;
509 inline ConstIterator cend ( size_t i ) const;
511 //**********************************************************************************************
512
513 //**Assignment operators************************************************************************
516 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
517 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
518
519 template< typename MT2 >
520 inline auto operator=( const Matrix<MT2,SO>& rhs )
521 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
522
523 template< typename MT2 >
524 inline auto operator=( const Matrix<MT2,SO>& rhs )
525 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
526
527 template< typename MT2 >
528 inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
529
530 template< typename MT2 >
531 inline auto operator+=( const Matrix<MT2,SO>& rhs )
532 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
533
534 template< typename MT2 >
535 inline auto operator+=( const Matrix<MT2,SO>& rhs )
536 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
537
538 template< typename MT2 >
539 inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
540
541 template< typename MT2 >
542 inline auto operator-=( const Matrix<MT2,SO>& rhs )
543 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
544
545 template< typename MT2 >
546 inline auto operator-=( const Matrix<MT2,SO>& rhs )
547 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
548
549 template< typename MT2 >
550 inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
551
552 template< typename MT2 >
553 inline auto operator%=( const Matrix<MT2,SO>& rhs )
554 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
555
556 template< typename MT2 >
557 inline auto operator%=( const Matrix<MT2,SO>& rhs )
558 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
559
560 template< typename MT2 >
561 inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
562
563 template< typename ST >
564 inline auto operator*=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >;
565
566 template< typename ST >
567 inline auto operator/=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >;
569 //**********************************************************************************************
570
571 //**Utility functions***************************************************************************
574 inline size_t rows() const noexcept;
575 inline size_t columns() const noexcept;
576 inline size_t spacing() const noexcept;
577 inline size_t capacity() const noexcept;
578 inline size_t capacity( size_t i ) const noexcept;
579 inline size_t nonZeros() const;
580 inline size_t nonZeros( size_t i ) const;
581 inline void reset();
582 inline void reset( size_t i );
583 inline void clear();
584 void resize ( size_t n, bool preserve=true );
585 inline void extend ( size_t n, bool preserve=true );
586 inline void reserve( size_t elements );
587 inline void shrinkToFit();
588 inline void swap( SymmetricMatrix& m ) noexcept;
590 //**********************************************************************************************
591
592 //**Numeric functions***************************************************************************
595 inline SymmetricMatrix& transpose();
596 inline SymmetricMatrix& ctranspose();
597
598 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
600 //**********************************************************************************************
601
602 //**Debugging functions*************************************************************************
605 inline bool isIntact() const noexcept;
607 //**********************************************************************************************
608
609 //**Expression template evaluation functions****************************************************
612 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
613 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
614
615 inline bool isAligned () const noexcept;
616 inline bool canSMPAssign() const noexcept;
618 //**********************************************************************************************
619
620 private:
621 //**Expression template evaluation functions****************************************************
624 template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
625 template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
626 template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
627 template< typename MT2 > inline void addAssign ( const DenseMatrix <MT2,SO>& rhs );
628 template< typename MT2 > inline void addAssign ( const SparseMatrix<MT2,SO>& rhs );
629 template< typename MT2 > inline void subAssign ( const DenseMatrix <MT2,SO>& rhs );
630 template< typename MT2 > inline void subAssign ( const SparseMatrix<MT2,SO>& rhs );
631 template< typename MT2 > inline void schurAssign( const DenseMatrix <MT2,SO>& rhs );
632 template< typename MT2 > inline void schurAssign( const SparseMatrix<MT2,SO>& rhs );
634 //**********************************************************************************************
635
636 //**Member variables****************************************************************************
639 MT matrix_;
641 //**********************************************************************************************
642
643 //**Compile time checks*************************************************************************
659 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
660 //**********************************************************************************************
661};
663//*************************************************************************************************
664
665
666
667
668//=================================================================================================
669//
670// CONSTRUCTORS
671//
672//=================================================================================================
673
674//*************************************************************************************************
678template< typename MT // Type of the adapted dense matrix
679 , bool SO > // Storage order of the adapted dense matrix
680inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
681 : matrix_() // The adapted dense matrix
682{
683 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
684}
686//*************************************************************************************************
687
688
689//*************************************************************************************************
695template< typename MT // Type of the adapted dense matrix
696 , bool SO > // Storage order of the adapted dense matrix
697inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
698 : matrix_( n, n ) // The adapted dense matrix
699{
701
702 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
703}
705//*************************************************************************************************
706
707
708//*************************************************************************************************
742template< typename MT // Type of the adapted dense matrix
743 , bool SO > // Storage order of the adapted dense matrix
744inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
745 : matrix_( ptr, n, n ) // The adapted dense matrix
746{
747 if( !isSymmetric( matrix_ ) ) {
748 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
749 }
750
751 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
752}
754//*************************************************************************************************
755
756
757//*************************************************************************************************
793template< typename MT // Type of the adapted dense matrix
794 , bool SO > // Storage order of the adapted dense matrix
795inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
796 : matrix_( ptr, n, n, nn ) // The adapted dense matrix
797{
798 if( !isSymmetric( matrix_ ) ) {
799 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
800 }
801
802 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
803}
805//*************************************************************************************************
806
807
808//*************************************************************************************************
814template< typename MT // Type of the adapted dense matrix
815 , bool SO > // Storage order of the adapted dense matrix
816inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
817 : matrix_( m.matrix_ ) // The adapted dense matrix
818{
819 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
820 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
821}
823//*************************************************************************************************
824
825
826//*************************************************************************************************
832template< typename MT // Type of the adapted dense matrix
833 , bool SO > // Storage order of the adapted dense matrix
834inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
835 : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
836{
837 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
838 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
839}
841//*************************************************************************************************
842
843
844//*************************************************************************************************
854template< typename MT // Type of the adapted dense matrix
855 , bool SO > // Storage order of the adapted dense matrix
856template< typename MT2 > // Type of the foreign matrix
857inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
858 : matrix_() // The adapted dense matrix
859{
860 using blaze::resize;
861
862 using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
863 using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
864
865 if( IsSymmetric_v<MT2> ) {
866 resize( matrix_, (*m).rows(), (*m).columns() );
867 assign( *m );
868 }
869 else {
870 Tmp tmp( *m );
871
872 if( !isSymmetric( tmp ) ) {
873 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
874 }
875
876 resize( matrix_, tmp.rows(), tmp.rows() );
877 assign( tmp );
878 }
879
880 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
881 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
882}
884//*************************************************************************************************
885
886
887//*************************************************************************************************
897template< typename MT // Type of the adapted dense matrix
898 , bool SO > // Storage order of the adapted dense matrix
899template< typename MT2 > // Type of the foreign matrix
900inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
901 : matrix_() // The adapted dense matrix
902{
903 using blaze::resize;
904
905 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
906 using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
907
908 if( IsSymmetric_v<MT2> ) {
909 resize( matrix_, (*m).rows(), (*m).columns() );
910 assign( trans( *m ) );
911 }
912 else {
913 Tmp tmp( *m );
914
915 if( !isSymmetric( tmp ) ) {
916 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
917 }
918
919 resize( matrix_, tmp.rows(), tmp.rows() );
920 assign( trans( tmp ) );
921 }
922
923 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
924 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
925}
927//*************************************************************************************************
928
929
930
931
932//=================================================================================================
933//
934// DATA ACCESS FUNCTIONS
935//
936//=================================================================================================
937
938//*************************************************************************************************
953template< typename MT // Type of the adapted dense matrix
954 , bool SO > // Storage order of the adapted dense matrix
955inline typename SymmetricMatrix<MT,SO,true,false>::Reference
956 SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
957{
958 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
959 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
960
961 if( ( !SO && i > j ) || ( SO && i < j ) )
962 return matrix_(i,j);
963 else
964 return matrix_(j,i);
965}
967//*************************************************************************************************
968
969
970//*************************************************************************************************
985template< typename MT // Type of the adapted dense matrix
986 , bool SO > // Storage order of the adapted dense matrix
987inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
988 SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
989{
990 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
991 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
992
993 if( ( !SO && i > j ) || ( SO && i < j ) )
994 return matrix_(i,j);
995 else
996 return matrix_(j,i);
997}
999//*************************************************************************************************
1000
1001
1002//*************************************************************************************************
1018template< typename MT // Type of the adapted dense matrix
1019 , bool SO > // Storage order of the adapted dense matrix
1020inline typename SymmetricMatrix<MT,SO,true,false>::Reference
1021 SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1022{
1023 if( i >= rows() ) {
1024 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1025 }
1026 if( j >= columns() ) {
1027 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1028 }
1029 return (*this)(i,j);
1030}
1032//*************************************************************************************************
1033
1034
1035//*************************************************************************************************
1051template< typename MT // Type of the adapted dense matrix
1052 , bool SO > // Storage order of the adapted dense matrix
1053inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
1054 SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1055{
1056 if( i >= rows() ) {
1057 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1058 }
1059 if( j >= columns() ) {
1060 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1061 }
1062 return (*this)(i,j);
1063}
1065//*************************************************************************************************
1066
1067
1068//*************************************************************************************************
1082template< typename MT // Type of the adapted dense matrix
1083 , bool SO > // Storage order of the adapted dense matrix
1084inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1086{
1087 return matrix_.data();
1088}
1090//*************************************************************************************************
1091
1092
1093//*************************************************************************************************
1104template< typename MT // Type of the adapted dense matrix
1105 , bool SO > // Storage order of the adapted dense matrix
1106inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1107 SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1108{
1109 return matrix_.data(i);
1110}
1112//*************************************************************************************************
1113
1114
1115//*************************************************************************************************
1127template< typename MT // Type of the adapted dense matrix
1128 , bool SO > // Storage order of the adapted dense matrix
1129inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1131{
1132 if( SO )
1133 return Iterator( matrix_, 0UL, i );
1134 else
1135 return Iterator( matrix_, i, 0UL );
1136}
1138//*************************************************************************************************
1139
1140
1141//*************************************************************************************************
1153template< typename MT // Type of the adapted dense matrix
1154 , bool SO > // Storage order of the adapted dense matrix
1155inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1157{
1158 if( SO )
1159 return ConstIterator( matrix_, 0UL, i );
1160 else
1161 return ConstIterator( matrix_, i, 0UL );
1162}
1164//*************************************************************************************************
1165
1166
1167//*************************************************************************************************
1179template< typename MT // Type of the adapted dense matrix
1180 , bool SO > // Storage order of the adapted dense matrix
1181inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1183{
1184 if( SO )
1185 return ConstIterator( matrix_, 0UL, i );
1186 else
1187 return ConstIterator( matrix_, i, 0UL );
1188}
1190//*************************************************************************************************
1191
1192
1193//*************************************************************************************************
1205template< typename MT // Type of the adapted dense matrix
1206 , bool SO > // Storage order of the adapted dense matrix
1207inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1209{
1210 if( SO )
1211 return Iterator( matrix_, rows(), i );
1212 else
1213 return Iterator( matrix_, i, columns() );
1214}
1216//*************************************************************************************************
1217
1218
1219//*************************************************************************************************
1231template< typename MT // Type of the adapted dense matrix
1232 , bool SO > // Storage order of the adapted dense matrix
1233inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1235{
1236 if( SO )
1237 return ConstIterator( matrix_, rows(), i );
1238 else
1239 return ConstIterator( matrix_, i, columns() );
1240}
1242//*************************************************************************************************
1243
1244
1245//*************************************************************************************************
1257template< typename MT // Type of the adapted dense matrix
1258 , bool SO > // Storage order of the adapted dense matrix
1259inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1261{
1262 if( SO )
1263 return ConstIterator( matrix_, rows(), i );
1264 else
1265 return ConstIterator( matrix_, i, columns() );
1266}
1268//*************************************************************************************************
1269
1270
1271
1272
1273//=================================================================================================
1274//
1275// ASSIGNMENT OPERATORS
1276//
1277//=================================================================================================
1278
1279//*************************************************************************************************
1289template< typename MT // Type of the adapted dense matrix
1290 , bool SO > // Storage order of the adapted dense matrix
1291inline SymmetricMatrix<MT,SO,true,false>&
1292 SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1293{
1294 using blaze::resize;
1295
1296 if( &rhs == this ) return *this;
1297
1298 resize( matrix_, rhs.rows(), rhs.columns() );
1299 assign( rhs );
1300
1301 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1302 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1303
1304 return *this;
1305}
1307//*************************************************************************************************
1308
1309
1310//*************************************************************************************************
1317template< typename MT // Type of the adapted dense matrix
1318 , bool SO > // Storage order of the adapted dense matrix
1319inline SymmetricMatrix<MT,SO,true,false>&
1320 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1321{
1322 matrix_ = std::move( rhs.matrix_ );
1323
1324 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1325 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1326
1327 return *this;
1328}
1330//*************************************************************************************************
1331
1332
1333//*************************************************************************************************
1347template< typename MT // Type of the adapted dense matrix
1348 , bool SO > // Storage order of the adapted dense matrix
1349template< typename MT2 > // Type of the right-hand side matrix
1350inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1351 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1352{
1353 using blaze::resize;
1354
1355 if( !IsSymmetric_v<MT2> && !isSymmetric( *rhs ) ) {
1356 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1357 }
1358
1359 if( (*rhs).isAliased( this ) ) {
1360 SymmetricMatrix tmp( *rhs );
1361 swap( tmp );
1362 }
1363 else {
1364 resize( matrix_, (*rhs).rows(), (*rhs).columns() );
1365 if( IsSparseMatrix_v<MT2> )
1366 reset();
1367 assign( *rhs );
1368 }
1369
1370 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1371 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1372
1373 return *this;
1374}
1376//*************************************************************************************************
1377
1378
1379//*************************************************************************************************
1393template< typename MT // Type of the adapted dense matrix
1394 , bool SO > // Storage order of the adapted dense matrix
1395template< typename MT2 > // Type of the right-hand side matrix
1396inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1397 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1398{
1399 using blaze::resize;
1400
1401 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1402
1403 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1404 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1405 }
1406
1407 Tmp tmp( *rhs );
1408
1409 if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1410 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1411 }
1412
1413 BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1414
1415 resize( matrix_, tmp.rows(), tmp.columns() );
1416 if( IsSparseMatrix_v<Tmp> )
1417 reset();
1418 assign( tmp );
1419
1420 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1421 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1422
1423 return *this;
1424}
1426//*************************************************************************************************
1427
1428
1429//*************************************************************************************************
1443template< typename MT // Type of the adapted dense matrix
1444 , bool SO > // Storage order of the adapted dense matrix
1445template< typename MT2 > // Type of the right-hand side matrix
1446inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1447 -> SymmetricMatrix&
1448{
1449 return this->operator=( trans( *rhs ) );
1450}
1452//*************************************************************************************************
1453
1454
1455//*************************************************************************************************
1468template< typename MT // Type of the adapted dense matrix
1469 , bool SO > // Storage order of the adapted dense matrix
1470template< typename MT2 > // Type of the right-hand side matrix
1471inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1472 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1473{
1474 if( !IsSymmetric_v<MT2> && !isSymmetric( *rhs ) ) {
1475 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1476 }
1477
1478 addAssign( *rhs );
1479
1480 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1481 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1482
1483 return *this;
1484}
1486//*************************************************************************************************
1487
1488
1489//*************************************************************************************************
1502template< typename MT // Type of the adapted dense matrix
1503 , bool SO > // Storage order of the adapted dense matrix
1504template< typename MT2 > // Type of the right-hand side matrix
1505inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1506 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1507{
1508 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1509
1510 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1511 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1512 }
1513
1514 Tmp tmp( *rhs );
1515
1516 if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1517 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1518 }
1519
1520 BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1521
1522 addAssign( tmp );
1523
1524 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1525 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1526
1527 return *this;
1528}
1530//*************************************************************************************************
1531
1532
1533//*************************************************************************************************
1547template< typename MT // Type of the adapted dense matrix
1548 , bool SO > // Storage order of the adapted dense matrix
1549template< typename MT2 > // Type of the right-hand side matrix
1550inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1551 -> SymmetricMatrix&
1552{
1553 return this->operator+=( trans( *rhs ) );
1554}
1556//*************************************************************************************************
1557
1558
1559//*************************************************************************************************
1572template< typename MT // Type of the adapted dense matrix
1573 , bool SO > // Storage order of the adapted dense matrix
1574template< typename MT2 > // Type of the right-hand side matrix
1575inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1576 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1577{
1578 if( !IsSymmetric_v<MT2> && !isSymmetric( *rhs ) ) {
1579 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1580 }
1581
1582 subAssign( *rhs );
1583
1584 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1585 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1586
1587 return *this;
1588}
1590//*************************************************************************************************
1591
1592
1593//*************************************************************************************************
1606template< typename MT // Type of the adapted dense matrix
1607 , bool SO > // Storage order of the adapted dense matrix
1608template< typename MT2 > // Type of the right-hand side matrix
1609inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1610 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1611{
1612 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1613
1614 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1615 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1616 }
1617
1618 Tmp tmp( *rhs );
1619
1620 if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1621 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1622 }
1623
1624 BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1625
1626 subAssign( tmp );
1627
1628 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1629 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1630
1631 return *this;
1632}
1634//*************************************************************************************************
1635
1636
1637//*************************************************************************************************
1651template< typename MT // Type of the adapted dense matrix
1652 , bool SO > // Storage order of the adapted dense matrix
1653template< typename MT2 > // Type of the right-hand side matrix
1654inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1655 -> SymmetricMatrix&
1656{
1657 return this->operator-=( trans( *rhs ) );
1658}
1660//*************************************************************************************************
1661
1662
1663//*************************************************************************************************
1677template< typename MT // Type of the adapted dense matrix
1678 , bool SO > // Storage order of the adapted dense matrix
1679template< typename MT2 > // Type of the right-hand side matrix
1680inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1681 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1682{
1683 if( !IsSymmetric_v<MT2> && !isSymmetric( *rhs ) ) {
1684 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1685 }
1686
1687 schurAssign( *rhs );
1688
1689 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1690 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1691
1692 return *this;
1693}
1695//*************************************************************************************************
1696
1697
1698//*************************************************************************************************
1712template< typename MT // Type of the adapted dense matrix
1713 , bool SO > // Storage order of the adapted dense matrix
1714template< typename MT2 > // Type of the right-hand side matrix
1715inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1716 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1717{
1718 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1719
1720 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1721 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1722 }
1723
1724 Tmp tmp( *rhs );
1725
1726 if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1727 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1728 }
1729
1730 BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1731
1732 schurAssign( tmp );
1733
1734 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1735 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1736
1737 return *this;
1738}
1740//*************************************************************************************************
1741
1742
1743//*************************************************************************************************
1757template< typename MT // Type of the adapted dense matrix
1758 , bool SO > // Storage order of the adapted dense matrix
1759template< typename MT2 > // Type of the right-hand side matrix
1760inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1761 -> SymmetricMatrix&
1762{
1763 return this->operator%=( trans( *rhs ) );
1764}
1766//*************************************************************************************************
1767
1768
1769//*************************************************************************************************
1777template< typename MT // Type of the adapted dense matrix
1778 , bool SO > // Storage order of the adapted dense matrix
1779template< typename ST > // Data type of the right-hand side scalar
1781 -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >
1782{
1783 if( SO ) {
1784 for( size_t j=0UL; j<columns(); ++j )
1785 for( size_t i=0UL; i<=j; ++i )
1786 matrix_(i,j) *= rhs;
1787 }
1788 else {
1789 for( size_t i=0UL; i<rows(); ++i )
1790 for( size_t j=0UL; j<=i; ++j )
1791 matrix_(i,j) *= rhs;
1792 }
1793
1794 return *this;
1795}
1797//*************************************************************************************************
1798
1799
1800//*************************************************************************************************
1808template< typename MT // Type of the adapted dense matrix
1809 , bool SO > // Storage order of the adapted dense matrix
1810template< typename ST > // Data type of the right-hand side scalar
1812 -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >
1813{
1814 BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1815
1816 if( SO ) {
1817 for( size_t j=0UL; j<columns(); ++j )
1818 for( size_t i=0UL; i<=j; ++i )
1819 matrix_(i,j) /= rhs;
1820 }
1821 else {
1822 for( size_t i=0UL; i<rows(); ++i )
1823 for( size_t j=0UL; j<=i; ++j )
1824 matrix_(i,j) /= rhs;
1825 }
1826
1827 return *this;
1828}
1830//*************************************************************************************************
1831
1832
1833
1834
1835//=================================================================================================
1836//
1837// UTILITY FUNCTIONS
1838//
1839//=================================================================================================
1840
1841//*************************************************************************************************
1847template< typename MT // Type of the adapted dense matrix
1848 , bool SO > // Storage order of the adapted dense matrix
1849inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1850{
1851 return matrix_.rows();
1852}
1854//*************************************************************************************************
1855
1856
1857//*************************************************************************************************
1863template< typename MT // Type of the adapted dense matrix
1864 , bool SO > // Storage order of the adapted dense matrix
1865inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1866{
1867 return matrix_.columns();
1868}
1870//*************************************************************************************************
1871
1872
1873//*************************************************************************************************
1885template< typename MT // Type of the adapted dense matrix
1886 , bool SO > // Storage order of the adapted dense matrix
1887inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1888{
1889 return matrix_.spacing();
1890}
1892//*************************************************************************************************
1893
1894
1895//*************************************************************************************************
1901template< typename MT // Type of the adapted dense matrix
1902 , bool SO > // Storage order of the adapted dense matrix
1903inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1904{
1905 return matrix_.capacity();
1906}
1908//*************************************************************************************************
1909
1910
1911//*************************************************************************************************
1922template< typename MT // Type of the adapted dense matrix
1923 , bool SO > // Storage order of the adapted dense matrix
1924inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1925{
1926 return matrix_.capacity(i);
1927}
1929//*************************************************************************************************
1930
1931
1932//*************************************************************************************************
1938template< typename MT // Type of the adapted dense matrix
1939 , bool SO > // Storage order of the adapted dense matrix
1941{
1942 size_t nonzeros( 0UL );
1943
1944 if( SO )
1945 {
1946 for( size_t j=0UL; j<columns(); ++j ) {
1947 for( size_t i=0UL; i<j; ++i ) {
1948 if( !isDefault( matrix_(i,j) ) )
1949 nonzeros += 2UL;
1950 }
1951 if( !isDefault( matrix_(j,j) ) )
1952 ++nonzeros;
1953 }
1954 }
1955 else
1956 {
1957 for( size_t i=0UL; i<rows(); ++i ) {
1958 for( size_t j=0UL; j<i; ++j ) {
1959 if( !isDefault( matrix_(i,j) ) )
1960 nonzeros += 2UL;
1961 }
1962 if( !isDefault( matrix_(i,i) ) )
1963 ++nonzeros;
1964 }
1965 }
1966
1967 return nonzeros;
1968}
1970//*************************************************************************************************
1971
1972
1973//*************************************************************************************************
1985template< typename MT // Type of the adapted dense matrix
1986 , bool SO > // Storage order of the adapted dense matrix
1987inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1988{
1989 size_t nonzeros( 0UL );
1990
1991 if( SO )
1992 {
1993 for( size_t j=0UL; j<i; ++j ) {
1994 if( !isDefault( matrix_(j,i) ) )
1995 ++nonzeros;
1996 }
1997 for( size_t j=i; j<rows(); ++j ) {
1998 if( !isDefault( matrix_(i,j) ) )
1999 ++nonzeros;
2000 }
2001 }
2002 else
2003 {
2004 for( size_t j=0UL; j<i; ++j ) {
2005 if( !isDefault( matrix_(i,j) ) )
2006 ++nonzeros;
2007 }
2008 for( size_t j=i; j<rows(); ++j ) {
2009 if( !isDefault( matrix_(j,i) ) )
2010 ++nonzeros;
2011 }
2012 }
2013
2014 return nonzeros;
2015}
2017//*************************************************************************************************
2018
2019
2020//*************************************************************************************************
2026template< typename MT // Type of the adapted dense matrix
2027 , bool SO > // Storage order of the adapted dense matrix
2029{
2030 using blaze::clear;
2031
2032 if( SO ) {
2033 for( size_t j=0UL; j<columns(); ++j )
2034 for( size_t i=0UL; i<=j; ++i )
2035 clear( matrix_(i,j) );
2036 }
2037 else {
2038 for( size_t i=0UL; i<rows(); ++i )
2039 for( size_t j=0UL; j<=i; ++j )
2040 clear( matrix_(i,j) );
2041 }
2042}
2044//*************************************************************************************************
2045
2046
2047//*************************************************************************************************
2087template< typename MT // Type of the adapted dense matrix
2088 , bool SO > // Storage order of the adapted dense matrix
2089inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2090{
2091 using blaze::clear;
2092
2093 for( auto element=begin(i); element!=end(i); ++element )
2094 clear( *element );
2095}
2097//*************************************************************************************************
2098
2099
2100//*************************************************************************************************
2112template< typename MT // Type of the adapted dense matrix
2113 , bool SO > // Storage order of the adapted dense matrix
2115{
2116 matrix_.clear();
2117
2118 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
2119 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
2120}
2122//*************************************************************************************************
2123
2124
2125//*************************************************************************************************
2141template< typename MT // Type of the adapted dense matrix
2142 , bool SO > // Storage order of the adapted dense matrix
2143void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2144{
2146
2147 MAYBE_UNUSED( preserve );
2148
2149 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2150
2151 const size_t oldsize( matrix_.rows() );
2152
2153 matrix_.resize( n, n, true );
2154
2155 if( n > oldsize ) {
2156 const size_t increment( n - oldsize );
2157 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2158 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2159 }
2160}
2162//*************************************************************************************************
2163
2164
2165//*************************************************************************************************
2178template< typename MT // Type of the adapted dense matrix
2179 , bool SO > // Storage order of the adapted dense matrix
2180inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2181{
2183
2184 MAYBE_UNUSED( preserve );
2185
2186 resize( rows() + n, true );
2187}
2189//*************************************************************************************************
2190
2191
2192//*************************************************************************************************
2202template< typename MT // Type of the adapted dense matrix
2203 , bool SO > // Storage order of the adapted dense matrix
2204inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2205{
2206 matrix_.reserve( elements );
2207}
2209//*************************************************************************************************
2210
2211
2212//*************************************************************************************************
2222template< typename MT // Type of the adapted dense matrix
2223 , bool SO > // Storage order of the adapted dense matrix
2225{
2226 matrix_.shrinkToFit();
2227}
2229//*************************************************************************************************
2230
2231
2232//*************************************************************************************************
2239template< typename MT // Type of the adapted dense matrix
2240 , bool SO > // Storage order of the adapted dense matrix
2241inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2242{
2243 using std::swap;
2244
2245 swap( matrix_, m.matrix_ );
2246}
2248//*************************************************************************************************
2249
2250
2251
2252
2253//=================================================================================================
2254//
2255// NUMERIC FUNCTIONS
2256//
2257//=================================================================================================
2258
2259//*************************************************************************************************
2265template< typename MT // Type of the adapted dense matrix
2266 , bool SO > // Storage order of the adapted dense matrix
2267inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2268{
2269 return *this;
2270}
2272//*************************************************************************************************
2273
2274
2275//*************************************************************************************************
2281template< typename MT // Type of the adapted dense matrix
2282 , bool SO > // Storage order of the adapted dense matrix
2283inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2284{
2285 if( SO ) {
2286 for( size_t j=0UL; j<columns(); ++j )
2287 for( size_t i=0UL; i<=j; ++i )
2288 conjugate( matrix_(i,j) );
2289 }
2290 else {
2291 for( size_t i=0UL; i<rows(); ++i )
2292 for( size_t j=0UL; j<=i; ++j )
2293 conjugate( matrix_(i,j) );
2294 }
2295
2296 return *this;
2297}
2299//*************************************************************************************************
2300
2301
2302//*************************************************************************************************
2320template< typename MT // Type of the adapted dense matrix
2321 , bool SO > // Storage order of the adapted dense matrix
2322template< typename Other > // Data type of the scalar value
2323inline SymmetricMatrix<MT,SO,true,false>&
2324 SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2325{
2326 if( SO ) {
2327 for( size_t j=0UL; j<columns(); ++j )
2328 for( size_t i=0UL; i<=j; ++i )
2329 matrix_(i,j) *= scalar;
2330 }
2331 else {
2332 for( size_t i=0UL; i<rows(); ++i )
2333 for( size_t j=0UL; j<=i; ++j )
2334 matrix_(i,j) *= scalar;
2335 }
2336
2337 return *this;
2338}
2340//*************************************************************************************************
2341
2342
2343
2344
2345//=================================================================================================
2346//
2347// DEBUGGING FUNCTIONS
2348//
2349//=================================================================================================
2350
2351//*************************************************************************************************
2361template< typename MT // Type of the adapted dense matrix
2362 , bool SO > // Storage order of the adapted dense matrix
2363inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2364{
2365 using blaze::isIntact;
2366
2367 return isIntact( matrix_ ) &&
2368 ( IsCustom_v<MT> || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2369}
2371//*************************************************************************************************
2372
2373
2374
2375
2376//=================================================================================================
2377//
2378// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2379//
2380//=================================================================================================
2381
2382//*************************************************************************************************
2393template< typename MT // Type of the adapted dense matrix
2394 , bool SO > // Storage order of the adapted dense matrix
2395template< typename Other > // Data type of the foreign expression
2396inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2397{
2398 return matrix_.canAlias( alias );
2399}
2401//*************************************************************************************************
2402
2403
2404//*************************************************************************************************
2415template< typename MT // Type of the adapted dense matrix
2416 , bool SO > // Storage order of the adapted dense matrix
2417template< typename Other > // Data type of the foreign expression
2418inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2419{
2420 return matrix_.isAliased( alias );
2421}
2423//*************************************************************************************************
2424
2425
2426//*************************************************************************************************
2436template< typename MT // Type of the adapted dense matrix
2437 , bool SO > // Storage order of the adapted dense matrix
2438inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2439{
2440 return matrix_.isAligned();
2441}
2443//*************************************************************************************************
2444
2445
2446//*************************************************************************************************
2457template< typename MT // Type of the adapted dense matrix
2458 , bool SO > // Storage order of the adapted dense matrix
2459inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2460{
2461 return matrix_.canSMPAssign();
2462}
2464//*************************************************************************************************
2465
2466
2467//*************************************************************************************************
2479template< typename MT // Type of the adapted dense matrix
2480 , bool SO > // Storage order of the adapted dense matrix
2481template< typename MT2 > // Type of the right-hand side dense matrix
2482inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2483{
2484 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2485 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2486
2487 if( SO ) {
2488 for( size_t j=0UL; j<columns(); ++j )
2489 for( size_t i=0UL; i<=j; ++i )
2490 matrix_(i,j) = std::move( (*rhs)(i,j) );
2491 }
2492 else {
2493 for( size_t i=0UL; i<rows(); ++i )
2494 for( size_t j=0UL; j<=i; ++j )
2495 matrix_(i,j) = std::move( (*rhs)(i,j) );
2496 }
2497}
2499//*************************************************************************************************
2500
2501
2502//*************************************************************************************************
2514template< typename MT // Type of the adapted dense matrix
2515 , bool SO > // Storage order of the adapted dense matrix
2516template< typename MT2 > // Type of the right-hand side dense matrix
2517inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2518{
2519 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2520 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2521
2522 if( SO ) {
2523 for( size_t j=0UL; j<columns(); ++j )
2524 for( size_t i=0UL; i<=j; ++i )
2525 matrix_(i,j) = (*rhs)(i,j);
2526 }
2527 else {
2528 for( size_t i=0UL; i<rows(); ++i )
2529 for( size_t j=0UL; j<=i; ++j )
2530 matrix_(i,j) = (*rhs)(i,j);
2531 }
2532}
2534//*************************************************************************************************
2535
2536
2537//*************************************************************************************************
2549template< typename MT // Type of the adapted dense matrix
2550 , bool SO > // Storage order of the adapted dense matrix
2551template< typename MT2 > // Type of the right-hand side sparse matrix
2552inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2553{
2554 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2555 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2556
2557 if( SO ) {
2558 for( size_t j=0UL; j<columns(); ++j ) {
2559 const auto last( (*rhs).upperBound(j,j) );
2560 for( auto element=(*rhs).begin(j); element!=last; ++element )
2561 matrix_(element->index(),j) = element->value();
2562 }
2563 }
2564 else {
2565 for( size_t i=0UL; i<rows(); ++i ) {
2566 const auto last( (*rhs).upperBound(i,i) );
2567 for( auto element=(*rhs).begin(i); element!=last; ++element )
2568 matrix_(i,element->index()) = element->value();
2569 }
2570 }
2571}
2573//*************************************************************************************************
2574
2575
2576//*************************************************************************************************
2588template< typename MT // Type of the adapted dense matrix
2589 , bool SO > // Storage order of the adapted dense matrix
2590template< typename MT2 > // Type of the right-hand side dense matrix
2591inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2592{
2593 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2594 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2595
2596 if( SO ) {
2597 for( size_t j=0UL; j<columns(); ++j )
2598 for( size_t i=0UL; i<=j; ++i )
2599 matrix_(i,j) += (*rhs)(i,j);
2600 }
2601 else {
2602 for( size_t i=0UL; i<rows(); ++i )
2603 for( size_t j=0UL; j<=i; ++j )
2604 matrix_(i,j) += (*rhs)(i,j);
2605 }
2606}
2608//*************************************************************************************************
2609
2610
2611//*************************************************************************************************
2623template< typename MT // Type of the adapted dense matrix
2624 , bool SO > // Storage order of the adapted dense matrix
2625template< typename MT2 > // Type of the right-hand side sparse matrix
2626inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2627{
2628 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2629 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2630
2631 if( SO ) {
2632 for( size_t j=0UL; j<columns(); ++j ) {
2633 const auto last( (*rhs).upperBound(j,j) );
2634 for( auto element=(*rhs).begin(j); element!=last; ++element )
2635 matrix_(element->index(),j) += element->value();
2636 }
2637 }
2638 else {
2639 for( size_t i=0UL; i<rows(); ++i ) {
2640 const auto last( (*rhs).upperBound(i,i) );
2641 for( auto element=(*rhs).begin(i); element!=last; ++element )
2642 matrix_(i,element->index()) += element->value();
2643 }
2644 }
2645}
2647//*************************************************************************************************
2648
2649
2650//*************************************************************************************************
2662template< typename MT // Type of the adapted dense matrix
2663 , bool SO > // Storage order of the adapted dense matrix
2664template< typename MT2 > // Type of the right-hand side dense matrix
2665inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2666{
2667 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2668 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2669
2670 if( SO ) {
2671 for( size_t j=0UL; j<columns(); ++j )
2672 for( size_t i=0UL; i<=j; ++i )
2673 matrix_(i,j) -= (*rhs)(i,j);
2674 }
2675 else {
2676 for( size_t i=0UL; i<rows(); ++i )
2677 for( size_t j=0UL; j<=i; ++j )
2678 matrix_(i,j) -= (*rhs)(i,j);
2679 }
2680}
2682//*************************************************************************************************
2683
2684
2685//*************************************************************************************************
2697template< typename MT // Type of the adapted dense matrix
2698 , bool SO > // Storage order of the adapted dense matrix
2699template< typename MT2 > // Type of the right-hand side sparse matrix
2700inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2701{
2702 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2703 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2704
2705 if( SO ) {
2706 for( size_t j=0UL; j<columns(); ++j ) {
2707 const auto last( (*rhs).upperBound(j,j) );
2708 for( auto element=(*rhs).begin(j); element!=last; ++element )
2709 matrix_(element->index(),j) -= element->value();
2710 }
2711 }
2712 else {
2713 for( size_t i=0UL; i<rows(); ++i ) {
2714 const auto last( (*rhs).upperBound(i,i) );
2715 for( auto element=(*rhs).begin(i); element!=last; ++element )
2716 matrix_(i,element->index()) -= element->value();
2717 }
2718 }
2719}
2721//*************************************************************************************************
2722
2723
2724//*************************************************************************************************
2736template< typename MT // Type of the adapted dense matrix
2737 , bool SO > // Storage order of the adapted dense matrix
2738template< typename MT2 > // Type of the right-hand side dense matrix
2739inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const DenseMatrix<MT2,SO>& rhs )
2740{
2741 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2742 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2743
2744 if( SO ) {
2745 for( size_t j=0UL; j<columns(); ++j )
2746 for( size_t i=0UL; i<=j; ++i )
2747 matrix_(i,j) *= (*rhs)(i,j);
2748 }
2749 else {
2750 for( size_t i=0UL; i<rows(); ++i )
2751 for( size_t j=0UL; j<=i; ++j )
2752 matrix_(i,j) *= (*rhs)(i,j);
2753 }
2754}
2756//*************************************************************************************************
2757
2758
2759//*************************************************************************************************
2771template< typename MT // Type of the adapted dense matrix
2772 , bool SO > // Storage order of the adapted dense matrix
2773template< typename MT2 > // Type of the right-hand side sparse matrix
2774inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const SparseMatrix<MT2,SO>& rhs )
2775{
2776 BLAZE_INTERNAL_ASSERT( rows() == (*rhs).rows() , "Invalid number of rows" );
2777 BLAZE_INTERNAL_ASSERT( columns() == (*rhs).columns(), "Invalid number of columns" );
2778
2779 if( SO ) {
2780 for( size_t j=0UL; j<columns(); ++j )
2781 {
2782 size_t i( 0UL );
2783
2784 const auto last( (*rhs).upperBound(j,j) );
2785 for( auto element=(*rhs).begin(j); element!=last; ++element ) {
2786 for( ; i<element->index(); ++i )
2787 reset( matrix_(i,j) );
2788 matrix_(i,j) *= element->value();
2789 ++i;
2790 }
2791
2792 for( ; i<rows(); ++i ) {
2793 reset( matrix_(i,j) );
2794 }
2795 }
2796 }
2797 else {
2798 for( size_t i=0UL; i<rows(); ++i )
2799 {
2800 size_t j( 0UL );
2801
2802 const auto last( (*rhs).upperBound(i,i) );
2803 for( auto element=(*rhs).begin(i); element!=last; ++element ) {
2804 for( ; j<element->index(); ++j )
2805 reset( matrix_(i,j) );
2806 matrix_(i,j) *= element->value();
2807 ++j;
2808 }
2809
2810 for( ; j<columns(); ++j ) {
2811 reset( matrix_(i,j) );
2812 }
2813 }
2814 }
2815}
2817//*************************************************************************************************
2818
2819} // namespace blaze
2820
2821#endif
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for the conjugate shim.
Constraint on the data type.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:751
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:719
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the If class template.
Header file for the IsComputation type trait class.
Header file for the IsCustom type trait.
Header file for the isDefault shim.
Header file for the IsSMPAssignable type trait.
Header file for the IsScalar type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsSquare type trait.
Header file for the IsSymmetric type trait.
Constraint on the data type.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Constraint on the data type.
Header file for the RemoveAdaptor type trait.
Header file for the RemoveReference type trait.
Constraint on the data type.
Constraint on the data type.
Compile time assertion.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the base template of the SymmetricMatrix.
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for utility functions for dense matrices.
Header file for the DenseMatrix base class.
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
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:574
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1921
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:182
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:386
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:510
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:265
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1456
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9640
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:448
bool isZero(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a zero matrix.
Definition: DenseMatrix.h:1819
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:2188
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:225
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:143
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#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_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#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_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition: Resizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:118
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.
Definition: Size.h:176
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.
Definition: IsComputation.h:90
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
constexpr 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:446
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
constexpr bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:408
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:628
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:584
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:1221
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:1195
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:1169
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the Size type trait.
Header file for the clear shim.
Header file for the isZero shim.
Header file for basic type definitions.
Header file for the implementation of the Submatrix view.