35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_ 36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_ 106 template<
typename MT
108 class SymmetricMatrix<MT,SO,false,false>
109 :
public SparseMatrix< SymmetricMatrix<MT,SO,false,false>, SO >
113 typedef OppositeType_<MT> OT;
114 typedef TransposeType_<MT> TT;
115 typedef ElementType_<MT> ET;
118 typedef typename MT::template Rebind< SharedValue<ET> >::Other MatrixType;
123 typedef SymmetricMatrix<MT,SO,false,false>
This;
124 typedef SparseMatrix<This,SO>
BaseType;
126 typedef SymmetricMatrix<OT,!SO,false,false>
OppositeType;
131 typedef NonNumericProxy<MatrixType>
Reference;
138 template<
typename NewType >
141 typedef SymmetricMatrix< typename MT::template Rebind<NewType>::Other > Other;
148 template<
size_t NewM
152 typedef SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
159 template<
typename IteratorType >
160 class SharedElement :
private SparseElement
164 typedef ET ValueType;
165 typedef size_t IndexType;
168 typedef SharedElement* Pointer;
169 typedef const SharedElement* ConstPointer;
177 inline SharedElement( IteratorType pos )
188 template<
typename T >
inline SharedElement& operator=(
const T& v ) {
200 template<
typename T >
inline SharedElement&
operator+=(
const T& v ) {
212 template<
typename T >
inline SharedElement&
operator-=(
const T& v ) {
224 template<
typename T >
inline SharedElement&
operator*=(
const T& v ) {
236 template<
typename T >
inline SharedElement&
operator/=(
const T& v ) {
247 inline Pointer operator->() {
257 inline ConstPointer operator->()
const {
267 inline Reference value() {
268 return *pos_->value();
277 inline ConstReference value()
const {
278 return *pos_->value();
287 inline IndexType index()
const {
288 return pos_->index();
302 template<
typename SparseElementType
303 ,
typename IteratorType >
308 typedef std::forward_iterator_tag IteratorCategory;
309 typedef SparseElementType ValueType;
310 typedef SparseElementType PointerType;
311 typedef SparseElementType ReferenceType;
312 typedef ptrdiff_t DifferenceType;
315 typedef IteratorCategory iterator_category;
316 typedef ValueType value_type;
317 typedef PointerType pointer;
318 typedef ReferenceType reference;
319 typedef DifferenceType difference_type;
325 inline SharedIterator()
335 inline SharedIterator( IteratorType pos )
345 template<
typename SparseElementType2,
typename IteratorType2 >
346 inline SharedIterator(
const SharedIterator<SparseElementType2,IteratorType2>& it )
356 inline SharedIterator& operator++() {
367 inline const SharedIterator operator++(
int ) {
368 const SharedIterator tmp( *
this );
380 return ReferenceType( pos_ );
389 inline PointerType operator->()
const {
390 return PointerType( pos_ );
400 inline bool operator==(
const SharedIterator& rhs )
const {
401 return pos_ == rhs.pos_;
411 inline bool operator!=(
const SharedIterator& rhs )
const {
412 return !( *
this == rhs );
422 inline DifferenceType
operator-(
const SharedIterator& rhs )
const {
423 return pos_ - rhs.pos_;
432 inline IteratorType base()
const {
443 template<
typename SparseElementType2,
typename IteratorType2 >
friend class SharedIterator;
450 typedef SharedIterator< SharedElement< Iterator_<MatrixType> >
451 , Iterator_<MatrixType>
455 typedef SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
456 , ConstIterator_<MatrixType>
462 enum :
bool { smpAssignable =
false };
468 explicit inline SymmetricMatrix();
469 explicit inline SymmetricMatrix(
size_t n );
470 explicit inline SymmetricMatrix(
size_t n,
size_t nonzeros );
471 explicit inline SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros );
473 inline SymmetricMatrix(
const SymmetricMatrix& m );
474 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
476 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
477 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
488 inline Reference operator()(
size_t i,
size_t j );
489 inline ConstReference operator()(
size_t i,
size_t j )
const;
490 inline Reference at(
size_t i,
size_t j );
491 inline ConstReference at(
size_t i,
size_t j )
const;
492 inline Iterator
begin (
size_t i );
493 inline ConstIterator
begin (
size_t i )
const;
494 inline ConstIterator
cbegin(
size_t i )
const;
495 inline Iterator
end (
size_t i );
496 inline ConstIterator
end (
size_t i )
const;
497 inline ConstIterator
cend (
size_t i )
const;
504 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
505 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
507 template<
typename MT2 >
508 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
510 template<
typename MT2 >
511 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
513 template<
typename MT2 >
514 inline 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 SymmetricMatrix&
operator+=(
const Matrix<MT2,!SO>& rhs );
522 template<
typename MT2 >
523 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,SO>& rhs );
525 template<
typename MT2 >
526 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,!SO>& rhs );
528 template<
typename MT2,
bool SO2 >
529 inline SymmetricMatrix&
operator*=(
const Matrix<MT2,SO2>& rhs );
531 template<
typename Other >
532 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >&
operator*=( Other rhs );
534 template<
typename Other >
535 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >&
operator/=( Other rhs );
542 inline size_t rows() const noexcept;
543 inline
size_t columns() const noexcept;
544 inline
size_t capacity() const noexcept;
545 inline
size_t capacity(
size_t i ) const noexcept;
547 inline
size_t nonZeros(
size_t i ) const;
549 inline
void reset(
size_t i );
551 inline
void resize (
size_t n,
bool preserve=true );
552 inline
void reserve(
size_t nonzeros );
553 inline
void reserve(
size_t i,
size_t nonzeros );
555 inline
void trim(
size_t i );
556 inline
void swap( SymmetricMatrix& m ) noexcept;
563 inline Iterator
set (
size_t i,
size_t j, const ElementType& value );
564 inline Iterator insert (
size_t i,
size_t j, const ElementType& value );
565 inline
void append (
size_t i,
size_t j, const ElementType& value,
bool check=false );
566 inline
void finalize(
size_t i );
573 inline
void erase(
size_t i,
size_t j );
574 inline Iterator erase(
size_t i, Iterator pos );
575 inline Iterator erase(
size_t i, Iterator first, Iterator last );
577 template< typename Pred >
578 inline
void erase( Pred predicate );
580 template< typename Pred >
581 inline
void erase(
size_t i, Iterator first, Iterator last, Pred predicate );
588 inline Iterator find (
size_t i,
size_t j );
589 inline ConstIterator find (
size_t i,
size_t j ) const;
590 inline Iterator lowerBound(
size_t i,
size_t j );
591 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
592 inline Iterator upperBound(
size_t i,
size_t j );
593 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
603 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
604 template< typename Other > inline SymmetricMatrix& scaleDiagonal( const Other& scale );
611 inline
bool isIntact() const noexcept;
618 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
619 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
621 inline
bool canSMPAssign() const noexcept;
629 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
630 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
631 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
632 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
644 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
645 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
681 template< typename MT
683 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
700 template<
typename MT
702 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
722 template<
typename MT
724 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
725 : matrix_( n, n, nonzeros )
746 template<
typename MT
748 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
749 : matrix_( n, n, nonzeros )
765 template<
typename MT
767 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
772 resize( matrix_, m.rows(), m.columns() );
788 template<
typename MT
790 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
791 : matrix_( std::move( m.matrix_ ) )
810 template<
typename MT
812 template<
typename MT2 >
813 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
818 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
819 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
823 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
827 resize( matrix_, tmp.rows(), tmp.columns() );
847 template<
typename MT
849 template<
typename MT2 >
850 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
855 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
856 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
860 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
864 resize( matrix_, tmp.rows(), tmp.columns() );
865 assign(
trans( tmp ) );
897 template<
typename MT
900 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
926 template<
typename MT
929 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const 934 return *matrix_(i,j);
956 template<
typename MT
959 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
989 template<
typename MT
992 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const 1000 return (*
this)(i,j);
1018 template<
typename MT
1023 return Iterator( matrix_.begin(i) );
1041 template<
typename MT
1064 template<
typename MT
1087 template<
typename MT
1110 template<
typename MT
1133 template<
typename MT
1162 template<
typename MT
1164 inline SymmetricMatrix<MT,SO,false,false>&
1165 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1169 if( &rhs ==
this )
return *
this;
1171 resize( matrix_, rhs.rows(), rhs.columns() );
1191 template<
typename MT
1193 inline SymmetricMatrix<MT,SO,false,false>&
1194 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1196 matrix_ = std::move( rhs.matrix_ );
1221 template<
typename MT
1223 template<
typename MT2 >
1224 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1225 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1229 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1233 if( (~rhs).canAlias(
this ) ) {
1234 SymmetricMatrix tmp( ~rhs );
1266 template<
typename MT
1268 template<
typename MT2 >
1269 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1270 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1274 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1278 const ResultType_<MT2> tmp( ~rhs );
1280 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
1284 resize( matrix_, tmp.rows(), tmp.columns() );
1311 template<
typename MT
1313 template<
typename MT2 >
1314 inline SymmetricMatrix<MT,SO,false,false>&
1315 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1317 return this->operator=(
trans( ~rhs ) );
1336 template<
typename MT
1338 template<
typename MT2 >
1339 inline SymmetricMatrix<MT,SO,false,false>&
1344 typedef AddTrait_< MT, ResultType_<MT2> > Tmp;
1346 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1350 Tmp tmp( (*
this) + ~rhs );
1352 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1356 resize( matrix_, tmp.rows(), tmp.columns() );
1383 template<
typename MT
1385 template<
typename MT2 >
1386 inline SymmetricMatrix<MT,SO,false,false>&
1408 template<
typename MT
1410 template<
typename MT2 >
1411 inline SymmetricMatrix<MT,SO,false,false>&
1416 typedef SubTrait_< MT, ResultType_<MT2> > Tmp;
1418 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1422 Tmp tmp( (*
this) - ~rhs );
1424 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1428 resize( matrix_, tmp.rows(), tmp.columns() );
1455 template<
typename MT
1457 template<
typename MT2 >
1458 inline SymmetricMatrix<MT,SO,false,false>&
1479 template<
typename MT
1481 template<
typename MT2
1483 inline SymmetricMatrix<MT,SO,false,false>&
1488 typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1490 if( matrix_.rows() != (~rhs).
columns() ) {
1494 Tmp tmp( (*
this) * ~rhs );
1496 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1500 resize( matrix_, tmp.rows(), tmp.columns() );
1521 template<
typename MT
1523 template<
typename Other >
1524 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1527 for(
size_t i=0UL; i<
rows(); ++i ) {
1528 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1529 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1530 *element->value() *= rhs;
1547 template<
typename MT
1549 template<
typename Other >
1550 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1555 for(
size_t i=0UL; i<
rows(); ++i ) {
1556 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1557 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1558 *element->value() /= rhs;
1581 template<
typename MT
1585 return matrix_.rows();
1597 template<
typename MT
1601 return matrix_.columns();
1613 template<
typename MT
1617 return matrix_.capacity();
1634 template<
typename MT
1638 return matrix_.capacity(i);
1650 template<
typename MT
1654 return matrix_.nonZeros();
1672 template<
typename MT
1676 return matrix_.nonZeros(i);
1688 template<
typename MT
1738 template<
typename MT
1742 for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1744 const size_t j( it->index() );
1750 const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1752 matrix_.erase( j, pos );
1755 const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1757 matrix_.erase( j, pos );
1775 template<
typename MT
1802 template<
typename MT
1812 matrix_.resize( n, n,
true );
1829 template<
typename MT
1831 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1833 matrix_.reserve( nonzeros );
1853 template<
typename MT
1855 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1857 matrix_.reserve( i, nonzeros );
1874 template<
typename MT
1876 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1896 template<
typename MT
1898 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
1913 template<
typename MT
1919 swap( matrix_, m.matrix_ );
1947 template<
typename MT
1952 SharedValue<ET> shared( value );
1955 matrix_.set( j, i, shared );
1957 return Iterator( matrix_.set( i, j, shared ) );
1978 template<
typename MT
1981 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
1983 SharedValue<ET> shared( value );
1986 matrix_.insert( j, i, shared );
1988 return Iterator( matrix_.insert( i, j, shared ) );
2049 template<
typename MT
2051 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2053 SharedValue<ET> shared( value );
2055 matrix_.append( i, j, shared, check );
2056 if( i != j && ( !check || !
isDefault( value ) ) )
2057 matrix_.insert( j, i, shared );
2077 template<
typename MT
2079 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2105 template<
typename MT
2107 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
2109 matrix_.erase( i, j );
2111 matrix_.erase( j, i );
2129 template<
typename MT
2132 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator pos )
2134 if( pos ==
end( i ) )
2137 const size_t j( pos->index() );
2140 return Iterator( matrix_.erase( i, pos.base() ) );
2144 matrix_.erase( j, matrix_.find( i, j ) );
2145 return Iterator( matrix_.erase( i, pos.base() ) );
2149 matrix_.erase( j, matrix_.find( j, i ) );
2150 return Iterator( matrix_.erase( i, pos.base() ) );
2171 template<
typename MT
2174 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator first, Iterator last )
2176 for( Iterator it=first; it!=last; ++it )
2178 const size_t j( it->index() );
2185 matrix_.erase( i, j );
2189 matrix_.erase( j, i );
2193 return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2213 template<
typename MT
2215 template<
typename Pred >
2216 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2218 matrix_.erase( [predicate=predicate](
const SharedValue<ET>& value ) {
2219 return predicate( *value );
2247 template<
typename MT
2249 template<
typename Pred >
2251 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator first, Iterator last, Pred predicate )
2253 for( Iterator it=first; it!=last; ++it ) {
2254 const size_t j( it->index() );
2255 if( i != j && predicate( it->value() ) ) {
2257 matrix_.erase( i, j );
2259 matrix_.erase( j, i );
2263 matrix_.erase( i, first.base(), last.base(),
2264 [predicate=predicate](
const SharedValue<ET>& value ) {
2265 return predicate( *value );
2298 template<
typename MT
2301 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2303 return Iterator( matrix_.find( i, j ) );
2325 template<
typename MT
2328 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const 2352 template<
typename MT
2355 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2357 return Iterator( matrix_.lowerBound( i, j ) );
2379 template<
typename MT
2382 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const 2406 template<
typename MT
2409 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2411 return Iterator( matrix_.upperBound( i, j ) );
2433 template<
typename MT
2436 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const 2458 template<
typename MT
2474 template<
typename MT
2478 for(
size_t i=0UL; i<
rows(); ++i ) {
2479 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2480 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2497 template<
typename MT
2499 template<
typename Other >
2500 inline SymmetricMatrix<MT,SO,false,false>&
2501 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2503 for(
size_t i=0UL; i<
rows(); ++i ) {
2504 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2505 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2506 ( *element->value() ).scale( scalar );
2522 template<
typename MT
2524 template<
typename Other >
2525 inline SymmetricMatrix<MT,SO,false,false>&
2526 SymmetricMatrix<MT,SO,false,false>::scaleDiagonal(
const Other& scalar )
2528 matrix_.scaleDiagonal( scalar );
2553 template<
typename MT
2584 template<
typename MT
2586 template<
typename Other >
2587 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2589 return matrix_.canAlias( alias );
2606 template<
typename MT
2608 template<
typename Other >
2609 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2611 return matrix_.isAliased( alias );
2628 template<
typename MT
2630 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2632 return matrix_.canSMPAssign();
2650 template<
typename MT
2652 template<
typename MT2 >
2653 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2660 std::vector<size_t> nonzeros(
rows(), 0UL );
2663 for(
size_t i=0UL; i<
rows(); ++i ) {
2668 matrix_.reserve(
sum );
2669 for(
size_t i=0UL; i<
rows(); ++i ) {
2670 matrix_.reserve( i, nonzeros[i] );
2673 for(
size_t i=0UL; i<
rows(); ++i ) {
2674 for(
size_t j=i; j<
columns(); ++j ) {
2676 SharedValue<ET> shared;
2677 *shared = std::move( (~rhs)(i,j) );
2678 matrix_.append( i, j, shared,
false );
2680 matrix_.append( j, i, shared,
false );
2701 template<
typename MT
2703 template<
typename MT2 >
2704 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2711 std::vector<size_t> nonzeros(
rows(), 0UL );
2714 for(
size_t i=0UL; i<
rows(); ++i ) {
2719 matrix_.reserve(
sum );
2720 for(
size_t i=0UL; i<
rows(); ++i ) {
2721 matrix_.reserve( i, nonzeros[i] );
2724 for(
size_t i=0UL; i<
rows(); ++i ) {
2725 for(
size_t j=i; j<
columns(); ++j ) {
2727 const SharedValue<ET> shared( (~rhs)(i,j) );
2728 matrix_.append( i, j, shared,
false );
2730 matrix_.append( j, i, shared,
false );
2751 template<
typename MT
2753 template<
typename MT2 >
2754 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2761 std::vector<size_t> nonzeros(
rows(), 0UL );
2764 for(
size_t i=0UL; i<
rows(); ++i ) {
2769 matrix_.reserve(
sum );
2770 for(
size_t i=0UL; i<
rows(); ++i ) {
2771 matrix_.reserve( i, nonzeros[i] );
2774 for(
size_t i=0UL; i<
rows(); ++i ) {
2775 for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2777 SharedValue<ET> shared;
2778 *shared = std::move( it->value() );
2779 matrix_.append( i, it->index(), shared, false );
2780 if( i != it->index() )
2781 matrix_.append( it->index(), i, shared, false );
2802 template<
typename MT
2804 template<
typename MT2 >
2805 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2812 std::vector<size_t> nonzeros(
rows(), 0UL );
2815 for(
size_t i=0UL; i<
rows(); ++i ) {
2820 matrix_.reserve(
sum );
2821 for(
size_t i=0UL; i<
rows(); ++i ) {
2822 matrix_.reserve( i, nonzeros[i] );
2825 for(
size_t i=0UL; i<
rows(); ++i ) {
2826 for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2828 const SharedValue<ET> shared( it->value() );
2829 matrix_.append( i, it->index(), shared, false );
2830 if( i != it->index() )
2831 matrix_.append( it->index(), i, shared, false );
#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
Constraint on the data type.
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.
Header file for the subtraction trait.
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.
BLAZE_ALWAYS_INLINE const complex< int8_t > sum(const SIMDcint8 &a) noexcept
Returns the sum of all elements in the 8-bit integral complex SIMD vector.
Definition: Reduction.h:63
#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_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
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.
Header file for the SharedValue class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
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 SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
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
#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 Columns type trait.
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
Header file for the SparseElement base class.
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
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#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.
Header file for the addition trait.
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
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
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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:570