35#ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONSCALAR_H_
36#define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONSCALAR_H_
107class SymmetricMatrix<MT,SO,true,false>
108 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
112 using OT = OppositeType_t<MT>;
113 using TT = TransposeType_t<MT>;
114 using ET = ElementType_t<MT>;
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>;
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;
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 inline SymmetricMatrix();
475 explicit inline SymmetricMatrix(
size_t n );
477 inline SymmetricMatrix( ElementType* ptr,
size_t n );
478 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 );
680inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
697inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
744inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
745 : matrix_( ptr, n, n )
795inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
796 : matrix_( ptr, n, n, nn )
816inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
817 : matrix_( m.matrix_ )
834inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
835 : matrix_( std::move( m.matrix_ ) )
856template<
typename MT2 >
857inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
862 using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
863 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
865 if( IsSymmetric_v<MT2> ) {
866 resize( matrix_, (*m).rows(), (*m).columns() );
876 resize( matrix_, tmp.rows(), tmp.rows() );
899template<
typename MT2 >
900inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
905 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
906 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
908 if( IsSymmetric_v<MT2> ) {
909 resize( matrix_, (*m).rows(), (*m).columns() );
910 assign(
trans( *m ) );
919 resize( matrix_, tmp.rows(), tmp.rows() );
920 assign(
trans( tmp ) );
955inline typename SymmetricMatrix<MT,SO,true,false>::Reference
956 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
961 if( ( !SO && i > j ) || ( SO && i < j ) )
987inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
988 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const
993 if( ( !SO && i > j ) || ( SO && i < j ) )
1018template<
typename MT
1020inline typename SymmetricMatrix<MT,SO,true,false>::Reference
1021 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1029 return (*
this)(i,j);
1051template<
typename MT
1053inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
1054 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const
1062 return (*
this)(i,j);
1082template<
typename MT
1084inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1087 return matrix_.data();
1104template<
typename MT
1106inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1109 return matrix_.data(i);
1127template<
typename MT
1129inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1133 return Iterator( matrix_, 0UL, i );
1135 return Iterator( matrix_, i, 0UL );
1153template<
typename MT
1155inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1159 return ConstIterator( matrix_, 0UL, i );
1161 return ConstIterator( matrix_, i, 0UL );
1179template<
typename MT
1181inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1185 return ConstIterator( matrix_, 0UL, i );
1187 return ConstIterator( matrix_, i, 0UL );
1205template<
typename MT
1207inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1211 return Iterator( matrix_,
rows(), i );
1213 return Iterator( matrix_, i,
columns() );
1231template<
typename MT
1233inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1237 return ConstIterator( matrix_,
rows(), i );
1239 return ConstIterator( matrix_, i,
columns() );
1257template<
typename MT
1259inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1263 return ConstIterator( matrix_,
rows(), i );
1265 return ConstIterator( matrix_, i,
columns() );
1289template<
typename MT
1291inline SymmetricMatrix<MT,SO,true,false>&
1292 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1296 if( &rhs ==
this )
return *
this;
1298 resize( matrix_, rhs.rows(), rhs.columns() );
1317template<
typename MT
1319inline SymmetricMatrix<MT,SO,true,false>&
1320 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs )
noexcept
1322 matrix_ = std::move( rhs.matrix_ );
1347template<
typename MT
1349template<
typename MT2 >
1350inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1351 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1355 if( !IsSymmetric_v<MT2> && !
isSymmetric( *rhs ) ) {
1359 if( (*rhs).isAliased(
this ) ) {
1360 SymmetricMatrix tmp( *rhs );
1364 resize( matrix_, (*rhs).rows(), (*rhs).columns() );
1365 if( IsSparseMatrix_v<MT2> )
1393template<
typename MT
1395template<
typename MT2 >
1396inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1397 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1401 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1403 if( !IsSquare_v<MT2> && !
isSquare( *rhs ) ) {
1409 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1415 resize( matrix_, tmp.rows(), tmp.columns() );
1416 if( IsSparseMatrix_v<Tmp> )
1443template<
typename MT
1445template<
typename MT2 >
1446inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1449 return this->operator=(
trans( *rhs ) );
1468template<
typename MT
1470template<
typename MT2 >
1472 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1474 if( !IsSymmetric_v<MT2> && !
isSymmetric( *rhs ) ) {
1502template<
typename MT
1504template<
typename MT2 >
1506 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1508 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1510 if( !IsSquare_v<MT2> && !
isSquare( *rhs ) ) {
1516 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1547template<
typename MT
1549template<
typename MT2 >
1572template<
typename MT
1574template<
typename MT2 >
1576 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1578 if( !IsSymmetric_v<MT2> && !
isSymmetric( *rhs ) ) {
1606template<
typename MT
1608template<
typename MT2 >
1610 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1612 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1614 if( !IsSquare_v<MT2> && !
isSquare( *rhs ) ) {
1620 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1651template<
typename MT
1653template<
typename MT2 >
1677template<
typename MT
1679template<
typename MT2 >
1680inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1681 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1683 if( !IsSymmetric_v<MT2> && !
isSymmetric( *rhs ) ) {
1687 schurAssign( *rhs );
1712template<
typename MT
1714template<
typename MT2 >
1715inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1716 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1718 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1720 if( !IsSquare_v<MT2> && !
isSquare( *rhs ) ) {
1726 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1757template<
typename MT
1759template<
typename MT2 >
1760inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1763 return this->operator%=(
trans( *rhs ) );
1777template<
typename MT
1779template<
typename ST >
1781 -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >
1784 for(
size_t j=0UL; j<
columns(); ++j )
1785 for(
size_t i=0UL; i<=j; ++i )
1786 matrix_(i,j) *= rhs;
1789 for(
size_t i=0UL; i<
rows(); ++i )
1790 for(
size_t j=0UL; j<=i; ++j )
1791 matrix_(i,j) *= rhs;
1808template<
typename MT
1810template<
typename ST >
1812 -> EnableIf_t< IsScalar_v<ST>, SymmetricMatrix& >
1817 for(
size_t j=0UL; j<
columns(); ++j )
1818 for(
size_t i=0UL; i<=j; ++i )
1819 matrix_(i,j) /= rhs;
1822 for(
size_t i=0UL; i<
rows(); ++i )
1823 for(
size_t j=0UL; j<=i; ++j )
1824 matrix_(i,j) /= rhs;
1847template<
typename MT
1851 return matrix_.rows();
1863template<
typename MT
1867 return matrix_.columns();
1885template<
typename MT
1889 return matrix_.spacing();
1901template<
typename MT
1905 return matrix_.capacity();
1922template<
typename MT
1926 return matrix_.capacity(i);
1938template<
typename MT
1942 size_t nonzeros( 0UL );
1946 for(
size_t j=0UL; j<
columns(); ++j ) {
1947 for(
size_t i=0UL; i<j; ++i ) {
1957 for(
size_t i=0UL; i<
rows(); ++i ) {
1958 for(
size_t j=0UL; j<i; ++j ) {
1985template<
typename MT
1989 size_t nonzeros( 0UL );
1993 for(
size_t j=0UL; j<i; ++j ) {
1997 for(
size_t j=i; j<
rows(); ++j ) {
2004 for(
size_t j=0UL; j<i; ++j ) {
2008 for(
size_t j=i; j<
rows(); ++j ) {
2026template<
typename MT
2033 for(
size_t j=0UL; j<
columns(); ++j )
2034 for(
size_t i=0UL; i<=j; ++i )
2035 clear( matrix_(i,j) );
2038 for(
size_t i=0UL; i<
rows(); ++i )
2039 for(
size_t j=0UL; j<=i; ++j )
2040 clear( matrix_(i,j) );
2087template<
typename MT
2093 for(
auto element=
begin(i); element!=
end(i); ++element )
2112template<
typename MT
2141template<
typename MT
2151 const size_t oldsize( matrix_.rows() );
2153 matrix_.resize( n, n,
true );
2156 const size_t increment( n - oldsize );
2157 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2158 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2178template<
typename MT
2180inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2202template<
typename MT
2204inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2222template<
typename MT
2226 matrix_.shrinkToFit();
2239template<
typename MT
2245 swap( matrix_, m.matrix_ );
2265template<
typename MT
2281template<
typename MT
2286 for(
size_t j=0UL; j<
columns(); ++j )
2287 for(
size_t i=0UL; i<=j; ++i )
2291 for(
size_t i=0UL; i<
rows(); ++i )
2292 for(
size_t j=0UL; j<=i; ++j )
2320template<
typename MT
2322template<
typename Other >
2323inline SymmetricMatrix<MT,SO,true,false>&
2324 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2327 for(
size_t j=0UL; j<
columns(); ++j )
2328 for(
size_t i=0UL; i<=j; ++i )
2329 matrix_(i,j) *= scalar;
2332 for(
size_t i=0UL; i<
rows(); ++i )
2333 for(
size_t j=0UL; j<=i; ++j )
2334 matrix_(i,j) *= scalar;
2361template<
typename MT
2368 ( IsCustom_v<MT> || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2393template<
typename MT
2395template<
typename Other >
2396inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2398 return matrix_.canAlias( alias );
2415template<
typename MT
2417template<
typename Other >
2418inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2420 return matrix_.isAliased( alias );
2436template<
typename MT
2438inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2440 return matrix_.isAligned();
2457template<
typename MT
2459inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2461 return matrix_.canSMPAssign();
2479template<
typename MT
2481template<
typename MT2 >
2482inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
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) );
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) );
2514template<
typename MT
2516template<
typename MT2 >
2517inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
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);
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);
2549template<
typename MT
2551template<
typename MT2 >
2552inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
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();
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();
2588template<
typename MT
2590template<
typename MT2 >
2591inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
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);
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);
2623template<
typename MT
2625template<
typename MT2 >
2626inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
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();
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();
2662template<
typename MT
2664template<
typename MT2 >
2665inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
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);
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);
2697template<
typename MT
2699template<
typename MT2 >
2700inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
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();
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();
2736template<
typename MT
2738template<
typename MT2 >
2739inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const DenseMatrix<MT2,SO>& rhs )
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);
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);
2771template<
typename MT
2773template<
typename MT2 >
2774inline void SymmetricMatrix<MT,SO,true,false>::schurAssign(
const SparseMatrix<MT2,SO>& rhs )
2780 for(
size_t j=0UL; j<
columns(); ++j )
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();
2792 for( ; i<
rows(); ++i ) {
2793 reset( matrix_(i,j) );
2798 for(
size_t i=0UL; i<
rows(); ++i )
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();
2811 reset( matrix_(i,j) );
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.
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.
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.