35 #ifndef _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
36 #define _BLAZE_MATH_DENSE_HYBRIDMATRIX_H_
192 template<
typename Type
196 class HybridMatrix :
public DenseMatrix< HybridMatrix<Type,M,N,SO>, SO >
229 template<
typename ET >
247 enum { smpAssignable = 0 };
255 explicit inline HybridMatrix(
size_t m,
size_t n,
const Type& init );
256 template<
typename Other >
explicit inline HybridMatrix(
size_t m,
size_t n,
const Other* array );
258 template<
typename Other,
size_t M2,
size_t N2 >
259 explicit inline HybridMatrix(
const Other (&array)[M2][N2] );
262 template<
typename MT,
bool SO2 >
inline HybridMatrix(
const Matrix<MT,SO2>& m );
273 inline Reference
operator()(
size_t i,
size_t j );
274 inline ConstReference
operator()(
size_t i,
size_t j )
const;
275 inline Pointer
data ();
276 inline ConstPointer
data ()
const;
277 inline Pointer
data (
size_t i );
278 inline ConstPointer
data (
size_t i )
const;
279 inline Iterator
begin (
size_t i );
280 inline ConstIterator
begin (
size_t i )
const;
281 inline ConstIterator
cbegin(
size_t i )
const;
282 inline Iterator
end (
size_t i );
283 inline ConstIterator
end (
size_t i )
const;
284 inline ConstIterator
cend (
size_t i )
const;
291 template<
typename Other,
size_t M2,
size_t N2 >
292 inline HybridMatrix& operator=(
const Other (&array)[M2][N2] );
296 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator= (
const Matrix<MT,SO2>& rhs );
297 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator+=(
const Matrix<MT,SO2>& rhs );
298 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator-=(
const Matrix<MT,SO2>& rhs );
299 template<
typename MT,
bool SO2 >
inline HybridMatrix& operator*=(
const Matrix<MT,SO2>& rhs );
301 template<
typename Other >
302 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
303 operator*=( Other rhs );
305 template<
typename Other >
306 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
307 operator/=( Other rhs );
314 inline size_t rows()
const;
318 inline size_t capacity(
size_t i )
const;
320 inline size_t nonZeros(
size_t i )
const;
322 inline void reset(
size_t i );
324 void resize (
size_t m,
size_t n,
bool preserve=
true );
325 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
327 template<
typename Other >
inline HybridMatrix& scale(
const Other& scalar );
335 static inline void*
operator new ( std::size_t
size );
336 static inline void*
operator new[]( std::size_t
size );
337 static inline void*
operator new ( std::size_t
size,
const std::nothrow_t& );
338 static inline void*
operator new[]( std::size_t
size,
const std::nothrow_t& );
340 static inline void operator delete (
void* ptr );
341 static inline void operator delete[](
void* ptr );
342 static inline void operator delete (
void* ptr,
const std::nothrow_t& );
343 static inline void operator delete[](
void* ptr,
const std::nothrow_t& );
350 template<
typename MT >
352 struct VectorizedAssign {
353 enum { value = vectorizable && MT::vectorizable &&
354 IsSame<Type,typename MT::ElementType>::value &&
355 IsRowMajorMatrix<MT>::value };
362 template<
typename MT >
364 struct VectorizedAddAssign {
365 enum { value = vectorizable && MT::vectorizable &&
366 IsSame<Type,typename MT::ElementType>::value &&
367 IntrinsicTrait<Type>::addition &&
368 IsRowMajorMatrix<MT>::value &&
369 !IsDiagonal<MT>::value };
376 template<
typename MT >
378 struct VectorizedSubAssign {
379 enum { value = vectorizable && MT::vectorizable &&
380 IsSame<Type,typename MT::ElementType>::value &&
381 IntrinsicTrait<Type>::subtraction &&
382 IsRowMajorMatrix<MT>::value &&
383 !IsDiagonal<MT>::value };
392 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
393 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
403 template<
typename MT,
bool SO2 >
404 inline typename DisableIf< VectorizedAssign<MT> >::Type
405 assign(
const DenseMatrix<MT,SO2>& rhs );
407 template<
typename MT,
bool SO2 >
408 inline typename EnableIf< VectorizedAssign<MT> >::Type
409 assign(
const DenseMatrix<MT,SO2>& rhs );
411 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
412 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
414 template<
typename MT,
bool SO2 >
415 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
416 addAssign(
const DenseMatrix<MT,SO2>& rhs );
418 template<
typename MT,
bool SO2 >
419 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
420 addAssign(
const DenseMatrix<MT,SO2>& rhs );
422 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
423 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
425 template<
typename MT,
bool SO2 >
426 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
427 subAssign(
const DenseMatrix<MT,SO2>& rhs );
429 template<
typename MT,
bool SO2 >
430 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
431 subAssign(
const DenseMatrix<MT,SO2>& rhs );
433 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
434 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
484 template<
typename Type
496 for(
size_t i=0UL; i<M*NN; ++i )
516 template<
typename Type
528 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
531 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
534 for(
size_t i=0UL; i<M*NN; ++i )
555 template<
typename Type
567 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
570 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
572 for(
size_t i=0UL; i<m; ++i ) {
573 for(
size_t j=0UL; j<n; ++j )
577 for(
size_t j=n; j<NN; ++j )
583 for(
size_t i=m; i<M; ++i )
584 for(
size_t j=0UL; j<NN; ++j )
618 template<
typename Type
622 template<
typename Other >
631 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
634 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
636 for(
size_t i=0UL; i<m; ++i ) {
637 for(
size_t j=0UL; j<n; ++j )
638 v_[i*NN+j] = array[i*n+j];
641 for(
size_t j=n; j<NN; ++j )
647 for(
size_t i=m; i<M; ++i )
648 for(
size_t j=0UL; j<NN; ++j )
676 template<
typename Type
680 template<
typename Other
692 for(
size_t i=0UL; i<M2; ++i ) {
693 for(
size_t j=0UL; j<N2; ++j )
694 v_[i*NN+j] = array[i][j];
697 for(
size_t j=N2; j<NN; ++j )
703 for(
size_t i=M2; i<M; ++i )
704 for(
size_t j=0UL; j<NN; ++j )
719 template<
typename Type
730 for(
size_t i=0UL; i<
m_; ++i ) {
731 for(
size_t j=0UL; j<
n_; ++j )
732 v_[i*NN+j] = m.v_[i*NN+j];
735 for(
size_t j=n_; j<NN; ++j )
741 for(
size_t i=m_; i<M; ++i )
742 for(
size_t j=0UL; j<NN; ++j )
755 template<
typename Type
759 template<
typename MT
771 throw std::invalid_argument(
"Invalid setup of hybrid matrix" );
773 for(
size_t i=0UL; i<
m_; ++i ) {
775 j<( IsNumeric<Type>::value ? NN :
n_ );
782 for(
size_t i=m_; i<M; ++i )
783 for(
size_t j=0UL; j<NN; ++j )
807 template<
typename Type
828 template<
typename Type
854 template<
typename Type
878 template<
typename Type
898 template<
typename Type
919 template<
typename Type
943 template<
typename Type
967 template<
typename Type
991 template<
typename Type
1015 template<
typename Type
1039 template<
typename Type
1063 template<
typename Type
1105 template<
typename Type
1109 template<
typename Other
1119 for(
size_t i=0UL; i<M2; ++i )
1120 for(
size_t j=0UL; j<N2; ++j )
1121 v_[i*NN+j] = array[i][j];
1134 template<
typename Type
1143 for(
size_t i=0UL; i<
m_; ++i )
1144 for(
size_t j=0UL; j<
n_; ++j )
1160 template<
typename Type
1171 resize( rhs.rows(), rhs.columns() );
1190 template<
typename Type
1194 template<
typename MT
1201 throw std::invalid_argument(
"Invalid assignment to hybrid matrix" );
1203 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
1276 throw std::invalid_argument(
"Matrix sizes do not match" );
1278 if( (~rhs).canAlias(
this ) ) {
1301 template<
typename Type
1305 template<
typename MT
1310 throw std::invalid_argument(
"Matrix sizes do not match" );
1313 return this->operator=( tmp );
1325 template<
typename Type
1329 template<
typename Other >
1335 assign( *
this, (*
this) * rhs );
1350 template<
typename Type
1354 template<
typename Other >
1362 assign( *
this, (*
this) / rhs );
1381 template<
typename Type
1397 template<
typename Type
1416 template<
typename Type
1432 template<
typename Type
1454 template<
typename Type
1474 template<
typename Type
1480 size_t nonzeros( 0UL );
1482 for(
size_t i=0UL; i<
m_; ++i )
1483 for(
size_t j=0UL; j<
n_; ++j )
1503 template<
typename Type
1511 const size_t jend( i*NN+
n_ );
1512 size_t nonzeros( 0UL );
1514 for(
size_t j=i*NN; j<jend; ++j )
1528 template<
typename Type
1536 for(
size_t i=0UL; i<
m_; ++i )
1537 for(
size_t j=0UL; j<
n_; ++j )
1538 clear( v_[i*NN+j] );
1554 template<
typename Type
1563 for(
size_t j=0UL; j<
n_; ++j )
1564 clear( v_[i*NN+j] );
1576 template<
typename Type
1623 template<
typename Type
1632 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
1635 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
1638 for(
size_t i=0UL; i<m; ++i )
1639 for(
size_t j=n; j<
n_; ++j )
1640 v_[i*NN+j] = Type();
1644 for(
size_t i=m; i<
m_; ++i )
1645 for(
size_t j=0UL; j<
n_; ++j )
1646 v_[i*NN+j] = Type();
1670 template<
typename Type
1693 template<
typename Type
1701 if(
m_ > N ||
n_ > M )
1702 throw std::logic_error(
"Impossible transpose operation" );
1704 const size_t maxsize(
max(
m_,
n_ ) );
1705 for(
size_t i=1UL; i<maxsize; ++i )
1706 for(
size_t j=0UL; j<i; ++j )
1707 swap( v_[i*NN+j], v_[j*NN+i] );
1710 for(
size_t i=0UL; i<
m_; ++i ) {
1711 for(
size_t j=m_; j<
n_; ++j ) {
1712 v_[i*NN+j] = Type();
1718 for(
size_t i=
n_; i<
m_; ++i ) {
1719 for(
size_t j=0UL; j<
n_; ++j ) {
1720 v_[i*NN+j] = Type();
1738 template<
typename Type
1742 template<
typename Other >
1745 for(
size_t i=0UL; i<
m_; ++i )
1746 for(
size_t j=0UL; j<
n_; ++j )
1747 v_[i*NN+j] *= scalar;
1761 template<
typename Type
1769 const size_t maxrows(
max(
m_, m.m_ ) );
1770 const size_t maxcols(
max(
n_, m.n_ ) );
1772 for(
size_t i=0UL; i<maxrows; ++i ) {
1773 for(
size_t j=0UL; j<maxcols; ++j ) {
1774 swap( v_[i*NN+j], m(i,j) );
1802 template<
typename Type
1812 return allocate<HybridMatrix>( 1UL );
1827 template<
typename Type
1851 template<
typename Type
1861 return allocate<HybridMatrix>( 1UL );
1876 template<
typename Type
1885 return allocate<HybridMatrix>( size/
sizeof(
HybridMatrix) );
1896 template<
typename Type
1902 deallocate( static_cast<HybridMatrix*>( ptr ) );
1913 template<
typename Type
1919 deallocate( static_cast<HybridMatrix*>( ptr ) );
1930 template<
typename Type
1936 deallocate( static_cast<HybridMatrix*>( ptr ) );
1947 template<
typename Type
1953 deallocate( static_cast<HybridMatrix*>( ptr ) );
1976 template<
typename Type
1980 template<
typename Other >
1983 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1998 template<
typename Type
2002 template<
typename Other >
2005 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
2019 template<
typename Type
2045 template<
typename Type
2061 return load( &v_[i*NN+j] );
2081 template<
typename Type
2096 return loadu( &v_[i*NN+j] );
2117 template<
typename Type
2133 store( &v_[i*NN+j], value );
2154 template<
typename Type
2169 storeu( &v_[i*NN+j], value );
2190 template<
typename Type
2206 stream( &v_[i*NN+j], value );
2222 template<
typename Type
2226 template<
typename MT
2233 for(
size_t i=0UL; i<
m_; ++i ) {
2234 for(
size_t j=0UL; j<
n_; ++j ) {
2235 v_[i*NN+j] = (~rhs)(i,j);
2253 template<
typename Type
2257 template<
typename MT
2268 for(
size_t i=0UL; i<
m_; ++i ) {
2288 template<
typename Type
2292 template<
typename MT >
2299 for(
size_t i=0UL; i<
m_; ++i )
2300 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2301 v_[i*NN+element->index()] = element->value();
2317 template<
typename Type
2321 template<
typename MT >
2330 for(
size_t j=0UL; j<
n_; ++j )
2331 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2332 v_[element->index()*NN+j] = element->value();
2348 template<
typename Type
2352 template<
typename MT
2359 for(
size_t i=0UL; i<
m_; ++i )
2363 v_[i*NN+i] += (~rhs)(i,i);
2375 for(
size_t j=jbegin; j<jend; ++j ) {
2376 v_[i*NN+j] += (~rhs)(i,j);
2395 template<
typename Type
2399 template<
typename MT
2412 for(
size_t i=0UL; i<
m_; ++i )
2422 for(
size_t j=jbegin; j<jend; j+=
IT::size ) {
2423 store( &v_[i*NN+j],
load( &v_[i*NN+j] ) + (~rhs).
load(i,j) );
2441 template<
typename Type
2445 template<
typename MT >
2452 for(
size_t i=0UL; i<
m_; ++i )
2453 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2454 v_[i*NN+element->index()] += element->value();
2470 template<
typename Type
2474 template<
typename MT >
2483 for(
size_t j=0UL; j<
n_; ++j )
2484 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2485 v_[element->index()*NN+j] += element->value();
2501 template<
typename Type
2505 template<
typename MT
2512 for(
size_t i=0UL; i<
m_; ++i )
2516 v_[i*NN+i] -= (~rhs)(i,i);
2528 for(
size_t j=jbegin; j<jend; ++j ) {
2529 v_[i*NN+j] -= (~rhs)(i,j);
2548 template<
typename Type
2552 template<
typename MT
2565 for(
size_t i=0UL; i<
m_; ++i )
2575 for(
size_t j=jbegin; j<jend; j+=
IT::size ) {
2576 store( &v_[i*NN+j],
load( &v_[i*NN+j] ) - (~rhs).
load(i,j) );
2594 template<
typename Type
2598 template<
typename MT >
2605 for(
size_t i=0UL; i<
m_; ++i )
2606 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2607 v_[i*NN+element->index()] -= element->value();
2623 template<
typename Type
2627 template<
typename MT >
2636 for(
size_t j=0UL; j<
n_; ++j )
2637 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2638 v_[element->index()*NN+j] -= element->value();
2663 template<
typename Type
2680 typedef HybridMatrix<Type,M,N,true>
This;
2692 typedef DenseIterator<Type>
Iterator;
2699 template<
typename ET >
2701 typedef HybridMatrix<ET,M,N,true>
Other;
2711 enum { vectorizable = IsVectorizable<Type>::value };
2717 enum { smpAssignable = 0 };
2725 explicit inline HybridMatrix(
size_t m,
size_t n,
const Type& init );
2726 template<
typename Other >
explicit inline HybridMatrix(
size_t m,
size_t n,
const Other* array );
2728 template<
typename Other,
size_t M2,
size_t N2 >
2729 explicit inline HybridMatrix(
const Other (&array)[M2][N2] );
2732 template<
typename MT,
bool SO >
inline HybridMatrix(
const Matrix<MT,SO>& m );
2743 inline Reference
operator()(
size_t i,
size_t j );
2744 inline ConstReference
operator()(
size_t i,
size_t j )
const;
2745 inline Pointer
data ();
2746 inline ConstPointer
data ()
const;
2747 inline Pointer
data (
size_t j );
2748 inline ConstPointer
data (
size_t j )
const;
2749 inline Iterator
begin (
size_t j );
2750 inline ConstIterator
begin (
size_t j )
const;
2751 inline ConstIterator
cbegin(
size_t j )
const;
2752 inline Iterator
end (
size_t j );
2753 inline ConstIterator
end (
size_t j )
const;
2754 inline ConstIterator
cend (
size_t j )
const;
2761 template<
typename Other,
size_t M2,
size_t N2 >
2762 inline HybridMatrix& operator=(
const Other (&array)[M2][N2] );
2766 template<
typename MT,
bool SO >
inline HybridMatrix& operator= (
const Matrix<MT,SO>& rhs );
2767 template<
typename MT,
bool SO >
inline HybridMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2768 template<
typename MT,
bool SO >
inline HybridMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2769 template<
typename MT,
bool SO >
inline HybridMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2771 template<
typename Other >
2772 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
2773 operator*=( Other rhs );
2775 template<
typename Other >
2776 inline typename EnableIf< IsNumeric<Other>,
HybridMatrix >::Type&
2777 operator/=( Other rhs );
2784 inline size_t rows()
const;
2785 inline size_t columns()
const;
2786 inline size_t spacing()
const;
2788 inline size_t capacity(
size_t j )
const;
2790 inline size_t nonZeros(
size_t j )
const;
2791 inline void reset();
2792 inline void reset(
size_t i );
2793 inline void clear();
2794 void resize (
size_t m,
size_t n,
bool preserve=
true );
2795 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2797 template<
typename Other >
inline HybridMatrix& scale(
const Other& scalar );
2805 static inline void*
operator new ( std::size_t
size );
2806 static inline void*
operator new[]( std::size_t
size );
2807 static inline void*
operator new ( std::size_t
size,
const std::nothrow_t& );
2808 static inline void*
operator new[]( std::size_t
size,
const std::nothrow_t& );
2810 static inline void operator delete (
void* ptr );
2811 static inline void operator delete[](
void* ptr );
2812 static inline void operator delete (
void* ptr,
const std::nothrow_t& );
2813 static inline void operator delete[](
void* ptr,
const std::nothrow_t& );
2820 template<
typename MT >
2821 struct VectorizedAssign {
2822 enum { value = vectorizable && MT::vectorizable &&
2823 IsSame<Type,typename MT::ElementType>::value &&
2824 IsColumnMajorMatrix<MT>::value };
2830 template<
typename MT >
2831 struct VectorizedAddAssign {
2832 enum { value = vectorizable && MT::vectorizable &&
2833 IsSame<Type,typename MT::ElementType>::value &&
2834 IntrinsicTrait<Type>::addition &&
2835 IsColumnMajorMatrix<MT>::value &&
2836 !IsDiagonal<MT>::value };
2842 template<
typename MT >
2843 struct VectorizedSubAssign {
2844 enum { value = vectorizable && MT::vectorizable &&
2845 IsSame<Type,typename MT::ElementType>::value &&
2846 IntrinsicTrait<Type>::subtraction &&
2847 IsColumnMajorMatrix<MT>::value &&
2848 !IsDiagonal<MT>::value };
2856 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2857 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2868 template<
typename MT,
bool SO >
2869 inline typename DisableIf< VectorizedAssign<MT> >::Type
2870 assign(
const DenseMatrix<MT,SO>& rhs );
2872 template<
typename MT,
bool SO >
2873 inline typename EnableIf< VectorizedAssign<MT> >::Type
2874 assign(
const DenseMatrix<MT,SO>& rhs );
2876 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2877 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2879 template<
typename MT,
bool SO >
2880 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2881 addAssign(
const DenseMatrix<MT,SO>& rhs );
2883 template<
typename MT,
bool SO >
2884 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2885 addAssign(
const DenseMatrix<MT,SO>& rhs );
2887 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2888 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2890 template<
typename MT,
bool SO >
2891 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2892 subAssign(
const DenseMatrix<MT,SO>& rhs );
2894 template<
typename MT,
bool SO >
2895 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2896 subAssign(
const DenseMatrix<MT,SO>& rhs );
2898 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2899 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2907 AlignedArray<Type,MM*N>
v_;
2942 template<
typename Type
2952 if( IsNumeric<Type>::value ) {
2953 for(
size_t i=0UL; i<MM*N; ++i )
2975 template<
typename Type
2986 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
2989 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
2991 if( IsNumeric<Type>::value ) {
2992 for(
size_t i=0UL; i<MM*N; ++i )
3015 template<
typename Type
3026 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
3029 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
3031 for(
size_t j=0UL; j<n; ++j ) {
3032 for(
size_t i=0UL; i<m; ++i )
3035 if( IsNumeric<Type>::value ) {
3036 for(
size_t i=m; i<MM; ++i )
3037 v_[i+j*MM] = Type();
3041 if( IsNumeric<Type>::value ) {
3042 for(
size_t j=n; j<N; ++j )
3043 for(
size_t i=0UL; i<MM; ++i )
3044 v_[i+j*MM] = Type();
3079 template<
typename Type
3082 template<
typename Other >
3091 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
3094 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
3096 for(
size_t j=0UL; j<n; ++j ) {
3097 for(
size_t i=0UL; i<m; ++i )
3098 v_[i+j*MM] = array[i+j*m];
3100 if( IsNumeric<Type>::value ) {
3101 for(
size_t i=m; i<MM; ++i )
3102 v_[i+j*MM] = Type();
3106 if( IsNumeric<Type>::value ) {
3107 for(
size_t j=n; j<N; ++j )
3108 for(
size_t i=0UL; i<MM; ++i )
3109 v_[i+j*MM] = Type();
3138 template<
typename Type
3141 template<
typename Other
3153 for(
size_t j=0UL; j<N2; ++j ) {
3154 for(
size_t i=0UL; i<M2; ++i )
3155 v_[i+j*MM] = array[i][j];
3157 if( IsNumeric<Type>::value ) {
3158 for(
size_t i=M2; i<MM; ++i )
3159 v_[i+j*MM] = Type();
3163 if( IsNumeric<Type>::value ) {
3164 for(
size_t j=N2; j<N; ++j )
3165 for(
size_t i=0UL; i<MM; ++i )
3166 v_[i+j*MM] = Type();
3182 template<
typename Type
3192 for(
size_t j=0UL; j<
n_; ++j ) {
3193 for(
size_t i=0UL; i<
m_; ++i )
3194 v_[i+j*MM] = m.v_[i+j*MM];
3196 if( IsNumeric<Type>::value ) {
3197 for(
size_t i=m_; i<MM; ++i )
3198 v_[i+j*MM] = Type();
3202 if( IsNumeric<Type>::value ) {
3203 for(
size_t j=n_; j<N; ++j )
3204 for(
size_t i=0UL; i<MM; ++i )
3205 v_[i+j*MM] = Type();
3219 template<
typename Type
3222 template<
typename MT
3234 throw std::invalid_argument(
"Invalid setup of hybrid matrix" );
3236 for(
size_t j=0UL; j<
n_; ++j ) {
3237 for(
size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
3238 i<( IsNumeric<Type>::value ? MM :
m_ );
3240 v_[i+j*MM] = Type();
3244 if( IsNumeric<Type>::value ) {
3245 for(
size_t j=n_; j<N; ++j )
3246 for(
size_t i=0UL; i<MM; ++i )
3247 v_[i+j*MM] = Type();
3250 assign( *
this, ~m );
3272 template<
typename Type
3294 template<
typename Type
3320 template<
typename Type
3323 inline typename HybridMatrix<Type,M,N,true>::Pointer
3344 template<
typename Type
3347 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3365 template<
typename Type
3368 inline typename HybridMatrix<Type,M,N,true>::Pointer
3387 template<
typename Type
3390 inline typename HybridMatrix<Type,M,N,true>::ConstPointer
3407 template<
typename Type
3427 template<
typename Type
3447 template<
typename Type
3467 template<
typename Type
3487 template<
typename Type
3507 template<
typename Type
3550 template<
typename Type
3553 template<
typename Other
3556 inline HybridMatrix<Type,M,N,true>&
3557 HybridMatrix<Type,M,N,true>::operator=(
const Other (&array)[M2][N2] )
3564 for(
size_t j=0UL; j<N2; ++j )
3565 for(
size_t i=0UL; i<M2; ++i )
3566 v_[i+j*MM] = array[i][j];
3581 template<
typename Type
3584 inline HybridMatrix<Type,M,N,true>&
3585 HybridMatrix<Type,M,N,true>::operator=(
const Type&
set )
3590 for(
size_t j=0UL; j<
n_; ++j )
3591 for(
size_t i=0UL; i<
m_; ++i )
3609 template<
typename Type
3612 inline HybridMatrix<Type,M,N,true>&
3613 HybridMatrix<Type,M,N,true>::operator=(
const HybridMatrix& rhs )
3620 resize( rhs.rows(), rhs.columns() );
3641 template<
typename Type
3644 template<
typename MT
3646 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator=(
const Matrix<MT,SO>& rhs )
3651 throw std::invalid_argument(
"Invalid assignment to hybrid matrix" );
3653 if( (~rhs).canAlias(
this ) ) {
3654 HybridMatrix tmp( ~rhs );
3659 if( IsSparseMatrix<MT>::value )
3681 template<
typename Type
3684 template<
typename MT
3686 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator+=(
const Matrix<MT,SO>& rhs )
3690 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3691 throw std::invalid_argument(
"Matrix sizes do not match" );
3693 if( (~rhs).canAlias(
this ) ) {
3718 template<
typename Type
3721 template<
typename MT
3723 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator-=(
const Matrix<MT,SO>& rhs )
3727 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3728 throw std::invalid_argument(
"Matrix sizes do not match" );
3730 if( (~rhs).canAlias(
this ) ) {
3755 template<
typename Type
3758 template<
typename MT
3760 inline HybridMatrix<Type,M,N,true>& HybridMatrix<Type,M,N,true>::operator*=(
const Matrix<MT,SO>& rhs )
3763 throw std::invalid_argument(
"Matrix sizes do not match" );
3765 HybridMatrix tmp( *
this * (~rhs) );
3766 return this->operator=( tmp );
3780 template<
typename Type
3783 template<
typename Other >
3784 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3785 HybridMatrix<Type,M,N,true>::operator*=( Other rhs )
3789 assign( *
this, (*
this) * rhs );
3806 template<
typename Type
3809 template<
typename Other >
3810 inline typename EnableIf< IsNumeric<Other>, HybridMatrix<Type,M,N,true> >::Type&
3811 HybridMatrix<Type,M,N,true>::operator/=( Other rhs )
3817 assign( *
this, (*
this) / rhs );
3838 template<
typename Type
3855 template<
typename Type
3875 template<
typename Type
3892 template<
typename Type
3910 template<
typename Type
3931 template<
typename Type
3936 size_t nonzeros( 0UL );
3938 for(
size_t j=0UL; j<
n_; ++j )
3939 for(
size_t i=0UL; i<
m_; ++i )
3956 template<
typename Type
3963 const size_t iend( j*MM+m_ );
3964 size_t nonzeros( 0UL );
3966 for(
size_t i=j*MM; i<iend; ++i )
3982 template<
typename Type
3989 for(
size_t j=0UL; j<
n_; ++j )
3990 for(
size_t i=0UL; i<
m_; ++i )
3991 clear( v_[i+j*MM] );
4007 template<
typename Type
4015 for(
size_t i=0UL; i<
m_; ++i )
4016 clear( v_[i+j*MM] );
4030 template<
typename Type
4078 template<
typename Type
4086 throw std::invalid_argument(
"Invalid number of rows for hybrid matrix" );
4089 throw std::invalid_argument(
"Invalid number of columns for hybrid matrix" );
4091 if( IsVectorizable<Type>::value && m < m_ ) {
4092 for(
size_t j=0UL; j<n; ++j )
4093 for(
size_t i=m; i<
m_; ++i )
4094 v_[i+j*MM] = Type();
4097 if( IsVectorizable<Type>::value && n < n_ ) {
4098 for(
size_t j=n; j<
n_; ++j )
4099 for(
size_t i=0UL; i<
m_; ++i )
4100 v_[i+j*MM] = Type();
4126 template<
typename Type
4150 template<
typename Type
4157 if( m_ > N || n_ > M )
4158 throw std::logic_error(
"Impossible transpose operation" );
4160 const size_t maxsize(
max( m_, n_ ) );
4161 for(
size_t j=1UL; j<maxsize; ++j )
4162 for(
size_t i=0UL; i<j; ++i )
4163 swap( v_[i+j*MM], v_[j+i*MM] );
4165 if( IsVectorizable<Type>::value && n_ < m_ ) {
4166 for(
size_t j=0UL; j<
n_; ++j ) {
4167 for(
size_t i=n_; i<
m_; ++i ) {
4168 v_[i+j*MM] = Type();
4173 if( IsVectorizable<Type>::value && n_ > m_ ) {
4174 for(
size_t j=m_; j<
n_; ++j )
4175 for(
size_t i=0UL; i<
m_; ++i )
4176 v_[i+j*MM] = Type();
4194 template<
typename Type
4197 template<
typename Other >
4198 inline HybridMatrix<Type,M,N,true>&
4199 HybridMatrix<Type,M,N,true>::scale(
const Other& scalar )
4201 for(
size_t j=0UL; j<
n_; ++j )
4202 for(
size_t i=0UL; i<
m_; ++i )
4203 v_[i+j*MM] *= scalar;
4219 template<
typename Type
4226 const size_t maxrows(
max( m_, m.m_ ) );
4227 const size_t maxcols(
max( n_, m.n_ ) );
4229 for(
size_t j=0UL; j<maxcols; ++j ) {
4230 for(
size_t i=0UL; i<maxrows; ++i ) {
4231 swap( v_[i+j*MM], m(i,j) );
4261 template<
typename Type
4264 inline void* HybridMatrix<Type,M,N,true>::operator
new( std::size_t
size )
4270 return allocate<HybridMatrix>( 1UL );
4287 template<
typename Type
4290 inline void* HybridMatrix<Type,M,N,true>::operator
new[]( std::size_t
size )
4295 return allocate<HybridMatrix>( size/
sizeof(HybridMatrix) );
4312 template<
typename Type
4315 inline void* HybridMatrix<Type,M,N,true>::operator
new( std::size_t
size,
const std::nothrow_t& )
4321 return allocate<HybridMatrix>( 1UL );
4338 template<
typename Type
4341 inline void* HybridMatrix<Type,M,N,true>::operator
new[]( std::size_t
size,
const std::nothrow_t& )
4346 return allocate<HybridMatrix>( size/
sizeof(HybridMatrix) );
4359 template<
typename Type
4362 inline void HybridMatrix<Type,M,N,true>::operator
delete(
void* ptr )
4364 deallocate( static_cast<HybridMatrix*>( ptr ) );
4377 template<
typename Type
4380 inline void HybridMatrix<Type,M,N,true>::operator
delete[](
void* ptr )
4382 deallocate( static_cast<HybridMatrix*>( ptr ) );
4395 template<
typename Type
4398 inline void HybridMatrix<Type,M,N,true>::operator
delete(
void* ptr,
const std::nothrow_t& )
4400 deallocate( static_cast<HybridMatrix*>( ptr ) );
4413 template<
typename Type
4416 inline void HybridMatrix<Type,M,N,true>::operator
delete[](
void* ptr,
const std::nothrow_t& )
4418 deallocate( static_cast<HybridMatrix*>( ptr ) );
4443 template<
typename Type
4446 template<
typename Other >
4449 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4466 template<
typename Type
4469 template<
typename Other >
4472 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
4488 template<
typename Type
4514 template<
typename Type
4529 return load( &v_[i+j*MM] );
4550 template<
typename Type
4564 return loadu( &v_[i+j*MM] );
4586 template<
typename Type
4601 store( &v_[i+j*MM], value );
4623 template<
typename Type
4637 storeu( &v_[i+j*MM], value );
4660 template<
typename Type
4675 stream( &v_[i+j*MM], value );
4693 template<
typename Type
4696 template<
typename MT
4698 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4703 for(
size_t j=0UL; j<
n_; ++j ) {
4704 for(
size_t i=0UL; i<
m_; ++i ) {
4705 v_[i+j*MM] = (~rhs)(i,j);
4725 template<
typename Type
4728 template<
typename MT
4730 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4739 for(
size_t j=0UL; j<
n_; ++j ) {
4761 template<
typename Type
4764 template<
typename MT >
4771 for(
size_t j=0UL; j<
n_; ++j )
4772 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
4773 v_[element->index()+j*MM] = element->value();
4791 template<
typename Type
4794 template<
typename MT >
4803 for(
size_t i=0UL; i<
m_; ++i )
4804 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4805 v_[i+element->index()*MM] = element->value();
4823 template<
typename Type
4826 template<
typename MT
4828 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4833 for(
size_t j=0UL; j<
n_; ++j )
4835 if( IsDiagonal<MT>::value )
4837 v_[j+j*MM] += (~rhs)(j,j);
4841 const size_t ibegin( ( IsLower<MT>::value )
4842 ?( IsStrictlyLower<MT>::value ? j+1UL : j )
4844 const size_t iend ( ( IsUpper<MT>::value )
4845 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4849 for(
size_t i=ibegin; i<iend; ++i ) {
4850 v_[i+j*MM] += (~rhs)(i,j);
4871 template<
typename Type
4874 template<
typename MT
4876 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4887 for(
size_t j=0UL; j<
n_; ++j )
4889 const size_t ibegin( ( IsLower<MT>::value )
4890 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-
IT::size) )
4892 const size_t iend ( ( IsUpper<MT>::value )
4893 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
4897 for(
size_t i=ibegin; i<iend; i+=
IT::size ) {
4898 store( &v_[i+j*MM],
load( &v_[i+j*MM] ) + (~rhs).
load(i,j) );
4918 template<
typename Type
4921 template<
typename MT >
4928 for(
size_t j=0UL; j<
n_; ++j )
4929 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
4930 v_[element->index()+j*MM] += element->value();
4948 template<
typename Type
4951 template<
typename MT >
4960 for(
size_t i=0UL; i<
m_; ++i )
4961 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
4962 v_[i+element->index()*MM] += element->value();
4980 template<
typename Type
4983 template<
typename MT
4985 inline typename DisableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4990 for(
size_t j=0UL; j<
n_; ++j )
4992 if( IsDiagonal<MT>::value )
4994 v_[j+j*MM] -= (~rhs)(j,j);
4998 const size_t ibegin( ( IsLower<MT>::value )
4999 ?( IsStrictlyLower<MT>::value ? j+1UL : j )
5001 const size_t iend ( ( IsUpper<MT>::value )
5002 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5006 for(
size_t i=ibegin; i<iend; ++i ) {
5007 v_[i+j*MM] -= (~rhs)(i,j);
5028 template<
typename Type
5031 template<
typename MT
5033 inline typename EnableIf< typename HybridMatrix<Type,M,N,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
5044 for(
size_t j=0UL; j<
n_; ++j )
5046 const size_t ibegin( ( IsLower<MT>::value )
5047 ?( ( IsStrictlyLower<MT>::value ? j+1UL : j ) &
size_t(-
IT::size) )
5049 const size_t iend ( ( IsUpper<MT>::value )
5050 ?( IsStrictlyUpper<MT>::value ? j : j+1UL )
5054 for(
size_t i=ibegin; i<iend; i+=
IT::size ) {
5055 store( &v_[i+j*MM],
load( &v_[i+j*MM] ) - (~rhs).
load(i,j) );
5075 template<
typename Type
5078 template<
typename MT >
5085 for(
size_t j=0UL; j<
n_; ++j )
5086 for( RhsConstIterator element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
5087 v_[element->index()+j*MM] -= element->value();
5105 template<
typename Type
5108 template<
typename MT >
5117 for(
size_t i=0UL; i<
m_; ++i )
5118 for( RhsConstIterator element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
5119 v_[i+element->index()*MM] -= element->value();
5145 template<
typename Type
5148 class HybridMatrix<Type,M,0UL,SO>;
5161 template<
typename Type
5164 class HybridMatrix<Type,0UL,N,SO>;
5177 template<
typename Type
5179 class HybridMatrix<Type,0UL,0UL,SO>;
5199 template<
typename Type,
size_t M,
size_t N,
bool SO >
5200 inline void reset( HybridMatrix<Type,M,N,SO>& m );
5202 template<
typename Type,
size_t M,
size_t N,
bool SO >
5203 inline void reset( HybridMatrix<Type,M,N,SO>& m,
size_t i );
5205 template<
typename Type,
size_t M,
size_t N,
bool SO >
5206 inline void clear( HybridMatrix<Type,M,N,SO>& m );
5208 template<
typename Type,
size_t M,
size_t N,
bool SO >
5209 inline bool isDefault(
const HybridMatrix<Type,M,N,SO>& m );
5211 template<
typename Type,
size_t M,
size_t N,
bool SO >
5212 inline void swap( HybridMatrix<Type,M,N,SO>& a, HybridMatrix<Type,M,N,SO>& b ) ;
5214 template<
typename Type,
size_t M,
size_t N,
bool SO >
5215 inline void move( HybridMatrix<Type,M,N,SO>& dst, HybridMatrix<Type,M,N,SO>& src ) ;
5227 template<
typename Type
5251 template<
typename Type
5269 template<
typename Type
5298 template<
typename Type
5304 return ( m.rows() == 0UL && m.columns() == 0UL );
5318 template<
typename Type
5338 template<
typename Type
5359 template<
typename T,
size_t M,
size_t N,
bool SO >
5360 struct HasConstDataAccess< HybridMatrix<T,M,N,SO> > :
public TrueType
5379 template<
typename T,
size_t M,
size_t N,
bool SO >
5380 struct HasMutableDataAccess< HybridMatrix<T,M,N,SO> > :
public TrueType
5399 template<
typename T,
size_t M,
size_t N,
bool SO >
5400 struct IsResizable< HybridMatrix<T,M,N,SO> > :
public TrueType
5419 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5420 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5422 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5425 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5426 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5428 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2,
false > Type;
5431 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5432 struct AddTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5434 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2, SO > Type;
5437 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5438 struct AddTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5440 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M2, N2,
false > Type;
5443 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5444 struct AddTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5446 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5449 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5450 struct AddTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5452 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5468 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5469 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, StaticMatrix<T2,M2,N2,SO> >
5471 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5474 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5475 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5477 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2,
false > Type;
5480 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5481 struct SubTrait< StaticMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5483 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2, SO > Type;
5486 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5487 struct SubTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5489 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M2, N2,
false > Type;
5492 template<
typename T1,
size_t M1,
size_t N1,
bool SO,
typename T2,
size_t M2,
size_t N2 >
5493 struct SubTrait< HybridMatrix<T1,M1,N1,SO>, HybridMatrix<T2,M2,N2,SO> >
5495 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), SO > Type;
5498 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5499 struct SubTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5501 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, ( M1 < M2 )?( M1 ):( M2 ), ( N1 < N2 )?( N1 ):( N2 ), false > Type;
5517 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5518 struct MultTrait< HybridMatrix<T1,M,N,SO>, T2 >
5520 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5524 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5525 struct MultTrait< T1, HybridMatrix<T2,M,N,SO> >
5527 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M, N, SO > Type;
5531 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2,
size_t K >
5532 struct MultTrait< HybridMatrix<T1,M,N,SO>, StaticVector<T2,K,false> >
5534 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5537 template<
typename T1,
size_t K,
typename T2,
size_t M,
size_t N,
bool SO >
5538 struct MultTrait< StaticVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5540 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5543 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2,
size_t K >
5544 struct MultTrait< HybridMatrix<T1,M,N,SO>, HybridVector<T2,K,false> >
5546 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5549 template<
typename T1,
size_t K,
typename T2,
size_t M,
size_t N,
bool SO >
5550 struct MultTrait< HybridVector<T1,K,true>, HybridMatrix<T2,M,N,SO> >
5552 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5555 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5556 struct MultTrait< HybridMatrix<T1,M,N,SO>, DynamicVector<T2,false> >
5558 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5561 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5562 struct MultTrait< DynamicVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5564 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5567 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5568 struct MultTrait< HybridMatrix<T1,M,N,SO>, CompressedVector<T2,false> >
5570 typedef HybridVector< typename MultTrait<T1,T2>::Type, M,
false > Type;
5573 template<
typename T1,
typename T2,
size_t M,
size_t N,
bool SO >
5574 struct MultTrait< CompressedVector<T1,true>, HybridMatrix<T2,M,N,SO> >
5576 typedef HybridVector< typename MultTrait<T1,T2>::Type, N,
true > Type;
5579 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5580 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, StaticMatrix<T2,M2,N2,SO2> >
5582 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5585 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5586 struct MultTrait< StaticMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5588 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5591 template<
typename T1,
size_t M1,
size_t N1,
bool SO1,
typename T2,
size_t M2,
size_t N2,
bool SO2 >
5592 struct MultTrait< HybridMatrix<T1,M1,N1,SO1>, HybridMatrix<T2,M2,N2,SO2> >
5594 typedef HybridMatrix< typename MultTrait<T1,T2>::Type, M1, N2, SO1 > Type;
5610 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5611 struct DivTrait< HybridMatrix<T1,M,N,SO>, T2 >
5613 typedef HybridMatrix< typename DivTrait<T1,T2>::Type, M, N, SO > Type;
5630 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
5631 struct MathTrait< HybridMatrix<T1,M,N,SO>, HybridMatrix<T2,M,N,SO> >
5633 typedef HybridMatrix< typename MathTrait<T1,T2>::HighType, M, N, SO > HighType;
5634 typedef HybridMatrix< typename MathTrait<T1,T2>::LowType , M, N, SO > LowType;
5650 template<
typename T1,
size_t M,
size_t N,
bool SO >
5651 struct SubmatrixTrait< HybridMatrix<T1,M,N,SO> >
5653 typedef HybridMatrix<T1,M,N,SO> Type;
5669 template<
typename T1,
size_t M,
size_t N,
bool SO >
5670 struct RowTrait< HybridMatrix<T1,M,N,SO> >
5672 typedef HybridVector<T1,N,true> Type;
5688 template<
typename T1,
size_t M,
size_t N,
bool SO >
5689 struct ColumnTrait< HybridMatrix<T1,M,N,SO> >
5691 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
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:996
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1068
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
Header file for mathematical functions.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Type ElementType
Type of the matrix elements.
Definition: HybridMatrix.h:214
Header file for basic type definitions.
size_t spacing() const
Returns the spacing between the beginning of two rows.
Definition: HybridMatrix.h:1420
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
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
Header file for the IsSparseMatrix type trait.
Header file for the IsDiagonal type trait.
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2122
Header file for the IsSame and IsStrictlySame type traits.
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
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: HybridMatrix.h:215
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2665
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: HybridMatrix.h:812
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 Type * ConstPointer
Pointer to a constant matrix value.
Definition: HybridMatrix.h:221
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
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_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
const Type & ConstReference
Reference to a constant matrix value.
Definition: HybridMatrix.h:219
Compile time check for upper triangular matrices.This type trait tests whether or not the given templ...
Definition: IsUpper.h:90
Header file for memory allocation and deallocation functionality.
HybridMatrix< Type, N, M,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: HybridMatrix.h:213
Type & Reference
Reference to a non-constant matrix value.
Definition: HybridMatrix.h:218
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: HybridMatrix.h:2003
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
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
Header file for the SparseMatrix base class.
const This & CompositeType
Data type for composite expression templates.
Definition: HybridMatrix.h:217
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: HybridMatrix.h:1627
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
size_t rows() const
Returns the current number of rows of the matrix.
Definition: HybridMatrix.h:1385
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.
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: HybridMatrix.h:1020
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: HybridMatrix.h:1478
#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
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
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: HybridMatrix.h:2023
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: HybridMatrix.h:1981
Header file for the DenseMatrix base class.
Pointer data()
Low-level data access to the matrix elements.
Definition: HybridMatrix.h:859
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
EnableIf< IsBuiltin< T > >::Type deallocate(T *address)
Deallocation of memory for built-in data types.
Definition: Memory.h:226
Header file for the DenseIterator class template.
HybridMatrix()
The default constructor for HybridMatrix.
Definition: HybridMatrix.h:488
Type * Pointer
Pointer to a non-constant matrix value.
Definition: HybridMatrix.h:220
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_DIAGONAL_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a diagonal matrix type, a compilation error is created.
Definition: Diagonal.h:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: HybridMatrix.h:216
Header file for the IsLower type trait.
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: HybridMatrix.h:200
size_t m_
The current number of rows of the matrix.
Definition: HybridMatrix.h:452
HybridMatrix< Type, M, N, SO > This
Type of this HybridMatrix instance.
Definition: HybridMatrix.h:210
Compile time check for diagonal matrices.This type trait tests whether or not the given template para...
Definition: IsDiagonal.h:92
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:1532
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
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:535
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: HybridMatrix.h:222
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
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 IsVectorizable type trait.
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
HybridMatrix< Type, M, N,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: HybridMatrix.h:212
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: HybridMatrix.h:948
AlignedArray< Type, M *NN > v_
The statically allocated matrix elements.
Definition: HybridMatrix.h:442
#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
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: HybridMatrix.h:223
Header file for run time assertion macros.
HybridMatrix & transpose()
Transposing the matrix.
Definition: HybridMatrix.h:1697
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.
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: HybridMatrix.h:1436
Header file for the submatrix trait.
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: HybridMatrix.h:211
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
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
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4934
Header file for the AlignedArray implementation.
Efficient implementation of a dynamically sized matrix with static memory.The HybridMatrix class temp...
Definition: Forward.h:56
#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.
Constraint on the data type.
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.
Constraint on the data type.
Header file for the HasMutableDataAccess type trait.
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
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.
Rebind mechanism to obtain a HybridMatrix with different data/element type.
Definition: HybridMatrix.h:230
Compile time check for strictly lower triangular matrices.This type trait tests whether or not the gi...
Definition: IsStrictlyLower.h:86
HybridMatrix< ET, M, N, SO > Other
The type of the other HybridMatrix.
Definition: HybridMatrix.h:231
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2666
Header file for the IsRowMajorMatrix type trait.
BLAZE_ALWAYS_INLINE IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2050
BLAZE_ALWAYS_INLINE 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:2195
size_t n_
The current number of columns of the matrix.
Definition: HybridMatrix.h:453
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
void swap(HybridMatrix &m)
Swapping the contents of two hybrid matrices.
Definition: HybridMatrix.h:1765
void clear()
Clearing the hybrid matrix.
Definition: HybridMatrix.h:1580
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:1401
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
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 extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: HybridMatrix.h:1674
#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
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2159
Header file for the IsResizable type trait.
System settings for the inline keywords.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: HybridMatrix.h:2086
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