35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
451 template<
typename MT
453 ,
bool SO = IsColumnMajorMatrix<MT>::value >
504 template<
typename IteratorType >
513 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
516 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
519 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
522 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
552 size_t remainingElements,
bool isMemoryAligned )
554 ,
final_ ( finalIterator )
555 ,
rest_ ( remainingElements )
565 template<
typename IteratorType2 >
684 for(
size_t j=0UL; j<
rest_; ++j )
686 for(
size_t j=rest_; j<
IT::size; ++j )
811 inline IteratorType
base()
const {
821 inline IteratorType
final()
const {
866 enum { vectorizable = MT::vectorizable };
869 enum { smpAssignable = MT::smpAssignable };
906 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO2>& rhs );
907 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO2>& rhs );
908 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO2>& rhs );
910 template<
typename Other >
911 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
912 operator*=( Other rhs );
914 template<
typename Other >
915 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
916 operator/=( Other rhs );
923 inline size_t rows()
const;
927 inline size_t capacity(
size_t i )
const;
929 inline size_t nonZeros(
size_t i )
const;
931 inline void reset(
size_t i );
933 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
940 template<
typename MT2 >
942 struct VectorizedAssign {
943 enum { value = vectorizable && MT2::vectorizable &&
944 IsSame<ElementType,typename MT2::ElementType>::value };
951 template<
typename MT2 >
953 struct VectorizedAddAssign {
954 enum { value = vectorizable && MT2::vectorizable &&
955 IsSame<ElementType,typename MT2::ElementType>::value &&
956 IntrinsicTrait<ElementType>::addition };
963 template<
typename MT2 >
965 struct VectorizedSubAssign {
966 enum { value = vectorizable && MT2::vectorizable &&
967 IsSame<ElementType,typename MT2::ElementType>::value &&
968 IntrinsicTrait<ElementType>::subtraction };
977 template<
typename Other >
978 inline bool canAlias(
const Other* alias )
const;
980 template<
typename MT2,
bool AF2,
bool SO2 >
981 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
983 template<
typename Other >
984 inline bool isAliased(
const Other* alias )
const;
986 template<
typename MT2,
bool AF2,
bool SO2 >
987 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
998 template<
typename MT2 >
999 inline typename DisableIf< VectorizedAssign<MT2> >::Type
1000 assign(
const DenseMatrix<MT2,SO>& rhs );
1002 template<
typename MT2 >
1003 inline typename EnableIf< VectorizedAssign<MT2> >::Type
1004 assign(
const DenseMatrix<MT2,SO>& rhs );
1006 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,!SO>& rhs );
1007 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,SO>& rhs );
1008 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,!SO>& rhs );
1010 template<
typename MT2 >
1011 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
1012 addAssign(
const DenseMatrix<MT2,SO>& rhs );
1014 template<
typename MT2 >
1015 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
1016 addAssign(
const DenseMatrix<MT2,SO>& rhs );
1018 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,!SO>& rhs );
1019 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
1020 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,!SO>& rhs );
1022 template<
typename MT2 >
1023 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
1024 subAssign(
const DenseMatrix<MT2,SO>& rhs );
1026 template<
typename MT2 >
1027 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
1028 subAssign(
const DenseMatrix<MT2,SO>& rhs );
1030 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,!SO>& rhs );
1031 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
1032 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,!SO>& rhs );
1041 template<
typename MT2,
bool SO2 >
inline bool preservesSymmetry(
const Matrix<MT2,SO2>& rhs )
const;
1074 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
1076 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
1080 template<
typename MT2,
bool AF2,
bool SO2 >
1083 template<
typename MT2,
bool AF2,
bool SO2 >
1086 template<
typename MT2,
bool AF2,
bool SO2 >
1125 template<
typename MT
1129 : matrix_ ( matrix )
1131 , column_ ( column )
1135 , final_ ( n - rest_ )
1136 , isAligned_( ( column %
IT::
size == 0UL ) &&
1139 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
1140 throw std::invalid_argument(
"Invalid submatrix specification" );
1160 template<
typename MT
1169 return matrix_(row_+i,column_+j);
1181 template<
typename MT
1190 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
1204 template<
typename MT
1209 return matrix_.data() + row_*
spacing() + column_;
1223 template<
typename MT
1228 return matrix_.data() + row_*
spacing() + column_;
1244 template<
typename MT
1250 const typename MT::Iterator first( matrix_.begin( row_ + i ) + column_ );
1251 return Iterator( first, first + final_, rest_, isAligned_ );
1267 template<
typename MT
1275 return ConstIterator( first, first + final_, rest_, isAligned_ );
1291 template<
typename MT
1299 return ConstIterator( first, first + final_, rest_, isAligned_ );
1315 template<
typename MT
1321 const typename MT::Iterator last( matrix_.begin( row_ + i ) + column_ +
n_ );
1322 return Iterator( last, last, rest_, isAligned_ );
1338 template<
typename MT
1362 template<
typename MT
1391 template<
typename MT
1396 const size_t iend( row_ +
m_ );
1397 const size_t jend( column_ +
n_ );
1399 for(
size_t i=row_; i<iend; ++i )
1400 for(
size_t j=column_; j<jend; ++j )
1421 template<
typename MT
1429 if(
this == &rhs || ( &matrix_ == &rhs.
matrix_ && row_ == rhs.
row_ && column_ == rhs.
column_ ) )
1433 throw std::invalid_argument(
"Submatrix sizes do not match" );
1436 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1464 template<
typename MT
1467 template<
typename MT2
1474 throw std::invalid_argument(
"Matrix sizes do not match" );
1477 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1483 (~rhs).canAlias( &matrix_ ) ) {
1508 template<
typename MT
1511 template<
typename MT2
1518 throw std::invalid_argument(
"Matrix sizes do not match" );
1521 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1529 (~rhs).canAlias( &matrix_ ) ) {
1530 const AddType tmp( *
this + (~rhs) );
1554 template<
typename MT
1557 template<
typename MT2
1564 throw std::invalid_argument(
"Matrix sizes do not match" );
1567 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1575 (~rhs).canAlias( &matrix_ ) ) {
1576 const SubType tmp( *
this - (~rhs ) );
1600 template<
typename MT
1603 template<
typename MT2
1608 throw std::invalid_argument(
"Matrix sizes do not match" );
1615 const MultType tmp( *
this * (~rhs) );
1618 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
1636 template<
typename MT
1639 template<
typename Other >
1656 template<
typename MT
1659 template<
typename Other >
1684 template<
typename MT
1699 template<
typename MT
1719 template<
typename MT
1724 return matrix_.spacing();
1734 template<
typename MT
1755 template<
typename MT
1774 template<
typename MT
1779 const size_t iend( row_ +
m_ );
1780 const size_t jend( column_ +
n_ );
1781 size_t nonzeros( 0UL );
1783 for(
size_t i=row_; i<iend; ++i )
1784 for(
size_t j=column_; j<jend; ++j )
1804 template<
typename MT
1811 const size_t jend( column_ +
n_ );
1812 size_t nonzeros( 0UL );
1814 for(
size_t j=column_; j<jend; ++j )
1828 template<
typename MT
1835 const size_t iend( row_ +
m_ );
1836 const size_t jend( column_ +
n_ );
1838 for(
size_t i=row_; i<iend; ++i )
1839 for(
size_t j=column_; j<jend; ++j )
1840 clear( matrix_(i,j) );
1856 template<
typename MT
1865 const size_t jend( column_ +
n_ );
1866 for(
size_t j=column_; j<jend; ++j )
1867 clear( matrix_(row_+i,j) );
1882 template<
typename MT
1888 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
1903 template<
typename MT
1906 template<
typename Other >
1909 const size_t iend( row_ +
m_ );
1910 const size_t jend( column_ +
n_ );
1912 for(
size_t i=row_; i<iend; ++i )
1913 for(
size_t j=column_; j<jend; ++j )
1914 matrix_(i,j) *= scalar;
1930 template<
typename MT
1937 if( ( row_ +
m_ <= column_ ) || ( column_ +
n_ <= row_ ) )
1954 template<
typename MT
1957 template<
typename MT2
1966 const bool lower( row_ > column_ );
1967 const size_t size (
min( row_ +
m_, column_ +
n_ ) - ( lower ? row_ : column_ ) );
1972 const size_t row ( lower ? 0UL : column_ - row_ );
1973 const size_t column( lower ? row_ - column_ : 0UL );
1998 template<
typename MT
2001 template<
typename Other >
2004 return matrix_.isAliased( alias );
2019 template<
typename MT
2022 template<
typename MT2
2027 return ( matrix_.isAliased( &alias->
matrix_ ) &&
2028 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
2029 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
2044 template<
typename MT
2047 template<
typename Other >
2050 return matrix_.isAliased( alias );
2065 template<
typename MT
2068 template<
typename MT2
2073 return ( matrix_.isAliased( &alias->
matrix_ ) &&
2074 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
2075 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
2089 template<
typename MT
2109 template<
typename MT
2135 template<
typename MT
2141 return loadu( i, j );
2162 template<
typename MT
2177 return matrix_.load( row_+i, column_+j );
2179 else if( j != final_ ) {
2180 return matrix_.loadu( row_+i, column_+j );
2184 for(
size_t k=0UL; k<rest_; ++k )
2185 array[k] = matrix_(row_+i,column_+j+k);
2186 for(
size_t k=rest_; k<
IT::size; ++k )
2210 template<
typename MT
2236 template<
typename MT
2250 matrix_.store( row_+i, column_+j, value );
2252 else if( j != final_ ) {
2253 matrix_.storeu( row_+i, column_+j, value );
2258 for(
size_t k=0UL; k<rest_; ++k )
2259 matrix_(row_+i,column_+j+k) = array[k];
2282 template<
typename MT
2303 template<
typename MT
2306 template<
typename MT2 >
2313 const size_t jend(
n_ &
size_t(-2) );
2316 for(
size_t i=0UL; i<
m_; ++i ) {
2317 for(
size_t j=0UL; j<jend; j+=2UL ) {
2318 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
2319 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
2322 matrix_(row_+i,column_+jend) = (~rhs)(i,jend);
2340 template<
typename MT
2343 template<
typename MT2 >
2354 !(~rhs).isAliased( &matrix_ ) )
2356 for(
size_t i=0UL; i<
m_; ++i )
2358 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
2362 const size_t jend(
n_ &
size_t(-
IT::size*4) );
2365 for(
size_t i=0UL; i<
m_; ++i ) {
2367 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
2368 matrix_.storeu( row_+i, column_+j , it.load() ); it +=
IT::size;
2370 matrix_.storeu( row_+i, column_+j+
IT::size*2UL, it.load() ); it +=
IT::size;
2371 matrix_.storeu( row_+i, column_+j+
IT::size*3UL, it.load() ); it +=
IT::size;
2374 storeu( i, j, it.load() );
2393 template<
typename MT
2396 template<
typename MT2 >
2404 const size_t block( 16UL );
2406 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2407 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2408 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2409 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2410 for(
size_t i=ii; i<iend; ++i ) {
2411 for(
size_t j=jj; j<jend; ++j ) {
2412 matrix_(row_+i,column_+j) = (~rhs)(i,j);
2432 template<
typename MT
2435 template<
typename MT2 >
2441 for(
size_t i=0UL; i<
m_; ++i )
2443 matrix_(row_+i,column_+element->index()) = element->value();
2459 template<
typename MT
2462 template<
typename MT2 >
2470 for(
size_t j=0UL; j<
n_; ++j )
2472 matrix_(row_+element->index(),column_+j) = element->value();
2488 template<
typename MT
2491 template<
typename MT2 >
2498 const size_t jend(
n_ &
size_t(-2) );
2501 for(
size_t i=0UL; i<
m_; ++i ) {
2502 for(
size_t j=0UL; j<jend; j+=2UL ) {
2503 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
2504 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
2507 matrix_(row_+i,column_+jend) += (~rhs)(i,jend);
2525 template<
typename MT
2528 template<
typename MT2 >
2537 const size_t jend(
n_ &
size_t(-
IT::size*4) );
2540 for(
size_t i=0UL; i<
m_; ++i ) {
2542 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
2543 matrix_.storeu( row_+i, column_+j ,
load(i,j ) + it.load() ); it +=
IT::size;
2567 template<
typename MT
2570 template<
typename MT2 >
2578 const size_t block( 16UL );
2580 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2581 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2582 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2583 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2584 for(
size_t i=ii; i<iend; ++i ) {
2585 for(
size_t j=jj; j<jend; ++j ) {
2586 matrix_(row_+i,column_+j) += (~rhs)(i,j);
2606 template<
typename MT
2609 template<
typename MT2 >
2615 for(
size_t i=0UL; i<
m_; ++i )
2617 matrix_(row_+i,column_+element->index()) += element->value();
2633 template<
typename MT
2636 template<
typename MT2 >
2644 for(
size_t j=0UL; j<
n_; ++j )
2646 matrix_(row_+element->index(),column_+j) += element->value();
2662 template<
typename MT
2665 template<
typename MT2 >
2672 const size_t jend(
n_ &
size_t(-2) );
2675 for(
size_t i=0UL; i<
m_; ++i ) {
2676 for(
size_t j=0UL; j<jend; j+=2UL ) {
2677 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
2678 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
2681 matrix_(row_+i,column_+jend) -= (~rhs)(i,jend);
2699 template<
typename MT
2702 template<
typename MT2 >
2711 const size_t jend(
n_ &
size_t(-
IT::size*4) );
2714 for(
size_t i=0UL; i<
m_; ++i ) {
2716 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
2717 matrix_.storeu( row_+i, column_+j ,
load(i,j ) - it.load() ); it +=
IT::size;
2741 template<
typename MT
2744 template<
typename MT2 >
2752 const size_t block( 16UL );
2754 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2755 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2756 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2757 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2758 for(
size_t i=ii; i<iend; ++i ) {
2759 for(
size_t j=jj; j<jend; ++j ) {
2760 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
2780 template<
typename MT
2783 template<
typename MT2 >
2789 for(
size_t i=0UL; i<
m_; ++i )
2791 matrix_(row_+i,column_+element->index()) -= element->value();
2807 template<
typename MT
2810 template<
typename MT2 >
2818 for(
size_t j=0UL; j<
n_; ++j )
2820 matrix_(row_+element->index(),column_+j) -= element->value();
2845 template<
typename MT >
2871 typedef DenseSubmatrix<MT,unaligned,true>
This;
2872 typedef typename SubmatrixTrait<MT>::Type
ResultType;
2884 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
2890 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
2896 template<
typename IteratorType >
2897 class SubmatrixIterator
2902 typedef typename std::iterator_traits<IteratorType>::iterator_category
IteratorCategory;
2905 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
2908 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
2911 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
2914 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
2944 size_t remainingElements,
bool isMemoryAligned )
2946 ,
final_ ( finalIterator )
2947 ,
rest_ ( remainingElements )
2957 template<
typename IteratorType2 >
3075 AlignedArray<ElementType,IT::size> array;
3076 for(
size_t i=0UL; i<
rest_; ++i )
3078 for(
size_t i=rest_; i<
IT::size; ++i )
3170 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
3182 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
3194 return SubmatrixIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
3203 inline IteratorType
base()
const {
3213 inline IteratorType
final()
const {
3223 inline size_t rest()
const {
3250 typedef SubmatrixIterator<typename MT::ConstIterator>
ConstIterator;
3253 typedef typename SelectType< useConst, ConstIterator, SubmatrixIterator<typename MT::Iterator> >::Type
Iterator;
3258 enum { vectorizable = MT::vectorizable };
3261 enum { smpAssignable = MT::smpAssignable };
3298 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
3299 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
3300 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
3302 template<
typename Other >
3303 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
3304 operator*=( Other rhs );
3306 template<
typename Other >
3307 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
3308 operator/=( Other rhs );
3315 inline size_t rows()
const;
3316 inline size_t columns()
const;
3317 inline size_t spacing()
const;
3319 inline size_t capacity(
size_t i )
const;
3321 inline size_t nonZeros(
size_t i )
const;
3322 inline void reset();
3323 inline void reset(
size_t i );
3325 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
3332 template<
typename MT2 >
3333 struct VectorizedAssign {
3334 enum { value = vectorizable && MT2::vectorizable &&
3335 IsSame<ElementType,typename MT2::ElementType>::value };
3341 template<
typename MT2 >
3342 struct VectorizedAddAssign {
3343 enum { value = vectorizable && MT2::vectorizable &&
3344 IsSame<ElementType,typename MT2::ElementType>::value &&
3345 IntrinsicTrait<ElementType>::addition };
3351 template<
typename MT2 >
3352 struct VectorizedSubAssign {
3353 enum { value = vectorizable && MT2::vectorizable &&
3354 IsSame<ElementType,typename MT2::ElementType>::value &&
3355 IntrinsicTrait<ElementType>::subtraction };
3363 template<
typename Other >
3364 inline bool canAlias(
const Other* alias )
const;
3366 template<
typename MT2,
bool AF2,
bool SO2 >
3367 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
3369 template<
typename Other >
3370 inline bool isAliased(
const Other* alias )
const;
3372 template<
typename MT2,
bool AF2,
bool SO2 >
3373 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
3384 template<
typename MT2 >
3385 inline typename DisableIf< VectorizedAssign<MT2> >::Type
3386 assign(
const DenseMatrix<MT2,true>& rhs );
3388 template<
typename MT2 >
3389 inline typename EnableIf< VectorizedAssign<MT2> >::Type
3390 assign(
const DenseMatrix<MT2,true>& rhs );
3392 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
3393 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
3394 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
3396 template<
typename MT2 >
3397 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
3398 addAssign(
const DenseMatrix<MT2,true>& rhs );
3400 template<
typename MT2 >
3401 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
3402 addAssign(
const DenseMatrix<MT2,true>& rhs );
3404 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
3405 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
3406 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
3408 template<
typename MT2 >
3409 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
3410 subAssign(
const DenseMatrix<MT2,true>& rhs );
3412 template<
typename MT2 >
3413 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
3414 subAssign(
const DenseMatrix<MT2,true>& rhs );
3416 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
3417 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
3418 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
3427 template<
typename MT2,
bool SO2 >
inline bool preservesSymmetry(
const Matrix<MT2,SO2>& rhs )
const;
3459 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
3461 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
3462 friend const DenseSubmatrix<MT2,AF1,SO2>
3463 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
3465 template<
typename MT2,
bool AF2,
bool SO2 >
3466 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
3468 template<
typename MT2,
bool AF2,
bool SO2 >
3469 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
3471 template<
typename MT2,
bool AF2,
bool SO2 >
3472 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
3509 template<
typename MT >
3511 : matrix_ ( matrix )
3513 , column_ ( column )
3516 , rest_ ( m % IT::
size )
3517 , final_ ( m - rest_ )
3518 , isAligned_( ( row % IT::
size == 0UL ) &&
3519 ( row + m == matrix.
rows() || m % IT::
size == 0UL ) )
3521 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
3522 throw std::invalid_argument(
"Invalid submatrix specification" );
3544 template<
typename MT >
3551 return matrix_(row_+i,column_+j);
3565 template<
typename MT >
3572 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3588 template<
typename MT >
3591 return matrix_.data() + row_ + column_*
spacing();
3607 template<
typename MT >
3608 inline typename DenseSubmatrix<MT,unaligned,true>::ConstPointer
3611 return matrix_.data() + row_ + column_*
spacing();
3624 template<
typename MT >
3629 const typename MT::Iterator first( matrix_.begin( column_ + j ) + row_ );
3630 return Iterator( first, first + final_, rest_, isAligned_ );
3643 template<
typename MT >
3649 return ConstIterator( first, first + final_, rest_, isAligned_ );
3662 template<
typename MT >
3668 return ConstIterator( first, first + final_, rest_, isAligned_ );
3681 template<
typename MT >
3686 const typename MT::Iterator last( matrix_.begin( column_ + j ) + row_ +
m_ );
3687 return Iterator( last, last, rest_, isAligned_ );
3700 template<
typename MT >
3719 template<
typename MT >
3748 template<
typename MT >
3749 inline DenseSubmatrix<MT,unaligned,true>&
3752 const size_t iend( row_ +
m_ );
3753 const size_t jend( column_ +
n_ );
3755 for(
size_t j=column_; j<jend; ++j )
3756 for(
size_t i=row_; i<iend; ++i )
3779 template<
typename MT >
3780 inline DenseSubmatrix<MT,unaligned,true>&
3786 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
3789 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
3790 throw std::invalid_argument(
"Submatrix sizes do not match" );
3792 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3793 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3795 if( rhs.canAlias( &matrix_ ) ) {
3823 template<
typename MT >
3824 template<
typename MT2
3826 inline DenseSubmatrix<MT,unaligned,true>&
3832 throw std::invalid_argument(
"Matrix sizes do not match" );
3834 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3835 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3837 if( IsSparseMatrix<MT2>::value )
3840 if( ( IsSymmetric<MT>::value && RequiresEvaluation<MT2>::value ) ||
3841 (~rhs).canAlias( &matrix_ ) ) {
3868 template<
typename MT >
3869 template<
typename MT2
3871 inline DenseSubmatrix<MT,unaligned,true>&
3872 DenseSubmatrix<MT,unaligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
3877 throw std::invalid_argument(
"Matrix sizes do not match" );
3879 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3880 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3882 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
3887 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
3888 (~rhs).canAlias( &matrix_ ) ) {
3889 const AddType tmp( *
this + (~rhs) );
3915 template<
typename MT >
3916 template<
typename MT2
3918 inline DenseSubmatrix<MT,unaligned,true>&
3919 DenseSubmatrix<MT,unaligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
3924 throw std::invalid_argument(
"Matrix sizes do not match" );
3926 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
3927 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3929 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
3934 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
3935 (~rhs).canAlias( &matrix_ ) ) {
3936 const SubType tmp( *
this - (~rhs ) );
3962 template<
typename MT >
3963 template<
typename MT2
3965 inline DenseSubmatrix<MT,unaligned,true>&
3966 DenseSubmatrix<MT,unaligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
3969 throw std::invalid_argument(
"Matrix sizes do not match" );
3971 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
3976 const MultType tmp( *
this * (~rhs) );
3978 if( IsSymmetric<MT>::value && !preservesSymmetry( tmp ) )
3979 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
3981 if( IsSparseMatrix<MultType>::value )
3999 template<
typename MT >
4000 template<
typename Other >
4001 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
4002 DenseSubmatrix<MT,unaligned,true>::operator*=( Other rhs )
4019 template<
typename MT >
4020 template<
typename Other >
4021 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
4022 DenseSubmatrix<MT,unaligned,true>::operator/=( Other rhs )
4047 template<
typename MT >
4062 template<
typename MT >
4080 template<
typename MT >
4083 return matrix_.spacing();
4095 template<
typename MT >
4111 template<
typename MT >
4130 template<
typename MT >
4133 const size_t iend( row_ +
m_ );
4134 const size_t jend( column_ +
n_ );
4135 size_t nonzeros( 0UL );
4137 for(
size_t j=column_; j<jend; ++j )
4138 for(
size_t i=row_; i<iend; ++i )
4155 template<
typename MT >
4160 const size_t iend( row_ +
m_ );
4161 size_t nonzeros( 0UL );
4163 for(
size_t i=row_; i<iend; ++i )
4164 if( !
isDefault( matrix_(i,column_+j) ) )
4179 template<
typename MT >
4184 const size_t iend( row_ +
m_ );
4185 const size_t jend( column_ +
n_ );
4187 for(
size_t j=column_; j<jend; ++j )
4188 for(
size_t i=row_; i<iend; ++i )
4189 clear( matrix_(i,j) );
4202 template<
typename MT >
4209 const size_t iend( row_ +
m_ );
4210 for(
size_t i=row_; i<iend; ++i )
4211 clear( matrix_(i,column_+j) );
4228 template<
typename MT >
4232 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
4249 template<
typename MT >
4250 template<
typename Other >
4251 inline DenseSubmatrix<MT,unaligned,true>& DenseSubmatrix<MT,unaligned,true>::scale(
const Other& scalar )
4253 const size_t iend( row_ +
m_ );
4254 const size_t jend( column_ +
n_ );
4256 for(
size_t j=column_; j<jend; ++j )
4257 for(
size_t i=row_; i<iend; ++i )
4258 matrix_(i,j) *= scalar;
4276 template<
typename MT >
4281 if( ( row_ +
m_ <= column_ ) || ( column_ +
n_ <= row_ ) )
4300 template<
typename MT >
4301 template<
typename MT2
4310 const bool lower( row_ > column_ );
4311 const size_t size (
min( row_ +
m_, column_ +
n_ ) - ( lower ? row_ : column_ ) );
4316 const size_t row ( lower ? 0UL : column_ - row_ );
4317 const size_t column( lower ? row_ - column_ : 0UL );
4344 template<
typename MT >
4345 template<
typename Other >
4348 return matrix_.isAliased( alias );
4365 template<
typename MT >
4366 template<
typename MT2
4371 return ( matrix_.isAliased( &alias->matrix_ ) &&
4372 ( row_ +
m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
4373 ( column_ +
n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
4390 template<
typename MT >
4391 template<
typename Other >
4394 return matrix_.isAliased( alias );
4411 template<
typename MT >
4412 template<
typename MT2
4417 return ( matrix_.isAliased( &alias->matrix_ ) &&
4418 ( row_ +
m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
4419 ( column_ +
n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
4435 template<
typename MT >
4455 template<
typename MT >
4480 template<
typename MT >
4481 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
4484 return loadu( i, j );
4506 template<
typename MT >
4507 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
4519 return matrix_.load( row_+i, column_+j );
4521 else if( i != final_ ) {
4522 return matrix_.loadu( row_+i, column_+j );
4525 AlignedArray<ElementType,IT::size> array;
4526 for(
size_t k=0UL; k<rest_; ++k )
4527 array[k] = matrix_(row_+i+k,column_+j);
4528 for(
size_t k=rest_; k<
IT::size; ++k )
4530 return load( array.data() );
4553 template<
typename MT >
4579 template<
typename MT >
4591 matrix_.store( row_+i, column_+j, value );
4593 else if( i != final_ ) {
4594 matrix_.storeu( row_+i, column_+j, value );
4597 AlignedArray<ElementType,IT::size> array;
4598 store( array.data(), value );
4599 for(
size_t k=0UL; k<rest_; ++k )
4600 matrix_(row_+i+k,column_+j) = array[k];
4624 template<
typename MT >
4645 template<
typename MT >
4646 template<
typename MT2 >
4647 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
4653 const size_t iend(
m_ &
size_t(-2) );
4656 for(
size_t j=0UL; j<
n_; ++j ) {
4657 for(
size_t i=0UL; i<iend; i+=2UL ) {
4658 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
4659 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
4662 matrix_(row_+iend,column_+j) = (~rhs)(iend,j);
4682 template<
typename MT >
4683 template<
typename MT2 >
4684 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
4694 !(~rhs).isAliased( &matrix_ ) )
4696 for(
size_t j=0UL; j<
n_; ++j )
4698 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
4702 const size_t iend(
m_ &
size_t(-IT::size*4) );
4705 for(
size_t j=0UL; j<
n_; ++j ) {
4707 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4708 matrix_.storeu( row_+i , column_+j, it.load() ); it +=
IT::size;
4709 matrix_.storeu( row_+i+IT::size , column_+j, it.load() ); it +=
IT::size;
4710 matrix_.storeu( row_+i+IT::size*2UL, column_+j, it.load() ); it +=
IT::size;
4711 matrix_.storeu( row_+i+IT::size*3UL, column_+j, it.load() ); it +=
IT::size;
4714 storeu( i, j, it.load() );
4735 template<
typename MT >
4736 template<
typename MT2 >
4744 const size_t block( 16UL );
4746 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4747 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4748 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4749 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4750 for(
size_t j=jj; j<jend; ++j ) {
4751 for(
size_t i=ii; i<iend; ++i ) {
4752 matrix_(row_+i,column_+j) = (~rhs)(i,j);
4774 template<
typename MT >
4775 template<
typename MT2 >
4781 for(
size_t j=0UL; j<
n_; ++j )
4783 matrix_(row_+element->index(),column_+j) = element->value();
4801 template<
typename MT >
4802 template<
typename MT2 >
4810 for(
size_t i=0UL; i<
m_; ++i )
4812 matrix_(row_+i,column_+element->index()) = element->value();
4830 template<
typename MT >
4831 template<
typename MT2 >
4832 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
4838 const size_t iend( m_ &
size_t(-2) );
4841 for(
size_t j=0UL; j<
n_; ++j ) {
4842 for(
size_t i=0UL; i<iend; i+=2UL ) {
4843 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
4844 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
4847 matrix_(row_+iend,column_+j) += (~rhs)(iend,j);
4867 template<
typename MT >
4868 template<
typename MT2 >
4869 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
4877 const size_t iend( m_ &
size_t(-IT::size*4) );
4880 for(
size_t j=0UL; j<
n_; ++j ) {
4882 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4883 matrix_.storeu( row_+i , column_+j,
load(i ,j) + it.load() ); it +=
IT::size;
4884 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) + it.load() ); it +=
IT::size;
4885 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) + it.load() ); it +=
IT::size;
4886 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) + it.load() ); it +=
IT::size;
4909 template<
typename MT >
4910 template<
typename MT2 >
4918 const size_t block( 16UL );
4920 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4921 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4922 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4923 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4924 for(
size_t j=jj; j<jend; ++j ) {
4925 for(
size_t i=ii; i<iend; ++i ) {
4926 matrix_(row_+i,column_+j) += (~rhs)(i,j);
4948 template<
typename MT >
4949 template<
typename MT2 >
4955 for(
size_t j=0UL; j<
n_; ++j )
4957 matrix_(row_+element->index(),column_+j) += element->value();
4975 template<
typename MT >
4976 template<
typename MT2 >
4984 for(
size_t i=0UL; i<
m_; ++i )
4986 matrix_(row_+i,column_+element->index()) += element->value();
5004 template<
typename MT >
5005 template<
typename MT2 >
5006 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
5012 const size_t iend( m_ &
size_t(-2) );
5015 for(
size_t j=0UL; j<
n_; ++j ) {
5016 for(
size_t i=0UL; i<iend; i+=2UL ) {
5017 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
5018 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
5021 matrix_(row_+iend,column_+j) -= (~rhs)(iend,j);
5041 template<
typename MT >
5042 template<
typename MT2 >
5043 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
5051 const size_t iend( m_ &
size_t(-IT::size*4) );
5054 for(
size_t j=0UL; j<
n_; ++j ) {
5056 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
5057 matrix_.storeu( row_+i , column_+j,
load(i ,j) - it.load() ); it +=
IT::size;
5058 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) - it.load() ); it +=
IT::size;
5059 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) - it.load() ); it +=
IT::size;
5060 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) - it.load() ); it +=
IT::size;
5083 template<
typename MT >
5084 template<
typename MT2 >
5092 const size_t block( 16UL );
5094 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
5095 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
5096 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
5097 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
5098 for(
size_t j=jj; j<jend; ++j ) {
5099 for(
size_t i=ii; i<iend; ++i ) {
5100 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
5122 template<
typename MT >
5123 template<
typename MT2 >
5129 for(
size_t j=0UL; j<
n_; ++j )
5131 matrix_(row_+element->index(),column_+j) -= element->value();
5149 template<
typename MT >
5150 template<
typename MT2 >
5158 for(
size_t i=0UL; i<
m_; ++i )
5160 matrix_(row_+i,column_+element->index()) -= element->value();
5186 template<
typename MT >
5187 class DenseSubmatrix<MT,
aligned,false> :
public DenseMatrix< DenseSubmatrix<MT,aligned,false>, false >
5193 typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type
Operand;
5196 typedef IntrinsicTrait<typename MT::ElementType>
IT;
5207 enum { useConst = IsConst<MT>::value };
5212 typedef DenseSubmatrix<MT,aligned,false>
This;
5213 typedef typename SubmatrixTrait<MT>::Type
ResultType;
5225 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
5231 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
5237 typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
5242 enum { vectorizable = MT::vectorizable };
5245 enum { smpAssignable = MT::smpAssignable };
5282 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
5283 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
5284 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
5286 template<
typename Other >
5287 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
5288 operator*=( Other rhs );
5290 template<
typename Other >
5291 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
5292 operator/=( Other rhs );
5299 inline size_t rows()
const;
5300 inline size_t columns()
const;
5301 inline size_t spacing()
const;
5303 inline size_t capacity(
size_t i )
const;
5305 inline size_t nonZeros(
size_t i )
const;
5306 inline void reset();
5307 inline void reset(
size_t i );
5309 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
5316 template<
typename MT2 >
5317 struct VectorizedAssign {
5318 enum { value = vectorizable && MT2::vectorizable &&
5319 IsSame<ElementType,typename MT2::ElementType>::value };
5325 template<
typename MT2 >
5326 struct VectorizedAddAssign {
5327 enum { value = vectorizable && MT2::vectorizable &&
5328 IsSame<ElementType,typename MT2::ElementType>::value &&
5329 IntrinsicTrait<ElementType>::addition };
5335 template<
typename MT2 >
5336 struct VectorizedSubAssign {
5337 enum { value = vectorizable && MT2::vectorizable &&
5338 IsSame<ElementType,typename MT2::ElementType>::value &&
5339 IntrinsicTrait<ElementType>::subtraction };
5347 template<
typename Other >
5348 inline bool canAlias(
const Other* alias )
const;
5350 template<
typename MT2,
bool AF2,
bool SO2 >
5351 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
5353 template<
typename Other >
5354 inline bool isAliased(
const Other* alias )
const;
5356 template<
typename MT2,
bool AF2,
bool SO2 >
5357 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
5368 template<
typename MT2 >
5369 inline typename DisableIf< VectorizedAssign<MT2> >::Type
5370 assign(
const DenseMatrix<MT2,false>& rhs );
5372 template<
typename MT2 >
5373 inline typename EnableIf< VectorizedAssign<MT2> >::Type
5374 assign(
const DenseMatrix<MT2,false>& rhs );
5376 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,true>& rhs );
5377 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
5378 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
5380 template<
typename MT2 >
5381 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
5382 addAssign(
const DenseMatrix<MT2,false>& rhs );
5384 template<
typename MT2 >
5385 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
5386 addAssign(
const DenseMatrix<MT2,false>& rhs );
5388 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,true>& rhs );
5389 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
5390 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
5392 template<
typename MT2 >
5393 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
5394 subAssign(
const DenseMatrix<MT2,false>& rhs );
5396 template<
typename MT2 >
5397 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
5398 subAssign(
const DenseMatrix<MT2,false>& rhs );
5400 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,true>& rhs );
5401 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
5402 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
5411 template<
typename MT2,
bool SO2 >
inline bool preservesSymmetry(
const Matrix<MT2,SO2>& rhs )
const;
5427 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
5429 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
5430 friend const DenseSubmatrix<MT2,AF1,SO2>
5431 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
5433 template<
typename MT2,
bool AF2,
bool SO2 >
5434 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
5436 template<
typename MT2,
bool AF2,
bool SO2 >
5437 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
5439 template<
typename MT2,
bool AF2,
bool SO2 >
5440 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
5477 template<
typename MT >
5485 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
5486 throw std::invalid_argument(
"Invalid submatrix specification" );
5488 if( column % IT::size != 0UL || (
column_ + n_ !=
matrix_.columns() && n_ % IT::size != 0UL ) )
5489 throw std::invalid_argument(
"Invalid submatrix alignment" );
5511 template<
typename MT >
5518 return matrix_(row_+i,column_+j);
5532 template<
typename MT >
5539 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
5555 template<
typename MT >
5558 return matrix_.data() + row_*
spacing() + column_;
5574 template<
typename MT >
5575 inline typename DenseSubmatrix<MT,aligned,false>::ConstPointer
5578 return matrix_.data() + row_*
spacing() + column_;
5596 template<
typename MT >
5601 return ( matrix_.begin( row_ + i ) + column_ );
5619 template<
typename MT >
5624 return ( matrix_.cbegin( row_ + i ) + column_ );
5642 template<
typename MT >
5647 return ( matrix_.cbegin( row_ + i ) + column_ );
5665 template<
typename MT >
5670 return ( matrix_.begin( row_ + i ) + column_ +
n_ );
5688 template<
typename MT >
5693 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
5711 template<
typename MT >
5716 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
5739 template<
typename MT >
5740 inline DenseSubmatrix<MT,aligned,false>&
5743 const size_t iend( row_ + m_ );
5744 const size_t jend( column_ + n_ );
5746 for(
size_t i=row_; i<iend; ++i )
5747 for(
size_t j=column_; j<jend; ++j )
5770 template<
typename MT >
5771 inline DenseSubmatrix<MT,aligned,false>&
5777 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
5780 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
5781 throw std::invalid_argument(
"Submatrix sizes do not match" );
5783 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
5784 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
5786 if( rhs.canAlias( &matrix_ ) ) {
5814 template<
typename MT >
5815 template<
typename MT2
5817 inline DenseSubmatrix<MT,aligned,false>&
5823 throw std::invalid_argument(
"Matrix sizes do not match" );
5825 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
5826 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
5828 if( IsSparseMatrix<MT2>::value )
5831 if( ( IsSymmetric<MT>::value && RequiresEvaluation<MT2>::value ) ||
5832 (~rhs).canAlias( &matrix_ ) ) {
5859 template<
typename MT >
5860 template<
typename MT2
5862 inline DenseSubmatrix<MT,aligned,false>&
5863 DenseSubmatrix<MT,aligned,false>::operator+=(
const Matrix<MT2,SO>& rhs )
5868 throw std::invalid_argument(
"Matrix sizes do not match" );
5870 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
5871 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
5873 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
5878 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
5879 (~rhs).canAlias( &matrix_ ) ) {
5880 const AddType tmp( *
this + (~rhs) );
5906 template<
typename MT >
5907 template<
typename MT2
5909 inline DenseSubmatrix<MT,aligned,false>&
5910 DenseSubmatrix<MT,aligned,false>::operator-=(
const Matrix<MT2,SO>& rhs )
5915 throw std::invalid_argument(
"Matrix sizes do not match" );
5917 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
5918 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
5920 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
5925 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
5926 (~rhs).canAlias( &matrix_ ) ) {
5927 const SubType tmp( *
this - (~rhs ) );
5953 template<
typename MT >
5954 template<
typename MT2
5956 inline DenseSubmatrix<MT,aligned,false>&
5957 DenseSubmatrix<MT,aligned,false>::operator*=(
const Matrix<MT2,SO>& rhs )
5960 throw std::invalid_argument(
"Matrix sizes do not match" );
5962 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
5967 const MultType tmp( *
this * (~rhs) );
5969 if( IsSymmetric<MT>::value && !preservesSymmetry( tmp ) )
5970 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
5972 if( IsSparseMatrix<MultType>::value )
5990 template<
typename MT >
5991 template<
typename Other >
5992 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
5993 DenseSubmatrix<MT,aligned,false>::operator*=( Other rhs )
6010 template<
typename MT >
6011 template<
typename Other >
6012 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
6013 DenseSubmatrix<MT,aligned,false>::operator/=( Other rhs )
6038 template<
typename MT >
6053 template<
typename MT >
6073 template<
typename MT >
6076 return matrix_.spacing();
6088 template<
typename MT >
6109 template<
typename MT >
6128 template<
typename MT >
6131 const size_t iend( row_ + m_ );
6132 const size_t jend( column_ + n_ );
6133 size_t nonzeros( 0UL );
6135 for(
size_t i=row_; i<iend; ++i )
6136 for(
size_t j=column_; j<jend; ++j )
6158 template<
typename MT >
6163 const size_t jend( column_ + n_ );
6164 size_t nonzeros( 0UL );
6166 for(
size_t j=column_; j<jend; ++j )
6182 template<
typename MT >
6187 const size_t iend( row_ + m_ );
6188 const size_t jend( column_ + n_ );
6190 for(
size_t i=row_; i<iend; ++i )
6191 for(
size_t j=column_; j<jend; ++j )
6192 clear( matrix_(i,j) );
6210 template<
typename MT >
6217 const size_t jend( column_ + n_ );
6218 for(
size_t j=column_; j<jend; ++j )
6219 clear( matrix_(row_+i,j) );
6236 template<
typename MT >
6240 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
6257 template<
typename MT >
6258 template<
typename Other >
6259 inline DenseSubmatrix<MT,aligned,false>& DenseSubmatrix<MT,aligned,false>::scale(
const Other& scalar )
6261 const size_t iend( row_ + m_ );
6262 const size_t jend( column_ + n_ );
6264 for(
size_t i=row_; i<iend; ++i )
6265 for(
size_t j=column_; j<jend; ++j )
6266 matrix_(i,j) *= scalar;
6284 template<
typename MT >
6289 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
6308 template<
typename MT >
6309 template<
typename MT2
6318 const bool lower( row_ > column_ );
6319 const size_t size (
min( row_ + m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
6324 const size_t row ( lower ? 0UL : column_ - row_ );
6325 const size_t column( lower ? row_ - column_ : 0UL );
6352 template<
typename MT >
6353 template<
typename Other >
6356 return matrix_.isAliased( alias );
6373 template<
typename MT >
6374 template<
typename MT2
6379 return ( matrix_.isAliased( &alias->matrix_ ) &&
6380 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
6381 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
6398 template<
typename MT >
6399 template<
typename Other >
6402 return matrix_.isAliased( alias );
6419 template<
typename MT >
6420 template<
typename MT2
6425 return ( matrix_.isAliased( &alias->matrix_ ) &&
6426 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
6427 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
6443 template<
typename MT >
6463 template<
typename MT >
6489 template<
typename MT >
6490 inline typename DenseSubmatrix<MT,aligned,false>::IntrinsicType
6499 return matrix_.load( row_+i, column_+j );
6522 template<
typename MT >
6523 inline typename DenseSubmatrix<MT,aligned,false>::IntrinsicType
6532 return matrix_.loadu( row_+i, column_+j );
6555 template<
typename MT >
6564 return matrix_.store( row_+i, column_+j, value );
6587 template<
typename MT >
6596 matrix_.storeu( row_+i, column_+j, value );
6620 template<
typename MT >
6629 matrix_.stream( row_+i, column_+j, value );
6647 template<
typename MT >
6648 template<
typename MT2 >
6649 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6655 const size_t jend( n_ &
size_t(-2) );
6658 for(
size_t i=0UL; i<
m_; ++i ) {
6659 for(
size_t j=0UL; j<jend; j+=2UL ) {
6660 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
6661 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
6664 matrix_(row_+i,column_+jend) = (~rhs)(i,jend);
6684 template<
typename MT >
6685 template<
typename MT2 >
6686 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6696 !(~rhs).isAliased( &matrix_ ) )
6698 for(
size_t i=0UL; i<
m_; ++i )
6704 const size_t jend( n_ &
size_t(-IT::size*4) );
6707 for(
size_t i=0UL; i<
m_; ++i ) {
6709 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
6716 store( i, j, it.load() );
6737 template<
typename MT >
6738 template<
typename MT2 >
6746 const size_t block( 16UL );
6748 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6749 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6750 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6751 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6752 for(
size_t i=ii; i<iend; ++i ) {
6753 for(
size_t j=jj; j<jend; ++j ) {
6754 matrix_(row_+i,column_+j) = (~rhs)(i,j);
6776 template<
typename MT >
6777 template<
typename MT2 >
6783 for(
size_t i=0UL; i<
m_; ++i )
6785 matrix_(row_+i,column_+element->index()) = element->value();
6803 template<
typename MT >
6804 template<
typename MT2 >
6812 for(
size_t j=0UL; j<
n_; ++j )
6814 matrix_(row_+element->index(),column_+j) = element->value();
6832 template<
typename MT >
6833 template<
typename MT2 >
6834 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6840 const size_t jend( n_ &
size_t(-2) );
6843 for(
size_t i=0UL; i<
m_; ++i ) {
6844 for(
size_t j=0UL; j<jend; j+=2UL ) {
6845 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
6846 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
6849 matrix_(row_+i,column_+jend) += (~rhs)(i,jend);
6869 template<
typename MT >
6870 template<
typename MT2 >
6871 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6879 const size_t jend( n_ &
size_t(-IT::size*4) );
6882 for(
size_t i=0UL; i<
m_; ++i ) {
6884 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
6911 template<
typename MT >
6912 template<
typename MT2 >
6920 const size_t block( 16UL );
6922 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6923 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6924 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6925 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6926 for(
size_t i=ii; i<iend; ++i ) {
6927 for(
size_t j=jj; j<jend; ++j ) {
6928 matrix_(row_+i,column_+j) += (~rhs)(i,j);
6950 template<
typename MT >
6951 template<
typename MT2 >
6957 for(
size_t i=0UL; i<
m_; ++i )
6959 matrix_(row_+i,column_+element->index()) += element->value();
6977 template<
typename MT >
6978 template<
typename MT2 >
6986 for(
size_t j=0UL; j<
n_; ++j )
6988 matrix_(row_+element->index(),column_+j) += element->value();
7006 template<
typename MT >
7007 template<
typename MT2 >
7008 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
7014 const size_t jend( n_ &
size_t(-2) );
7017 for(
size_t i=0UL; i<
m_; ++i ) {
7018 for(
size_t j=0UL; j<jend; j+=2UL ) {
7019 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
7020 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
7023 matrix_(row_+i,column_+jend) -= (~rhs)(i,jend);
7043 template<
typename MT >
7044 template<
typename MT2 >
7045 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
7053 const size_t jend( n_ &
size_t(-IT::size*4) );
7056 for(
size_t i=0UL; i<
m_; ++i ) {
7058 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
7085 template<
typename MT >
7086 template<
typename MT2 >
7094 const size_t block( 16UL );
7096 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
7097 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
7098 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
7099 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
7100 for(
size_t i=ii; i<iend; ++i ) {
7101 for(
size_t j=jj; j<jend; ++j ) {
7102 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
7124 template<
typename MT >
7125 template<
typename MT2 >
7131 for(
size_t i=0UL; i<
m_; ++i )
7133 matrix_(row_+i,column_+element->index()) -= element->value();
7151 template<
typename MT >
7152 template<
typename MT2 >
7160 for(
size_t j=0UL; j<
n_; ++j )
7162 matrix_(row_+element->index(),column_+j) -= element->value();
7188 template<
typename MT >
7189 class DenseSubmatrix<MT,
aligned,true> :
public DenseMatrix< DenseSubmatrix<MT,aligned,true>, true >
7195 typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type
Operand;
7198 typedef IntrinsicTrait<typename MT::ElementType>
IT;
7209 enum { useConst = IsConst<MT>::value };
7214 typedef DenseSubmatrix<MT,aligned,true>
This;
7215 typedef typename SubmatrixTrait<MT>::Type
ResultType;
7227 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
7233 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
7239 typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
7244 enum { vectorizable = MT::vectorizable };
7247 enum { smpAssignable = MT::smpAssignable };
7284 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
7285 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
7286 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
7288 template<
typename Other >
7289 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
7290 operator*=( Other rhs );
7292 template<
typename Other >
7293 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
7294 operator/=( Other rhs );
7301 inline size_t rows()
const;
7302 inline size_t columns()
const;
7303 inline size_t spacing()
const;
7305 inline size_t capacity(
size_t i )
const;
7307 inline size_t nonZeros(
size_t i )
const;
7308 inline void reset();
7309 inline void reset(
size_t i );
7311 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
7318 template<
typename MT2 >
7319 struct VectorizedAssign {
7320 enum { value = vectorizable && MT2::vectorizable &&
7321 IsSame<ElementType,typename MT2::ElementType>::value };
7327 template<
typename MT2 >
7328 struct VectorizedAddAssign {
7329 enum { value = vectorizable && MT2::vectorizable &&
7330 IsSame<ElementType,typename MT2::ElementType>::value &&
7331 IntrinsicTrait<ElementType>::addition };
7337 template<
typename MT2 >
7338 struct VectorizedSubAssign {
7339 enum { value = vectorizable && MT2::vectorizable &&
7340 IsSame<ElementType,typename MT2::ElementType>::value &&
7341 IntrinsicTrait<ElementType>::subtraction };
7349 template<
typename Other >
7350 inline bool canAlias(
const Other* alias )
const;
7352 template<
typename MT2,
bool AF2,
bool SO2 >
7353 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
7355 template<
typename Other >
7356 inline bool isAliased(
const Other* alias )
const;
7358 template<
typename MT2,
bool AF2,
bool SO2 >
7359 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
7370 template<
typename MT2 >
7371 inline typename DisableIf< VectorizedAssign<MT2> >::Type
7372 assign(
const DenseMatrix<MT2,true>& rhs );
7374 template<
typename MT2 >
7375 inline typename EnableIf< VectorizedAssign<MT2> >::Type
7376 assign(
const DenseMatrix<MT2,true>& rhs );
7378 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
7379 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
7380 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
7382 template<
typename MT2 >
7383 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
7384 addAssign(
const DenseMatrix<MT2,true>& rhs );
7386 template<
typename MT2 >
7387 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
7388 addAssign(
const DenseMatrix<MT2,true>& rhs );
7390 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
7391 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
7392 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
7394 template<
typename MT2 >
7395 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
7396 subAssign(
const DenseMatrix<MT2,true>& rhs );
7398 template<
typename MT2 >
7399 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
7400 subAssign(
const DenseMatrix<MT2,true>& rhs );
7402 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
7403 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
7404 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
7413 template<
typename MT2,
bool SO2 >
inline bool preservesSymmetry(
const Matrix<MT2,SO2>& rhs )
const;
7429 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
7431 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
7432 friend const DenseSubmatrix<MT2,AF1,SO2>
7433 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
7435 template<
typename MT2,
bool AF2,
bool SO2 >
7436 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
7438 template<
typename MT2,
bool AF2,
bool SO2 >
7439 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
7441 template<
typename MT2,
bool AF2,
bool SO2 >
7442 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
7479 template<
typename MT >
7487 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
7488 throw std::invalid_argument(
"Invalid submatrix specification" );
7490 if( row % IT::size != 0UL || (
row_ + m_ !=
matrix_.rows() && m_ % IT::size != 0UL ) )
7491 throw std::invalid_argument(
"Invalid submatrix alignment" );
7513 template<
typename MT >
7520 return matrix_(row_+i,column_+j);
7534 template<
typename MT >
7541 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
7557 template<
typename MT >
7560 return matrix_.data() + row_ + column_*
spacing();
7576 template<
typename MT >
7577 inline typename DenseSubmatrix<MT,aligned,true>::ConstPointer
7580 return matrix_.data() + row_ + column_*
spacing();
7593 template<
typename MT >
7598 return ( matrix_.begin( column_ + j ) + row_ );
7611 template<
typename MT >
7616 return ( matrix_.cbegin( column_ + j ) + row_ );
7629 template<
typename MT >
7634 return ( matrix_.cbegin( column_ + j ) + row_ );
7647 template<
typename MT >
7652 return ( matrix_.begin( column_ + j ) + row_ +
m_ );
7665 template<
typename MT >
7670 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
7683 template<
typename MT >
7688 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
7711 template<
typename MT >
7712 inline DenseSubmatrix<MT,aligned,true>&
7715 const size_t iend( row_ + m_ );
7716 const size_t jend( column_ + n_ );
7718 for(
size_t j=column_; j<jend; ++j )
7719 for(
size_t i=row_; i<iend; ++i )
7742 template<
typename MT >
7743 inline DenseSubmatrix<MT,aligned,true>&
7749 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
7752 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
7753 throw std::invalid_argument(
"Submatrix sizes do not match" );
7755 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
7756 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
7758 if( rhs.canAlias( &matrix_ ) ) {
7786 template<
typename MT >
7787 template<
typename MT2
7789 inline DenseSubmatrix<MT,aligned,true>&
7795 throw std::invalid_argument(
"Matrix sizes do not match" );
7797 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
7798 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
7800 if( IsSparseMatrix<MT2>::value )
7803 if( ( IsSymmetric<MT>::value && RequiresEvaluation<MT2>::value ) ||
7804 (~rhs).canAlias( &matrix_ ) ) {
7831 template<
typename MT >
7832 template<
typename MT2
7834 inline DenseSubmatrix<MT,aligned,true>&
7835 DenseSubmatrix<MT,aligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
7840 throw std::invalid_argument(
"Matrix sizes do not match" );
7842 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
7843 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
7845 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
7850 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
7851 (~rhs).canAlias( &matrix_ ) ) {
7852 const AddType tmp( *
this + (~rhs) );
7878 template<
typename MT >
7879 template<
typename MT2
7881 inline DenseSubmatrix<MT,aligned,true>&
7882 DenseSubmatrix<MT,aligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
7887 throw std::invalid_argument(
"Matrix sizes do not match" );
7889 if( IsSymmetric<MT>::value && !preservesSymmetry( ~rhs ) )
7890 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
7892 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
7897 if( ( IsSymmetric<MT>::value && ( RequiresEvaluation<MT2>::value || hasOverlap() ) ) ||
7898 (~rhs).canAlias( &matrix_ ) ) {
7899 const SubType tmp( *
this - (~rhs ) );
7925 template<
typename MT >
7926 template<
typename MT2
7928 inline DenseSubmatrix<MT,aligned,true>&
7929 DenseSubmatrix<MT,aligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
7932 throw std::invalid_argument(
"Matrix sizes do not match" );
7934 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
7939 const MultType tmp( *
this * (~rhs) );
7941 if( IsSymmetric<MT>::value && !preservesSymmetry( tmp ) )
7942 throw std::invalid_argument(
"Invalid assignment to symmetric matrix" );
7944 if( IsSparseMatrix<MultType>::value )
7962 template<
typename MT >
7963 template<
typename Other >
7964 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
7965 DenseSubmatrix<MT,aligned,true>::operator*=( Other rhs )
7982 template<
typename MT >
7983 template<
typename Other >
7984 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
7985 DenseSubmatrix<MT,aligned,true>::operator/=( Other rhs )
8010 template<
typename MT >
8025 template<
typename MT >
8043 template<
typename MT >
8046 return matrix_.spacing();
8058 template<
typename MT >
8074 template<
typename MT >
8093 template<
typename MT >
8096 const size_t iend( row_ + m_ );
8097 const size_t jend( column_ + n_ );
8098 size_t nonzeros( 0UL );
8100 for(
size_t j=column_; j<jend; ++j )
8101 for(
size_t i=row_; i<iend; ++i )
8118 template<
typename MT >
8123 const size_t iend( row_ + m_ );
8124 size_t nonzeros( 0UL );
8126 for(
size_t i=row_; i<iend; ++i )
8127 if( !
isDefault( matrix_(i,column_+j) ) )
8142 template<
typename MT >
8147 const size_t iend( row_ + m_ );
8148 const size_t jend( column_ + n_ );
8150 for(
size_t j=column_; j<jend; ++j )
8151 for(
size_t i=row_; i<iend; ++i )
8152 clear( matrix_(i,j) );
8165 template<
typename MT >
8172 const size_t iend( row_ + m_ );
8173 for(
size_t i=row_; i<iend; ++i )
8174 clear( matrix_(i,column_+j) );
8191 template<
typename MT >
8195 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
8212 template<
typename MT >
8213 template<
typename Other >
8214 inline DenseSubmatrix<MT,aligned,true>& DenseSubmatrix<MT,aligned,true>::scale(
const Other& scalar )
8216 const size_t iend( row_ + m_ );
8217 const size_t jend( column_ + n_ );
8219 for(
size_t j=column_; j<jend; ++j )
8220 for(
size_t i=row_; i<iend; ++i )
8221 matrix_(i,j) *= scalar;
8239 template<
typename MT >
8244 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
8263 template<
typename MT >
8264 template<
typename MT2
8273 const bool lower( row_ > column_ );
8274 const size_t size (
min( row_ + m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
8279 const size_t row ( lower ? 0UL : column_ - row_ );
8280 const size_t column( lower ? row_ - column_ : 0UL );
8307 template<
typename MT >
8308 template<
typename Other >
8311 return matrix_.isAliased( alias );
8328 template<
typename MT >
8329 template<
typename MT2
8334 return ( matrix_.isAliased( &alias->matrix_ ) &&
8335 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
8336 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
8353 template<
typename MT >
8354 template<
typename Other >
8357 return matrix_.isAliased( alias );
8374 template<
typename MT >
8375 template<
typename MT2
8380 return ( matrix_.isAliased( &alias->matrix_ ) &&
8381 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
8382 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
8398 template<
typename MT >
8418 template<
typename MT >
8443 template<
typename MT >
8444 inline typename DenseSubmatrix<MT,aligned,true>::IntrinsicType
8453 return matrix_.load( row_+i, column_+j );
8475 template<
typename MT >
8476 inline typename DenseSubmatrix<MT,aligned,true>::IntrinsicType
8485 return matrix_.loadu( row_+i, column_+j );
8507 template<
typename MT >
8516 matrix_.store( row_+i, column_+j, value );
8539 template<
typename MT >
8548 matrix_.storeu( row_+i, column_+j, value );
8571 template<
typename MT >
8580 matrix_.stream( row_+i, column_+j, value );
8598 template<
typename MT >
8599 template<
typename MT2 >
8600 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
8606 const size_t iend( m_ &
size_t(-2) );
8609 for(
size_t j=0UL; j<
n_; ++j ) {
8610 for(
size_t i=0UL; i<iend; i+=2UL ) {
8611 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
8612 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
8615 matrix_(row_+iend,column_+j) = (~rhs)(iend,j);
8635 template<
typename MT >
8636 template<
typename MT2 >
8637 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
8647 !(~rhs).isAliased( &matrix_ ) )
8649 for(
size_t j=0UL; j<
n_; ++j )
8655 const size_t iend( m_ &
size_t(-IT::size*4) );
8658 for(
size_t j=0UL; j<
n_; ++j ) {
8660 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
8667 store( i, j, it.load() );
8688 template<
typename MT >
8689 template<
typename MT2 >
8697 const size_t block( 16UL );
8699 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8700 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8701 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8702 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8703 for(
size_t j=jj; j<jend; ++j ) {
8704 for(
size_t i=ii; i<iend; ++i ) {
8705 matrix_(row_+i,column_+j) = (~rhs)(i,j);
8727 template<
typename MT >
8728 template<
typename MT2 >
8734 for(
size_t j=0UL; j<
n_; ++j )
8736 matrix_(row_+element->index(),column_+j) = element->value();
8754 template<
typename MT >
8755 template<
typename MT2 >
8763 for(
size_t i=0UL; i<
m_; ++i )
8765 matrix_(row_+i,column_+element->index()) = element->value();
8783 template<
typename MT >
8784 template<
typename MT2 >
8785 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
8791 const size_t iend( m_ &
size_t(-2) );
8794 for(
size_t j=0UL; j<
n_; ++j ) {
8795 for(
size_t i=0UL; i<iend; i+=2UL ) {
8796 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
8797 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
8800 matrix_(row_+iend,column_+j) += (~rhs)(iend,j);
8820 template<
typename MT >
8821 template<
typename MT2 >
8822 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
8830 const size_t iend( m_ &
size_t(-IT::size*4) );
8833 for(
size_t j=0UL; j<
n_; ++j ) {
8835 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
8862 template<
typename MT >
8863 template<
typename MT2 >
8871 const size_t block( 16UL );
8873 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8874 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8875 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8876 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8877 for(
size_t j=jj; j<jend; ++j ) {
8878 for(
size_t i=ii; i<iend; ++i ) {
8879 matrix_(row_+i,column_+j) += (~rhs)(i,j);
8901 template<
typename MT >
8902 template<
typename MT2 >
8908 for(
size_t j=0UL; j<
n_; ++j )
8910 matrix_(row_+element->index(),column_+j) += element->value();
8928 template<
typename MT >
8929 template<
typename MT2 >
8937 for(
size_t i=0UL; i<
m_; ++i )
8939 matrix_(row_+i,column_+element->index()) += element->value();
8957 template<
typename MT >
8958 template<
typename MT2 >
8959 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
8965 const size_t iend( m_ &
size_t(-2) );
8968 for(
size_t j=0UL; j<
n_; ++j ) {
8969 for(
size_t i=0UL; i<iend; i+=2UL ) {
8970 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
8971 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
8974 matrix_(row_+iend,column_+j) -= (~rhs)(iend,j);
8994 template<
typename MT >
8995 template<
typename MT2 >
8996 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
9004 const size_t iend( m_ &
size_t(-IT::size*4) );
9007 for(
size_t j=0UL; j<
n_; ++j ) {
9009 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
9036 template<
typename MT >
9037 template<
typename MT2 >
9045 const size_t block( 16UL );
9047 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
9048 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
9049 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
9050 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
9051 for(
size_t j=jj; j<jend; ++j ) {
9052 for(
size_t i=ii; i<iend; ++i ) {
9053 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
9075 template<
typename MT >
9076 template<
typename MT2 >
9082 for(
size_t j=0UL; j<
n_; ++j )
9084 matrix_(row_+element->index(),column_+j) -= element->value();
9102 template<
typename MT >
9103 template<
typename MT2 >
9111 for(
size_t i=0UL; i<
m_; ++i )
9113 matrix_(row_+i,column_+element->index()) -= element->value();
9134 template<
typename MT,
bool AF,
bool SO >
9135 inline void reset( DenseSubmatrix<MT,AF,SO>& dm );
9137 template<
typename MT,
bool AF,
bool SO >
9138 inline void reset( DenseSubmatrix<MT,AF,SO>& dm,
size_t i );
9140 template<
typename MT,
bool AF,
bool SO >
9141 inline void clear( DenseSubmatrix<MT,AF,SO>& dm );
9143 template<
typename MT,
bool AF,
bool SO >
9144 inline bool isDefault(
const DenseSubmatrix<MT,AF,SO>& dm );
9146 template<
typename MT,
bool AF,
bool SO >
9147 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseMatrix<MT,SO>& b );
9149 template<
typename MT,
bool AF,
bool SO >
9150 inline bool isSame(
const DenseMatrix<MT,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
9152 template<
typename MT,
bool AF,
bool SO >
9153 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
9165 template<
typename MT
9188 template<
typename MT
9207 template<
typename MT
9235 template<
typename MT
9243 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
9244 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
9249 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
9250 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
9272 template<
typename MT,
bool AF,
bool SO >
9275 return (
isSame( a.matrix_, ~b ) && ( a.rows() == (~b).
rows() ) && ( a.columns() == (~b).
columns() ) );
9292 template<
typename MT,
bool AF,
bool SO >
9295 return (
isSame( ~a, b.matrix_ ) && ( (~a).rows() == b.rows() ) && ( (~a).columns() == b.columns() ) );
9312 template<
typename MT,
bool AF,
bool SO >
9315 return (
isSame( a.matrix_, b.matrix_ ) &&
9316 ( a.row_ == b.row_ ) && ( a.column_ == b.column_ ) &&
9317 ( a.m_ == b.m_ ) && ( a.n_ == b.n_ ) );
9349 inline const DenseSubmatrix<MT,AF1,SO>
9350 submatrix(
const DenseSubmatrix<MT,AF2,SO>& dm,
size_t row,
size_t column,
size_t m,
size_t n )
9354 if( ( row + m > dm.rows() ) || ( column + n > dm.columns() ) )
9355 throw std::invalid_argument(
"Invalid submatrix specification" );
9357 return DenseSubmatrix<MT,AF1,SO>( dm.matrix_, dm.row_ +
row, dm.column_ +
column, m, n );
9373 template<
typename MT,
bool AF,
bool SO >
9374 struct SubmatrixTrait< DenseSubmatrix<MT,AF,SO> >
9392 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
9393 struct SubmatrixExprTrait< DenseSubmatrix<MT,AF1,SO>, AF2 >
9395 typedef DenseSubmatrix<MT,AF2,SO> Type;
9403 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
9404 struct SubmatrixExprTrait< const DenseSubmatrix<MT,AF1,SO>, AF2 >
9406 typedef DenseSubmatrix<MT,AF2,SO> Type;
9414 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
9415 struct SubmatrixExprTrait< volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
9417 typedef DenseSubmatrix<MT,AF2,SO> Type;
9425 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
9426 struct SubmatrixExprTrait< const volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
9428 typedef DenseSubmatrix<MT,AF2,SO> Type;
9444 template<
typename MT,
bool AF,
bool SO >
9445 struct RowTrait< DenseSubmatrix<MT,AF,SO> >
9463 template<
typename MT,
bool AF,
bool SO >
9464 struct ColumnTrait< DenseSubmatrix<MT,AF,SO> >
Constraint on the data type.
SelectType< useConst, ConstIterator, SubmatrixIterator< typename MT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubmatrix.h:861
void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:2285
Constraint on the data type.
DenseSubmatrix & transpose()
Transposing the submatrix.
Definition: DenseSubmatrix.h:1885
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubmatrix.h:525
ReferenceType reference
Reference return type.
Definition: DenseSubmatrix.h:528
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:1050
Header file for mathematical functions.
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubmatrix.h:1053
bool canAlias(const Other *alias) const
Returns whether the submatrix can alias with the given address alias.
Definition: DenseSubmatrix.h:2002
size_t rest() const
Access to the number of remaining elements beyond the final iterator.
Definition: DenseSubmatrix.h:831
#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 subvector/submatrix alignment flag values.
Header file for the UNUSED_PARAMETER function template.
SelectType< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant submatrix value.
Definition: DenseSubmatrix.h:498
Header file for the subtraction trait.
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubmatrix.h:522
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubmatrix.h:529
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Header file for the row trait.
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
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:118
Header file for the IsSparseMatrix type trait.
SubmatrixIterator(IteratorType iterator, IteratorType finalIterator, size_t remainingElements, bool isMemoryAligned)
Constructor of the SubmatrixIterator class.
Definition: DenseSubmatrix.h:551
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
#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:118
#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
Reference operator()(size_t i, size_t j)
2D-access to the dense submatrix elements.
Definition: DenseSubmatrix.h:1164
bool operator<=(const SubmatrixIterator &rhs) const
Less-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:743
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
Header file for the IsSame and IsStrictlySame type traits.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:731
bool hasOverlap() const
Checking whether there exists an overlap in the context of a symmetric matrix.
Definition: DenseSubmatrix.h:1933
DenseSubmatrix(Operand matrix, size_t row, size_t column, size_t m, size_t n)
The constructor for DenseSubmatrix.
Definition: DenseSubmatrix.h:1128
bool isAligned() const
Returns whether the submatrix is properly aligned in memory.
Definition: DenseSubmatrix.h:2092
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: DenseSubmatrix.h:1318
bool isAliased(const Other *alias) const
Returns whether the submatrix is aliased with the given address alias.
Definition: DenseSubmatrix.h:2048
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
Header file for the IsColumnMajorMatrix type trait.
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DenseSubmatrix.h:1366
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2636
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubmatrix.h:645
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
const size_t n_
The number of columns of the submatrix.
Definition: DenseSubmatrix.h:1052
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:1049
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBMATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a submatrix type (i.e. a dense or sparse submatrix), a compilation error is created.
Definition: Submatrix.h:118
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:255
const ElementType * ConstPointer
Pointer to a constant submatrix value.
Definition: DenseSubmatrix.h:495
SubmatrixIterator(const SubmatrixIterator< IteratorType2 > &it)
Conversion constructor from different SubmatrixIterator instances.
Definition: DenseSubmatrix.h:566
void reset()
Reset to the default initial values.
Definition: DenseSubmatrix.h:1831
MT::ElementType ElementType
Type of the submatrix elements.
Definition: DenseSubmatrix.h:483
size_t columns() const
Returns the number of columns of the dense submatrix.
Definition: DenseSubmatrix.h:1702
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
Header file for the RequiresEvaluation type trait.
bool isAligned() const
Access to the iterator's memory alignment flag.
Definition: DenseSubmatrix.h:841
Pointer data()
Low-level data access to the submatrix elements.
Definition: DenseSubmatrix.h:1207
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1295
size_t rows() const
Returns the number of rows of the dense submatrix.
Definition: DenseSubmatrix.h:1687
SubmatrixIterator()
Default constructor of the SubmatrixIterator class.
Definition: DenseSubmatrix.h:535
Base class for all submatrices.The Submatrix class serves as a tag for all submatrices (i...
Definition: Submatrix.h:64
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
bool preservesSymmetry(const Matrix< MT2, SO2 > &rhs) const
Checking whether the given matrix would violate the symmetry of the underlying matrix.
Definition: DenseSubmatrix.h:1959
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
friend const SubmatrixIterator operator+(size_t inc, const SubmatrixIterator &it)
Addition between an integral value and a SubmatrixIterator.
Definition: DenseSubmatrix.h:789
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseSubmatrix.h:460
DenseSubmatrix & operator=(const ElementType &rhs)
Homogenous assignment to all submatrix elements.
Definition: DenseSubmatrix.h:1394
const bool aligned
Alignment flag for aligned subvectors and submatrices.
Definition: AlignmentFlag.h:83
SubmatrixTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseSubmatrix.h:480
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1247
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
ValueType value_type
Type of the underlying elements.
Definition: DenseSubmatrix.h:526
Pointer data()
Low-level data access to the array elements.
Definition: AlignedArray.h:441
bool operator<(const SubmatrixIterator &rhs) const
Less-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:721
std::iterator_traits< IteratorType >::reference ReferenceType
Reference return type.
Definition: DenseSubmatrix.h:519
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:2166
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant submatrix value.
Definition: DenseSubmatrix.h:492
Compile time type selection.The SelectType class template selects one of the two given types T1 and T...
Definition: SelectType.h:59
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.
Header file for nested template disabiguation.
Header file for the If class template.
IntrinsicType load() const
Aligned load of an intrinsic element of the dense submatrix.
Definition: DenseSubmatrix.h:660
Header file for the IsFloatingPoint type trait.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
SubmatrixIterator< typename MT::ConstIterator > ConstIterator
Iterator over constant elements.
Definition: DenseSubmatrix.h:858
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
SubmatrixIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubmatrix.h:580
Header file for the Or class template.
bool operator==(const SubmatrixIterator &rhs) const
Equality comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:699
Constraint on the data type.
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
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
const DenseSubmatrix & CompositeType
Data type for composite expression templates.
Definition: DenseSubmatrix.h:486
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a simple dense...
Definition: Thresholds.h:690
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the matrix element type.
Definition: DenseSubmatrix.h:463
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:2139
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_VECTORIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a vectorizable data type...
Definition: Vectorizable.h:79
bool operator!=(const SubmatrixIterator &rhs) const
Inequality comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:710
Constraints on the storage order of matrix types.
const SubmatrixIterator operator++(int)
Post-increment operator.
Definition: DenseSubmatrix.h:614
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
SubmatrixIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubmatrix.h:592
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
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubmatrix.h:482
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubmatrix.h:1054
Constraint on the data type.
Header file for the SelectType class template.
std::iterator_traits< IteratorType >::value_type ValueType
Type of the underlying elements.
Definition: DenseSubmatrix.h:513
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:1048
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
IteratorType iterator_
Iterator to the current submatrix element.
Definition: DenseSubmatrix.h:848
Header file for the IsNumeric type trait.
DenseSubmatrix< MT, AF, SO > This
Type of this DenseSubmatrix instance.
Definition: DenseSubmatrix.h:479
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
bool isAligned_
Memory alignment flag.
Definition: DenseSubmatrix.h:851
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
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
#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
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
Header file for the IsConst type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense submatrix.
Definition: DenseSubmatrix.h:675
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:142
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
DifferenceType operator-(const SubmatrixIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubmatrix.h:765
Base template for the MultTrait class.
Definition: MultTrait.h:142
Header file for the addition trait.
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
Header file for the division trait.
SubmatrixIterator & operator++()
Pre-increment operator.
Definition: DenseSubmatrix.h:603
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubmatrix.h:485
Header file for the submatrix trait.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Iterator over the elements of the sparse submatrix.
Definition: DenseSubmatrix.h:505
const bool isAligned_
Memory alignment flag.
Definition: DenseSubmatrix.h:1059
Header file for the AlignedArray implementation.
Header file for the cache size of the target architecture.
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubmatrix.h:510
bool operator>(const SubmatrixIterator &rhs) const
Greater-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:732
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2481
Header file for the column trait.
Header file for the isDefault shim.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DenseSubmatrix.h:481
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
PointerType pointer
Pointer return type.
Definition: DenseSubmatrix.h:527
size_t capacity() const
Returns the maximum capacity of the dense submatrix.
Definition: DenseSubmatrix.h:1737
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:118
const SubmatrixIterator operator--(int)
Post-decrement operator.
Definition: DenseSubmatrix.h:635
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Compile time check for constant data types.The IsConst type trait tests whether or not the given temp...
Definition: IsConst.h:94
IteratorType final_
The final iterator for intrinsic operations.
Definition: DenseSubmatrix.h:849
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:2239
Header file for all intrinsic functionality.
IteratorType final() const
Access to the final position of the submatrix iterator.
Definition: DenseSubmatrix.h:821
size_t nonZeros() const
Returns the number of non-zero elements in the dense submatrix.
Definition: DenseSubmatrix.h:1777
IteratorType base() const
Access to the current position of the submatrix iterator.
Definition: DenseSubmatrix.h:811
IT::Type IntrinsicType
Intrinsic type of the submatrix elements.
Definition: DenseSubmatrix.h:484
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2637
MT::ConstReference ConstReference
Reference to a constant submatrix value.
Definition: DenseSubmatrix.h:489
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:137
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:256
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubmatrix.h:850
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubmatrix.h:516
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
View on a specific submatrix of a dense matrix.The DenseSubmatrix template represents a view on a spe...
Definition: DenseSubmatrix.h:454
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 canSMPAssign() const
Returns whether the submatrix can be used in SMP assignments.
Definition: DenseSubmatrix.h:2112
Header file for basic type definitions.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DenseSubmatrix.h:1722
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
Implementation of a static array with a fixed alignment.The AlignedArray class template represents a ...
Definition: AlignedArray.h:264
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Base template for the SubTrait class.
Definition: SubTrait.h:142
Header file for the Submatrix base class.
const size_t m_
The number of rows of the submatrix.
Definition: DenseSubmatrix.h:1051
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional matrix type...
Definition: Matrix.h:79
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:2213
friend const SubmatrixIterator operator-(const SubmatrixIterator &it, size_t dec)
Subtraction between a SubmatrixIterator and an integral value.
Definition: DenseSubmatrix.h:801
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
SubmatrixIterator & operator--()
Pre-decrement operator.
Definition: DenseSubmatrix.h:624
#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
bool operator>=(const SubmatrixIterator &rhs) const
Greater-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:754
Header file for the IsExpression type trait class.
friend const SubmatrixIterator operator+(const SubmatrixIterator &it, size_t inc)
Addition between a SubmatrixIterator and an integral value.
Definition: DenseSubmatrix.h:777
Constraint on the data type.
Header file for the FunctionTrace class.
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