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_<MT>;
115 using TT = TransposeType_<MT>;
116 using ET = ElementType_<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>;
127 using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
132 using Reference = NonNumericProxy<MatrixType>;
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;
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 {
270 return *pos_->value();
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_<MatrixType> >
453 , Iterator_<MatrixType> >;
456 using ConstIterator = SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
457 , ConstIterator_<MatrixType> >;
462 enum :
bool { smpAssignable =
false };
468 explicit inline SymmetricMatrix();
469 explicit inline SymmetricMatrix(
size_t n );
470 explicit inline SymmetricMatrix(
size_t n,
size_t nonzeros );
471 explicit inline SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros );
473 inline SymmetricMatrix(
const SymmetricMatrix& m );
474 inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
476 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
477 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
488 inline Reference operator()(
size_t i,
size_t j );
490 inline Reference at(
size_t i,
size_t j );
504 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
505 inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
507 template<
typename MT2 >
508 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
510 template<
typename MT2 >
511 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=(
const Matrix<MT2,SO>& rhs );
513 template<
typename MT2 >
514 inline SymmetricMatrix& operator=(
const Matrix<MT2,!SO>& rhs );
516 template<
typename MT2 >
517 inline SymmetricMatrix&
operator+=(
const Matrix<MT2,SO>& rhs );
519 template<
typename MT2 >
520 inline SymmetricMatrix&
operator+=(
const Matrix<MT2,!SO>& rhs );
522 template<
typename MT2 >
523 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,SO>& rhs );
525 template<
typename MT2 >
526 inline SymmetricMatrix&
operator-=(
const Matrix<MT2,!SO>& rhs );
528 template<
typename MT2 >
529 inline SymmetricMatrix& operator%=(
const Matrix<MT2,SO>& rhs );
531 template<
typename MT2 >
532 inline SymmetricMatrix& operator%=(
const Matrix<MT2,!SO>& rhs );
534 template<
typename ST >
535 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >&
operator*=( ST rhs );
537 template<
typename ST >
538 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >&
operator/=( ST rhs );
545 inline size_t rows() const noexcept;
546 inline
size_t columns() const noexcept;
547 inline
size_t capacity() const noexcept;
548 inline
size_t capacity(
size_t i ) const noexcept;
550 inline
size_t nonZeros(
size_t i ) const;
552 inline
void reset(
size_t i );
554 inline
void resize (
size_t n,
bool preserve=true );
555 inline
void reserve(
size_t nonzeros );
556 inline
void reserve(
size_t i,
size_t nonzeros );
558 inline
void trim(
size_t i );
560 inline
void swap( SymmetricMatrix& m ) noexcept;
569 inline
void append (
size_t i,
size_t j, const
ElementType& value,
bool check=false );
570 inline
void finalize(
size_t i );
577 inline
void erase(
size_t i,
size_t j );
581 template< typename Pred >
582 inline
void erase( Pred predicate );
584 template< typename Pred >
585 inline
void erase(
size_t i,
Iterator first,
Iterator last, Pred predicate );
592 inline
Iterator find (
size_t i,
size_t j );
594 inline
Iterator lowerBound(
size_t i,
size_t j );
596 inline
Iterator upperBound(
size_t i,
size_t j );
607 template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
614 inline
bool isIntact() const noexcept;
621 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
622 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
624 inline
bool canSMPAssign() const noexcept;
632 template< typename MT2 >
void assign( DenseMatrix<MT2,SO>& rhs );
633 template< typename MT2 >
void assign( const DenseMatrix<MT2,SO>& rhs );
634 template< typename MT2 >
void assign( SparseMatrix<MT2,SO>& rhs );
635 template< typename MT2 >
void assign( const SparseMatrix<MT2,SO>& rhs );
647 template<
bool RF, typename MT2,
bool SO2,
bool DF2,
bool NF2 >
648 friend
bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
684 template< typename MT
686 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
703 template<
typename MT
705 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n )
725 template<
typename MT
727 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
size_t nonzeros )
728 : matrix_( n, n, nonzeros )
749 template<
typename MT
751 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
size_t n,
const std::vector<size_t>& nonzeros )
752 : matrix_( n, n, nonzeros )
768 template<
typename MT
770 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const SymmetricMatrix& m )
775 resize( matrix_, m.rows(), m.columns() );
791 template<
typename MT
793 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
794 : matrix_( std::move( m.matrix_ ) )
813 template<
typename MT
815 template<
typename MT2 >
816 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
821 using RT = RemoveAdaptor_< ResultType_<MT2> >;
822 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
826 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
830 resize( matrix_, tmp.rows(), tmp.columns() );
850 template<
typename MT
852 template<
typename MT2 >
853 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
858 using RT = RemoveAdaptor_< ResultType_<MT2> >;
859 using Tmp = If_< IsComputation<MT2>, RT,
const MT2& >;
863 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
867 resize( matrix_, tmp.rows(), tmp.columns() );
868 assign(
trans( tmp ) );
900 template<
typename MT
903 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
929 template<
typename MT
932 SymmetricMatrix<MT,SO,false,false>::operator()(
size_t i,
size_t j )
const 937 return *matrix_(i,j);
959 template<
typename MT
962 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
992 template<
typename MT
995 SymmetricMatrix<MT,SO,false,false>::at(
size_t i,
size_t j )
const 1003 return (*
this)(i,j);
1021 template<
typename MT
1026 return Iterator( matrix_.begin(i) );
1044 template<
typename MT
1067 template<
typename MT
1090 template<
typename MT
1113 template<
typename MT
1136 template<
typename MT
1165 template<
typename MT
1167 inline SymmetricMatrix<MT,SO,false,false>&
1168 SymmetricMatrix<MT,SO,false,false>::operator=(
const SymmetricMatrix& rhs )
1172 if( &rhs ==
this )
return *
this;
1174 resize( matrix_, rhs.rows(), rhs.columns() );
1194 template<
typename MT
1196 inline SymmetricMatrix<MT,SO,false,false>&
1197 SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1199 matrix_ = std::move( rhs.matrix_ );
1224 template<
typename MT
1226 template<
typename MT2 >
1227 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1228 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1232 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1236 if( (~rhs).canAlias(
this ) ) {
1237 SymmetricMatrix tmp( ~rhs );
1269 template<
typename MT
1271 template<
typename MT2 >
1272 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1273 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,SO>& rhs )
1277 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1281 const ResultType_<MT2> tmp( ~rhs );
1283 if( !IsSymmetric<MT2>::value && !
isSymmetric( tmp ) ) {
1287 resize( matrix_, tmp.rows(), tmp.columns() );
1314 template<
typename MT
1316 template<
typename MT2 >
1317 inline SymmetricMatrix<MT,SO,false,false>&
1318 SymmetricMatrix<MT,SO,false,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1320 return this->operator=(
trans( ~rhs ) );
1339 template<
typename MT
1341 template<
typename MT2 >
1342 inline SymmetricMatrix<MT,SO,false,false>&
1347 using Tmp = AddTrait_< MT, ResultType_<MT2> >;
1349 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1353 Tmp tmp( (*
this) + ~rhs );
1355 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1359 resize( matrix_, tmp.rows(), tmp.columns() );
1386 template<
typename MT
1388 template<
typename MT2 >
1389 inline SymmetricMatrix<MT,SO,false,false>&
1411 template<
typename MT
1413 template<
typename MT2 >
1414 inline SymmetricMatrix<MT,SO,false,false>&
1419 using Tmp = SubTrait_< MT, ResultType_<MT2> >;
1421 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1425 Tmp tmp( (*
this) - ~rhs );
1427 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1431 resize( matrix_, tmp.rows(), tmp.columns() );
1458 template<
typename MT
1460 template<
typename MT2 >
1461 inline SymmetricMatrix<MT,SO,false,false>&
1483 template<
typename MT
1485 template<
typename MT2 >
1486 inline SymmetricMatrix<MT,SO,false,false>&
1487 SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,SO>& rhs )
1491 using Tmp = SchurTrait_< MT, ResultType_<MT2> >;
1493 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1497 Tmp tmp( (*
this) % ~rhs );
1499 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1503 resize( matrix_, tmp.rows(), tmp.columns() );
1530 template<
typename MT
1532 template<
typename MT2 >
1533 inline SymmetricMatrix<MT,SO,false,false>&
1534 SymmetricMatrix<MT,SO,false,false>::operator%=(
const Matrix<MT2,!SO>& rhs )
1536 return this->operator%=(
trans( ~rhs ) );
1550 template<
typename MT
1552 template<
typename ST >
1553 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,false,false> >&
1556 for(
size_t i=0UL; i<
rows(); ++i ) {
1557 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1558 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1559 *element->value() *= rhs;
1576 template<
typename MT
1578 template<
typename ST >
1579 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,false,false> >&
1584 for(
size_t i=0UL; i<
rows(); ++i ) {
1585 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1586 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1587 *element->value() /= rhs;
1610 template<
typename MT
1614 return matrix_.rows();
1626 template<
typename MT
1630 return matrix_.columns();
1642 template<
typename MT
1646 return matrix_.capacity();
1663 template<
typename MT
1667 return matrix_.capacity(i);
1679 template<
typename MT
1683 return matrix_.nonZeros();
1701 template<
typename MT
1705 return matrix_.nonZeros(i);
1717 template<
typename MT
1767 template<
typename MT
1771 for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1773 const size_t j( it->index() );
1779 const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1781 matrix_.erase( j, pos );
1784 const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1786 matrix_.erase( j, pos );
1804 template<
typename MT
1831 template<
typename MT
1841 matrix_.resize( n, n,
true );
1858 template<
typename MT
1860 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t nonzeros )
1862 matrix_.reserve( nonzeros );
1882 template<
typename MT
1884 inline void SymmetricMatrix<MT,SO,false,false>::reserve(
size_t i,
size_t nonzeros )
1886 matrix_.reserve( i, nonzeros );
1903 template<
typename MT
1905 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1925 template<
typename MT
1927 inline void SymmetricMatrix<MT,SO,false,false>::trim(
size_t i )
1945 template<
typename MT
1949 matrix_.shrinkToFit();
1962 template<
typename MT
1968 swap( matrix_, m.matrix_ );
1996 template<
typename MT
2001 SharedValue<ET> shared( value );
2004 matrix_.set( j, i, shared );
2006 return Iterator( matrix_.set( i, j, shared ) );
2027 template<
typename MT
2030 SymmetricMatrix<MT,SO,false,false>::insert(
size_t i,
size_t j,
const ElementType& value )
2032 SharedValue<ET> shared( value );
2035 matrix_.insert( j, i, shared );
2037 return Iterator( matrix_.insert( i, j, shared ) );
2098 template<
typename MT
2100 inline void SymmetricMatrix<MT,SO,false,false>::append(
size_t i,
size_t j,
const ElementType& value,
bool check )
2102 SharedValue<ET> shared( value );
2104 matrix_.append( i, j, shared, check );
2105 if( i != j && ( !check || !isDefault<strict>( value ) ) )
2106 matrix_.insert( j, i, shared );
2126 template<
typename MT
2128 inline void SymmetricMatrix<MT,SO,false,false>::finalize(
size_t i )
2154 template<
typename MT
2156 inline void SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
size_t j )
2158 matrix_.erase( i, j );
2160 matrix_.erase( j, i );
2178 template<
typename MT
2181 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator pos )
2183 if( pos ==
end( i ) )
2186 const size_t j( pos->index() );
2189 return Iterator( matrix_.erase( i, pos.base() ) );
2193 matrix_.erase( j, matrix_.find( i, j ) );
2194 return Iterator( matrix_.erase( i, pos.base() ) );
2198 matrix_.erase( j, matrix_.find( j, i ) );
2199 return Iterator( matrix_.erase( i, pos.base() ) );
2220 template<
typename MT
2223 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last )
2225 for(
Iterator it=first; it!=last; ++it )
2227 const size_t j( it->index() );
2234 matrix_.erase( i, j );
2238 matrix_.erase( j, i );
2242 return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2262 template<
typename MT
2264 template<
typename Pred >
2265 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2267 matrix_.erase( [predicate=predicate](
const SharedValue<ET>& value ) {
2268 return predicate( *value );
2296 template<
typename MT
2298 template<
typename Pred >
2300 SymmetricMatrix<MT,SO,false,false>::erase(
size_t i,
Iterator first,
Iterator last, Pred predicate )
2302 for(
Iterator it=first; it!=last; ++it ) {
2303 const size_t j( it->index() );
2304 if( i != j && predicate( it->value() ) ) {
2306 matrix_.erase( i, j );
2308 matrix_.erase( j, i );
2312 matrix_.erase( i, first.base(), last.base(),
2313 [predicate=predicate](
const SharedValue<ET>& value ) {
2314 return predicate( *value );
2347 template<
typename MT
2350 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
2352 return Iterator( matrix_.find( i, j ) );
2374 template<
typename MT
2377 SymmetricMatrix<MT,SO,false,false>::find(
size_t i,
size_t j )
const 2401 template<
typename MT
2404 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
2406 return Iterator( matrix_.lowerBound( i, j ) );
2428 template<
typename MT
2431 SymmetricMatrix<MT,SO,false,false>::lowerBound(
size_t i,
size_t j )
const 2455 template<
typename MT
2458 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
2460 return Iterator( matrix_.upperBound( i, j ) );
2482 template<
typename MT
2485 SymmetricMatrix<MT,SO,false,false>::upperBound(
size_t i,
size_t j )
const 2507 template<
typename MT
2523 template<
typename MT
2527 for(
size_t i=0UL; i<
rows(); ++i ) {
2528 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2529 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2557 template<
typename MT
2559 template<
typename Other >
2560 inline SymmetricMatrix<MT,SO,false,false>&
2561 SymmetricMatrix<MT,SO,false,false>::scale(
const Other& scalar )
2563 for(
size_t i=0UL; i<
rows(); ++i ) {
2564 const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2565 for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2566 ( *element->value() ).scale( scalar );
2593 template<
typename MT
2624 template<
typename MT
2626 template<
typename Other >
2627 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias(
const Other* alias )
const noexcept
2629 return matrix_.canAlias( alias );
2646 template<
typename MT
2648 template<
typename Other >
2649 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased(
const Other* alias )
const noexcept
2651 return matrix_.isAliased( alias );
2668 template<
typename MT
2670 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2672 return matrix_.canSMPAssign();
2690 template<
typename MT
2692 template<
typename MT2 >
2693 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2700 std::vector<size_t> nonzeros(
rows(), 0UL );
2703 for(
size_t i=0UL; i<
rows(); ++i ) {
2708 matrix_.reserve(
sum );
2709 for(
size_t i=0UL; i<
rows(); ++i ) {
2710 matrix_.reserve( i, nonzeros[i] );
2713 for(
size_t i=0UL; i<
rows(); ++i ) {
2714 for(
size_t j=i; j<
columns(); ++j ) {
2716 SharedValue<ET> shared;
2717 *shared = std::move( (~rhs)(i,j) );
2718 matrix_.append( i, j, shared,
false );
2720 matrix_.append( j, i, shared,
false );
2741 template<
typename MT
2743 template<
typename MT2 >
2744 void SymmetricMatrix<MT,SO,false,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2751 std::vector<size_t> nonzeros(
rows(), 0UL );
2754 for(
size_t i=0UL; i<
rows(); ++i ) {
2759 matrix_.reserve(
sum );
2760 for(
size_t i=0UL; i<
rows(); ++i ) {
2761 matrix_.reserve( i, nonzeros[i] );
2764 for(
size_t i=0UL; i<
rows(); ++i ) {
2765 for(
size_t j=i; j<
columns(); ++j ) {
2767 const SharedValue<ET> shared( (~rhs)(i,j) );
2768 matrix_.append( i, j, shared,
false );
2770 matrix_.append( j, i, shared,
false );
2791 template<
typename MT
2793 template<
typename MT2 >
2794 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2801 std::vector<size_t> nonzeros(
rows(), 0UL );
2804 for(
size_t i=0UL; i<
rows(); ++i ) {
2809 matrix_.reserve(
sum );
2810 for(
size_t i=0UL; i<
rows(); ++i ) {
2811 matrix_.reserve( i, nonzeros[i] );
2814 for(
size_t i=0UL; i<
rows(); ++i ) {
2815 for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2817 SharedValue<ET> shared;
2818 *shared = std::move( it->value() );
2819 matrix_.append( i, it->index(), shared, false );
2820 if( i != it->index() )
2821 matrix_.append( it->index(), i, shared, false );
2842 template<
typename MT
2844 template<
typename MT2 >
2845 void SymmetricMatrix<MT,SO,false,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2852 std::vector<size_t> nonzeros(
rows(), 0UL );
2855 for(
size_t i=0UL; i<
rows(); ++i ) {
2860 matrix_.reserve(
sum );
2861 for(
size_t i=0UL; i<
rows(); ++i ) {
2862 matrix_.reserve( i, nonzeros[i] );
2865 for(
size_t i=0UL; i<
rows(); ++i ) {
2866 for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).
end(i); ++it ) {
2868 const SharedValue<ET> shared( it->value() );
2869 matrix_.append( i, it->index(), shared, false );
2870 if( i != it->index() )
2871 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:3077
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
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:522
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
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
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:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
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:588
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:827
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#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:560
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
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:474
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:408
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:670
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:3082
Header file for the clear shim.
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:5908
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:5891
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#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:3079
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
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:506
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:714
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:430
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:608
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:272
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:841
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
#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:3081
#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:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#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
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
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
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801