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_t<MT>;
114 using TT = TransposeType_t<MT>;
115 using ET = ElementType_t<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_t<MatrixType> >
452 , Iterator_t<MatrixType> >;
455 using ConstIterator = SharedIterator< const SharedElement< ConstIterator_t<MatrixType> >
456 , ConstIterator_t<MatrixType> >;
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 );
483 ~SymmetricMatrix() =
default;
490 inline Reference operator()(
size_t i,
size_t j );
492 inline Reference at(
size_t i,
size_t j );
506 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
507 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
509 template<
typename MT2 >
510 inline auto operator=(
const Matrix<MT2,SO>& rhs )
511 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
513 template<
typename MT2 >
514 inline auto operator=(
const Matrix<MT2,SO>& rhs )
515 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
517 template<
typename MT2 >
518 inline auto operator=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
520 template<
typename MT2 >
521 inline auto operator+=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
523 template<
typename MT2 >
524 inline auto operator+=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
526 template<
typename MT2 >
527 inline auto operator-=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
529 template<
typename MT2 >
530 inline auto operator-=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
532 template<
typename MT2 >
533 inline auto operator%=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
535 template<
typename MT2 >
536 inline auto operator%=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
538 template<
typename ST >
539 inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
541 template<
typename ST >
542 inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
549 inline size_t rows() const noexcept;
550 inline
size_t columns() const noexcept;
551 inline
size_t capacity() const noexcept;
552 inline
size_t capacity(
size_t i ) const noexcept;
554 inline
size_t nonZeros(
size_t i ) const;
556 inline
void reset(
size_t i );
558 inline
void resize (
size_t n,
bool preserve=true );
559 inline
void reserve(
size_t nonzeros );
560 inline
void reserve(
size_t i,
size_t nonzeros );
562 inline
void trim(
size_t i );
564 inline
void swap( SymmetricMatrix& m ) noexcept;
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
void erase(
size_t i,
size_t j );
585 template< typename Pred >
586 inline
void erase( Pred predicate );
588 template< typename Pred >
589 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
596 inline
Iterator find (
size_t i,
size_t j );
598 inline
Iterator lowerBound(
size_t i,
size_t j );
600 inline
Iterator upperBound(
size_t i,
size_t j );
611 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
618 inline
bool isIntact() const noexcept;
625 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
626 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
628 inline
bool canSMPAssign() const noexcept;
636 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
637 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
638 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
639 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
651 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
652 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
688 template< typename MT
690 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
707 template<
typename MT
709 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
729 template<
typename MT
731 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
732 : matrix_( n, n, nonzeros )
753 template<
typename MT
755 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
756 : matrix_( n, n, nonzeros )
772 template<
typename MT
774 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
779 resize( matrix_, m.rows(), m.columns() );
795 template<
typename MT
797 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
798 : matrix_( std::move( m.matrix_ ) )
817 template<
typename MT
819 template<
typename MT2 >
820 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
825 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
826 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
834 resize( matrix_, tmp.rows(), tmp.columns() );
854 template<
typename MT
856 template<
typename MT2 >
857 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
862 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
863 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
871 resize( matrix_, tmp.rows(), tmp.columns() );
872 assign(
trans( tmp ) );
904 template<
typename MT
907 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
933 template<
typename MT
936 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const 941 return *matrix_(i,j);
963 template<
typename MT
966 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
996 template<
typename MT
999 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const 1007 return (*
this)(i,j);
1025 template<
typename MT
1030 return Iterator( matrix_.begin(i) );
1048 template<
typename MT
1071 template<
typename MT
1094 template<
typename MT
1117 template<
typename MT
1140 template<
typename MT
1169 template<
typename MT
1171 inline SymmetricMatrix<MT,SO,false,false>&
1172 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1176 if( &rhs ==
this )
return *
this;
1178 resize( matrix_, rhs.rows(), rhs.columns() );
1198 template<
typename MT
1200 inline SymmetricMatrix<MT,SO,false,false>&
1201 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1203 matrix_ = std::move( rhs.matrix_ );
1228 template<
typename MT
1230 template<
typename MT2 >
1231 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1232 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1236 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1240 if( (~rhs).canAlias(
this ) ) {
1241 SymmetricMatrix tmp( ~rhs );
1273 template<
typename MT
1275 template<
typename MT2 >
1276 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1277 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1281 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1285 const ResultType_t<MT2> tmp( ~rhs );
1287 if( !IsSymmetric_v<MT2> && !
isSymmetric( tmp ) ) {
1291 resize( matrix_, tmp.rows(), tmp.columns() );
1318 template<
typename MT
1320 template<
typename MT2 >
1321 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1324 return this->operator=(
trans( ~rhs ) );
1343 template<
typename MT
1345 template<
typename MT2 >
1351 using Tmp = AddTrait_t< MT, ResultType_t<MT2> >;
1353 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1357 Tmp tmp( (*
this) + ~rhs );
1359 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1363 resize( matrix_, tmp.rows(), tmp.columns() );
1390 template<
typename MT
1392 template<
typename MT2 >
1415 template<
typename MT
1417 template<
typename MT2 >
1423 using Tmp = SubTrait_t< MT, ResultType_t<MT2> >;
1425 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1429 Tmp tmp( (*
this) - ~rhs );
1431 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1435 resize( matrix_, tmp.rows(), tmp.columns() );
1462 template<
typename MT
1464 template<
typename MT2 >
1487 template<
typename MT
1489 template<
typename MT2 >
1490 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1495 using Tmp = SchurTrait_t< MT, ResultType_t<MT2> >;
1497 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1501 Tmp tmp( (*
this) % ~rhs );
1503 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1507 resize( matrix_, tmp.rows(), tmp.columns() );
1534 template<
typename MT
1536 template<
typename MT2 >
1537 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1540 return this->operator%=(
trans( ~rhs ) );
1554 template<
typename MT
1556 template<
typename ST >
1558 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1560 for(
size_t i=0UL; i<
rows(); ++i ) {
1561 const auto last( matrix_.upperBound(i,i) );
1562 for(
auto element=matrix_.begin(i); element!=last; ++element )
1563 *element->value() *= rhs;
1580 template<
typename MT
1582 template<
typename ST >
1584 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1588 for(
size_t i=0UL; i<
rows(); ++i ) {
1589 const auto last( matrix_.upperBound(i,i) );
1590 for(
auto element=matrix_.begin(i); element!=last; ++element )
1591 *element->value() /= rhs;
1614 template<
typename MT
1618 return matrix_.rows();
1630 template<
typename MT
1634 return matrix_.columns();
1646 template<
typename MT
1650 return matrix_.capacity();
1667 template<
typename MT
1671 return matrix_.capacity(i);
1683 template<
typename MT
1687 return matrix_.nonZeros();
1705 template<
typename MT
1709 return matrix_.nonZeros(i);
1721 template<
typename MT
1771 template<
typename MT
1777 for(
auto it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1779 const size_t j( it->index() );
1785 const Iterator_t<MatrixType> pos( matrix_.find( i, j ) );
1787 erase( matrix_, j, pos );
1790 const Iterator_t<MatrixType> pos( matrix_.find( j, i ) );
1792 erase( matrix_, j, pos );
1810 template<
typename MT
1837 template<
typename MT
1847 matrix_.resize( n, n,
true );
1864 template<
typename MT
1866 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1868 matrix_.reserve( nonzeros );
1888 template<
typename MT
1890 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1892 matrix_.reserve( i, nonzeros );
1909 template<
typename MT
1911 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1931 template<
typename MT
1933 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
1951 template<
typename MT
1955 matrix_.shrinkToFit();
1968 template<
typename MT
1974 swap( matrix_, m.matrix_ );
2002 template<
typename MT
2007 SharedValue<ET> shared( value );
2010 matrix_.set( j, i, shared );
2012 return Iterator( matrix_.set( i, j, shared ) );
2033 template<
typename MT
2036 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
2038 SharedValue<ET> shared( value );
2041 matrix_.insert( j, i, shared );
2043 return Iterator( matrix_.insert( i, j, shared ) );
2104 template<
typename MT
2106 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2108 SharedValue<ET> shared( value );
2110 matrix_.append( i, j, shared, check );
2111 if( i != j && ( !check || !isDefault<strict>( value ) ) )
2112 matrix_.insert( j, i, shared );
2132 template<
typename MT
2134 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2160 template<
typename MT
2162 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
2166 erase( matrix_, i, j );
2168 erase( matrix_, j, i );
2186 template<
typename MT
2189 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator pos )
2193 if( pos ==
end( i ) )
2196 const size_t j( pos->index() );
2199 return Iterator( erase( matrix_, i, pos.base() ) );
2203 erase( matrix_, j, matrix_.find( i, j ) );
2204 return Iterator( erase( matrix_, i, pos.base() ) );
2208 erase( matrix_, j, matrix_.find( j, i ) );
2209 return Iterator( erase( matrix_, i, pos.base() ) );
2230 template<
typename MT
2233 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last )
2237 for(
auto it=first; it!=last; ++it )
2239 const size_t j( it->index() );
2246 erase( matrix_, i, j );
2250 erase( matrix_, j, i );
2254 return Iterator( erase( matrix_, i, first.base(), last.base() ) );
2274 template<
typename MT
2276 template<
typename Pred >
2277 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2281 erase( matrix_, [predicate=predicate](
const SharedValue<ET>& value ) {
2282 return predicate( *value );
2310 template<
typename MT
2312 template<
typename Pred >
2314 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
2318 for(
auto it=first; it!=last; ++it ) {
2319 const size_t j( it->index() );
2320 if( i != j && predicate( it->value() ) ) {
2322 erase( matrix_, i, j );
2324 erase( matrix_, j, i );
2328 erase( matrix_, i, first.base(), last.base(),
2329 [predicate=predicate](
const SharedValue<ET>& value ) {
2330 return predicate( *value );
2363 template<
typename MT
2366 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2368 return Iterator( matrix_.find( i, j ) );
2390 template<
typename MT
2393 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const 2417 template<
typename MT
2420 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2422 return Iterator( matrix_.lowerBound( i, j ) );
2444 template<
typename MT
2447 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const 2471 template<
typename MT
2474 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2476 return Iterator( matrix_.upperBound( i, j ) );
2498 template<
typename MT
2501 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const 2523 template<
typename MT
2539 template<
typename MT
2543 for(
size_t i=0UL; i<
rows(); ++i ) {
2544 const auto last( matrix_.upperBound(i,i) );
2545 for(
auto element=matrix_.begin(i); element!=last; ++element )
2573 template<
typename MT
2575 template<
typename Other >
2576 inline SymmetricMatrix<MT,SO,false,false>&
2577 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2579 for(
size_t i=0UL; i<
rows(); ++i ) {
2580 const auto last( matrix_.upperBound(i,i) );
2581 for(
auto element=matrix_.begin(i); element!=last; ++element )
2582 ( *element->value() ).scale( scalar );
2609 template<
typename MT
2640 template<
typename MT
2642 template<
typename Other >
2643 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2645 return matrix_.canAlias( alias );
2662 template<
typename MT
2664 template<
typename Other >
2665 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2667 return matrix_.isAliased( alias );
2684 template<
typename MT
2686 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2688 return matrix_.canSMPAssign();
2706 template<
typename MT
2708 template<
typename MT2 >
2709 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2716 std::vector<size_t> nonzeros(
rows(), 0UL );
2719 for(
size_t i=0UL; i<
rows(); ++i ) {
2724 matrix_.reserve(
sum );
2725 for(
size_t i=0UL; i<
rows(); ++i ) {
2726 matrix_.reserve( i, nonzeros[i] );
2729 for(
size_t i=0UL; i<
rows(); ++i ) {
2730 for(
size_t j=i; j<
columns(); ++j ) {
2732 SharedValue<ET> shared;
2733 *shared = std::move( (~rhs)(i,j) );
2734 matrix_.append( i, j, shared,
false );
2736 matrix_.append( j, i, shared,
false );
2757 template<
typename MT
2759 template<
typename MT2 >
2760 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2767 std::vector<size_t> nonzeros(
rows(), 0UL );
2770 for(
size_t i=0UL; i<
rows(); ++i ) {
2775 matrix_.reserve(
sum );
2776 for(
size_t i=0UL; i<
rows(); ++i ) {
2777 matrix_.reserve( i, nonzeros[i] );
2780 for(
size_t i=0UL; i<
rows(); ++i ) {
2781 for(
size_t j=i; j<
columns(); ++j ) {
2783 const SharedValue<ET> shared( (~rhs)(i,j) );
2784 matrix_.append( i, j, shared,
false );
2786 matrix_.append( j, i, shared,
false );
2807 template<
typename MT
2809 template<
typename MT2 >
2810 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2817 std::vector<size_t> nonzeros(
rows(), 0UL );
2820 for(
size_t i=0UL; i<
rows(); ++i ) {
2825 matrix_.reserve(
sum );
2826 for(
size_t i=0UL; i<
rows(); ++i ) {
2827 matrix_.reserve( i, nonzeros[i] );
2830 for(
size_t i=0UL; i<
rows(); ++i ) {
2831 for(
auto it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2833 SharedValue<ET> shared;
2834 *shared = std::move( it->value() );
2835 matrix_.append( i, it->index(), shared, false );
2836 if( i != it->index() )
2837 matrix_.append( it->index(), i, shared, false );
2858 template<
typename MT
2860 template<
typename MT2 >
2861 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2868 std::vector<size_t> nonzeros(
rows(), 0UL );
2871 for(
size_t i=0UL; i<
rows(); ++i ) {
2876 matrix_.reserve(
sum );
2877 for(
size_t i=0UL; i<
rows(); ++i ) {
2878 matrix_.reserve( i, nonzeros[i] );
2881 for(
size_t i=0UL; i<
rows(); ++i ) {
2882 for(
auto it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2884 const SharedValue<ET> shared( it->value() );
2885 matrix_.append( i, it->index(), shared, false );
2886 if( i != it->index() )
2887 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:3078
Header file for the Schur product trait.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:750
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_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
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Constraint on the data type.
Header file for the SharedValue class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:482
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:416
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
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 isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
Header file for the If class template.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2146
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
Constraint on the data type.
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
Header file for the RemoveAdaptor type trait.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Header file for run time assertion macros.
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:281
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
Constraint on the data type.
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:539
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5863
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#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
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825