35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
105 template<
typename MT
107 class SymmetricMatrix<MT,SO,true,false>
108 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
119 typedef SymmetricMatrix<MT,SO,true,false>
This;
121 typedef SymmetricMatrix<OT,!SO,true,false>
OppositeType;
128 typedef typename MT::Pointer Pointer;
129 typedef typename MT::ConstPointer ConstPointer;
135 template<
typename ET >
138 typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
145 template<
typename MatrixType >
151 typedef typename IfTrue< IsConst<MatrixType>::value
155 typedef std::random_access_iterator_tag IteratorCategory;
156 typedef RemoveReference<Reference> ValueType;
157 typedef ValueType* PointerType;
158 typedef Reference ReferenceType;
159 typedef ptrdiff_t DifferenceType;
162 typedef IteratorCategory iterator_category;
163 typedef ValueType value_type;
164 typedef PointerType pointer;
165 typedef ReferenceType reference;
166 typedef DifferenceType difference_type;
172 inline MatrixIterator()
186 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column )
198 template<
typename MatrixType2 >
199 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it )
200 : matrix_( it.matrix_ )
202 , column_( it.column_ )
212 inline MatrixIterator& operator+=(
size_t inc ) {
213 ( SO )?( row_ += inc ):( column_ += inc );
224 inline MatrixIterator& operator-=(
size_t dec ) {
225 ( SO )?( row_ -= dec ):( column_ -= dec );
235 inline MatrixIterator& operator++() {
236 ( SO )?( ++row_ ):( ++column_ );
246 inline const MatrixIterator operator++(
int ) {
247 const MatrixIterator tmp( *
this );
258 inline MatrixIterator& operator--() {
259 ( SO )?( --row_ ):( --column_ );
269 inline const MatrixIterator operator--(
int ) {
270 const MatrixIterator tmp( *
this );
282 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
283 return (*matrix_)(row_,column_);
285 return (*matrix_)(column_,row_);
294 inline PointerType operator->()
const {
295 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
296 return &(*matrix_)(row_,column_);
298 return &(*matrix_)(column_,row_);
308 template<
typename MatrixType2 >
309 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const {
310 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
320 template<
typename MatrixType2 >
321 inline bool operator!=(
const MatrixIterator<MatrixType2>& rhs )
const {
322 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
332 template<
typename MatrixType2 >
333 inline bool operator<( const MatrixIterator<MatrixType2>& rhs )
const {
334 return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
335 return ( column_ < rhs.column_ );
345 template<
typename MatrixType2 >
346 inline bool operator>(
const MatrixIterator<MatrixType2>& rhs )
const {
347 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
348 return ( column_ > rhs.column_ );
358 template<
typename MatrixType2 >
359 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs )
const {
360 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
370 template<
typename MatrixType2 >
371 inline bool operator>=(
const MatrixIterator<MatrixType2>& rhs )
const {
372 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
382 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const {
383 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
394 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) {
396 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
398 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
409 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) {
411 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
413 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
424 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) {
426 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
428 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
440 template<
typename MatrixType2 >
friend class MatrixIterator;
446 typedef MatrixIterator<MT>
Iterator;
452 enum { vectorizable = 0 };
455 enum { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
461 explicit inline SymmetricMatrix();
462 explicit inline SymmetricMatrix(
size_t n );
464 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n );
465 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn );
467 template<
typename Deleter >
468 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d );
470 template<
typename Deleter >
471 explicit inline SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d );
473 inline SymmetricMatrix(
const SymmetricMatrix& m );
474 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
475 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
486 inline Reference operator()(
size_t i,
size_t j );
487 inline ConstReference operator()(
size_t i,
size_t j )
const;
488 inline Reference at(
size_t i,
size_t j );
489 inline ConstReference at(
size_t i,
size_t j )
const;
490 inline ConstPointer data ()
const;
491 inline ConstPointer data (
size_t i )
const;
492 inline Iterator
begin (
size_t i );
493 inline ConstIterator
begin (
size_t i )
const;
494 inline ConstIterator
cbegin(
size_t i )
const;
495 inline Iterator
end (
size_t i );
496 inline ConstIterator
end (
size_t i )
const;
497 inline ConstIterator
cend (
size_t i )
const;
504 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
506 template<
typename MT2 >
507 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
508 operator=(
const Matrix<MT2,SO>& rhs );
510 template<
typename MT2 >
511 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
512 operator=(
const Matrix<MT2,SO>& rhs );
514 template<
typename MT2 >
515 inline SymmetricMatrix& operator=(
const Matrix<MT2,!SO>& rhs );
517 template<
typename MT2 >
518 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
519 operator+=(
const Matrix<MT2,SO>& rhs );
521 template<
typename MT2 >
522 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
523 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 typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
530 operator-=(
const Matrix<MT2,SO>& rhs );
532 template<
typename MT2 >
533 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
534 operator-=(
const Matrix<MT2,SO>& rhs );
536 template<
typename MT2 >
537 inline SymmetricMatrix& operator-=(
const Matrix<MT2,!SO>& rhs );
539 template<
typename MT2,
bool SO2 >
540 inline SymmetricMatrix& operator*=(
const Matrix<MT2,SO2>& rhs );
542 template<
typename Other >
543 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
544 operator*=( Other rhs );
546 template<
typename Other >
547 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
548 operator/=( Other rhs );
555 inline size_t rows()
const;
559 inline size_t capacity(
size_t i )
const;
561 inline size_t nonZeros(
size_t i )
const;
563 inline void reset(
size_t i );
565 void resize (
size_t n,
bool preserve=
true );
566 inline void extend (
size_t n,
bool preserve=
true );
567 inline void reserve(
size_t elements );
570 template<
typename Other >
inline SymmetricMatrix& scale(
const Other& scalar );
571 inline void swap( SymmetricMatrix& m ) ;
585 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
586 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
588 inline bool isAligned ()
const;
589 inline bool canSMPAssign()
const;
597 template<
typename MT2 >
inline void assign ( DenseMatrix <MT2,SO>& rhs );
598 template<
typename MT2 >
inline void assign (
const DenseMatrix <MT2,SO>& rhs );
599 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,SO>& rhs );
600 template<
typename MT2 >
inline void addAssign(
const DenseMatrix <MT2,SO>& rhs );
601 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
602 template<
typename MT2 >
inline void subAssign(
const DenseMatrix <MT2,SO>& rhs );
603 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
615 template<
typename MT2,
bool SO2,
bool DF2,
bool NF2 >
616 friend bool isDefault(
const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
652 template<
typename MT
654 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
669 template<
typename MT
671 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
703 template<
typename MT
705 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n )
706 : matrix_( ptr, n, n )
741 template<
typename MT
743 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn )
744 : matrix_( ptr, n, n, nn )
777 template<
typename MT
779 template<
typename Deleter >
780 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n, Deleter d )
781 : matrix_( ptr, n, n, d )
815 template<
typename MT
817 template<
typename Deleter >
818 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr,
size_t n,
size_t nn, Deleter d )
819 : matrix_( ptr, n, n, nn, d )
837 template<
typename MT
839 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
840 : matrix_( m.matrix_ )
859 template<
typename MT
861 template<
typename MT2 >
862 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
867 typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
868 typedef typename If< IsComputation<MT2>, RT,
const MT2& >::Type Tmp;
870 if( IsSymmetric<MT2>::value ) {
881 resize( matrix_, tmp.rows(), tmp.rows() );
902 template<
typename MT
904 template<
typename MT2 >
905 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
910 typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
911 typedef typename If< IsComputation<MT2>, RT,
const MT2& >::Type Tmp;
913 if( IsSymmetric<MT2>::value ) {
915 assign(
trans( ~m ) );
924 resize( matrix_, tmp.rows(), tmp.rows() );
925 assign(
trans( tmp ) );
958 template<
typename MT
961 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
966 if( ( !SO && i > j ) || ( SO && i < j ) )
990 template<
typename MT
993 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const
998 if( ( !SO && i > j ) || ( SO && i < j ) )
1001 return matrix_(j,i);
1023 template<
typename MT
1026 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
1034 return (*
this)(i,j);
1056 template<
typename MT
1059 SymmetricMatrix<MT,SO,true,false>::at(
size_t i,
size_t j )
const
1067 return (*
this)(i,j);
1087 template<
typename MT
1089 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1090 SymmetricMatrix<MT,SO,true,false>::data()
const
1092 return matrix_.data();
1109 template<
typename MT
1111 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1112 SymmetricMatrix<MT,SO,true,false>::data(
size_t i )
const
1114 return matrix_.data(i);
1132 template<
typename MT
1138 return Iterator( matrix_, 0UL, i );
1140 return Iterator( matrix_, i, 0UL );
1158 template<
typename MT
1184 template<
typename MT
1210 template<
typename MT
1236 template<
typename MT
1262 template<
typename MT
1294 template<
typename MT
1296 inline SymmetricMatrix<MT,SO,true,false>&
1297 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1301 if( &rhs ==
this )
return *
this;
1303 resize( matrix_, rhs.rows(), rhs.columns() );
1329 template<
typename MT
1331 template<
typename MT2 >
1332 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1333 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1337 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1341 if( (~rhs).isAliased(
this ) ) {
1342 SymmetricMatrix tmp( ~rhs );
1347 if( IsSparseMatrix<MT2>::value )
1375 template<
typename MT
1377 template<
typename MT2 >
1378 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1379 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1383 typedef typename If< IsSymmetric<MT2>
1387 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1393 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1399 resize( matrix_, tmp.rows(), tmp.columns() );
1400 if( IsSparseMatrix<Tmp>::value )
1427 template<
typename MT
1429 template<
typename MT2 >
1430 inline SymmetricMatrix<MT,SO,true,false>&
1431 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1433 return this->operator=(
trans( ~rhs ) );
1452 template<
typename MT
1454 template<
typename MT2 >
1455 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1456 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,SO>& rhs )
1458 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1486 template<
typename MT
1488 template<
typename MT2 >
1489 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1490 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,SO>& rhs )
1492 typedef typename If< IsSymmetric<MT2>
1496 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1502 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1533 template<
typename MT
1535 template<
typename MT2 >
1536 inline SymmetricMatrix<MT,SO,true,false>&
1537 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,!SO>& rhs )
1539 return this->operator+=(
trans( ~rhs ) );
1558 template<
typename MT
1560 template<
typename MT2 >
1561 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1562 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,SO>& rhs )
1564 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) ) {
1592 template<
typename MT
1594 template<
typename MT2 >
1595 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1596 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,SO>& rhs )
1598 typedef typename If< IsSymmetric<MT2>
1602 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) ) {
1608 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) ) {
1639 template<
typename MT
1641 template<
typename MT2 >
1642 inline SymmetricMatrix<MT,SO,true,false>&
1643 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,!SO>& rhs )
1645 return this->operator-=(
trans( ~rhs ) );
1663 template<
typename MT
1665 template<
typename MT2
1667 inline SymmetricMatrix<MT,SO,true,false>&
1668 SymmetricMatrix<MT,SO,true,false>::operator*=(
const Matrix<MT2,SO2>& rhs )
1672 typedef typename MultTrait<MT,typename MT2::ResultType>::Type Tmp;
1676 if( matrix_.rows() != (~rhs).
columns() ) {
1680 Tmp tmp( (*
this) * ~rhs );
1686 resize( matrix_, tmp.rows(), tmp.columns() );
1706 template<
typename MT
1708 template<
typename Other >
1709 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1710 SymmetricMatrix<MT,SO,true,false>::operator*=( Other rhs )
1713 for(
size_t j=0UL; j<
columns(); ++j )
1714 for(
size_t i=0UL; i<=j; ++i )
1715 matrix_(i,j) *= rhs;
1718 for(
size_t i=0UL; i<
rows(); ++i )
1719 for(
size_t j=0UL; j<=i; ++j )
1720 matrix_(i,j) *= rhs;
1737 template<
typename MT
1739 template<
typename Other >
1740 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1741 SymmetricMatrix<MT,SO,true,false>::operator/=( Other rhs )
1746 for(
size_t j=0UL; j<
columns(); ++j )
1747 for(
size_t i=0UL; i<=j; ++i )
1748 matrix_(i,j) /= rhs;
1751 for(
size_t i=0UL; i<
rows(); ++i )
1752 for(
size_t j=0UL; j<=i; ++j )
1753 matrix_(i,j) /= rhs;
1776 template<
typename MT
1780 return matrix_.rows();
1792 template<
typename MT
1796 return matrix_.columns();
1814 template<
typename MT
1818 return matrix_.spacing();
1830 template<
typename MT
1834 return matrix_.capacity();
1851 template<
typename MT
1855 return matrix_.capacity(i);
1867 template<
typename MT
1871 size_t nonzeros( 0UL );
1875 for(
size_t j=0UL; j<
columns(); ++j ) {
1876 for(
size_t i=0UL; i<j; ++i ) {
1886 for(
size_t i=0UL; i<
rows(); ++i ) {
1887 for(
size_t j=0UL; j<i; ++j ) {
1914 template<
typename MT
1918 size_t nonzeros( 0UL );
1922 for(
size_t j=0UL; j<i; ++j ) {
1926 for(
size_t j=i; j<
rows(); ++j ) {
1933 for(
size_t j=0UL; j<i; ++j ) {
1937 for(
size_t j=i; j<
rows(); ++j ) {
1955 template<
typename MT
1962 for(
size_t j=0UL; j<
columns(); ++j )
1963 for(
size_t i=0UL; i<=j; ++i )
1964 clear( matrix_(i,j) );
1967 for(
size_t i=0UL; i<
rows(); ++i )
1968 for(
size_t j=0UL; j<=i; ++j )
1969 clear( matrix_(i,j) );
2016 template<
typename MT
2041 template<
typename MT
2069 template<
typename MT
2079 const size_t oldsize( matrix_.rows() );
2081 matrix_.resize( n, n,
true );
2084 const size_t increment( n - oldsize );
2085 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2086 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2106 template<
typename MT
2108 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
2130 template<
typename MT
2132 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
2134 matrix_.reserve( elements );
2146 template<
typename MT
2162 template<
typename MT
2167 for(
size_t j=0UL; j<
columns(); ++j )
2168 for(
size_t i=0UL; i<=j; ++i )
2172 for(
size_t i=0UL; i<
rows(); ++i )
2173 for(
size_t j=0UL; j<=i; ++j )
2190 template<
typename MT
2192 template<
typename Other >
2193 inline SymmetricMatrix<MT,SO,true,false>&
2194 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
2197 for(
size_t j=0UL; j<
columns(); ++j )
2198 for(
size_t i=0UL; i<=j; ++i )
2199 matrix_(i,j) *= scalar;
2202 for(
size_t i=0UL; i<
rows(); ++i )
2203 for(
size_t j=0UL; j<=i; ++j )
2204 matrix_(i,j) *= scalar;
2221 template<
typename MT
2227 swap( matrix_, m.matrix_ );
2251 template<
typename MT
2258 ( IsCustom<MT>::value || ( SO ?
isUpper( matrix_ ) :
isLower( matrix_ ) ) );
2283 template<
typename MT
2285 template<
typename Other >
2286 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const
2288 return matrix_.canAlias( alias );
2305 template<
typename MT
2307 template<
typename Other >
2308 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const
2310 return matrix_.isAliased( alias );
2326 template<
typename MT
2328 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned()
const
2330 return matrix_.isAligned();
2347 template<
typename MT
2349 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign()
const
2351 return matrix_.canSMPAssign();
2369 template<
typename MT
2371 template<
typename MT2 >
2372 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2378 for(
size_t j=0UL; j<
columns(); ++j )
2379 for(
size_t i=0UL; i<=j; ++i )
2380 move( matrix_(i,j), (~rhs)(i,j) );
2383 for(
size_t i=0UL; i<
rows(); ++i )
2384 for(
size_t j=0UL; j<=i; ++j )
2385 move( matrix_(i,j), (~rhs)(i,j) );
2404 template<
typename MT
2406 template<
typename MT2 >
2407 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const DenseMatrix<MT2,SO>& rhs )
2413 for(
size_t j=0UL; j<
columns(); ++j )
2414 for(
size_t i=0UL; i<=j; ++i )
2415 matrix_(i,j) = (~rhs)(i,j);
2418 for(
size_t i=0UL; i<
rows(); ++i )
2419 for(
size_t j=0UL; j<=i; ++j )
2420 matrix_(i,j) = (~rhs)(i,j);
2439 template<
typename MT
2441 template<
typename MT2 >
2442 inline void SymmetricMatrix<MT,SO,true,false>::assign(
const SparseMatrix<MT2,SO>& rhs )
2450 for(
size_t j=0UL; j<
columns(); ++j ) {
2451 const ConstIterator last( (~rhs).upperBound(j,j) );
2452 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2453 matrix_(element->index(),j) = element->value();
2457 for(
size_t i=0UL; i<
rows(); ++i ) {
2458 const ConstIterator last( (~rhs).upperBound(i,i) );
2459 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2460 matrix_(i,element->index()) = element->value();
2480 template<
typename MT
2482 template<
typename MT2 >
2483 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const DenseMatrix<MT2,SO>& rhs )
2489 for(
size_t j=0UL; j<
columns(); ++j )
2490 for(
size_t i=0UL; i<=j; ++i )
2491 matrix_(i,j) += (~rhs)(i,j);
2494 for(
size_t i=0UL; i<
rows(); ++i )
2495 for(
size_t j=0UL; j<=i; ++j )
2496 matrix_(i,j) += (~rhs)(i,j);
2515 template<
typename MT
2517 template<
typename MT2 >
2518 inline void SymmetricMatrix<MT,SO,true,false>::addAssign(
const SparseMatrix<MT2,SO>& rhs )
2526 for(
size_t j=0UL; j<
columns(); ++j ) {
2527 const ConstIterator last( (~rhs).upperBound(j,j) );
2528 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2529 matrix_(element->index(),j) += element->value();
2533 for(
size_t i=0UL; i<
rows(); ++i ) {
2534 const ConstIterator last( (~rhs).upperBound(i,i) );
2535 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2536 matrix_(i,element->index()) += element->value();
2556 template<
typename MT
2558 template<
typename MT2 >
2559 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const DenseMatrix<MT2,SO>& rhs )
2565 for(
size_t j=0UL; j<
columns(); ++j )
2566 for(
size_t i=0UL; i<=j; ++i )
2567 matrix_(i,j) -= (~rhs)(i,j);
2570 for(
size_t i=0UL; i<
rows(); ++i )
2571 for(
size_t j=0UL; j<=i; ++j )
2572 matrix_(i,j) -= (~rhs)(i,j);
2591 template<
typename MT
2593 template<
typename MT2 >
2594 inline void SymmetricMatrix<MT,SO,true,false>::subAssign(
const SparseMatrix<MT2,SO>& rhs )
2602 for(
size_t j=0UL; j<
columns(); ++j ) {
2603 const ConstIterator last( (~rhs).upperBound(j,j) );
2604 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2605 matrix_(element->index(),j) -= element->value();
2609 for(
size_t i=0UL; i<
rows(); ++i ) {
2610 const ConstIterator last( (~rhs).upperBound(i,i) );
2611 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2612 matrix_(i,element->index()) -= element->value();
Header file for all restructuring submatrix functions.
#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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7820
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
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:229
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
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:292
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:250
Header file for the IsSparseMatrix type trait.
#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:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:697
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:584
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#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:116
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:378
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
Header file for the implementation of the base template of the SymmetricMatrix.
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1044
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Constraint on the data type.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:4953
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
BLAZE_ALWAYS_INLINE void conjugate(T &a)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Constraint on the data type.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1277
Constraints on the storage order of matrix types.
#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:118
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:187
#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:118
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:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for the RemoveAdaptor type trait.
Header file for all forward declarations for expression class templates.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
#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:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Header file for run time assertion macros.
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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Header file for the RemoveReference type trait.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the move shim.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:146
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:79
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:118
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for exception macros.
#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:143
#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
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558