35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_ 36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_ 107 template<
typename MT
109 class SymmetricMatrix<MT,SO,false,false>
110 :
public SparseMatrix< SymmetricMatrix<MT,SO,false,false>, SO >
114 using OT = OppositeType_t<MT>;
115 using TT = TransposeType_t<MT>;
116 using ET = ElementType_t<MT>;
119 using MatrixType =
typename MT::template Rebind< SharedValue<ET> >::Other;
124 using This = SymmetricMatrix<MT,SO,false,false>;
125 using BaseType = SparseMatrix<This,SO>;
126 using ResultType = This;
127 using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
128 using TransposeType = SymmetricMatrix<TT,!SO,false,false>;
129 using ElementType = ET;
130 using ReturnType = ReturnType_t<MT>;
131 using CompositeType =
const This&;
132 using Reference = NonNumericProxy<MatrixType>;
133 using ConstReference = ConstReference_t<MT>;
139 template<
typename NewType >
142 using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
149 template<
size_t NewM
153 using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
160 template<
typename IteratorType >
162 :
private SparseElement
166 using ValueType = ET;
167 using IndexType = size_t;
168 using Reference = ValueType&;
169 using ConstReference =
const ValueType&;
170 using Pointer = SharedElement*;
171 using ConstPointer =
const SharedElement*;
179 inline SharedElement( IteratorType pos )
190 template<
typename T >
inline SharedElement& operator=(
const T& v ) {
202 template<
typename T >
inline SharedElement&
operator+=(
const T& v ) {
214 template<
typename T >
inline SharedElement&
operator-=(
const T& v ) {
226 template<
typename T >
inline SharedElement&
operator*=(
const T& v ) {
238 template<
typename T >
inline SharedElement&
operator/=(
const T& v ) {
249 inline Pointer operator->() {
259 inline ConstPointer operator->()
const {
269 inline Reference value() {
270 return *pos_->value();
279 inline ConstReference value()
const {
280 return *pos_->value();
289 inline IndexType index()
const {
290 return pos_->index();
304 template<
typename SparseElementType
305 ,
typename IteratorType >
310 using IteratorCategory = std::forward_iterator_tag;
311 using ValueType = SparseElementType;
312 using PointerType = SparseElementType;
313 using ReferenceType = SparseElementType;
314 using DifferenceType = ptrdiff_t;
317 using iterator_category = IteratorCategory;
318 using value_type = ValueType;
319 using pointer = PointerType;
320 using reference = ReferenceType;
321 using difference_type = DifferenceType;
327 inline SharedIterator()
337 inline SharedIterator( IteratorType pos )
347 template<
typename SparseElementType2,
typename IteratorType2 >
348 inline SharedIterator(
const SharedIterator<SparseElementType2,IteratorType2>& it )
358 inline SharedIterator& operator++() {
369 inline const SharedIterator operator++(
int ) {
370 const SharedIterator tmp( *
this );
382 return ReferenceType( pos_ );
391 inline PointerType operator->()
const {
392 return PointerType( pos_ );
402 inline bool operator==(
const SharedIterator& rhs )
const {
403 return pos_ == rhs.pos_;
413 inline bool operator!=(
const SharedIterator& rhs )
const {
414 return !( *
this == rhs );
424 inline DifferenceType
operator-(
const SharedIterator& rhs )
const {
425 return pos_ - rhs.pos_;
434 inline IteratorType base()
const {
445 template<
typename SparseElementType2,
typename IteratorType2 >
friend class SharedIterator;
452 using Iterator = SharedIterator< SharedElement< Iterator_t<MatrixType> >
453 , Iterator_t<MatrixType> >;
456 using ConstIterator = SharedIterator< const SharedElement< ConstIterator_t<MatrixType> >
457 , ConstIterator_t<MatrixType> >;
462 static constexpr
bool smpAssignable =
false;
468 explicit inline SymmetricMatrix();
469 explicit inline SymmetricMatrix(
size_t n );
470 explicit inline SymmetricMatrix(
size_t n,
size_t nonzeros );
471 explicit inline SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros );
473 inline SymmetricMatrix(
const SymmetricMatrix& m );
474 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
476 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
477 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
484 ~SymmetricMatrix() =
default;
491 inline Reference operator()(
size_t i,
size_t j );
492 inline ConstReference operator()(
size_t i,
size_t j )
const;
493 inline Reference at(
size_t i,
size_t j );
494 inline ConstReference at(
size_t i,
size_t j )
const;
495 inline Iterator
begin (
size_t i );
496 inline ConstIterator
begin (
size_t i )
const;
497 inline ConstIterator
cbegin(
size_t i )
const;
498 inline Iterator
end (
size_t i );
499 inline ConstIterator
end (
size_t i )
const;
500 inline ConstIterator
cend (
size_t i )
const;
507 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
508 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
510 template<
typename MT2 >
511 inline auto operator=(
const Matrix<MT2,SO>& rhs )
512 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
514 template<
typename MT2 >
515 inline auto operator=(
const Matrix<MT2,SO>& rhs )
516 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
518 template<
typename MT2 >
519 inline auto operator=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
521 template<
typename MT2 >
522 inline auto operator+=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
524 template<
typename MT2 >
525 inline auto operator+=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
527 template<
typename MT2 >
528 inline auto operator-=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
530 template<
typename MT2 >
531 inline auto operator-=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
533 template<
typename MT2 >
534 inline auto operator%=(
const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
536 template<
typename MT2 >
537 inline auto operator%=(
const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
539 template<
typename ST >
540 inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
542 template<
typename ST >
543 inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
550 inline size_t rows() const noexcept;
551 inline
size_t columns() const noexcept;
552 inline
size_t capacity() const noexcept;
553 inline
size_t capacity(
size_t i ) const noexcept;
555 inline
size_t nonZeros(
size_t i ) const;
557 inline
void reset(
size_t i );
559 inline
void resize (
size_t n,
bool preserve=true );
560 inline
void reserve(
size_t nonzeros );
561 inline
void reserve(
size_t i,
size_t nonzeros );
563 inline
void trim(
size_t i );
565 inline
void swap( SymmetricMatrix& m ) noexcept;
572 inline Iterator
set (
size_t i,
size_t j, const ElementType& value );
573 inline Iterator insert (
size_t i,
size_t j, const ElementType& value );
574 inline
void append (
size_t i,
size_t j, const ElementType& value,
bool check=false );
575 inline
void finalize(
size_t i );
582 inline
void erase(
size_t i,
size_t j );
583 inline Iterator erase(
size_t i, Iterator pos );
584 inline Iterator erase(
size_t i, Iterator first, Iterator last );
586 template< typename Pred >
587 inline
void erase( Pred predicate );
589 template< typename Pred >
590 inline
void erase(
size_t i, Iterator first, Iterator last, Pred predicate );
597 inline Iterator find (
size_t i,
size_t j );
598 inline ConstIterator find (
size_t i,
size_t j ) const;
599 inline Iterator lowerBound(
size_t i,
size_t j );
600 inline ConstIterator lowerBound(
size_t i,
size_t j ) const;
601 inline Iterator upperBound(
size_t i,
size_t j );
602 inline ConstIterator upperBound(
size_t i,
size_t j ) const;
612 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
619 inline
bool isIntact() const noexcept;
626 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
627 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
629 inline
bool canSMPAssign() const noexcept;
637 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
638 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
639 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
640 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
652 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
653 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
691 template< typename MT
693 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
710 template<
typename MT
712 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
732 template<
typename MT
734 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
735 : matrix_( n, n, nonzeros )
756 template<
typename MT
758 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
759 : matrix_( n, n, nonzeros )
775 template<
typename MT
777 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
782 resize( matrix_, m.rows(), m.columns() );
798 template<
typename MT
800 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
801 : matrix_( std::move( m.matrix_ ) )
820 template<
typename MT
822 template<
typename MT2 >
823 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
828 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
829 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
837 resize( matrix_, tmp.rows(), tmp.columns() );
857 template<
typename MT
859 template<
typename MT2 >
860 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
865 using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
866 using Tmp = If_t< IsComputation_v<MT2>, RT,
const MT2& >;
874 resize( matrix_, tmp.rows(), tmp.columns() );
875 assign(
trans( tmp ) );
907 template<
typename MT
909 inline typename SymmetricMatrix<MT,SO,false,false>::Reference
910 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
915 return Reference( matrix_, i, j );
936 template<
typename MT
938 inline typename SymmetricMatrix<MT,SO,false,false>::ConstReference
939 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const 944 return *matrix_(i,j);
966 template<
typename MT
968 inline typename SymmetricMatrix<MT,SO,false,false>::Reference
969 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
999 template<
typename MT
1001 inline typename SymmetricMatrix<MT,SO,false,false>::ConstReference
1002 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const 1010 return (*
this)(i,j);
1028 template<
typename MT
1030 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
1033 return Iterator( matrix_.begin(i) );
1051 template<
typename MT
1053 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1056 return ConstIterator( matrix_.begin(i) );
1074 template<
typename MT
1076 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1079 return ConstIterator( matrix_.cbegin(i) );
1097 template<
typename MT
1099 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
1102 return Iterator( matrix_.end(i) );
1120 template<
typename MT
1122 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1125 return ConstIterator( matrix_.end(i) );
1143 template<
typename MT
1145 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1148 return ConstIterator( matrix_.cend(i) );
1172 template<
typename MT
1174 inline SymmetricMatrix<MT,SO,false,false>&
1175 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1179 if( &rhs ==
this )
return *
this;
1181 resize( matrix_, rhs.rows(), rhs.columns() );
1201 template<
typename MT
1203 inline SymmetricMatrix<MT,SO,false,false>&
1204 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1206 matrix_ = std::move( rhs.matrix_ );
1231 template<
typename MT
1233 template<
typename MT2 >
1234 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1235 -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1239 if( !IsSymmetric_v<MT2> && !
isSymmetric( ~rhs ) ) {
1243 if( (~rhs).canAlias(
this ) ) {
1244 SymmetricMatrix tmp( ~rhs );
1276 template<
typename MT
1278 template<
typename MT2 >
1279 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1280 -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1284 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1288 const ResultType_t<MT2> tmp( ~rhs );
1290 if( !IsSymmetric_v<MT2> && !
isSymmetric( tmp ) ) {
1294 resize( matrix_, tmp.rows(), tmp.columns() );
1321 template<
typename MT
1323 template<
typename MT2 >
1324 inline auto SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1327 return this->operator=(
trans( ~rhs ) );
1346 template<
typename MT
1348 template<
typename MT2 >
1354 using Tmp = AddTrait_t< MT, ResultType_t<MT2> >;
1356 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1360 Tmp tmp( (*
this) + ~rhs );
1362 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1366 resize( matrix_, tmp.rows(), tmp.columns() );
1393 template<
typename MT
1395 template<
typename MT2 >
1418 template<
typename MT
1420 template<
typename MT2 >
1426 using Tmp = SubTrait_t< MT, ResultType_t<MT2> >;
1428 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1432 Tmp tmp( (*
this) - ~rhs );
1434 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1438 resize( matrix_, tmp.rows(), tmp.columns() );
1465 template<
typename MT
1467 template<
typename MT2 >
1490 template<
typename MT
1492 template<
typename MT2 >
1493 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1498 using Tmp = SchurTrait_t< MT, ResultType_t<MT2> >;
1500 if( !IsSquare_v<MT2> && !
isSquare( ~rhs ) ) {
1504 Tmp tmp( (*
this) % ~rhs );
1506 if( !IsSymmetric_v<Tmp> && !
isSymmetric( tmp ) ) {
1510 resize( matrix_, tmp.rows(), tmp.columns() );
1537 template<
typename MT
1539 template<
typename MT2 >
1540 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1543 return this->operator%=(
trans( ~rhs ) );
1557 template<
typename MT
1559 template<
typename ST >
1561 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1563 for(
size_t i=0UL; i<
rows(); ++i ) {
1564 const auto last( matrix_.upperBound(i,i) );
1565 for(
auto element=matrix_.begin(i); element!=last; ++element )
1566 *element->value() *= rhs;
1583 template<
typename MT
1585 template<
typename ST >
1587 -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1591 for(
size_t i=0UL; i<
rows(); ++i ) {
1592 const auto last( matrix_.upperBound(i,i) );
1593 for(
auto element=matrix_.begin(i); element!=last; ++element )
1594 *element->value() /= rhs;
1617 template<
typename MT
1621 return matrix_.rows();
1633 template<
typename MT
1637 return matrix_.columns();
1649 template<
typename MT
1653 return matrix_.capacity();
1670 template<
typename MT
1674 return matrix_.capacity(i);
1686 template<
typename MT
1690 return matrix_.nonZeros();
1708 template<
typename MT
1712 return matrix_.nonZeros(i);
1724 template<
typename MT
1774 template<
typename MT
1780 for(
auto it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1782 const size_t j( it->index() );
1788 const Iterator_t<MatrixType> pos( matrix_.find( i, j ) );
1790 erase( matrix_, j, pos );
1793 const Iterator_t<MatrixType> pos( matrix_.find( j, i ) );
1795 erase( matrix_, j, pos );
1813 template<
typename MT
1840 template<
typename MT
1850 matrix_.resize( n, n,
true );
1867 template<
typename MT
1869 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1871 matrix_.reserve( nonzeros );
1891 template<
typename MT
1893 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1895 matrix_.reserve( i, nonzeros );
1912 template<
typename MT
1914 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1934 template<
typename MT
1936 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
1954 template<
typename MT
1958 matrix_.shrinkToFit();
1971 template<
typename MT
1977 swap( matrix_, m.matrix_ );
2005 template<
typename MT
2007 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2010 SharedValue<ET> shared( value );
2013 matrix_.set( j, i, shared );
2015 return Iterator( matrix_.set( i, j, shared ) );
2036 template<
typename MT
2038 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2039 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
2041 SharedValue<ET> shared( value );
2044 matrix_.insert( j, i, shared );
2046 return Iterator( matrix_.insert( i, j, shared ) );
2107 template<
typename MT
2109 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2111 SharedValue<ET> shared( value );
2113 matrix_.append( i, j, shared, check );
2114 if( i != j && ( !check || !isDefault<strict>( value ) ) )
2115 matrix_.insert( j, i, shared );
2135 template<
typename MT
2137 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2163 template<
typename MT
2165 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
2169 erase( matrix_, i, j );
2171 erase( matrix_, j, i );
2189 template<
typename MT
2191 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2192 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator pos )
2196 if( pos ==
end( i ) )
2199 const size_t j( pos->index() );
2202 return Iterator( erase( matrix_, i, pos.base() ) );
2206 erase( matrix_, j, matrix_.find( i, j ) );
2207 return Iterator( erase( matrix_, i, pos.base() ) );
2211 erase( matrix_, j, matrix_.find( j, i ) );
2212 return Iterator( erase( matrix_, i, pos.base() ) );
2233 template<
typename MT
2235 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2236 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator first, Iterator last )
2240 for(
auto it=first; it!=last; ++it )
2242 const size_t j( it->index() );
2249 erase( matrix_, i, j );
2253 erase( matrix_, j, i );
2257 return Iterator( erase( matrix_, i, first.base(), last.base() ) );
2277 template<
typename MT
2279 template<
typename Pred >
2280 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2284 erase( matrix_, [predicate=predicate](
const SharedValue<ET>& value ) {
2285 return predicate( *value );
2313 template<
typename MT
2315 template<
typename Pred >
2317 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i, Iterator first, Iterator last, Pred predicate )
2321 for(
auto it=first; it!=last; ++it ) {
2322 const size_t j( it->index() );
2323 if( i != j && predicate( it->value() ) ) {
2325 erase( matrix_, i, j );
2327 erase( matrix_, j, i );
2331 erase( matrix_, i, first.base(), last.base(),
2332 [predicate=predicate](
const SharedValue<ET>& value ) {
2333 return predicate( *value );
2366 template<
typename MT
2368 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2369 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2371 return Iterator( matrix_.find( i, j ) );
2393 template<
typename MT
2395 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2396 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const 2398 return ConstIterator( matrix_.find( i, j ) );
2420 template<
typename MT
2422 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2423 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2425 return Iterator( matrix_.lowerBound( i, j ) );
2447 template<
typename MT
2449 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2450 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const 2452 return ConstIterator( matrix_.lowerBound( i, j ) );
2474 template<
typename MT
2476 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2477 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2479 return Iterator( matrix_.upperBound( i, j ) );
2501 template<
typename MT
2503 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2504 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const 2506 return ConstIterator( matrix_.upperBound( i, j ) );
2526 template<
typename MT
2542 template<
typename MT
2546 for(
size_t i=0UL; i<
rows(); ++i ) {
2547 const auto last( matrix_.upperBound(i,i) );
2548 for(
auto element=matrix_.begin(i); element!=last; ++element )
2576 template<
typename MT
2578 template<
typename Other >
2579 inline SymmetricMatrix<MT,SO,false,false>&
2580 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2582 for(
size_t i=0UL; i<
rows(); ++i ) {
2583 const auto last( matrix_.upperBound(i,i) );
2584 for(
auto element=matrix_.begin(i); element!=last; ++element )
2585 ( *element->value() ).scale( scalar );
2612 template<
typename MT
2643 template<
typename MT
2645 template<
typename Other >
2646 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2648 return matrix_.canAlias( alias );
2665 template<
typename MT
2667 template<
typename Other >
2668 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2670 return matrix_.isAliased( alias );
2687 template<
typename MT
2689 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2691 return matrix_.canSMPAssign();
2709 template<
typename MT
2711 template<
typename MT2 >
2712 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2719 std::vector<size_t> nonzeros(
rows(), 0UL );
2722 for(
size_t i=0UL; i<
rows(); ++i ) {
2727 matrix_.reserve(
sum );
2728 for(
size_t i=0UL; i<
rows(); ++i ) {
2729 matrix_.reserve( i, nonzeros[i] );
2732 for(
size_t i=0UL; i<
rows(); ++i ) {
2733 for(
size_t j=i; j<
columns(); ++j ) {
2735 SharedValue<ET> shared;
2736 *shared = std::move( (~rhs)(i,j) );
2737 matrix_.append( i, j, shared,
false );
2739 matrix_.append( j, i, shared,
false );
2760 template<
typename MT
2762 template<
typename MT2 >
2763 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2770 std::vector<size_t> nonzeros(
rows(), 0UL );
2773 for(
size_t i=0UL; i<
rows(); ++i ) {
2778 matrix_.reserve(
sum );
2779 for(
size_t i=0UL; i<
rows(); ++i ) {
2780 matrix_.reserve( i, nonzeros[i] );
2783 for(
size_t i=0UL; i<
rows(); ++i ) {
2784 for(
size_t j=i; j<
columns(); ++j ) {
2786 const SharedValue<ET> shared( (~rhs)(i,j) );
2787 matrix_.append( i, j, shared,
false );
2789 matrix_.append( j, i, shared,
false );
2810 template<
typename MT
2812 template<
typename MT2 >
2813 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2820 std::vector<size_t> nonzeros(
rows(), 0UL );
2823 for(
size_t i=0UL; i<
rows(); ++i ) {
2828 matrix_.reserve(
sum );
2829 for(
size_t i=0UL; i<
rows(); ++i ) {
2830 matrix_.reserve( i, nonzeros[i] );
2833 for(
size_t i=0UL; i<
rows(); ++i ) {
2834 for(
auto it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2836 SharedValue<ET> shared;
2837 *shared = std::move( it->value() );
2838 matrix_.append( i, it->index(), shared, false );
2839 if( i != it->index() )
2840 matrix_.append( it->index(), i, shared, false );
2861 template<
typename MT
2863 template<
typename MT2 >
2864 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2871 std::vector<size_t> nonzeros(
rows(), 0UL );
2874 for(
size_t i=0UL; i<
rows(); ++i ) {
2879 matrix_.reserve(
sum );
2880 for(
size_t i=0UL; i<
rows(); ++i ) {
2881 matrix_.reserve( i, nonzeros[i] );
2884 for(
size_t i=0UL; i<
rows(); ++i ) {
2885 for(
auto it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2887 const SharedValue<ET> shared( it->value() );
2888 matrix_.append( i, it->index(), shared, false );
2889 if( i != it->index() )
2890 matrix_.append( it->index(), i, shared, false );
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
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.
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
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
Constraint on the data type.
Header file for the Schur product trait.
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,...
Definition: Assert.h:117
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.
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
Header file for the SharedValue class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
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
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:677
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
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:9091
#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
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2147
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
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.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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
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:615
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
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:558
#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,...
Definition: Symmetric.h:79
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,...
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:282
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:1328
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
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.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
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:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#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,...
Definition: Hermitian.h:79
#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,...
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
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825