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 using OT = OppositeType_<MT>;
114 using TT = TransposeType_<MT>;
115 using ET = ElementType_<MT>;
118 using MatrixType =
typename MT::template Rebind< SharedValue<ET> >::Other;
123 using This = SymmetricMatrix<MT,SO,false,false>;
124 using BaseType = SparseMatrix<This,SO>;
126 using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
131 using Reference = NonNumericProxy<MatrixType>;
138 template<
typename NewType >
141 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
148 template<
size_t NewM
152 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
159 template<
typename IteratorType >
161 :
private SparseElement
165 using ValueType = ET;
166 using IndexType = size_t;
169 using Pointer = SharedElement*;
170 using ConstPointer =
const SharedElement*;
178 inline SharedElement( IteratorType pos )
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 ) {
237 template<
typename T >
inline SharedElement&
operator/=(
const T& v ) {
248 inline Pointer operator->() {
258 inline ConstPointer operator->()
const {
269 return *pos_->value();
279 return *pos_->value();
288 inline IndexType index()
const {
289 return pos_->index();
303 template<
typename SparseElementType
304 ,
typename IteratorType >
309 using IteratorCategory = std::forward_iterator_tag;
310 using ValueType = SparseElementType;
311 using PointerType = SparseElementType;
312 using ReferenceType = SparseElementType;
313 using DifferenceType = ptrdiff_t;
316 using iterator_category = IteratorCategory;
317 using value_type = ValueType;
318 using pointer = PointerType;
319 using reference = ReferenceType;
320 using difference_type = DifferenceType;
326 inline SharedIterator()
336 inline SharedIterator( IteratorType pos )
346 template<
typename SparseElementType2,
typename IteratorType2 >
347 inline SharedIterator(
const SharedIterator<SparseElementType2,IteratorType2>& it )
357 inline SharedIterator& operator++() {
368 inline const SharedIterator operator++(
int ) {
369 const SharedIterator tmp( *
this );
381 return ReferenceType( pos_ );
390 inline PointerType operator->()
const {
391 return PointerType( pos_ );
401 inline bool operator==(
const SharedIterator& rhs )
const {
402 return pos_ == rhs.pos_;
412 inline bool operator!=(
const SharedIterator& rhs )
const {
413 return !( *
this == rhs );
423 inline DifferenceType
operator-(
const SharedIterator& rhs )
const {
424 return pos_ - rhs.pos_;
433 inline IteratorType base()
const {
444 template<
typename SparseElementType2,
typename IteratorType2 >
friend class SharedIterator;
451 using Iterator = SharedIterator< SharedElement< Iterator_<MatrixType> >
452 , Iterator_<MatrixType> >;
455 using ConstIterator = SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
456 , ConstIterator_<MatrixType> >;
461 enum :
bool { smpAssignable =
false };
467 explicit inline SymmetricMatrix();
468 explicit inline SymmetricMatrix(
size_t n );
469 explicit inline SymmetricMatrix(
size_t n,
size_t nonzeros );
470 explicit inline SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros );
472 inline SymmetricMatrix(
const SymmetricMatrix& m );
473 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
475 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
476 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
487 inline Reference operator()(
size_t i,
size_t j );
489 inline Reference at(
size_t i,
size_t j );
503 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
504 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
506 template<
typename MT2 >
507 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
509 template<
typename MT2 >
510 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
512 template<
typename MT2 >
513 inline SymmetricMatrix& operator=(
const Matrix<MT2,!SO>& rhs );
515 template<
typename MT2 >
516 inline SymmetricMatrix&
operator+=(
const Matrix<MT2,SO>& rhs );
518 template<
typename MT2 >
519 inline SymmetricMatrix&
operator+=(
const Matrix<MT2,!SO>& rhs );
521 template<
typename MT2 >
522 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,SO>& rhs );
524 template<
typename MT2 >
525 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,!SO>& rhs );
527 template<
typename MT2 >
528 inline SymmetricMatrix& operator%=(
const Matrix<MT2,SO>& rhs );
530 template<
typename MT2 >
531 inline SymmetricMatrix& operator%=(
const Matrix<MT2,!SO>& rhs );
533 template<
typename MT2,
bool SO2 >
534 inline SymmetricMatrix&
operator*=(
const Matrix<MT2,SO2>& rhs );
536 template<
typename Other >
537 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >&
operator*=( Other rhs );
539 template<
typename Other >
540 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >&
operator/=( Other rhs );
547 inline size_t rows() const noexcept;
548 inline
size_t columns() const noexcept;
549 inline
size_t capacity() const noexcept;
550 inline
size_t capacity(
size_t i ) const noexcept;
552 inline
size_t nonZeros(
size_t i ) const;
554 inline
void reset(
size_t i );
556 inline
void resize (
size_t n,
bool preserve=true );
557 inline
void reserve(
size_t nonzeros );
558 inline
void reserve(
size_t i,
size_t nonzeros );
560 inline
void trim(
size_t i );
562 inline
void swap( SymmetricMatrix& m ) noexcept;
571 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
572 inline
void finalize(
size_t i );
579 inline
void erase(
size_t i,
size_t j );
583 template< typename Pred >
584 inline
void erase( Pred predicate );
586 template< typename Pred >
587 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
594 inline
Iterator find (
size_t i,
size_t j );
596 inline
Iterator lowerBound(
size_t i,
size_t j );
598 inline
Iterator upperBound(
size_t i,
size_t j );
609 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
610 template< typename Other > inline SymmetricMatrix& scaleDiagonal( const Other& scale );
617 inline
bool isIntact() const noexcept;
624 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
625 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
627 inline
bool canSMPAssign() const noexcept;
635 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
636 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
637 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
638 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
650 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
651 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
687 template< typename MT
689 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
706 template<
typename MT
708 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
728 template<
typename MT
730 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
731 : matrix_( n, n, nonzeros )
752 template<
typename MT
754 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
755 : matrix_( n, n, nonzeros )
771 template<
typename MT
773 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
778 resize( matrix_, m.rows(), m.columns() );
794 template<
typename MT
796 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
797 : matrix_( std::move( m.matrix_ ) )
816 template<
typename MT
818 template<
typename MT2 >
819 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
824 using RT = RemoveAdaptor_< ResultType_<MT2> >;
825 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
829 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
833 resize( matrix_, tmp.rows(), tmp.columns() );
853 template<
typename MT
855 template<
typename MT2 >
856 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
861 using RT = RemoveAdaptor_< ResultType_<MT2> >;
862 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
866 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
870 resize( matrix_, tmp.rows(), tmp.columns() );
871 assign(
trans( tmp ) );
903 template<
typename MT
906 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
932 template<
typename MT
935 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const 940 return *matrix_(i,j);
962 template<
typename MT
965 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
995 template<
typename MT
998 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const 1006 return (*
this)(i,j);
1024 template<
typename MT
1029 return Iterator( matrix_.begin(i) );
1047 template<
typename MT
1070 template<
typename MT
1093 template<
typename MT
1116 template<
typename MT
1139 template<
typename MT
1168 template<
typename MT
1170 inline SymmetricMatrix<MT,SO,false,false>&
1171 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1175 if( &rhs ==
this )
return *
this;
1177 resize( matrix_, rhs.rows(), rhs.columns() );
1197 template<
typename MT
1199 inline SymmetricMatrix<MT,SO,false,false>&
1200 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1202 matrix_ = std::move( rhs.matrix_ );
1227 template<
typename MT
1229 template<
typename MT2 >
1230 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1231 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1235 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1239 if( (~rhs).canAlias(
this ) ) {
1240 SymmetricMatrix tmp( ~rhs );
1272 template<
typename MT
1274 template<
typename MT2 >
1275 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1276 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1280 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1284 const ResultType_<MT2> tmp( ~rhs );
1286 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
1290 resize( matrix_, tmp.rows(), tmp.columns() );
1317 template<
typename MT
1319 template<
typename MT2 >
1320 inline SymmetricMatrix<MT,SO,false,false>&
1321 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1323 return this->operator=(
trans( ~rhs ) );
1342 template<
typename MT
1344 template<
typename MT2 >
1345 inline SymmetricMatrix<MT,SO,false,false>&
1350 using Tmp = AddTrait_< MT, ResultType_<MT2> >;
1352 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1356 Tmp tmp( (*
this) + ~rhs );
1358 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1362 resize( matrix_, tmp.rows(), tmp.columns() );
1389 template<
typename MT
1391 template<
typename MT2 >
1392 inline SymmetricMatrix<MT,SO,false,false>&
1414 template<
typename MT
1416 template<
typename MT2 >
1417 inline SymmetricMatrix<MT,SO,false,false>&
1422 using Tmp = SubTrait_< MT, ResultType_<MT2> >;
1424 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1428 Tmp tmp( (*
this) - ~rhs );
1430 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1434 resize( matrix_, tmp.rows(), tmp.columns() );
1461 template<
typename MT
1463 template<
typename MT2 >
1464 inline SymmetricMatrix<MT,SO,false,false>&
1486 template<
typename MT
1488 template<
typename MT2 >
1489 inline SymmetricMatrix<MT,SO,false,false>&
1490 SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1494 using Tmp = SchurTrait_< MT, ResultType_<MT2> >;
1496 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1500 Tmp tmp( (*
this) % ~rhs );
1502 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1506 resize( matrix_, tmp.rows(), tmp.columns() );
1533 template<
typename MT
1535 template<
typename MT2 >
1536 inline SymmetricMatrix<MT,SO,false,false>&
1537 SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1539 return this->operator%=(
trans( ~rhs ) );
1557 template<
typename MT
1559 template<
typename MT2
1561 inline SymmetricMatrix<MT,SO,false,false>&
1566 using Tmp = MultTrait_< MT, ResultType_<MT2> >;
1568 if( matrix_.rows() != (~rhs).
columns() ) {
1572 Tmp tmp( (*
this) * ~rhs );
1574 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1578 resize( matrix_, tmp.rows(), tmp.columns() );
1599 template<
typename MT
1601 template<
typename Other >
1602 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1605 for(
size_t i=0UL; i<
rows(); ++i ) {
1606 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1607 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1608 *element->value() *= rhs;
1625 template<
typename MT
1627 template<
typename Other >
1628 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1633 for(
size_t i=0UL; i<
rows(); ++i ) {
1634 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1635 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1636 *element->value() /= rhs;
1659 template<
typename MT
1663 return matrix_.rows();
1675 template<
typename MT
1679 return matrix_.columns();
1691 template<
typename MT
1695 return matrix_.capacity();
1712 template<
typename MT
1716 return matrix_.capacity(i);
1728 template<
typename MT
1732 return matrix_.nonZeros();
1750 template<
typename MT
1754 return matrix_.nonZeros(i);
1766 template<
typename MT
1816 template<
typename MT
1820 for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1822 const size_t j( it->index() );
1828 const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1830 matrix_.erase( j, pos );
1833 const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1835 matrix_.erase( j, pos );
1853 template<
typename MT
1880 template<
typename MT
1890 matrix_.resize( n, n,
true );
1907 template<
typename MT
1909 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1911 matrix_.reserve( nonzeros );
1931 template<
typename MT
1933 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1935 matrix_.reserve( i, nonzeros );
1952 template<
typename MT
1954 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1974 template<
typename MT
1976 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
1994 template<
typename MT
1998 matrix_.shrinkToFit();
2011 template<
typename MT
2017 swap( matrix_, m.matrix_ );
2045 template<
typename MT
2050 SharedValue<ET> shared( value );
2053 matrix_.set( j, i, shared );
2055 return Iterator( matrix_.set( i, j, shared ) );
2076 template<
typename MT
2079 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
2081 SharedValue<ET> shared( value );
2084 matrix_.insert( j, i, shared );
2086 return Iterator( matrix_.insert( i, j, shared ) );
2147 template<
typename MT
2149 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2151 SharedValue<ET> shared( value );
2153 matrix_.append( i, j, shared, check );
2154 if( i != j && ( !check || !isDefault<strict>( value ) ) )
2155 matrix_.insert( j, i, shared );
2175 template<
typename MT
2177 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2203 template<
typename MT
2205 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
2207 matrix_.erase( i, j );
2209 matrix_.erase( j, i );
2227 template<
typename MT
2230 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator pos )
2232 if( pos ==
end( i ) )
2235 const size_t j( pos->index() );
2238 return Iterator( matrix_.erase( i, pos.base() ) );
2242 matrix_.erase( j, matrix_.find( i, j ) );
2243 return Iterator( matrix_.erase( i, pos.base() ) );
2247 matrix_.erase( j, matrix_.find( j, i ) );
2248 return Iterator( matrix_.erase( i, pos.base() ) );
2269 template<
typename MT
2272 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last )
2274 for(
Iterator it=first; it!=last; ++it )
2276 const size_t j( it->index() );
2283 matrix_.erase( i, j );
2287 matrix_.erase( j, i );
2291 return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2311 template<
typename MT
2313 template<
typename Pred >
2314 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2316 matrix_.erase( [predicate=predicate](
const SharedValue<ET>& value ) {
2317 return predicate( *value );
2345 template<
typename MT
2347 template<
typename Pred >
2349 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
2351 for(
Iterator it=first; it!=last; ++it ) {
2352 const size_t j( it->index() );
2353 if( i != j && predicate( it->value() ) ) {
2355 matrix_.erase( i, j );
2357 matrix_.erase( j, i );
2361 matrix_.erase( i, first.base(), last.base(),
2362 [predicate=predicate](
const SharedValue<ET>& value ) {
2363 return predicate( *value );
2396 template<
typename MT
2399 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2401 return Iterator( matrix_.find( i, j ) );
2423 template<
typename MT
2426 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const 2450 template<
typename MT
2453 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2455 return Iterator( matrix_.lowerBound( i, j ) );
2477 template<
typename MT
2480 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const 2504 template<
typename MT
2507 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2509 return Iterator( matrix_.upperBound( i, j ) );
2531 template<
typename MT
2534 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const 2556 template<
typename MT
2572 template<
typename MT
2576 for(
size_t i=0UL; i<
rows(); ++i ) {
2577 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2578 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2606 template<
typename MT
2608 template<
typename Other >
2609 inline SymmetricMatrix<MT,SO,false,false>&
2610 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2612 for(
size_t i=0UL; i<
rows(); ++i ) {
2613 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2614 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2615 ( *element->value() ).scale( scalar );
2634 template<
typename MT
2636 template<
typename Other >
2637 inline SymmetricMatrix<MT,SO,false,false>&
2638 SymmetricMatrix<MT,SO,false,false>::scaleDiagonal(
const Other& scalar )
2640 matrix_.scaleDiagonal( scalar );
2665 template<
typename MT
2696 template<
typename MT
2698 template<
typename Other >
2699 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2701 return matrix_.canAlias( alias );
2718 template<
typename MT
2720 template<
typename Other >
2721 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2723 return matrix_.isAliased( alias );
2740 template<
typename MT
2742 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2744 return matrix_.canSMPAssign();
2762 template<
typename MT
2764 template<
typename MT2 >
2765 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2772 std::vector<size_t> nonzeros(
rows(), 0UL );
2775 for(
size_t i=0UL; i<
rows(); ++i ) {
2780 matrix_.reserve(
sum );
2781 for(
size_t i=0UL; i<
rows(); ++i ) {
2782 matrix_.reserve( i, nonzeros[i] );
2785 for(
size_t i=0UL; i<
rows(); ++i ) {
2786 for(
size_t j=i; j<
columns(); ++j ) {
2788 SharedValue<ET> shared;
2789 *shared = std::move( (~rhs)(i,j) );
2790 matrix_.append( i, j, shared,
false );
2792 matrix_.append( j, i, shared,
false );
2813 template<
typename MT
2815 template<
typename MT2 >
2816 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2823 std::vector<size_t> nonzeros(
rows(), 0UL );
2826 for(
size_t i=0UL; i<
rows(); ++i ) {
2831 matrix_.reserve(
sum );
2832 for(
size_t i=0UL; i<
rows(); ++i ) {
2833 matrix_.reserve( i, nonzeros[i] );
2836 for(
size_t i=0UL; i<
rows(); ++i ) {
2837 for(
size_t j=i; j<
columns(); ++j ) {
2839 const SharedValue<ET> shared( (~rhs)(i,j) );
2840 matrix_.append( i, j, shared,
false );
2842 matrix_.append( j, i, shared,
false );
2863 template<
typename MT
2865 template<
typename MT2 >
2866 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2873 std::vector<size_t> nonzeros(
rows(), 0UL );
2876 for(
size_t i=0UL; i<
rows(); ++i ) {
2881 matrix_.reserve(
sum );
2882 for(
size_t i=0UL; i<
rows(); ++i ) {
2883 matrix_.reserve( i, nonzeros[i] );
2886 for(
size_t i=0UL; i<
rows(); ++i ) {
2887 for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2889 SharedValue<ET> shared;
2890 *shared = std::move( it->value() );
2891 matrix_.append( i, it->index(), shared, false );
2892 if( i != it->index() )
2893 matrix_.append( it->index(), i, shared, false );
2914 template<
typename MT
2916 template<
typename MT2 >
2917 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2924 std::vector<size_t> nonzeros(
rows(), 0UL );
2927 for(
size_t i=0UL; i<
rows(); ++i ) {
2932 matrix_.reserve(
sum );
2933 for(
size_t i=0UL; i<
rows(); ++i ) {
2934 matrix_.reserve( i, nonzeros[i] );
2937 for(
size_t i=0UL; i<
rows(); ++i ) {
2938 for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2940 const SharedValue<ET> shared( it->value() );
2941 matrix_.append( i, it->index(), shared, false );
2942 if( i != it->index() )
2943 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.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
#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:356
Header file for basic type definitions.
#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:1411
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
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:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
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:560
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:661
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
#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:394
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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
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:1393
Constraint on the data type.
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:308
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:242
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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
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:5924
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:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
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:340
Header file for the SparseElement base class.
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:548
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:264
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:8893
Header file for the RemoveAdaptor type trait.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
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
BLAZE_ALWAYS_INLINE ValueType_< T > sum(const SIMDi8< T > &a) noexcept
Returns the sum of all elements in the 8-bit integral SIMD vector.
Definition: Reduction.h:65
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
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
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:270
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:700
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:790
#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:3083
#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 isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#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:1375
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:742
#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:635