35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_ 104 template<
typename MT
106 class SymmetricMatrix<MT,SO,true,false>
107 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
111 using OT = OppositeType_t<MT>;
112 using TT = TransposeType_t<MT>;
113 using ET = ElementType_t<MT>;
118 using This = SymmetricMatrix<MT,SO,true,false>;
119 using BaseType = DenseMatrix<This,SO>;
121 using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
128 using Pointer = Pointer_t<MT>;
129 using ConstPointer = ConstPointer_t<MT>;
135 template<
typename NewType >
138 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
145 template<
size_t NewM
149 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
156 template<
typename MatrixType >
162 using Reference = If_t< IsConst_v<MatrixType>
163 , ConstReference_t<MatrixType>
164 , Reference_t<MatrixType> >;
166 using IteratorCategory = std::random_access_iterator_tag;
167 using ValueType = RemoveReference_t<Reference>;
168 using PointerType = ValueType*;
170 using DifferenceType = ptrdiff_t;
173 using iterator_category = IteratorCategory;
174 using value_type = ValueType;
175 using pointer = PointerType;
176 using reference = ReferenceType;
177 using difference_type = DifferenceType;
183 inline MatrixIterator() noexcept
197 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column ) noexcept
209 template<
typename MatrixType2 >
210 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it ) noexcept
211 : matrix_( it.matrix_ )
213 , column_( it.column_ )
223 inline MatrixIterator&
operator+=(
size_t inc ) noexcept {
224 ( SO )?( row_ += inc ):( column_ += inc );
235 inline MatrixIterator&
operator-=(
size_t dec ) noexcept {
236 ( SO )?( row_ -= dec ):( column_ -= dec );
246 inline MatrixIterator& operator++() noexcept {
247 ( SO )?( ++row_ ):( ++column_ );
257 inline const MatrixIterator operator++(
int ) noexcept {
258 const MatrixIterator tmp( *
this );
269 inline MatrixIterator& operator--() noexcept {
270 ( SO )?( --row_ ):( --column_ );
280 inline const MatrixIterator operator--(
int ) noexcept {
281 const MatrixIterator tmp( *
this );
293 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
294 return (*matrix_)(row_,column_);
296 return (*matrix_)(column_,row_);
305 inline PointerType operator->()
const {
306 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
307 return &(*matrix_)(row_,column_);
309 return &(*matrix_)(column_,row_);
319 template<
typename MatrixType2 >
320 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
321 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
331 template<
typename MatrixType2 >
332 inline bool operator!=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
333 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
343 template<
typename MatrixType2 >
344 inline bool operator<( const MatrixIterator<MatrixType2>& rhs )
const noexcept {
345 return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
346 return ( column_ < rhs.column_ );
356 template<
typename MatrixType2 >
357 inline bool operator>(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
358 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
359 return ( column_ > rhs.column_ );
369 template<
typename MatrixType2 >
370 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs )
const noexcept {
371 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
381 template<
typename MatrixType2 >
382 inline bool operator>=(
const MatrixIterator<MatrixType2>& rhs )
const noexcept {
383 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
393 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const noexcept {
394 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
405 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) noexcept {
407 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
409 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
420 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) noexcept {
422 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
424 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
435 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) noexcept {
437 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
439 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
451 template<
typename MatrixType2 >
friend class MatrixIterator;
457 using Iterator = MatrixIterator<MT>;
463 static constexpr
bool simdEnabled =
false;
472 explicit inline SymmetricMatrix();
473 explicit inline SymmetricMatrix(
size_t n );
475 explicit inline SymmetricMatrix(
ElementType* ptr,
size_t n );
476 explicit inline SymmetricMatrix(
ElementType* ptr,
size_t n,
size_t nn );
478 inline SymmetricMatrix(
const SymmetricMatrix& m );
479 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
481 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
482 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
489 ~SymmetricMatrix() =
default;
496 inline Reference operator()(
size_t i,
size_t j );
498 inline Reference at(
size_t i,
size_t j );
500 inline ConstPointer
data () const noexcept;
501 inline ConstPointer
data (
size_t i ) const noexcept;
514 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
515 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
517 template< typename MT2 >
518 inline auto operator=( const Matrix<MT2,SO>& rhs )
521 template< typename MT2 >
522 inline auto operator=( const Matrix<MT2,SO>& rhs )
525 template< typename MT2 >
526 inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
528 template< typename MT2 >
529 inline auto operator+=( const Matrix<MT2,SO>& rhs )
532 template< typename MT2 >
533 inline auto operator+=( const Matrix<MT2,SO>& rhs )
536 template< typename MT2 >
537 inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
539 template< typename MT2 >
540 inline auto operator-=( const Matrix<MT2,SO>& rhs )
543 template< typename MT2 >
544 inline auto operator-=( const Matrix<MT2,SO>& rhs )
547 template< typename MT2 >
548 inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
550 template< typename MT2 >
551 inline auto operator%=( const Matrix<MT2,SO>& rhs )
554 template< typename MT2 >
555 inline auto operator%=( const Matrix<MT2,SO>& rhs )
558 template< typename MT2 >
559 inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
561 template< typename ST >
564 template< typename ST >
572 inline
size_t rows() const noexcept;
573 inline
size_t columns() const noexcept;
574 inline
size_t spacing() const noexcept;
575 inline
size_t capacity() const noexcept;
576 inline
size_t capacity(
size_t i ) const noexcept;
578 inline
size_t nonZeros(
size_t i ) const;
580 inline
void reset(
size_t i );
582 void resize (
size_t n,
bool preserve=true );
583 inline
void extend (
size_t n,
bool preserve=true );
584 inline
void reserve(
size_t elements );
586 inline
void swap( SymmetricMatrix& m ) noexcept;
596 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
603 inline
bool isIntact() const noexcept;
610 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
611 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
613 inline
bool isAligned () const noexcept;
614 inline
bool canSMPAssign() const noexcept;
622 template< typename MT2 > inline
void assign ( DenseMatrix <MT2,SO>& rhs );
623 template< typename MT2 > inline
void assign ( const DenseMatrix <MT2,SO>& rhs );
624 template< typename MT2 > inline
void assign ( const SparseMatrix<MT2,SO>& rhs );
625 template< typename MT2 > inline
void addAssign ( const DenseMatrix <MT2,SO>& rhs );
626 template< typename MT2 > inline
void addAssign ( const SparseMatrix<MT2,SO>& rhs );
627 template< typename MT2 > inline
void subAssign ( const DenseMatrix <MT2,SO>& rhs );
628 template< typename MT2 > inline
void subAssign ( const SparseMatrix<MT2,SO>& rhs );
629 template< typename MT2 > inline
void schurAssign( const DenseMatrix <MT2,SO>& rhs );
630 template< typename MT2 > inline
void schurAssign( const SparseMatrix<MT2,SO>& rhs );
642 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
643 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
679 template< typename MT
681 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
696 template<
typename MT
698 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
743 template<
typename MT
745 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
ElementType* ptr,
size_t n )
746 : matrix_( ptr, n, n )
794 template<
typename MT
796 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
ElementType* ptr,
size_t n,
size_t nn )
797 : matrix_( ptr, n, n, nn )
815 template<
typename MT
817 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
818 : matrix_( m.matrix_ )
833 template<
typename MT
835 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
836 : matrix_( std::move( m.matrix_ ) )
855 template<
typename MT
857 template<
typename MT2 >
858 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
863 using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
864 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
866 if( IsSymmetric_v<MT2> ) {
877 resize( matrix_, tmp.rows(), tmp.rows() );
898 template<
typename MT
900 template<
typename MT2 >
901 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
906 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
907 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
909 if( IsSymmetric_v<MT2> ) {
911 assign(
trans( ~m ) );
920 resize( matrix_, tmp.rows(), tmp.rows() );
921 assign(
trans( tmp ) );
954 template<
typename MT
957 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
962 if( ( !SO && i > j ) || ( SO && i < j ) )
986 template<
typename MT
989 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const 994 if( ( !SO && i > j ) || ( SO && i < j ) )
1019 template<
typename MT
1022 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1030 return (*
this)(i,j);
1052 template<
typename MT
1055 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const 1063 return (*
this)(i,j);
1083 template<
typename MT
1085 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1088 return matrix_.data();
1105 template<
typename MT
1107 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1110 return matrix_.data(i);
1128 template<
typename MT
1134 return Iterator( matrix_, 0UL, i );
1136 return Iterator( matrix_, i, 0UL );
1154 template<
typename MT
1180 template<
typename MT
1206 template<
typename MT
1232 template<
typename MT
1258 template<
typename MT
1290 template<
typename MT
1292 inline SymmetricMatrix<MT,SO,true,false>&
1293 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1297 if( &rhs ==
this )
return *
this;
1299 resize( matrix_, rhs.rows(), rhs.columns() );
1318 template<
typename MT
1320 inline SymmetricMatrix<MT,SO,true,false>&
1321 SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1323 matrix_ = std::move( rhs.matrix_ );
1348 template<
typename MT
1350 template<
typename MT2 >
1351 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1352 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1356 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1360 if( (~rhs).isAliased(
this ) ) {
1361 SymmetricMatrix tmp( ~rhs );
1366 if( IsSparseMatrix_v<MT2> )
1394 template<
typename MT
1396 template<
typename MT2 >
1397 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1398 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1402 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1404 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1410 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1416 resize( matrix_, tmp.rows(), tmp.columns() );
1417 if( IsSparseMatrix_v<Tmp> )
1444 template<
typename MT
1446 template<
typename MT2 >
1447 inline auto SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1450 return this->operator=(
trans( ~rhs ) );
1469 template<
typename MT
1471 template<
typename MT2 >
1473 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1475 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1503 template<
typename MT
1505 template<
typename MT2 >
1507 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1509 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1511 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1517 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1548 template<
typename MT
1550 template<
typename MT2 >
1573 template<
typename MT
1575 template<
typename MT2 >
1577 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1579 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1607 template<
typename MT
1609 template<
typename MT2 >
1611 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1613 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1615 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1621 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1652 template<
typename MT
1654 template<
typename MT2 >
1678 template<
typename MT
1680 template<
typename MT2 >
1681 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1682 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1684 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1688 schurAssign( ~rhs );
1713 template<
typename MT
1715 template<
typename MT2 >
1716 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1717 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1719 using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1721 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1727 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1758 template<
typename MT
1760 template<
typename MT2 >
1761 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1764 return this->operator%=(
trans( ~rhs ) );
1778 template<
typename MT
1780 template<
typename ST >
1782 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1785 for(
size_t j=0UL; j<
columns(); ++j )
1786 for(
size_t i=0UL; i<=j; ++i )
1787 matrix_(i,j) *= rhs;
1790 for(
size_t i=0UL; i<
rows(); ++i )
1791 for(
size_t j=0UL; j<=i; ++j )
1792 matrix_(i,j) *= rhs;
1809 template<
typename MT
1811 template<
typename ST >
1813 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1818 for(
size_t j=0UL; j<
columns(); ++j )
1819 for(
size_t i=0UL; i<=j; ++i )
1820 matrix_(i,j) /= rhs;
1823 for(
size_t i=0UL; i<
rows(); ++i )
1824 for(
size_t j=0UL; j<=i; ++j )
1825 matrix_(i,j) /= rhs;
1848 template<
typename MT
1852 return matrix_.rows();
1864 template<
typename MT
1868 return matrix_.columns();
1886 template<
typename MT
1890 return matrix_.spacing();
1902 template<
typename MT
1906 return matrix_.capacity();
1923 template<
typename MT
1927 return matrix_.capacity(i);
1939 template<
typename MT
1943 size_t nonzeros( 0UL );
1947 for(
size_t j=0UL; j<
columns(); ++j ) {
1948 for(
size_t i=0UL; i<j; ++i ) {
1958 for(
size_t i=0UL; i<
rows(); ++i ) {
1959 for(
size_t j=0UL; j<i; ++j ) {
1986 template<
typename MT
1990 size_t nonzeros( 0UL );
1994 for(
size_t j=0UL; j<i; ++j ) {
1998 for(
size_t j=i; j<
rows(); ++j ) {
2005 for(
size_t j=0UL; j<i; ++j ) {
2009 for(
size_t j=i; j<
rows(); ++j ) {
2027 template<
typename MT
2034 for(
size_t j=0UL; j<
columns(); ++j )
2035 for(
size_t i=0UL; i<=j; ++i )
2036 clear( matrix_(i,j) );
2039 for(
size_t i=0UL; i<
rows(); ++i )
2040 for(
size_t j=0UL; j<=i; ++j )
2041 clear( matrix_(i,j) );
2088 template<
typename MT
2094 for(
auto element=
begin(i); element!=
end(i); ++element )
2113 template<
typename MT
2141 template<
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();
2178 template<
typename MT
2180 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2202 template<
typename MT
2204 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2222 template<
typename MT
2226 matrix_.shrinkToFit();
2239 template<
typename MT
2245 swap( matrix_, m.matrix_ );
2265 template<
typename MT
2281 template<
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 )
2320 template<
typename MT
2322 template<
typename Other >
2323 inline 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;
2361 template<
typename MT
2368 ( IsCustom_v<MT> || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2393 template<
typename MT
2395 template<
typename Other >
2396 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const noexcept
2398 return matrix_.canAlias( alias );
2415 template<
typename MT
2417 template<
typename Other >
2418 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const noexcept
2420 return matrix_.isAliased( alias );
2436 template<
typename MT
2438 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2440 return matrix_.isAligned();
2457 template<
typename MT
2459 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2461 return matrix_.canSMPAssign();
2479 template<
typename MT
2481 template<
typename MT2 >
2482 inline 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) );
2514 template<
typename MT
2516 template<
typename MT2 >
2517 inline 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);
2549 template<
typename MT
2551 template<
typename MT2 >
2552 inline 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();
2588 template<
typename MT
2590 template<
typename MT2 >
2591 inline 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);
2623 template<
typename MT
2625 template<
typename MT2 >
2626 inline 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();
2662 template<
typename MT
2664 template<
typename MT2 >
2665 inline 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);
2697 template<
typename MT
2699 template<
typename MT2 >
2700 inline 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();
2736 template<
typename MT
2738 template<
typename MT2 >
2739 inline 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);
2771 template<
typename MT
2773 template<
typename MT2 >
2774 inline 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 the implementation of the Submatrix view.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1004
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1271
#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
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
Header file for the UNUSED_PARAMETER function template.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
Header file for the IsSparseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
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:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:446
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:135
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is a numeric (integral or floating point) d...
Definition: Numeric.h:81
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
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:8908
Header file for the RemoveAdaptor type trait.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Header file for all forward declarations for expression class templates.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
Constraint on the data type.
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:539
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:718
Header file for the RemoveReference type trait.
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.The IsComputation_v variable template pr...
Definition: IsComputation.h:90
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
#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
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5863
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, 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
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825