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 ET >
139 typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
146 template<
typename MatrixType >
152 typedef If_< IsConst<MatrixType>
153 , ConstReference_<MatrixType>
156 typedef std::random_access_iterator_tag IteratorCategory;
157 typedef RemoveReference_<Reference> ValueType;
158 typedef ValueType* PointerType;
159 typedef Reference ReferenceType;
160 typedef ptrdiff_t DifferenceType;
163 typedef IteratorCategory iterator_category;
164 typedef ValueType value_type;
165 typedef PointerType pointer;
166 typedef ReferenceType reference;
167 typedef DifferenceType difference_type;
173 inline MatrixIterator() noexcept
187 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
199 template<
typename MatrixType2 >
200 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it ) noexcept
201 : matrix_( it.matrix_ )
203 , column_( it.column_ )
213 inline MatrixIterator&
operator+=(
size_t inc ) noexcept {
214 ( SO )?( row_ += inc ):( column_ += inc );
225 inline MatrixIterator&
operator-=(
size_t dec ) noexcept {
226 ( SO )?( row_ -= dec ):( column_ -= dec );
236 inline MatrixIterator& operator++() noexcept {
237 ( SO )?( ++row_ ):( ++column_ );
247 inline const MatrixIterator operator++(
int ) noexcept {
248 const MatrixIterator tmp( *
this );
259 inline MatrixIterator& operator--() noexcept {
260 ( SO )?( --row_ ):( --column_ );
270 inline const MatrixIterator operator--(
int ) noexcept {
271 const MatrixIterator tmp( *
this );
283 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
284 return (*matrix_)(row_,column_);
286 return (*matrix_)(column_,row_);
295 inline PointerType operator->()
const {
296 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
297 return &(*matrix_)(row_,column_);
299 return &(*matrix_)(column_,row_);
309 template<
typename MatrixType2 >
310 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
311 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
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_ );
336 return ( column_ < rhs.column_ );
346 template<
typename MatrixType2 >
347 inline bool operator>(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
348 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
349 return ( column_ > rhs.column_ );
359 template<
typename MatrixType2 >
360 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs )
const noexcept {
361 return ( SO )?( row_ <= rhs.row_ ):( 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 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const noexcept {
384 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
395 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) noexcept {
397 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
399 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
410 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) noexcept {
412 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
414 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
425 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) noexcept {
427 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
429 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
441 template<
typename MatrixType2 >
friend class MatrixIterator;
447 typedef MatrixIterator<MT>
Iterator;
453 enum :
bool { simdEnabled =
false };
456 enum :
bool { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
462 explicit inline SymmetricMatrix();
463 explicit inline SymmetricMatrix(
size_t n );
465 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n );
466 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn );
468 template<
typename Deleter >
469 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d );
471 template<
typename Deleter >
472 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d );
474 inline SymmetricMatrix(
const SymmetricMatrix& m );
475 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
477 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
478 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
489 inline Reference operator()(
size_t i,
size_t j );
490 inline ConstReference operator()(
size_t i,
size_t j ) const;
491 inline Reference at(
size_t i,
size_t j );
492 inline ConstReference at(
size_t i,
size_t j ) const;
493 inline ConstPointer data () const noexcept;
494 inline ConstPointer data (
size_t i ) const noexcept;
495 inline Iterator
begin (
size_t i );
496 inline ConstIterator
begin (
size_t i ) const;
497 inline ConstIterator
cbegin(
size_t i ) const;
498 inline Iterator
end (
size_t i );
499 inline ConstIterator
end (
size_t i ) const;
500 inline ConstIterator
cend (
size_t i ) const;
507 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
508 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
510 template< typename MT2 >
511 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
513 template< typename MT2 >
514 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
516 template< typename MT2 >
517 inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
519 template< typename MT2 >
520 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
522 template< typename MT2 >
523 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
525 template< typename MT2 >
526 inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
528 template< typename MT2 >
529 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
531 template< typename MT2 >
532 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
534 template< typename MT2 >
535 inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
537 template< typename MT2,
bool SO2 >
538 inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
540 template< typename Other >
541 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
543 template< typename Other >
544 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
551 inline
size_t rows() const noexcept;
552 inline
size_t columns() const noexcept;
553 inline
size_t spacing() const noexcept;
554 inline
size_t capacity() const noexcept;
555 inline
size_t capacity(
size_t i ) const noexcept;
557 inline
size_t nonZeros(
size_t i ) const;
559 inline
void reset(
size_t i );
561 void resize (
size_t n,
bool preserve=true );
562 inline
void extend (
size_t n,
bool preserve=true );
563 inline
void reserve(
size_t elements );
566 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
567 inline
void swap( SymmetricMatrix& m ) noexcept;
574 inline
bool isIntact() const noexcept;
581 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
582 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
584 inline
bool isAligned () const noexcept;
585 inline
bool canSMPAssign() const noexcept;
593 template< typename MT2 > inline
void assign ( DenseMatrix <MT2,SO>& rhs );
594 template< typename MT2 > inline
void assign ( const DenseMatrix <MT2,SO>& rhs );
595 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,SO>& rhs );
596 template< typename MT2 > inline
void addAssign( const DenseMatrix <MT2,SO>& rhs );
597 template< typename MT2 > inline
void addAssign( const SparseMatrix<MT2,SO>& rhs );
598 template< typename MT2 > inline
void subAssign( const DenseMatrix <MT2,SO>& rhs );
599 template< typename MT2 > inline
void subAssign( const SparseMatrix<MT2,SO>& rhs );
611 template< typename MT2,
bool SO2,
bool DF2,
bool NF2 >
612 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
648 template< typename MT
650 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
665 template<
typename MT
667 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
699 template<
typename MT
701 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
702 : matrix_( ptr, n, n )
737 template<
typename MT
739 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
740 : matrix_( ptr, n, n, nn )
773 template<
typename MT
775 template<
typename Deleter >
776 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d )
777 : matrix_( ptr, n, n, d )
811 template<
typename MT
813 template<
typename Deleter >
814 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d )
815 : matrix_( ptr, n, n, nn, d )
833 template<
typename MT
835 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
836 : matrix_( m.matrix_ )
851 template<
typename MT
853 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
854 : matrix_(
std::move( m.matrix_ ) )
873 template<
typename MT
875 template<
typename MT2 >
876 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
881 typedef RemoveAdaptor_<ResultType_<MT2> > RT;
882 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
884 if( IsSymmetric<MT2>::value ) {
895 resize( matrix_, tmp.rows(), tmp.rows() );
916 template<
typename MT
918 template<
typename MT2 >
919 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
924 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
925 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
927 if( IsSymmetric<MT2>::value ) {
929 assign(
trans( ~m ) );
938 resize( matrix_, tmp.rows(), tmp.rows() );
939 assign(
trans( tmp ) );
972 template<
typename MT
975 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
980 if( ( !SO && i > j ) || ( SO && i < j ) )
1004 template<
typename MT
1007 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const
1012 if( ( !SO && i > j ) || ( SO && i < j ) )
1013 return matrix_(i,j);
1015 return matrix_(j,i);
1037 template<
typename MT
1040 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1048 return (*
this)(i,j);
1070 template<
typename MT
1073 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const
1081 return (*
this)(i,j);
1101 template<
typename MT
1103 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1104 SymmetricMatrix<MT,SO,true,false>::data() const noexcept
1106 return matrix_.data();
1123 template<
typename MT
1125 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1126 SymmetricMatrix<MT,SO,true,false>::data(
size_t i )
const noexcept
1128 return matrix_.data(i);
1146 template<
typename MT
1152 return Iterator( matrix_, 0UL, i );
1154 return Iterator( matrix_, i, 0UL );
1172 template<
typename MT
1198 template<
typename MT
1224 template<
typename MT
1250 template<
typename MT
1276 template<
typename MT
1308 template<
typename MT
1310 inline SymmetricMatrix<MT,SO,true,false>&
1311 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1315 if( &rhs ==
this )
return *
this;
1317 resize( matrix_, rhs.rows(), rhs.columns() );
1336 template<
typename MT
1338 inline SymmetricMatrix<MT,SO,true,false>&
1339 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1341 matrix_ = std::move( rhs.matrix_ );
1366 template<
typename MT
1368 template<
typename MT2 >
1369 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1370 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1374 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1378 if( (~rhs).isAliased(
this ) ) {
1379 SymmetricMatrix tmp( ~rhs );
1384 if( IsSparseMatrix<MT2>::value )
1412 template<
typename MT
1414 template<
typename MT2 >
1415 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1416 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1420 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1422 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1428 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1434 resize( matrix_, tmp.rows(), tmp.columns() );
1435 if( IsSparseMatrix<Tmp>::value )
1462 template<
typename MT
1464 template<
typename MT2 >
1465 inline SymmetricMatrix<MT,SO,true,false>&
1466 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1468 return this->operator=(
trans( ~rhs ) );
1487 template<
typename MT
1489 template<
typename MT2 >
1490 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1493 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1521 template<
typename MT
1523 template<
typename MT2 >
1524 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1527 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1529 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1535 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1566 template<
typename MT
1568 template<
typename MT2 >
1569 inline SymmetricMatrix<MT,SO,true,false>&
1591 template<
typename MT
1593 template<
typename MT2 >
1594 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1597 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1625 template<
typename MT
1627 template<
typename MT2 >
1628 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1631 typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1633 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1639 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1670 template<
typename MT
1672 template<
typename MT2 >
1673 inline SymmetricMatrix<MT,SO,true,false>&
1694 template<
typename MT
1696 template<
typename MT2
1698 inline SymmetricMatrix<MT,SO,true,false>&
1703 typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1707 if( matrix_.rows() != (~rhs).
columns() ) {
1711 Tmp tmp( (*
this) * ~rhs );
1717 resize( matrix_, tmp.rows(), tmp.columns() );
1737 template<
typename MT
1739 template<
typename Other >
1740 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1744 for(
size_t j=0UL; j<
columns(); ++j )
1745 for(
size_t i=0UL; i<=j; ++i )
1746 matrix_(i,j) *= rhs;
1749 for(
size_t i=0UL; i<
rows(); ++i )
1750 for(
size_t j=0UL; j<=i; ++j )
1751 matrix_(i,j) *= rhs;
1768 template<
typename MT
1770 template<
typename Other >
1771 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1777 for(
size_t j=0UL; j<
columns(); ++j )
1778 for(
size_t i=0UL; i<=j; ++i )
1779 matrix_(i,j) /= rhs;
1782 for(
size_t i=0UL; i<
rows(); ++i )
1783 for(
size_t j=0UL; j<=i; ++j )
1784 matrix_(i,j) /= rhs;
1807 template<
typename MT
1811 return matrix_.rows();
1823 template<
typename MT
1827 return matrix_.columns();
1845 template<
typename MT
1849 return matrix_.spacing();
1861 template<
typename MT
1865 return matrix_.capacity();
1882 template<
typename MT
1886 return matrix_.capacity(i);
1898 template<
typename MT
1902 size_t nonzeros( 0UL );
1906 for(
size_t j=0UL; j<
columns(); ++j ) {
1907 for(
size_t i=0UL; i<j; ++i ) {
1917 for(
size_t i=0UL; i<
rows(); ++i ) {
1918 for(
size_t j=0UL; j<i; ++j ) {
1945 template<
typename MT
1949 size_t nonzeros( 0UL );
1953 for(
size_t j=0UL; j<i; ++j ) {
1957 for(
size_t j=i; j<
rows(); ++j ) {
1964 for(
size_t j=0UL; j<i; ++j ) {
1968 for(
size_t j=i; j<
rows(); ++j ) {
1986 template<
typename MT
1993 for(
size_t j=0UL; j<
columns(); ++j )
1994 for(
size_t i=0UL; i<=j; ++i )
1995 clear( matrix_(i,j) );
1998 for(
size_t i=0UL; i<
rows(); ++i )
1999 for(
size_t j=0UL; j<=i; ++j )
2000 clear( matrix_(i,j) );
2047 template<
typename MT
2053 for( Iterator element=
begin(i); element!=
end(i); ++element )
2072 template<
typename MT
2100 template<
typename MT
2110 const size_t oldsize( matrix_.rows() );
2112 matrix_.resize( n, n,
true );
2115 const size_t increment( n - oldsize );
2116 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2117 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2137 template<
typename MT
2139 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2161 template<
typename MT
2163 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2165 matrix_.reserve( elements );
2177 template<
typename MT
2193 template<
typename MT
2198 for(
size_t j=0UL; j<
columns(); ++j )
2199 for(
size_t i=0UL; i<=j; ++i )
2203 for(
size_t i=0UL; i<
rows(); ++i )
2204 for(
size_t j=0UL; j<=i; ++j )
2221 template<
typename MT
2223 template<
typename Other >
2224 inline SymmetricMatrix<MT,SO,true,false>&
2225 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2228 for(
size_t j=0UL; j<
columns(); ++j )
2229 for(
size_t i=0UL; i<=j; ++i )
2230 matrix_(i,j) *= scalar;
2233 for(
size_t i=0UL; i<
rows(); ++i )
2234 for(
size_t j=0UL; j<=i; ++j )
2235 matrix_(i,j) *= scalar;
2251 template<
typename MT
2257 swap( matrix_, m.matrix_ );
2281 template<
typename MT
2288 ( IsCustom<MT>::value || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2313 template<
typename MT
2315 template<
typename Other >
2316 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2318 return matrix_.canAlias( alias );
2335 template<
typename MT
2337 template<
typename Other >
2338 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2340 return matrix_.isAliased( alias );
2356 template<
typename MT
2358 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2360 return matrix_.isAligned();
2377 template<
typename MT
2379 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2381 return matrix_.canSMPAssign();
2399 template<
typename MT
2401 template<
typename MT2 >
2402 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2408 for(
size_t j=0UL; j<
columns(); ++j )
2409 for(
size_t i=0UL; i<=j; ++i )
2410 matrix_(i,j) = std::move( (~rhs)(i,j) );
2413 for(
size_t i=0UL; i<
rows(); ++i )
2414 for(
size_t j=0UL; j<=i; ++j )
2415 matrix_(i,j) = std::move( (~rhs)(i,j) );
2434 template<
typename MT
2436 template<
typename MT2 >
2437 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2443 for(
size_t j=0UL; j<
columns(); ++j )
2444 for(
size_t i=0UL; i<=j; ++i )
2445 matrix_(i,j) = (~rhs)(i,j);
2448 for(
size_t i=0UL; i<
rows(); ++i )
2449 for(
size_t j=0UL; j<=i; ++j )
2450 matrix_(i,j) = (~rhs)(i,j);
2469 template<
typename MT
2471 template<
typename MT2 >
2472 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2480 for(
size_t j=0UL; j<
columns(); ++j ) {
2481 const ConstIterator last( (~rhs).upperBound(j,j) );
2482 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2483 matrix_(element->index(),j) = element->value();
2487 for(
size_t i=0UL; i<
rows(); ++i ) {
2488 const ConstIterator last( (~rhs).upperBound(i,i) );
2489 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2490 matrix_(i,element->index()) = element->value();
2510 template<
typename MT
2512 template<
typename MT2 >
2513 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
2519 for(
size_t j=0UL; j<
columns(); ++j )
2520 for(
size_t i=0UL; i<=j; ++i )
2521 matrix_(i,j) += (~rhs)(i,j);
2524 for(
size_t i=0UL; i<
rows(); ++i )
2525 for(
size_t j=0UL; j<=i; ++j )
2526 matrix_(i,j) += (~rhs)(i,j);
2545 template<
typename MT
2547 template<
typename MT2 >
2548 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
2556 for(
size_t j=0UL; j<
columns(); ++j ) {
2557 const ConstIterator last( (~rhs).upperBound(j,j) );
2558 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2559 matrix_(element->index(),j) += element->value();
2563 for(
size_t i=0UL; i<
rows(); ++i ) {
2564 const ConstIterator last( (~rhs).upperBound(i,i) );
2565 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2566 matrix_(i,element->index()) += element->value();
2586 template<
typename MT
2588 template<
typename MT2 >
2589 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
2595 for(
size_t j=0UL; j<
columns(); ++j )
2596 for(
size_t i=0UL; i<=j; ++i )
2597 matrix_(i,j) -= (~rhs)(i,j);
2600 for(
size_t i=0UL; i<
rows(); ++i )
2601 for(
size_t j=0UL; j<=i; ++j )
2602 matrix_(i,j) -= (~rhs)(i,j);
2621 template<
typename MT
2623 template<
typename MT2 >
2624 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
2632 for(
size_t j=0UL; j<
columns(); ++j ) {
2633 const ConstIterator last( (~rhs).upperBound(j,j) );
2634 for( ConstIterator 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 ConstIterator last( (~rhs).upperBound(i,i) );
2641 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2642 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
Header file for auxiliary alias declarations.
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, 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.
const DMatDMatMultExpr< T1, T2 > 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:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
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.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:689
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:188
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:2643
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:5077
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:590
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
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:442
#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:384
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:2639
DisableIf_< Or< IsComputation< MT >, IsTransExpr< 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:126
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:298
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1036
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
constexpr bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
Header file for the IsSquare type trait.
Constraint on the data type.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5104
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:5148
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:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#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.
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:330
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1267
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:538
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Header file for the RemoveAdaptor type trait.
Header file for all forward declarations for expression class templates.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
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.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< 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:126
#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:2642
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:2646
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:258
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
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:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#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:950
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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#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:167
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
#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:564