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 ET >
141 typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
148 template<
typename IteratorType >
149 class SharedElement :
private SparseElement
153 typedef ET ValueType;
154 typedef size_t IndexType;
157 typedef SharedElement* Pointer;
158 typedef const SharedElement* ConstPointer;
166 inline SharedElement( IteratorType pos )
177 template<
typename T >
inline SharedElement& operator=(
const T& v ) {
189 template<
typename T >
inline SharedElement&
operator+=(
const T& v ) {
201 template<
typename T >
inline SharedElement&
operator-=(
const T& v ) {
213 template<
typename T >
inline SharedElement&
operator*=(
const T& v ) {
225 template<
typename T >
inline SharedElement&
operator/=(
const T& v ) {
236 inline Pointer operator->() {
246 inline ConstPointer operator->()
const {
256 inline Reference value() {
257 return *pos_->value();
266 inline ConstReference value()
const {
267 return *pos_->value();
276 inline IndexType index()
const {
277 return pos_->index();
291 template<
typename SparseElementType
292 ,
typename IteratorType >
297 typedef std::forward_iterator_tag IteratorCategory;
298 typedef SparseElementType ValueType;
299 typedef SparseElementType PointerType;
300 typedef SparseElementType ReferenceType;
301 typedef ptrdiff_t DifferenceType;
304 typedef IteratorCategory iterator_category;
305 typedef ValueType value_type;
306 typedef PointerType pointer;
307 typedef ReferenceType reference;
308 typedef DifferenceType difference_type;
314 inline SharedIterator()
324 inline SharedIterator( IteratorType pos )
334 template<
typename SparseElementType2,
typename IteratorType2 >
335 inline SharedIterator(
const SharedIterator<SparseElementType2,IteratorType2>& it )
345 inline SharedIterator& operator++() {
356 inline const SharedIterator operator++(
int ) {
357 const SharedIterator tmp( *
this );
369 return ReferenceType( pos_ );
378 inline PointerType operator->()
const {
379 return PointerType( pos_ );
389 inline bool operator==(
const SharedIterator& rhs )
const {
390 return pos_ == rhs.pos_;
400 inline bool operator!=(
const SharedIterator& rhs )
const {
401 return !( *
this == rhs );
411 inline DifferenceType
operator-(
const SharedIterator& rhs )
const {
412 return pos_ - rhs.pos_;
421 inline IteratorType base()
const {
432 template<
typename SparseElementType2,
typename IteratorType2 >
friend class SharedIterator;
439 typedef SharedIterator< SharedElement< Iterator_<MatrixType> >
440 , Iterator_<MatrixType>
444 typedef SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
445 , ConstIterator_<MatrixType>
451 enum :
bool { smpAssignable =
false };
457 explicit inline SymmetricMatrix();
458 explicit inline SymmetricMatrix(
size_t n );
459 explicit inline SymmetricMatrix(
size_t n,
size_t nonzeros );
460 explicit inline SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros );
462 inline SymmetricMatrix(
const SymmetricMatrix& m );
463 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
465 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
466 template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
477 inline Reference operator()(
size_t i,
size_t j );
478 inline ConstReference operator()(
size_t i,
size_t j ) const;
479 inline Reference at(
size_t i,
size_t j );
480 inline ConstReference at(
size_t i,
size_t j ) const;
481 inline Iterator
begin (
size_t i );
482 inline ConstIterator
begin (
size_t i ) const;
483 inline ConstIterator
cbegin(
size_t i ) const;
484 inline Iterator
end (
size_t i );
485 inline ConstIterator
end (
size_t i ) const;
486 inline ConstIterator
cend (
size_t i ) const;
493 inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
494 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
496 template< typename MT2 >
497 inline
DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
499 template< typename MT2 >
500 inline
EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
502 template< typename MT2 >
503 inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
505 template< typename MT2 >
506 inline SymmetricMatrix& operator+=( const Matrix<MT2,SO>& rhs );
508 template< typename MT2 >
509 inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
511 template< typename MT2 >
512 inline SymmetricMatrix& operator-=( const Matrix<MT2,SO>& rhs );
514 template< typename MT2 >
515 inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
517 template< typename MT2,
bool SO2 >
518 inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
520 template< typename Other >
521 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
523 template< typename Other >
524 inline
EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
531 inline
size_t rows() const noexcept;
532 inline
size_t columns() const noexcept;
533 inline
size_t capacity() const noexcept;
534 inline
size_t capacity(
size_t i ) const noexcept;
536 inline
size_t nonZeros(
size_t i ) const;
538 inline
void reset(
size_t i );
540 inline Iterator
set(
size_t i,
size_t j, const ElementType& value );
541 inline Iterator insert(
size_t i,
size_t j, const ElementType& value );
542 inline
void erase(
size_t i,
size_t j );
543 inline Iterator erase(
size_t i, Iterator pos );
544 inline Iterator erase(
size_t i, Iterator first, Iterator last );
545 inline
void resize (
size_t n,
bool preserve=true );
546 inline
void reserve(
size_t nonzeros );
547 inline
void reserve(
size_t i,
size_t nonzeros );
549 inline
void trim(
size_t i );
552 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
553 template< typename Other > inline SymmetricMatrix& scaleDiagonal( Other scale );
554 inline
void swap( SymmetricMatrix& m ) noexcept;
561 inline Iterator find (
size_t i,
size_t j );
562 inline ConstIterator find (
size_t i,
size_t j ) const;
563 inline Iterator lowerBound(
size_t i,
size_t j );
564 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
565 inline Iterator upperBound(
size_t i,
size_t j );
566 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
573 inline
void append (
size_t i,
size_t j, const ElementType& value,
bool check=false );
574 inline
void finalize(
size_t i );
581 inline
bool isIntact() const noexcept;
588 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
589 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
591 inline
bool canSMPAssign() const noexcept;
599 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
600 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
601 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
602 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
614 template< typename MT2,
bool SO2,
bool DF2,
bool NF2 >
615 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
651 template< typename MT
653 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
670 template<
typename MT
672 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
692 template<
typename MT
694 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
695 : matrix_( n, n, nonzeros )
716 template<
typename MT
718 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
719 : matrix_( n, n, nonzeros )
735 template<
typename MT
737 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
742 resize( matrix_, m.rows(), m.columns() );
758 template<
typename MT
760 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
761 : matrix_(
std::move( m.matrix_ ) )
780 template<
typename MT
782 template<
typename MT2 >
783 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
788 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
789 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
793 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
797 resize( matrix_, tmp.rows(), tmp.columns() );
817 template<
typename MT
819 template<
typename MT2 >
820 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
825 typedef RemoveAdaptor_< ResultType_<MT2> > RT;
826 typedef If_< IsComputation<MT2>, RT,
const MT2& > Tmp;
830 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
834 resize( matrix_, tmp.rows(), tmp.columns() );
835 assign(
trans( tmp ) );
867 template<
typename MT
870 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
896 template<
typename MT
899 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const
904 return *matrix_(i,j);
926 template<
typename MT
929 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
959 template<
typename MT
962 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const
988 template<
typename MT
993 return Iterator( matrix_.begin(i) );
1011 template<
typename MT
1034 template<
typename MT
1057 template<
typename MT
1080 template<
typename MT
1103 template<
typename MT
1132 template<
typename MT
1134 inline SymmetricMatrix<MT,SO,false,false>&
1135 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1139 if( &rhs ==
this )
return *
this;
1141 resize( matrix_, rhs.rows(), rhs.columns() );
1161 template<
typename MT
1163 inline SymmetricMatrix<MT,SO,false,false>&
1164 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1166 matrix_ = std::move( rhs.matrix_ );
1191 template<
typename MT
1193 template<
typename MT2 >
1194 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1195 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1199 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1203 if( (~rhs).canAlias(
this ) ) {
1204 SymmetricMatrix tmp( ~rhs );
1236 template<
typename MT
1238 template<
typename MT2 >
1239 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1240 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1244 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1248 const ResultType_<MT2> tmp( ~rhs );
1250 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
1254 resize( matrix_, tmp.rows(), tmp.columns() );
1281 template<
typename MT
1283 template<
typename MT2 >
1284 inline SymmetricMatrix<MT,SO,false,false>&
1285 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1287 return this->operator=(
trans( ~rhs ) );
1306 template<
typename MT
1308 template<
typename MT2 >
1309 inline SymmetricMatrix<MT,SO,false,false>&
1314 typedef AddTrait_< MT, ResultType_<MT2> > Tmp;
1316 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1320 Tmp tmp( (*
this) + ~rhs );
1322 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1326 resize( matrix_, tmp.rows(), tmp.columns() );
1353 template<
typename MT
1355 template<
typename MT2 >
1356 inline SymmetricMatrix<MT,SO,false,false>&
1378 template<
typename MT
1380 template<
typename MT2 >
1381 inline SymmetricMatrix<MT,SO,false,false>&
1386 typedef SubTrait_< MT, ResultType_<MT2> > Tmp;
1388 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1392 Tmp tmp( (*
this) - ~rhs );
1394 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1398 resize( matrix_, tmp.rows(), tmp.columns() );
1425 template<
typename MT
1427 template<
typename MT2 >
1428 inline SymmetricMatrix<MT,SO,false,false>&
1449 template<
typename MT
1451 template<
typename MT2
1453 inline SymmetricMatrix<MT,SO,false,false>&
1458 typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1460 if( matrix_.rows() != (~rhs).
columns() ) {
1464 Tmp tmp( (*
this) * ~rhs );
1466 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1470 resize( matrix_, tmp.rows(), tmp.columns() );
1491 template<
typename MT
1493 template<
typename Other >
1494 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1497 for(
size_t i=0UL; i<
rows(); ++i ) {
1498 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1499 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1500 *element->value() *= rhs;
1517 template<
typename MT
1519 template<
typename Other >
1520 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1525 for(
size_t i=0UL; i<
rows(); ++i ) {
1526 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1527 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1528 *element->value() /= rhs;
1551 template<
typename MT
1555 return matrix_.rows();
1567 template<
typename MT
1571 return matrix_.columns();
1583 template<
typename MT
1587 return matrix_.capacity();
1604 template<
typename MT
1608 return matrix_.capacity(i);
1620 template<
typename MT
1624 return matrix_.nonZeros();
1642 template<
typename MT
1646 return matrix_.nonZeros(i);
1658 template<
typename MT
1708 template<
typename MT
1712 for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1714 const size_t j( it->index() );
1720 const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1722 matrix_.erase( j, pos );
1725 const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1727 matrix_.erase( j, pos );
1745 template<
typename MT
1771 template<
typename MT
1776 SharedValue<ET> shared( value );
1779 matrix_.set( j, i, shared );
1781 return Iterator( matrix_.set( i, j, shared ) );
1802 template<
typename MT
1805 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
1807 SharedValue<ET> shared( value );
1810 matrix_.insert( j, i, shared );
1812 return Iterator( matrix_.insert( i, j, shared ) );
1828 template<
typename MT
1830 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
1832 matrix_.erase( i, j );
1834 matrix_.erase( j, i );
1852 template<
typename MT
1855 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator pos )
1857 if( pos ==
end( i ) )
1860 const size_t j( pos->index() );
1863 return Iterator( matrix_.erase( i, pos.base() ) );
1867 matrix_.erase( j, matrix_.find( i, j ) );
1868 return Iterator( matrix_.erase( i, pos.base() ) );
1872 matrix_.erase( j, matrix_.find( j, i ) );
1873 return Iterator( matrix_.erase( i, pos.base() ) );
1894 template<
typename MT
1897 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator first, Iterator last )
1899 for( Iterator it=first; it!=last; ++it )
1901 const size_t j( it->index() );
1908 matrix_.erase( i, j );
1912 matrix_.erase( j, i );
1916 return Iterator( matrix_.erase( i, first.base(), last.base() ) );
1937 template<
typename MT
1947 matrix_.resize( n, n,
true );
1964 template<
typename MT
1966 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1968 matrix_.reserve( nonzeros );
1988 template<
typename MT
1990 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1992 matrix_.reserve( i, nonzeros );
2009 template<
typename MT
2011 inline void SymmetricMatrix<MT,SO,false,false>::trim()
2031 template<
typename MT
2033 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
2047 template<
typename MT
2063 template<
typename MT
2067 for(
size_t i=0UL; i<
rows(); ++i ) {
2068 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2069 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2086 template<
typename MT
2088 template<
typename Other >
2089 inline SymmetricMatrix<MT,SO,false,false>&
2090 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2092 for(
size_t i=0UL; i<
rows(); ++i ) {
2093 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2094 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2095 ( *element->value() ).scale( scalar );
2111 template<
typename MT
2113 template<
typename Other >
2114 inline SymmetricMatrix<MT,SO,false,false>&
2115 SymmetricMatrix<MT,SO,false,false>::scaleDiagonal( Other scalar )
2117 matrix_.scaleDiagonal( scalar );
2131 template<
typename MT
2137 swap( matrix_, m.matrix_ );
2167 template<
typename MT
2170 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2172 return Iterator( matrix_.find( i, j ) );
2194 template<
typename MT
2197 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const
2221 template<
typename MT
2224 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2226 return Iterator( matrix_.lowerBound( i, j ) );
2248 template<
typename MT
2251 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const
2275 template<
typename MT
2278 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2280 return Iterator( matrix_.upperBound( i, j ) );
2302 template<
typename MT
2305 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const
2376 template<
typename MT
2378 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2380 SharedValue<ET> shared( value );
2382 matrix_.append( i, j, shared, check );
2383 if( i != j && ( !check || !
isDefault( value ) ) )
2384 matrix_.insert( j, i, shared );
2404 template<
typename MT
2406 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2432 template<
typename MT
2463 template<
typename MT
2465 template<
typename Other >
2466 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2468 return matrix_.canAlias( alias );
2485 template<
typename MT
2487 template<
typename Other >
2488 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2490 return matrix_.isAliased( alias );
2507 template<
typename MT
2509 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2511 return matrix_.canSMPAssign();
2529 template<
typename MT
2531 template<
typename MT2 >
2532 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2539 std::vector<size_t> nonzeros(
rows(), 0UL );
2542 for(
size_t i=0UL; i<
rows(); ++i ) {
2547 matrix_.reserve(
sum );
2548 for(
size_t i=0UL; i<
rows(); ++i ) {
2549 matrix_.reserve( i, nonzeros[i] );
2552 for(
size_t i=0UL; i<
rows(); ++i ) {
2553 for(
size_t j=i; j<
columns(); ++j ) {
2555 SharedValue<ET> shared;
2556 *shared = std::move( (~rhs)(i,j) );
2557 matrix_.append( i, j, shared,
false );
2559 matrix_.append( j, i, shared,
false );
2580 template<
typename MT
2582 template<
typename MT2 >
2583 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2590 std::vector<size_t> nonzeros(
rows(), 0UL );
2593 for(
size_t i=0UL; i<
rows(); ++i ) {
2598 matrix_.reserve(
sum );
2599 for(
size_t i=0UL; i<
rows(); ++i ) {
2600 matrix_.reserve( i, nonzeros[i] );
2603 for(
size_t i=0UL; i<
rows(); ++i ) {
2604 for(
size_t j=i; j<
columns(); ++j ) {
2606 const SharedValue<ET> shared( (~rhs)(i,j) );
2607 matrix_.append( i, j, shared,
false );
2609 matrix_.append( j, i, shared,
false );
2630 template<
typename MT
2632 template<
typename MT2 >
2633 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2640 std::vector<size_t> nonzeros(
rows(), 0UL );
2643 for(
size_t i=0UL; i<
rows(); ++i ) {
2648 matrix_.reserve(
sum );
2649 for(
size_t i=0UL; i<
rows(); ++i ) {
2650 matrix_.reserve( i, nonzeros[i] );
2653 for(
size_t i=0UL; i<
rows(); ++i ) {
2654 for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2656 SharedValue<ET> shared;
2657 *shared = std::move( it->value() );
2658 matrix_.append( i, it->index(), shared, false );
2659 if( i != it->index() )
2660 matrix_.append( it->index(), i, shared, false );
2681 template<
typename MT
2683 template<
typename MT2 >
2684 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2691 std::vector<size_t> nonzeros(
rows(), 0UL );
2694 for(
size_t i=0UL; i<
rows(); ++i ) {
2699 matrix_.reserve(
sum );
2700 for(
size_t i=0UL; i<
rows(); ++i ) {
2701 matrix_.reserve( i, nonzeros[i] );
2704 for(
size_t i=0UL; i<
rows(); ++i ) {
2705 for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2707 const SharedValue<ET> shared( it->value() );
2708 matrix_.append( i, it->index(), shared, false );
2709 if( i != it->index() )
2710 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.
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
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:346
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.
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.
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: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
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
#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
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
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.
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.
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 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
#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.
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
Header file for the SparseElement base class.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
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: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.
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: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
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
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
#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:564