35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 106 template<
typename MT
108 class SymmetricMatrix<MT,SO,true,false>
109 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
113 using OT = OppositeType_t<MT>;
114 using TT = TransposeType_t<MT>;
115 using ET = ElementType_t<MT>;
120 using This = SymmetricMatrix<MT,SO,true,false>;
121 using BaseType = DenseMatrix<This,SO>;
122 using ResultType = This;
123 using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
124 using TransposeType = SymmetricMatrix<TT,!SO,true,false>;
125 using ElementType = ET;
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>;
137 template<
typename NewType >
140 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
147 template<
size_t NewM
151 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
158 template<
typename MatrixType >
164 using Reference = If_t< IsConst_v<MatrixType>
165 , ConstReference_t<MatrixType>
166 , Reference_t<MatrixType> >;
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;
175 using iterator_category = IteratorCategory;
176 using value_type = ValueType;
177 using pointer = PointerType;
178 using reference = ReferenceType;
179 using difference_type = DifferenceType;
185 inline MatrixIterator() noexcept
199 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
211 template<
typename MatrixType2 >
212 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it ) noexcept
213 : matrix_( it.matrix_ )
215 , column_( it.column_ )
225 inline MatrixIterator&
operator+=(
size_t inc ) noexcept {
226 ( SO )?( row_ += inc ):( column_ += inc );
237 inline MatrixIterator&
operator-=(
size_t dec ) noexcept {
238 ( SO )?( row_ -= dec ):( column_ -= dec );
248 inline MatrixIterator& operator++() noexcept {
249 ( SO )?( ++row_ ):( ++column_ );
259 inline const MatrixIterator operator++(
int ) noexcept {
260 const MatrixIterator tmp( *
this );
271 inline MatrixIterator& operator--() noexcept {
272 ( SO )?( --row_ ):( --column_ );
282 inline const MatrixIterator operator--(
int ) noexcept {
283 const MatrixIterator tmp( *
this );
295 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
296 return (*matrix_)(row_,column_);
298 return (*matrix_)(column_,row_);
307 inline PointerType operator->()
const {
308 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
309 return &(*matrix_)(row_,column_);
311 return &(*matrix_)(column_,row_);
321 template<
typename MatrixType2 >
322 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
323 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
333 template<
typename MatrixType2 >
334 inline bool operator!=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
335 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
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_ );
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_ );
371 template<
typename MatrixType2 >
372 inline bool operator<=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
373 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
383 template<
typename MatrixType2 >
384 inline bool operator>=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
385 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
395 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const noexcept {
396 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
407 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) noexcept {
409 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
411 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
422 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) noexcept {
424 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
426 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
437 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) noexcept {
439 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
441 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
453 template<
typename MatrixType2 >
friend class MatrixIterator;
459 using Iterator = MatrixIterator<MT>;
460 using ConstIterator = MatrixIterator<const MT>;
465 static constexpr
bool simdEnabled =
false;
468 static constexpr
bool smpAssignable = ( MT::smpAssignable && !IsSMPAssignable_v<ET> );
474 explicit inline SymmetricMatrix();
475 explicit inline SymmetricMatrix(
size_t n );
477 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n );
478 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn );
480 inline SymmetricMatrix(
const SymmetricMatrix& m );
481 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
483 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
484 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
491 ~SymmetricMatrix() =
default;
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;
516 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
517 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
519 template< typename MT2 >
520 inline auto operator=( const Matrix<MT2,SO>& rhs )
523 template< typename MT2 >
524 inline auto operator=( const Matrix<MT2,SO>& rhs )
527 template< typename MT2 >
528 inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
530 template< typename MT2 >
531 inline auto operator+=( const Matrix<MT2,SO>& rhs )
534 template< typename MT2 >
535 inline auto operator+=( const Matrix<MT2,SO>& rhs )
538 template< typename MT2 >
539 inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
541 template< typename MT2 >
542 inline auto operator-=( const Matrix<MT2,SO>& rhs )
545 template< typename MT2 >
546 inline auto operator-=( const Matrix<MT2,SO>& rhs )
549 template< typename MT2 >
550 inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
552 template< typename MT2 >
553 inline auto operator%=( const Matrix<MT2,SO>& rhs )
556 template< typename MT2 >
557 inline auto operator%=( const Matrix<MT2,SO>& rhs )
560 template< typename MT2 >
561 inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
563 template< typename ST >
566 template< typename ST >
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;
580 inline
size_t nonZeros(
size_t i ) const;
582 inline
void reset(
size_t i );
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 );
588 inline
void swap( SymmetricMatrix& m ) noexcept;
598 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
605 inline
bool isIntact() const noexcept;
612 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
613 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
615 inline
bool isAligned () const noexcept;
616 inline
bool canSMPAssign() const noexcept;
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 );
644 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
645 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
683 template< typename MT
685 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
700 template<
typename MT
702 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
747 template<
typename MT
749 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
750 : matrix_( ptr, n, n )
798 template<
typename MT
800 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
801 : matrix_( ptr, n, n, nn )
819 template<
typename MT
821 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
822 : matrix_( m.matrix_ )
837 template<
typename MT
839 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
840 : matrix_( std::move( m.matrix_ ) )
859 template<
typename MT
861 template<
typename MT2 >
862 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
867 using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
868 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
870 if( IsSymmetric_v<MT2> ) {
881 resize( matrix_, tmp.rows(), tmp.rows() );
902 template<
typename MT
904 template<
typename MT2 >
905 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
910 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
911 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
913 if( IsSymmetric_v<MT2> ) {
915 assign(
trans( ~m ) );
924 resize( matrix_, tmp.rows(), tmp.rows() );
925 assign(
trans( tmp ) );
958 template<
typename MT
960 inline typename SymmetricMatrix<MT,SO,true,false>::Reference
961 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
966 if( ( !SO && i > j ) || ( SO && i < j ) )
990 template<
typename MT
992 inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
993 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const 998 if( ( !SO && i > j ) || ( SO && i < j ) )
1001 return matrix_(j,i);
1023 template<
typename MT
1025 inline typename SymmetricMatrix<MT,SO,true,false>::Reference
1026 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1034 return (*
this)(i,j);
1056 template<
typename MT
1058 inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
1059 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const 1067 return (*
this)(i,j);
1087 template<
typename MT
1089 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1092 return matrix_.data();
1109 template<
typename MT
1111 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1114 return matrix_.data(i);
1132 template<
typename MT
1134 inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1138 return Iterator( matrix_, 0UL, i );
1140 return Iterator( matrix_, i, 0UL );
1158 template<
typename MT
1160 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1164 return ConstIterator( matrix_, 0UL, i );
1166 return ConstIterator( matrix_, i, 0UL );
1184 template<
typename MT
1186 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1190 return ConstIterator( matrix_, 0UL, i );
1192 return ConstIterator( matrix_, i, 0UL );
1210 template<
typename MT
1212 inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1216 return Iterator( matrix_,
rows(), i );
1218 return Iterator( matrix_, i,
columns() );
1236 template<
typename MT
1238 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1242 return ConstIterator( matrix_,
rows(), i );
1244 return ConstIterator( matrix_, i,
columns() );
1262 template<
typename MT
1264 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1268 return ConstIterator( matrix_,
rows(), i );
1270 return ConstIterator( matrix_, i,
columns() );
1294 template<
typename MT
1296 inline SymmetricMatrix<MT,SO,true,false>&
1297 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1301 if( &rhs ==
this )
return *
this;
1303 resize( matrix_, rhs.rows(), rhs.columns() );
1322 template<
typename MT
1324 inline SymmetricMatrix<MT,SO,true,false>&
1325 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1327 matrix_ = std::move( rhs.matrix_ );
1352 template<
typename MT
1354 template<
typename MT2 >
1355 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1356 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1360 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1364 if( (~rhs).isAliased(
this ) ) {
1365 SymmetricMatrix tmp( ~rhs );
1370 if( IsSparseMatrix_v<MT2> )
1398 template<
typename MT
1400 template<
typename MT2 >
1401 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1402 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1406 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1408 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1414 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1420 resize( matrix_, tmp.rows(), tmp.columns() );
1421 if( IsSparseMatrix_v<Tmp> )
1448 template<
typename MT
1450 template<
typename MT2 >
1451 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1454 return this->operator=(
trans( ~rhs ) );
1473 template<
typename MT
1475 template<
typename MT2 >
1477 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1479 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1507 template<
typename MT
1509 template<
typename MT2 >
1511 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1513 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1515 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1521 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1552 template<
typename MT
1554 template<
typename MT2 >
1577 template<
typename MT
1579 template<
typename MT2 >
1581 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1583 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1611 template<
typename MT
1613 template<
typename MT2 >
1615 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1617 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1619 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1625 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1656 template<
typename MT
1658 template<
typename MT2 >
1682 template<
typename MT
1684 template<
typename MT2 >
1685 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1686 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1688 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1692 schurAssign( ~rhs );
1717 template<
typename MT
1719 template<
typename MT2 >
1720 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1721 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1723 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1725 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1731 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1762 template<
typename MT
1764 template<
typename MT2 >
1765 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1768 return this->operator%=(
trans( ~rhs ) );
1782 template<
typename MT
1784 template<
typename ST >
1786 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1789 for(
size_t j=0UL; j<
columns(); ++j )
1790 for(
size_t i=0UL; i<=j; ++i )
1791 matrix_(i,j) *= rhs;
1794 for(
size_t i=0UL; i<
rows(); ++i )
1795 for(
size_t j=0UL; j<=i; ++j )
1796 matrix_(i,j) *= rhs;
1813 template<
typename MT
1815 template<
typename ST >
1817 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1822 for(
size_t j=0UL; j<
columns(); ++j )
1823 for(
size_t i=0UL; i<=j; ++i )
1824 matrix_(i,j) /= rhs;
1827 for(
size_t i=0UL; i<
rows(); ++i )
1828 for(
size_t j=0UL; j<=i; ++j )
1829 matrix_(i,j) /= rhs;
1852 template<
typename MT
1856 return matrix_.rows();
1868 template<
typename MT
1872 return matrix_.columns();
1890 template<
typename MT
1894 return matrix_.spacing();
1906 template<
typename MT
1910 return matrix_.capacity();
1927 template<
typename MT
1931 return matrix_.capacity(i);
1943 template<
typename MT
1947 size_t nonzeros( 0UL );
1951 for(
size_t j=0UL; j<
columns(); ++j ) {
1952 for(
size_t i=0UL; i<j; ++i ) {
1962 for(
size_t i=0UL; i<
rows(); ++i ) {
1963 for(
size_t j=0UL; j<i; ++j ) {
1990 template<
typename MT
1994 size_t nonzeros( 0UL );
1998 for(
size_t j=0UL; j<i; ++j ) {
2002 for(
size_t j=i; j<
rows(); ++j ) {
2009 for(
size_t j=0UL; j<i; ++j ) {
2013 for(
size_t j=i; j<
rows(); ++j ) {
2031 template<
typename MT
2038 for(
size_t j=0UL; j<
columns(); ++j )
2039 for(
size_t i=0UL; i<=j; ++i )
2040 clear( matrix_(i,j) );
2043 for(
size_t i=0UL; i<
rows(); ++i )
2044 for(
size_t j=0UL; j<=i; ++j )
2045 clear( matrix_(i,j) );
2092 template<
typename MT
2098 for(
auto element=
begin(i); element!=
end(i); ++element )
2117 template<
typename MT
2145 template<
typename MT
2155 const size_t oldsize( matrix_.rows() );
2157 matrix_.resize( n, n,
true );
2160 const size_t increment( n - oldsize );
2161 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2162 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2182 template<
typename MT
2184 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2206 template<
typename MT
2208 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2226 template<
typename MT
2230 matrix_.shrinkToFit();
2243 template<
typename MT
2249 swap( matrix_, m.matrix_ );
2269 template<
typename MT
2285 template<
typename MT
2290 for(
size_t j=0UL; j<
columns(); ++j )
2291 for(
size_t i=0UL; i<=j; ++i )
2295 for(
size_t i=0UL; i<
rows(); ++i )
2296 for(
size_t j=0UL; j<=i; ++j )
2324 template<
typename MT
2326 template<
typename Other >
2327 inline SymmetricMatrix<MT,SO,true,false>&
2328 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2331 for(
size_t j=0UL; j<
columns(); ++j )
2332 for(
size_t i=0UL; i<=j; ++i )
2333 matrix_(i,j) *= scalar;
2336 for(
size_t i=0UL; i<
rows(); ++i )
2337 for(
size_t j=0UL; j<=i; ++j )
2338 matrix_(i,j) *= scalar;
2365 template<
typename MT
2372 ( IsCustom_v<MT> || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2397 template<
typename MT
2399 template<
typename Other >
2400 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2402 return matrix_.canAlias( alias );
2419 template<
typename MT
2421 template<
typename Other >
2422 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2424 return matrix_.isAliased( alias );
2440 template<
typename MT
2442 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2444 return matrix_.isAligned();
2461 template<
typename MT
2463 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2465 return matrix_.canSMPAssign();
2483 template<
typename MT
2485 template<
typename MT2 >
2486 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2492 for(
size_t j=0UL; j<
columns(); ++j )
2493 for(
size_t i=0UL; i<=j; ++i )
2494 matrix_(i,j) = std::move( (~rhs)(i,j) );
2497 for(
size_t i=0UL; i<
rows(); ++i )
2498 for(
size_t j=0UL; j<=i; ++j )
2499 matrix_(i,j) = std::move( (~rhs)(i,j) );
2518 template<
typename MT
2520 template<
typename MT2 >
2521 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2527 for(
size_t j=0UL; j<
columns(); ++j )
2528 for(
size_t i=0UL; i<=j; ++i )
2529 matrix_(i,j) = (~rhs)(i,j);
2532 for(
size_t i=0UL; i<
rows(); ++i )
2533 for(
size_t j=0UL; j<=i; ++j )
2534 matrix_(i,j) = (~rhs)(i,j);
2553 template<
typename MT
2555 template<
typename MT2 >
2556 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2562 for(
size_t j=0UL; j<
columns(); ++j ) {
2563 const auto last( (~rhs).upperBound(j,j) );
2564 for(
auto element=(~rhs).
begin(j); element!=last; ++element )
2565 matrix_(element->index(),j) = element->value();
2569 for(
size_t i=0UL; i<
rows(); ++i ) {
2570 const auto last( (~rhs).upperBound(i,i) );
2571 for(
auto element=(~rhs).
begin(i); element!=last; ++element )
2572 matrix_(i,element->index()) = element->value();
2592 template<
typename MT
2594 template<
typename MT2 >
2595 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
2601 for(
size_t j=0UL; j<
columns(); ++j )
2602 for(
size_t i=0UL; i<=j; ++i )
2603 matrix_(i,j) += (~rhs)(i,j);
2606 for(
size_t i=0UL; i<
rows(); ++i )
2607 for(
size_t j=0UL; j<=i; ++j )
2608 matrix_(i,j) += (~rhs)(i,j);
2627 template<
typename MT
2629 template<
typename MT2 >
2630 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
2636 for(
size_t j=0UL; j<
columns(); ++j ) {
2637 const auto last( (~rhs).upperBound(j,j) );
2638 for(
auto element=(~rhs).
begin(j); element!=last; ++element )
2639 matrix_(element->index(),j) += element->value();
2643 for(
size_t i=0UL; i<
rows(); ++i ) {
2644 const auto last( (~rhs).upperBound(i,i) );
2645 for(
auto element=(~rhs).
begin(i); element!=last; ++element )
2646 matrix_(i,element->index()) += element->value();
2666 template<
typename MT
2668 template<
typename MT2 >
2669 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
2675 for(
size_t j=0UL; j<
columns(); ++j )
2676 for(
size_t i=0UL; i<=j; ++i )
2677 matrix_(i,j) -= (~rhs)(i,j);
2680 for(
size_t i=0UL; i<
rows(); ++i )
2681 for(
size_t j=0UL; j<=i; ++j )
2682 matrix_(i,j) -= (~rhs)(i,j);
2701 template<
typename MT
2703 template<
typename MT2 >
2704 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
2710 for(
size_t j=0UL; j<
columns(); ++j ) {
2711 const auto last( (~rhs).upperBound(j,j) );
2712 for(
auto element=(~rhs).
begin(j); element!=last; ++element )
2713 matrix_(element->index(),j) -= element->value();
2717 for(
size_t i=0UL; i<
rows(); ++i ) {
2718 const auto last( (~rhs).upperBound(i,i) );
2719 for(
auto element=(~rhs).
begin(i); element!=last; ++element )
2720 matrix_(i,element->index()) -= element->value();
2740 template<
typename MT
2742 template<
typename MT2 >
2743 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const DenseMatrix<MT2,SO>& rhs )
2749 for(
size_t j=0UL; j<
columns(); ++j )
2750 for(
size_t i=0UL; i<=j; ++i )
2751 matrix_(i,j) *= (~rhs)(i,j);
2754 for(
size_t i=0UL; i<
rows(); ++i )
2755 for(
size_t j=0UL; j<=i; ++j )
2756 matrix_(i,j) *= (~rhs)(i,j);
2775 template<
typename MT
2777 template<
typename MT2 >
2778 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const SparseMatrix<MT2,SO>& rhs )
2784 for(
size_t j=0UL; j<
columns(); ++j )
2788 const auto last( (~rhs).upperBound(j,j) );
2789 for(
auto element=(~rhs).
begin(j); element!=last; ++element ) {
2790 for( ; i<element->index(); ++i )
2791 reset( matrix_(i,j) );
2792 matrix_(i,j) *= element->value();
2796 for( ; i<
rows(); ++i ) {
2797 reset( matrix_(i,j) );
2802 for(
size_t i=0UL; i<
rows(); ++i )
2806 const auto last( (~rhs).upperBound(i,i) );
2807 for(
auto element=(~rhs).
begin(i); element!=last; ++element ) {
2808 for( ; j<element->index(); ++j )
2809 reset( matrix_(i,j) );
2810 matrix_(i,j) *= element->value();
2815 reset( matrix_(i,j) );
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
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,...
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
Constraint on the data type.
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:133
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Constraint on the data type.
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1793
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:2060
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
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:750
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:170
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:178
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
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
#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
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
Constraint on the data type.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:253
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
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:9091
#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.
#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:370
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
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.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 IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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:139
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
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:293
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:615
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.The IsComputation_v variable template pr...
Definition: IsComputation.h:90
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
#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,...
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
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:133
#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
Header file for all forward declarations for expression class templates.
#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,...
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:282
Constraint on the data type.
Constraint on the data type.
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
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1328
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
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:718
Header file for the RemoveReference type trait.
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
#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.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#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,...
Definition: Hermitian.h:79
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
#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
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
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,...
Definition: Assert.h:101
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825