35 #ifndef _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
36 #define _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
181 template<
typename Type
185 class HybridMatrix :
public DenseMatrix< HybridMatrix<Type,M,N,SO>, SO >
194 enum { NN = N + ( IT::size - ( N % IT::size ) ) % IT::size };
227 enum { smpAssignable = 0 };
235 explicit inline HybridMatrix(
size_t m,
size_t n,
const Type& init );
236 template<
typename Other >
explicit inline HybridMatrix(
size_t m,
size_t n,
const Other* array );
238 template<
typename Other,
size_t M2,
size_t N2 >
239 explicit inline HybridMatrix(
const Other (&array)[M2][N2] );
242 template<
typename MT,
bool SO2 >
inline HybridMatrix(
const Matrix<MT,SO2>& m );
271 template<
typename Other,
size_t M2,
size_t N2 >
272 inline HybridMatrix& operator=(
const Other (&array)[M2][N2] );
276 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator= (
const Matrix<MT,SO2>& rhs );
277 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator+=(
const Matrix<MT,SO2>& rhs );
278 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator-=(
const Matrix<MT,SO2>& rhs );
279 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator*=(
const Matrix<MT,SO2>& rhs );
281 template<
typename Other >
282 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
283 operator*=( Other rhs );
285 template<
typename Other >
286 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
287 operator/=( Other rhs );
294 inline size_t rows()
const;
298 inline size_t capacity(
size_t i )
const;
300 inline size_t nonZeros(
size_t i )
const;
302 inline void reset(
size_t i );
304 void resize (
size_t m,
size_t n,
bool preserve=
true );
305 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
307 template<
typename Other >
inline HybridMatrix& scale(
const Other& scalar );
315 static inline void*
operator new ( std::size_t size );
316 static inline void*
operator new[]( std::size_t size );
317 static inline void*
operator new ( std::size_t size,
const std::nothrow_t& );
318 static inline void*
operator new[]( std::size_t size,
const std::nothrow_t& );
320 static inline void operator delete (
void* ptr );
321 static inline void operator delete[](
void* ptr );
322 static inline void operator delete (
void* ptr,
const std::nothrow_t& );
323 static inline void operator delete[](
void* ptr,
const std::nothrow_t& );
330 template<
typename MT >
332 struct VectorizedAssign {
333 enum { value = vectorizable && MT::vectorizable &&
334 IsSame<Type,typename MT::ElementType>::value &&
335 IsRowMajorMatrix<MT>::value };
342 template<
typename MT >
344 struct VectorizedAddAssign {
345 enum { value = vectorizable && MT::vectorizable &&
346 IsSame<Type,typename MT::ElementType>::value &&
347 IntrinsicTrait<Type>::addition &&
348 IsRowMajorMatrix<MT>::value };
355 template<
typename MT >
357 struct VectorizedSubAssign {
358 enum { value = vectorizable && MT::vectorizable &&
359 IsSame<Type,typename MT::ElementType>::value &&
360 IntrinsicTrait<Type>::subtraction &&
361 IsRowMajorMatrix<MT>::value };
370 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
371 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
381 template<
typename MT,
bool SO2 >
382 inline typename DisableIf< VectorizedAssign<MT> >::Type
383 assign(
const DenseMatrix<MT,SO2>& rhs );
385 template<
typename MT,
bool SO2 >
386 inline typename EnableIf< VectorizedAssign<MT> >::Type
387 assign(
const DenseMatrix<MT,SO2>& rhs );
389 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
390 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
392 template<
typename MT,
bool SO2 >
393 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
394 addAssign(
const DenseMatrix<MT,SO2>& rhs );
396 template<
typename MT,
bool SO2 >
397 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
398 addAssign(
const DenseMatrix<MT,SO2>& rhs );
400 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
401 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
403 template<
typename MT,
bool SO2 >
404 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
405 subAssign(
const DenseMatrix<MT,SO2>& rhs );
407 template<
typename MT,
bool SO2 >
408 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
409 subAssign(
const DenseMatrix<MT,SO2>& rhs );
411 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
412 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
462 template<
typename Type
472 for(
size_t i=0UL; i<M*NN; ++i )
492 template<
typename Type
502 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
505 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
508 for(
size_t i=0UL; i<M*NN; ++i )
529 template<
typename Type
539 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
542 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
544 for(
size_t i=0UL; i<m; ++i ) {
545 for(
size_t j=0UL; j<n; ++j )
549 for(
size_t j=n; j<NN; ++j )
555 for(
size_t i=m; i<M; ++i )
556 for(
size_t j=0UL; j<NN; ++j )
590 template<
typename Type
594 template<
typename Other >
601 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
604 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
606 for(
size_t i=0UL; i<m; ++i ) {
607 for(
size_t j=0UL; j<n; ++j )
608 v_[i*NN+j] = array[i*n+j];
611 for(
size_t j=n; j<NN; ++j )
617 for(
size_t i=m; i<M; ++i )
618 for(
size_t j=0UL; j<NN; ++j )
646 template<
typename Type
650 template<
typename Other
661 for(
size_t i=0UL; i<M2; ++i ) {
662 for(
size_t j=0UL; j<N2; ++j )
663 v_[i*NN+j] = array[i][j];
666 for(
size_t j=N2; j<NN; ++j )
672 for(
size_t i=M2; i<M; ++i )
673 for(
size_t j=0UL; j<NN; ++j )
688 template<
typename Type
697 for(
size_t i=0UL; i<
m_; ++i ) {
698 for(
size_t j=0UL; j<
n_; ++j )
699 v_[i*NN+j] = m.v_[i*NN+j];
702 for(
size_t j=n_; j<NN; ++j )
708 for(
size_t i=m_; i<M; ++i )
709 for(
size_t j=0UL; j<NN; ++j )
722 template<
typename Type
726 template<
typename MT
736 throw std::invalid_argument(
"Invalid setup of hybrid matrix" );
738 for(
size_t i=0UL; i<
m_; ++i ) {
740 j<( IsVectorizable<Type>::value ? NN :
n_ ); ++j ) {
746 for(
size_t i=m_; i<M; ++i )
747 for(
size_t j=0UL; j<NN; ++j )
771 template<
typename Type
792 template<
typename Type
818 template<
typename Type
842 template<
typename Type
862 template<
typename Type
883 template<
typename Type
907 template<
typename Type
931 template<
typename Type
955 template<
typename Type
979 template<
typename Type
1003 template<
typename Type
1027 template<
typename Type
1069 template<
typename Type
1073 template<
typename Other
1083 for(
size_t i=0UL; i<M2; ++i )
1084 for(
size_t j=0UL; j<N2; ++j )
1085 v_[i*NN+j] = array[i][j];
1098 template<
typename Type
1107 for(
size_t i=0UL; i<
m_; ++i )
1108 for(
size_t j=0UL; j<
n_; ++j )
1124 template<
typename Type
1135 resize( rhs.rows(), rhs.columns() );
1154 template<
typename Type
1158 template<
typename MT
1165 throw std::invalid_argument(
"Invalid assignment to hybrid matrix" );
1167 if( (~rhs).canAlias(
this ) ) {
1193 template<
typename Type
1197 template<
typename MT
1204 throw std::invalid_argument(
"Matrix sizes do not match" );
1206 if( (~rhs).canAlias(
this ) ) {
1229 template<
typename Type
1233 template<
typename MT
1240 throw std::invalid_argument(
"Matrix sizes do not match" );
1242 if( (~rhs).canAlias(
this ) ) {
1265 template<
typename Type
1269 template<
typename MT
1274 throw std::invalid_argument(
"Matrix sizes do not match" );
1277 return this->operator=( tmp );
1289 template<
typename Type
1293 template<
typename Other >
1299 assign( *
this, (*
this) * rhs );
1314 template<
typename Type
1318 template<
typename Other >
1326 assign( *
this, (*
this) / rhs );
1345 template<
typename Type
1361 template<
typename Type
1380 template<
typename Type
1396 template<
typename Type
1418 template<
typename Type
1438 template<
typename Type
1444 size_t nonzeros( 0UL );
1446 for(
size_t i=0UL; i<
m_; ++i )
1447 for(
size_t j=0UL; j<
n_; ++j )
1467 template<
typename Type
1475 const size_t jend( i*NN+
n_ );
1476 size_t nonzeros( 0UL );
1478 for(
size_t j=i*NN; j<jend; ++j )
1492 template<
typename Type
1500 for(
size_t i=0UL; i<
m_; ++i )
1501 for(
size_t j=0UL; j<
n_; ++j )
1502 reset( v_[i*NN+j] );
1518 template<
typename Type
1527 for(
size_t j=0UL; j<
n_; ++j )
1528 reset( v_[i*NN+j] );
1540 template<
typename Type
1587 template<
typename Type
1596 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
1599 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
1602 for(
size_t i=0UL; i<m; ++i )
1603 for(
size_t j=n; j<
n_; ++j )
1604 v_[i*NN+j] = Type();
1608 for(
size_t i=m; i<
m_; ++i )
1609 for(
size_t j=0UL; j<
n_; ++j )
1610 v_[i*NN+j] = Type();
1634 template<
typename Type
1641 resize(
m_+m,
n_+n );
1657 template<
typename Type
1665 if(
m_ > N ||
n_ > M )
1666 throw std::logic_error(
"Impossible transpose operation" );
1668 const size_t maxsize( max(
m_,
n_ ) );
1669 for(
size_t i=1UL; i<maxsize; ++i )
1670 for(
size_t j=0UL; j<i; ++j )
1671 swap( v_[i*NN+j], v_[j*NN+i] );
1674 for(
size_t i=0UL; i<
m_; ++i ) {
1675 for(
size_t j=m_; j<
n_; ++j ) {
1676 v_[i*NN+j] = Type();
1682 for(
size_t i=
n_; i<
m_; ++i ) {
1683 for(
size_t j=0UL; j<
n_; ++j ) {
1684 v_[i*NN+j] = Type();
1702 template<
typename Type
1706 template<
typename Other >
1709 for(
size_t i=0UL; i<
m_; ++i )
1710 for(
size_t j=0UL; j<
n_; ++j )
1711 v_[i*NN+j] *= scalar;
1725 template<
typename Type
1733 const size_t maxrows( max(
m_, m.m_ ) );
1734 const size_t maxcols( max(
n_, m.n_ ) );
1736 for(
size_t i=0UL; i<maxrows; ++i ) {
1737 for(
size_t j=0UL; j<maxcols; ++j ) {
1738 swap( v_[i*NN+j], m(i,j) );
1766 template<
typename Type
1776 return allocate<HybridMatrix>( 1UL );
1791 template<
typename Type
1800 return allocate<HybridMatrix>( size/
sizeof(
HybridMatrix) );
1815 template<
typename Type
1825 return allocate<HybridMatrix>( 1UL );
1840 template<
typename Type
1849 return allocate<HybridMatrix>( size/
sizeof(
HybridMatrix) );
1860 template<
typename Type
1866 deallocate( static_cast<HybridMatrix*>( ptr ) );
1877 template<
typename Type
1883 deallocate( static_cast<HybridMatrix*>( ptr ) );
1894 template<
typename Type
1900 deallocate( static_cast<HybridMatrix*>( ptr ) );
1911 template<
typename Type
1917 deallocate( static_cast<HybridMatrix*>( ptr ) );
1940 template<
typename Type
1944 template<
typename Other >
1947 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1962 template<
typename Type
1966 template<
typename Other >
1969 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1983 template<
typename Type
2009 template<
typename Type
2025 return load( &v_[i*NN+j] );
2045 template<
typename Type
2060 return loadu( &v_[i*NN+j] );
2081 template<
typename Type
2096 store( &v_[i*NN+j], value );
2117 template<
typename Type
2131 storeu( &v_[i*NN+j], value );
2152 template<
typename Type
2167 stream( &v_[i*NN+j], value );
2183 template<
typename Type
2187 template<
typename MT
2194 for(
size_t i=0UL; i<
m_; ++i ) {
2195 for(
size_t j=0UL; j<
n_; ++j ) {
2196 v_[i*NN+j] = (~rhs)(i,j);
2214 template<
typename Type
2218 template<
typename MT
2229 for(
size_t i=0UL; i<
m_; ++i ) {
2230 for(
size_t j=0UL; j<
n_; j+=IT::size ) {
2249 template<
typename Type
2253 template<
typename MT >
2260 for(
size_t i=0UL; i<
m_; ++i )
2261 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2262 v_[i*NN+element->index()] = element->value();
2278 template<
typename Type
2282 template<
typename MT >
2289 for(
size_t j=0UL; j<
n_; ++j )
2290 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2291 v_[element->index()*NN+j] = element->value();
2307 template<
typename Type
2311 template<
typename MT
2318 for(
size_t i=0UL; i<
m_; ++i ) {
2319 for(
size_t j=0UL; j<
n_; ++j ) {
2320 v_[i*NN+j] += (~rhs)(i,j);
2338 template<
typename Type
2342 template<
typename MT
2354 for(
size_t i=0UL; i<
m_; ++i ) {
2355 for(
size_t j=0UL; j<
n_; j+=IT::size ) {
2356 store( &v_[i*NN+j],
load( &v_[i*NN+j] ) + (~rhs).
load(i,j) );
2374 template<
typename Type
2378 template<
typename MT >
2385 for(
size_t i=0UL; i<
m_; ++i )
2386 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2387 v_[i*NN+element->index()] += element->value();
2403 template<
typename Type
2407 template<
typename MT >
2414 for(
size_t j=0UL; j<
n_; ++j )
2415 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2416 v_[element->index()*NN+j] += element->value();
2432 template<
typename Type
2436 template<
typename MT
2443 for(
size_t i=0UL; i<
m_; ++i ) {
2444 for(
size_t j=0UL; j<
n_; ++j ) {
2445 v_[i*NN+j] -= (~rhs)(i,j);
2463 template<
typename Type
2467 template<
typename MT
2479 for(
size_t i=0UL; i<
m_; ++i ) {
2480 for(
size_t j=0UL; j<
n_; j+=IT::size ) {
2481 store( &v_[i*NN+j],
load( &v_[i*NN+j] ) - (~rhs).
load(i,j) );
2499 template<
typename Type
2503 template<
typename MT >
2510 for(
size_t i=0UL; i<
m_; ++i )
2511 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2512 v_[i*NN+element->index()] -= element->value();
2528 template<
typename Type
2532 template<
typename MT >
2539 for(
size_t j=0UL; j<
n_; ++j )
2540 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2541 v_[element->index()*NN+j] -= element->value();
2566 template<
typename Type
2578 enum { MM = M + ( IT::size - ( M % IT::size ) ) % IT::size };
2583 typedef HybridMatrix<Type,M,N,true>
This;
2595 typedef DenseIterator<Type>
Iterator;
2605 enum { vectorizable = IsVectorizable<Type>::value };
2611 enum { smpAssignable = 0 };
2619 explicit inline HybridMatrix(
size_t m,
size_t n,
const Type& init );
2620 template<
typename Other >
explicit inline HybridMatrix(
size_t m,
size_t n,
const Other* array );
2622 template<
typename Other,
size_t M2,
size_t N2 >
2623 explicit inline HybridMatrix(
const Other (&array)[M2][N2] );
2626 template<
typename MT,
bool SO >
inline HybridMatrix(
const Matrix<MT,SO>& m );
2655 template<
typename Other,
size_t M2,
size_t N2 >
2656 inline HybridMatrix& operator=(
const Other (&array)[M2][N2] );
2660 template<
typename MT,
bool SO >
inline HybridMatrix& operator= (
const Matrix<MT,SO>& rhs );
2661 template<
typename MT,
bool SO >
inline HybridMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2662 template<
typename MT,
bool SO >
inline HybridMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2663 template<
typename MT,
bool SO >
inline HybridMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2665 template<
typename Other >
2666 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
2667 operator*=( Other rhs );
2669 template<
typename Other >
2670 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
2671 operator/=( Other rhs );
2678 inline size_t rows()
const;
2679 inline size_t columns()
const;
2680 inline size_t spacing()
const;
2682 inline size_t capacity(
size_t j )
const;
2684 inline size_t nonZeros(
size_t j )
const;
2685 inline void reset();
2686 inline void reset(
size_t i );
2687 inline void clear();
2688 void resize (
size_t m,
size_t n,
bool preserve=
true );
2689 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2691 template<
typename Other >
inline HybridMatrix& scale(
const Other& scalar );
2699 static inline void*
operator new ( std::size_t size );
2700 static inline void*
operator new[]( std::size_t size );
2701 static inline void*
operator new ( std::size_t size,
const std::nothrow_t& );
2702 static inline void*
operator new[]( std::size_t size,
const std::nothrow_t& );
2704 static inline void operator delete (
void* ptr );
2705 static inline void operator delete[](
void* ptr );
2706 static inline void operator delete (
void* ptr,
const std::nothrow_t& );
2707 static inline void operator delete[](
void* ptr,
const std::nothrow_t& );
2714 template<
typename MT >
2715 struct VectorizedAssign {
2716 enum { value = vectorizable && MT::vectorizable &&
2717 IsSame<Type,typename MT::ElementType>::value &&
2718 IsColumnMajorMatrix<MT>::value };
2724 template<
typename MT >
2725 struct VectorizedAddAssign {
2726 enum { value = vectorizable && MT::vectorizable &&
2727 IsSame<Type,typename MT::ElementType>::value &&
2728 IntrinsicTrait<Type>::addition &&
2729 IsColumnMajorMatrix<MT>::value };
2735 template<
typename MT >
2736 struct VectorizedSubAssign {
2737 enum { value = vectorizable && MT::vectorizable &&
2738 IsSame<Type,typename MT::ElementType>::value &&
2739 IntrinsicTrait<Type>::subtraction &&
2740 IsColumnMajorMatrix<MT>::value };
2748 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2749 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2759 template<
typename MT,
bool SO >
2760 inline typename DisableIf< VectorizedAssign<MT> >::Type
2761 assign(
const DenseMatrix<MT,SO>& rhs );
2763 template<
typename MT,
bool SO >
2764 inline typename EnableIf< VectorizedAssign<MT> >::Type
2765 assign(
const DenseMatrix<MT,SO>& rhs );
2767 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2768 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2770 template<
typename MT,
bool SO >
2771 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2772 addAssign(
const DenseMatrix<MT,SO>& rhs );
2774 template<
typename MT,
bool SO >
2775 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2776 addAssign(
const DenseMatrix<MT,SO>& rhs );
2778 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2779 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2781 template<
typename MT,
bool SO >
2782 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2783 subAssign(
const DenseMatrix<MT,SO>& rhs );
2785 template<
typename MT,
bool SO >
2786 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2787 subAssign(
const DenseMatrix<MT,SO>& rhs );
2789 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2790 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2798 AlignedArray<Type,MM*N>
v_;
2833 template<
typename Type
2841 if( IsVectorizable<Type>::value ) {
2842 for(
size_t i=0UL; i<MM*N; ++i )
2864 template<
typename Type
2873 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
2876 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
2878 if( IsVectorizable<Type>::value ) {
2879 for(
size_t i=0UL; i<MM*N; ++i )
2902 template<
typename Type
2911 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
2914 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
2916 for(
size_t j=0UL; j<n; ++j ) {
2917 for(
size_t i=0UL; i<m; ++i )
2920 if( IsVectorizable<Type>::value ) {
2921 for(
size_t i=m; i<MM; ++i )
2922 v_[i+j*MM] = Type();
2926 if( IsVectorizable<Type>::value ) {
2927 for(
size_t j=n; j<N; ++j )
2928 for(
size_t i=0UL; i<MM; ++i )
2929 v_[i+j*MM] = Type();
2964 template<
typename Type
2967 template<
typename Other >
2974 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
2977 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
2979 for(
size_t j=0UL; j<n; ++j ) {
2980 for(
size_t i=0UL; i<m; ++i )
2981 v_[i+j*MM] = array[i+j*m];
2983 if( IsVectorizable<Type>::value ) {
2984 for(
size_t i=m; i<MM; ++i )
2985 v_[i+j*MM] = Type();
2989 if( IsVectorizable<Type>::value ) {
2990 for(
size_t j=n; j<N; ++j )
2991 for(
size_t i=0UL; i<MM; ++i )
2992 v_[i+j*MM] = Type();
3021 template<
typename Type
3024 template<
typename Other
3035 for(
size_t j=0UL; j<N2; ++j ) {
3036 for(
size_t i=0UL; i<M2; ++i )
3037 v_[i+j*MM] = array[i][j];
3039 if( IsVectorizable<Type>::value ) {
3040 for(
size_t i=M2; i<MM; ++i )
3041 v_[i+j*MM] = Type();
3045 if( IsVectorizable<Type>::value ) {
3046 for(
size_t j=N2; j<N; ++j )
3047 for(
size_t i=0UL; i<MM; ++i )
3048 v_[i+j*MM] = Type();
3064 template<
typename Type
3072 for(
size_t j=0UL; j<
n_; ++j ) {
3073 for(
size_t i=0UL; i<
m_; ++i )
3074 v_[i+j*MM] = m.v_[i+j*MM];
3076 if( IsVectorizable<Type>::value ) {
3077 for(
size_t i=m_; i<MM; ++i )
3078 v_[i+j*MM] = Type();
3082 if( IsVectorizable<Type>::value ) {
3083 for(
size_t j=n_; j<N; ++j )
3084 for(
size_t i=0UL; i<MM; ++i )
3085 v_[i+j*MM] = Type();
3099 template<
typename Type
3102 template<
typename MT
3112 throw std::invalid_argument(
"Invalid setup of hybrid matrix" );
3114 for(
size_t j=0UL; j<
n_; ++j ) {
3115 for(
size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
3116 i<( IsVectorizable<Type>::value ? MM :
m_ ); ++i ) {
3117 v_[i+j*MM] = Type();
3121 if( IsVectorizable<Type>::value ) {
3122 for(
size_t j=n_; j<N; ++j )
3123 for(
size_t i=0UL; i<MM; ++i )
3124 v_[i+j*MM] = Type();
3127 assign( *
this, ~m );
3149 template<
typename Type
3171 template<
typename Type
3197 template<
typename Type
3200 inline typename HybridMatrix<Type,M,N,true>::Pointer
3221 template<
typename Type
3224 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3242 template<
typename Type
3245 inline typename HybridMatrix<Type,M,N,true>::Pointer
3264 template<
typename Type
3267 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3284 template<
typename Type
3304 template<
typename Type
3324 template<
typename Type
3344 template<
typename Type
3364 template<
typename Type
3384 template<
typename Type
3427 template<
typename Type
3430 template<
typename Other
3433 inline HybridMatrix<Type,M,N,true>&
3434 HybridMatrix<Type,M,N,true>::operator=(
const Other (&array)[M2][N2] )
3441 for(
size_t j=0UL; j<N2; ++j )
3442 for(
size_t i=0UL; i<M2; ++i )
3443 v_[i+j*MM] = array[i][j];
3458 template<
typename Type
3461 inline HybridMatrix<Type,M,N,true>&
3462 HybridMatrix<Type,M,N,true>::operator=(
const Type&
set )
3467 for(
size_t j=0UL; j<
n_; ++j )
3468 for(
size_t i=0UL; i<
m_; ++i )
3486 template<
typename Type
3489 inline HybridMatrix<Type,M,N,true>&
3490 HybridMatrix<Type,M,N,true>::operator=(
const HybridMatrix& rhs )
3497 resize( rhs.rows(), rhs.columns() );
3518 template<
typename Type
3521 template<
typename MT
3523 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator=(
const Matrix<MT,SO>& rhs )
3528 throw std::invalid_argument(
"Invalid assignment to hybrid matrix" );
3530 if( (~rhs).canAlias(
this ) ) {
3531 HybridMatrix tmp( ~rhs );
3536 if( IsSparseMatrix<MT>::value )
3558 template<
typename Type
3561 template<
typename MT
3563 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator+=(
const Matrix<MT,SO>& rhs )
3567 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3568 throw std::invalid_argument(
"Matrix sizes do not match" );
3570 if( (~rhs).canAlias(
this ) ) {
3595 template<
typename Type
3598 template<
typename MT
3600 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator-=(
const Matrix<MT,SO>& rhs )
3604 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3605 throw std::invalid_argument(
"Matrix sizes do not match" );
3607 if( (~rhs).canAlias(
this ) ) {
3632 template<
typename Type
3635 template<
typename MT
3637 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator*=(
const Matrix<MT,SO>& rhs )
3640 throw std::invalid_argument(
"Matrix sizes do not match" );
3642 HybridMatrix tmp( *
this * (~rhs) );
3643 return this->operator=( tmp );
3657 template<
typename Type
3660 template<
typename Other >
3661 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3662 HybridMatrix<Type,M,N,true>::operator*=( Other rhs )
3666 assign( *
this, (*
this) * rhs );
3683 template<
typename Type
3686 template<
typename Other >
3687 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3688 HybridMatrix<Type,M,N,true>::operator/=( Other rhs )
3694 assign( *
this, (*
this) / rhs );
3715 template<
typename Type
3732 template<
typename Type
3752 template<
typename Type
3769 template<
typename Type
3787 template<
typename Type
3808 template<
typename Type
3813 size_t nonzeros( 0UL );
3815 for(
size_t j=0UL; j<
n_; ++j )
3816 for(
size_t i=0UL; i<
m_; ++i )
3833 template<
typename Type
3840 const size_t iend( j*MM+m_ );
3841 size_t nonzeros( 0UL );
3843 for(
size_t i=j*MM; i<iend; ++i )
3859 template<
typename Type
3866 for(
size_t j=0UL; j<
n_; ++j )
3867 for(
size_t i=0UL; i<
m_; ++i )
3868 reset( v_[i+j*MM] );
3884 template<
typename Type
3892 for(
size_t i=0UL; i<
m_; ++i )
3893 reset( v_[i+j*MM] );
3907 template<
typename Type
3955 template<
typename Type
3963 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
3966 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
3968 if( IsVectorizable<Type>::value && m < m_ ) {
3969 for(
size_t j=0UL; j<n; ++j )
3970 for(
size_t i=m; i<
m_; ++i )
3971 v_[i+j*MM] = Type();
3974 if( IsVectorizable<Type>::value && n < n_ ) {
3975 for(
size_t j=n; j<
n_; ++j )
3976 for(
size_t i=0UL; i<
m_; ++i )
3977 v_[i+j*MM] = Type();
4003 template<
typename Type
4009 resize( m_+m, n_+n );
4027 template<
typename Type
4034 if( m_ > N || n_ > M )
4035 throw std::logic_error(
"Impossible transpose operation" );
4037 const size_t maxsize( max( m_, n_ ) );
4038 for(
size_t j=1UL; j<maxsize; ++j )
4039 for(
size_t i=0UL; i<j; ++i )
4040 swap( v_[i+j*MM], v_[j+i*MM] );
4042 if( IsVectorizable<Type>::value && n_ < m_ ) {
4043 for(
size_t j=0UL; j<
n_; ++j ) {
4044 for(
size_t i=n_; i<
m_; ++i ) {
4045 v_[i+j*MM] = Type();
4050 if( IsVectorizable<Type>::value && n_ > m_ ) {
4051 for(
size_t j=m_; j<
n_; ++j )
4052 for(
size_t i=0UL; i<
m_; ++i )
4053 v_[i+j*MM] = Type();
4071 template<
typename Type
4074 template<
typename Other >
4075 inline HybridMatrix<Type,M,N,true>&
4076 HybridMatrix<Type,M,N,true>::scale(
const Other& scalar )
4078 for(
size_t j=0UL; j<
n_; ++j )
4079 for(
size_t i=0UL; i<
m_; ++i )
4080 v_[i+j*MM] *= scalar;
4096 template<
typename Type
4103 const size_t maxrows( max( m_, m.m_ ) );
4104 const size_t maxcols( max( n_, m.n_ ) );
4106 for(
size_t j=0UL; j<maxcols; ++j ) {
4107 for(
size_t i=0UL; i<maxrows; ++i ) {
4108 swap( v_[i+j*MM], m(i,j) );
4138 template<
typename Type
4141 inline void* HybridMatrix<Type,M,N,true>::operator
new( std::size_t size )
4147 return allocate<HybridMatrix>( 1UL );
4164 template<
typename Type
4167 inline void* HybridMatrix<Type,M,N,true>::operator
new[]( std::size_t size )
4172 return allocate<HybridMatrix>( size/
sizeof(HybridMatrix) );
4189 template<
typename Type
4192 inline void* HybridMatrix<Type,M,N,true>::operator
new( std::size_t size,
const std::nothrow_t& )
4198 return allocate<HybridMatrix>( 1UL );
4215 template<
typename Type
4218 inline void* HybridMatrix<Type,M,N,true>::operator
new[]( std::size_t size,
const std::nothrow_t& )
4223 return allocate<HybridMatrix>( size/
sizeof(HybridMatrix) );
4236 template<
typename Type
4239 inline void HybridMatrix<Type,M,N,true>::operator
delete(
void* ptr )
4241 deallocate( static_cast<HybridMatrix*>( ptr ) );
4254 template<
typename Type
4257 inline void HybridMatrix<Type,M,N,true>::operator
delete[](
void* ptr )
4259 deallocate( static_cast<HybridMatrix*>( ptr ) );
4272 template<
typename Type
4275 inline void HybridMatrix<Type,M,N,true>::operator
delete(
void* ptr,
const std::nothrow_t& )
4277 deallocate( static_cast<HybridMatrix*>( ptr ) );
4290 template<
typename Type
4293 inline void HybridMatrix<Type,M,N,true>::operator
delete[](
void* ptr,
const std::nothrow_t& )
4295 deallocate( static_cast<HybridMatrix*>( ptr ) );
4320 template<
typename Type
4323 template<
typename Other >
4326 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4343 template<
typename Type
4346 template<
typename Other >
4349 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4365 template<
typename Type
4391 template<
typename Type
4394 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4406 return load( &v_[i+j*MM] );
4427 template<
typename Type
4430 inline typename HybridMatrix<Type,M,N,true>::IntrinsicType
4441 return loadu( &v_[i+j*MM] );
4463 template<
typename Type
4477 store( &v_[i+j*MM], value );
4499 template<
typename Type
4512 storeu( &v_[i+j*MM], value );
4535 template<
typename Type
4549 stream( &v_[i+j*MM], value );
4567 template<
typename Type
4570 template<
typename MT
4572 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4577 for(
size_t j=0UL; j<
n_; ++j ) {
4578 for(
size_t i=0UL; i<
m_; ++i ) {
4579 v_[i+j*MM] = (~rhs)(i,j);
4599 template<
typename Type
4602 template<
typename MT
4604 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4613 for(
size_t j=0UL; j<
n_; ++j ) {
4614 for(
size_t i=0UL; i<
m_; i+=IT::size ) {
4635 template<
typename Type
4638 template<
typename MT >
4645 for(
size_t j=0UL; j<
n_; ++j )
4646 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4647 v_[element->index()+j*MM] = element->value();
4665 template<
typename Type
4668 template<
typename MT >
4675 for(
size_t i=0UL; i<
m_; ++i )
4676 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4677 v_[i+element->index()*MM] = element->value();
4695 template<
typename Type
4698 template<
typename MT
4700 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4705 for(
size_t j=0UL; j<
n_; ++j ) {
4706 for(
size_t i=0UL; i<
m_; ++i ) {
4707 v_[i+j*MM] += (~rhs)(i,j);
4727 template<
typename Type
4730 template<
typename MT
4732 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4742 for(
size_t j=0UL; j<
n_; ++j ) {
4743 for(
size_t i=0UL; i<
m_; i+=IT::size ) {
4744 store( &v_[i+j*MM],
load( &v_[i+j*MM] ) + (~rhs).
load(i,j) );
4764 template<
typename Type
4767 template<
typename MT >
4774 for(
size_t j=0UL; j<
n_; ++j )
4775 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4776 v_[element->index()+j*MM] += element->value();
4794 template<
typename Type
4797 template<
typename MT >
4804 for(
size_t i=0UL; i<
m_; ++i )
4805 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4806 v_[i+element->index()*MM] += element->value();
4824 template<
typename Type
4827 template<
typename MT
4829 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4834 for(
size_t j=0UL; j<
n_; ++j ) {
4835 for(
size_t i=0UL; i<
m_; ++i ) {
4836 v_[i+j*MM] -= (~rhs)(i,j);
4856 template<
typename Type
4859 template<
typename MT
4861 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4871 for(
size_t j=0UL; j<
n_; ++j ) {
4872 for(
size_t i=0UL; i<
m_; i+=IT::size ) {
4873 store( &v_[i+j*MM],
load( &v_[i+j*MM] ) - (~rhs).
load(i,j) );
4893 template<
typename Type
4896 template<
typename MT >
4903 for(
size_t j=0UL; j<
n_; ++j )
4904 for( RhsConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4905 v_[element->index()+j*MM] -= element->value();
4923 template<
typename Type
4926 template<
typename MT >
4933 for(
size_t i=0UL; i<
m_; ++i )
4934 for( RhsConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4935 v_[i+element->index()*MM] -= element->value();
4961 template<
typename Type
4964 class HybridMatrix<Type,M,0UL,SO>;
4977 template<
typename Type
4980 class HybridMatrix<Type,0UL,N,SO>;
4993 template<
typename Type
4995 class HybridMatrix<Type,0UL,0UL,SO>;
5015 template<
typename Type,
size_t M,
size_t N,
bool SO >
5016 inline void reset( HybridMatrix<Type,M,N,SO>& m );
5018 template<
typename Type,
size_t M,
size_t N,
bool SO >
5019 inline void clear( HybridMatrix<Type,M,N,SO>& m );
5021 template<
typename Type,
size_t M,
size_t N,
bool SO >
5022 inline bool isDefault(
const HybridMatrix<Type,M,N,SO>& m );
5024 template<
typename Type,
size_t M,
size_t N,
bool SO >
5025 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) ;
5037 template<
typename Type
5057 template<
typename Type
5075 template<
typename Type
5082 for(
size_t i=0UL; i<m.rows(); ++i )
5083 for(
size_t j=0UL; j<m.columns(); ++j )
5084 if( !
isDefault( m(i,j) ) )
return false;
5087 for(
size_t j=0UL; j<m.columns(); ++j )
5088 for(
size_t i=0UL; i<m.rows(); ++i )
5089 if( !
isDefault( m(i,j) ) )
return false;
5106 template<
typename Type
5127 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5128 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5130 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5133 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5134 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5136 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2,
false > Type;
5139 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5140 struct AddTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5142 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5145 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5146 struct AddTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5148 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2,
false > Type;
5151 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5152 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5154 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5157 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5158 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5160 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5176 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5177 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5179 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5182 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5183 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5185 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2,
false > Type;
5188 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5189 struct SubTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5191 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5194 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5195 struct SubTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5197 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2,
false > Type;
5200 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5201 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5203 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5206 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5207 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5209 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5225 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5226 struct MultTrait< HybridMatrix<T1,M,N,SO>, T2 >
5228 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5232 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5233 struct MultTrait< T1, HybridMatrix<T2,M,N,SO> >
5235 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5239 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2,
size_t K >
5240 struct MultTrait< HybridMatrix<T1,M,N,SO>, StaticVector<T2,K,false> >
5242 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5245 template<
typename T1,
size_t K,
typename T2,
size_t M,
size_t N,
bool SO >
5246 struct MultTrait< StaticVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5248 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5251 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2,
size_t K >
5252 struct MultTrait< HybridMatrix<T1,M,N,SO>, HybridVector<T2,K,false> >
5254 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5257 template<
typename T1,
size_t K,
typename T2,
size_t M,
size_t N,
bool SO >
5258 struct MultTrait< HybridVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5260 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5263 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5264 struct MultTrait< HybridMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5266 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5269 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5270 struct MultTrait< DynamicVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5272 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5275 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5276 struct MultTrait< HybridMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5278 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5281 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5282 struct MultTrait< CompressedVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5284 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5287 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5288 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5290 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5293 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5294 struct MultTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5296 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5299 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5300 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5302 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5318 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5319 struct DivTrait< HybridMatrix<T1,M,N,SO>, T2 >
5321 typedef HybridMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5338 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5339 struct MathTrait< HybridMatrix<T1,M,N,SO>, HybridMatrix<T2,M,N,SO> >
5341 typedef HybridMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5342 typedef HybridMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5358 template<
typename T1,
size_t M,
size_t N,
bool SO >
5359 struct SubmatrixTrait< HybridMatrix<T1,M,N,SO> >
5361 typedef HybridMatrix<T1,M,N,SO> Type;
5377 template<
typename T1,
size_t M,
size_t N,
bool SO >
5378 struct RowTrait< HybridMatrix<T1,M,N,SO> >
5380 typedef HybridVector<T1,N,true> Type;
5396 template<
typename T1,
size_t M,
size_t N,
bool SO >
5397 struct ColumnTrait< HybridMatrix<T1,M,N,SO> >
5399 typedef HybridVector<T1,M,false> Type;
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:108
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2156
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:960
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1032
Constraint on the data type.
Header file for mathematical functions.
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2085
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2050
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: HybridMatrix.h:1384
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
Header file for the row trait.
Header file for the IsSparseMatrix type trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
This ResultType
Result type for expression template evaluations.
Definition: HybridMatrix.h:200
Header file for the IsColumnMajorMatrix type trait.
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2555
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: HybridMatrix.h:776
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
size_t n_
The current number of columns of the matrix.
Definition: HybridMatrix.h:431
Header file for memory allocation and deallocation functionality.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: HybridMatrix.h:1967
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
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
Constraint on the data type.
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridMatrix.h:205
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2014
Header file for the SparseMatrix base class.
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:115
Type * Pointer
Pointer to a non-constant matrix value.
Definition: HybridMatrix.h:209
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: HybridMatrix.h:1591
Type & Reference
Reference to a non-constant matrix value.
Definition: HybridMatrix.h:207
Header file for the DisableIf class template.
HybridMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: HybridMatrix.h:202
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: HybridMatrix.h:210
Header file for the multiplication trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: HybridMatrix.h:1349
Header file for nested template disabiguation.
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2121
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:984
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4605
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2412
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: HybridMatrix.h:1442
#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
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: HybridMatrix.h:1987
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: HybridMatrix.h:1945
Header file for the DenseMatrix base class.
Pointer data()
Low-level data access to the matrix elements.
Definition: HybridMatrix.h:823
Header file for the DenseIterator class template.
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
HybridMatrix()
The default constructor for HybridMatrix.
Definition: HybridMatrix.h:466
Constraint on the data type.
HybridMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: HybridMatrix.h:201
Header file for the default storage order for all vectors of the Blaze library.
#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
void reset()
Reset to the default initial values.
Definition: HybridMatrix.h:1496
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
Header file for the EnableIf class template.
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
Header file for the IsVectorizable type trait.
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: HybridMatrix.h:212
Header file for the IsNumeric type trait.
Type ElementType
Type of the matrix elements.
Definition: HybridMatrix.h:203
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:912
EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
HybridMatrix & transpose()
Transposing the matrix.
Definition: HybridMatrix.h:1661
Header file for the addition trait.
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4671
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: HybridMatrix.h:1400
Header file for the submatrix trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
Header file for the reset shim.
Header file for the AlignedArray implementation.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
Efficient implementation of a dynamically sized matrix with static memory.The HybridMatrix class temp...
Definition: Forward.h:49
#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:2411
Header file for the column trait.
Header file for the isDefault shim.
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.
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridMatrix.h:211
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2556
Header file for the IsRowMajorMatrix type trait.
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: HybridMatrix.h:204
const Type & ConstReference
Reference to a constant matrix value.
Definition: HybridMatrix.h:208
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
void swap(HybridMatrix &m)
Swapping the contents of two hybrid matrices.
Definition: HybridMatrix.h:1729
Header file for basic type definitions.
void clear()
Clearing the hybrid matrix.
Definition: HybridMatrix.h:1544
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
size_t columns() const
Returns the current number of columns of the matrix.
Definition: HybridMatrix.h:1365
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2409
HybridMatrix< Type, M, N, SO > This
Type of this HybridMatrix instance.
Definition: HybridMatrix.h:199
size_t m_
The current number of rows of the matrix.
Definition: HybridMatrix.h:430
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: HybridMatrix.h:1638
#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
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: HybridMatrix.h:189
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:154
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: HybridMatrix.h:420
#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
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209
const This & CompositeType
Data type for composite expression templates.
Definition: HybridMatrix.h:206