35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
380 template<
typename MT
382 ,
bool SO = IsColumnMajorMatrix<MT>::value >
433 template<
typename IteratorType >
442 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
445 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
448 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
451 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
587 for(
size_t j=0UL; j<
rest_; ++j )
589 for(
size_t j=rest_; j<IT::size; ++j )
729 enum { vectorizable = MT::vectorizable };
732 enum { smpAssignable = MT::smpAssignable };
769 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO2>& rhs );
770 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO2>& rhs );
771 template<
typename MT2,
bool SO2 >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO2>& rhs );
773 template<
typename Other >
774 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
775 operator*=( Other rhs );
777 template<
typename Other >
778 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
779 operator/=( Other rhs );
786 inline size_t rows()
const;
790 inline size_t capacity(
size_t i )
const;
792 inline size_t nonZeros(
size_t i )
const;
794 inline void reset(
size_t i );
796 template<
typename Other >
inline DenseSubmatrix& scale( Other scalar );
803 template<
typename MT2 >
805 struct VectorizedAssign {
806 enum { value = vectorizable && MT2::vectorizable &&
807 IsSame<ElementType,typename MT2::ElementType>::value };
814 template<
typename MT2 >
816 struct VectorizedAddAssign {
817 enum { value = vectorizable && MT2::vectorizable &&
818 IsSame<ElementType,typename MT2::ElementType>::value &&
819 IntrinsicTrait<ElementType>::addition };
826 template<
typename MT2 >
828 struct VectorizedSubAssign {
829 enum { value = vectorizable && MT2::vectorizable &&
830 IsSame<ElementType,typename MT2::ElementType>::value &&
831 IntrinsicTrait<ElementType>::subtraction };
840 template<
typename Other >
841 inline bool canAlias(
const Other* alias )
const;
843 template<
typename MT2,
bool AF2,
bool SO2 >
844 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
846 template<
typename Other >
847 inline bool isAliased(
const Other* alias )
const;
849 template<
typename MT2,
bool AF2,
bool SO2 >
850 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
861 template<
typename MT2 >
862 inline typename DisableIf< VectorizedAssign<MT2> >::Type
863 assign(
const DenseMatrix<MT2,SO>& rhs );
865 template<
typename MT2 >
866 inline typename EnableIf< VectorizedAssign<MT2> >::Type
867 assign(
const DenseMatrix<MT2,SO>& rhs );
869 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,!SO>& rhs );
870 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,SO>& rhs );
871 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,!SO>& rhs );
873 template<
typename MT2 >
874 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
875 addAssign(
const DenseMatrix<MT2,SO>& rhs );
877 template<
typename MT2 >
878 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
879 addAssign(
const DenseMatrix<MT2,SO>& rhs );
881 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,!SO>& rhs );
882 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
883 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,!SO>& rhs );
885 template<
typename MT2 >
886 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
887 subAssign(
const DenseMatrix<MT2,SO>& rhs );
889 template<
typename MT2 >
890 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
891 subAssign(
const DenseMatrix<MT2,SO>& rhs );
893 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,!SO>& rhs );
894 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
895 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,!SO>& rhs );
929 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
931 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
935 template<
typename MT2,
bool AF2,
bool SO2 >
938 template<
typename MT2,
bool AF2,
bool SO2 >
941 template<
typename MT2,
bool AF2,
bool SO2 >
980 template<
typename MT
989 , rest_ ( n %
IT::size )
990 , final_ ( n - rest_ )
991 , isAligned_( ( column %
IT::size == 0UL ) &&
992 ( column + n == matrix.
columns() || n %
IT::size == 0UL ) )
994 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
995 throw std::invalid_argument(
"Invalid submatrix specification" );
1015 template<
typename MT
1024 return matrix_(row_+i,column_+j);
1036 template<
typename MT
1045 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
1059 template<
typename MT
1064 return matrix_.data() + row_*
spacing() + column_;
1078 template<
typename MT
1083 return matrix_.data() + row_*
spacing() + column_;
1099 template<
typename MT
1105 const typename MT::Iterator first( matrix_.begin( row_ + i ) + column_ );
1106 return Iterator( first, first + final_, rest_, isAligned_ );
1122 template<
typename MT
1130 return ConstIterator( first, first + final_, rest_, isAligned_ );
1146 template<
typename MT
1154 return ConstIterator( first, first + final_, rest_, isAligned_ );
1170 template<
typename MT
1176 const typename MT::Iterator last( matrix_.begin( row_ + i ) + column_ +
n_ );
1177 return Iterator( last, last, rest_, isAligned_ );
1193 template<
typename MT
1217 template<
typename MT
1244 template<
typename MT
1249 const size_t iend( row_ +
m_ );
1250 const size_t jend( column_ +
n_ );
1252 for(
size_t i=row_; i<iend; ++i )
1253 for(
size_t j=column_; j<jend; ++j )
1272 template<
typename MT
1280 if(
this == &rhs || ( &matrix_ == &rhs.
matrix_ && row_ == rhs.
row_ && column_ == rhs.
column_ ) )
1284 throw std::invalid_argument(
"Submatrix sizes do not match" );
1311 template<
typename MT
1314 template<
typename MT2
1321 throw std::invalid_argument(
"Matrix sizes do not match" );
1326 if( (~rhs).canAlias( &matrix_ ) ) {
1349 template<
typename MT
1352 template<
typename MT2
1359 throw std::invalid_argument(
"Matrix sizes do not match" );
1361 if( (~rhs).canAlias( &matrix_ ) ) {
1384 template<
typename MT
1387 template<
typename MT2
1394 throw std::invalid_argument(
"Matrix sizes do not match" );
1396 if( (~rhs).canAlias( &matrix_ ) ) {
1419 template<
typename MT
1422 template<
typename MT2
1427 throw std::invalid_argument(
"Matrix sizes do not match" );
1434 const MultType tmp( *
this * (~rhs) );
1451 template<
typename MT
1454 template<
typename Other >
1471 template<
typename MT
1474 template<
typename Other >
1499 template<
typename MT
1514 template<
typename MT
1534 template<
typename MT
1539 return matrix_.spacing();
1549 template<
typename MT
1570 template<
typename MT
1589 template<
typename MT
1594 const size_t iend( row_ +
m_ );
1595 const size_t jend( column_ +
n_ );
1596 size_t nonzeros( 0UL );
1598 for(
size_t i=row_; i<iend; ++i )
1599 for(
size_t j=column_; j<jend; ++j )
1619 template<
typename MT
1626 const size_t jend( column_ +
n_ );
1627 size_t nonzeros( 0UL );
1629 for(
size_t j=column_; j<jend; ++j )
1643 template<
typename MT
1650 const size_t iend( row_ +
m_ );
1651 const size_t jend( column_ +
n_ );
1653 for(
size_t i=row_; i<iend; ++i )
1654 for(
size_t j=column_; j<jend; ++j )
1655 reset( matrix_(i,j) );
1671 template<
typename MT
1680 const size_t jend( column_ +
n_ );
1681 for(
size_t j=column_; j<jend; ++j )
1682 reset( matrix_(row_+i,j) );
1697 template<
typename MT
1703 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
1718 template<
typename MT
1721 template<
typename Other >
1724 const size_t iend( row_ +
m_ );
1725 const size_t jend( column_ +
n_ );
1727 for(
size_t i=row_; i<iend; ++i )
1728 for(
size_t j=column_; j<jend; ++j )
1729 matrix_(i,j) *= scalar;
1754 template<
typename MT
1757 template<
typename Other >
1760 return matrix_.isAliased( alias );
1775 template<
typename MT
1778 template<
typename MT2
1783 return ( matrix_.isAliased( &alias->
matrix_ ) &&
1784 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
1785 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
1800 template<
typename MT
1803 template<
typename Other >
1806 return matrix_.isAliased( alias );
1821 template<
typename MT
1824 template<
typename MT2
1829 return ( matrix_.isAliased( &alias->
matrix_ ) &&
1830 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
1831 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
1845 template<
typename MT
1865 template<
typename MT
1891 template<
typename MT
1897 return loadu( i, j );
1918 template<
typename MT
1933 return matrix_.load( row_+i, column_+j );
1935 else if( j != final_ ) {
1936 return matrix_.loadu( row_+i, column_+j );
1940 for(
size_t k=0UL; k<rest_; ++k )
1941 array[k] = matrix_(row_+i,column_+j+k);
1942 for(
size_t k=rest_; k<IT::size; ++k )
1966 template<
typename MT
1992 template<
typename MT
2006 matrix_.store( row_+i, column_+j, value );
2008 else if( j != final_ ) {
2009 matrix_.storeu( row_+i, column_+j, value );
2014 for(
size_t k=0UL; k<rest_; ++k )
2015 matrix_(row_+i,column_+j+k) = array[k];
2038 template<
typename MT
2059 template<
typename MT
2062 template<
typename MT2 >
2069 const size_t jend(
n_ &
size_t(-2) );
2072 for(
size_t i=0UL; i<
m_; ++i ) {
2073 for(
size_t j=0UL; j<jend; j+=2UL ) {
2074 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
2075 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
2078 matrix_(row_+i,column_+jend) = (~rhs)(i,jend);
2096 template<
typename MT
2099 template<
typename MT2 >
2110 !(~rhs).isAliased( &matrix_ ) )
2112 for(
size_t i=0UL; i<
m_; ++i )
2113 for(
size_t j=0UL; j<
n_; j+=IT::size )
2114 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
2118 const size_t jend(
n_ &
size_t(-IT::size*4) );
2121 for(
size_t i=0UL; i<
m_; ++i ) {
2123 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2124 matrix_.storeu( row_+i, column_+j , it.load() ); it += IT::size;
2125 matrix_.storeu( row_+i, column_+j+IT::size , it.load() ); it += IT::size;
2126 matrix_.storeu( row_+i, column_+j+IT::size*2UL, it.load() ); it += IT::size;
2127 matrix_.storeu( row_+i, column_+j+IT::size*3UL, it.load() ); it += IT::size;
2129 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2130 storeu( i, j, it.load() );
2149 template<
typename MT
2152 template<
typename MT2 >
2158 const size_t block( 16UL );
2160 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2161 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2162 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2163 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2164 for(
size_t i=ii; i<iend; ++i ) {
2165 for(
size_t j=jj; j<jend; ++j ) {
2166 matrix_(row_+i,column_+j) = (~rhs)(i,j);
2186 template<
typename MT
2189 template<
typename MT2 >
2195 for(
size_t i=0UL; i<
m_; ++i )
2196 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2197 matrix_(row_+i,column_+element->index()) = element->value();
2213 template<
typename MT
2216 template<
typename MT2 >
2222 for(
size_t j=0UL; j<
n_; ++j )
2223 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2224 matrix_(row_+element->index(),column_+j) = element->value();
2240 template<
typename MT
2243 template<
typename MT2 >
2250 const size_t jend(
n_ &
size_t(-2) );
2253 for(
size_t i=0UL; i<
m_; ++i ) {
2254 for(
size_t j=0UL; j<jend; j+=2UL ) {
2255 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
2256 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
2259 matrix_(row_+i,column_+jend) += (~rhs)(i,jend);
2277 template<
typename MT
2280 template<
typename MT2 >
2289 const size_t jend(
n_ &
size_t(-IT::size*4) );
2292 for(
size_t i=0UL; i<
m_; ++i ) {
2294 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2295 matrix_.storeu( row_+i, column_+j ,
load(i,j ) + it.load() ); it += IT::size;
2296 matrix_.storeu( row_+i, column_+j+IT::size ,
load(i,j+IT::size ) + it.load() ); it += IT::size;
2297 matrix_.storeu( row_+i, column_+j+IT::size*2UL,
load(i,j+IT::size*2UL) + it.load() ); it += IT::size;
2298 matrix_.storeu( row_+i, column_+j+IT::size*3UL,
load(i,j+IT::size*3UL) + it.load() ); it += IT::size;
2300 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2319 template<
typename MT
2322 template<
typename MT2 >
2328 const size_t block( 16UL );
2330 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2331 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2332 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2333 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2334 for(
size_t i=ii; i<iend; ++i ) {
2335 for(
size_t j=jj; j<jend; ++j ) {
2336 matrix_(row_+i,column_+j) += (~rhs)(i,j);
2356 template<
typename MT
2359 template<
typename MT2 >
2365 for(
size_t i=0UL; i<
m_; ++i )
2366 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2367 matrix_(row_+i,column_+element->index()) += element->value();
2383 template<
typename MT
2386 template<
typename MT2 >
2392 for(
size_t j=0UL; j<
n_; ++j )
2393 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2394 matrix_(row_+element->index(),column_+j) += element->value();
2410 template<
typename MT
2413 template<
typename MT2 >
2420 const size_t jend(
n_ &
size_t(-2) );
2423 for(
size_t i=0UL; i<
m_; ++i ) {
2424 for(
size_t j=0UL; j<jend; j+=2UL ) {
2425 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
2426 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
2429 matrix_(row_+i,column_+jend) -= (~rhs)(i,jend);
2447 template<
typename MT
2450 template<
typename MT2 >
2459 const size_t jend(
n_ &
size_t(-IT::size*4) );
2462 for(
size_t i=0UL; i<
m_; ++i ) {
2464 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2465 matrix_.storeu( row_+i, column_+j ,
load(i,j ) - it.load() ); it += IT::size;
2466 matrix_.storeu( row_+i, column_+j+IT::size ,
load(i,j+IT::size ) - it.load() ); it += IT::size;
2467 matrix_.storeu( row_+i, column_+j+IT::size*2UL,
load(i,j+IT::size*2UL) - it.load() ); it += IT::size;
2468 matrix_.storeu( row_+i, column_+j+IT::size*3UL,
load(i,j+IT::size*3UL) - it.load() ); it += IT::size;
2470 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2489 template<
typename MT
2492 template<
typename MT2 >
2498 const size_t block( 16UL );
2500 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2501 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2502 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2503 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2504 for(
size_t i=ii; i<iend; ++i ) {
2505 for(
size_t j=jj; j<jend; ++j ) {
2506 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
2526 template<
typename MT
2529 template<
typename MT2 >
2535 for(
size_t i=0UL; i<
m_; ++i )
2536 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2537 matrix_(row_+i,column_+element->index()) -= element->value();
2553 template<
typename MT
2556 template<
typename MT2 >
2562 for(
size_t j=0UL; j<
n_; ++j )
2563 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2564 matrix_(row_+element->index(),column_+j) -= element->value();
2589 template<
typename MT >
2615 typedef DenseSubmatrix<MT,unaligned,true>
This;
2616 typedef typename SubmatrixTrait<MT>::Type
ResultType;
2628 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
2634 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
2640 template<
typename IteratorType >
2641 class SubmatrixIterator
2646 typedef typename std::iterator_traits<IteratorType>::iterator_category
IteratorCategory;
2649 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
2652 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
2655 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
2658 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
2793 AlignedArray<ElementType,IT::size> array;
2794 for(
size_t i=0UL; i<
rest_; ++i )
2796 for(
size_t i=rest_; i<IT::size; ++i )
2888 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
2900 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
2912 return SubmatrixIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
2928 typedef SubmatrixIterator<typename MT::ConstIterator>
ConstIterator;
2931 typedef typename SelectType< useConst, ConstIterator, SubmatrixIterator<typename MT::Iterator> >::Type
Iterator;
2936 enum { vectorizable = MT::vectorizable };
2939 enum { smpAssignable = MT::smpAssignable };
2976 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
2977 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
2978 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
2980 template<
typename Other >
2981 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
2982 operator*=( Other rhs );
2984 template<
typename Other >
2985 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
2986 operator/=( Other rhs );
2993 inline size_t rows()
const;
2994 inline size_t columns()
const;
2995 inline size_t spacing()
const;
2997 inline size_t capacity(
size_t i )
const;
2999 inline size_t nonZeros(
size_t i )
const;
3000 inline void reset();
3001 inline void reset(
size_t i );
3003 template<
typename Other >
inline DenseSubmatrix& scale( Other scalar );
3010 template<
typename MT2 >
3011 struct VectorizedAssign {
3012 enum { value = vectorizable && MT2::vectorizable &&
3013 IsSame<ElementType,typename MT2::ElementType>::value };
3019 template<
typename MT2 >
3020 struct VectorizedAddAssign {
3021 enum { value = vectorizable && MT2::vectorizable &&
3022 IsSame<ElementType,typename MT2::ElementType>::value &&
3023 IntrinsicTrait<ElementType>::addition };
3029 template<
typename MT2 >
3030 struct VectorizedSubAssign {
3031 enum { value = vectorizable && MT2::vectorizable &&
3032 IsSame<ElementType,typename MT2::ElementType>::value &&
3033 IntrinsicTrait<ElementType>::subtraction };
3041 template<
typename Other >
3042 inline bool canAlias(
const Other* alias )
const;
3044 template<
typename MT2,
bool AF2,
bool SO2 >
3045 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
3047 template<
typename Other >
3048 inline bool isAliased(
const Other* alias )
const;
3050 template<
typename MT2,
bool AF2,
bool SO2 >
3051 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
3062 template<
typename MT2 >
3063 inline typename DisableIf< VectorizedAssign<MT2> >::Type
3064 assign(
const DenseMatrix<MT2,true>& rhs );
3066 template<
typename MT2 >
3067 inline typename EnableIf< VectorizedAssign<MT2> >::Type
3068 assign(
const DenseMatrix<MT2,true>& rhs );
3070 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
3071 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
3072 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
3074 template<
typename MT2 >
3075 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
3076 addAssign(
const DenseMatrix<MT2,true>& rhs );
3078 template<
typename MT2 >
3079 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
3080 addAssign(
const DenseMatrix<MT2,true>& rhs );
3082 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
3083 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
3084 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
3086 template<
typename MT2 >
3087 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
3088 subAssign(
const DenseMatrix<MT2,true>& rhs );
3090 template<
typename MT2 >
3091 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
3092 subAssign(
const DenseMatrix<MT2,true>& rhs );
3094 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
3095 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
3096 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
3129 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
3131 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
3132 friend const DenseSubmatrix<MT2,AF1,SO2>
3133 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
3135 template<
typename MT2,
bool AF2,
bool SO2 >
3136 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
3138 template<
typename MT2,
bool AF2,
bool SO2 >
3139 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
3141 template<
typename MT2,
bool AF2,
bool SO2 >
3142 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
3179 template<
typename MT >
3181 : matrix_ ( matrix )
3183 , column_ ( column )
3186 , rest_ ( m % IT::size )
3187 , final_ ( m - rest_ )
3188 , isAligned_( ( row % IT::size == 0UL ) &&
3189 ( row + m == matrix.
rows() || m % IT::size == 0UL ) )
3191 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
3192 throw std::invalid_argument(
"Invalid submatrix specification" );
3214 template<
typename MT >
3221 return matrix_(row_+i,column_+j);
3235 template<
typename MT >
3242 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
3258 template<
typename MT >
3261 return matrix_.data() + row_ + column_*
spacing();
3277 template<
typename MT >
3278 inline typename DenseSubmatrix<MT,unaligned,true>::ConstPointer
3281 return matrix_.data() + row_ + column_*
spacing();
3294 template<
typename MT >
3299 const typename MT::Iterator first( matrix_.begin( column_ + j ) + row_ );
3300 return Iterator( first, first + final_, rest_, isAligned_ );
3313 template<
typename MT >
3319 return ConstIterator( first, first + final_, rest_, isAligned_ );
3332 template<
typename MT >
3338 return ConstIterator( first, first + final_, rest_, isAligned_ );
3351 template<
typename MT >
3356 const typename MT::Iterator last( matrix_.begin( column_ + j ) + row_ +
m_ );
3357 return Iterator( last, last, rest_, isAligned_ );
3370 template<
typename MT >
3389 template<
typename MT >
3416 template<
typename MT >
3417 inline DenseSubmatrix<MT,unaligned,true>&
3420 const size_t iend( row_ +
m_ );
3421 const size_t jend( column_ +
n_ );
3423 for(
size_t j=column_; j<jend; ++j )
3424 for(
size_t i=row_; i<iend; ++i )
3445 template<
typename MT >
3446 inline DenseSubmatrix<MT,unaligned,true>&
3452 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
3455 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
3456 throw std::invalid_argument(
"Submatrix sizes do not match" );
3458 if( rhs.canAlias( &matrix_ ) ) {
3463 if( IsSparseMatrix<MT>::value )
3485 template<
typename MT >
3486 template<
typename MT2
3488 inline DenseSubmatrix<MT,unaligned,true>&
3494 throw std::invalid_argument(
"Matrix sizes do not match" );
3496 if( IsSparseMatrix<MT2>::value )
3499 if( (~rhs).canAlias( &matrix_ ) ) {
3524 template<
typename MT >
3525 template<
typename MT2
3527 inline DenseSubmatrix<MT,unaligned,true>&
3528 DenseSubmatrix<MT,unaligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
3533 throw std::invalid_argument(
"Matrix sizes do not match" );
3535 if( (~rhs).canAlias( &matrix_ ) ) {
3560 template<
typename MT >
3561 template<
typename MT2
3563 inline DenseSubmatrix<MT,unaligned,true>&
3564 DenseSubmatrix<MT,unaligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
3569 throw std::invalid_argument(
"Matrix sizes do not match" );
3571 if( (~rhs).canAlias( &matrix_ ) ) {
3596 template<
typename MT >
3597 template<
typename MT2
3599 inline DenseSubmatrix<MT,unaligned,true>&
3600 DenseSubmatrix<MT,unaligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
3603 throw std::invalid_argument(
"Matrix sizes do not match" );
3605 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
3610 const MultType tmp( *
this * (~rhs) );
3611 if( IsSparseMatrix<MultType>::value )
3629 template<
typename MT >
3630 template<
typename Other >
3631 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
3632 DenseSubmatrix<MT,unaligned,true>::operator*=( Other rhs )
3649 template<
typename MT >
3650 template<
typename Other >
3651 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
3652 DenseSubmatrix<MT,unaligned,true>::operator/=( Other rhs )
3677 template<
typename MT >
3692 template<
typename MT >
3710 template<
typename MT >
3713 return matrix_.spacing();
3725 template<
typename MT >
3741 template<
typename MT >
3760 template<
typename MT >
3763 const size_t iend( row_ +
m_ );
3764 const size_t jend( column_ +
n_ );
3765 size_t nonzeros( 0UL );
3767 for(
size_t j=column_; j<jend; ++j )
3768 for(
size_t i=row_; i<iend; ++i )
3785 template<
typename MT >
3790 const size_t iend( row_ +
m_ );
3791 size_t nonzeros( 0UL );
3793 for(
size_t i=row_; i<iend; ++i )
3794 if( !
isDefault( matrix_(i,column_+j) ) )
3809 template<
typename MT >
3814 const size_t iend( row_ +
m_ );
3815 const size_t jend( column_ +
n_ );
3817 for(
size_t j=column_; j<jend; ++j )
3818 for(
size_t i=row_; i<iend; ++i )
3819 reset( matrix_(i,j) );
3832 template<
typename MT >
3839 const size_t iend( row_ +
m_ );
3840 for(
size_t i=row_; i<iend; ++i )
3841 reset( matrix_(i,column_+j) );
3858 template<
typename MT >
3862 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
3879 template<
typename MT >
3880 template<
typename Other >
3881 inline DenseSubmatrix<MT,unaligned,true>& DenseSubmatrix<MT,unaligned,true>::scale( Other scalar )
3883 const size_t iend( row_ +
m_ );
3884 const size_t jend( column_ +
n_ );
3886 for(
size_t j=column_; j<jend; ++j )
3887 for(
size_t i=row_; i<iend; ++i )
3888 matrix_(i,j) *= scalar;
3915 template<
typename MT >
3916 template<
typename Other >
3919 return matrix_.isAliased( alias );
3936 template<
typename MT >
3937 template<
typename MT2
3942 return ( matrix_.isAliased( &alias->matrix_ ) &&
3943 ( row_ +
m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
3944 ( column_ +
n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
3961 template<
typename MT >
3962 template<
typename Other >
3965 return matrix_.isAliased( alias );
3982 template<
typename MT >
3983 template<
typename MT2
3988 return ( matrix_.isAliased( &alias->matrix_ ) &&
3989 ( row_ +
m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
3990 ( column_ +
n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
4006 template<
typename MT >
4026 template<
typename MT >
4051 template<
typename MT >
4052 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
4055 return loadu( i, j );
4077 template<
typename MT >
4078 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
4090 return matrix_.load( row_+i, column_+j );
4092 else if( i != final_ ) {
4093 return matrix_.loadu( row_+i, column_+j );
4096 AlignedArray<ElementType,IT::size> array;
4097 for(
size_t k=0UL; k<rest_; ++k )
4098 array[k] = matrix_(row_+i+k,column_+j);
4099 for(
size_t k=rest_; k<IT::size; ++k )
4101 return load( array.data() );
4124 template<
typename MT >
4150 template<
typename MT >
4162 matrix_.store( row_+i, column_+j, value );
4164 else if( i != final_ ) {
4165 matrix_.storeu( row_+i, column_+j, value );
4168 AlignedArray<ElementType,IT::size> array;
4169 store( array.data(), value );
4170 for(
size_t k=0UL; k<rest_; ++k )
4171 matrix_(row_+i+k,column_+j) = array[k];
4195 template<
typename MT >
4216 template<
typename MT >
4217 template<
typename MT2 >
4218 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
4224 const size_t iend(
m_ &
size_t(-2) );
4227 for(
size_t j=0UL; j<
n_; ++j ) {
4228 for(
size_t i=0UL; i<iend; i+=2UL ) {
4229 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
4230 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
4233 matrix_(row_+iend,column_+j) = (~rhs)(iend,j);
4253 template<
typename MT >
4254 template<
typename MT2 >
4255 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
4265 !(~rhs).isAliased( &matrix_ ) )
4267 for(
size_t j=0UL; j<
n_; ++j )
4268 for(
size_t i=0UL; i<
m_; i+=IT::size )
4269 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
4273 const size_t iend(
m_ &
size_t(-IT::size*4) );
4276 for(
size_t j=0UL; j<
n_; ++j ) {
4278 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4279 matrix_.storeu( row_+i , column_+j, it.load() ); it += IT::size;
4280 matrix_.storeu( row_+i+IT::size , column_+j, it.load() ); it += IT::size;
4281 matrix_.storeu( row_+i+IT::size*2UL, column_+j, it.load() ); it += IT::size;
4282 matrix_.storeu( row_+i+IT::size*3UL, column_+j, it.load() ); it += IT::size;
4284 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4285 storeu( i, j, it.load() );
4306 template<
typename MT >
4307 template<
typename MT2 >
4313 const size_t block( 16UL );
4315 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4316 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4317 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4318 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4319 for(
size_t j=jj; j<jend; ++j ) {
4320 for(
size_t i=ii; i<iend; ++i ) {
4321 matrix_(row_+i,column_+j) = (~rhs)(i,j);
4343 template<
typename MT >
4344 template<
typename MT2 >
4350 for(
size_t j=0UL; j<
n_; ++j )
4351 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4352 matrix_(row_+element->index(),column_+j) = element->value();
4370 template<
typename MT >
4371 template<
typename MT2 >
4377 for(
size_t i=0UL; i<
m_; ++i )
4378 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4379 matrix_(row_+i,column_+element->index()) = element->value();
4397 template<
typename MT >
4398 template<
typename MT2 >
4399 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
4405 const size_t iend( m_ &
size_t(-2) );
4408 for(
size_t j=0UL; j<
n_; ++j ) {
4409 for(
size_t i=0UL; i<iend; i+=2UL ) {
4410 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
4411 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
4414 matrix_(row_+iend,column_+j) += (~rhs)(iend,j);
4434 template<
typename MT >
4435 template<
typename MT2 >
4436 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
4444 const size_t iend( m_ &
size_t(-IT::size*4) );
4447 for(
size_t j=0UL; j<
n_; ++j ) {
4449 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4450 matrix_.storeu( row_+i , column_+j,
load(i ,j) + it.load() ); it += IT::size;
4451 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) + it.load() ); it += IT::size;
4452 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) + it.load() ); it += IT::size;
4453 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) + it.load() ); it += IT::size;
4455 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4476 template<
typename MT >
4477 template<
typename MT2 >
4483 const size_t block( 16UL );
4485 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4486 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4487 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4488 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4489 for(
size_t j=jj; j<jend; ++j ) {
4490 for(
size_t i=ii; i<iend; ++i ) {
4491 matrix_(row_+i,column_+j) += (~rhs)(i,j);
4513 template<
typename MT >
4514 template<
typename MT2 >
4520 for(
size_t j=0UL; j<
n_; ++j )
4521 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4522 matrix_(row_+element->index(),column_+j) += element->value();
4540 template<
typename MT >
4541 template<
typename MT2 >
4547 for(
size_t i=0UL; i<
m_; ++i )
4548 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4549 matrix_(row_+i,column_+element->index()) += element->value();
4567 template<
typename MT >
4568 template<
typename MT2 >
4569 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
4575 const size_t iend( m_ &
size_t(-2) );
4578 for(
size_t j=0UL; j<
n_; ++j ) {
4579 for(
size_t i=0UL; i<iend; i+=2UL ) {
4580 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
4581 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
4584 matrix_(row_+iend,column_+j) -= (~rhs)(iend,j);
4604 template<
typename MT >
4605 template<
typename MT2 >
4606 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
4614 const size_t iend( m_ &
size_t(-IT::size*4) );
4617 for(
size_t j=0UL; j<
n_; ++j ) {
4619 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4620 matrix_.storeu( row_+i , column_+j,
load(i ,j) - it.load() ); it += IT::size;
4621 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) - it.load() ); it += IT::size;
4622 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) - it.load() ); it += IT::size;
4623 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) - it.load() ); it += IT::size;
4625 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4646 template<
typename MT >
4647 template<
typename MT2 >
4653 const size_t block( 16UL );
4655 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4656 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4657 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4658 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4659 for(
size_t j=jj; j<jend; ++j ) {
4660 for(
size_t i=ii; i<iend; ++i ) {
4661 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
4683 template<
typename MT >
4684 template<
typename MT2 >
4690 for(
size_t j=0UL; j<
n_; ++j )
4691 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4692 matrix_(row_+element->index(),column_+j) -= element->value();
4710 template<
typename MT >
4711 template<
typename MT2 >
4717 for(
size_t i=0UL; i<
m_; ++i )
4718 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4719 matrix_(row_+i,column_+element->index()) -= element->value();
4745 template<
typename MT >
4746 class DenseSubmatrix<MT,
aligned,false> :
public DenseMatrix< DenseSubmatrix<MT,aligned,false>, false >
4752 typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type
Operand;
4755 typedef IntrinsicTrait<typename MT::ElementType>
IT;
4766 enum { useConst = IsConst<MT>::value };
4771 typedef DenseSubmatrix<MT,aligned,false>
This;
4772 typedef typename SubmatrixTrait<MT>::Type
ResultType;
4784 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
4790 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
4796 typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
4801 enum { vectorizable = MT::vectorizable };
4804 enum { smpAssignable = MT::smpAssignable };
4841 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
4842 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
4843 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
4845 template<
typename Other >
4846 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
4847 operator*=( Other rhs );
4849 template<
typename Other >
4850 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
4851 operator/=( Other rhs );
4858 inline size_t rows()
const;
4859 inline size_t columns()
const;
4860 inline size_t spacing()
const;
4862 inline size_t capacity(
size_t i )
const;
4864 inline size_t nonZeros(
size_t i )
const;
4865 inline void reset();
4866 inline void reset(
size_t i );
4868 template<
typename Other >
inline DenseSubmatrix& scale( Other scalar );
4875 template<
typename MT2 >
4876 struct VectorizedAssign {
4877 enum { value = vectorizable && MT2::vectorizable &&
4878 IsSame<ElementType,typename MT2::ElementType>::value };
4884 template<
typename MT2 >
4885 struct VectorizedAddAssign {
4886 enum { value = vectorizable && MT2::vectorizable &&
4887 IsSame<ElementType,typename MT2::ElementType>::value &&
4888 IntrinsicTrait<ElementType>::addition };
4894 template<
typename MT2 >
4895 struct VectorizedSubAssign {
4896 enum { value = vectorizable && MT2::vectorizable &&
4897 IsSame<ElementType,typename MT2::ElementType>::value &&
4898 IntrinsicTrait<ElementType>::subtraction };
4906 template<
typename Other >
4907 inline bool canAlias(
const Other* alias )
const;
4909 template<
typename MT2,
bool AF2,
bool SO2 >
4910 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
4912 template<
typename Other >
4913 inline bool isAliased(
const Other* alias )
const;
4915 template<
typename MT2,
bool AF2,
bool SO2 >
4916 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
4927 template<
typename MT2 >
4928 inline typename DisableIf< VectorizedAssign<MT2> >::Type
4929 assign(
const DenseMatrix<MT2,false>& rhs );
4931 template<
typename MT2 >
4932 inline typename EnableIf< VectorizedAssign<MT2> >::Type
4933 assign(
const DenseMatrix<MT2,false>& rhs );
4935 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,true>& rhs );
4936 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
4937 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
4939 template<
typename MT2 >
4940 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
4941 addAssign(
const DenseMatrix<MT2,false>& rhs );
4943 template<
typename MT2 >
4944 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
4945 addAssign(
const DenseMatrix<MT2,false>& rhs );
4947 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,true>& rhs );
4948 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
4949 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
4951 template<
typename MT2 >
4952 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
4953 subAssign(
const DenseMatrix<MT2,false>& rhs );
4955 template<
typename MT2 >
4956 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
4957 subAssign(
const DenseMatrix<MT2,false>& rhs );
4959 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,true>& rhs );
4960 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
4961 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
4978 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
4980 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
4981 friend const DenseSubmatrix<MT2,AF1,SO2>
4982 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
4984 template<
typename MT2,
bool AF2,
bool SO2 >
4985 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
4987 template<
typename MT2,
bool AF2,
bool SO2 >
4988 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
4990 template<
typename MT2,
bool AF2,
bool SO2 >
4991 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
5028 template<
typename MT >
5036 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
5037 throw std::invalid_argument(
"Invalid submatrix specification" );
5039 if( column % IT::size != 0UL || (
column_ + n_ !=
matrix_.columns() && n_ % IT::size != 0UL ) )
5040 throw std::invalid_argument(
"Invalid submatrix alignment" );
5062 template<
typename MT >
5069 return matrix_(row_+i,column_+j);
5083 template<
typename MT >
5090 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
5106 template<
typename MT >
5109 return matrix_.data() + row_*
spacing() + column_;
5125 template<
typename MT >
5126 inline typename DenseSubmatrix<MT,aligned,false>::ConstPointer
5129 return matrix_.data() + row_*
spacing() + column_;
5147 template<
typename MT >
5152 return ( matrix_.begin( row_ + i ) + column_ );
5170 template<
typename MT >
5175 return ( matrix_.cbegin( row_ + i ) + column_ );
5193 template<
typename MT >
5198 return ( matrix_.cbegin( row_ + i ) + column_ );
5216 template<
typename MT >
5221 return ( matrix_.begin( row_ + i ) + column_ +
n_ );
5239 template<
typename MT >
5244 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
5262 template<
typename MT >
5267 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
5288 template<
typename MT >
5289 inline DenseSubmatrix<MT,aligned,false>&
5292 const size_t iend( row_ + m_ );
5293 const size_t jend( column_ + n_ );
5295 for(
size_t i=row_; i<iend; ++i )
5296 for(
size_t j=column_; j<jend; ++j )
5317 template<
typename MT >
5318 inline DenseSubmatrix<MT,aligned,false>&
5324 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
5327 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
5328 throw std::invalid_argument(
"Submatrix sizes do not match" );
5330 if( rhs.canAlias( &matrix_ ) ) {
5335 if( IsSparseMatrix<MT>::value )
5357 template<
typename MT >
5358 template<
typename MT2
5360 inline DenseSubmatrix<MT,aligned,false>&
5366 throw std::invalid_argument(
"Matrix sizes do not match" );
5368 if( IsSparseMatrix<MT2>::value )
5371 if( (~rhs).canAlias( &matrix_ ) ) {
5396 template<
typename MT >
5397 template<
typename MT2
5399 inline DenseSubmatrix<MT,aligned,false>&
5400 DenseSubmatrix<MT,aligned,false>::operator+=(
const Matrix<MT2,SO>& rhs )
5405 throw std::invalid_argument(
"Matrix sizes do not match" );
5407 if( (~rhs).canAlias( &matrix_ ) ) {
5432 template<
typename MT >
5433 template<
typename MT2
5435 inline DenseSubmatrix<MT,aligned,false>&
5436 DenseSubmatrix<MT,aligned,false>::operator-=(
const Matrix<MT2,SO>& rhs )
5441 throw std::invalid_argument(
"Matrix sizes do not match" );
5443 if( (~rhs).canAlias( &matrix_ ) ) {
5468 template<
typename MT >
5469 template<
typename MT2
5471 inline DenseSubmatrix<MT,aligned,false>&
5472 DenseSubmatrix<MT,aligned,false>::operator*=(
const Matrix<MT2,SO>& rhs )
5475 throw std::invalid_argument(
"Matrix sizes do not match" );
5477 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
5482 const MultType tmp( *
this * (~rhs) );
5483 if( IsSparseMatrix<MultType>::value )
5501 template<
typename MT >
5502 template<
typename Other >
5503 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
5504 DenseSubmatrix<MT,aligned,false>::operator*=( Other rhs )
5521 template<
typename MT >
5522 template<
typename Other >
5523 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
5524 DenseSubmatrix<MT,aligned,false>::operator/=( Other rhs )
5549 template<
typename MT >
5564 template<
typename MT >
5584 template<
typename MT >
5587 return matrix_.spacing();
5599 template<
typename MT >
5620 template<
typename MT >
5639 template<
typename MT >
5642 const size_t iend( row_ + m_ );
5643 const size_t jend( column_ + n_ );
5644 size_t nonzeros( 0UL );
5646 for(
size_t i=row_; i<iend; ++i )
5647 for(
size_t j=column_; j<jend; ++j )
5669 template<
typename MT >
5674 const size_t jend( column_ + n_ );
5675 size_t nonzeros( 0UL );
5677 for(
size_t j=column_; j<jend; ++j )
5693 template<
typename MT >
5698 const size_t iend( row_ + m_ );
5699 const size_t jend( column_ + n_ );
5701 for(
size_t i=row_; i<iend; ++i )
5702 for(
size_t j=column_; j<jend; ++j )
5703 reset( matrix_(i,j) );
5721 template<
typename MT >
5728 const size_t jend( column_ + n_ );
5729 for(
size_t j=column_; j<jend; ++j )
5730 reset( matrix_(row_+i,j) );
5747 template<
typename MT >
5751 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
5768 template<
typename MT >
5769 template<
typename Other >
5770 inline DenseSubmatrix<MT,aligned,false>& DenseSubmatrix<MT,aligned,false>::scale( Other scalar )
5772 const size_t iend( row_ + m_ );
5773 const size_t jend( column_ + n_ );
5775 for(
size_t i=row_; i<iend; ++i )
5776 for(
size_t j=column_; j<jend; ++j )
5777 matrix_(i,j) *= scalar;
5804 template<
typename MT >
5805 template<
typename Other >
5808 return matrix_.isAliased( alias );
5825 template<
typename MT >
5826 template<
typename MT2
5831 return ( matrix_.isAliased( &alias->matrix_ ) &&
5832 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5833 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5850 template<
typename MT >
5851 template<
typename Other >
5854 return matrix_.isAliased( alias );
5871 template<
typename MT >
5872 template<
typename MT2
5877 return ( matrix_.isAliased( &alias->matrix_ ) &&
5878 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
5879 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
5895 template<
typename MT >
5915 template<
typename MT >
5941 template<
typename MT >
5942 inline typename DenseSubmatrix<MT,aligned,false>::IntrinsicType
5951 return matrix_.load( row_+i, column_+j );
5974 template<
typename MT >
5975 inline typename DenseSubmatrix<MT,aligned,false>::IntrinsicType
5984 return matrix_.loadu( row_+i, column_+j );
6007 template<
typename MT >
6016 return matrix_.store( row_+i, column_+j, value );
6039 template<
typename MT >
6048 matrix_.storeu( row_+i, column_+j, value );
6072 template<
typename MT >
6081 matrix_.stream( row_+i, column_+j, value );
6099 template<
typename MT >
6100 template<
typename MT2 >
6101 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6107 const size_t jend( n_ &
size_t(-2) );
6110 for(
size_t i=0UL; i<
m_; ++i ) {
6111 for(
size_t j=0UL; j<jend; j+=2UL ) {
6112 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
6113 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
6116 matrix_(row_+i,column_+jend) = (~rhs)(i,jend);
6136 template<
typename MT >
6137 template<
typename MT2 >
6138 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6148 !(~rhs).isAliased( &matrix_ ) )
6150 for(
size_t i=0UL; i<
m_; ++i )
6151 for(
size_t j=0UL; j<
n_; j+=IT::size )
6156 const size_t jend( n_ &
size_t(-IT::size*4) );
6159 for(
size_t i=0UL; i<
m_; ++i ) {
6161 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
6162 store( i, j , it.load() ); it += IT::size;
6163 store( i, j+IT::size , it.load() ); it += IT::size;
6164 store( i, j+IT::size*2UL, it.load() ); it += IT::size;
6165 store( i, j+IT::size*3UL, it.load() ); it += IT::size;
6167 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
6168 store( i, j, it.load() );
6189 template<
typename MT >
6190 template<
typename MT2 >
6196 const size_t block( 16UL );
6198 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6199 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6200 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6201 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6202 for(
size_t i=ii; i<iend; ++i ) {
6203 for(
size_t j=jj; j<jend; ++j ) {
6204 matrix_(row_+i,column_+j) = (~rhs)(i,j);
6226 template<
typename MT >
6227 template<
typename MT2 >
6233 for(
size_t i=0UL; i<
m_; ++i )
6234 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6235 matrix_(row_+i,column_+element->index()) = element->value();
6253 template<
typename MT >
6254 template<
typename MT2 >
6260 for(
size_t j=0UL; j<
n_; ++j )
6261 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6262 matrix_(row_+element->index(),column_+j) = element->value();
6280 template<
typename MT >
6281 template<
typename MT2 >
6282 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6288 const size_t jend( n_ &
size_t(-2) );
6291 for(
size_t i=0UL; i<
m_; ++i ) {
6292 for(
size_t j=0UL; j<jend; j+=2UL ) {
6293 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
6294 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
6297 matrix_(row_+i,column_+jend) += (~rhs)(i,jend);
6317 template<
typename MT >
6318 template<
typename MT2 >
6319 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6327 const size_t jend( n_ &
size_t(-IT::size*4) );
6330 for(
size_t i=0UL; i<
m_; ++i ) {
6332 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
6333 store( i, j ,
load(i,j ) + it.load() ); it += IT::size;
6334 store( i, j+IT::size ,
load(i,j+IT::size ) + it.load() ); it += IT::size;
6335 store( i, j+IT::size*2UL,
load(i,j+IT::size*2UL) + it.load() ); it += IT::size;
6336 store( i, j+IT::size*3UL,
load(i,j+IT::size*3UL) + it.load() ); it += IT::size;
6338 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
6359 template<
typename MT >
6360 template<
typename MT2 >
6366 const size_t block( 16UL );
6368 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6369 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6370 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6371 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6372 for(
size_t i=ii; i<iend; ++i ) {
6373 for(
size_t j=jj; j<jend; ++j ) {
6374 matrix_(row_+i,column_+j) += (~rhs)(i,j);
6396 template<
typename MT >
6397 template<
typename MT2 >
6403 for(
size_t i=0UL; i<
m_; ++i )
6404 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6405 matrix_(row_+i,column_+element->index()) += element->value();
6423 template<
typename MT >
6424 template<
typename MT2 >
6430 for(
size_t j=0UL; j<
n_; ++j )
6431 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6432 matrix_(row_+element->index(),column_+j) += element->value();
6450 template<
typename MT >
6451 template<
typename MT2 >
6452 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
6458 const size_t jend( n_ &
size_t(-2) );
6461 for(
size_t i=0UL; i<
m_; ++i ) {
6462 for(
size_t j=0UL; j<jend; j+=2UL ) {
6463 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
6464 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
6467 matrix_(row_+i,column_+jend) -= (~rhs)(i,jend);
6487 template<
typename MT >
6488 template<
typename MT2 >
6489 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
6497 const size_t jend( n_ &
size_t(-IT::size*4) );
6500 for(
size_t i=0UL; i<
m_; ++i ) {
6502 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
6503 store( i, j ,
load(i,j ) - it.load() ); it += IT::size;
6504 store( i, j+IT::size ,
load(i,j+IT::size ) - it.load() ); it += IT::size;
6505 store( i, j+IT::size*2UL,
load(i,j+IT::size*2UL) - it.load() ); it += IT::size;
6506 store( i, j+IT::size*3UL,
load(i,j+IT::size*3UL) - it.load() ); it += IT::size;
6508 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
6529 template<
typename MT >
6530 template<
typename MT2 >
6536 const size_t block( 16UL );
6538 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6539 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6540 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6541 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6542 for(
size_t i=ii; i<iend; ++i ) {
6543 for(
size_t j=jj; j<jend; ++j ) {
6544 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
6566 template<
typename MT >
6567 template<
typename MT2 >
6573 for(
size_t i=0UL; i<
m_; ++i )
6574 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
6575 matrix_(row_+i,column_+element->index()) -= element->value();
6593 template<
typename MT >
6594 template<
typename MT2 >
6600 for(
size_t j=0UL; j<
n_; ++j )
6601 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
6602 matrix_(row_+element->index(),column_+j) -= element->value();
6628 template<
typename MT >
6629 class DenseSubmatrix<MT,
aligned,true> :
public DenseMatrix< DenseSubmatrix<MT,aligned,true>, true >
6635 typedef typename SelectType< IsExpression<MT>::value, MT, MT& >::Type
Operand;
6638 typedef IntrinsicTrait<typename MT::ElementType>
IT;
6649 enum { useConst = IsConst<MT>::value };
6654 typedef DenseSubmatrix<MT,aligned,true>
This;
6655 typedef typename SubmatrixTrait<MT>::Type
ResultType;
6667 typedef typename SelectType< useConst, ConstReference, typename MT::Reference >::Type
Reference;
6673 typedef typename SelectType< useConst, ConstPointer, ElementType* >::Type
Pointer;
6679 typedef typename SelectType< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
6684 enum { vectorizable = MT::vectorizable };
6687 enum { smpAssignable = MT::smpAssignable };
6724 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator+=(
const Matrix<MT2,SO>& rhs );
6725 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator-=(
const Matrix<MT2,SO>& rhs );
6726 template<
typename MT2,
bool SO >
inline DenseSubmatrix& operator*=(
const Matrix<MT2,SO>& rhs );
6728 template<
typename Other >
6729 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
6730 operator*=( Other rhs );
6732 template<
typename Other >
6733 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
6734 operator/=( Other rhs );
6741 inline size_t rows()
const;
6742 inline size_t columns()
const;
6743 inline size_t spacing()
const;
6745 inline size_t capacity(
size_t i )
const;
6747 inline size_t nonZeros(
size_t i )
const;
6748 inline void reset();
6749 inline void reset(
size_t i );
6751 template<
typename Other >
inline DenseSubmatrix& scale( Other scalar );
6758 template<
typename MT2 >
6759 struct VectorizedAssign {
6760 enum { value = vectorizable && MT2::vectorizable &&
6761 IsSame<ElementType,typename MT2::ElementType>::value };
6767 template<
typename MT2 >
6768 struct VectorizedAddAssign {
6769 enum { value = vectorizable && MT2::vectorizable &&
6770 IsSame<ElementType,typename MT2::ElementType>::value &&
6771 IntrinsicTrait<ElementType>::addition };
6777 template<
typename MT2 >
6778 struct VectorizedSubAssign {
6779 enum { value = vectorizable && MT2::vectorizable &&
6780 IsSame<ElementType,typename MT2::ElementType>::value &&
6781 IntrinsicTrait<ElementType>::subtraction };
6789 template<
typename Other >
6790 inline bool canAlias(
const Other* alias )
const;
6792 template<
typename MT2,
bool AF2,
bool SO2 >
6793 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
6795 template<
typename Other >
6796 inline bool isAliased(
const Other* alias )
const;
6798 template<
typename MT2,
bool AF2,
bool SO2 >
6799 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
6810 template<
typename MT2 >
6811 inline typename DisableIf< VectorizedAssign<MT2> >::Type
6812 assign(
const DenseMatrix<MT2,true>& rhs );
6814 template<
typename MT2 >
6815 inline typename EnableIf< VectorizedAssign<MT2> >::Type
6816 assign(
const DenseMatrix<MT2,true>& rhs );
6818 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
6819 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
6820 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
6822 template<
typename MT2 >
6823 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
6824 addAssign(
const DenseMatrix<MT2,true>& rhs );
6826 template<
typename MT2 >
6827 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
6828 addAssign(
const DenseMatrix<MT2,true>& rhs );
6830 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
6831 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
6832 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
6834 template<
typename MT2 >
6835 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
6836 subAssign(
const DenseMatrix<MT2,true>& rhs );
6838 template<
typename MT2 >
6839 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
6840 subAssign(
const DenseMatrix<MT2,true>& rhs );
6842 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
6843 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
6844 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
6861 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
6863 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
6864 friend const DenseSubmatrix<MT2,AF1,SO2>
6865 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
6867 template<
typename MT2,
bool AF2,
bool SO2 >
6868 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
6870 template<
typename MT2,
bool AF2,
bool SO2 >
6871 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
6873 template<
typename MT2,
bool AF2,
bool SO2 >
6874 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
6911 template<
typename MT >
6919 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
6920 throw std::invalid_argument(
"Invalid submatrix specification" );
6922 if( row % IT::size != 0UL || (
row_ + m_ !=
matrix_.rows() && m_ % IT::size != 0UL ) )
6923 throw std::invalid_argument(
"Invalid submatrix alignment" );
6945 template<
typename MT >
6952 return matrix_(row_+i,column_+j);
6966 template<
typename MT >
6973 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
6989 template<
typename MT >
6992 return matrix_.data() + row_ + column_*
spacing();
7008 template<
typename MT >
7009 inline typename DenseSubmatrix<MT,aligned,true>::ConstPointer
7012 return matrix_.data() + row_ + column_*
spacing();
7025 template<
typename MT >
7030 return ( matrix_.begin( column_ + j ) + row_ );
7043 template<
typename MT >
7048 return ( matrix_.cbegin( column_ + j ) + row_ );
7061 template<
typename MT >
7066 return ( matrix_.cbegin( column_ + j ) + row_ );
7079 template<
typename MT >
7084 return ( matrix_.begin( column_ + j ) + row_ +
m_ );
7097 template<
typename MT >
7102 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
7115 template<
typename MT >
7120 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
7141 template<
typename MT >
7142 inline DenseSubmatrix<MT,aligned,true>&
7145 const size_t iend( row_ + m_ );
7146 const size_t jend( column_ + n_ );
7148 for(
size_t j=column_; j<jend; ++j )
7149 for(
size_t i=row_; i<iend; ++i )
7170 template<
typename MT >
7171 inline DenseSubmatrix<MT,aligned,true>&
7177 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
7180 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
7181 throw std::invalid_argument(
"Submatrix sizes do not match" );
7183 if( rhs.canAlias( &matrix_ ) ) {
7188 if( IsSparseMatrix<MT>::value )
7210 template<
typename MT >
7211 template<
typename MT2
7213 inline DenseSubmatrix<MT,aligned,true>&
7219 throw std::invalid_argument(
"Matrix sizes do not match" );
7221 if( IsSparseMatrix<MT2>::value )
7224 if( (~rhs).canAlias( &matrix_ ) ) {
7249 template<
typename MT >
7250 template<
typename MT2
7252 inline DenseSubmatrix<MT,aligned,true>&
7253 DenseSubmatrix<MT,aligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
7258 throw std::invalid_argument(
"Matrix sizes do not match" );
7260 if( (~rhs).canAlias( &matrix_ ) ) {
7285 template<
typename MT >
7286 template<
typename MT2
7288 inline DenseSubmatrix<MT,aligned,true>&
7289 DenseSubmatrix<MT,aligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
7294 throw std::invalid_argument(
"Matrix sizes do not match" );
7296 if( (~rhs).canAlias( &matrix_ ) ) {
7321 template<
typename MT >
7322 template<
typename MT2
7324 inline DenseSubmatrix<MT,aligned,true>&
7325 DenseSubmatrix<MT,aligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
7328 throw std::invalid_argument(
"Matrix sizes do not match" );
7330 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
7335 const MultType tmp( *
this * (~rhs) );
7336 if( IsSparseMatrix<MultType>::value )
7354 template<
typename MT >
7355 template<
typename Other >
7356 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
7357 DenseSubmatrix<MT,aligned,true>::operator*=( Other rhs )
7374 template<
typename MT >
7375 template<
typename Other >
7376 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
7377 DenseSubmatrix<MT,aligned,true>::operator/=( Other rhs )
7402 template<
typename MT >
7417 template<
typename MT >
7435 template<
typename MT >
7438 return matrix_.spacing();
7450 template<
typename MT >
7466 template<
typename MT >
7485 template<
typename MT >
7488 const size_t iend( row_ + m_ );
7489 const size_t jend( column_ + n_ );
7490 size_t nonzeros( 0UL );
7492 for(
size_t j=column_; j<jend; ++j )
7493 for(
size_t i=row_; i<iend; ++i )
7510 template<
typename MT >
7515 const size_t iend( row_ + m_ );
7516 size_t nonzeros( 0UL );
7518 for(
size_t i=row_; i<iend; ++i )
7519 if( !
isDefault( matrix_(i,column_+j) ) )
7534 template<
typename MT >
7539 const size_t iend( row_ + m_ );
7540 const size_t jend( column_ + n_ );
7542 for(
size_t j=column_; j<jend; ++j )
7543 for(
size_t i=row_; i<iend; ++i )
7544 reset( matrix_(i,j) );
7557 template<
typename MT >
7564 const size_t iend( row_ + m_ );
7565 for(
size_t i=row_; i<iend; ++i )
7566 reset( matrix_(i,column_+j) );
7583 template<
typename MT >
7587 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
7604 template<
typename MT >
7605 template<
typename Other >
7606 inline DenseSubmatrix<MT,aligned,true>& DenseSubmatrix<MT,aligned,true>::scale( Other scalar )
7608 const size_t iend( row_ + m_ );
7609 const size_t jend( column_ + n_ );
7611 for(
size_t j=column_; j<jend; ++j )
7612 for(
size_t i=row_; i<iend; ++i )
7613 matrix_(i,j) *= scalar;
7640 template<
typename MT >
7641 template<
typename Other >
7644 return matrix_.isAliased( alias );
7661 template<
typename MT >
7662 template<
typename MT2
7667 return ( matrix_.isAliased( &alias->matrix_ ) &&
7668 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7669 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7686 template<
typename MT >
7687 template<
typename Other >
7690 return matrix_.isAliased( alias );
7707 template<
typename MT >
7708 template<
typename MT2
7713 return ( matrix_.isAliased( &alias->matrix_ ) &&
7714 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
7715 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
7731 template<
typename MT >
7751 template<
typename MT >
7776 template<
typename MT >
7777 inline typename DenseSubmatrix<MT,aligned,true>::IntrinsicType
7786 return matrix_.load( row_+i, column_+j );
7808 template<
typename MT >
7809 inline typename DenseSubmatrix<MT,aligned,true>::IntrinsicType
7818 return matrix_.loadu( row_+i, column_+j );
7840 template<
typename MT >
7849 matrix_.store( row_+i, column_+j, value );
7872 template<
typename MT >
7881 matrix_.storeu( row_+i, column_+j, value );
7904 template<
typename MT >
7913 matrix_.stream( row_+i, column_+j, value );
7931 template<
typename MT >
7932 template<
typename MT2 >
7933 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
7939 const size_t iend( m_ &
size_t(-2) );
7942 for(
size_t j=0UL; j<
n_; ++j ) {
7943 for(
size_t i=0UL; i<iend; i+=2UL ) {
7944 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
7945 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
7948 matrix_(row_+iend,column_+j) = (~rhs)(iend,j);
7968 template<
typename MT >
7969 template<
typename MT2 >
7970 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
7980 !(~rhs).isAliased( &matrix_ ) )
7982 for(
size_t j=0UL; j<
n_; ++j )
7983 for(
size_t i=0UL; i<
m_; i+=IT::size )
7988 const size_t iend( m_ &
size_t(-IT::size*4) );
7991 for(
size_t j=0UL; j<
n_; ++j ) {
7993 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
7994 store( i , j, it.load() ); it += IT::size;
7995 store( i+IT::size , j, it.load() ); it += IT::size;
7996 store( i+IT::size*2UL, j, it.load() ); it += IT::size;
7997 store( i+IT::size*3UL, j, it.load() ); it += IT::size;
7999 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
8000 store( i, j, it.load() );
8021 template<
typename MT >
8022 template<
typename MT2 >
8028 const size_t block( 16UL );
8030 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8031 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8032 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8033 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8034 for(
size_t j=jj; j<jend; ++j ) {
8035 for(
size_t i=ii; i<iend; ++i ) {
8036 matrix_(row_+i,column_+j) = (~rhs)(i,j);
8058 template<
typename MT >
8059 template<
typename MT2 >
8065 for(
size_t j=0UL; j<
n_; ++j )
8066 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
8067 matrix_(row_+element->index(),column_+j) = element->value();
8085 template<
typename MT >
8086 template<
typename MT2 >
8092 for(
size_t i=0UL; i<
m_; ++i )
8093 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
8094 matrix_(row_+i,column_+element->index()) = element->value();
8112 template<
typename MT >
8113 template<
typename MT2 >
8114 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
8120 const size_t iend( m_ &
size_t(-2) );
8123 for(
size_t j=0UL; j<
n_; ++j ) {
8124 for(
size_t i=0UL; i<iend; i+=2UL ) {
8125 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
8126 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
8129 matrix_(row_+iend,column_+j) += (~rhs)(iend,j);
8149 template<
typename MT >
8150 template<
typename MT2 >
8151 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
8159 const size_t iend( m_ &
size_t(-IT::size*4) );
8162 for(
size_t j=0UL; j<
n_; ++j ) {
8164 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
8165 store( i , j,
load(i ,j) + it.load() ); it += IT::size;
8166 store( i+IT::size , j,
load(i+IT::size ,j) + it.load() ); it += IT::size;
8167 store( i+IT::size*2UL, j,
load(i+IT::size*2UL,j) + it.load() ); it += IT::size;
8168 store( i+IT::size*3UL, j,
load(i+IT::size*3UL,j) + it.load() ); it += IT::size;
8170 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
8191 template<
typename MT >
8192 template<
typename MT2 >
8198 const size_t block( 16UL );
8200 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8201 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8202 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8203 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8204 for(
size_t j=jj; j<jend; ++j ) {
8205 for(
size_t i=ii; i<iend; ++i ) {
8206 matrix_(row_+i,column_+j) += (~rhs)(i,j);
8228 template<
typename MT >
8229 template<
typename MT2 >
8235 for(
size_t j=0UL; j<
n_; ++j )
8236 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
8237 matrix_(row_+element->index(),column_+j) += element->value();
8255 template<
typename MT >
8256 template<
typename MT2 >
8262 for(
size_t i=0UL; i<
m_; ++i )
8263 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
8264 matrix_(row_+i,column_+element->index()) += element->value();
8282 template<
typename MT >
8283 template<
typename MT2 >
8284 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
8290 const size_t iend( m_ &
size_t(-2) );
8293 for(
size_t j=0UL; j<
n_; ++j ) {
8294 for(
size_t i=0UL; i<iend; i+=2UL ) {
8295 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
8296 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
8299 matrix_(row_+iend,column_+j) -= (~rhs)(iend,j);
8319 template<
typename MT >
8320 template<
typename MT2 >
8321 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
8329 const size_t iend( m_ &
size_t(-IT::size*4) );
8332 for(
size_t j=0UL; j<
n_; ++j ) {
8334 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
8335 store( i , j,
load(i ,j) - it.load() ); it += IT::size;
8336 store( i+IT::size , j,
load(i+IT::size ,j) - it.load() ); it += IT::size;
8337 store( i+IT::size*2UL, j,
load(i+IT::size*2UL,j) - it.load() ); it += IT::size;
8338 store( i+IT::size*3UL, j,
load(i+IT::size*3UL,j) - it.load() ); it += IT::size;
8340 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
8361 template<
typename MT >
8362 template<
typename MT2 >
8368 const size_t block( 16UL );
8370 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
8371 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
8372 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
8373 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
8374 for(
size_t j=jj; j<jend; ++j ) {
8375 for(
size_t i=ii; i<iend; ++i ) {
8376 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
8398 template<
typename MT >
8399 template<
typename MT2 >
8405 for(
size_t j=0UL; j<
n_; ++j )
8406 for(
typename MT2::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
8407 matrix_(row_+element->index(),column_+j) -= element->value();
8425 template<
typename MT >
8426 template<
typename MT2 >
8432 for(
size_t i=0UL; i<
m_; ++i )
8433 for(
typename MT2::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
8434 matrix_(row_+i,column_+element->index()) -= element->value();
8455 template<
typename MT,
bool AF,
bool SO >
8456 inline void reset( DenseSubmatrix<MT,AF,SO>& dm );
8458 template<
typename MT,
bool AF,
bool SO >
8459 inline void clear( DenseSubmatrix<MT,AF,SO>& dm );
8461 template<
typename MT,
bool AF,
bool SO >
8462 inline bool isDefault(
const DenseSubmatrix<MT,AF,SO>& dm );
8464 template<
typename MT,
bool AF,
bool SO >
8465 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseMatrix<MT,SO>& b );
8467 template<
typename MT,
bool AF,
bool SO >
8468 inline bool isSame(
const DenseMatrix<MT,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
8470 template<
typename MT,
bool AF,
bool SO >
8471 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
8483 template<
typename MT
8502 template<
typename MT
8530 template<
typename MT
8538 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
8539 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
8544 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
8545 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
8567 template<
typename MT,
bool AF,
bool SO >
8570 return (
isSame( a.matrix_, ~b ) && ( a.rows() == (~b).
rows() ) && ( a.columns() == (~b).
columns() ) );
8587 template<
typename MT,
bool AF,
bool SO >
8590 return (
isSame( ~a, b.matrix_ ) && ( (~a).rows() == b.rows() ) && ( (~a).columns() == b.columns() ) );
8607 template<
typename MT,
bool AF,
bool SO >
8610 return (
isSame( a.matrix_, b.matrix_ ) &&
8611 ( a.row_ == b.row_ ) && ( a.column_ == b.column_ ) &&
8612 ( a.m_ == b.m_ ) && ( a.n_ == b.n_ ) );
8644 inline const DenseSubmatrix<MT,AF1,SO>
8645 submatrix(
const DenseSubmatrix<MT,AF2,SO>& dm,
size_t row,
size_t column,
size_t m,
size_t n )
8649 if( ( row + m > dm.rows() ) || ( column + n > dm.columns() ) )
8650 throw std::invalid_argument(
"Invalid submatrix specification" );
8652 return DenseSubmatrix<MT,AF1,SO>( dm.matrix_, dm.row_ +
row, dm.column_ +
column, m, n );
8668 template<
typename MT,
bool AF,
bool SO >
8669 struct SubmatrixTrait< DenseSubmatrix<MT,AF,SO> >
8687 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
8688 struct SubmatrixExprTrait< DenseSubmatrix<MT,AF1,SO>, AF2 >
8690 typedef DenseSubmatrix<MT,AF2,SO> Type;
8698 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
8699 struct SubmatrixExprTrait< const DenseSubmatrix<MT,AF1,SO>, AF2 >
8701 typedef DenseSubmatrix<MT,AF2,SO> Type;
8709 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
8710 struct SubmatrixExprTrait< volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
8712 typedef DenseSubmatrix<MT,AF2,SO> Type;
8720 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
8721 struct SubmatrixExprTrait< const volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
8723 typedef DenseSubmatrix<MT,AF2,SO> Type;
8739 template<
typename MT,
bool AF,
bool SO >
8740 struct RowTrait< DenseSubmatrix<MT,AF,SO> >
8758 template<
typename MT,
bool AF,
bool SO >
8759 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:724
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:2041
Constraint on the data type.
DenseSubmatrix & transpose()
Transposing the submatrix.
Definition: DenseSubmatrix.h:1700
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubmatrix.h:454
ReferenceType reference
Reference return type.
Definition: DenseSubmatrix.h:457
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:905
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubmatrix.h:908
bool canAlias(const Other *alias) const
Returns whether the submatrix can alias with the given address alias.
Definition: DenseSubmatrix.h:1758
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#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
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:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
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:427
Header file for the subtraction trait.
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubmatrix.h:451
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubmatrix.h:458
Header file for the row trait.
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:152
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:117
Header file for the IsSparseMatrix type trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
#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:1019
bool operator<=(const SubmatrixIterator &rhs) const
Less-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:646
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
DenseSubmatrix(Operand matrix, size_t row, size_t column, size_t m, size_t n)
The constructor for DenseSubmatrix.
Definition: DenseSubmatrix.h:983
bool isAligned() const
Returns whether the submatrix is properly aligned in memory.
Definition: DenseSubmatrix.h:1848
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: DenseSubmatrix.h:1173
bool isAliased(const Other *alias) const
Returns whether the submatrix is aliased with the given address alias.
Definition: DenseSubmatrix.h:1804
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:1221
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2555
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubmatrix.h:548
const size_t n_
The number of columns of the submatrix.
Definition: DenseSubmatrix.h:907
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:904
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:84
#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:249
SubmatrixIterator(IteratorType iterator, IteratorType final, size_t rest, bool isAligned)
Constructor for the SubmatrixIterator class.
Definition: DenseSubmatrix.h:469
const ElementType * ConstPointer
Pointer to a constant submatrix value.
Definition: DenseSubmatrix.h:424
void reset()
Reset to the default initial values.
Definition: DenseSubmatrix.h:1646
MT::ElementType ElementType
Type of the submatrix elements.
Definition: DenseSubmatrix.h:412
size_t columns() const
Returns the number of columns of the dense submatrix.
Definition: DenseSubmatrix.h:1517
#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
Pointer data()
Low-level data access to the submatrix elements.
Definition: DenseSubmatrix.h:1062
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1150
size_t rows() const
Returns the number of rows of the dense submatrix.
Definition: DenseSubmatrix.h:1502
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
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:409
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
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:692
SelectType< IsExpression< MT >::value, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseSubmatrix.h:389
DenseSubmatrix & operator=(const ElementType &rhs)
Homogenous assignment to all submatrix elements.
Definition: DenseSubmatrix.h:1247
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:409
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1102
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
void smpAddAssign(DenseMatrix< 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:122
ValueType value_type
Type of the underlying elements.
Definition: DenseSubmatrix.h:455
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:624
std::iterator_traits< IteratorType >::reference ReferenceType
Reference return type.
Definition: DenseSubmatrix.h:448
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:1922
SelectType< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant submatrix value.
Definition: DenseSubmatrix.h:421
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 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:563
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:721
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
SubmatrixIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubmatrix.h:483
Header file for the Or class template.
bool operator==(const SubmatrixIterator &rhs) const
Equality comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:602
Constraint on the data type.
Header file for the DenseMatrix base class.
const DenseSubmatrix & CompositeType
Data type for composite expression templates.
Definition: DenseSubmatrix.h:415
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a plain dense ...
Definition: Thresholds.h:690
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:271
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the matrix element type.
Definition: DenseSubmatrix.h:392
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:1895
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:613
Constraints on the storage order of matrix types.
const SubmatrixIterator operator++(int)
Post-increment operator.
Definition: DenseSubmatrix.h:517
SubmatrixIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubmatrix.h:495
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubmatrix.h:411
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2406
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubmatrix.h:909
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:442
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
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:216
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:903
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
IteratorType iterator_
Iterator to the current submatrix element.
Definition: DenseSubmatrix.h:711
Header file for the IsNumeric type trait.
DenseSubmatrix< MT, AF, SO > This
Type of this DenseSubmatrix instance.
Definition: DenseSubmatrix.h:408
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:714
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
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:2407
Header file for the IsConst type trait.
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:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense submatrix.
Definition: DenseSubmatrix.h:578
Header file for run time assertion macros.
DifferenceType operator-(const SubmatrixIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubmatrix.h:668
Base template for the MultTrait class.
Definition: MultTrait.h:141
Header file for the addition trait.
Header file for the division trait.
SubmatrixIterator & operator++()
Pre-increment operator.
Definition: DenseSubmatrix.h:506
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubmatrix.h:414
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:301
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:434
Header file for the reset shim.
const bool isAligned_
Memory alignment flag.
Definition: DenseSubmatrix.h:914
Header file for the AlignedArray implementation.
Header file for the cache size of the target architecture.
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:331
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubmatrix.h:439
bool operator>(const SubmatrixIterator &rhs) const
Greater-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:635
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
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:410
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
PointerType pointer
Pointer return type.
Definition: DenseSubmatrix.h:456
size_t capacity() const
Returns the maximum capacity of the dense submatrix.
Definition: DenseSubmatrix.h:1552
#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:538
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:712
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:1995
Header file for all intrinsic functionality.
size_t nonZeros() const
Returns the number of non-zero elements in the dense submatrix.
Definition: DenseSubmatrix.h:1592
IT::Type IntrinsicType
Intrinsic type of the submatrix elements.
Definition: DenseSubmatrix.h:413
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2556
MT::ConstReference ConstReference
Reference to a constant submatrix value.
Definition: DenseSubmatrix.h:418
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:136
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:907
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:250
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubmatrix.h:713
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubmatrix.h:445
#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:2403
View on a specific submatrix of a dense matrix.The DenseSubmatrix template represents a view on a spe...
Definition: DenseSubmatrix.h:383
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
bool canSMPAssign() const
Returns whether the submatrix can be used in SMP assignments.
Definition: DenseSubmatrix.h:1868
Header file for basic type definitions.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DenseSubmatrix.h:1537
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:2409
Header file for the Submatrix base class.
const size_t m_
The number of rows of the submatrix.
Definition: DenseSubmatrix.h:906
#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:1969
friend const SubmatrixIterator operator-(const SubmatrixIterator &it, size_t dec)
Subtraction between a SubmatrixIterator and an integral value.
Definition: DenseSubmatrix.h:704
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
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:154
SubmatrixIterator & operator--()
Pre-decrement operator.
Definition: DenseSubmatrix.h:527
#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:657
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:680
Constraint on the data type.
Header file for the FunctionTrace class.