35 #ifndef _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
36 #define _BLAZE_MATH_VIEWS_DENSESUBMATRIX_H_
471 template<
typename MT
473 ,
bool SO = IsColumnMajorMatrix<MT>::value >
524 template<
typename IteratorType >
533 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
536 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
539 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
542 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
572 size_t remainingElements,
bool isMemoryAligned )
574 ,
final_ ( finalIterator )
575 ,
rest_ ( remainingElements )
585 template<
typename IteratorType2 >
680 inline IntrinsicType
load()
const {
695 inline IntrinsicType
loadu()
const {
704 for(
size_t j=0UL; j<
rest_; ++j )
706 for(
size_t j=rest_; j<
IT::size; ++j )
831 inline IteratorType
base()
const {
841 inline IteratorType
final()
const {
886 enum { vectorizable = MT::vectorizable };
889 enum { smpAssignable = MT::smpAssignable };
907 inline Reference
operator()(
size_t i,
size_t j );
908 inline ConstReference
operator()(
size_t i,
size_t j )
const;
909 inline Pointer
data ();
910 inline ConstPointer
data ()
const;
911 inline Iterator
begin (
size_t i );
912 inline ConstIterator
begin (
size_t i )
const;
913 inline ConstIterator
cbegin(
size_t i )
const;
914 inline Iterator
end (
size_t i );
915 inline ConstIterator
end (
size_t i )
const;
916 inline ConstIterator
cend (
size_t i )
const;
926 template<
typename MT2,
bool SO2 >
929 template<
typename MT2,
bool SO2 >
930 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
931 operator+=(
const Matrix<MT2,SO2>& rhs );
933 template<
typename MT2,
bool SO2 >
934 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
935 operator+=(
const Matrix<MT2,SO2>& rhs );
937 template<
typename MT2,
bool SO2 >
938 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
939 operator-=(
const Matrix<MT2,SO2>& rhs );
941 template<
typename MT2,
bool SO2 >
942 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
943 operator-=(
const Matrix<MT2,SO2>& rhs );
945 template<
typename MT2,
bool SO2 >
948 template<
typename Other >
949 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
950 operator*=( Other rhs );
952 template<
typename Other >
953 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
954 operator/=( Other rhs );
961 inline size_t rows()
const;
965 inline size_t capacity(
size_t i )
const;
967 inline size_t nonZeros(
size_t i )
const;
969 inline void reset(
size_t i );
971 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
978 template<
typename MT2 >
980 struct VectorizedAssign {
981 enum { value = vectorizable && MT2::vectorizable &&
982 IsSame<ElementType,typename MT2::ElementType>::value };
989 template<
typename MT2 >
991 struct VectorizedAddAssign {
992 enum { value = vectorizable && MT2::vectorizable &&
993 IsSame<ElementType,typename MT2::ElementType>::value &&
994 IntrinsicTrait<ElementType>::addition };
1001 template<
typename MT2 >
1003 struct VectorizedSubAssign {
1004 enum { value = vectorizable && MT2::vectorizable &&
1005 IsSame<ElementType,typename MT2::ElementType>::value &&
1006 IntrinsicTrait<ElementType>::subtraction };
1015 template<
typename Other >
1016 inline bool canAlias(
const Other* alias )
const;
1018 template<
typename MT2,
bool AF2,
bool SO2 >
1019 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
1021 template<
typename Other >
1022 inline bool isAliased(
const Other* alias )
const;
1024 template<
typename MT2,
bool AF2,
bool SO2 >
1025 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
1030 inline IntrinsicType
load (
size_t i,
size_t j )
const;
1031 inline IntrinsicType
loadu(
size_t i,
size_t j )
const;
1033 inline void store (
size_t i,
size_t j,
const IntrinsicType& value );
1034 inline void storeu(
size_t i,
size_t j,
const IntrinsicType& value );
1035 inline void stream(
size_t i,
size_t j,
const IntrinsicType& value );
1037 template<
typename MT2 >
1038 inline typename DisableIf< VectorizedAssign<MT2> >::Type
1039 assign(
const DenseMatrix<MT2,SO>& rhs );
1041 template<
typename MT2 >
1042 inline typename EnableIf< VectorizedAssign<MT2> >::Type
1043 assign(
const DenseMatrix<MT2,SO>& rhs );
1045 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,!SO>& rhs );
1046 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,SO>& rhs );
1047 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,!SO>& rhs );
1049 template<
typename MT2 >
1050 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
1051 addAssign(
const DenseMatrix<MT2,SO>& rhs );
1053 template<
typename MT2 >
1054 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
1055 addAssign(
const DenseMatrix<MT2,SO>& rhs );
1057 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,!SO>& rhs );
1058 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,SO>& rhs );
1059 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,!SO>& rhs );
1061 template<
typename MT2 >
1062 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
1063 subAssign(
const DenseMatrix<MT2,SO>& rhs );
1065 template<
typename MT2 >
1066 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
1067 subAssign(
const DenseMatrix<MT2,SO>& rhs );
1069 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,!SO>& rhs );
1070 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,SO>& rhs );
1071 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,!SO>& rhs );
1081 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
1082 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
1083 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
1085 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
1086 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1087 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
1089 template<
typename MT2,
bool SO2,
typename MT3 >
1090 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1091 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
1093 template<
typename MT2,
bool SO2,
typename MT3 >
1094 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1095 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
1097 template<
typename MT2,
bool SO2,
typename MT3 >
1098 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1099 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
1101 template<
typename MT2,
bool SO2,
typename MT3 >
1102 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1103 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
1105 template<
typename MT2,
bool SO2,
typename MT3 >
1106 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1107 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
1109 template<
typename MT2,
bool SO2,
typename MT3 >
1110 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1111 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
1113 template<
typename MT2,
bool SO2,
typename MT3 >
1114 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1115 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
1117 template<
typename MT2,
bool SO2,
typename MT3 >
1118 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
1119 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
1121 template<
typename MT2,
bool SO2,
typename MT3 >
1122 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
1123 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
1125 template<
typename MT2,
bool SO2,
typename MT3 >
1126 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
1127 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
1129 template<
typename MT2,
bool SO2,
typename MT3 >
1130 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
1131 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
1133 template<
typename MT2,
bool SO2,
typename MT3 >
1134 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
1135 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
1168 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
1170 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
1174 template<
typename MT2,
bool AF2,
bool SO2 >
1177 template<
typename MT2,
bool AF2,
bool SO2 >
1180 template<
typename MT2,
bool AF2,
bool SO2 >
1183 template<
typename MT2,
bool AF2,
bool SO2 >
1186 template<
typename MT2,
bool AF2,
bool SO2 >
1189 template<
typename MT2,
bool AF2,
bool SO2 >
1192 template<
typename MT2,
bool AF2,
bool SO2 >
1235 template<
typename MT
1239 : matrix_ ( matrix )
1241 , column_ ( column )
1245 , final_ ( n - rest_ )
1246 , isAligned_( ( column %
IT::
size == 0UL ) &&
1249 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
1250 throw std::invalid_argument(
"Invalid submatrix specification" );
1270 template<
typename MT
1279 return matrix_(row_+i,column_+j);
1291 template<
typename MT
1300 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
1314 template<
typename MT
1319 return matrix_.data() + row_*
spacing() + column_;
1333 template<
typename MT
1338 return matrix_.data() + row_*
spacing() + column_;
1354 template<
typename MT
1360 const typename MT::Iterator first( matrix_.begin( row_ + i ) + column_ );
1361 return Iterator( first, first + final_, rest_, isAligned_ );
1377 template<
typename MT
1385 return ConstIterator( first, first + final_, rest_, isAligned_ );
1401 template<
typename MT
1409 return ConstIterator( first, first + final_, rest_, isAligned_ );
1425 template<
typename MT
1431 const typename MT::Iterator last( matrix_.begin( row_ + i ) + column_ +
n_ );
1432 return Iterator( last, last, rest_, isAligned_ );
1448 template<
typename MT
1472 template<
typename MT
1503 template<
typename MT
1508 const size_t iend( row_ +
m_ );
1510 for(
size_t i=row_; i<iend; ++i )
1514 ?(
max( i+1UL, column_ ) )
1515 :(
max( i, column_ ) ) )
1519 ?(
min( i, column_+
n_ ) )
1520 :(
min( i+1UL, column_+
n_ ) ) )
1523 for(
size_t j=jbegin; j<jend; ++j )
1546 template<
typename MT
1554 if(
this == &rhs || ( &matrix_ == &rhs.
matrix_ && row_ == rhs.
row_ && column_ == rhs.
column_ ) )
1558 throw std::invalid_argument(
"Submatrix sizes do not match" );
1560 if( !preservesInvariant( matrix_, rhs ) )
1561 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1596 template<
typename MT
1599 template<
typename MT2
1606 throw std::invalid_argument(
"Matrix sizes do not match" );
1609 Right right( ~rhs );
1611 if( !preservesInvariant( matrix_, right ) )
1612 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1649 template<
typename MT
1652 template<
typename MT2
1668 throw std::invalid_argument(
"Matrix sizes do not match" );
1670 if( !preservesInvariant( matrix_, ~rhs ) )
1671 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1676 const AddType tmp( *
this + (~rhs) );
1705 template<
typename MT
1708 template<
typename MT2
1724 throw std::invalid_argument(
"Matrix sizes do not match" );
1726 const AddType tmp( *
this + (~rhs) );
1728 if( !preservesInvariant( matrix_, tmp ) )
1729 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1757 template<
typename MT
1760 template<
typename MT2
1762 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
1776 throw std::invalid_argument(
"Matrix sizes do not match" );
1778 if( !preservesInvariant( matrix_, ~rhs ) )
1779 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1784 const SubType tmp( *
this - (~rhs ) );
1813 template<
typename MT
1816 template<
typename MT2
1818 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
1832 throw std::invalid_argument(
"Matrix sizes do not match" );
1834 const SubType tmp( *
this - (~rhs) );
1836 if( !preservesInvariant( matrix_, tmp ) )
1837 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1865 template<
typename MT
1868 template<
typename MT2
1882 throw std::invalid_argument(
"Matrix sizes do not match" );
1884 const MultType tmp( *
this * (~rhs) );
1886 if( !preservesInvariant( matrix_, tmp ) )
1887 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
1912 template<
typename MT
1915 template<
typename Other >
1941 template<
typename MT
1944 template<
typename Other >
1973 template<
typename MT
1988 template<
typename MT
2008 template<
typename MT
2013 return matrix_.spacing();
2023 template<
typename MT
2044 template<
typename MT
2063 template<
typename MT
2068 const size_t iend( row_ +
m_ );
2069 const size_t jend( column_ +
n_ );
2070 size_t nonzeros( 0UL );
2072 for(
size_t i=row_; i<iend; ++i )
2073 for(
size_t j=column_; j<jend; ++j )
2093 template<
typename MT
2100 const size_t jend( column_ +
n_ );
2101 size_t nonzeros( 0UL );
2103 for(
size_t j=column_; j<jend; ++j )
2117 template<
typename MT
2124 for(
size_t i=row_; i<row_+
m_; ++i )
2128 ?(
max( i+1UL, column_ ) )
2129 :(
max( i, column_ ) ) )
2133 ?(
min( i, column_+
n_ ) )
2134 :(
min( i+1UL, column_+
n_ ) ) )
2137 for(
size_t j=jbegin; j<jend; ++j )
2138 clear( matrix_(i,j) );
2155 template<
typename MT
2166 ?(
max( i+1UL, column_ ) )
2167 :(
max( i, column_ ) ) )
2171 ?(
min( i, column_+
n_ ) )
2172 :(
min( i+1UL, column_+
n_ ) ) )
2175 for(
size_t j=jbegin; j<jend; ++j )
2176 clear( matrix_(row_+i,j) );
2196 template<
typename MT
2202 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
2205 throw std::runtime_error(
"Invalid transpose of a lower matrix" );
2208 throw std::runtime_error(
"Invalid transpose of an upper matrix" );
2229 template<
typename MT
2232 template<
typename Other >
2237 const size_t iend( row_ +
m_ );
2239 for(
size_t i=row_; i<iend; ++i )
2243 ?(
max( i+1UL, column_ ) )
2244 :(
max( i, column_ ) ) )
2248 ?(
min( i, column_+
n_ ) )
2249 :(
min( i+1UL, column_+
n_ ) ) )
2252 for(
size_t j=jbegin; j<jend; ++j )
2253 matrix_(i,j) *= scalar;
2270 template<
typename MT
2277 if( ( row_ +
m_ <= column_ ) || ( column_ +
n_ <= row_ ) )
2295 template<
typename MT
2298 template<
typename MT2
2323 template<
typename MT
2326 template<
typename MT2
2340 const bool lower( row_ > column_ );
2341 const size_t size (
min( row_ +
m_, column_ +
n_ ) - ( lower ? row_ : column_ ) );
2346 const size_t row ( lower ? 0UL : column_ - row_ );
2347 const size_t column( lower ? row_ - column_ : 0UL );
2366 template<
typename MT
2369 template<
typename MT2
2379 if( row_ + 1UL >= column_ +
n_ )
2383 ?( column_ +
n_ - row_ )
2384 :( column_ +
n_ - row_ - 1UL ) );
2385 const size_t iend(
min( ipos,
m_ ) );
2387 for(
size_t i=0UL; i<iend; ++i )
2389 const bool containsDiagonal( row_+i >= column_ );
2394 const size_t jbegin( ( containsDiagonal )
2396 ?( row_ + i - column_ )
2397 :( row_ + i - column_ + 1UL ) )
2400 for(
size_t j=jbegin; j<
n_; ++j ) {
2423 template<
typename MT
2426 template<
typename MT2
2429 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2436 if( row_ + 1UL >= column_ +
n_ )
2441 :( row_ - column_ + 1UL ) );
2442 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
2444 for(
size_t j=jbegin; j<
n_; ++j )
2446 const bool containsDiagonal( column_+j < row_+
m_ );
2449 ?( column_ + j - row_ + 1UL )
2450 :( column_ + j - row_ ) );
2451 const size_t iend(
min( ipos,
m_ ) );
2453 for(
size_t i=0UL; i<iend; ++i ) {
2479 template<
typename MT
2482 template<
typename MT2
2485 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2494 if( row_ + 1UL >= column_ +
n_ )
2498 ?( column_ +
n_ - row_ )
2499 :( column_ +
n_ - row_ - 1UL ) );
2500 const size_t iend(
min( ipos,
m_ ) );
2502 for(
size_t i=0UL; i<iend; ++i )
2504 const bool containsDiagonal( row_+i >= column_ );
2506 const size_t index( ( containsDiagonal )
2508 ?( row_ + i - column_ )
2509 :( row_ + i - column_ + 1UL ) )
2512 const RhsIterator last( (~rhs).
end(i) );
2513 RhsIterator element( (~rhs).lowerBound( i, index ) );
2516 if( element == last || ( element->index() != row_+i-column_ ) || !
isOne( element->value() ) )
2521 for( ; element!=last; ++element ) {
2544 template<
typename MT
2547 template<
typename MT2
2550 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2559 if( row_ + 1UL >= column_ +
n_ )
2564 :( row_ - column_ + 1UL ) );
2565 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
2567 for(
size_t j=jbegin; j<
n_; ++j )
2569 const bool containsDiagonal( column_+j < row_+
m_ );
2572 ?( column_ + j - row_ + 1UL )
2573 :( column_ + j - row_ ) );
2574 const RhsIterator last( (~rhs).lowerBound(
min( index,
m_ ), j ) );
2577 ( last == (~rhs).
end(j) || ( last->index() != column_+j-row_ ) || !
isOne( last->value() ) ) ) {
2581 for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
2604 template<
typename MT
2607 template<
typename MT2
2617 if( column_ + 1UL >= row_ +
m_ )
2622 :( column_ - row_ + 1UL ) );
2623 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
2625 for(
size_t i=ibegin; i<
m_; ++i )
2627 const bool containsDiagonal( row_+i < column_+
n_ );
2630 ?( row_ + i - column_ + 1UL )
2631 :( row_ + i - column_ ) );
2632 const size_t jend(
min( jpos,
n_ ) );
2634 for(
size_t j=0UL; j<jend; ++j ) {
2660 template<
typename MT
2663 template<
typename MT2
2666 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2673 if( column_ + 1UL >= row_ +
m_ )
2677 ?( row_ +
m_ - column_ )
2678 :( row_ +
m_ - column_ - 1UL ) );
2679 const size_t jend(
min( jpos,
n_ ) );
2681 for(
size_t j=0UL; j<jend; ++j )
2683 const bool containsDiagonal( column_+j >= row_ );
2688 const size_t ibegin( ( containsDiagonal )
2690 ?( column_ + j - row_ )
2691 :( column_ + j - row_ + 1UL ) )
2694 for(
size_t i=ibegin; i<
m_; ++i ) {
2717 template<
typename MT
2720 template<
typename MT2
2723 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2732 if( column_ + 1UL >= row_ +
m_ )
2737 :( column_ - row_ + 1UL ) );
2738 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
2740 for(
size_t i=ibegin; i<
m_; ++i )
2742 const bool containsDiagonal( row_+i < column_+
n_ );
2745 ?( row_ + i - column_ + 1UL )
2746 :( row_ + i - column_ ) );
2747 const RhsIterator last( (~rhs).lowerBound( i,
min( index,
n_ ) ) );
2750 ( last == (~rhs).
end(i) || ( last->index() != row_+i-column_ ) || !
isOne( last->value() ) ) ) {
2754 for( RhsIterator element=(~rhs).begin(i); element!=last; ++element ) {
2777 template<
typename MT
2780 template<
typename MT2
2783 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
2792 if( column_ + 1UL >= row_ +
m_ )
2796 ?( row_ +
m_ - column_ )
2797 :( row_ +
m_ - column_ - 1UL ) );
2798 const size_t jend(
min( jpos,
n_ ) );
2800 for(
size_t j=0UL; j<jend; ++j )
2802 const bool containsDiagonal( column_+j >= row_ );
2804 const size_t index( ( containsDiagonal )
2806 ?( column_ + j - row_ )
2807 :( column_ + j - row_ + 1UL ) )
2810 const RhsIterator last( (~rhs).
end(j) );
2811 RhsIterator element( (~rhs).lowerBound( index, j ) );
2814 if( element == last || ( element->index() != column_+j-row_ ) || !
isOne( element->value() ) )
2819 for( ; element!=last; ++element ) {
2841 template<
typename MT
2844 template<
typename MT2
2854 for(
size_t i=0UL; i<
m_; ++i ) {
2855 for(
size_t j=0UL; j<
n_; ++j ) {
2856 if( ( row_ + i != column_ + j ) && !
isDefault( (~rhs)(i,j) ) )
2877 template<
typename MT
2880 template<
typename MT2
2883 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
2890 for(
size_t j=0UL; j<
n_; ++j ) {
2891 for(
size_t i=0UL; i<
m_; ++i ) {
2892 if( ( column_ + j != row_ + i ) && !
isDefault( (~rhs)(i,j) ) )
2913 template<
typename MT
2916 template<
typename MT2
2919 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
2928 for(
size_t i=0UL; i<
m_; ++i ) {
2929 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
2930 if( ( row_ + i != column_ + element->index() ) && !
isDefault( element->value() ) )
2951 template<
typename MT
2954 template<
typename MT2
2957 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
2966 for(
size_t j=0UL; j<
n_; ++j ) {
2967 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
2968 if( ( column_ + j != row_ + element->index() ) && !
isDefault( element->value() ) )
2996 template<
typename MT
2999 template<
typename Other >
3002 return matrix_.isAliased( alias );
3017 template<
typename MT
3020 template<
typename MT2
3025 return ( matrix_.isAliased( &alias->
matrix_ ) &&
3026 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
3027 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
3042 template<
typename MT
3045 template<
typename Other >
3048 return matrix_.isAliased( alias );
3063 template<
typename MT
3066 template<
typename MT2
3071 return ( matrix_.isAliased( &alias->
matrix_ ) &&
3072 ( row_ +
m_ > alias->
row_ ) && ( row_ < alias->row_ + alias->
m_ ) &&
3073 ( column_ +
n_ > alias->
column_ ) && ( column_ < alias->column_ + alias->
n_ ) );
3087 template<
typename MT
3107 template<
typename MT
3133 template<
typename MT
3139 return loadu( i, j );
3160 template<
typename MT
3175 return matrix_.load( row_+i, column_+j );
3177 else if( j != final_ ) {
3178 return matrix_.loadu( row_+i, column_+j );
3182 for(
size_t k=0UL; k<rest_; ++k )
3183 array[k] = matrix_(row_+i,column_+j+k);
3184 for(
size_t k=rest_; k<
IT::size; ++k )
3208 template<
typename MT
3234 template<
typename MT
3248 matrix_.store( row_+i, column_+j, value );
3250 else if( j != final_ ) {
3251 matrix_.storeu( row_+i, column_+j, value );
3256 for(
size_t k=0UL; k<rest_; ++k )
3257 matrix_(row_+i,column_+j+k) = array[k];
3280 template<
typename MT
3301 template<
typename MT
3304 template<
typename MT2 >
3313 const size_t jpos(
n_ &
size_t(-2) );
3316 for(
size_t i=0UL; i<
m_; ++i ) {
3317 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3318 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
3319 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
3322 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
3340 template<
typename MT
3343 template<
typename MT2 >
3355 !(~rhs).isAliased( &matrix_ ) )
3357 for(
size_t i=0UL; i<
m_; ++i )
3359 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
3363 const size_t jpos(
n_ &
size_t(-
IT::size*4) );
3366 for(
size_t i=0UL; i<
m_; ++i ) {
3368 for(
size_t j=0UL; j<jpos; j+=
IT::size*4UL ) {
3369 matrix_.storeu( row_+i, column_+j , it.load() ); it +=
IT::size;
3371 matrix_.storeu( row_+i, column_+j+
IT::size*2UL, it.load() ); it +=
IT::size;
3372 matrix_.storeu( row_+i, column_+j+
IT::size*3UL, it.load() ); it +=
IT::size;
3375 storeu( i, j, it.load() );
3394 template<
typename MT
3397 template<
typename MT2 >
3406 const size_t block( 16UL );
3408 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
3409 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
3410 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
3411 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
3412 for(
size_t i=ii; i<iend; ++i ) {
3413 for(
size_t j=jj; j<jend; ++j ) {
3414 matrix_(row_+i,column_+j) = (~rhs)(i,j);
3434 template<
typename MT
3437 template<
typename MT2 >
3445 for(
size_t i=0UL; i<
m_; ++i )
3447 matrix_(row_+i,column_+element->index()) = element->value();
3463 template<
typename MT
3466 template<
typename MT2 >
3475 for(
size_t j=0UL; j<
n_; ++j )
3477 matrix_(row_+element->index(),column_+j) = element->value();
3493 template<
typename MT
3496 template<
typename MT2 >
3505 const size_t jpos(
n_ &
size_t(-2) );
3508 for(
size_t i=0UL; i<
m_; ++i ) {
3509 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3510 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
3511 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
3514 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
3532 template<
typename MT
3535 template<
typename MT2 >
3545 const size_t jpos(
n_ &
size_t(-
IT::size*4) );
3548 for(
size_t i=0UL; i<
m_; ++i ) {
3550 for(
size_t j=0UL; j<jpos; j+=
IT::size*4UL ) {
3551 matrix_.storeu( row_+i, column_+j ,
load(i,j ) + it.load() ); it +=
IT::size;
3575 template<
typename MT
3578 template<
typename MT2 >
3587 const size_t block( 16UL );
3589 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
3590 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
3591 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
3592 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
3593 for(
size_t i=ii; i<iend; ++i ) {
3594 for(
size_t j=jj; j<jend; ++j ) {
3595 matrix_(row_+i,column_+j) += (~rhs)(i,j);
3615 template<
typename MT
3618 template<
typename MT2 >
3626 for(
size_t i=0UL; i<
m_; ++i )
3628 matrix_(row_+i,column_+element->index()) += element->value();
3644 template<
typename MT
3647 template<
typename MT2 >
3656 for(
size_t j=0UL; j<
n_; ++j )
3658 matrix_(row_+element->index(),column_+j) += element->value();
3674 template<
typename MT
3677 template<
typename MT2 >
3686 const size_t jpos(
n_ &
size_t(-2) );
3689 for(
size_t i=0UL; i<
m_; ++i ) {
3690 for(
size_t j=0UL; j<jpos; j+=2UL ) {
3691 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
3692 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
3695 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
3713 template<
typename MT
3716 template<
typename MT2 >
3726 const size_t jpos(
n_ &
size_t(-
IT::size*4) );
3729 for(
size_t i=0UL; i<
m_; ++i ) {
3731 for(
size_t j=0UL; j<jpos; j+=
IT::size*4UL ) {
3732 matrix_.storeu( row_+i, column_+j ,
load(i,j ) - it.load() ); it +=
IT::size;
3756 template<
typename MT
3759 template<
typename MT2 >
3768 const size_t block( 16UL );
3770 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
3771 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
3772 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
3773 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
3774 for(
size_t i=ii; i<iend; ++i ) {
3775 for(
size_t j=jj; j<jend; ++j ) {
3776 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
3796 template<
typename MT
3799 template<
typename MT2 >
3807 for(
size_t i=0UL; i<
m_; ++i )
3809 matrix_(row_+i,column_+element->index()) -= element->value();
3825 template<
typename MT
3828 template<
typename MT2 >
3837 for(
size_t j=0UL; j<
n_; ++j )
3839 matrix_(row_+element->index(),column_+j) -= element->value();
3864 template<
typename MT >
3890 typedef DenseSubmatrix<MT,unaligned,true>
This;
3891 typedef typename SubmatrixTrait<MT>::Type
ResultType;
3903 typedef typename IfTrue< useConst, ConstReference, typename MT::Reference >::Type
Reference;
3909 typedef typename IfTrue< useConst, ConstPointer, ElementType* >::Type
Pointer;
3915 template<
typename IteratorType >
3916 class SubmatrixIterator
3921 typedef typename std::iterator_traits<IteratorType>::iterator_category
IteratorCategory;
3924 typedef typename std::iterator_traits<IteratorType>::value_type
ValueType;
3927 typedef typename std::iterator_traits<IteratorType>::pointer
PointerType;
3930 typedef typename std::iterator_traits<IteratorType>::reference
ReferenceType;
3933 typedef typename std::iterator_traits<IteratorType>::difference_type
DifferenceType;
3963 size_t remainingElements,
bool isMemoryAligned )
3965 ,
final_ ( finalIterator )
3966 ,
rest_ ( remainingElements )
3976 template<
typename IteratorType2 >
4056 inline ReferenceType
operator*()
const {
4071 inline IntrinsicType
load()
const {
4086 inline IntrinsicType
loadu()
const {
4094 AlignedArray<ElementType,IT::size> array;
4095 for(
size_t i=0UL; i<
rest_; ++i )
4097 for(
size_t i=rest_; i<
IT::size; ++i )
4189 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
4201 return SubmatrixIterator( it.iterator_ + inc, it.final_, it.rest_, it.isAligned_ );
4213 return SubmatrixIterator( it.iterator_ - dec, it.final_, it.rest_, it.isAligned_ );
4222 inline IteratorType
base()
const {
4232 inline IteratorType
final()
const {
4242 inline size_t rest()
const {
4269 typedef SubmatrixIterator<typename MT::ConstIterator>
ConstIterator;
4272 typedef typename IfTrue< useConst, ConstIterator, SubmatrixIterator<typename MT::Iterator> >::Type
Iterator;
4277 enum { vectorizable = MT::vectorizable };
4280 enum { smpAssignable = MT::smpAssignable };
4298 inline Reference
operator()(
size_t i,
size_t j );
4299 inline ConstReference
operator()(
size_t i,
size_t j )
const;
4300 inline Pointer
data ();
4301 inline ConstPointer
data ()
const;
4302 inline Iterator
begin (
size_t i );
4303 inline ConstIterator
begin (
size_t i )
const;
4304 inline ConstIterator
cbegin(
size_t i )
const;
4305 inline Iterator
end (
size_t i );
4306 inline ConstIterator
end (
size_t i )
const;
4307 inline ConstIterator
cend (
size_t i )
const;
4317 template<
typename MT2,
bool SO >
4320 template<
typename MT2,
bool SO >
4321 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
4322 operator+=(
const Matrix<MT2,SO>& rhs );
4324 template<
typename MT2,
bool SO >
4325 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
4326 operator+=(
const Matrix<MT2,SO>& rhs );
4328 template<
typename MT2,
bool SO >
4329 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
4330 operator-=(
const Matrix<MT2,SO>& rhs );
4332 template<
typename MT2,
bool SO >
4333 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
4334 operator-=(
const Matrix<MT2,SO>& rhs );
4336 template<
typename MT2,
bool SO >
4339 template<
typename Other >
4340 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
4341 operator*=( Other rhs );
4343 template<
typename Other >
4344 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
4345 operator/=( Other rhs );
4352 inline size_t rows()
const;
4353 inline size_t columns()
const;
4354 inline size_t spacing()
const;
4356 inline size_t capacity(
size_t i )
const;
4358 inline size_t nonZeros(
size_t i )
const;
4359 inline void reset();
4360 inline void reset(
size_t i );
4362 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
4369 template<
typename MT2 >
4370 struct VectorizedAssign {
4371 enum { value = vectorizable && MT2::vectorizable &&
4372 IsSame<ElementType,typename MT2::ElementType>::value };
4378 template<
typename MT2 >
4379 struct VectorizedAddAssign {
4380 enum { value = vectorizable && MT2::vectorizable &&
4381 IsSame<ElementType,typename MT2::ElementType>::value &&
4382 IntrinsicTrait<ElementType>::addition };
4388 template<
typename MT2 >
4389 struct VectorizedSubAssign {
4390 enum { value = vectorizable && MT2::vectorizable &&
4391 IsSame<ElementType,typename MT2::ElementType>::value &&
4392 IntrinsicTrait<ElementType>::subtraction };
4400 template<
typename Other >
4401 inline bool canAlias(
const Other* alias )
const;
4403 template<
typename MT2,
bool AF2,
bool SO2 >
4404 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
4406 template<
typename Other >
4407 inline bool isAliased(
const Other* alias )
const;
4409 template<
typename MT2,
bool AF2,
bool SO2 >
4410 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
4415 inline IntrinsicType
load (
size_t i,
size_t j )
const;
4416 inline IntrinsicType
loadu(
size_t i,
size_t j )
const;
4418 inline void store (
size_t i,
size_t j,
const IntrinsicType& value );
4419 inline void storeu(
size_t i,
size_t j,
const IntrinsicType& value );
4420 inline void stream(
size_t i,
size_t j,
const IntrinsicType& value );
4422 template<
typename MT2 >
4423 inline typename DisableIf< VectorizedAssign<MT2> >::Type
4424 assign(
const DenseMatrix<MT2,true>& rhs );
4426 template<
typename MT2 >
4427 inline typename EnableIf< VectorizedAssign<MT2> >::Type
4428 assign(
const DenseMatrix<MT2,true>& rhs );
4430 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
4431 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
4432 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
4434 template<
typename MT2 >
4435 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
4436 addAssign(
const DenseMatrix<MT2,true>& rhs );
4438 template<
typename MT2 >
4439 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
4440 addAssign(
const DenseMatrix<MT2,true>& rhs );
4442 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
4443 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
4444 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
4446 template<
typename MT2 >
4447 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
4448 subAssign(
const DenseMatrix<MT2,true>& rhs );
4450 template<
typename MT2 >
4451 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
4452 subAssign(
const DenseMatrix<MT2,true>& rhs );
4454 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
4455 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
4456 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
4466 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
4467 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
4468 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
4470 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
4471 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4472 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
4474 template<
typename MT2,
bool SO2,
typename MT3 >
4475 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4476 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
4478 template<
typename MT2,
bool SO2,
typename MT3 >
4479 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4480 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
4482 template<
typename MT2,
bool SO2,
typename MT3 >
4483 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4484 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
4486 template<
typename MT2,
bool SO2,
typename MT3 >
4487 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4488 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
4490 template<
typename MT2,
bool SO2,
typename MT3 >
4491 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4492 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
4494 template<
typename MT2,
bool SO2,
typename MT3 >
4495 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4496 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
4498 template<
typename MT2,
bool SO2,
typename MT3 >
4499 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4500 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
4502 template<
typename MT2,
bool SO2,
typename MT3 >
4503 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
4504 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
4506 template<
typename MT2,
bool SO2,
typename MT3 >
4507 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4508 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
4510 template<
typename MT2,
bool SO2,
typename MT3 >
4511 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4512 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
4514 template<
typename MT2,
bool SO2,
typename MT3 >
4515 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4516 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
4518 template<
typename MT2,
bool SO2,
typename MT3 >
4519 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
4520 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
4552 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
4554 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
4555 friend const DenseSubmatrix<MT2,AF1,SO2>
4556 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
4558 template<
typename MT2,
bool AF2,
bool SO2 >
4559 friend bool isSymmetric(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
4561 template<
typename MT2,
bool AF2,
bool SO2 >
4562 friend bool isLower(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
4564 template<
typename MT2,
bool AF2,
bool SO2 >
4565 friend bool isUpper(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
4567 template<
typename MT2,
bool AF2,
bool SO2 >
4568 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
4570 template<
typename MT2,
bool AF2,
bool SO2 >
4571 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
4573 template<
typename MT2,
bool AF2,
bool SO2 >
4574 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
4576 template<
typename MT2,
bool AF2,
bool SO2 >
4577 friend typename DerestrictTrait< DenseSubmatrix<MT2,AF2,SO2> >::Type
4578 derestrict( DenseSubmatrix<MT2,AF2,SO2>& dm );
4589 BLAZE_STATIC_ASSERT( !IsRestricted<MT>::value || IsLower<MT>::value || IsUpper<MT>::value );
4618 template<
typename MT >
4620 : matrix_ ( matrix )
4622 , column_ ( column )
4625 , rest_ ( m % IT::
size )
4626 , final_ ( m - rest_ )
4627 , isAligned_( ( row % IT::
size == 0UL ) &&
4628 ( row + m == matrix.
rows() || m % IT::
size == 0UL ) )
4630 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
4631 throw std::invalid_argument(
"Invalid submatrix specification" );
4653 template<
typename MT >
4660 return matrix_(row_+i,column_+j);
4674 template<
typename MT >
4681 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
4697 template<
typename MT >
4700 return matrix_.data() + row_ + column_*
spacing();
4716 template<
typename MT >
4717 inline typename DenseSubmatrix<MT,unaligned,true>::ConstPointer
4720 return matrix_.data() + row_ + column_*
spacing();
4733 template<
typename MT >
4738 const typename MT::Iterator first( matrix_.begin( column_ + j ) + row_ );
4739 return Iterator( first, first + final_, rest_, isAligned_ );
4752 template<
typename MT >
4758 return ConstIterator( first, first + final_, rest_, isAligned_ );
4771 template<
typename MT >
4777 return ConstIterator( first, first + final_, rest_, isAligned_ );
4790 template<
typename MT >
4795 const typename MT::Iterator last( matrix_.begin( column_ + j ) + row_ +
m_ );
4796 return Iterator( last, last, rest_, isAligned_ );
4809 template<
typename MT >
4828 template<
typename MT >
4859 template<
typename MT >
4860 inline DenseSubmatrix<MT,unaligned,true>&
4863 const size_t jend( column_ +
n_ );
4865 for(
size_t j=column_; j<jend; ++j )
4867 const size_t ibegin( ( IsLower<MT>::value )
4868 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
4869 ?(
max( j+1UL, row_ ) )
4870 :(
max( j, row_ ) ) )
4872 const size_t iend ( ( IsUpper<MT>::value )
4873 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
4874 ?(
min( j, row_+
m_ ) )
4875 :(
min( j+1UL, row_+
m_ ) ) )
4878 for(
size_t i=ibegin; i<iend; ++i )
4903 template<
typename MT >
4904 inline DenseSubmatrix<MT,unaligned,true>&
4910 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
4913 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
4914 throw std::invalid_argument(
"Submatrix sizes do not match" );
4916 if( !preservesInvariant( matrix_, rhs ) )
4917 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
4919 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4921 if( rhs.canAlias( &matrix_ ) ) {
4922 const ResultType tmp( rhs );
4954 template<
typename MT >
4955 template<
typename MT2
4957 inline DenseSubmatrix<MT,unaligned,true>&
4963 throw std::invalid_argument(
"Matrix sizes do not match" );
4965 typedef typename If< IsAdaptor<MT>,
typename MT2::CompositeType,
const MT2& >::Type Right;
4966 Right right( ~rhs );
4968 if( !preservesInvariant( matrix_, right ) )
4969 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
4971 if( IsSparseMatrix<MT2>::value )
4974 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
4976 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
5008 template<
typename MT >
5009 template<
typename MT2
5011 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
5012 , DenseSubmatrix<MT,unaligned,true>& >::Type
5013 DenseSubmatrix<MT,unaligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
5019 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
5025 throw std::invalid_argument(
"Matrix sizes do not match" );
5027 if( !preservesInvariant( matrix_, ~rhs ) )
5028 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
5030 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5032 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
5033 const AddType tmp( *
this + (~rhs) );
5064 template<
typename MT >
5065 template<
typename MT2
5067 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
5068 , DenseSubmatrix<MT,unaligned,true>& >::Type
5069 DenseSubmatrix<MT,unaligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
5075 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
5081 throw std::invalid_argument(
"Matrix sizes do not match" );
5083 const AddType tmp( *
this + (~rhs) );
5085 if( !preservesInvariant( matrix_, tmp ) )
5086 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
5088 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5116 template<
typename MT >
5117 template<
typename MT2
5119 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
5120 , DenseSubmatrix<MT,unaligned,true>& >::Type
5121 DenseSubmatrix<MT,unaligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
5127 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
5133 throw std::invalid_argument(
"Matrix sizes do not match" );
5135 if( !preservesInvariant( matrix_, ~rhs ) )
5136 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
5138 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5140 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
5141 const SubType tmp( *
this - (~rhs ) );
5172 template<
typename MT >
5173 template<
typename MT2
5175 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
5176 , DenseSubmatrix<MT,unaligned,true>& >::Type
5177 DenseSubmatrix<MT,unaligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
5183 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
5189 throw std::invalid_argument(
"Matrix sizes do not match" );
5191 const SubType tmp( *
this - (~rhs) );
5193 if( !preservesInvariant( matrix_, tmp ) )
5194 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
5196 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5224 template<
typename MT >
5225 template<
typename MT2
5227 inline DenseSubmatrix<MT,unaligned,true>&
5228 DenseSubmatrix<MT,unaligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
5234 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
5240 throw std::invalid_argument(
"Matrix sizes do not match" );
5242 const MultType tmp( *
this * (~rhs) );
5244 if( !preservesInvariant( matrix_, tmp ) )
5245 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
5247 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5272 template<
typename MT >
5273 template<
typename Other >
5274 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
5275 DenseSubmatrix<MT,unaligned,true>::operator*=( Other rhs )
5279 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5301 template<
typename MT >
5302 template<
typename Other >
5303 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,unaligned,true> >::Type&
5304 DenseSubmatrix<MT,unaligned,true>::operator/=( Other rhs )
5310 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5333 template<
typename MT >
5348 template<
typename MT >
5366 template<
typename MT >
5369 return matrix_.spacing();
5381 template<
typename MT >
5397 template<
typename MT >
5416 template<
typename MT >
5419 const size_t iend( row_ +
m_ );
5420 const size_t jend( column_ +
n_ );
5421 size_t nonzeros( 0UL );
5423 for(
size_t j=column_; j<jend; ++j )
5424 for(
size_t i=row_; i<iend; ++i )
5441 template<
typename MT >
5446 const size_t iend( row_ +
m_ );
5447 size_t nonzeros( 0UL );
5449 for(
size_t i=row_; i<iend; ++i )
5450 if( !
isDefault( matrix_(i,column_+j) ) )
5465 template<
typename MT >
5470 for(
size_t j=column_; j<column_+
n_; ++j )
5472 const size_t ibegin( ( IsLower<MT>::value )
5473 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
5474 ?(
max( j+1UL, row_ ) )
5475 :(
max( j, row_ ) ) )
5477 const size_t iend ( ( IsUpper<MT>::value )
5478 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
5479 ?(
min( j, row_+
m_ ) )
5480 :(
min( j+1UL, row_+
m_ ) ) )
5483 for(
size_t i=ibegin; i<iend; ++i )
5484 clear( matrix_(i,j) );
5498 template<
typename MT >
5505 const size_t ibegin( ( IsLower<MT>::value )
5506 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
5507 ?(
max( j+1UL, row_ ) )
5508 :(
max( j, row_ ) ) )
5510 const size_t iend ( ( IsUpper<MT>::value )
5511 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
5512 ?(
min( j, row_+
m_ ) )
5513 :(
min( j+1UL, row_+
m_ ) ) )
5516 for(
size_t i=ibegin; i<iend; ++i )
5517 clear( matrix_(i,column_+j) );
5539 template<
typename MT >
5543 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
5545 if( IsLower<MT>::value && ( row_ + 1UL < column_ + n_ ) )
5546 throw std::runtime_error(
"Invalid transpose of a lower matrix" );
5548 if( IsUpper<MT>::value && ( column_ + 1UL < row_ +
m_ ) )
5549 throw std::runtime_error(
"Invalid transpose of an upper matrix" );
5551 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
5552 const ResultType tmp(
trans(*
this) );
5572 template<
typename MT >
5573 template<
typename Other >
5574 inline DenseSubmatrix<MT,unaligned,true>& DenseSubmatrix<MT,unaligned,true>::scale(
const Other& scalar )
5578 const size_t jend( column_ + n_ );
5580 for(
size_t j=column_; j<jend; ++j )
5582 const size_t ibegin( ( IsLower<MT>::value )
5583 ?( ( IsStrictlyLower<MT>::value )
5584 ?(
max( j+1UL, row_ ) )
5585 :(
max( j, row_ ) ) )
5587 const size_t iend ( ( IsUpper<MT>::value )
5588 ?( ( IsStrictlyUpper<MT>::value )
5589 ?(
min( j, row_+
m_ ) )
5590 :(
min( j+1UL, row_+
m_ ) ) )
5593 for(
size_t i=ibegin; i<iend; ++i )
5594 matrix_(i,j) *= scalar;
5613 template<
typename MT >
5618 if( ( row_ +
m_ <= column_ ) || ( column_ + n_ <= row_ ) )
5638 template<
typename MT >
5639 template<
typename MT2
5643 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
5644 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
5666 template<
typename MT >
5667 template<
typename MT2
5671 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5672 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
5681 const bool lower( row_ > column_ );
5682 const size_t size (
min( row_ +
m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
5687 const size_t row ( lower ? 0UL : column_ - row_ );
5688 const size_t column( lower ? row_ - column_ : 0UL );
5709 template<
typename MT >
5710 template<
typename MT2
5713 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5714 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
5720 if( row_ + 1UL >= column_ + n_ )
5723 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
5724 ?( column_ + n_ - row_ )
5725 :( column_ + n_ - row_ - 1UL ) );
5726 const size_t iend(
min( ipos,
m_ ) );
5728 for(
size_t i=0UL; i<iend; ++i )
5730 const bool containsDiagonal( row_+i >= column_ );
5732 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
5735 const size_t jbegin( ( containsDiagonal )
5736 ?( ( IsStrictlyLower<MT2>::value )
5737 ?( row_ + i - column_ )
5738 :( row_ + i - column_ + 1UL ) )
5741 for(
size_t j=jbegin; j<
n_; ++j ) {
5766 template<
typename MT >
5767 template<
typename MT2
5770 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5771 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
5777 if( row_ + 1UL >= column_ + n_ )
5780 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
5782 :( row_ - column_ + 1UL ) );
5783 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
5785 for(
size_t j=jbegin; j<
n_; ++j )
5787 const bool containsDiagonal( column_+j < row_+
m_ );
5789 const size_t ipos( ( IsStrictlyLower<MT2>::value && containsDiagonal )
5790 ?( column_ + j - row_ + 1UL )
5791 :( column_ + j - row_ ) );
5792 const size_t iend(
min( ipos,
m_ ) );
5794 for(
size_t i=0UL; i<iend; ++i ) {
5799 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
5822 template<
typename MT >
5823 template<
typename MT2
5826 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5827 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
5835 if( row_ + 1UL >= column_ + n_ )
5838 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
5839 ?( column_ + n_ - row_ )
5840 :( column_ + n_ - row_ - 1UL ) );
5841 const size_t iend(
min( ipos,
m_ ) );
5843 for(
size_t i=0UL; i<iend; ++i )
5845 const bool containsDiagonal( row_+i >= column_ );
5847 const size_t index( ( containsDiagonal )
5848 ?( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
5849 ?( row_ + i - column_ )
5850 :( row_ + i - column_ + 1UL ) )
5853 const RhsIterator last( (~rhs).
end(i) );
5854 RhsIterator element( (~rhs).lowerBound( i, index ) );
5856 if( IsUniLower<MT2>::value && containsDiagonal ) {
5857 if( element == last || ( element->index() != row_+i-column_ ) || !
isOne( element->value() ) )
5862 for( ; element!=last; ++element ) {
5887 template<
typename MT >
5888 template<
typename MT2
5891 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5892 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
5900 if( row_ + 1UL >= column_ + n_ )
5903 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
5905 :( row_ - column_ + 1UL ) );
5906 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
5908 for(
size_t j=jbegin; j<
n_; ++j )
5910 const bool containsDiagonal( column_+j < row_+
m_ );
5912 const size_t index( ( IsStrictlyLower<MT2>::value && containsDiagonal )
5913 ?( column_ + j - row_ + 1UL )
5914 :( column_ + j - row_ ) );
5915 const RhsIterator last( (~rhs).lowerBound(
min( index,
m_ ), j ) );
5917 if( IsUniLower<MT2>::value && containsDiagonal &&
5918 ( last == (~rhs).
end(j) || ( last->index() != column_+j-row_ ) || !
isOne( last->value() ) ) ) {
5922 for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
5947 template<
typename MT >
5948 template<
typename MT2
5951 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
5952 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
5958 if( column_ + 1UL >= row_ +
m_ )
5961 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
5963 :( column_ - row_ + 1UL ) );
5964 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
5966 for(
size_t i=ibegin; i<
m_; ++i )
5968 const bool containsDiagonal( row_+i < column_+n_ );
5970 const size_t jpos( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
5971 ?( row_ + i - column_ + 1UL )
5972 :( row_ + i - column_ ) );
5973 const size_t jend(
min( jpos, n_ ) );
5975 for(
size_t j=0UL; j<jend; ++j ) {
5980 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
6003 template<
typename MT >
6004 template<
typename MT2
6007 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
6008 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
6014 if( column_ + 1UL >= row_ + m_ )
6017 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
6018 ?( row_ + m_ - column_ )
6019 :( row_ + m_ - column_ - 1UL ) );
6020 const size_t jend(
min( jpos, n_ ) );
6022 for(
size_t j=0UL; j<jend; ++j )
6024 const bool containsDiagonal( column_+j >= row_ );
6026 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
6029 const size_t ibegin( ( containsDiagonal )
6030 ?( ( IsStrictlyUpper<MT2>::value )
6031 ?( column_ + j - row_ )
6032 :( column_ + j - row_ + 1UL ) )
6035 for(
size_t i=ibegin; i<
m_; ++i ) {
6060 template<
typename MT >
6061 template<
typename MT2
6064 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
6065 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
6073 if( column_ + 1UL >= row_ + m_ )
6076 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
6078 :( column_ - row_ + 1UL ) );
6079 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
6081 for(
size_t i=ibegin; i<
m_; ++i )
6083 const bool containsDiagonal( row_+i < column_+n_ );
6085 const size_t index( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
6086 ?( row_ + i - column_ + 1UL )
6087 :( row_ + i - column_ ) );
6088 const RhsIterator last( (~rhs).lowerBound( i,
min( index, n_ ) ) );
6090 if( IsUniUpper<MT2>::value && containsDiagonal &&
6091 ( last == (~rhs).
end(i) || ( last->index() != row_+i-column_ ) || !
isOne( last->value() ) ) ) {
6095 for( RhsIterator element=(~rhs).begin(i); element!=last; ++element ) {
6120 template<
typename MT >
6121 template<
typename MT2
6124 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
6125 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
6133 if( column_ + 1UL >= row_ + m_ )
6136 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
6137 ?( row_ + m_ - column_ )
6138 :( row_ + m_ - column_ - 1UL ) );
6139 const size_t jend(
min( jpos, n_ ) );
6141 for(
size_t j=0UL; j<jend; ++j )
6143 const bool containsDiagonal( column_+j >= row_ );
6145 const size_t index( ( containsDiagonal )
6146 ?( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
6147 ?( column_ + j - row_ )
6148 :( column_ + j - row_ + 1UL ) )
6151 const RhsIterator last( (~rhs).
end(j) );
6152 RhsIterator element( (~rhs).lowerBound( index, j ) );
6154 if( IsUniUpper<MT2>::value && containsDiagonal ) {
6155 if( element == last || ( element->index() != column_+j-row_ ) || !
isOne( element->value() ) )
6160 for( ; element!=last; ++element ) {
6184 template<
typename MT >
6185 template<
typename MT2
6188 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
6189 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
6195 for(
size_t i=0UL; i<
m_; ++i ) {
6196 for(
size_t j=0UL; j<
n_; ++j ) {
6197 if( ( row_ + i != column_ + j ) && !
isDefault( (~rhs)(i,j) ) )
6220 template<
typename MT >
6221 template<
typename MT2
6224 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
6225 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
6231 for(
size_t j=0UL; j<
n_; ++j ) {
6232 for(
size_t i=0UL; i<
m_; ++i ) {
6233 if( ( column_ + j != row_ + i ) && !
isDefault( (~rhs)(i,j) ) )
6256 template<
typename MT >
6257 template<
typename MT2
6260 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
6261 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
6269 for(
size_t i=0UL; i<
m_; ++i ) {
6270 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
6271 if( ( row_ + i != column_ + element->index() ) && !
isDefault( element->value() ) )
6294 template<
typename MT >
6295 template<
typename MT2
6298 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
6299 DenseSubmatrix<MT,unaligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
6307 for(
size_t j=0UL; j<
n_; ++j ) {
6308 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
6309 if( ( column_ + j != row_ + element->index() ) && !
isDefault( element->value() ) )
6339 template<
typename MT >
6340 template<
typename Other >
6343 return matrix_.isAliased( alias );
6360 template<
typename MT >
6361 template<
typename MT2
6366 return ( matrix_.isAliased( &alias->matrix_ ) &&
6367 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
6368 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
6385 template<
typename MT >
6386 template<
typename Other >
6389 return matrix_.isAliased( alias );
6406 template<
typename MT >
6407 template<
typename MT2
6412 return ( matrix_.isAliased( &alias->matrix_ ) &&
6413 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
6414 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
6430 template<
typename MT >
6450 template<
typename MT >
6475 template<
typename MT >
6476 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
6479 return loadu( i, j );
6501 template<
typename MT >
6502 inline typename DenseSubmatrix<MT,unaligned,true>::IntrinsicType
6514 return matrix_.load( row_+i, column_+j );
6516 else if( i != final_ ) {
6517 return matrix_.loadu( row_+i, column_+j );
6520 AlignedArray<ElementType,IT::size> array;
6521 for(
size_t k=0UL; k<rest_; ++k )
6522 array[k] = matrix_(row_+i+k,column_+j);
6523 for(
size_t k=rest_; k<
IT::size; ++k )
6525 return load( array.data() );
6548 template<
typename MT >
6574 template<
typename MT >
6586 matrix_.store( row_+i, column_+j, value );
6588 else if( i != final_ ) {
6589 matrix_.storeu( row_+i, column_+j, value );
6592 AlignedArray<ElementType,IT::size> array;
6593 store( array.data(), value );
6594 for(
size_t k=0UL; k<rest_; ++k )
6595 matrix_(row_+i+k,column_+j) = array[k];
6619 template<
typename MT >
6640 template<
typename MT >
6641 template<
typename MT2 >
6642 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6650 const size_t ipos( m_ &
size_t(-2) );
6653 for(
size_t j=0UL; j<
n_; ++j ) {
6654 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6655 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
6656 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
6659 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
6679 template<
typename MT >
6680 template<
typename MT2 >
6681 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
6691 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
6692 !(~rhs).isAliased( &matrix_ ) )
6694 for(
size_t j=0UL; j<
n_; ++j )
6696 matrix_.stream( row_+i, column_+j, (~rhs).load(i,j) );
6700 const size_t ipos( m_ &
size_t(-IT::size*4) );
6703 for(
size_t j=0UL; j<
n_; ++j ) {
6705 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
6706 matrix_.storeu( row_+i , column_+j, it.load() ); it +=
IT::size;
6707 matrix_.storeu( row_+i+IT::size , column_+j, it.load() ); it +=
IT::size;
6708 matrix_.storeu( row_+i+IT::size*2UL, column_+j, it.load() ); it +=
IT::size;
6709 matrix_.storeu( row_+i+IT::size*3UL, column_+j, it.load() ); it +=
IT::size;
6712 storeu( i, j, it.load() );
6733 template<
typename MT >
6734 template<
typename MT2 >
6743 const size_t block( 16UL );
6745 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6746 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6747 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6748 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6749 for(
size_t j=jj; j<jend; ++j ) {
6750 for(
size_t i=ii; i<iend; ++i ) {
6751 matrix_(row_+i,column_+j) = (~rhs)(i,j);
6773 template<
typename MT >
6774 template<
typename MT2 >
6782 for(
size_t j=0UL; j<
n_; ++j )
6784 matrix_(row_+element->index(),column_+j) = element->value();
6802 template<
typename MT >
6803 template<
typename MT2 >
6812 for(
size_t i=0UL; i<
m_; ++i )
6814 matrix_(row_+i,column_+element->index()) = element->value();
6832 template<
typename MT >
6833 template<
typename MT2 >
6834 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6842 const size_t ipos( m_ &
size_t(-2) );
6845 for(
size_t j=0UL; j<
n_; ++j ) {
6846 for(
size_t i=0UL; i<ipos; i+=2UL ) {
6847 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
6848 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
6851 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
6871 template<
typename MT >
6872 template<
typename MT2 >
6873 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
6882 const size_t ipos( m_ &
size_t(-IT::size*4) );
6885 for(
size_t j=0UL; j<
n_; ++j ) {
6887 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
6888 matrix_.storeu( row_+i , column_+j,
load(i ,j) + it.load() ); it +=
IT::size;
6889 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) + it.load() ); it +=
IT::size;
6890 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) + it.load() ); it +=
IT::size;
6891 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) + it.load() ); it +=
IT::size;
6914 template<
typename MT >
6915 template<
typename MT2 >
6924 const size_t block( 16UL );
6926 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
6927 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
6928 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
6929 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
6930 for(
size_t j=jj; j<jend; ++j ) {
6931 for(
size_t i=ii; i<iend; ++i ) {
6932 matrix_(row_+i,column_+j) += (~rhs)(i,j);
6954 template<
typename MT >
6955 template<
typename MT2 >
6963 for(
size_t j=0UL; j<
n_; ++j )
6965 matrix_(row_+element->index(),column_+j) += element->value();
6983 template<
typename MT >
6984 template<
typename MT2 >
6993 for(
size_t i=0UL; i<
m_; ++i )
6995 matrix_(row_+i,column_+element->index()) += element->value();
7013 template<
typename MT >
7014 template<
typename MT2 >
7015 inline typename DisableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
7023 const size_t ipos( m_ &
size_t(-2) );
7026 for(
size_t j=0UL; j<
n_; ++j ) {
7027 for(
size_t i=0UL; i<ipos; i+=2UL ) {
7028 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
7029 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
7032 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
7052 template<
typename MT >
7053 template<
typename MT2 >
7054 inline typename EnableIf< typename DenseSubmatrix<MT,unaligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
7063 const size_t ipos( m_ &
size_t(-IT::size*4) );
7066 for(
size_t j=0UL; j<
n_; ++j ) {
7068 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
7069 matrix_.storeu( row_+i , column_+j,
load(i ,j) - it.load() ); it +=
IT::size;
7070 matrix_.storeu( row_+i+IT::size , column_+j,
load(i+IT::size ,j) - it.load() ); it +=
IT::size;
7071 matrix_.storeu( row_+i+IT::size*2UL, column_+j,
load(i+IT::size*2UL,j) - it.load() ); it +=
IT::size;
7072 matrix_.storeu( row_+i+IT::size*3UL, column_+j,
load(i+IT::size*3UL,j) - it.load() ); it +=
IT::size;
7095 template<
typename MT >
7096 template<
typename MT2 >
7105 const size_t block( 16UL );
7107 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
7108 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
7109 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
7110 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
7111 for(
size_t j=jj; j<jend; ++j ) {
7112 for(
size_t i=ii; i<iend; ++i ) {
7113 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
7135 template<
typename MT >
7136 template<
typename MT2 >
7144 for(
size_t j=0UL; j<
n_; ++j )
7146 matrix_(row_+element->index(),column_+j) -= element->value();
7164 template<
typename MT >
7165 template<
typename MT2 >
7174 for(
size_t i=0UL; i<
m_; ++i )
7176 matrix_(row_+i,column_+element->index()) -= element->value();
7202 template<
typename MT >
7203 class DenseSubmatrix<MT,
aligned,false> :
public DenseMatrix< DenseSubmatrix<MT,aligned,false>, false >
7209 typedef typename If< IsExpression<MT>, MT, MT& >::Type
Operand;
7212 typedef IntrinsicTrait<typename MT::ElementType>
IT;
7223 enum { useConst = IsConst<MT>::value };
7228 typedef DenseSubmatrix<MT,aligned,false>
This;
7229 typedef typename SubmatrixTrait<MT>::Type
ResultType;
7241 typedef typename IfTrue< useConst, ConstReference, typename MT::Reference >::Type
Reference;
7247 typedef typename IfTrue< useConst, ConstPointer, ElementType* >::Type
Pointer;
7253 typedef typename IfTrue< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
7258 enum { vectorizable = MT::vectorizable };
7261 enum { smpAssignable = MT::smpAssignable };
7267 explicit inline DenseSubmatrix( Operand matrix,
size_t row,
size_t column,
size_t m,
size_t n );
7279 inline Reference
operator()(
size_t i,
size_t j );
7280 inline ConstReference
operator()(
size_t i,
size_t j )
const;
7281 inline Pointer
data ();
7282 inline ConstPointer
data ()
const;
7283 inline Iterator
begin (
size_t i );
7284 inline ConstIterator
begin (
size_t i )
const;
7285 inline ConstIterator
cbegin(
size_t i )
const;
7286 inline Iterator
end (
size_t i );
7287 inline ConstIterator
end (
size_t i )
const;
7288 inline ConstIterator
cend (
size_t i )
const;
7298 template<
typename MT2,
bool SO >
7301 template<
typename MT2,
bool SO >
7302 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
7305 template<
typename MT2,
bool SO >
7306 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
7307 operator+=(
const Matrix<MT2,SO>& rhs );
7309 template<
typename MT2,
bool SO >
7310 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
7311 operator+=(
const Matrix<MT2,SO>& rhs );
7313 template<
typename MT2,
bool SO >
7314 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
7315 operator-=(
const Matrix<MT2,SO>& rhs );
7317 template<
typename MT2,
bool SO >
7318 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
7319 operator-=(
const Matrix<MT2,SO>& rhs );
7321 template<
typename MT2,
bool SO >
7324 template<
typename Other >
7325 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
7326 operator*=( Other rhs );
7328 template<
typename Other >
7329 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
7330 operator/=( Other rhs );
7337 inline size_t rows()
const;
7338 inline size_t columns()
const;
7339 inline size_t spacing()
const;
7341 inline size_t capacity(
size_t i )
const;
7343 inline size_t nonZeros(
size_t i )
const;
7344 inline void reset();
7345 inline void reset(
size_t i );
7347 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
7354 template<
typename MT2 >
7355 struct VectorizedAssign {
7356 enum { value = vectorizable && MT2::vectorizable &&
7357 IsSame<ElementType,typename MT2::ElementType>::value };
7363 template<
typename MT2 >
7364 struct VectorizedAddAssign {
7365 enum { value = vectorizable && MT2::vectorizable &&
7366 IsSame<ElementType,typename MT2::ElementType>::value &&
7367 IntrinsicTrait<ElementType>::addition };
7373 template<
typename MT2 >
7374 struct VectorizedSubAssign {
7375 enum { value = vectorizable && MT2::vectorizable &&
7376 IsSame<ElementType,typename MT2::ElementType>::value &&
7377 IntrinsicTrait<ElementType>::subtraction };
7385 template<
typename Other >
7386 inline bool canAlias(
const Other* alias )
const;
7388 template<
typename MT2,
bool AF2,
bool SO2 >
7389 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
7391 template<
typename Other >
7392 inline bool isAliased(
const Other* alias )
const;
7394 template<
typename MT2,
bool AF2,
bool SO2 >
7395 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
7407 template<
typename MT2 >
7408 inline typename DisableIf< VectorizedAssign<MT2> >::Type
7409 assign(
const DenseMatrix<MT2,false>& rhs );
7411 template<
typename MT2 >
7412 inline typename EnableIf< VectorizedAssign<MT2> >::Type
7413 assign(
const DenseMatrix<MT2,false>& rhs );
7415 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,true>& rhs );
7416 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
7417 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
7419 template<
typename MT2 >
7420 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
7421 addAssign(
const DenseMatrix<MT2,false>& rhs );
7423 template<
typename MT2 >
7424 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
7425 addAssign(
const DenseMatrix<MT2,false>& rhs );
7427 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,true>& rhs );
7428 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
7429 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
7431 template<
typename MT2 >
7432 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
7433 subAssign(
const DenseMatrix<MT2,false>& rhs );
7435 template<
typename MT2 >
7436 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
7437 subAssign(
const DenseMatrix<MT2,false>& rhs );
7439 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,true>& rhs );
7440 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
7441 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
7451 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
7452 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
7453 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
7455 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
7456 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7457 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
7459 template<
typename MT2,
bool SO2,
typename MT3 >
7460 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7461 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
7463 template<
typename MT2,
bool SO2,
typename MT3 >
7464 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7465 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
7467 template<
typename MT2,
bool SO2,
typename MT3 >
7468 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7469 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
7471 template<
typename MT2,
bool SO2,
typename MT3 >
7472 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7473 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
7475 template<
typename MT2,
bool SO2,
typename MT3 >
7476 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7477 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
7479 template<
typename MT2,
bool SO2,
typename MT3 >
7480 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7481 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
7483 template<
typename MT2,
bool SO2,
typename MT3 >
7484 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7485 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
7487 template<
typename MT2,
bool SO2,
typename MT3 >
7488 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
7489 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
7491 template<
typename MT2,
bool SO2,
typename MT3 >
7492 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
7493 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
7495 template<
typename MT2,
bool SO2,
typename MT3 >
7496 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
7497 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
7499 template<
typename MT2,
bool SO2,
typename MT3 >
7500 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
7501 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
7503 template<
typename MT2,
bool SO2,
typename MT3 >
7504 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
7505 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
7521 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
7523 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
7524 friend const DenseSubmatrix<MT2,AF1,SO2>
7525 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
7527 template<
typename MT2,
bool AF2,
bool SO2 >
7528 friend bool isSymmetric(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
7530 template<
typename MT2,
bool AF2,
bool SO2 >
7531 friend bool isLower(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
7533 template<
typename MT2,
bool AF2,
bool SO2 >
7534 friend bool isUpper(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
7536 template<
typename MT2,
bool AF2,
bool SO2 >
7537 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
7539 template<
typename MT2,
bool AF2,
bool SO2 >
7540 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
7542 template<
typename MT2,
bool AF2,
bool SO2 >
7543 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
7545 template<
typename MT2,
bool AF2,
bool SO2 >
7546 friend typename DerestrictTrait< DenseSubmatrix<MT2,AF2,SO2> >::Type
7547 derestrict( DenseSubmatrix<MT2,AF2,SO2>& dm );
7558 BLAZE_STATIC_ASSERT( !IsRestricted<MT>::value || IsLower<MT>::value || IsUpper<MT>::value );
7587 template<
typename MT >
7595 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
7596 throw std::invalid_argument(
"Invalid submatrix specification" );
7598 if( column % IT::size != 0UL || (
column_ + n_ !=
matrix_.columns() && n_ % IT::size != 0UL ) )
7599 throw std::invalid_argument(
"Invalid submatrix alignment" );
7621 template<
typename MT >
7628 return matrix_(row_+i,column_+j);
7642 template<
typename MT >
7649 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
7665 template<
typename MT >
7668 return matrix_.data() + row_*
spacing() + column_;
7684 template<
typename MT >
7685 inline typename DenseSubmatrix<MT,aligned,false>::ConstPointer
7688 return matrix_.data() + row_*
spacing() + column_;
7706 template<
typename MT >
7711 return ( matrix_.begin( row_ + i ) + column_ );
7729 template<
typename MT >
7734 return ( matrix_.cbegin( row_ + i ) + column_ );
7752 template<
typename MT >
7757 return ( matrix_.cbegin( row_ + i ) + column_ );
7775 template<
typename MT >
7780 return ( matrix_.begin( row_ + i ) + column_ +
n_ );
7798 template<
typename MT >
7803 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
7821 template<
typename MT >
7826 return ( matrix_.cbegin( row_ + i ) + column_ +
n_ );
7851 template<
typename MT >
7852 inline DenseSubmatrix<MT,aligned,false>&
7855 const size_t iend( row_ + m_ );
7857 for(
size_t i=row_; i<iend; ++i )
7859 const size_t jbegin( ( IsUpper<MT>::value )
7860 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
7861 ?(
max( i+1UL, column_ ) )
7862 :(
max( i, column_ ) ) )
7864 const size_t jend ( ( IsLower<MT>::value )
7865 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
7866 ?(
min( i, column_+n_ ) )
7867 :(
min( i+1UL, column_+n_ ) ) )
7870 for(
size_t j=jbegin; j<jend; ++j )
7895 template<
typename MT >
7896 inline DenseSubmatrix<MT,aligned,false>&
7902 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
7905 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
7906 throw std::invalid_argument(
"Submatrix sizes do not match" );
7908 if( !preservesInvariant( matrix_, rhs ) )
7909 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
7911 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
7913 if( rhs.canAlias( &matrix_ ) ) {
7914 const ResultType tmp( rhs );
7946 template<
typename MT >
7947 template<
typename MT2
7949 inline DenseSubmatrix<MT,aligned,false>&
7955 throw std::invalid_argument(
"Matrix sizes do not match" );
7957 typedef typename If< IsAdaptor<MT>,
typename MT2::CompositeType,
const MT2& >::Type Right;
7958 Right right( ~rhs );
7960 if( !preservesInvariant( matrix_, right ) )
7961 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
7963 if( IsSparseMatrix<MT2>::value )
7966 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
7968 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
8000 template<
typename MT >
8001 template<
typename MT2
8003 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
8004 , DenseSubmatrix<MT,aligned,false>& >::Type
8005 DenseSubmatrix<MT,aligned,false>::operator+=(
const Matrix<MT2,SO>& rhs )
8011 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
8017 throw std::invalid_argument(
"Matrix sizes do not match" );
8019 if( !preservesInvariant( matrix_, ~rhs ) )
8020 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
8022 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8024 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
8025 const AddType tmp( *
this + (~rhs) );
8056 template<
typename MT >
8057 template<
typename MT2
8059 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
8060 , DenseSubmatrix<MT,aligned,false>& >::Type
8061 DenseSubmatrix<MT,aligned,false>::operator+=(
const Matrix<MT2,SO>& rhs )
8067 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
8073 throw std::invalid_argument(
"Matrix sizes do not match" );
8075 const AddType tmp( *
this + (~rhs) );
8077 if( !preservesInvariant( matrix_, tmp ) )
8078 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
8080 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8108 template<
typename MT >
8109 template<
typename MT2
8111 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
8112 , DenseSubmatrix<MT,aligned,false>& >::Type
8113 DenseSubmatrix<MT,aligned,false>::operator-=(
const Matrix<MT2,SO>& rhs )
8119 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
8125 throw std::invalid_argument(
"Matrix sizes do not match" );
8127 if( !preservesInvariant( matrix_, ~rhs ) )
8128 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
8130 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8132 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
8133 const SubType tmp( *
this - (~rhs ) );
8164 template<
typename MT >
8165 template<
typename MT2
8167 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
8168 , DenseSubmatrix<MT,aligned,false>& >::Type
8169 DenseSubmatrix<MT,aligned,false>::operator-=(
const Matrix<MT2,SO>& rhs )
8175 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
8181 throw std::invalid_argument(
"Matrix sizes do not match" );
8183 const SubType tmp( *
this - (~rhs) );
8185 if( !preservesInvariant( matrix_, tmp ) )
8186 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
8188 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8216 template<
typename MT >
8217 template<
typename MT2
8219 inline DenseSubmatrix<MT,aligned,false>&
8220 DenseSubmatrix<MT,aligned,false>::operator*=(
const Matrix<MT2,SO>& rhs )
8226 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
8232 throw std::invalid_argument(
"Matrix sizes do not match" );
8234 const MultType tmp( *
this * (~rhs) );
8236 if( !preservesInvariant( matrix_, tmp ) )
8237 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
8239 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8264 template<
typename MT >
8265 template<
typename Other >
8266 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
8267 DenseSubmatrix<MT,aligned,false>::operator*=( Other rhs )
8271 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8293 template<
typename MT >
8294 template<
typename Other >
8295 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,false> >::Type&
8296 DenseSubmatrix<MT,aligned,false>::operator/=( Other rhs )
8302 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8325 template<
typename MT >
8340 template<
typename MT >
8360 template<
typename MT >
8363 return matrix_.spacing();
8375 template<
typename MT >
8396 template<
typename MT >
8415 template<
typename MT >
8418 const size_t iend( row_ + m_ );
8419 const size_t jend( column_ + n_ );
8420 size_t nonzeros( 0UL );
8422 for(
size_t i=row_; i<iend; ++i )
8423 for(
size_t j=column_; j<jend; ++j )
8445 template<
typename MT >
8450 const size_t jend( column_ + n_ );
8451 size_t nonzeros( 0UL );
8453 for(
size_t j=column_; j<jend; ++j )
8469 template<
typename MT >
8474 for(
size_t i=row_; i<row_+
m_; ++i )
8476 const size_t jbegin( ( IsUpper<MT>::value )
8477 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
8478 ?(
max( i+1UL, column_ ) )
8479 :(
max( i, column_ ) ) )
8481 const size_t jend ( ( IsLower<MT>::value )
8482 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
8483 ?(
min( i, column_+n_ ) )
8484 :(
min( i+1UL, column_+n_ ) ) )
8487 for(
size_t j=jbegin; j<jend; ++j )
8488 clear( matrix_(i,j) );
8507 template<
typename MT >
8514 const size_t jbegin( ( IsUpper<MT>::value )
8515 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
8516 ?(
max( i+1UL, column_ ) )
8517 :(
max( i, column_ ) ) )
8519 const size_t jend ( ( IsLower<MT>::value )
8520 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
8521 ?(
min( i, column_+n_ ) )
8522 :(
min( i+1UL, column_+n_ ) ) )
8525 for(
size_t j=jbegin; j<jend; ++j )
8526 clear( matrix_(row_+i,j) );
8548 template<
typename MT >
8552 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
8554 if( IsLower<MT>::value && ( row_ + 1UL < column_ + n_ ) )
8555 throw std::runtime_error(
"Invalid transpose of a lower matrix" );
8557 if( IsUpper<MT>::value && ( column_ + 1UL < row_ + m_ ) )
8558 throw std::runtime_error(
"Invalid transpose of an upper matrix" );
8560 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
8561 const ResultType tmp(
trans(*
this) );
8581 template<
typename MT >
8582 template<
typename Other >
8583 inline DenseSubmatrix<MT,aligned,false>& DenseSubmatrix<MT,aligned,false>::scale(
const Other& scalar )
8587 const size_t iend( row_ + m_ );
8589 for(
size_t i=row_; i<iend; ++i )
8591 const size_t jbegin( ( IsUpper<MT>::value )
8592 ?( ( IsStrictlyUpper<MT>::value )
8593 ?(
max( i+1UL, column_ ) )
8594 :(
max( i, column_ ) ) )
8596 const size_t jend ( ( IsLower<MT>::value )
8597 ?( ( IsStrictlyLower<MT>::value )
8598 ?(
min( i, column_+n_ ) )
8599 :(
min( i+1UL, column_+n_ ) ) )
8602 for(
size_t j=jbegin; j<jend; ++j )
8603 matrix_(i,j) *= scalar;
8622 template<
typename MT >
8627 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
8647 template<
typename MT >
8648 template<
typename MT2
8652 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
8653 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
8675 template<
typename MT >
8676 template<
typename MT2
8680 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8681 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
8690 const bool lower( row_ > column_ );
8691 const size_t size (
min( row_ + m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
8696 const size_t row ( lower ? 0UL : column_ - row_ );
8697 const size_t column( lower ? row_ - column_ : 0UL );
8718 template<
typename MT >
8719 template<
typename MT2
8722 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8723 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
8729 if( row_ + 1UL >= column_ + n_ )
8732 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
8733 ?( column_ + n_ - row_ )
8734 :( column_ + n_ - row_ - 1UL ) );
8735 const size_t iend(
min( ipos, m_ ) );
8737 for(
size_t i=0UL; i<iend; ++i )
8739 const bool containsDiagonal( row_+i >= column_ );
8741 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
8744 const size_t jbegin( ( containsDiagonal )
8745 ?( ( IsStrictlyLower<MT2>::value )
8746 ?( row_ + i - column_ )
8747 :( row_ + i - column_ + 1UL ) )
8750 for(
size_t j=jbegin; j<
n_; ++j ) {
8775 template<
typename MT >
8776 template<
typename MT2
8779 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8780 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
8786 if( row_ + 1UL >= column_ + n_ )
8789 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
8791 :( row_ - column_ + 1UL ) );
8792 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
8794 for(
size_t j=jbegin; j<
n_; ++j )
8796 const bool containsDiagonal( column_+j < row_+m_ );
8798 const size_t ipos( ( IsStrictlyLower<MT2>::value && containsDiagonal )
8799 ?( column_ + j - row_ + 1UL )
8800 :( column_ + j - row_ ) );
8801 const size_t iend(
min( ipos, m_ ) );
8803 for(
size_t i=0UL; i<iend; ++i ) {
8808 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
8831 template<
typename MT >
8832 template<
typename MT2
8835 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8836 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
8844 if( row_ + 1UL >= column_ + n_ )
8847 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
8848 ?( column_ + n_ - row_ )
8849 :( column_ + n_ - row_ - 1UL ) );
8850 const size_t iend(
min( ipos, m_ ) );
8852 for(
size_t i=0UL; i<iend; ++i )
8854 const bool containsDiagonal( row_+i >= column_ );
8856 const size_t index( ( containsDiagonal )
8857 ?( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
8858 ?( row_ + i - column_ )
8859 :( row_ + i - column_ + 1UL ) )
8862 const RhsIterator last( (~rhs).
end(i) );
8863 RhsIterator element( (~rhs).lowerBound( i, index ) );
8865 if( IsUniLower<MT2>::value && containsDiagonal ) {
8866 if( element == last || ( element->index() != row_+i-column_ ) || !
isOne( element->value() ) )
8871 for( ; element!=last; ++element ) {
8896 template<
typename MT >
8897 template<
typename MT2
8900 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8901 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
8909 if( row_ + 1UL >= column_ + n_ )
8912 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
8914 :( row_ - column_ + 1UL ) );
8915 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
8917 for(
size_t j=jbegin; j<
n_; ++j )
8919 const bool containsDiagonal( column_+j < row_+m_ );
8921 const size_t index( ( IsStrictlyLower<MT2>::value && containsDiagonal )
8922 ?( column_ + j - row_ + 1UL )
8923 :( column_ + j - row_ ) );
8924 const RhsIterator last( (~rhs).lowerBound(
min( index, m_ ), j ) );
8926 if( IsUniLower<MT2>::value && containsDiagonal &&
8927 ( last == (~rhs).
end(j) || ( last->index() != column_+j-row_ ) || !
isOne( last->value() ) ) ) {
8931 for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
8956 template<
typename MT >
8957 template<
typename MT2
8960 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
8961 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
8967 if( column_ + 1UL >= row_ + m_ )
8970 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
8972 :( column_ - row_ + 1UL ) );
8973 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
8975 for(
size_t i=ibegin; i<
m_; ++i )
8977 const bool containsDiagonal( row_+i < column_+n_ );
8979 const size_t jpos( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
8980 ?( row_ + i - column_ + 1UL )
8981 :( row_ + i - column_ ) );
8982 const size_t jend(
min( jpos, n_ ) );
8984 for(
size_t j=0UL; j<jend; ++j ) {
8989 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
9012 template<
typename MT >
9013 template<
typename MT2
9016 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
9017 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
9023 if( column_ + 1UL >= row_ + m_ )
9026 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
9027 ?( row_ + m_ - column_ )
9028 :( row_ + m_ - column_ - 1UL ) );
9029 const size_t jend(
min( jpos, n_ ) );
9031 for(
size_t j=0UL; j<jend; ++j )
9033 const bool containsDiagonal( column_+j >= row_ );
9035 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
9038 const size_t ibegin( ( containsDiagonal )
9039 ?( ( IsStrictlyUpper<MT2>::value )
9040 ?( column_ + j - row_ )
9041 :( column_ + j - row_ + 1UL ) )
9044 for(
size_t i=ibegin; i<
m_; ++i ) {
9069 template<
typename MT >
9070 template<
typename MT2
9073 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
9074 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
9082 if( column_ + 1UL >= row_ + m_ )
9085 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
9087 :( column_ - row_ + 1UL ) );
9088 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
9090 for(
size_t i=ibegin; i<
m_; ++i )
9092 const bool containsDiagonal( row_+i < column_+n_ );
9094 const size_t index( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
9095 ?( row_ + i - column_ + 1UL )
9096 :( row_ + i - column_ ) );
9097 const RhsIterator last( (~rhs).lowerBound( i,
min( index, n_ ) ) );
9099 if( IsUniUpper<MT2>::value && containsDiagonal &&
9100 ( last == (~rhs).
end(i) || ( last->index() != row_+i-column_ ) || !
isOne( last->value() ) ) ) {
9104 for( RhsIterator element=(~rhs).begin(i); element!=last; ++element ) {
9129 template<
typename MT >
9130 template<
typename MT2
9133 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
9134 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
9142 if( column_ + 1UL >= row_ + m_ )
9145 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
9146 ?( row_ + m_ - column_ )
9147 :( row_ + m_ - column_ - 1UL ) );
9148 const size_t jend(
min( jpos, n_ ) );
9150 for(
size_t j=0UL; j<jend; ++j )
9152 const bool containsDiagonal( column_+j >= row_ );
9154 const size_t index( ( containsDiagonal )
9155 ?( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
9156 ?( column_ + j - row_ )
9157 :( column_ + j - row_ + 1UL ) )
9160 const RhsIterator last( (~rhs).
end(j) );
9161 RhsIterator element( (~rhs).lowerBound( index, j ) );
9163 if( IsUniUpper<MT2>::value && containsDiagonal ) {
9164 if( element == last || ( element->index() != column_+j-row_ ) || !
isOne( element->value() ) )
9169 for( ; element!=last; ++element ) {
9193 template<
typename MT >
9194 template<
typename MT2
9197 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
9198 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
9204 for(
size_t i=0UL; i<
m_; ++i ) {
9205 for(
size_t j=0UL; j<
n_; ++j ) {
9206 if( ( row_ + i != column_ + j ) && !
isDefault( (~rhs)(i,j) ) )
9229 template<
typename MT >
9230 template<
typename MT2
9233 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
9234 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
9240 for(
size_t j=0UL; j<
n_; ++j ) {
9241 for(
size_t i=0UL; i<
m_; ++i ) {
9242 if( ( column_ + j != row_ + i ) && !
isDefault( (~rhs)(i,j) ) )
9265 template<
typename MT >
9266 template<
typename MT2
9269 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
9270 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
9278 for(
size_t i=0UL; i<
m_; ++i ) {
9279 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
9280 if( ( row_ + i != column_ + element->index() ) && !
isDefault( element->value() ) )
9303 template<
typename MT >
9304 template<
typename MT2
9307 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
9308 DenseSubmatrix<MT,aligned,false>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
9316 for(
size_t j=0UL; j<
n_; ++j ) {
9317 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
9318 if( ( column_ + j != row_ + element->index() ) && !
isDefault( element->value() ) )
9348 template<
typename MT >
9349 template<
typename Other >
9352 return matrix_.isAliased( alias );
9369 template<
typename MT >
9370 template<
typename MT2
9375 return ( matrix_.isAliased( &alias->matrix_ ) &&
9376 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
9377 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
9394 template<
typename MT >
9395 template<
typename Other >
9398 return matrix_.isAliased( alias );
9415 template<
typename MT >
9416 template<
typename MT2
9421 return ( matrix_.isAliased( &alias->matrix_ ) &&
9422 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
9423 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
9439 template<
typename MT >
9459 template<
typename MT >
9485 template<
typename MT >
9495 return matrix_.load( row_+i, column_+j );
9518 template<
typename MT >
9528 return matrix_.loadu( row_+i, column_+j );
9551 template<
typename MT >
9561 return matrix_.store( row_+i, column_+j, value );
9584 template<
typename MT >
9594 matrix_.storeu( row_+i, column_+j, value );
9618 template<
typename MT >
9628 matrix_.stream( row_+i, column_+j, value );
9646 template<
typename MT >
9647 template<
typename MT2 >
9648 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
9656 const size_t jpos( n_ &
size_t(-2) );
9659 for(
size_t i=0UL; i<
m_; ++i ) {
9660 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9661 matrix_(row_+i,column_+j ) = (~rhs)(i,j );
9662 matrix_(row_+i,column_+j+1UL) = (~rhs)(i,j+1UL);
9665 matrix_(row_+i,column_+jpos) = (~rhs)(i,jpos);
9685 template<
typename MT >
9686 template<
typename MT2 >
9687 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
9697 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
9698 !(~rhs).isAliased( &matrix_ ) )
9700 for(
size_t i=0UL; i<
m_; ++i )
9706 const size_t jpos( n_ &
size_t(-IT::size*4) );
9709 for(
size_t i=0UL; i<
m_; ++i ) {
9711 for(
size_t j=0UL; j<jpos; j+=IT::size*4UL ) {
9718 store( i, j, it.load() );
9739 template<
typename MT >
9740 template<
typename MT2 >
9749 const size_t block( 16UL );
9751 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
9752 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
9753 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
9754 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
9755 for(
size_t i=ii; i<iend; ++i ) {
9756 for(
size_t j=jj; j<jend; ++j ) {
9757 matrix_(row_+i,column_+j) = (~rhs)(i,j);
9779 template<
typename MT >
9780 template<
typename MT2 >
9788 for(
size_t i=0UL; i<
m_; ++i )
9790 matrix_(row_+i,column_+element->index()) = element->value();
9808 template<
typename MT >
9809 template<
typename MT2 >
9818 for(
size_t j=0UL; j<
n_; ++j )
9820 matrix_(row_+element->index(),column_+j) = element->value();
9838 template<
typename MT >
9839 template<
typename MT2 >
9840 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
9848 const size_t jpos( n_ &
size_t(-2) );
9851 for(
size_t i=0UL; i<
m_; ++i ) {
9852 for(
size_t j=0UL; j<jpos; j+=2UL ) {
9853 matrix_(row_+i,column_+j ) += (~rhs)(i,j );
9854 matrix_(row_+i,column_+j+1UL) += (~rhs)(i,j+1UL);
9857 matrix_(row_+i,column_+jpos) += (~rhs)(i,jpos);
9877 template<
typename MT >
9878 template<
typename MT2 >
9879 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
9888 const size_t jpos( n_ &
size_t(-IT::size*4) );
9891 for(
size_t i=0UL; i<
m_; ++i ) {
9893 for(
size_t j=0UL; j<jpos; j+=IT::size*4UL ) {
9920 template<
typename MT >
9921 template<
typename MT2 >
9930 const size_t block( 16UL );
9932 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
9933 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
9934 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
9935 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
9936 for(
size_t i=ii; i<iend; ++i ) {
9937 for(
size_t j=jj; j<jend; ++j ) {
9938 matrix_(row_+i,column_+j) += (~rhs)(i,j);
9960 template<
typename MT >
9961 template<
typename MT2 >
9969 for(
size_t i=0UL; i<
m_; ++i )
9971 matrix_(row_+i,column_+element->index()) += element->value();
9989 template<
typename MT >
9990 template<
typename MT2 >
9999 for(
size_t j=0UL; j<
n_; ++j )
10001 matrix_(row_+element->index(),column_+j) += element->value();
10019 template<
typename MT >
10020 template<
typename MT2 >
10021 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
10029 const size_t jpos( n_ &
size_t(-2) );
10032 for(
size_t i=0UL; i<
m_; ++i ) {
10033 for(
size_t j=0UL; j<jpos; j+=2UL ) {
10034 matrix_(row_+i,column_+j ) -= (~rhs)(i,j );
10035 matrix_(row_+i,column_+j+1UL) -= (~rhs)(i,j+1UL);
10038 matrix_(row_+i,column_+jpos) -= (~rhs)(i,jpos);
10058 template<
typename MT >
10059 template<
typename MT2 >
10060 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,false>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
10069 const size_t jpos( n_ &
size_t(-IT::size*4) );
10072 for(
size_t i=0UL; i<
m_; ++i ) {
10074 for(
size_t j=0UL; j<jpos; j+=IT::size*4UL ) {
10077 store( i, j+IT::size*2UL,
load(i,j+IT::size*2UL) - it.load() ); it +=
IT::size;
10078 store( i, j+IT::size*3UL,
load(i,j+IT::size*3UL) - it.load() ); it +=
IT::size;
10101 template<
typename MT >
10102 template<
typename MT2 >
10111 const size_t block( 16UL );
10113 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
10114 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
10115 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
10116 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
10117 for(
size_t i=ii; i<iend; ++i ) {
10118 for(
size_t j=jj; j<jend; ++j ) {
10119 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
10141 template<
typename MT >
10142 template<
typename MT2 >
10150 for(
size_t i=0UL; i<
m_; ++i )
10152 matrix_(row_+i,column_+element->index()) -= element->value();
10170 template<
typename MT >
10171 template<
typename MT2 >
10180 for(
size_t j=0UL; j<
n_; ++j )
10182 matrix_(row_+element->index(),column_+j) -= element->value();
10208 template<
typename MT >
10209 class DenseSubmatrix<MT,
aligned,true> :
public DenseMatrix< DenseSubmatrix<MT,aligned,true>, true >
10210 ,
private Submatrix
10215 typedef typename If< IsExpression<MT>, MT, MT& >::Type
Operand;
10218 typedef IntrinsicTrait<typename MT::ElementType>
IT;
10229 enum { useConst = IsConst<MT>::value };
10234 typedef DenseSubmatrix<MT,aligned,true>
This;
10235 typedef typename SubmatrixTrait<MT>::Type
ResultType;
10247 typedef typename IfTrue< useConst, ConstReference, typename MT::Reference >::Type
Reference;
10253 typedef typename IfTrue< useConst, ConstPointer, ElementType* >::Type
Pointer;
10259 typedef typename IfTrue< useConst, ConstIterator, typename MT::Iterator >::Type
Iterator;
10264 enum { vectorizable = MT::vectorizable };
10267 enum { smpAssignable = MT::smpAssignable };
10273 explicit inline DenseSubmatrix( Operand matrix,
size_t row,
size_t column,
size_t m,
size_t n );
10285 inline Reference
operator()(
size_t i,
size_t j );
10286 inline ConstReference
operator()(
size_t i,
size_t j )
const;
10287 inline Pointer
data ();
10288 inline ConstPointer
data ()
const;
10289 inline Iterator
begin (
size_t i );
10290 inline ConstIterator
begin (
size_t i )
const;
10291 inline ConstIterator
cbegin(
size_t i )
const;
10292 inline Iterator
end (
size_t i );
10293 inline ConstIterator
end (
size_t i )
const;
10294 inline ConstIterator
cend (
size_t i )
const;
10304 template<
typename MT2,
bool SO >
10307 template<
typename MT2,
bool SO >
10308 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
10309 operator+=(
const Matrix<MT2,SO>& rhs );
10311 template<
typename MT2,
bool SO >
10312 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
10313 operator+=(
const Matrix<MT2,SO>& rhs );
10315 template<
typename MT2,
bool SO >
10316 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
10317 operator-=(
const Matrix<MT2,SO>& rhs );
10319 template<
typename MT2,
bool SO >
10320 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >,
DenseSubmatrix& >::Type
10321 operator-=(
const Matrix<MT2,SO>& rhs );
10323 template<
typename MT2,
bool SO >
10326 template<
typename Other >
10327 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
10328 operator*=( Other rhs );
10330 template<
typename Other >
10331 inline typename EnableIf< IsNumeric<Other>,
DenseSubmatrix >::Type&
10332 operator/=( Other rhs );
10339 inline size_t rows()
const;
10340 inline size_t columns()
const;
10341 inline size_t spacing()
const;
10343 inline size_t capacity(
size_t i )
const;
10345 inline size_t nonZeros(
size_t i )
const;
10346 inline void reset();
10347 inline void reset(
size_t i );
10349 template<
typename Other >
inline DenseSubmatrix& scale(
const Other& scalar );
10356 template<
typename MT2 >
10357 struct VectorizedAssign {
10358 enum { value = vectorizable && MT2::vectorizable &&
10359 IsSame<ElementType,typename MT2::ElementType>::value };
10365 template<
typename MT2 >
10366 struct VectorizedAddAssign {
10367 enum { value = vectorizable && MT2::vectorizable &&
10368 IsSame<ElementType,typename MT2::ElementType>::value &&
10369 IntrinsicTrait<ElementType>::addition };
10375 template<
typename MT2 >
10376 struct VectorizedSubAssign {
10377 enum { value = vectorizable && MT2::vectorizable &&
10378 IsSame<ElementType,typename MT2::ElementType>::value &&
10379 IntrinsicTrait<ElementType>::subtraction };
10387 template<
typename Other >
10388 inline bool canAlias(
const Other* alias )
const;
10390 template<
typename MT2,
bool AF2,
bool SO2 >
10391 inline bool canAlias(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
10393 template<
typename Other >
10394 inline bool isAliased(
const Other* alias )
const;
10396 template<
typename MT2,
bool AF2,
bool SO2 >
10397 inline bool isAliased(
const DenseSubmatrix<MT2,AF2,SO2>* alias )
const;
10409 template<
typename MT2 >
10410 inline typename DisableIf< VectorizedAssign<MT2> >::Type
10411 assign(
const DenseMatrix<MT2,true>& rhs );
10413 template<
typename MT2 >
10414 inline typename EnableIf< VectorizedAssign<MT2> >::Type
10415 assign(
const DenseMatrix<MT2,true>& rhs );
10417 template<
typename MT2 >
inline void assign(
const DenseMatrix<MT2,false>& rhs );
10418 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,true>& rhs );
10419 template<
typename MT2 >
inline void assign(
const SparseMatrix<MT2,false>& rhs );
10421 template<
typename MT2 >
10422 inline typename DisableIf< VectorizedAddAssign<MT2> >::Type
10423 addAssign(
const DenseMatrix<MT2,true>& rhs );
10425 template<
typename MT2 >
10426 inline typename EnableIf< VectorizedAddAssign<MT2> >::Type
10427 addAssign(
const DenseMatrix<MT2,true>& rhs );
10429 template<
typename MT2 >
inline void addAssign(
const DenseMatrix<MT2,false>& rhs );
10430 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,true>& rhs );
10431 template<
typename MT2 >
inline void addAssign(
const SparseMatrix<MT2,false>& rhs );
10433 template<
typename MT2 >
10434 inline typename DisableIf< VectorizedSubAssign<MT2> >::Type
10435 subAssign(
const DenseMatrix<MT2,true>& rhs );
10437 template<
typename MT2 >
10438 inline typename EnableIf< VectorizedSubAssign<MT2> >::Type
10439 subAssign(
const DenseMatrix<MT2,true>& rhs );
10441 template<
typename MT2 >
inline void subAssign(
const DenseMatrix<MT2,false>& rhs );
10442 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,true>& rhs );
10443 template<
typename MT2 >
inline void subAssign(
const SparseMatrix<MT2,false>& rhs );
10453 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
10454 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
10455 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
10457 template<
typename MT2,
bool SO2,
typename MT3,
bool SO3 >
10458 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10459 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs );
10461 template<
typename MT2,
bool SO2,
typename MT3 >
10462 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10463 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
10465 template<
typename MT2,
bool SO2,
typename MT3 >
10466 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10467 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
10469 template<
typename MT2,
bool SO2,
typename MT3 >
10470 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10471 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
10473 template<
typename MT2,
bool SO2,
typename MT3 >
10474 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10475 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
10477 template<
typename MT2,
bool SO2,
typename MT3 >
10478 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10479 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
10481 template<
typename MT2,
bool SO2,
typename MT3 >
10482 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10483 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
10485 template<
typename MT2,
bool SO2,
typename MT3 >
10486 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10487 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
10489 template<
typename MT2,
bool SO2,
typename MT3 >
10490 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
10491 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
10493 template<
typename MT2,
bool SO2,
typename MT3 >
10494 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
10495 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs );
10497 template<
typename MT2,
bool SO2,
typename MT3 >
10498 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
10499 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs );
10501 template<
typename MT2,
bool SO2,
typename MT3 >
10502 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
10503 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs );
10505 template<
typename MT2,
bool SO2,
typename MT3 >
10506 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
10507 preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs );
10523 template<
typename MT2,
bool AF2,
bool SO2 >
friend class DenseSubmatrix;
10525 template<
bool AF1,
typename MT2,
bool AF2,
bool SO2 >
10526 friend const DenseSubmatrix<MT2,AF1,SO2>
10527 submatrix(
const DenseSubmatrix<MT2,AF2,SO2>& dm,
size_t row,
size_t column,
size_t m,
size_t n );
10529 template<
typename MT2,
bool AF2,
bool SO2 >
10530 friend bool isSymmetric(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
10532 template<
typename MT2,
bool AF2,
bool SO2 >
10533 friend bool isLower(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
10535 template<
typename MT2,
bool AF2,
bool SO2 >
10536 friend bool isUpper(
const DenseSubmatrix<MT2,AF2,SO2>& dm );
10538 template<
typename MT2,
bool AF2,
bool SO2 >
10539 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseMatrix<MT2,SO2>& b );
10541 template<
typename MT2,
bool AF2,
bool SO2 >
10542 friend bool isSame(
const DenseMatrix<MT2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
10544 template<
typename MT2,
bool AF2,
bool SO2 >
10545 friend bool isSame(
const DenseSubmatrix<MT2,AF2,SO2>& a,
const DenseSubmatrix<MT2,AF2,SO2>& b );
10547 template<
typename MT2,
bool AF2,
bool SO2 >
10548 friend typename DerestrictTrait< DenseSubmatrix<MT2,AF2,SO2> >::Type
10549 derestrict( DenseSubmatrix<MT2,AF2,SO2>& dm );
10560 BLAZE_STATIC_ASSERT( !IsRestricted<MT>::value || IsLower<MT>::value || IsUpper<MT>::value );
10589 template<
typename MT >
10591 : matrix_( matrix )
10593 , column_( column )
10597 if( ( row + m > matrix.rows() ) || ( column + n > matrix.columns() ) )
10598 throw std::invalid_argument(
"Invalid submatrix specification" );
10600 if( row % IT::size != 0UL || (
row_ + m_ !=
matrix_.rows() && m_ % IT::size != 0UL ) )
10601 throw std::invalid_argument(
"Invalid submatrix alignment" );
10623 template<
typename MT >
10630 return matrix_(row_+i,column_+j);
10644 template<
typename MT >
10651 return const_cast<const MT&
>( matrix_ )(row_+i,column_+j);
10667 template<
typename MT >
10670 return matrix_.data() + row_ + column_*
spacing();
10686 template<
typename MT >
10687 inline typename DenseSubmatrix<MT,aligned,true>::ConstPointer
10690 return matrix_.data() + row_ + column_*
spacing();
10703 template<
typename MT >
10708 return ( matrix_.begin( column_ + j ) + row_ );
10721 template<
typename MT >
10726 return ( matrix_.cbegin( column_ + j ) + row_ );
10739 template<
typename MT >
10744 return ( matrix_.cbegin( column_ + j ) + row_ );
10757 template<
typename MT >
10762 return ( matrix_.begin( column_ + j ) + row_ +
m_ );
10775 template<
typename MT >
10780 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
10793 template<
typename MT >
10798 return ( matrix_.cbegin( column_ + j ) + row_ +
m_ );
10823 template<
typename MT >
10824 inline DenseSubmatrix<MT,aligned,true>&
10827 const size_t jend( column_ + n_ );
10829 for(
size_t j=column_; j<jend; ++j )
10831 const size_t ibegin( ( IsLower<MT>::value )
10832 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
10833 ?(
max( j+1UL, row_ ) )
10834 :(
max( j, row_ ) ) )
10836 const size_t iend ( ( IsUpper<MT>::value )
10837 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
10838 ?(
min( j, row_+m_ ) )
10839 :(
min( j+1UL, row_+m_ ) ) )
10842 for(
size_t i=ibegin; i<iend; ++i )
10843 matrix_(i,j) = rhs;
10867 template<
typename MT >
10868 inline DenseSubmatrix<MT,aligned,true>&
10874 if(
this == &rhs || ( &matrix_ == &rhs.matrix_ && row_ == rhs.row_ && column_ == rhs.column_ ) )
10877 if(
rows() != rhs.rows() ||
columns() != rhs.columns() )
10878 throw std::invalid_argument(
"Submatrix sizes do not match" );
10880 if( !preservesInvariant( matrix_, rhs ) )
10881 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
10883 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
10885 if( rhs.canAlias( &matrix_ ) ) {
10886 const ResultType tmp( rhs );
10917 template<
typename MT >
10918 template<
typename MT2
10920 inline DenseSubmatrix<MT,aligned,true>&
10926 throw std::invalid_argument(
"Matrix sizes do not match" );
10928 typedef typename If< IsAdaptor<MT>,
typename MT2::CompositeType,
const MT2& >::Type Right;
10929 Right right( ~rhs );
10931 if( !preservesInvariant( matrix_, right ) )
10932 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
10934 if( IsSparseMatrix<MT2>::value )
10937 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
10939 if( IsReference<Right>::value && right.canAlias( &matrix_ ) ) {
10971 template<
typename MT >
10972 template<
typename MT2
10974 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
10975 , DenseSubmatrix<MT,aligned,true>& >::Type
10976 DenseSubmatrix<MT,aligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
10982 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
10988 throw std::invalid_argument(
"Matrix sizes do not match" );
10990 if( !preservesInvariant( matrix_, ~rhs ) )
10991 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
10993 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
10995 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
10996 const AddType tmp( *
this + (~rhs) );
11027 template<
typename MT >
11028 template<
typename MT2
11030 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
11031 , DenseSubmatrix<MT,aligned,true>& >::Type
11032 DenseSubmatrix<MT,aligned,true>::operator+=(
const Matrix<MT2,SO>& rhs )
11038 typedef typename AddTrait<ResultType,typename MT2::ResultType>::Type AddType;
11044 throw std::invalid_argument(
"Matrix sizes do not match" );
11046 const AddType tmp( *
this + (~rhs) );
11048 if( !preservesInvariant( matrix_, tmp ) )
11049 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
11051 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11079 template<
typename MT >
11080 template<
typename MT2
11082 inline typename DisableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
11083 , DenseSubmatrix<MT,aligned,true>& >::Type
11084 DenseSubmatrix<MT,aligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
11090 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
11096 throw std::invalid_argument(
"Matrix sizes do not match" );
11098 if( !preservesInvariant( matrix_, ~rhs ) )
11099 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
11101 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11103 if( ( IsSymmetric<MT>::value && hasOverlap() ) || (~rhs).canAlias( &matrix_ ) ) {
11104 const SubType tmp( *
this - (~rhs ) );
11135 template<
typename MT >
11136 template<
typename MT2
11138 inline typename EnableIf< And< IsAdaptor<MT>, RequiresEvaluation<MT2> >
11139 , DenseSubmatrix<MT,aligned,true>& >::Type
11140 DenseSubmatrix<MT,aligned,true>::operator-=(
const Matrix<MT2,SO>& rhs )
11146 typedef typename SubTrait<ResultType,typename MT2::ResultType>::Type SubType;
11152 throw std::invalid_argument(
"Matrix sizes do not match" );
11154 const SubType tmp( *
this - (~rhs) );
11156 if( !preservesInvariant( matrix_, tmp ) )
11157 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
11159 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11187 template<
typename MT >
11188 template<
typename MT2
11190 inline DenseSubmatrix<MT,aligned,true>&
11191 DenseSubmatrix<MT,aligned,true>::operator*=(
const Matrix<MT2,SO>& rhs )
11197 typedef typename MultTrait<ResultType,typename MT2::ResultType>::Type MultType;
11203 throw std::invalid_argument(
"Matrix sizes do not match" );
11205 const MultType tmp( *
this * (~rhs) );
11207 if( !preservesInvariant( matrix_, tmp ) )
11208 throw std::invalid_argument(
"Invalid assignment to matrix adaptor" );
11210 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11235 template<
typename MT >
11236 template<
typename Other >
11237 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
11238 DenseSubmatrix<MT,aligned,true>::operator*=( Other rhs )
11242 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11264 template<
typename MT >
11265 template<
typename Other >
11266 inline typename EnableIf< IsNumeric<Other>, DenseSubmatrix<MT,aligned,true> >::Type&
11267 DenseSubmatrix<MT,aligned,true>::operator/=( Other rhs )
11273 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11296 template<
typename MT >
11311 template<
typename MT >
11329 template<
typename MT >
11332 return matrix_.spacing();
11344 template<
typename MT >
11360 template<
typename MT >
11379 template<
typename MT >
11382 const size_t iend( row_ + m_ );
11383 const size_t jend( column_ + n_ );
11384 size_t nonzeros( 0UL );
11386 for(
size_t j=column_; j<jend; ++j )
11387 for(
size_t i=row_; i<iend; ++i )
11404 template<
typename MT >
11409 const size_t iend( row_ + m_ );
11410 size_t nonzeros( 0UL );
11412 for(
size_t i=row_; i<iend; ++i )
11413 if( !
isDefault( matrix_(i,column_+j) ) )
11428 template<
typename MT >
11433 for(
size_t j=column_; j<column_+
n_; ++j )
11435 const size_t ibegin( ( IsLower<MT>::value )
11436 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
11437 ?(
max( j+1UL, row_ ) )
11438 :(
max( j, row_ ) ) )
11440 const size_t iend ( ( IsUpper<MT>::value )
11441 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
11442 ?(
min( j, row_+m_ ) )
11443 :(
min( j+1UL, row_+m_ ) ) )
11446 for(
size_t i=ibegin; i<iend; ++i )
11447 clear( matrix_(i,j) );
11461 template<
typename MT >
11468 const size_t ibegin( ( IsLower<MT>::value )
11469 ?( ( IsUniLower<MT>::value || IsStrictlyLower<MT>::value )
11470 ?(
max( j+1UL, row_ ) )
11471 :(
max( j, row_ ) ) )
11473 const size_t iend ( ( IsUpper<MT>::value )
11474 ?( ( IsUniUpper<MT>::value || IsStrictlyUpper<MT>::value )
11475 ?(
min( j, row_+m_ ) )
11476 :(
min( j+1UL, row_+m_ ) ) )
11479 for(
size_t i=ibegin; i<iend; ++i )
11480 clear( matrix_(i,column_+j) );
11502 template<
typename MT >
11506 throw std::runtime_error(
"Invalid transpose of a non-quadratic submatrix" );
11508 if( IsLower<MT>::value && ( row_ + 1UL < column_ + n_ ) )
11509 throw std::runtime_error(
"Invalid transpose of a lower matrix" );
11511 if( IsUpper<MT>::value && ( column_ + 1UL < row_ + m_ ) )
11512 throw std::runtime_error(
"Invalid transpose of an upper matrix" );
11514 typename DerestrictTrait<This>::Type left( derestrict( *
this ) );
11515 const ResultType tmp(
trans(*
this) );
11535 template<
typename MT >
11536 template<
typename Other >
11537 inline DenseSubmatrix<MT,aligned,true>& DenseSubmatrix<MT,aligned,true>::scale(
const Other& scalar )
11541 const size_t jend( column_ + n_ );
11543 for(
size_t j=column_; j<jend; ++j )
11545 const size_t ibegin( ( IsLower<MT>::value )
11546 ?( ( IsStrictlyLower<MT>::value )
11547 ?(
max( j+1UL, row_ ) )
11548 :(
max( j, row_ ) ) )
11550 const size_t iend ( ( IsUpper<MT>::value )
11551 ?( ( IsStrictlyUpper<MT>::value )
11552 ?(
min( j, row_+m_ ) )
11553 :(
min( j+1UL, row_+m_ ) ) )
11556 for(
size_t i=ibegin; i<iend; ++i )
11557 matrix_(i,j) *= scalar;
11576 template<
typename MT >
11581 if( ( row_ + m_ <= column_ ) || ( column_ + n_ <= row_ ) )
11601 template<
typename MT >
11602 template<
typename MT2
11606 inline typename EnableIf< Not< IsAdaptor<MT2> >,
bool >::Type
11607 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
11629 template<
typename MT >
11630 template<
typename MT2
11634 inline typename EnableIf< And< IsSymmetric<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11635 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const Matrix<MT3,SO3>& rhs )
11641 if( !hasOverlap() )
11644 const bool lower( row_ > column_ );
11645 const size_t size (
min( row_ + m_, column_ + n_ ) - ( lower ? row_ : column_ ) );
11650 const size_t row ( lower ? 0UL : column_ - row_ );
11651 const size_t column( lower ? row_ - column_ : 0UL );
11672 template<
typename MT >
11673 template<
typename MT2
11676 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11677 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
11683 if( row_ + 1UL >= column_ + n_ )
11686 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
11687 ?( column_ + n_ - row_ )
11688 :( column_ + n_ - row_ - 1UL ) );
11689 const size_t iend(
min( ipos, m_ ) );
11691 for(
size_t i=0UL; i<iend; ++i )
11693 const bool containsDiagonal( row_+i >= column_ );
11695 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
11698 const size_t jbegin( ( containsDiagonal )
11699 ?( ( IsStrictlyLower<MT2>::value )
11700 ?( row_ + i - column_ )
11701 :( row_ + i - column_ + 1UL ) )
11704 for(
size_t j=jbegin; j<
n_; ++j ) {
11729 template<
typename MT >
11730 template<
typename MT2
11733 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11734 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
11740 if( row_ + 1UL >= column_ + n_ )
11743 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
11744 ?( row_ - column_ )
11745 :( row_ - column_ + 1UL ) );
11746 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
11748 for(
size_t j=jbegin; j<
n_; ++j )
11750 const bool containsDiagonal( column_+j < row_+m_ );
11752 const size_t ipos( ( IsStrictlyLower<MT2>::value && containsDiagonal )
11753 ?( column_ + j - row_ + 1UL )
11754 :( column_ + j - row_ ) );
11755 const size_t iend(
min( ipos, m_ ) );
11757 for(
size_t i=0UL; i<iend; ++i ) {
11762 if( IsUniLower<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
11785 template<
typename MT >
11786 template<
typename MT2
11789 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11790 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
11798 if( row_ + 1UL >= column_ + n_ )
11801 const size_t ipos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
11802 ?( column_ + n_ - row_ )
11803 :( column_ + n_ - row_ - 1UL ) );
11804 const size_t iend(
min( ipos, m_ ) );
11806 for(
size_t i=0UL; i<iend; ++i )
11808 const bool containsDiagonal( row_+i >= column_ );
11810 const size_t index( ( containsDiagonal )
11811 ?( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
11812 ?( row_ + i - column_ )
11813 :( row_ + i - column_ + 1UL ) )
11816 const RhsIterator last( (~rhs).
end(i) );
11817 RhsIterator element( (~rhs).lowerBound( i, index ) );
11819 if( IsUniLower<MT2>::value && containsDiagonal ) {
11820 if( element == last || ( element->index() != row_+i-column_ ) || !
isOne( element->value() ) )
11825 for( ; element!=last; ++element ) {
11850 template<
typename MT >
11851 template<
typename MT2
11854 inline typename EnableIf< And< IsLower<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11855 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
11863 if( row_ + 1UL >= column_ + n_ )
11866 const size_t jpos( ( IsUniLower<MT2>::value || IsStrictlyLower<MT2>::value )
11867 ?( row_ - column_ )
11868 :( row_ - column_ + 1UL ) );
11869 const size_t jbegin( ( row_ < column_ )?( 0UL ):( jpos ) );
11871 for(
size_t j=jbegin; j<
n_; ++j )
11873 const bool containsDiagonal( column_+j < row_+m_ );
11875 const size_t index( ( IsStrictlyLower<MT2>::value && containsDiagonal )
11876 ?( column_ + j - row_ + 1UL )
11877 :( column_ + j - row_ ) );
11878 const RhsIterator last( (~rhs).lowerBound(
min( index, m_ ), j ) );
11880 if( IsUniLower<MT2>::value && containsDiagonal &&
11881 ( last == (~rhs).
end(j) || ( last->index() != column_+j-row_ ) || !
isOne( last->value() ) ) ) {
11885 for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
11910 template<
typename MT >
11911 template<
typename MT2
11914 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11915 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
11921 if( column_ + 1UL >= row_ + m_ )
11924 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
11925 ?( column_ - row_ )
11926 :( column_ - row_ + 1UL ) );
11927 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
11929 for(
size_t i=ibegin; i<
m_; ++i )
11931 const bool containsDiagonal( row_+i < column_+n_ );
11933 const size_t jpos( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
11934 ?( row_ + i - column_ + 1UL )
11935 :( row_ + i - column_ ) );
11936 const size_t jend(
min( jpos, n_ ) );
11938 for(
size_t j=0UL; j<jend; ++j ) {
11943 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(i,row_+i-column_) ) )
11966 template<
typename MT >
11967 template<
typename MT2
11970 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
11971 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
11977 if( column_ + 1UL >= row_ + m_ )
11980 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
11981 ?( row_ + m_ - column_ )
11982 :( row_ + m_ - column_ - 1UL ) );
11983 const size_t jend(
min( jpos, n_ ) );
11985 for(
size_t j=0UL; j<jend; ++j )
11987 const bool containsDiagonal( column_+j >= row_ );
11989 if( IsUniUpper<MT2>::value && containsDiagonal && !
isOne( (~rhs)(column_+j-row_,j) ) )
11992 const size_t ibegin( ( containsDiagonal )
11993 ?( ( IsStrictlyUpper<MT2>::value )
11994 ?( column_ + j - row_ )
11995 :( column_ + j - row_ + 1UL ) )
11998 for(
size_t i=ibegin; i<
m_; ++i ) {
12023 template<
typename MT >
12024 template<
typename MT2
12027 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
12028 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
12036 if( column_ + 1UL >= row_ + m_ )
12039 const size_t ipos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
12040 ?( column_ - row_ )
12041 :( column_ - row_ + 1UL ) );
12042 const size_t ibegin( ( column_ < row_ )?( 0UL ):( ipos ) );
12044 for(
size_t i=ibegin; i<
m_; ++i )
12046 const bool containsDiagonal( row_+i < column_+n_ );
12048 const size_t index( ( IsStrictlyUpper<MT2>::value && containsDiagonal )
12049 ?( row_ + i - column_ + 1UL )
12050 :( row_ + i - column_ ) );
12051 const RhsIterator last( (~rhs).lowerBound( i,
min( index, n_ ) ) );
12053 if( IsUniUpper<MT2>::value && containsDiagonal &&
12054 ( last == (~rhs).
end(i) || ( last->index() != row_+i-column_ ) || !
isOne( last->value() ) ) ) {
12058 for( RhsIterator element=(~rhs).begin(i); element!=last; ++element ) {
12083 template<
typename MT >
12084 template<
typename MT2
12087 inline typename EnableIf< And< IsUpper<MT2>, Not< IsDiagonal<MT2> > >,
bool >::Type
12088 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
12096 if( column_ + 1UL >= row_ + m_ )
12099 const size_t jpos( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
12100 ?( row_ + m_ - column_ )
12101 :( row_ + m_ - column_ - 1UL ) );
12102 const size_t jend(
min( jpos, n_ ) );
12104 for(
size_t j=0UL; j<jend; ++j )
12106 const bool containsDiagonal( column_+j >= row_ );
12108 const size_t index( ( containsDiagonal )
12109 ?( ( IsUniUpper<MT2>::value || IsStrictlyUpper<MT2>::value )
12110 ?( column_ + j - row_ )
12111 :( column_ + j - row_ + 1UL ) )
12114 const RhsIterator last( (~rhs).
end(j) );
12115 RhsIterator element( (~rhs).lowerBound( index, j ) );
12117 if( IsUniUpper<MT2>::value && containsDiagonal ) {
12118 if( element == last || ( element->index() != column_+j-row_ ) || !
isOne( element->value() ) )
12123 for( ; element!=last; ++element ) {
12147 template<
typename MT >
12148 template<
typename MT2
12151 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
12152 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,false>& rhs )
12158 for(
size_t i=0UL; i<
m_; ++i ) {
12159 for(
size_t j=0UL; j<
n_; ++j ) {
12160 if( ( row_ + i != column_ + j ) && !
isDefault( (~rhs)(i,j) ) )
12183 template<
typename MT >
12184 template<
typename MT2
12187 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
12188 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const DenseMatrix<MT3,true>& rhs )
12194 for(
size_t j=0UL; j<
n_; ++j ) {
12195 for(
size_t i=0UL; i<
m_; ++i ) {
12196 if( ( column_ + j != row_ + i ) && !
isDefault( (~rhs)(i,j) ) )
12219 template<
typename MT >
12220 template<
typename MT2
12223 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
12224 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,false>& rhs )
12232 for(
size_t i=0UL; i<
m_; ++i ) {
12233 for( RhsIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
12234 if( ( row_ + i != column_ + element->index() ) && !
isDefault( element->value() ) )
12257 template<
typename MT >
12258 template<
typename MT2
12261 inline typename EnableIf< IsDiagonal<MT2>,
bool >::Type
12262 DenseSubmatrix<MT,aligned,true>::preservesInvariant(
const DenseMatrix<MT2,SO2>& lhs,
const SparseMatrix<MT3,true>& rhs )
12270 for(
size_t j=0UL; j<
n_; ++j ) {
12271 for( RhsIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
12272 if( ( column_ + j != row_ + element->index() ) && !
isDefault( element->value() ) )
12302 template<
typename MT >
12303 template<
typename Other >
12306 return matrix_.isAliased( alias );
12323 template<
typename MT >
12324 template<
typename MT2
12329 return ( matrix_.isAliased( &alias->matrix_ ) &&
12330 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
12331 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
12348 template<
typename MT >
12349 template<
typename Other >
12352 return matrix_.isAliased( alias );
12369 template<
typename MT >
12370 template<
typename MT2
12375 return ( matrix_.isAliased( &alias->matrix_ ) &&
12376 ( row_ + m_ > alias->row_ ) && ( row_ < alias->row_ + alias->m_ ) &&
12377 ( column_ + n_ > alias->column_ ) && ( column_ < alias->column_ + alias->n_ ) );
12393 template<
typename MT >
12413 template<
typename MT >
12438 template<
typename MT >
12448 return matrix_.load( row_+i, column_+j );
12470 template<
typename MT >
12480 return matrix_.loadu( row_+i, column_+j );
12502 template<
typename MT >
12512 matrix_.store( row_+i, column_+j, value );
12535 template<
typename MT >
12545 matrix_.storeu( row_+i, column_+j, value );
12568 template<
typename MT >
12578 matrix_.stream( row_+i, column_+j, value );
12596 template<
typename MT >
12597 template<
typename MT2 >
12598 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
12606 const size_t ipos( m_ &
size_t(-2) );
12609 for(
size_t j=0UL; j<
n_; ++j ) {
12610 for(
size_t i=0UL; i<ipos; i+=2UL ) {
12611 matrix_(row_+i ,column_+j) = (~rhs)(i ,j);
12612 matrix_(row_+i+1UL,column_+j) = (~rhs)(i+1UL,j);
12615 matrix_(row_+ipos,column_+j) = (~rhs)(ipos,j);
12635 template<
typename MT >
12636 template<
typename MT2 >
12637 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAssign<MT2> >::Type
12647 m_*n_ > (
cacheSize / (
sizeof(ElementType) * 3UL ) ) &&
12648 !(~rhs).isAliased( &matrix_ ) )
12650 for(
size_t j=0UL; j<
n_; ++j )
12656 const size_t ipos( m_ &
size_t(-IT::size*4) );
12659 for(
size_t j=0UL; j<
n_; ++j ) {
12661 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
12668 store( i, j, it.load() );
12689 template<
typename MT >
12690 template<
typename MT2 >
12699 const size_t block( 16UL );
12701 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
12702 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
12703 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
12704 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
12705 for(
size_t j=jj; j<jend; ++j ) {
12706 for(
size_t i=ii; i<iend; ++i ) {
12707 matrix_(row_+i,column_+j) = (~rhs)(i,j);
12729 template<
typename MT >
12730 template<
typename MT2 >
12738 for(
size_t j=0UL; j<
n_; ++j )
12740 matrix_(row_+element->index(),column_+j) = element->value();
12758 template<
typename MT >
12759 template<
typename MT2 >
12768 for(
size_t i=0UL; i<
m_; ++i )
12770 matrix_(row_+i,column_+element->index()) = element->value();
12788 template<
typename MT >
12789 template<
typename MT2 >
12790 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
12798 const size_t ipos( m_ &
size_t(-2) );
12801 for(
size_t j=0UL; j<
n_; ++j ) {
12802 for(
size_t i=0UL; i<ipos; i+=2UL ) {
12803 matrix_(row_+i ,column_+j) += (~rhs)(i ,j);
12804 matrix_(row_+i+1UL,column_+j) += (~rhs)(i+1UL,j);
12807 matrix_(row_+ipos,column_+j) += (~rhs)(ipos,j);
12827 template<
typename MT >
12828 template<
typename MT2 >
12829 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT2> >::Type
12838 const size_t ipos( m_ &
size_t(-IT::size*4) );
12841 for(
size_t j=0UL; j<
n_; ++j ) {
12843 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
12846 store( i+IT::size*2UL, j,
load(i+IT::size*2UL,j) + it.load() ); it +=
IT::size;
12847 store( i+IT::size*3UL, j,
load(i+IT::size*3UL,j) + it.load() ); it +=
IT::size;
12870 template<
typename MT >
12871 template<
typename MT2 >
12880 const size_t block( 16UL );
12882 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
12883 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
12884 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
12885 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
12886 for(
size_t j=jj; j<jend; ++j ) {
12887 for(
size_t i=ii; i<iend; ++i ) {
12888 matrix_(row_+i,column_+j) += (~rhs)(i,j);
12910 template<
typename MT >
12911 template<
typename MT2 >
12919 for(
size_t j=0UL; j<
n_; ++j )
12921 matrix_(row_+element->index(),column_+j) += element->value();
12939 template<
typename MT >
12940 template<
typename MT2 >
12949 for(
size_t i=0UL; i<
m_; ++i )
12951 matrix_(row_+i,column_+element->index()) += element->value();
12969 template<
typename MT >
12970 template<
typename MT2 >
12971 inline typename DisableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
12979 const size_t ipos( m_ &
size_t(-2) );
12982 for(
size_t j=0UL; j<
n_; ++j ) {
12983 for(
size_t i=0UL; i<ipos; i+=2UL ) {
12984 matrix_(row_+i ,column_+j) -= (~rhs)(i ,j);
12985 matrix_(row_+i+1UL,column_+j) -= (~rhs)(i+1UL,j);
12988 matrix_(row_+ipos,column_+j) -= (~rhs)(ipos,j);
13008 template<
typename MT >
13009 template<
typename MT2 >
13010 inline typename EnableIf< typename DenseSubmatrix<MT,aligned,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT2> >::Type
13019 const size_t ipos( m_ &
size_t(-IT::size*4) );
13022 for(
size_t j=0UL; j<
n_; ++j ) {
13024 for(
size_t i=0UL; i<ipos; i+=IT::size*4UL ) {
13027 store( i+IT::size*2UL, j,
load(i+IT::size*2UL,j) - it.load() ); it +=
IT::size;
13028 store( i+IT::size*3UL, j,
load(i+IT::size*3UL,j) - it.load() ); it +=
IT::size;
13051 template<
typename MT >
13052 template<
typename MT2 >
13061 const size_t block( 16UL );
13063 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
13064 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
13065 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
13066 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
13067 for(
size_t j=jj; j<jend; ++j ) {
13068 for(
size_t i=ii; i<iend; ++i ) {
13069 matrix_(row_+i,column_+j) -= (~rhs)(i,j);
13091 template<
typename MT >
13092 template<
typename MT2 >
13100 for(
size_t j=0UL; j<
n_; ++j )
13102 matrix_(row_+element->index(),column_+j) -= element->value();
13120 template<
typename MT >
13121 template<
typename MT2 >
13130 for(
size_t i=0UL; i<
m_; ++i )
13132 matrix_(row_+i,column_+element->index()) -= element->value();
13153 template<
typename MT,
bool AF,
bool SO >
13154 inline void reset( DenseSubmatrix<MT,AF,SO>& dm );
13156 template<
typename MT,
bool AF,
bool SO >
13157 inline void reset( DenseSubmatrix<MT,AF,SO>& dm,
size_t i );
13159 template<
typename MT,
bool AF,
bool SO >
13160 inline void clear( DenseSubmatrix<MT,AF,SO>& dm );
13162 template<
typename MT,
bool AF,
bool SO >
13163 inline bool isDefault(
const DenseSubmatrix<MT,AF,SO>& dm );
13165 template<
typename MT,
bool AF,
bool SO >
13166 inline bool isSymmetric(
const DenseSubmatrix<MT,AF,SO>& dm );
13168 template<
typename MT,
bool AF,
bool SO >
13169 inline bool isLower(
const DenseSubmatrix<MT,AF,SO>& dm );
13171 template<
typename MT,
bool AF,
bool SO >
13172 inline bool isUpper(
const DenseSubmatrix<MT,AF,SO>& dm );
13174 template<
typename MT,
bool AF,
bool SO >
13175 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseMatrix<MT,SO>& b );
13177 template<
typename MT,
bool AF,
bool SO >
13178 inline bool isSame(
const DenseMatrix<MT,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
13180 template<
typename MT,
bool AF,
bool SO >
13181 inline bool isSame(
const DenseSubmatrix<MT,AF,SO>& a,
const DenseSubmatrix<MT,AF,SO>& b );
13193 template<
typename MT
13216 template<
typename MT
13235 template<
typename MT
13263 template<
typename MT
13271 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
13272 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
13277 for(
size_t j=0UL; j<(~dm).
columns(); ++j )
13278 for(
size_t i=0UL; i<(~dm).
rows(); ++i )
13310 template<
typename MT
13319 else return isSymmetric( static_cast<const BaseType&>( dm ) );
13356 template<
typename MT
13365 else return isLower( static_cast<const BaseType&>( dm ) );
13402 template<
typename MT
13411 else return isUpper( static_cast<const BaseType&>( dm ) );
13428 template<
typename MT
13433 return (
isSame( a.matrix_, ~b ) && ( a.rows() == (~b).
rows() ) && ( a.columns() == (~b).
columns() ) );
13450 template<
typename MT
13455 return (
isSame( ~a, b.matrix_ ) && ( (~a).rows() == b.rows() ) && ( (~a).columns() == b.columns() ) );
13472 template<
typename MT
13477 return (
isSame( a.matrix_, b.matrix_ ) &&
13478 ( a.row_ == b.row_ ) && ( a.column_ == b.column_ ) &&
13479 ( a.m_ == b.m_ ) && ( a.n_ == b.n_ ) );
13499 template<
typename MT
13502 inline typename DerestrictTrait< DenseSubmatrix<MT,AF,SO> >::Type
13503 derestrict( DenseSubmatrix<MT,AF,SO>& dm )
13505 typedef typename DerestrictTrait< DenseSubmatrix<MT,AF,SO> >::Type
ReturnType;
13506 return ReturnType( derestrict( dm.matrix_ ), dm.row_, dm.column_, dm.m_, dm.n_ );
13539 inline const DenseSubmatrix<MT,AF1,SO>
13540 submatrix(
const DenseSubmatrix<MT,AF2,SO>& dm,
size_t row,
size_t column,
size_t m,
size_t n )
13544 if( ( row + m > dm.rows() ) || ( column + n > dm.columns() ) )
13545 throw std::invalid_argument(
"Invalid submatrix specification" );
13547 return DenseSubmatrix<MT,AF1,SO>( dm.matrix_, dm.row_ +
row, dm.column_ +
column, m, n );
13563 template<
typename MT,
bool AF,
bool SO >
13564 struct IsRestricted< DenseSubmatrix<MT,AF,SO> > :
public If< IsRestricted<MT>, TrueType, FalseType >::Type
13566 enum { value = IsRestricted<MT>::value };
13583 template<
typename MT,
bool AF,
bool SO >
13584 struct DerestrictTrait< DenseSubmatrix<MT,AF,SO> >
13586 typedef DenseSubmatrix< typename RemoveReference< typename DerestrictTrait<MT>::Type >::Type, AF > Type;
13602 template<
typename MT,
bool AF,
bool SO >
13603 struct HasConstDataAccess< DenseSubmatrix<MT,AF,SO> >
13604 :
public If< HasConstDataAccess<MT>, TrueType, FalseType >::Type
13606 enum { value = HasConstDataAccess<MT>::value };
13623 template<
typename MT,
bool AF,
bool SO >
13624 struct HasMutableDataAccess< DenseSubmatrix<MT,AF,SO> >
13625 :
public If< HasMutableDataAccess<MT>, TrueType, FalseType >::Type
13627 enum { value = HasMutableDataAccess<MT>::value };
13628 typedef typename If< HasMutableDataAccess<MT>,
TrueType,
FalseType >::Type Type;
13644 template<
typename MT,
bool AF,
bool SO >
13645 struct SubmatrixTrait< DenseSubmatrix<MT,AF,SO> >
13663 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
13664 struct SubmatrixExprTrait< DenseSubmatrix<MT,AF1,SO>, AF2 >
13666 typedef DenseSubmatrix<MT,AF2,SO> Type;
13674 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
13675 struct SubmatrixExprTrait< const DenseSubmatrix<MT,AF1,SO>, AF2 >
13677 typedef DenseSubmatrix<MT,AF2,SO> Type;
13685 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
13686 struct SubmatrixExprTrait< volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
13688 typedef DenseSubmatrix<MT,AF2,SO> Type;
13696 template<
typename MT,
bool AF1,
bool SO,
bool AF2 >
13697 struct SubmatrixExprTrait< const volatile DenseSubmatrix<MT,AF1,SO>, AF2 >
13699 typedef DenseSubmatrix<MT,AF2,SO> Type;
13715 template<
typename MT,
bool AF,
bool SO >
13716 struct RowTrait< DenseSubmatrix<MT,AF,SO> >
13734 template<
typename MT,
bool AF,
bool SO >
13735 struct ColumnTrait< DenseSubmatrix<MT,AF,SO> >
Constraint on the data type.
IfTrue< useConst, ConstPointer, ElementType * >::Type Pointer
Pointer to a non-constant submatrix value.
Definition: DenseSubmatrix.h:518
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:3283
Constraint on the data type.
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
DenseSubmatrix & transpose()
Transposing the submatrix.
Definition: DenseSubmatrix.h:2199
IteratorCategory iterator_category
The iterator category.
Definition: DenseSubmatrix.h:545
ReferenceType reference
Reference return type.
Definition: DenseSubmatrix.h:548
const size_t column_
The first column of the submatrix.
Definition: DenseSubmatrix.h:1144
Header file for mathematical functions.
const size_t rest_
The number of remaining elements in an unaligned intrinsic operation.
Definition: DenseSubmatrix.h:1147
bool canAlias(const Other *alias) const
Returns whether the submatrix can alias with the given address alias.
Definition: DenseSubmatrix.h:3000
size_t rest() const
Access to the number of remaining elements beyond the final iterator.
Definition: DenseSubmatrix.h:851
#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
IfTrue< useConst, ConstIterator, SubmatrixIterator< typename MT::Iterator > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseSubmatrix.h:881
Header file for the subvector/submatrix alignment flag values.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
Header file for the subtraction trait.
Header file for basic type definitions.
std::iterator_traits< IteratorType >::difference_type DifferenceType
Difference between two iterators.
Definition: DenseSubmatrix.h:542
DifferenceType difference_type
Difference between two iterators.
Definition: DenseSubmatrix.h:549
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:264
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type stream(T *address, const sse_int16_t &value)
Aligned, non-temporal store of a vector of 2-byte integral values.
Definition: Stream.h:76
Header file for the row trait.
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:258
Base template for the SubmatrixTrait class.
Definition: SubmatrixTrait.h:118
Header file for the IsSparseMatrix type trait.
SubmatrixIterator(IteratorType iterator, IteratorType finalIterator, size_t remainingElements, bool isMemoryAligned)
Constructor of the SubmatrixIterator class.
Definition: DenseSubmatrix.h:571
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:209
Header file for the IsDiagonal type trait.
#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:1274
bool operator<=(const SubmatrixIterator &rhs) const
Less-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:763
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b)
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:946
Header file for the IsSame and IsStrictlySame type traits.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:692
bool hasOverlap() const
Checking whether there exists an overlap in the context of a symmetric matrix.
Definition: DenseSubmatrix.h:2273
DenseSubmatrix(Operand matrix, size_t row, size_t column, size_t m, size_t n)
The constructor for DenseSubmatrix.
Definition: DenseSubmatrix.h:1238
bool isAligned() const
Returns whether the submatrix is properly aligned in memory.
Definition: DenseSubmatrix.h:3090
Iterator end(size_t i)
Returns an iterator just past the last non-zero element of row/column i.
Definition: DenseSubmatrix.h:1428
bool isAliased(const Other *alias) const
Returns whether the submatrix is aliased with the given address alias.
Definition: DenseSubmatrix.h:3046
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.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:821
ConstIterator cend(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition: DenseSubmatrix.h:1476
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2665
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
ReferenceType operator*() const
Direct access to the element at the current iterator position.
Definition: DenseSubmatrix.h:665
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
const size_t n_
The number of columns of the submatrix.
Definition: DenseSubmatrix.h:1146
const size_t row_
The first row of the submatrix.
Definition: DenseSubmatrix.h:1143
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the And class template.
#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
Compile time check for lower triangular matrices.This type trait tests whether or not the given templ...
Definition: IsLower.h:90
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower or upper unitriangular matrix ty...
Definition: UniTriangular.h:118
CompressedMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:259
const ElementType * ConstPointer
Pointer to a constant submatrix value.
Definition: DenseSubmatrix.h:515
SubmatrixIterator(const SubmatrixIterator< IteratorType2 > &it)
Conversion constructor from different SubmatrixIterator instances.
Definition: DenseSubmatrix.h:586
void reset()
Reset to the default initial values.
Definition: DenseSubmatrix.h:2120
MT::ElementType ElementType
Type of the submatrix elements.
Definition: DenseSubmatrix.h:503
size_t columns() const
Returns the number of columns of the dense submatrix.
Definition: DenseSubmatrix.h:1991
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:118
Header file for the RequiresEvaluation type trait.
bool isAligned() const
Access to the iterator's memory alignment flag.
Definition: DenseSubmatrix.h:861
Pointer data()
Low-level data access to the submatrix elements.
Definition: DenseSubmatrix.h:1317
ConstIterator cbegin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1405
size_t rows() const
Returns the number of rows of the dense submatrix.
Definition: DenseSubmatrix.h:1976
Header file for the IsUniLower type trait.
SubmatrixIterator()
Default constructor of the SubmatrixIterator class.
Definition: DenseSubmatrix.h:555
Base class for all submatrices.The Submatrix class serves as a tag for all submatrices (i...
Definition: Submatrix.h:64
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:964
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:809
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
DenseSubmatrix & operator=(const ElementType &rhs)
Homogenous assignment to all submatrix elements.
Definition: DenseSubmatrix.h:1506
const bool aligned
Alignment flag for aligned subvectors and submatrices.
Definition: AlignmentFlag.h:83
Compile time check for data types with restricted data access.This type trait tests whether the given...
Definition: IsRestricted.h:82
SubmatrixTrait< MT >::Type ResultType
Result type for expression template evaluations.
Definition: DenseSubmatrix.h:500
Iterator begin(size_t i)
Returns an iterator to the first non-zero element of row/column i.
Definition: DenseSubmatrix.h:1357
Constraint on the data type.
Header file for the matrix storage order types.
Constraint on the data type.
Compile time check to query the requirement to evaluate an expression.Via this type trait it is possi...
Definition: RequiresEvaluation.h:90
ValueType value_type
Type of the underlying elements.
Definition: DenseSubmatrix.h:546
Compile time check for upper unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniUpper.h:85
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:741
std::iterator_traits< IteratorType >::reference ReferenceType
Reference return type.
Definition: DenseSubmatrix.h:539
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:3164
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
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:680
Constraint on the data type.
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:878
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:116
SubmatrixIterator & operator+=(size_t inc)
Addition assignment operator.
Definition: DenseSubmatrix.h:600
Header file for the Or class template.
bool operator==(const SubmatrixIterator &rhs) const
Equality comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:719
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type store(T *address, const sse_int16_t &value)
Aligned store of a vector of 2-byte integral values.
Definition: Store.h:80
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1602
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
const DenseSubmatrix & CompositeType
Data type for composite expression templates.
Definition: DenseSubmatrix.h:506
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a simple dense...
Definition: Thresholds.h:690
IntrinsicTrait< typename MT::ElementType > IT
Intrinsic trait for the matrix element type.
Definition: DenseSubmatrix.h:483
Header file for the IsLower type trait.
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:3137
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:730
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1197
Constraints on the storage order of matrix types.
const SubmatrixIterator operator++(int)
Post-increment operator.
Definition: DenseSubmatrix.h:634
Compile time check for symmetric matrices.This type trait tests whether or not the given template par...
Definition: IsSymmetric.h:85
SubmatrixIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition: DenseSubmatrix.h:612
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:195
Compile time check for strictly upper triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyUpper.h:86
ResultType::TransposeType TransposeType
Transpose type for expression template evaluations.
Definition: DenseSubmatrix.h:502
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
const size_t final_
The final index for unaligned intrinsic operations.
Definition: DenseSubmatrix.h:1148
Constraint on the data type.
std::iterator_traits< IteratorType >::value_type ValueType
Type of the underlying elements.
Definition: DenseSubmatrix.h:533
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
Header file for the IsAdaptor type trait.
Header file for the isOne shim.
Compile time check for lower unitriangular matrices.This type trait tests whether or not the given te...
Definition: IsUniLower.h:85
Operand matrix_
The dense matrix containing the submatrix.
Definition: DenseSubmatrix.h:1142
Header file for the DerestrictTrait class template.
const bool unaligned
Alignment flag for unaligned subvectors and submatrices.
Definition: AlignmentFlag.h:63
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Constraint on the data type.
IteratorType iterator_
Iterator to the current submatrix element.
Definition: DenseSubmatrix.h:868
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
DenseSubmatrix< MT, AF, SO > This
Type of this DenseSubmatrix instance.
Definition: DenseSubmatrix.h:499
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:871
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Header file for the SubmatrixExprTrait class template.
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2506
Header file for the IsConst type trait.
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
IntrinsicType loadu() const
Unaligned load of an intrinsic element of the dense submatrix.
Definition: DenseSubmatrix.h:695
Header file for run time assertion macros.
Base template for the AddTrait class.
Definition: AddTrait.h:150
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
DifferenceType operator-(const SubmatrixIterator &rhs) const
Calculating the number of elements between two iterators.
Definition: DenseSubmatrix.h:785
Base template for the MultTrait class.
Definition: MultTrait.h:150
Header file for the addition trait.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
Header file for the division trait.
SubmatrixIterator & operator++()
Pre-increment operator.
Definition: DenseSubmatrix.h:623
MT::ReturnType ReturnType
Return type for expression template evaluations.
Definition: DenseSubmatrix.h:505
Header file for the submatrix trait.
If< IsExpression< MT >, MT, MT & >::Type Operand
Composite data type of the dense matrix expression.
Definition: DenseSubmatrix.h:480
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESTRICTED(T)
Constraint on the data type.In case the given data type T does have a restricted data access...
Definition: Restricted.h:118
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:525
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > > >::Type storeu(T *address, const sse_int16_t &value)
Unaligned store of a vector of 2-byte integral values.
Definition: Storeu.h:77
const bool isAligned_
Memory alignment flag.
Definition: DenseSubmatrix.h:1153
Header file for the AlignedArray implementation.
Header file for the cache size of the target architecture.
std::iterator_traits< IteratorType >::iterator_category IteratorCategory
The iterator category.
Definition: DenseSubmatrix.h:530
Compile time type negation.The Not class template negates the given compile time condition. In case the given condition would evaluate to true, the nested member enumeration is set to false and vice versa:
Definition: Not.h:70
bool operator>(const SubmatrixIterator &rhs) const
Greater-than comparison between two SubmatrixIterator objects.
Definition: DenseSubmatrix.h:752
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2510
Header file for the column trait.
Header file for the isDefault shim.
ResultType::OppositeType OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DenseSubmatrix.h:501
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
Constraint on the data type.
PointerType pointer
Pointer return type.
Definition: DenseSubmatrix.h:547
Constraint on the data type.
size_t capacity() const
Returns the maximum capacity of the dense submatrix.
Definition: DenseSubmatrix.h:2026
Header file for the HasMutableDataAccess type trait.
#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
Evaluation of the return type of the derestrict function.Via this type trait it is possible to evalua...
Definition: DerestrictTrait.h:74
Header file for the IsReference type trait.
const SubmatrixIterator operator--(int)
Post-decrement operator.
Definition: DenseSubmatrix.h:655
Header file for the RemoveReference type trait.
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:869
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:3237
IfTrue< useConst, ConstReference, typename MT::Reference >::Type Reference
Reference to a non-constant submatrix value.
Definition: DenseSubmatrix.h:512
Header file for all intrinsic functionality.
IteratorType final() const
Access to the final position of the submatrix iterator.
Definition: DenseSubmatrix.h:841
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
size_t nonZeros() const
Returns the number of non-zero elements in the dense submatrix.
Definition: DenseSubmatrix.h:2066
IteratorType base() const
Access to the current position of the submatrix iterator.
Definition: DenseSubmatrix.h:831
IT::Type IntrinsicType
Intrinsic type of the submatrix elements.
Definition: DenseSubmatrix.h:504
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2666
MT::ConstReference ConstReference
Reference to a constant submatrix value.
Definition: DenseSubmatrix.h:509
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:143
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:937
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
CompressedMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:260
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
size_t rest_
The number of remaining elements beyond the final iterator.
Definition: DenseSubmatrix.h:870
std::iterator_traits< IteratorType >::pointer PointerType
Pointer return type.
Definition: DenseSubmatrix.h:536
#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:2502
View on a specific submatrix of a dense matrix.The DenseSubmatrix template represents a view on a spe...
Definition: DenseSubmatrix.h:474
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
bool canSMPAssign() const
Returns whether the submatrix can be used in SMP assignments.
Definition: DenseSubmatrix.h:3110
Compile time type check.This class tests whether the given template parameter T is a reference type (...
Definition: IsReference.h:94
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DenseSubmatrix.h:2011
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:2508
Base template for the SubTrait class.
Definition: SubTrait.h:150
Header file for the Submatrix base class.
const size_t m_
The number of rows of the submatrix.
Definition: DenseSubmatrix.h:1145
Header file for the IsUpper type trait.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the submatrix.
Definition: DenseSubmatrix.h:3211
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
friend const SubmatrixIterator operator-(const SubmatrixIterator &it, size_t dec)
Subtraction between a SubmatrixIterator and an integral value.
Definition: DenseSubmatrix.h:821
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
EnableIf< IsNumeric< Type >, bool >::Type isOne(const Type &v)
Returns whether the given value/object represents the numeric value 1.
Definition: IsOne.h:80
Header file for the IsRestricted type trait.
System settings for the inline keywords.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
SubmatrixIterator & operator--()
Pre-decrement operator.
Definition: DenseSubmatrix.h:644
#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:774
Compile time type selection.The IfTrue class template selects one of the two given types T1 and T2 de...
Definition: If.h:59
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:797
Constraint on the data type.
Header file for the FunctionTrace class.
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849