35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 105 template<
typename MT
107 class SymmetricMatrix<MT,SO,true,false>
108 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
112 using OT = OppositeType_<MT>;
113 using TT = TransposeType_<MT>;
114 using ET = ElementType_<MT>;
119 using This = SymmetricMatrix<MT,SO,true,false>;
120 using BaseType = DenseMatrix<This,SO>;
122 using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
129 using Pointer = Pointer_<MT>;
130 using ConstPointer = ConstPointer_<MT>;
136 template<
typename NewType >
139 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
146 template<
size_t NewM
150 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
157 template<
typename MatrixType >
163 using Reference = If_< IsConst<MatrixType>
164 , ConstReference_<MatrixType>
165 , Reference_<MatrixType> >;
167 using IteratorCategory = std::random_access_iterator_tag;
168 using ValueType = RemoveReference_<Reference>;
169 using PointerType = ValueType*;
171 using DifferenceType = ptrdiff_t;
174 using iterator_category = IteratorCategory;
175 using value_type = ValueType;
176 using pointer = PointerType;
177 using reference = ReferenceType;
178 using difference_type = DifferenceType;
184 inline MatrixIterator() noexcept
198 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
210 template<
typename MatrixType2 >
211 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it ) noexcept
212 : matrix_( it.matrix_ )
214 , column_( it.column_ )
224 inline MatrixIterator&
operator+=(
size_t inc ) noexcept {
225 ( SO )?( row_ += inc ):( column_ += inc );
236 inline MatrixIterator&
operator-=(
size_t dec ) noexcept {
237 ( SO )?( row_ -= dec ):( column_ -= dec );
247 inline MatrixIterator& operator++() noexcept {
248 ( SO )?( ++row_ ):( ++column_ );
258 inline const MatrixIterator operator++(
int ) noexcept {
259 const MatrixIterator tmp( *
this );
270 inline MatrixIterator& operator--() noexcept {
271 ( SO )?( --row_ ):( --column_ );
281 inline const MatrixIterator operator--(
int ) noexcept {
282 const MatrixIterator tmp( *
this );
294 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
295 return (*matrix_)(row_,column_);
297 return (*matrix_)(column_,row_);
306 inline PointerType operator->()
const {
307 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
308 return &(*matrix_)(row_,column_);
310 return &(*matrix_)(column_,row_);
320 template<
typename MatrixType2 >
321 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
322 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
332 template<
typename MatrixType2 >
333 inline bool operator!=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
334 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
344 template<
typename MatrixType2 >
345 inline bool operator<( const MatrixIterator<MatrixType2>& rhs )
const noexcept {
346 return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
347 return ( column_ < rhs.column_ );
357 template<
typename MatrixType2 >
358 inline bool operator>(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
359 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
360 return ( column_ > rhs.column_ );
370 template<
typename MatrixType2 >
371 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs )
const noexcept {
372 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
382 template<
typename MatrixType2 >
383 inline bool operator>=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
384 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
394 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const noexcept {
395 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
406 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) noexcept {
408 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
410 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
421 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) noexcept {
423 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
425 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
436 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) noexcept {
438 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
440 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
452 template<
typename MatrixType2 >
friend class MatrixIterator;
458 using Iterator = MatrixIterator<MT>;
464 enum :
bool { simdEnabled =
false };
467 enum :
bool { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
473 explicit inline SymmetricMatrix();
474 explicit inline SymmetricMatrix(
size_t n );
476 explicit inline SymmetricMatrix(
ElementType* ptr,
size_t n );
477 explicit inline SymmetricMatrix(
ElementType* ptr,
size_t n,
size_t nn );
479 inline SymmetricMatrix(
const SymmetricMatrix& m );
480 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
482 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
483 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
494 inline Reference operator()(
size_t i,
size_t j );
496 inline Reference at(
size_t i,
size_t j );
498 inline ConstPointer
data () const noexcept;
499 inline ConstPointer
data (
size_t i ) const noexcept;
512 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
513 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
515 template< typename MT2 >
516 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
518 template< typename MT2 >
519 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
521 template< typename MT2 >
522 inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
524 template< typename MT2 >
525 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
527 template< typename MT2 >
528 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
530 template< typename MT2 >
531 inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
533 template< typename MT2 >
534 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
536 template< typename MT2 >
537 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
539 template< typename MT2 >
540 inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
542 template< typename MT2 >
543 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator%=( const Matrix<MT2,SO>& rhs );
545 template< typename MT2 >
546 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator%=( const Matrix<MT2,SO>& rhs );
548 template< typename MT2 >
549 inline SymmetricMatrix& operator%=( const Matrix<MT2,!SO>& rhs );
551 template< typename ST >
552 inline
EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator*=( ST rhs );
554 template< typename ST >
555 inline
EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator/=( ST rhs );
562 inline
size_t rows() const noexcept;
563 inline
size_t columns() const noexcept;
564 inline
size_t spacing() const noexcept;
565 inline
size_t capacity() const noexcept;
566 inline
size_t capacity(
size_t i ) const noexcept;
568 inline
size_t nonZeros(
size_t i ) const;
570 inline
void reset(
size_t i );
572 void resize (
size_t n,
bool preserve=true );
573 inline
void extend (
size_t n,
bool preserve=true );
574 inline
void reserve(
size_t elements );
576 inline
void swap( SymmetricMatrix& m ) noexcept;
586 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
593 inline
bool isIntact() const noexcept;
600 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
601 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
603 inline
bool isAligned () const noexcept;
604 inline
bool canSMPAssign() const noexcept;
612 template< typename MT2 > inline
void assign ( DenseMatrix <MT2,SO>& rhs );
613 template< typename MT2 > inline
void assign ( const DenseMatrix <MT2,SO>& rhs );
614 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,SO>& rhs );
615 template< typename MT2 > inline
void addAssign ( const DenseMatrix <MT2,SO>& rhs );
616 template< typename MT2 > inline
void addAssign ( const SparseMatrix<MT2,SO>& rhs );
617 template< typename MT2 > inline
void subAssign ( const DenseMatrix <MT2,SO>& rhs );
618 template< typename MT2 > inline
void subAssign ( const SparseMatrix<MT2,SO>& rhs );
619 template< typename MT2 > inline
void schurAssign( const DenseMatrix <MT2,SO>& rhs );
620 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,SO>& rhs );
632 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
633 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
669 template< typename MT
671 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
686 template<
typename MT
688 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
733 template<
typename MT
735 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
736 : matrix_( ptr, n, n )
784 template<
typename MT
786 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
787 : matrix_( ptr, n, n, nn )
805 template<
typename MT
807 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
808 : matrix_( m.matrix_ )
823 template<
typename MT
825 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
826 : matrix_( std::move( m.matrix_ ) )
845 template<
typename MT
847 template<
typename MT2 >
848 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
853 using RT = RemoveAdaptor_<ResultType_<MT2> >;
854 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
856 if( IsSymmetric<MT2>::value ) {
867 resize( matrix_, tmp.rows(), tmp.rows() );
888 template<
typename MT
890 template<
typename MT2 >
891 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
896 using RT = RemoveAdaptor_< ResultType_<MT2> >;
897 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
899 if( IsSymmetric<MT2>::value ) {
901 assign(
trans( ~m ) );
910 resize( matrix_, tmp.rows(), tmp.rows() );
911 assign(
trans( tmp ) );
944 template<
typename MT
947 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
952 if( ( !SO && i > j ) || ( SO && i < j ) )
976 template<
typename MT
979 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const 984 if( ( !SO && i > j ) || ( SO && i < j ) )
1009 template<
typename MT
1012 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1020 return (*
this)(i,j);
1042 template<
typename MT
1045 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const 1053 return (*
this)(i,j);
1073 template<
typename MT
1075 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1078 return matrix_.data();
1095 template<
typename MT
1097 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1100 return matrix_.data(i);
1118 template<
typename MT
1124 return Iterator( matrix_, 0UL, i );
1126 return Iterator( matrix_, i, 0UL );
1144 template<
typename MT
1170 template<
typename MT
1196 template<
typename MT
1222 template<
typename MT
1248 template<
typename MT
1280 template<
typename MT
1282 inline SymmetricMatrix<MT,SO,true,false>&
1283 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1287 if( &rhs ==
this )
return *
this;
1289 resize( matrix_, rhs.rows(), rhs.columns() );
1308 template<
typename MT
1310 inline SymmetricMatrix<MT,SO,true,false>&
1311 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1313 matrix_ = std::move( rhs.matrix_ );
1338 template<
typename MT
1340 template<
typename MT2 >
1341 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1342 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1346 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1350 if( (~rhs).isAliased(
this ) ) {
1351 SymmetricMatrix tmp( ~rhs );
1356 if( IsSparseMatrix<MT2>::value )
1384 template<
typename MT
1386 template<
typename MT2 >
1387 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1388 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1392 using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1394 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1400 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1406 resize( matrix_, tmp.rows(), tmp.columns() );
1407 if( IsSparseMatrix<Tmp>::value )
1434 template<
typename MT
1436 template<
typename MT2 >
1437 inline SymmetricMatrix<MT,SO,true,false>&
1438 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1440 return this->operator=(
trans( ~rhs ) );
1459 template<
typename MT
1461 template<
typename MT2 >
1462 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1465 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1493 template<
typename MT
1495 template<
typename MT2 >
1496 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1499 using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1501 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1507 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1538 template<
typename MT
1540 template<
typename MT2 >
1541 inline SymmetricMatrix<MT,SO,true,false>&
1563 template<
typename MT
1565 template<
typename MT2 >
1566 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1569 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1597 template<
typename MT
1599 template<
typename MT2 >
1600 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1603 using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1605 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1611 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1642 template<
typename MT
1644 template<
typename MT2 >
1645 inline SymmetricMatrix<MT,SO,true,false>&
1668 template<
typename MT
1670 template<
typename MT2 >
1671 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1672 SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1674 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1678 schurAssign( ~rhs );
1703 template<
typename MT
1705 template<
typename MT2 >
1706 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1707 SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1709 using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1711 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1717 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1748 template<
typename MT
1750 template<
typename MT2 >
1751 inline SymmetricMatrix<MT,SO,true,false>&
1752 SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1754 return this->operator%=(
trans( ~rhs ) );
1768 template<
typename MT
1770 template<
typename ST >
1771 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,true,false> >&
1775 for(
size_t j=0UL; j<
columns(); ++j )
1776 for(
size_t i=0UL; i<=j; ++i )
1777 matrix_(i,j) *= rhs;
1780 for(
size_t i=0UL; i<
rows(); ++i )
1781 for(
size_t j=0UL; j<=i; ++j )
1782 matrix_(i,j) *= rhs;
1799 template<
typename MT
1801 template<
typename ST >
1802 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,true,false> >&
1808 for(
size_t j=0UL; j<
columns(); ++j )
1809 for(
size_t i=0UL; i<=j; ++i )
1810 matrix_(i,j) /= rhs;
1813 for(
size_t i=0UL; i<
rows(); ++i )
1814 for(
size_t j=0UL; j<=i; ++j )
1815 matrix_(i,j) /= rhs;
1838 template<
typename MT
1842 return matrix_.rows();
1854 template<
typename MT
1858 return matrix_.columns();
1876 template<
typename MT
1880 return matrix_.spacing();
1892 template<
typename MT
1896 return matrix_.capacity();
1913 template<
typename MT
1917 return matrix_.capacity(i);
1929 template<
typename MT
1933 size_t nonzeros( 0UL );
1937 for(
size_t j=0UL; j<
columns(); ++j ) {
1938 for(
size_t i=0UL; i<j; ++i ) {
1948 for(
size_t i=0UL; i<
rows(); ++i ) {
1949 for(
size_t j=0UL; j<i; ++j ) {
1976 template<
typename MT
1980 size_t nonzeros( 0UL );
1984 for(
size_t j=0UL; j<i; ++j ) {
1988 for(
size_t j=i; j<
rows(); ++j ) {
1995 for(
size_t j=0UL; j<i; ++j ) {
1999 for(
size_t j=i; j<
rows(); ++j ) {
2017 template<
typename MT
2024 for(
size_t j=0UL; j<
columns(); ++j )
2025 for(
size_t i=0UL; i<=j; ++i )
2026 clear( matrix_(i,j) );
2029 for(
size_t i=0UL; i<
rows(); ++i )
2030 for(
size_t j=0UL; j<=i; ++j )
2031 clear( matrix_(i,j) );
2078 template<
typename MT
2103 template<
typename MT
2131 template<
typename MT
2141 const size_t oldsize( matrix_.rows() );
2143 matrix_.resize( n, n,
true );
2146 const size_t increment( n - oldsize );
2147 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2148 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2168 template<
typename MT
2170 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2192 template<
typename MT
2194 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2196 matrix_.reserve( elements );
2212 template<
typename MT
2216 matrix_.shrinkToFit();
2229 template<
typename MT
2235 swap( matrix_, m.matrix_ );
2255 template<
typename MT
2271 template<
typename MT
2276 for(
size_t j=0UL; j<
columns(); ++j )
2277 for(
size_t i=0UL; i<=j; ++i )
2281 for(
size_t i=0UL; i<
rows(); ++i )
2282 for(
size_t j=0UL; j<=i; ++j )
2310 template<
typename MT
2312 template<
typename Other >
2313 inline SymmetricMatrix<MT,SO,true,false>&
2314 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2317 for(
size_t j=0UL; j<
columns(); ++j )
2318 for(
size_t i=0UL; i<=j; ++i )
2319 matrix_(i,j) *= scalar;
2322 for(
size_t i=0UL; i<
rows(); ++i )
2323 for(
size_t j=0UL; j<=i; ++j )
2324 matrix_(i,j) *= scalar;
2351 template<
typename MT
2358 ( IsCustom<MT>::value || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2383 template<
typename MT
2385 template<
typename Other >
2386 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2388 return matrix_.canAlias( alias );
2405 template<
typename MT
2407 template<
typename Other >
2408 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2410 return matrix_.isAliased( alias );
2426 template<
typename MT
2428 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2430 return matrix_.isAligned();
2447 template<
typename MT
2449 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2451 return matrix_.canSMPAssign();
2469 template<
typename MT
2471 template<
typename MT2 >
2472 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2478 for(
size_t j=0UL; j<
columns(); ++j )
2479 for(
size_t i=0UL; i<=j; ++i )
2480 matrix_(i,j) = std::move( (~rhs)(i,j) );
2483 for(
size_t i=0UL; i<
rows(); ++i )
2484 for(
size_t j=0UL; j<=i; ++j )
2485 matrix_(i,j) = std::move( (~rhs)(i,j) );
2504 template<
typename MT
2506 template<
typename MT2 >
2507 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2513 for(
size_t j=0UL; j<
columns(); ++j )
2514 for(
size_t i=0UL; i<=j; ++i )
2515 matrix_(i,j) = (~rhs)(i,j);
2518 for(
size_t i=0UL; i<
rows(); ++i )
2519 for(
size_t j=0UL; j<=i; ++j )
2520 matrix_(i,j) = (~rhs)(i,j);
2539 template<
typename MT
2541 template<
typename MT2 >
2542 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2547 using RhsIterator = ConstIterator_<MT2>;
2550 for(
size_t j=0UL; j<
columns(); ++j ) {
2551 const RhsIterator last( (~rhs).upperBound(j,j) );
2552 for( RhsIterator element=(~rhs).
begin(j); element!=last; ++element )
2553 matrix_(element->index(),j) = element->value();
2557 for(
size_t i=0UL; i<
rows(); ++i ) {
2558 const RhsIterator last( (~rhs).upperBound(i,i) );
2559 for( RhsIterator element=(~rhs).
begin(i); element!=last; ++element )
2560 matrix_(i,element->index()) = element->value();
2580 template<
typename MT
2582 template<
typename MT2 >
2583 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
2589 for(
size_t j=0UL; j<
columns(); ++j )
2590 for(
size_t i=0UL; i<=j; ++i )
2591 matrix_(i,j) += (~rhs)(i,j);
2594 for(
size_t i=0UL; i<
rows(); ++i )
2595 for(
size_t j=0UL; j<=i; ++j )
2596 matrix_(i,j) += (~rhs)(i,j);
2615 template<
typename MT
2617 template<
typename MT2 >
2618 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
2623 using RhsIterator = ConstIterator_<MT2>;
2626 for(
size_t j=0UL; j<
columns(); ++j ) {
2627 const RhsIterator last( (~rhs).upperBound(j,j) );
2628 for( RhsIterator element=(~rhs).
begin(j); element!=last; ++element )
2629 matrix_(element->index(),j) += element->value();
2633 for(
size_t i=0UL; i<
rows(); ++i ) {
2634 const RhsIterator last( (~rhs).upperBound(i,i) );
2635 for( RhsIterator element=(~rhs).
begin(i); element!=last; ++element )
2636 matrix_(i,element->index()) += element->value();
2656 template<
typename MT
2658 template<
typename MT2 >
2659 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
2665 for(
size_t j=0UL; j<
columns(); ++j )
2666 for(
size_t i=0UL; i<=j; ++i )
2667 matrix_(i,j) -= (~rhs)(i,j);
2670 for(
size_t i=0UL; i<
rows(); ++i )
2671 for(
size_t j=0UL; j<=i; ++j )
2672 matrix_(i,j) -= (~rhs)(i,j);
2691 template<
typename MT
2693 template<
typename MT2 >
2694 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
2699 using RhsIterator = ConstIterator_<MT2>;
2702 for(
size_t j=0UL; j<
columns(); ++j ) {
2703 const RhsIterator last( (~rhs).upperBound(j,j) );
2704 for( RhsIterator element=(~rhs).
begin(j); element!=last; ++element )
2705 matrix_(element->index(),j) -= element->value();
2709 for(
size_t i=0UL; i<
rows(); ++i ) {
2710 const RhsIterator last( (~rhs).upperBound(i,i) );
2711 for( RhsIterator element=(~rhs).
begin(i); element!=last; ++element )
2712 matrix_(i,element->index()) -= element->value();
2732 template<
typename MT
2734 template<
typename MT2 >
2735 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const DenseMatrix<MT2,SO>& rhs )
2741 for(
size_t j=0UL; j<
columns(); ++j )
2742 for(
size_t i=0UL; i<=j; ++i )
2743 matrix_(i,j) *= (~rhs)(i,j);
2746 for(
size_t i=0UL; i<
rows(); ++i )
2747 for(
size_t j=0UL; j<=i; ++j )
2748 matrix_(i,j) *= (~rhs)(i,j);
2767 template<
typename MT
2769 template<
typename MT2 >
2770 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const SparseMatrix<MT2,SO>& rhs )
2775 using RhsIterator = ConstIterator_<MT2>;
2778 for(
size_t j=0UL; j<
columns(); ++j )
2782 const RhsIterator last( (~rhs).upperBound(j,j) );
2783 for( RhsIterator element=(~rhs).
begin(j); element!=last; ++element ) {
2784 for( ; i<element->index(); ++i )
2785 reset( matrix_(i,j) );
2786 matrix_(i,j) *= element->value();
2790 for( ; i<
rows(); ++i ) {
2791 reset( matrix_(i,j) );
2796 for(
size_t i=0UL; i<
rows(); ++i )
2800 const RhsIterator last( (~rhs).upperBound(i,i) );
2801 for( RhsIterator element=(~rhs).
begin(i); element!=last; ++element ) {
2802 for( ; j<element->index(); ++j )
2803 reset( matrix_(i,j) );
2804 matrix_(i,j) *= element->value();
2809 reset( matrix_(i,j) );
Header file for the implementation of the Submatrix view.
#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:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1214
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1469
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
Header file for the IsSparseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
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:701
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:827
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#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:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
Constraint on the data type.
BLAZE_ALWAYS_INLINE 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:474
BLAZE_ALWAYS_INLINE 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:408
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Header file for the If class template.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5891
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#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:79
Header file for the IsSMPAssignable type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
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:367
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:443
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Constraints on the storage order of matrix types.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:134
Header file for the exception macros of the math module.
#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:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is a numeric (integral or floating point) d...
Definition: Numeric.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:714
BLAZE_ALWAYS_INLINE 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:430
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:8893
Header file for the RemoveAdaptor type trait.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Header file for all forward declarations for expression class templates.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
#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:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
#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:81
#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:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric< T >::value)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:841
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
#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:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801