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 typedef OppositeType_<MT> OT;
113 typedef TransposeType_<MT> TT;
114 typedef ElementType_<MT> ET;
119 typedef SymmetricMatrix<MT,SO,true,false>
This;
120 typedef DenseMatrix<This,SO>
BaseType;
122 typedef SymmetricMatrix<OT,!SO,true,false>
OppositeType;
129 typedef Pointer_<MT> Pointer;
130 typedef ConstPointer_<MT> ConstPointer;
136 template<
typename NewType >
139 typedef SymmetricMatrix< typename MT::template Rebind<NewType>::Other > Other;
146 template<
size_t NewM
150 typedef SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
157 template<
typename MatrixType >
163 typedef If_< IsConst<MatrixType>
164 , ConstReference_<MatrixType>
167 typedef std::random_access_iterator_tag IteratorCategory;
168 typedef RemoveReference_<Reference> ValueType;
169 typedef ValueType* PointerType;
170 typedef Reference ReferenceType;
171 typedef ptrdiff_t DifferenceType;
174 typedef IteratorCategory iterator_category;
175 typedef ValueType value_type;
176 typedef PointerType pointer;
177 typedef ReferenceType reference;
178 typedef DifferenceType difference_type;
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 typedef MatrixIterator<MT>
Iterator;
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 template<
typename Deleter >
480 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d );
482 template<
typename Deleter >
483 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d );
485 inline SymmetricMatrix(
const SymmetricMatrix& m );
486 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
488 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
489 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
500 inline Reference operator()(
size_t i,
size_t j );
501 inline ConstReference operator()(
size_t i,
size_t j )
const;
502 inline Reference at(
size_t i,
size_t j );
503 inline ConstReference at(
size_t i,
size_t j )
const;
504 inline ConstPointer data () const noexcept;
505 inline ConstPointer data (
size_t i ) const noexcept;
506 inline Iterator
begin (
size_t i );
507 inline ConstIterator
begin (
size_t i ) const;
508 inline ConstIterator
cbegin(
size_t i ) const;
509 inline Iterator
end (
size_t i );
510 inline ConstIterator
end (
size_t i ) const;
511 inline ConstIterator
cend (
size_t i ) const;
518 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
519 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
521 template< typename MT2 >
522 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
524 template< typename MT2 >
525 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
527 template< typename MT2 >
528 inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
530 template< typename MT2 >
531 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
533 template< typename MT2 >
534 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
536 template< typename MT2 >
537 inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
539 template< typename MT2 >
540 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
542 template< typename MT2 >
543 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
545 template< typename MT2 >
546 inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
548 template< typename MT2,
bool SO2 >
549 inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
551 template< typename Other >
552 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
554 template< typename Other >
555 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other 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 );
575 inline
void swap( SymmetricMatrix& m ) noexcept;
585 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
592 inline
bool isIntact() const noexcept;
599 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
600 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
602 inline
bool isAligned () const noexcept;
603 inline
bool canSMPAssign() const noexcept;
611 template< typename MT2 > inline
void assign ( DenseMatrix <MT2,SO>& rhs );
612 template< typename MT2 > inline
void assign ( const DenseMatrix <MT2,SO>& rhs );
613 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,SO>& rhs );
614 template< typename MT2 > inline
void addAssign( const DenseMatrix <MT2,SO>& rhs );
615 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,SO>& rhs );
616 template< typename MT2 > inline
void subAssign( const DenseMatrix <MT2,SO>& rhs );
617 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,SO>& rhs );
629 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
630 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
666 template< typename MT
668 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
683 template<
typename MT
685 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
717 template<
typename MT
719 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
720 : matrix_( ptr, n, n )
755 template<
typename MT
757 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
758 : matrix_( ptr, n, n, nn )
791 template<
typename MT
793 template<
typename Deleter >
794 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d )
795 : matrix_( ptr, n, n, d )
829 template<
typename MT
831 template<
typename Deleter >
832 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d )
833 : matrix_( ptr, n, n, nn, d )
851 template<
typename MT
853 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
854 : matrix_( m.matrix_ )
869 template<
typename MT
871 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
872 : matrix_( std::move( m.matrix_ ) )
891 template<
typename MT
893 template<
typename MT2 >
894 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
899 typedef RemoveAdaptor_<ResultType_<MT2> > RT;
900 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
902 if( IsSymmetric<MT2>::value ) {
913 resize( matrix_, tmp.rows(), tmp.rows() );
934 template<
typename MT
936 template<
typename MT2 >
937 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
942 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
943 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
945 if( IsSymmetric<MT2>::value ) {
947 assign(
trans( ~m ) );
956 resize( matrix_, tmp.rows(), tmp.rows() );
957 assign(
trans( tmp ) );
990 template<
typename MT
993 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
998 if( ( !SO && i > j ) || ( SO && i < j ) )
1001 return matrix_(j,i);
1022 template<
typename MT
1025 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const 1030 if( ( !SO && i > j ) || ( SO && i < j ) )
1031 return matrix_(i,j);
1033 return matrix_(j,i);
1055 template<
typename MT
1058 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1066 return (*
this)(i,j);
1088 template<
typename MT
1091 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const 1099 return (*
this)(i,j);
1119 template<
typename MT
1121 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1122 SymmetricMatrix<MT,SO,true,false>::data() const noexcept
1124 return matrix_.data();
1141 template<
typename MT
1143 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1144 SymmetricMatrix<MT,SO,true,false>::data(
size_t i )
const noexcept
1146 return matrix_.data(i);
1164 template<
typename MT
1170 return Iterator( matrix_, 0UL, i );
1172 return Iterator( matrix_, i, 0UL );
1190 template<
typename MT
1216 template<
typename MT
1242 template<
typename MT
1268 template<
typename MT
1294 template<
typename MT
1326 template<
typename MT
1328 inline SymmetricMatrix<MT,SO,true,false>&
1329 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1333 if( &rhs ==
this )
return *
this;
1335 resize( matrix_, rhs.rows(), rhs.columns() );
1354 template<
typename MT
1356 inline SymmetricMatrix<MT,SO,true,false>&
1357 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1359 matrix_ = std::move( rhs.matrix_ );
1384 template<
typename MT
1386 template<
typename MT2 >
1387 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1388 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1392 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1396 if( (~rhs).isAliased(
this ) ) {
1397 SymmetricMatrix tmp( ~rhs );
1402 if( IsSparseMatrix<MT2>::value )
1430 template<
typename MT
1432 template<
typename MT2 >
1433 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1434 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1438 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1440 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1446 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1452 resize( matrix_, tmp.rows(), tmp.columns() );
1453 if( IsSparseMatrix<Tmp>::value )
1480 template<
typename MT
1482 template<
typename MT2 >
1483 inline SymmetricMatrix<MT,SO,true,false>&
1484 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1486 return this->operator=(
trans( ~rhs ) );
1505 template<
typename MT
1507 template<
typename MT2 >
1508 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1511 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1539 template<
typename MT
1541 template<
typename MT2 >
1542 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1545 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1547 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1553 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1584 template<
typename MT
1586 template<
typename MT2 >
1587 inline SymmetricMatrix<MT,SO,true,false>&
1609 template<
typename MT
1611 template<
typename MT2 >
1612 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1615 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1643 template<
typename MT
1645 template<
typename MT2 >
1646 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1649 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1651 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1657 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1688 template<
typename MT
1690 template<
typename MT2 >
1691 inline SymmetricMatrix<MT,SO,true,false>&
1712 template<
typename MT
1714 template<
typename MT2
1716 inline SymmetricMatrix<MT,SO,true,false>&
1721 typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1725 if( matrix_.rows() != (~rhs).
columns() ) {
1729 Tmp tmp( (*
this) * ~rhs );
1735 resize( matrix_, tmp.rows(), tmp.columns() );
1755 template<
typename MT
1757 template<
typename Other >
1758 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1762 for(
size_t j=0UL; j<
columns(); ++j )
1763 for(
size_t i=0UL; i<=j; ++i )
1764 matrix_(i,j) *= rhs;
1767 for(
size_t i=0UL; i<
rows(); ++i )
1768 for(
size_t j=0UL; j<=i; ++j )
1769 matrix_(i,j) *= rhs;
1786 template<
typename MT
1788 template<
typename Other >
1789 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1795 for(
size_t j=0UL; j<
columns(); ++j )
1796 for(
size_t i=0UL; i<=j; ++i )
1797 matrix_(i,j) /= rhs;
1800 for(
size_t i=0UL; i<
rows(); ++i )
1801 for(
size_t j=0UL; j<=i; ++j )
1802 matrix_(i,j) /= rhs;
1825 template<
typename MT
1829 return matrix_.rows();
1841 template<
typename MT
1845 return matrix_.columns();
1863 template<
typename MT
1867 return matrix_.spacing();
1879 template<
typename MT
1883 return matrix_.capacity();
1900 template<
typename MT
1904 return matrix_.capacity(i);
1916 template<
typename MT
1920 size_t nonzeros( 0UL );
1924 for(
size_t j=0UL; j<
columns(); ++j ) {
1925 for(
size_t i=0UL; i<j; ++i ) {
1935 for(
size_t i=0UL; i<
rows(); ++i ) {
1936 for(
size_t j=0UL; j<i; ++j ) {
1963 template<
typename MT
1967 size_t nonzeros( 0UL );
1971 for(
size_t j=0UL; j<i; ++j ) {
1975 for(
size_t j=i; j<
rows(); ++j ) {
1982 for(
size_t j=0UL; j<i; ++j ) {
1986 for(
size_t j=i; j<
rows(); ++j ) {
2004 template<
typename MT
2011 for(
size_t j=0UL; j<
columns(); ++j )
2012 for(
size_t i=0UL; i<=j; ++i )
2013 clear( matrix_(i,j) );
2016 for(
size_t i=0UL; i<
rows(); ++i )
2017 for(
size_t j=0UL; j<=i; ++j )
2018 clear( matrix_(i,j) );
2065 template<
typename MT
2071 for( Iterator element=
begin(i); element!=
end(i); ++element )
2090 template<
typename MT
2118 template<
typename MT
2128 const size_t oldsize( matrix_.rows() );
2130 matrix_.resize( n, n,
true );
2133 const size_t increment( n - oldsize );
2134 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2135 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2155 template<
typename MT
2157 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2179 template<
typename MT
2181 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2183 matrix_.reserve( elements );
2196 template<
typename MT
2202 swap( matrix_, m.matrix_ );
2222 template<
typename MT
2238 template<
typename MT
2243 for(
size_t j=0UL; j<
columns(); ++j )
2244 for(
size_t i=0UL; i<=j; ++i )
2248 for(
size_t i=0UL; i<
rows(); ++i )
2249 for(
size_t j=0UL; j<=i; ++j )
2266 template<
typename MT
2268 template<
typename Other >
2269 inline SymmetricMatrix<MT,SO,true,false>&
2270 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2273 for(
size_t j=0UL; j<
columns(); ++j )
2274 for(
size_t i=0UL; i<=j; ++i )
2275 matrix_(i,j) *= scalar;
2278 for(
size_t i=0UL; i<
rows(); ++i )
2279 for(
size_t j=0UL; j<=i; ++j )
2280 matrix_(i,j) *= scalar;
2307 template<
typename MT
2314 ( IsCustom<MT>::value || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2339 template<
typename MT
2341 template<
typename Other >
2342 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2344 return matrix_.canAlias( alias );
2361 template<
typename MT
2363 template<
typename Other >
2364 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2366 return matrix_.isAliased( alias );
2382 template<
typename MT
2384 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2386 return matrix_.isAligned();
2403 template<
typename MT
2405 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2407 return matrix_.canSMPAssign();
2425 template<
typename MT
2427 template<
typename MT2 >
2428 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2434 for(
size_t j=0UL; j<
columns(); ++j )
2435 for(
size_t i=0UL; i<=j; ++i )
2436 matrix_(i,j) = std::move( (~rhs)(i,j) );
2439 for(
size_t i=0UL; i<
rows(); ++i )
2440 for(
size_t j=0UL; j<=i; ++j )
2441 matrix_(i,j) = std::move( (~rhs)(i,j) );
2460 template<
typename MT
2462 template<
typename MT2 >
2463 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2469 for(
size_t j=0UL; j<
columns(); ++j )
2470 for(
size_t i=0UL; i<=j; ++i )
2471 matrix_(i,j) = (~rhs)(i,j);
2474 for(
size_t i=0UL; i<
rows(); ++i )
2475 for(
size_t j=0UL; j<=i; ++j )
2476 matrix_(i,j) = (~rhs)(i,j);
2495 template<
typename MT
2497 template<
typename MT2 >
2498 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2506 for(
size_t j=0UL; j<
columns(); ++j ) {
2507 const ConstIterator last( (~rhs).upperBound(j,j) );
2508 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2509 matrix_(element->index(),j) = element->value();
2513 for(
size_t i=0UL; i<
rows(); ++i ) {
2514 const ConstIterator last( (~rhs).upperBound(i,i) );
2515 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2516 matrix_(i,element->index()) = element->value();
2536 template<
typename MT
2538 template<
typename MT2 >
2539 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
2545 for(
size_t j=0UL; j<
columns(); ++j )
2546 for(
size_t i=0UL; i<=j; ++i )
2547 matrix_(i,j) += (~rhs)(i,j);
2550 for(
size_t i=0UL; i<
rows(); ++i )
2551 for(
size_t j=0UL; j<=i; ++j )
2552 matrix_(i,j) += (~rhs)(i,j);
2571 template<
typename MT
2573 template<
typename MT2 >
2574 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
2582 for(
size_t j=0UL; j<
columns(); ++j ) {
2583 const ConstIterator last( (~rhs).upperBound(j,j) );
2584 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2585 matrix_(element->index(),j) += element->value();
2589 for(
size_t i=0UL; i<
rows(); ++i ) {
2590 const ConstIterator last( (~rhs).upperBound(i,i) );
2591 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2592 matrix_(i,element->index()) += element->value();
2612 template<
typename MT
2614 template<
typename MT2 >
2615 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
2621 for(
size_t j=0UL; j<
columns(); ++j )
2622 for(
size_t i=0UL; i<=j; ++i )
2623 matrix_(i,j) -= (~rhs)(i,j);
2626 for(
size_t i=0UL; i<
rows(); ++i )
2627 for(
size_t j=0UL; j<=i; ++j )
2628 matrix_(i,j) -= (~rhs)(i,j);
2647 template<
typename MT
2649 template<
typename MT2 >
2650 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
2658 for(
size_t j=0UL; j<
columns(); ++j ) {
2659 const ConstIterator last( (~rhs).upperBound(j,j) );
2660 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2661 matrix_(element->index(),j) -= element->value();
2665 for(
size_t i=0UL; i<
rows(); ++i ) {
2666 const ConstIterator last( (~rhs).upperBound(i,i) );
2667 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2668 matrix_(i,element->index()) -= element->value();
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
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:102
Header file for auxiliary alias declarations.
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:1066
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1321
#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 Rows type trait.
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:352
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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Constraint on the data type.
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:194
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
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:699
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5556
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:596
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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:390
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:731
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
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:304
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:238
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
Header file for the IsSquare type trait.
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.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5635
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:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#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.
Header file for the Columns type trait.
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
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:336
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:128
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
Constraints on the storage order of matrix types.
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:544
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
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.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:128
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:553
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
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:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
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:267
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:697
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:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(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
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:733
Header file for the IsComputation type trait class.
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:1303
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
SubmatrixExprTrait_< MT, unaligned > submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:168
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
const DMatDMatMultExpr< T1, T2, false, false, false, false > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7505
#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:570