35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
101 template<
typename MT
103 class SymmetricMatrix<MT,SO,true,false>
104 :
public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
115 typedef SymmetricMatrix<MT,SO,true,false>
This;
117 typedef SymmetricMatrix<OT,!SO,true,false>
OppositeType;
124 typedef typename MT::Pointer Pointer;
125 typedef typename MT::ConstPointer ConstPointer;
131 template<
typename ET >
134 typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
141 template<
typename MatrixType >
147 typedef typename IfTrue< IsConst<MatrixType>::value
151 typedef std::random_access_iterator_tag IteratorCategory;
152 typedef RemoveReference<Reference> ValueType;
153 typedef ValueType* PointerType;
154 typedef Reference ReferenceType;
155 typedef ptrdiff_t DifferenceType;
158 typedef IteratorCategory iterator_category;
159 typedef ValueType value_type;
160 typedef PointerType pointer;
161 typedef ReferenceType reference;
162 typedef DifferenceType difference_type;
168 inline MatrixIterator()
182 inline MatrixIterator( MatrixType& matrix,
size_t row,
size_t column )
194 template<
typename MatrixType2 >
195 inline MatrixIterator(
const MatrixIterator<MatrixType2>& it )
196 : matrix_( it.matrix_ )
198 , column_( it.column_ )
208 inline MatrixIterator& operator+=(
size_t inc ) {
209 ( SO )?( row_ += inc ):( column_ += inc );
220 inline MatrixIterator& operator-=(
size_t dec ) {
221 ( SO )?( row_ -= dec ):( column_ -= dec );
231 inline MatrixIterator& operator++() {
232 ( SO )?( ++row_ ):( ++column_ );
242 inline const MatrixIterator operator++(
int ) {
243 const MatrixIterator tmp( *
this );
254 inline MatrixIterator& operator--() {
255 ( SO )?( --row_ ):( --column_ );
265 inline const MatrixIterator operator--(
int ) {
266 const MatrixIterator tmp( *
this );
278 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
279 return (*matrix_)(row_,column_);
281 return (*matrix_)(column_,row_);
290 inline PointerType operator->()
const {
291 if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
292 return &(*matrix_)(row_,column_);
294 return &(*matrix_)(column_,row_);
304 template<
typename MatrixType2 >
305 inline bool operator==(
const MatrixIterator<MatrixType2>& rhs )
const {
306 return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
316 template<
typename MatrixType2 >
317 inline bool operator!=(
const MatrixIterator<MatrixType2>& rhs )
const {
318 return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
328 template<
typename MatrixType2 >
329 inline bool operator<( const MatrixIterator<MatrixType2>& rhs )
const {
330 return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
331 return ( column_ < rhs.column_ );
341 template<
typename MatrixType2 >
342 inline bool operator>(
const MatrixIterator<MatrixType2>& rhs )
const {
343 return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
344 return ( column_ > rhs.column_ );
354 template<
typename MatrixType2 >
355 inline bool operator<=( const MatrixIterator<MatrixType2>& rhs )
const {
356 return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
366 template<
typename MatrixType2 >
367 inline bool operator>=(
const MatrixIterator<MatrixType2>& rhs )
const {
368 return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
378 inline DifferenceType
operator-(
const MatrixIterator& rhs )
const {
379 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
390 friend inline const MatrixIterator
operator+(
const MatrixIterator& it,
size_t inc ) {
392 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
394 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
405 friend inline const MatrixIterator
operator+(
size_t inc,
const MatrixIterator& it ) {
407 return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
409 return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
420 friend inline const MatrixIterator
operator-(
const MatrixIterator& it,
size_t dec ) {
422 return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
424 return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
436 template<
typename MatrixType2 >
friend class MatrixIterator;
442 typedef MatrixIterator<MT>
Iterator;
448 enum { vectorizable = 0 };
451 enum { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
457 explicit inline SymmetricMatrix();
458 explicit inline SymmetricMatrix(
size_t n );
460 inline SymmetricMatrix(
const SymmetricMatrix& m );
461 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,SO>& m );
462 template<
typename MT2 >
inline SymmetricMatrix(
const Matrix<MT2,!SO>& m );
473 inline Reference operator()(
size_t i,
size_t j );
474 inline ConstReference operator()(
size_t i,
size_t j )
const;
475 inline ConstPointer data ()
const;
476 inline ConstPointer data (
size_t i )
const;
477 inline Iterator
begin (
size_t i );
478 inline ConstIterator
begin (
size_t i )
const;
479 inline ConstIterator
cbegin(
size_t i )
const;
480 inline Iterator
end (
size_t i );
481 inline ConstIterator
end (
size_t i )
const;
482 inline ConstIterator
cend (
size_t i )
const;
489 inline SymmetricMatrix& operator=(
const SymmetricMatrix& rhs );
491 template<
typename MT2 >
492 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
493 operator=(
const Matrix<MT2,SO>& rhs );
495 template<
typename MT2 >
496 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
497 operator=(
const Matrix<MT2,SO>& rhs );
499 template<
typename MT2 >
500 inline SymmetricMatrix& operator=(
const Matrix<MT2,!SO>& rhs );
502 template<
typename MT2 >
503 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
504 operator+=(
const Matrix<MT2,SO>& rhs );
506 template<
typename MT2 >
507 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
508 operator+=(
const Matrix<MT2,SO>& rhs );
510 template<
typename MT2 >
511 inline SymmetricMatrix& operator+=(
const Matrix<MT2,!SO>& rhs );
513 template<
typename MT2 >
514 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
515 operator-=(
const Matrix<MT2,SO>& rhs );
517 template<
typename MT2 >
518 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
519 operator-=(
const Matrix<MT2,SO>& rhs );
521 template<
typename MT2 >
522 inline SymmetricMatrix& operator-=(
const Matrix<MT2,!SO>& rhs );
524 template<
typename MT2,
bool SO2 >
525 inline SymmetricMatrix& operator*=(
const Matrix<MT2,SO2>& rhs );
527 template<
typename Other >
528 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
529 operator*=( Other rhs );
531 template<
typename Other >
532 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
533 operator/=( Other rhs );
540 inline size_t rows()
const;
544 inline size_t capacity(
size_t i )
const;
546 inline size_t nonZeros(
size_t i )
const;
548 inline void reset(
size_t i );
550 void resize (
size_t n,
bool preserve=
true );
551 inline void extend (
size_t n,
bool preserve=
true );
552 inline void reserve(
size_t elements );
553 inline SymmetricMatrix& transpose();
554 template<
typename Other >
inline SymmetricMatrix& scale(
const Other& scalar );
555 inline void swap( SymmetricMatrix& m ) ;
563 inline bool isLowerOrUpper();
571 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
572 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
574 inline bool isAligned ()
const;
575 inline bool canSMPAssign()
const;
583 template<
typename MT2 >
inline void assign ( DenseMatrix <MT2,SO>& rhs );
584 template<
typename MT2 >
inline void assign (
const DenseMatrix <MT2,SO>& rhs );
585 template<
typename MT2 >
inline void assign (
const SparseMatrix<MT2,SO>& rhs );
586 template<
typename MT2 >
inline void addAssign(
const DenseMatrix <MT2,SO>& rhs );
587 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
588 template<
typename MT2 >
inline void subAssign(
const DenseMatrix <MT2,SO>& rhs );
589 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
601 template<
typename MT2,
bool SO2,
bool DF2,
bool NF2 >
602 friend bool isDefault(
const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
637 template<
typename MT
639 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
654 template<
typename MT
656 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
size_t n )
673 template<
typename MT
675 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const SymmetricMatrix& m )
676 : matrix_( m.matrix_ )
695 template<
typename MT
697 template<
typename MT2 >
698 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,SO>& m )
703 typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
704 typedef typename If< IsComputation<MT2>, RT,
const MT2& >::Type Tmp;
706 if( IsSymmetric<MT2>::value ) {
714 throw std::invalid_argument(
"Invalid setup of symmetric matrix" );
716 resize( matrix_, tmp.rows(), tmp.rows() );
737 template<
typename MT
739 template<
typename MT2 >
740 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix(
const Matrix<MT2,!SO>& m )
745 typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
746 typedef typename If< IsComputation<MT2>, RT,
const MT2& >::Type Tmp;
748 if( IsSymmetric<MT2>::value ) {
756 throw std::invalid_argument(
"Invalid setup of symmetric matrix" );
758 resize( matrix_, tmp.rows(), tmp.rows() );
789 template<
typename MT
792 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
797 if( ( !SO && i > j ) || ( SO && i < j ) )
818 template<
typename MT
821 SymmetricMatrix<MT,SO,true,false>::operator()(
size_t i,
size_t j )
const
826 if( ( !SO && i > j ) || ( SO && i < j ) )
849 template<
typename MT
851 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
852 SymmetricMatrix<MT,SO,true,false>::data()
const
854 return matrix_.data();
871 template<
typename MT
873 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
874 SymmetricMatrix<MT,SO,true,false>::data(
size_t i )
const
876 return matrix_.data(i);
894 template<
typename MT
920 template<
typename MT
946 template<
typename MT
972 template<
typename MT
998 template<
typename MT
1024 template<
typename MT
1056 template<
typename MT
1058 inline SymmetricMatrix<MT,SO,true,false>&
1059 SymmetricMatrix<MT,SO,true,false>::operator=(
const SymmetricMatrix& rhs )
1063 if( &rhs ==
this )
return *
this;
1065 resize( matrix_, rhs.rows(), rhs.columns() );
1091 template<
typename MT
1093 template<
typename MT2 >
1094 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1095 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1099 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) )
1100 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1102 if( (~rhs).isAliased(
this ) ) {
1103 SymmetricMatrix tmp( ~rhs );
1108 if( IsSparseMatrix<MT2>::value )
1136 template<
typename MT
1138 template<
typename MT2 >
1139 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1140 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,SO>& rhs )
1144 typedef typename If< IsSymmetric<MT2>
1148 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) )
1149 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1153 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) )
1154 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1158 resize( matrix_, tmp.rows(), tmp.columns() );
1159 if( IsSparseMatrix<Tmp>::value )
1186 template<
typename MT
1188 template<
typename MT2 >
1189 inline SymmetricMatrix<MT,SO,true,false>&
1190 SymmetricMatrix<MT,SO,true,false>::operator=(
const Matrix<MT2,!SO>& rhs )
1192 return this->operator=(
trans( ~rhs ) );
1211 template<
typename MT
1213 template<
typename MT2 >
1214 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1215 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,SO>& rhs )
1217 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) )
1218 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1244 template<
typename MT
1246 template<
typename MT2 >
1247 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1248 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,SO>& rhs )
1250 typedef typename If< IsSymmetric<MT2>
1254 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) )
1255 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1259 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) )
1260 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1289 template<
typename MT
1291 template<
typename MT2 >
1292 inline SymmetricMatrix<MT,SO,true,false>&
1293 SymmetricMatrix<MT,SO,true,false>::operator+=(
const Matrix<MT2,!SO>& rhs )
1295 return this->operator+=(
trans( ~rhs ) );
1314 template<
typename MT
1316 template<
typename MT2 >
1317 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1318 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,SO>& rhs )
1320 if( !IsSymmetric<MT2>::value && !
isSymmetric( ~rhs ) )
1321 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1347 template<
typename MT
1349 template<
typename MT2 >
1350 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1351 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,SO>& rhs )
1353 typedef typename If< IsSymmetric<MT2>
1357 if( !IsSquare<MT2>::value && !
isSquare( ~rhs ) )
1358 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1362 if( !IsSymmetric<Tmp>::value && !
isSymmetric( tmp ) )
1363 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1392 template<
typename MT
1394 template<
typename MT2 >
1395 inline SymmetricMatrix<MT,SO,true,false>&
1396 SymmetricMatrix<MT,SO,true,false>::operator-=(
const Matrix<MT2,!SO>& rhs )
1398 return this->operator-=(
trans( ~rhs ) );
1416 template<
typename MT
1418 template<
typename MT2
1420 inline SymmetricMatrix<MT,SO,true,false>&
1421 SymmetricMatrix<MT,SO,true,false>::operator*=(
const Matrix<MT2,SO2>& rhs )
1425 typedef typename MultTrait<MT,typename MT2::ResultType>::Type Tmp;
1429 if( matrix_.rows() != (~rhs).
columns() )
1430 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1432 Tmp tmp( (*
this) * ~rhs );
1435 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1437 resize( matrix_, tmp.rows(), tmp.columns() );
1457 template<
typename MT
1459 template<
typename Other >
1460 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1461 SymmetricMatrix<MT,SO,true,false>::operator*=( Other rhs )
1464 for(
size_t j=0UL; j<
columns(); ++j )
1465 for(
size_t i=0UL; i<=j; ++i )
1466 matrix_(i,j) *= rhs;
1469 for(
size_t i=0UL; i<
rows(); ++i )
1470 for(
size_t j=0UL; j<=i; ++j )
1471 matrix_(i,j) *= rhs;
1488 template<
typename MT
1490 template<
typename Other >
1491 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1492 SymmetricMatrix<MT,SO,true,false>::operator/=( Other rhs )
1497 for(
size_t j=0UL; j<
columns(); ++j )
1498 for(
size_t i=0UL; i<=j; ++i )
1499 matrix_(i,j) /= rhs;
1502 for(
size_t i=0UL; i<
rows(); ++i )
1503 for(
size_t j=0UL; j<=i; ++j )
1504 matrix_(i,j) /= rhs;
1527 template<
typename MT
1531 return matrix_.rows();
1543 template<
typename MT
1547 return matrix_.columns();
1565 template<
typename MT
1569 return matrix_.spacing();
1581 template<
typename MT
1585 return matrix_.capacity();
1602 template<
typename MT
1606 return matrix_.capacity(i);
1618 template<
typename MT
1622 size_t nonzeros( 0UL );
1626 for(
size_t j=0UL; j<
columns(); ++j ) {
1627 for(
size_t i=0UL; i<j; ++i ) {
1637 for(
size_t i=0UL; i<
rows(); ++i ) {
1638 for(
size_t j=0UL; j<i; ++j ) {
1665 template<
typename MT
1669 size_t nonzeros( 0UL );
1673 for(
size_t j=0UL; j<i; ++j ) {
1677 for(
size_t j=i; j<
rows(); ++j ) {
1684 for(
size_t j=0UL; j<i; ++j ) {
1688 for(
size_t j=i; j<
rows(); ++j ) {
1706 template<
typename MT
1713 for(
size_t j=0UL; j<
columns(); ++j )
1714 for(
size_t i=0UL; i<=j; ++i )
1715 clear( matrix_(i,j) );
1718 for(
size_t i=0UL; i<
rows(); ++i )
1719 for(
size_t j=0UL; j<=i; ++j )
1720 clear( matrix_(i,j) );
1767 template<
typename MT
1792 template<
typename MT
1820 template<
typename MT
1830 const size_t oldsize( matrix_.rows() );
1832 matrix_.resize( n, n,
true );
1835 const size_t increment( n - oldsize );
1836 submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
1837 submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
1857 template<
typename MT
1859 inline void SymmetricMatrix<MT,SO,true,false>::extend(
size_t n,
bool preserve )
1881 template<
typename MT
1883 inline void SymmetricMatrix<MT,SO,true,false>::reserve(
size_t elements )
1885 matrix_.reserve( elements );
1897 template<
typename MT
1899 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
1914 template<
typename MT
1916 template<
typename Other >
1917 inline SymmetricMatrix<MT,SO,true,false>&
1918 SymmetricMatrix<MT,SO,true,false>::scale(
const Other& scalar )
1921 for(
size_t j=0UL; j<
columns(); ++j )
1922 for(
size_t i=0UL; i<=j; ++i )
1923 matrix_(i,j) *= scalar;
1926 for(
size_t i=0UL; i<
rows(); ++i )
1927 for(
size_t j=0UL; j<=i; ++j )
1928 matrix_(i,j) *= scalar;
1945 template<
typename MT
1951 swap( matrix_, m.matrix_ );
1968 template<
typename MT
1970 inline bool SymmetricMatrix<MT,SO,true,false>::isLowerOrUpper()
1997 template<
typename MT
1999 template<
typename Other >
2000 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias(
const Other* alias )
const
2002 return matrix_.canAlias( alias );
2019 template<
typename MT
2021 template<
typename Other >
2022 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased(
const Other* alias )
const
2024 return matrix_.isAliased( alias );
2040 template<
typename MT
2042 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned()
const
2044 return matrix_.isAligned();
2061 template<
typename MT
2063 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign()
const
2065 return matrix_.canSMPAssign();
2083 template<
typename MT
2085 template<
typename MT2 >
2092 for(
size_t j=0UL; j<
columns(); ++j )
2093 for(
size_t i=0UL; i<=j; ++i )
2094 move( matrix_(i,j), (~rhs)(i,j) );
2097 for(
size_t i=0UL; i<
rows(); ++i )
2098 for(
size_t j=0UL; j<=i; ++j )
2099 move( matrix_(i,j), (~rhs)(i,j) );
2118 template<
typename MT
2120 template<
typename MT2 >
2127 for(
size_t j=0UL; j<
columns(); ++j )
2128 for(
size_t i=0UL; i<=j; ++i )
2129 matrix_(i,j) = (~rhs)(i,j);
2132 for(
size_t i=0UL; i<
rows(); ++i )
2133 for(
size_t j=0UL; j<=i; ++j )
2134 matrix_(i,j) = (~rhs)(i,j);
2153 template<
typename MT
2155 template<
typename MT2 >
2164 for(
size_t j=0UL; j<
columns(); ++j ) {
2165 const ConstIterator last( (~rhs).upperBound(j,j) );
2166 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2167 matrix_(element->index(),j) = element->value();
2171 for(
size_t i=0UL; i<
rows(); ++i ) {
2172 const ConstIterator last( (~rhs).upperBound(i,i) );
2173 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2174 matrix_(i,element->index()) = element->value();
2194 template<
typename MT
2196 template<
typename MT2 >
2203 for(
size_t j=0UL; j<
columns(); ++j )
2204 for(
size_t i=0UL; i<=j; ++i )
2205 matrix_(i,j) += (~rhs)(i,j);
2208 for(
size_t i=0UL; i<
rows(); ++i )
2209 for(
size_t j=0UL; j<=i; ++j )
2210 matrix_(i,j) += (~rhs)(i,j);
2229 template<
typename MT
2231 template<
typename MT2 >
2240 for(
size_t j=0UL; j<
columns(); ++j ) {
2241 const ConstIterator last( (~rhs).upperBound(j,j) );
2242 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2243 matrix_(element->index(),j) += element->value();
2247 for(
size_t i=0UL; i<
rows(); ++i ) {
2248 const ConstIterator last( (~rhs).upperBound(i,i) );
2249 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2250 matrix_(i,element->index()) += element->value();
2270 template<
typename MT
2272 template<
typename MT2 >
2279 for(
size_t j=0UL; j<
columns(); ++j )
2280 for(
size_t i=0UL; i<=j; ++i )
2281 matrix_(i,j) -= (~rhs)(i,j);
2284 for(
size_t i=0UL; i<
rows(); ++i )
2285 for(
size_t j=0UL; j<=i; ++j )
2286 matrix_(i,j) -= (~rhs)(i,j);
2305 template<
typename MT
2307 template<
typename MT2 >
2316 for(
size_t j=0UL; j<
columns(); ++j ) {
2317 const ConstIterator last( (~rhs).upperBound(j,j) );
2318 for( ConstIterator element=(~rhs).
begin(j); element!=last; ++element )
2319 matrix_(element->index(),j) -= element->value();
2323 for(
size_t i=0UL; i<
rows(); ++i ) {
2324 const ConstIterator last( (~rhs).upperBound(i,i) );
2325 for( ConstIterator element=(~rhs).
begin(i); element!=last; ++element )
2326 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
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 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:8247
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:902
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:237
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:4825
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:300
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:258
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:242
#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:692
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4762
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:103
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
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2501
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:386
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2503
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:964
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
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:4789
Header file for the DisableIf class template.
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:4807
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#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
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
Constraint on the data type.
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2504
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1197
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:195
#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:535
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
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:2509
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:841
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:103
#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:2506
Header file for run time assertion macros.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Constraint on the data type.
Constraint on the data type.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
#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:2510
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:200
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:143
#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:937
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:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
#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
Header file for the IsResizable 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
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849