35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_ 36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_ 219 template<
typename Type
220 ,
bool SO = defaultStorageOrder >
248 template<
typename NewType >
257 template<
size_t NewM
284 explicit inline
DynamicMatrix(
size_t m,
size_t n, const Type& init );
287 template< typename Other >
288 explicit inline
DynamicMatrix(
size_t m,
size_t n, const Other* array );
290 template< typename Other,
size_t Rows,
size_t Cols >
291 explicit inline
DynamicMatrix( const Other (&array)[Rows][Cols] );
309 inline
Reference operator()(
size_t i,
size_t j ) noexcept;
310 inline
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
332 template< typename Other,
size_t Rows,
size_t Cols >
333 inline
DynamicMatrix& operator=( const Other (&array)[Rows][Cols] );
338 template< typename MT,
bool SO2 > inline
DynamicMatrix& operator= ( const
Matrix<MT,SO2>& rhs );
339 template< typename MT,
bool SO2 > inline
DynamicMatrix& operator+=( const
Matrix<MT,SO2>& rhs );
340 template< typename MT,
bool SO2 > inline
DynamicMatrix& operator-=( const
Matrix<MT,SO2>& rhs );
341 template< typename MT,
bool SO2 > inline
DynamicMatrix& operator%=( const
Matrix<MT,SO2>& rhs );
348 inline
size_t rows() const noexcept;
349 inline
size_t columns() const noexcept;
350 inline
size_t spacing() const noexcept;
351 inline
size_t capacity() const noexcept;
352 inline
size_t capacity(
size_t i ) const noexcept;
354 inline
size_t nonZeros(
size_t i ) const;
356 inline
void reset(
size_t i );
358 void resize (
size_t m,
size_t n,
bool preserve=true );
359 inline
void extend (
size_t m,
size_t n,
bool preserve=true );
372 template< typename Other > inline
DynamicMatrix& scale( const Other& scalar );
379 template< typename MT >
381 static constexpr
bool VectorizedAssign_v =
382 ( useOptimizedKernels &&
390 template< typename MT >
392 static constexpr
bool VectorizedAddAssign_v =
393 ( useOptimizedKernels &&
403 template< typename MT >
405 static constexpr
bool VectorizedSubAssign_v =
406 ( useOptimizedKernels &&
416 template< typename MT >
418 static constexpr
bool VectorizedSchurAssign_v =
419 ( useOptimizedKernels &&
435 inline
bool isIntact() const noexcept;
442 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
443 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
457 template< typename MT >
460 template< typename MT >
467 template< typename MT >
470 template< typename MT >
477 template< typename MT >
480 template< typename MT >
487 template< typename MT >
490 template< typename MT >
503 inline
size_t addPadding(
size_t value ) const noexcept;
550 template< typename Type
571 template<
typename Type
580 if( IsVectorizable_v<Type> ) {
581 for(
size_t i=0UL; i<
m_; ++i ) {
582 for(
size_t j=
n_; j<
nn_; ++j ) {
583 v_[i*
nn_+j] = Type();
602 template<
typename Type
607 for(
size_t i=0UL; i<m; ++i ) {
608 for(
size_t j=0UL; j<
n_; ++j ) {
638 template<
typename Type
645 for(
const auto& rowList : list ) {
646 std::fill( std::copy( rowList.begin(), rowList.end(),
begin(i) ),
end(i), Type() );
678 template<
typename Type
680 template<
typename Other >
684 for(
size_t i=0UL; i<m; ++i ) {
685 for(
size_t j=0UL; j<n; ++j ) {
686 v_[i*
nn_+j] = array[i*n+j];
716 template<
typename Type
718 template<
typename Other
724 for(
size_t i=0UL; i<Rows; ++i ) {
725 for(
size_t j=0UL; j<Cols; ++j ) {
726 v_[i*
nn_+j] = array[i][j];
743 template<
typename Type
762 template<
typename Type
768 , capacity_( m.capacity_ )
785 template<
typename Type
787 template<
typename MT
792 if( IsSparseMatrix_v<MT> ) {
814 template<
typename Type
841 template<
typename Type
863 template<
typename Type
886 template<
typename Type
913 template<
typename Type
941 template<
typename Type
963 template<
typename Type
981 template<
typename Type
1000 template<
typename Type
1022 template<
typename Type
1044 template<
typename Type
1066 template<
typename Type
1088 template<
typename Type
1094 return Iterator( v_ + i*nn_ + n_ );
1110 template<
typename Type
1132 template<
typename Type
1157 template<
typename Type
1161 for(
size_t i=0UL; i<m_; ++i )
1162 for(
size_t j=0UL; j<n_; ++j )
1191 template<
typename Type
1200 for(
const auto& rowList : list ) {
1201 std::fill( std::copy( rowList.begin(), rowList.end(), v_+i*nn_ ), v_+(i+1UL)*nn_, Type() );
1231 template<
typename Type
1233 template<
typename Other
1238 resize( Rows, Cols,
false );
1240 for(
size_t i=0UL; i<Rows; ++i )
1241 for(
size_t j=0UL; j<Cols; ++j )
1242 v_[i*nn_+j] = array[i][j];
1258 template<
typename Type
1262 if( &rhs ==
this )
return *
this;
1280 template<
typename Type
1289 capacity_ = rhs.capacity_;
1295 rhs.capacity_ = 0UL;
1312 template<
typename Type
1314 template<
typename MT
1318 using TT = decltype(
trans( *
this ) );
1319 using CT = decltype(
ctrans( *
this ) );
1320 using IT = decltype(
inv( *
this ) );
1322 if( IsSame_v<MT,TT> && (~rhs).isAliased(
this ) ) {
1325 else if( IsSame_v<MT,CT> && (~rhs).isAliased(
this ) ) {
1328 else if( !IsSame_v<MT,IT> && (~rhs).canAlias(
this ) ) {
1334 if( IsSparseMatrix_v<MT> )
1356 template<
typename Type
1358 template<
typename MT
1362 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
1366 if( (~rhs).canAlias(
this ) ) {
1391 template<
typename Type
1393 template<
typename MT
1397 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
1401 if( (~rhs).canAlias(
this ) ) {
1426 template<
typename Type
1428 template<
typename MT
1432 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
1436 if( (~rhs).canAlias(
this ) ) {
1464 template<
typename Type
1478 template<
typename Type
1497 template<
typename Type
1511 template<
typename Type
1531 template<
typename Type
1547 template<
typename Type
1551 size_t nonzeros( 0UL );
1553 for(
size_t i=0UL; i<m_; ++i )
1554 for(
size_t j=0UL; j<n_; ++j )
1574 template<
typename Type
1580 const size_t jend( i*nn_ + n_ );
1581 size_t nonzeros( 0UL );
1583 for(
size_t j=i*nn_; j<jend; ++j )
1597 template<
typename Type
1603 for(
size_t i=0UL; i<m_; ++i )
1604 for(
size_t j=0UL; j<n_; ++j )
1605 clear( v_[i*nn_+j] );
1621 template<
typename Type
1628 for(
size_t j=0UL; j<n_; ++j )
1629 clear( v_[i*nn_+j] );
1641 template<
typename Type
1645 resize( 0UL, 0UL,
false );
1684 template<
typename Type
1691 if( m == m_ && n == n_ )
return;
1693 const size_t nn( addPadding( n ) );
1698 const size_t min_m(
min( m, m_ ) );
1699 const size_t min_n(
min( n, n_ ) );
1701 for(
size_t i=0UL; i<min_m; ++i ) {
1702 transfer( v_+i*nn_, v_+i*nn_+min_n, v+i*nn );
1709 else if( m*nn > capacity_ ) {
1716 if( IsVectorizable_v<Type> ) {
1717 for(
size_t i=0UL; i<m; ++i )
1718 for(
size_t j=n; j<nn; ++j )
1719 v_[i*nn+j] = Type();
1743 template<
typename Type
1747 resize( m_+m, n_+n, preserve );
1761 template<
typename Type
1775 if( IsVectorizable_v<Type> ) {
1776 for(
size_t i=capacity_; i<
elements; ++i )
1799 template<
typename Type
1803 if( ( m_ * nn_ ) < capacity_ ) {
1816 template<
typename Type
1825 swap( capacity_, m.capacity_ );
1840 template<
typename Type
1844 if( usePadding && IsVectorizable_v<Type> )
1845 return nextMultiple<size_t>( value, SIMDSIZE );
1864 template<
typename Type
1870 constexpr
size_t block( BLOCK_SIZE );
1874 for(
size_t ii=0UL; ii<m_; ii+=block ) {
1875 const size_t iend(
min( ii+block, m_ ) );
1876 for(
size_t jj=0UL; jj<=ii; jj+=block ) {
1877 for(
size_t i=ii; i<iend; ++i ) {
1878 const size_t jend(
min( jj+block, n_, i ) );
1879 for(
size_t j=jj; j<jend; ++j ) {
1880 swap( v_[i*nn_+j], v_[j*nn_+i] );
1902 template<
typename Type
1906 constexpr
size_t block( BLOCK_SIZE );
1910 for(
size_t ii=0UL; ii<m_; ii+=block ) {
1911 const size_t iend(
min( ii+block, m_ ) );
1912 for(
size_t jj=0UL; jj<ii; jj+=block ) {
1913 const size_t jend(
min( jj+block, n_ ) );
1914 for(
size_t i=ii; i<iend; ++i ) {
1915 for(
size_t j=jj; j<jend; ++j ) {
1916 cswap( v_[i*nn_+j], v_[j*nn_+i] );
1920 for(
size_t i=ii; i<iend; ++i ) {
1921 for(
size_t j=ii; j<i; ++j ) {
1922 cswap( v_[i*nn_+j], v_[j*nn_+i] );
1956 template<
typename Type
1958 template<
typename Other >
1961 for(
size_t i=0UL; i<m_; ++i )
1962 for(
size_t j=0UL; j<n_; ++j )
1963 v_[i*nn_+j] *= scalar;
1987 template<
typename Type
1991 if( m_ * n_ > capacity_ )
1994 if( IsVectorizable_v<Type> ) {
1995 for(
size_t i=0UL; i<m_; ++i ) {
1996 for(
size_t j=n_; j<nn_; ++j ) {
1997 if( v_[i*nn_+j] != Type() )
2026 template<
typename Type
2028 template<
typename Other >
2031 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
2046 template<
typename Type
2048 template<
typename Other >
2051 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
2065 template<
typename Type
2069 return ( usePadding ||
columns() % SIMDSIZE == 0UL );
2084 template<
typename Type
2088 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
2108 template<
typename Type
2114 return loada( i, j );
2116 return loadu( i, j );
2136 template<
typename Type
2151 return loada( v_+i*nn_+j );
2171 template<
typename Type
2184 return loadu( v_+i*nn_+j );
2205 template<
typename Type
2234 template<
typename Type
2249 storea( v_+i*nn_+j, value );
2270 template<
typename Type
2283 storeu( v_+i*nn_+j, value );
2305 template<
typename Type
2320 stream( v_+i*nn_+j, value );
2336 template<
typename Type
2338 template<
typename MT >
2345 const size_t jpos( n_ &
size_t(-2) );
2348 for(
size_t i=0UL; i<m_; ++i ) {
2349 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2350 v_[i*nn_+j ] = (~rhs)(i,j );
2351 v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
2354 v_[i*nn_+jpos] = (~rhs)(i,jpos);
2372 template<
typename Type
2374 template<
typename MT >
2383 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
2385 const size_t jpos( ( remainder )?( n_ &
size_t(-SIMDSIZE) ):( n_ ) );
2386 BLAZE_INTERNAL_ASSERT( !remainder || ( n_ - ( n_ % (SIMDSIZE) ) ) == jpos,
"Invalid end calculation" );
2388 if( usePadding && useStreaming &&
2389 ( m_*n_ > ( cacheSize / (
sizeof(Type) * 3UL ) ) ) && !(~rhs).isAliased(
this ) )
2391 for(
size_t i=0UL; i<m_; ++i )
2394 Iterator left(
begin(i) );
2397 for( ; j<jpos; j+=SIMDSIZE, left+=SIMDSIZE, right+=SIMDSIZE ) {
2398 left.stream( right.load() );
2400 for( ; remainder && j<n_; ++j, ++left, ++right ) {
2407 for(
size_t i=0UL; i<m_; ++i )
2410 Iterator left(
begin(i) );
2411 ConstIterator_t<MT> right( (~rhs).
begin(i) );
2413 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2414 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2415 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2416 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2417 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2419 for( ; j<jpos; j+=SIMDSIZE ) {
2420 left.store( right.load() ); left+=SIMDSIZE, right+=SIMDSIZE;
2422 for( ; remainder && j<n_; ++j ) {
2423 *left = *right; ++left; ++right;
2442 template<
typename Type
2444 template<
typename MT >
2452 constexpr
size_t block( BLOCK_SIZE );
2454 for(
size_t ii=0UL; ii<m_; ii+=block ) {
2455 const size_t iend(
min( m_, ii+block ) );
2456 for(
size_t jj=0UL; jj<n_; jj+=block ) {
2457 const size_t jend(
min( n_, jj+block ) );
2458 for(
size_t i=ii; i<iend; ++i ) {
2459 for(
size_t j=jj; j<jend; ++j ) {
2460 v_[i*nn_+j] = (~rhs)(i,j);
2480 template<
typename Type
2482 template<
typename MT >
2488 for(
size_t i=0UL; i<m_; ++i )
2489 for(
auto element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2490 v_[i*nn_+element->index()] = element->value();
2506 template<
typename Type
2508 template<
typename MT >
2516 for(
size_t j=0UL; j<n_; ++j )
2517 for(
auto element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2518 v_[element->index()*nn_+j] = element->value();
2534 template<
typename Type
2536 template<
typename MT >
2543 for(
size_t i=0UL; i<m_; ++i )
2545 if( IsDiagonal_v<MT> )
2547 v_[i*nn_+i] += (~rhs)(i,i);
2551 const size_t jbegin( ( IsUpper_v<MT> )
2552 ?( IsStrictlyUpper_v<MT> ? i+1UL : i )
2554 const size_t jend ( ( IsLower_v<MT> )
2555 ?( IsStrictlyLower_v<MT> ? i : i+1UL )
2561 for( ; (j+2UL) <= jend; j+=2UL ) {
2562 v_[i*nn_+j ] += (~rhs)(i,j );
2563 v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2566 v_[i*nn_+j] += (~rhs)(i,j);
2585 template<
typename Type
2587 template<
typename MT >
2597 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
2599 for(
size_t i=0UL; i<m_; ++i )
2601 const size_t jbegin( ( IsUpper_v<MT> )
2602 ?( ( IsStrictlyUpper_v<MT> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2604 const size_t jend ( ( IsLower_v<MT> )
2605 ?( IsStrictlyLower_v<MT> ? i : i+1UL )
2609 const size_t jpos( ( remainder )?( jend &
size_t(-SIMDSIZE) ):( jend ) );
2610 BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (SIMDSIZE) ) ) == jpos,
"Invalid end calculation" );
2613 Iterator left(
begin(i) + jbegin );
2616 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2617 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2618 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2619 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2620 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2622 for( ; j<jpos; j+=SIMDSIZE ) {
2623 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2625 for( ; remainder && j<jend; ++j ) {
2626 *left += *right; ++left; ++right;
2644 template<
typename Type
2646 template<
typename MT >
2654 constexpr
size_t block( BLOCK_SIZE );
2656 for(
size_t ii=0UL; ii<m_; ii+=block ) {
2657 const size_t iend(
min( m_, ii+block ) );
2658 for(
size_t jj=0UL; jj<n_; jj+=block )
2660 if( IsLower_v<MT> && ii < jj )
break;
2661 if( IsUpper_v<MT> && ii > jj )
continue;
2663 for(
size_t i=ii; i<iend; ++i )
2665 const size_t jbegin( ( IsUpper_v<MT> )
2666 ?(
max( ( IsStrictlyUpper_v<MT> ? i+1UL : i ), jj ) )
2668 const size_t jend ( ( IsLower_v<MT> )
2669 ?(
min( ( IsStrictlyLower_v<MT> ? i : i+1UL ), n_, jj+block ) )
2670 :(
min( n_, jj+block ) ) );
2673 for(
size_t j=jbegin; j<jend; ++j ) {
2674 v_[i*nn_+j] += (~rhs)(i,j);
2694 template<
typename Type
2696 template<
typename MT >
2702 for(
size_t i=0UL; i<m_; ++i )
2703 for(
auto element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2704 v_[i*nn_+element->index()] += element->value();
2720 template<
typename Type
2722 template<
typename MT >
2730 for(
size_t j=0UL; j<n_; ++j )
2731 for(
auto element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2732 v_[element->index()*nn_+j] += element->value();
2748 template<
typename Type
2750 template<
typename MT >
2757 for(
size_t i=0UL; i<m_; ++i )
2759 if( IsDiagonal_v<MT> )
2761 v_[i*nn_+i] -= (~rhs)(i,i);
2765 const size_t jbegin( ( IsUpper_v<MT> )
2766 ?( IsStrictlyUpper_v<MT> ? i+1UL : i )
2768 const size_t jend ( ( IsLower_v<MT> )
2769 ?( IsStrictlyLower_v<MT> ? i : i+1UL )
2775 for( ; (j+2UL) <= jend; j+=2UL ) {
2776 v_[i*nn_+j ] -= (~rhs)(i,j );
2777 v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2780 v_[i*nn_+j] -= (~rhs)(i,j);
2799 template<
typename Type
2801 template<
typename MT >
2811 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
2813 for(
size_t i=0UL; i<m_; ++i )
2815 const size_t jbegin( ( IsUpper_v<MT> )
2816 ?( ( IsStrictlyUpper_v<MT> ? i+1UL : i ) &
size_t(-SIMDSIZE) )
2818 const size_t jend ( ( IsLower_v<MT> )
2819 ?( IsStrictlyLower_v<MT> ? i : i+1UL )
2823 const size_t jpos( ( remainder )?( jend &
size_t(-SIMDSIZE) ):( jend ) );
2824 BLAZE_INTERNAL_ASSERT( !remainder || ( jend - ( jend % (SIMDSIZE) ) ) == jpos,
"Invalid end calculation" );
2827 Iterator left(
begin(i) + jbegin );
2830 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
2831 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2832 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2833 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2834 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2836 for( ; j<jpos; j+=SIMDSIZE ) {
2837 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
2839 for( ; remainder && j<jend; ++j ) {
2840 *left -= *right; ++left; ++right;
2858 template<
typename Type
2860 template<
typename MT >
2868 constexpr
size_t block( BLOCK_SIZE );
2870 for(
size_t ii=0UL; ii<m_; ii+=block ) {
2871 const size_t iend(
min( m_, ii+block ) );
2872 for(
size_t jj=0UL; jj<n_; jj+=block )
2874 if( IsLower_v<MT> && ii < jj )
break;
2875 if( IsUpper_v<MT> && ii > jj )
continue;
2877 for(
size_t i=ii; i<iend; ++i )
2879 const size_t jbegin( ( IsUpper_v<MT> )
2880 ?(
max( ( IsStrictlyUpper_v<MT> ? i+1UL : i ), jj ) )
2882 const size_t jend ( ( IsLower_v<MT> )
2883 ?(
min( ( IsStrictlyLower_v<MT> ? i : i+1UL ), n_, jj+block ) )
2884 :(
min( n_, jj+block ) ) );
2887 for(
size_t j=jbegin; j<jend; ++j ) {
2888 v_[i*nn_+j] -= (~rhs)(i,j);
2908 template<
typename Type
2910 template<
typename MT >
2916 for(
size_t i=0UL; i<m_; ++i )
2917 for(
auto element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element )
2918 v_[i*nn_+element->index()] -= element->value();
2934 template<
typename Type
2936 template<
typename MT >
2944 for(
size_t j=0UL; j<n_; ++j )
2945 for(
auto element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element )
2946 v_[element->index()*nn_+j] -= element->value();
2962 template<
typename Type
2964 template<
typename MT >
2971 const size_t jpos( n_ &
size_t(-2) );
2974 for(
size_t i=0UL; i<m_; ++i ) {
2975 for(
size_t j=0UL; j<jpos; j+=2UL ) {
2976 v_[i*nn_+j ] *= (~rhs)(i,j );
2977 v_[i*nn_+j+1UL] *= (~rhs)(i,j+1UL);
2980 v_[i*nn_+jpos] *= (~rhs)(i,jpos);
2998 template<
typename Type
3000 template<
typename MT >
3009 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
3011 for(
size_t i=0UL; i<m_; ++i )
3013 const size_t jpos( ( remainder )?( n_ &
size_t(-SIMDSIZE) ):( n_ ) );
3014 BLAZE_INTERNAL_ASSERT( !remainder || ( n_ - ( n_ % (SIMDSIZE) ) ) == jpos,
"Invalid end calculation" );
3017 Iterator left(
begin(i) );
3020 for( ; (j+SIMDSIZE*3UL) < jpos; j+=SIMDSIZE*4UL ) {
3021 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3022 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3023 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3024 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3026 for( ; j<jpos; j+=SIMDSIZE ) {
3027 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
3029 for( ; remainder && j<n_; ++j ) {
3030 *left *= *right; ++left; ++right;
3048 template<
typename Type
3050 template<
typename MT >
3058 constexpr
size_t block( BLOCK_SIZE );
3060 for(
size_t ii=0UL; ii<m_; ii+=block ) {
3061 const size_t iend(
min( m_, ii+block ) );
3062 for(
size_t jj=0UL; jj<n_; jj+=block ) {
3063 const size_t jend(
min( n_, jj+block ) );
3064 for(
size_t i=ii; i<iend; ++i ) {
3065 for(
size_t j=jj; j<jend; ++j ) {
3066 v_[i*nn_+j] *= (~rhs)(i,j);
3086 template<
typename Type
3088 template<
typename MT >
3096 for(
size_t i=0UL; i<m_; ++i )
3100 for(
auto element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
3101 for( ; j<element->index(); ++j )
3102 reset( v_[i*nn_+j] );
3103 v_[i*nn_+j] *= element->value();
3107 for( ; j<n_; ++j ) {
3108 reset( v_[i*nn_+j] );
3126 template<
typename Type
3128 template<
typename MT >
3138 for(
size_t j=0UL; j<n_; ++j )
3142 for(
auto element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
3143 for( ; i<element->index(); ++i )
3144 reset( v_[i*nn_+j] );
3145 v_[i*nn_+j] *= element->value();
3149 for( ; i<m_; ++i ) {
3150 reset( v_[i*nn_+j] );
3177 template<
typename Type >
3179 :
public DenseMatrix< DynamicMatrix<Type,true>, true >
3205 template<
typename NewType >
3214 template<
size_t NewM
3217 using Other = DynamicMatrix<Type,true>;
3227 static constexpr
bool simdEnabled = IsVectorizable_v<Type>;
3233 static constexpr
bool smpAssignable = !IsSMPAssignable_v<Type>;
3241 explicit inline
DynamicMatrix(
size_t m,
size_t n, const Type& init );
3242 inline
DynamicMatrix( initializer_list< initializer_list<Type> > list );
3244 template< typename Other > explicit inline
DynamicMatrix(
size_t m,
size_t n, const Other* array );
3246 template< typename Other,
size_t Rows,
size_t Cols >
3247 explicit inline
DynamicMatrix( const Other (&array)[Rows][Cols] );
3251 template< typename MT,
bool SO > inline
DynamicMatrix( const Matrix<MT,SO>& m );
3265 inline
Reference operator()(
size_t i,
size_t j ) noexcept;
3266 inline
ConstReference operator()(
size_t i,
size_t j ) const noexcept;
3286 inline
DynamicMatrix& operator=( initializer_list< initializer_list<Type> > list );
3288 template< typename Other,
size_t Rows,
size_t Cols >
3289 inline
DynamicMatrix& operator=( const Other (&array)[Rows][Cols] );
3294 template< typename MT,
bool SO > inline
DynamicMatrix& operator= ( const Matrix<MT,SO>& rhs );
3295 template< typename MT,
bool SO > inline
DynamicMatrix& operator+=( const Matrix<MT,SO>& rhs );
3296 template< typename MT,
bool SO > inline
DynamicMatrix& operator-=( const Matrix<MT,SO>& rhs );
3297 template< typename MT,
bool SO > inline
DynamicMatrix& operator%=( const Matrix<MT,SO>& rhs );
3304 inline
size_t rows() const noexcept;
3305 inline
size_t columns() const noexcept;
3306 inline
size_t spacing() const noexcept;
3307 inline
size_t capacity() const noexcept;
3308 inline
size_t capacity(
size_t j ) const noexcept;
3310 inline
size_t nonZeros(
size_t j ) const;
3311 inline
void reset();
3312 inline
void reset(
size_t j );
3313 inline
void clear();
3314 void resize (
size_t m,
size_t n,
bool preserve=true );
3315 inline
void extend (
size_t m,
size_t n,
bool preserve=true );
3328 template< typename Other > inline
DynamicMatrix& scale( const Other& scalar );
3335 template< typename MT >
3336 static constexpr
bool VectorizedAssign_v =
3337 ( useOptimizedKernels &&
3344 template< typename MT >
3345 static constexpr
bool VectorizedAddAssign_v =
3346 ( useOptimizedKernels &&
3355 template< typename MT >
3356 static constexpr
bool VectorizedSubAssign_v =
3357 ( useOptimizedKernels &&
3366 template< typename MT >
3367 static constexpr
bool VectorizedSchurAssign_v =
3368 ( useOptimizedKernels &&
3383 inline
bool isIntact() const noexcept;
3390 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
3391 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
3393 inline
bool isAligned () const noexcept;
3405 template< typename MT >
3406 inline auto
assign( const DenseMatrix<MT,true>& rhs ) ->
DisableIf_t< VectorizedAssign_v<MT> >;
3408 template< typename MT >
3409 inline auto
assign( const DenseMatrix<MT,true>& rhs ) ->
EnableIf_t< VectorizedAssign_v<MT> >;
3411 template< typename MT > inline
void assign( const DenseMatrix<MT,false>& rhs );
3412 template< typename MT > inline
void assign( const SparseMatrix<MT,true>& rhs );
3413 template< typename MT > inline
void assign( const SparseMatrix<MT,false>& rhs );
3415 template< typename MT >
3416 inline auto
addAssign( const DenseMatrix<MT,true>& rhs ) ->
DisableIf_t< VectorizedAddAssign_v<MT> >;
3418 template< typename MT >
3419 inline auto
addAssign( const DenseMatrix<MT,true>& rhs ) ->
EnableIf_t< VectorizedAddAssign_v<MT> >;
3421 template< typename MT > inline
void addAssign( const DenseMatrix<MT,false>& rhs );
3422 template< typename MT > inline
void addAssign( const SparseMatrix<MT,true>& rhs );
3423 template< typename MT > inline
void addAssign( const SparseMatrix<MT,false>& rhs );
3425 template< typename MT >
3426 inline auto
subAssign ( const DenseMatrix<MT,true>& rhs ) ->
DisableIf_t< VectorizedSubAssign_v<MT> >;
3428 template< typename MT >
3429 inline auto
subAssign ( const DenseMatrix<MT,true>& rhs ) ->
EnableIf_t< VectorizedSubAssign_v<MT> >;
3431 template< typename MT > inline
void subAssign( const DenseMatrix<MT,false>& rhs );
3432 template< typename MT > inline
void subAssign( const SparseMatrix<MT,true>& rhs );
3433 template< typename MT > inline
void subAssign( const SparseMatrix<MT,false>& rhs );
3435 template< typename MT >
3436 inline auto
schurAssign ( const DenseMatrix<MT,true>& rhs ) ->
DisableIf_t< VectorizedSchurAssign_v<MT> >;
3438 template< typename MT >
3439 inline auto
schurAssign ( const DenseMatrix<MT,true>& rhs ) ->
EnableIf_t< VectorizedSchurAssign_v<MT> >;
3441 template< typename MT > inline
void schurAssign( const DenseMatrix<MT,false>& rhs );
3442 template< typename MT > inline
void schurAssign( const SparseMatrix<MT,true>& rhs );
3443 template< typename MT > inline
void schurAssign( const SparseMatrix<MT,false>& rhs );
3451 inline
size_t addPadding(
size_t minRows ) const noexcept;
3491 template< typename Type >
3513 template<
typename Type >
3521 if( IsVectorizable_v<Type> ) {
3522 for(
size_t j=0UL; j<
n_; ++j ) {
3523 for(
size_t i=
m_; i<mm_; ++i ) {
3524 v_[i+j*mm_] = Type();
3545 template<
typename Type >
3547 : DynamicMatrix( m, n )
3549 for(
size_t j=0UL; j<
n_; ++j ) {
3550 for(
size_t i=0UL; i<
m_; ++i ) {
3582 template<
typename Type >
3588 for(
const auto& rowList : list ) {
3590 for(
const auto& element : rowList ) {
3591 v_[i+j*mm_] = element;
3594 for( ; j<
n_; ++j ) {
3595 v_[i+j*mm_] = Type();
3631 template<
typename Type >
3632 template<
typename Other >
3634 : DynamicMatrix( m, n )
3636 for(
size_t j=0UL; j<n; ++j ) {
3637 for(
size_t i=0UL; i<m; ++i ) {
3638 v_[i+j*mm_] = array[i+j*m];
3670 template<
typename Type >
3671 template<
typename Other
3675 : DynamicMatrix( Rows, Cols )
3677 for(
size_t j=0UL; j<Cols; ++j ) {
3678 for(
size_t i=0UL; i<Rows; ++i ) {
3679 v_[i+j*mm_] = array[i][j];
3698 template<
typename Type >
3700 : DynamicMatrix( m.m_, m.n_ )
3718 template<
typename Type >
3723 , capacity_( m.capacity_ )
3742 template<
typename Type >
3743 template<
typename MT
3748 if( IsSparseMatrix_v<MT> ) {
3772 template<
typename Type >
3800 template<
typename Type >
3823 template<
typename Type >
3847 template<
typename Type >
3857 return (*
this)(i,j);
3875 template<
typename Type >
3885 return (*
this)(i,j);
3903 template<
typename Type >
3925 template<
typename Type >
3944 template<
typename Type >
3964 template<
typename Type >
3982 template<
typename Type >
3987 return Iterator( v_ + j*mm_ );
4000 template<
typename Type >
4005 return ConstIterator( v_ + j*mm_ );
4018 template<
typename Type >
4023 return ConstIterator( v_ + j*mm_ );
4036 template<
typename Type >
4041 return Iterator( v_ + j*mm_ + m_ );
4054 template<
typename Type >
4059 return ConstIterator( v_ + j*mm_ + m_ );
4072 template<
typename Type >
4077 return ConstIterator( v_ + j*mm_ + m_ );
4098 template<
typename Type >
4101 for(
size_t j=0UL; j<n_; ++j )
4102 for(
size_t i=0UL; i<m_; ++i )
4133 template<
typename Type >
4134 inline DynamicMatrix<Type,true>&
4141 for(
const auto& rowList : list ) {
4143 for(
const auto& element : rowList ) {
4144 v_[i+j*mm_] = element;
4147 for( ; j<n_; ++j ) {
4148 v_[i+j*mm_] = Type();
4181 template<
typename Type >
4182 template<
typename Other
4187 resize( Rows, Cols,
false );
4189 for(
size_t j=0UL; j<Cols; ++j )
4190 for(
size_t i=0UL; i<Rows; ++i )
4191 v_[i+j*mm_] = array[i][j];
4209 template<
typename Type >
4212 if( &rhs ==
this )
return *
this;
4214 resize( rhs.m_, rhs.n_,
false );
4232 template<
typename Type >
4240 capacity_ = rhs.capacity_;
4246 rhs.capacity_ = 0UL;
4265 template<
typename Type >
4266 template<
typename MT
4270 using TT = decltype(
trans( *
this ) );
4271 using CT = decltype(
ctrans( *
this ) );
4272 using IT = decltype(
inv( *
this ) );
4274 if( IsSame_v<MT,TT> && (~rhs).isAliased(
this ) ) {
4277 else if( IsSame_v<MT,CT> && (~rhs).isAliased(
this ) ) {
4280 else if( !IsSame_v<MT,IT> && (~rhs).canAlias(
this ) ) {
4281 DynamicMatrix tmp( ~rhs );
4286 if( IsSparseMatrix_v<MT> )
4310 template<
typename Type >
4311 template<
typename MT
4313 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
4315 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
4319 if( (~rhs).canAlias(
this ) ) {
4320 const ResultType_t<MT> tmp( ~rhs );
4346 template<
typename Type >
4347 template<
typename MT
4349 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
4351 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
4355 if( (~rhs).canAlias(
this ) ) {
4356 const ResultType_t<MT> tmp( ~rhs );
4382 template<
typename Type >
4383 template<
typename MT
4385 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator%=(
const Matrix<MT,SO>& rhs )
4387 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ ) {
4391 if( (~rhs).canAlias(
this ) ) {
4392 const ResultType_t<MT> tmp( ~rhs );
4421 template<
typename Type >
4436 template<
typename Type >
4454 template<
typename Type >
4469 template<
typename Type >
4485 template<
typename Type >
4502 template<
typename Type >
4505 size_t nonzeros( 0UL );
4507 for(
size_t j=0UL; j<n_; ++j )
4508 for(
size_t i=0UL; i<m_; ++i )
4525 template<
typename Type >
4530 const size_t iend( j*mm_ + m_ );
4531 size_t nonzeros( 0UL );
4533 for(
size_t i=j*mm_; i<iend; ++i )
4549 template<
typename Type >
4554 for(
size_t j=0UL; j<n_; ++j )
4555 for(
size_t i=0UL; i<m_; ++i )
4556 clear( v_[i+j*mm_] );
4572 template<
typename Type >
4578 for(
size_t i=0UL; i<m_; ++i )
4579 clear( v_[i+j*mm_] );
4593 template<
typename Type >
4596 resize( 0UL, 0UL,
false );
4637 template<
typename Type >
4643 if( m == m_ && n == n_ )
return;
4645 const size_t mm( addPadding( m ) );
4650 const size_t min_m(
min( m, m_ ) );
4651 const size_t min_n(
min( n, n_ ) );
4653 for(
size_t j=0UL; j<min_n; ++j ) {
4654 transfer( v_+j*mm_, v_+min_m+j*mm_, v+j*mm );
4661 else if( mm*n > capacity_ ) {
4668 if( IsVectorizable_v<Type> ) {
4669 for(
size_t j=0UL; j<n; ++j )
4670 for(
size_t i=m; i<mm; ++i )
4671 v_[i+j*mm] = Type();
4697 template<
typename Type >
4700 resize( m_+m, n_+n, preserve );
4716 template<
typename Type >
4729 if( IsVectorizable_v<Type> ) {
4730 for(
size_t i=capacity_; i<
elements; ++i )
4755 template<
typename Type >
4758 if( ( mm_ * n_ ) < capacity_ ) {
4759 DynamicMatrix( *this ).swap( *
this );
4773 template<
typename Type >
4781 swap( capacity_, m.capacity_ );
4798 template<
typename Type >
4801 if( usePadding && IsVectorizable_v<Type> )
4802 return nextMultiple<size_t>( values, SIMDSIZE );
4823 template<
typename Type >
4828 constexpr
size_t block( BLOCK_SIZE );
4832 for(
size_t jj=0UL; jj<n_; jj+=block ) {
4833 const size_t jend(
min( jj+block, n_ ) );
4834 for(
size_t ii=0UL; ii<=jj; ii+=block ) {
4835 for(
size_t j=jj; j<jend; ++j ) {
4836 const size_t iend(
min( ii+block, m_, j ) );
4837 for(
size_t i=ii; i<iend; ++i ) {
4838 swap( v_[i+j*mm_], v_[j+i*mm_] );
4846 DynamicMatrix tmp(
trans(*
this) );
4862 template<
typename Type >
4865 constexpr
size_t block( BLOCK_SIZE );
4869 for(
size_t jj=0UL; jj<n_; jj+=block ) {
4870 const size_t jend(
min( jj+block, n_ ) );
4871 for(
size_t ii=0UL; ii<jj; ii+=block ) {
4872 const size_t iend(
min( ii+block, m_ ) );
4873 for(
size_t j=jj; j<jend; ++j ) {
4874 for(
size_t i=ii; i<iend; ++i ) {
4875 cswap( v_[i+j*mm_], v_[j+i*mm_] );
4879 for(
size_t j=jj; j<jend; ++j ) {
4880 for(
size_t i=jj; i<j; ++i ) {
4881 cswap( v_[i+j*mm_], v_[j+i*mm_] );
4889 DynamicMatrix tmp(
ctrans(*
this) );
4917 template<
typename Type >
4918 template<
typename Other >
4919 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale(
const Other& scalar )
4921 for(
size_t j=0UL; j<n_; ++j )
4922 for(
size_t i=0UL; i<m_; ++i )
4923 v_[i+j*mm_] *= scalar;
4949 template<
typename Type >
4952 if( m_ * n_ > capacity_ )
4955 if( IsVectorizable_v<Type> ) {
4956 for(
size_t j=0UL; j<n_; ++j ) {
4957 for(
size_t i=m_; i<mm_; ++i ) {
4958 if( v_[i+j*mm_] != Type() )
4989 template<
typename Type >
4990 template<
typename Other >
4993 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
5010 template<
typename Type >
5011 template<
typename Other >
5014 return static_cast<const void*>(
this ) == static_cast<const void*>( alias );
5030 template<
typename Type >
5033 return ( usePadding ||
rows() % SIMDSIZE == 0UL );
5050 template<
typename Type >
5053 return (
rows() *
columns() >= SMP_DMATASSIGN_THRESHOLD );
5074 template<
typename Type >
5079 return loada( i, j );
5081 return loadu( i, j );
5102 template<
typename Type >
5116 return loada( v_+i+j*mm_ );
5137 template<
typename Type >
5149 return loadu( v_+i+j*mm_ );
5171 template<
typename Type >
5200 template<
typename Type >
5214 storea( v_+i+j*mm_, value );
5236 template<
typename Type >
5248 storeu( v_+i+j*mm_, value );
5271 template<
typename Type >
5285 stream( v_+i+j*mm_, value );
5303 template<
typename Type >
5304 template<
typename MT >
5306 -> DisableIf_t< VectorizedAssign_v<MT> >
5311 const size_t ipos( m_ &
size_t(-2) );
5314 for(
size_t j=0UL; j<n_; ++j ) {
5315 for(
size_t i=0UL; i<ipos; i+=2UL ) {
5316 v_[i +j*mm_] = (~rhs)(i ,j);
5317 v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
5320 v_[ipos+j*mm_] = (~rhs)(ipos,j);
5340 template<
typename Type >
5341 template<
typename MT >
5343 -> EnableIf_t< VectorizedAssign_v<MT> >
5350 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
5352 const size_t ipos( ( remainder )?( m_ &
size_t(-SIMDSIZE) ):( m_ ) );
5353 BLAZE_INTERNAL_ASSERT( !remainder || ( m_ - ( m_ % (SIMDSIZE) ) ) == ipos,
"Invalid end calculation" );
5355 if( usePadding && useStreaming &&
5356 ( m_*n_ > ( cacheSize / (
sizeof(Type) * 3UL ) ) ) && !(~rhs).isAliased(
this ) )
5358 for(
size_t j=0UL; j<n_; ++j )
5361 Iterator left(
begin(j) );
5362 ConstIterator_t<MT> right( (~rhs).
begin(j) );
5364 for( ; i<ipos; i+=SIMDSIZE ) {
5365 left.stream( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5367 for( ; remainder && i<m_; ++i ) {
5368 *left = *right; ++left; ++right;
5374 for(
size_t j=0UL; j<n_; ++j )
5377 Iterator left(
begin(j) );
5378 ConstIterator_t<MT> right( (~rhs).
begin(j) );
5380 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5381 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5382 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5383 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5384 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5386 for( ; i<ipos; i+=SIMDSIZE ) {
5387 left.store( right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5389 for( ; remainder && i<m_; ++i ) {
5390 *left = *right; ++left; ++right;
5411 template<
typename Type >
5412 template<
typename MT >
5420 constexpr
size_t block( BLOCK_SIZE );
5422 for(
size_t jj=0UL; jj<n_; jj+=block ) {
5423 const size_t jend(
min( n_, jj+block ) );
5424 for(
size_t ii=0UL; ii<m_; ii+=block ) {
5425 const size_t iend(
min( m_, ii+block ) );
5426 for(
size_t j=jj; j<jend; ++j ) {
5427 for(
size_t i=ii; i<iend; ++i ) {
5428 v_[i+j*mm_] = (~rhs)(i,j);
5450 template<
typename Type >
5451 template<
typename MT >
5457 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
5458 for(
auto element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
5459 v_[element->index()+j*mm_] = element->value();
5477 template<
typename Type >
5478 template<
typename MT >
5486 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
5487 for(
auto element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
5488 v_[i+element->index()*mm_] = element->value();
5506 template<
typename Type >
5507 template<
typename MT >
5509 -> DisableIf_t< VectorizedAddAssign_v<MT> >
5514 for(
size_t j=0UL; j<n_; ++j )
5516 if( IsDiagonal_v<MT> )
5518 v_[j+j*mm_] += (~rhs)(j,j);
5522 const size_t ibegin( ( IsLower_v<MT> )
5523 ?( IsStrictlyLower_v<MT> ? j+1UL : j )
5525 const size_t iend ( ( IsUpper_v<MT> )
5526 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
5532 for( ; (i+2UL) <= iend; i+=2UL ) {
5533 v_[i +j*mm_] += (~rhs)(i ,j);
5534 v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
5537 v_[i+j*mm_] += (~rhs)(i,j);
5558 template<
typename Type >
5559 template<
typename MT >
5561 -> EnableIf_t< VectorizedAddAssign_v<MT> >
5569 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
5571 for(
size_t j=0UL; j<n_; ++j )
5573 const size_t ibegin( ( IsLower_v<MT> )
5574 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5576 const size_t iend ( ( IsUpper_v<MT> )
5577 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
5581 const size_t ipos( ( remainder )?( iend &
size_t(-SIMDSIZE) ):( iend ) );
5582 BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (SIMDSIZE) ) ) == ipos,
"Invalid end calculation" );
5585 Iterator left(
begin(j) + ibegin );
5586 ConstIterator_t<MT> right( (~rhs).
begin(j) + ibegin );
5588 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5589 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5590 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5591 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5592 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5594 for( ; i<ipos; i+=SIMDSIZE ) {
5595 left.store( left.load() + right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5597 for( ; remainder && i<iend; ++i ) {
5598 *left += *right; ++left; ++right;
5618 template<
typename Type >
5619 template<
typename MT >
5627 constexpr
size_t block( BLOCK_SIZE );
5629 for(
size_t jj=0UL; jj<n_; jj+=block ) {
5630 const size_t jend(
min( n_, jj+block ) );
5631 for(
size_t ii=0UL; ii<m_; ii+=block )
5633 if( IsLower_v<MT> && ii < jj )
continue;
5634 if( IsUpper_v<MT> && ii > jj )
break;
5636 for(
size_t j=jj; j<jend; ++j )
5638 const size_t ibegin( ( IsLower_v<MT> )
5639 ?(
max( ( IsStrictlyLower_v<MT> ? j+1UL : j ), ii ) )
5641 const size_t iend ( ( IsUpper_v<MT> )
5642 ?(
min( ( IsStrictlyUpper_v<MT> ? j : j+1UL ), m_, ii+block ) )
5643 :(
min( m_, ii+block ) ) );
5646 for(
size_t i=ibegin; i<iend; ++i ) {
5647 v_[i+j*mm_] += (~rhs)(i,j);
5669 template<
typename Type >
5670 template<
typename MT >
5676 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
5677 for(
auto element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
5678 v_[element->index()+j*mm_] += element->value();
5696 template<
typename Type >
5697 template<
typename MT >
5705 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
5706 for(
auto element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
5707 v_[i+element->index()*mm_] += element->value();
5725 template<
typename Type >
5726 template<
typename MT >
5728 -> DisableIf_t< VectorizedSubAssign_v<MT> >
5733 for(
size_t j=0UL; j<n_; ++j )
5735 if( IsDiagonal_v<MT> )
5737 v_[j+j*mm_] -= (~rhs)(j,j);
5741 const size_t ibegin( ( IsLower_v<MT> )
5742 ?( IsStrictlyLower_v<MT> ? j+1UL : j )
5744 const size_t iend ( ( IsUpper_v<MT> )
5745 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
5751 for( ; (i+2UL) <= iend; i+=2UL ) {
5752 v_[i +j*mm_] -= (~rhs)(i ,j);
5753 v_[i+1+j*mm_] -= (~rhs)(i+1,j);
5756 v_[i+j*mm_] -= (~rhs)(i,j);
5777 template<
typename Type >
5778 template<
typename MT >
5780 -> EnableIf_t< VectorizedSubAssign_v<MT> >
5788 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
5790 for(
size_t j=0UL; j<n_; ++j )
5792 const size_t ibegin( ( IsLower_v<MT> )
5793 ?( ( IsStrictlyLower_v<MT> ? j+1UL : j ) &
size_t(-SIMDSIZE) )
5795 const size_t iend ( ( IsUpper_v<MT> )
5796 ?( IsStrictlyUpper_v<MT> ? j : j+1UL )
5800 const size_t ipos( ( remainder )?( iend &
size_t(-SIMDSIZE) ):( iend ) );
5801 BLAZE_INTERNAL_ASSERT( !remainder || ( iend - ( iend % (SIMDSIZE) ) ) == ipos,
"Invalid end calculation" );
5804 Iterator left(
begin(j) + ibegin );
5805 ConstIterator_t<MT> right( (~rhs).
begin(j) + ibegin );
5807 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
5808 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5809 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5810 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5811 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5813 for( ; i<ipos; i+=SIMDSIZE ) {
5814 left.store( left.load() - right.load() ); left += SIMDSIZE; right += SIMDSIZE;
5816 for( ; remainder && i<iend; ++i ) {
5817 *left -= *right; ++left; ++right;
5837 template<
typename Type >
5838 template<
typename MT >
5846 constexpr
size_t block( BLOCK_SIZE );
5848 for(
size_t jj=0UL; jj<n_; jj+=block ) {
5849 const size_t jend(
min( n_, jj+block ) );
5850 for(
size_t ii=0UL; ii<m_; ii+=block )
5852 if( IsLower_v<MT> && ii < jj )
continue;
5853 if( IsUpper_v<MT> && ii > jj )
break;
5855 for(
size_t j=jj; j<jend; ++j )
5857 const size_t ibegin( ( IsLower_v<MT> )
5858 ?(
max( ( IsStrictlyLower_v<MT> ? j+1UL : j ), ii ) )
5860 const size_t iend ( ( IsUpper_v<MT> )
5861 ?(
min( ( IsStrictlyUpper_v<MT> ? j : j+1UL ), m_, ii+block ) )
5862 :(
min( m_, ii+block ) ) );
5865 for(
size_t i=ibegin; i<iend; ++i ) {
5866 v_[i+j*mm_] -= (~rhs)(i,j);
5888 template<
typename Type >
5889 template<
typename MT >
5895 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
5896 for(
auto element=(~rhs).begin(j); element!=(~rhs).
end(j); ++element )
5897 v_[element->index()+j*mm_] -= element->value();
5915 template<
typename Type >
5916 template<
typename MT >
5924 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
5925 for(
auto element=(~rhs).begin(i); element!=(~rhs).
end(i); ++element )
5926 v_[i+element->index()*mm_] -= element->value();
5944 template<
typename Type >
5945 template<
typename MT >
5947 -> DisableIf_t< VectorizedSchurAssign_v<MT> >
5952 const size_t ipos( m_ &
size_t(-2) );
5955 for(
size_t j=0UL; j<n_; ++j ) {
5956 for(
size_t i=0UL; (i+2UL) <= ipos; i+=2UL ) {
5957 v_[i +j*mm_] *= (~rhs)(i ,j);
5958 v_[i+1+j*mm_] *= (~rhs)(i+1,j);
5961 v_[ipos+j*mm_] *= (~rhs)(ipos,j);
5981 template<
typename Type >
5982 template<
typename MT >
5984 -> EnableIf_t< VectorizedSchurAssign_v<MT> >
5991 constexpr
bool remainder( !usePadding || !IsPadded_v<MT> );
5993 for(
size_t j=0UL; j<n_; ++j )
5995 const size_t ipos( ( remainder )?( m_ &
size_t(-SIMDSIZE) ):( m_ ) );
5996 BLAZE_INTERNAL_ASSERT( !remainder || ( m_ - ( m_ % (SIMDSIZE) ) ) == ipos,
"Invalid end calculation" );
5999 Iterator left(
begin(j) );
6000 ConstIterator_t<MT> right( (~rhs).
begin(j) );
6002 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
6003 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6004 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6005 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6006 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6008 for( ; i<ipos; i+=SIMDSIZE ) {
6009 left.store( left.load() * right.load() ); left += SIMDSIZE; right += SIMDSIZE;
6011 for( ; remainder && i<m_; ++i ) {
6012 *left *= *right; ++left; ++right;
6032 template<
typename Type >
6033 template<
typename MT >
6041 constexpr
size_t block( BLOCK_SIZE );
6043 for(
size_t jj=0UL; jj<n_; jj+=block ) {
6044 const size_t jend(
min( n_, jj+block ) );
6045 for(
size_t ii=0UL; ii<m_; ii+=block ) {
6046 const size_t iend(
min( m_, ii+block ) );
6047 for(
size_t j=jj; j<jend; ++j ) {
6048 for(
size_t i=ii; i<iend; ++i ) {
6049 v_[i+j*mm_] *= (~rhs)(i,j);
6071 template<
typename Type >
6072 template<
typename MT >
6080 for(
size_t j=0UL; j<n_; ++j )
6084 for(
auto element=(~rhs).
begin(j); element!=(~rhs).
end(j); ++element ) {
6085 for( ; i<element->index(); ++i )
6086 reset( v_[i+j*mm_] );
6087 v_[i+j*mm_] *= element->value();
6091 for( ; i<m_; ++i ) {
6092 reset( v_[i+j*mm_] );
6112 template<
typename Type >
6113 template<
typename MT >
6123 for(
size_t i=0UL; i<m_; ++i )
6127 for(
auto element=(~rhs).
begin(i); element!=(~rhs).
end(i); ++element ) {
6128 for( ; j<element->index(); ++j )
6129 reset( v_[i+j*mm_] );
6130 v_[i+j*mm_] *= element->value();
6134 for( ; j<n_; ++j ) {
6135 reset( v_[i+j*mm_] );
6158 template<
typename Type,
bool SO >
6159 void reset( DynamicMatrix<Type,SO>& m );
6161 template<
typename Type,
bool SO >
6162 void reset( DynamicMatrix<Type,SO>& m,
size_t i );
6164 template<
typename Type,
bool SO >
6165 void clear( DynamicMatrix<Type,SO>& m );
6167 template<
bool RF,
typename Type,
bool SO >
6168 bool isDefault(
const DynamicMatrix<Type,SO>& m );
6170 template<
typename Type,
bool SO >
6171 bool isIntact(
const DynamicMatrix<Type,SO>& m ) noexcept;
6173 template<
typename Type,
bool SO >
6174 void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) noexcept;
6186 template<
typename Type
6208 template<
typename Type
6224 template<
typename Type
6286 template<
typename Type
6290 return m.isIntact();
6303 template<
typename Type
6322 template<
typename T,
bool SO >
6323 struct HasConstDataAccess< DynamicMatrix<T,SO> >
6340 template<
typename T,
bool SO >
6341 struct HasMutableDataAccess< DynamicMatrix<T,SO> >
6358 template<
typename T,
bool SO >
6359 struct IsAligned< DynamicMatrix<T,SO> >
6376 template<
typename T,
bool SO >
6377 struct IsContiguous< DynamicMatrix<T,SO> >
6394 template<
typename T,
bool SO >
6395 struct IsPadded< DynamicMatrix<T,SO> >
6412 template<
typename T,
bool SO >
6413 struct IsResizable< DynamicMatrix<T,SO> >
6430 template<
typename T,
bool SO >
6431 struct IsShrinkable< DynamicMatrix<T,SO> >
6448 template<
typename T1,
typename T2 >
6449 struct AddTraitEval2< T1, T2
6452 ( IsDenseMatrix_v<T1> || IsDenseMatrix_v<T2> ) &&
6462 using ET1 = ElementType_t<T1>;
6463 using ET2 = ElementType_t<T2>;
6465 static constexpr
bool SO1 = StorageOrder_v<T1>;
6466 static constexpr
bool SO2 = StorageOrder_v<T2>;
6468 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
6469 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
6470 ? ( IsSymmetric_v<T1>
6478 using Type = DynamicMatrix< AddTrait_t<ET1,ET2>, SO >;
6494 template<
typename T1,
typename T2 >
6495 struct SubTraitEval2< T1, T2
6498 ( IsDenseMatrix_v<T1> || IsDenseMatrix_v<T2> ) &&
6508 using ET1 = ElementType_t<T1>;
6509 using ET2 = ElementType_t<T2>;
6511 static constexpr
bool SO1 = StorageOrder_v<T1>;
6512 static constexpr
bool SO2 = StorageOrder_v<T2>;
6514 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
6515 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
6516 ? ( IsSymmetric_v<T1>
6524 using Type = DynamicMatrix< SubTrait_t<ET1,ET2>, SO >;
6540 template<
typename T1,
typename T2 >
6541 struct SchurTraitEval2< T1, T2
6543 IsDenseMatrix_v<T2> &&
6553 using ET1 = ElementType_t<T1>;
6554 using ET2 = ElementType_t<T2>;
6556 static constexpr
bool SO1 = StorageOrder_v<T1>;
6557 static constexpr
bool SO2 = StorageOrder_v<T2>;
6559 static constexpr
bool SO = ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
6560 ? ( IsSymmetric_v<T1>
6565 using Type = DynamicMatrix< MultTrait_t<ET1,ET2>, SO >;
6581 template<
typename T1,
typename T2 >
6582 struct MultTraitEval2< T1, T2
6590 using ET1 = ElementType_t<T1>;
6592 using Type = DynamicMatrix< MultTrait_t<ET1,T2>, StorageOrder_v<T1> >;
6595 template<
typename T1,
typename T2 >
6596 struct MultTraitEval2< T1, T2
6598 IsDenseMatrix_v<T2> &&
6604 using ET2 = ElementType_t<T2>;
6606 using Type = DynamicMatrix< MultTrait_t<T1,ET2>, StorageOrder_v<T2> >;
6609 template<
typename T1,
typename T2 >
6610 struct MultTraitEval2< T1, T2
6612 IsDenseVector_v<T2> &&
6613 IsColumnVector_v<T1> &&
6614 IsRowVector_v<T2> &&
6620 using ET1 = ElementType_t<T1>;
6621 using ET2 = ElementType_t<T2>;
6623 using Type = DynamicMatrix< MultTrait_t<ET1,ET2>,
false >;
6626 template<
typename T1,
typename T2 >
6627 struct MultTraitEval2< T1, T2
6630 ( IsDenseMatrix_v<T1> || IsDenseMatrix_v<T2> ) &&
6634 ( !IsSquare_v<T2> || Size_v<T1,1UL> ==
DefaultSize_v ) ) ) &&
6640 using ET1 = ElementType_t<T1>;
6641 using ET2 = ElementType_t<T2>;
6643 static constexpr
bool SO = ( IsSparseMatrix_v<T1> ? StorageOrder_v<T2> : StorageOrder_v<T1> );
6645 using Type = DynamicMatrix< MultTrait_t<ET1,ET2>, SO >;
6661 template<
typename T1,
typename T2 >
6662 struct KronTraitEval2< T1, T2
6664 IsDenseMatrix_v<T2> &&
6674 using ET1 = ElementType_t<T1>;
6675 using ET2 = ElementType_t<T2>;
6677 using Type = DynamicMatrix< MultTrait_t<ET1,ET2>, StorageOrder_v<T2> >;
6693 template<
typename T1,
typename T2 >
6694 struct DivTraitEval2< T1, T2
6702 using ET1 = ElementType_t<T1>;
6704 using Type = DynamicMatrix< DivTrait_t<ET1,T2>, StorageOrder_v<T1> >;
6720 template<
typename T,
typename OP >
6721 struct UnaryMapTraitEval2< T, OP
6728 using ET = ElementType_t<T>;
6730 using Type = DynamicMatrix< MapTrait_t<ET,OP>, StorageOrder_v<T> >;
6738 template<
typename T1,
typename T2,
typename OP >
6739 struct BinaryMapTraitEval2< T1, T2, OP
6751 using ET1 = ElementType_t<T1>;
6752 using ET2 = ElementType_t<T2>;
6754 static constexpr
bool SO1 = StorageOrder_v<T1>;
6755 static constexpr
bool SO2 = StorageOrder_v<T2>;
6757 static constexpr
bool SO = ( IsDenseMatrix_v<T1> && IsDenseMatrix_v<T2>
6758 ? ( IsSymmetric_v<T1> ^ IsSymmetric_v<T2>
6759 ? ( IsSymmetric_v<T1>
6767 using Type = DynamicMatrix< MapTrait_t<ET1,ET2,OP>, SO >;
6783 template<
typename T
6785 struct ExpandTraitEval2< T, E
6793 using Type = DynamicMatrix< ElementType_t<T>, TF >;
6809 template<
typename T1,
bool SO,
typename T2 >
6810 struct HighType< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
6812 using Type = DynamicMatrix< typename HighType<T1,T2>::Type, SO >;
6828 template<
typename T1,
bool SO,
typename T2 >
6829 struct LowType< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
6831 using Type = DynamicMatrix< typename LowType<T1,T2>::Type, SO >;
6847 template<
typename MT >
6855 using Type = DynamicMatrix< RemoveConst_t< ElementType_t<MT> >, StorageOrder_v<MT> >;
6871 template<
typename MT,
size_t M >
6872 struct RowsTraitEval2< MT, M
6877 using Type = DynamicMatrix< RemoveConst_t< ElementType_t<MT> >,
false >;
6893 template<
typename MT,
size_t N >
6894 struct ColumnsTraitEval2< MT, N
6899 using Type = DynamicMatrix< RemoveConst_t< ElementType_t<MT> >,
true >;
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,...
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:511
size_t addPadding(size_t value) const noexcept
Add the necessary amount of padding to the given value.
Definition: DynamicMatrix.h:1842
Header file for auxiliary alias declarations.
Headerfile for the generic min algorithm.
BLAZE_ALWAYS_INLINE void storeu(size_t i, size_t j, const SIMDType &value) noexcept
Unaligned store of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2273
Header file for kernel specific block sizes.
Header file for the Schur product trait.
bool isAligned() const noexcept
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:2067
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1763
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
Header file for the nextMultiple shim.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for the alignment flag values.
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1466
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE SIMDType load(size_t i, size_t j) const noexcept
Load of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2111
Header file for basic type definitions.
auto subAssign(const DenseMatrix< MT, SO > &rhs) -> DisableIf_t< VectorizedSubAssign_v< MT > >
Default implementation of the subtraction assignment of a row-major dense matrix.
Definition: DynamicMatrix.h:2751
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:229
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:514
BLAZE_ALWAYS_INLINE SIMDType loadu(size_t i, size_t j) const noexcept
Unaligned load of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2174
typename T::ResultType ResultType_t
Alias declaration for nested ResultType type definitions.The ResultType_t alias declaration provides ...
Definition: Aliases.h:390
constexpr bool IsSIMDCombinable_v
Auxiliary variable template for the IsSIMDCombinable type trait.The IsSIMDCombinable_v variable templ...
Definition: IsSIMDCombinable.h:137
Header file for the IsSparseMatrix type trait.
DynamicMatrix & operator=(const Type &rhs)
Homogenous assignment to all matrix elements.
Definition: DynamicMatrix.h:1159
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1686
Header file for the IsDiagonal type trait.
DynamicMatrix() noexcept
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:552
Header file for the IsSame and IsStrictlySame type traits.
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:76
BLAZE_ALWAYS_INLINE void store(size_t i, size_t j, const SIMDType &value) noexcept
Store of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2208
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:231
Header file for the IsRowVector type trait.
typename SIMDTrait< T >::Type SIMDTrait_t
Auxiliary alias declaration for the SIMDTrait class template.The SIMDTrait_t alias declaration provid...
Definition: SIMDTrait.h:315
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
ConstIterator cend(size_t i) const noexcept
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:1135
BLAZE_ALWAYS_INLINE void cswap(T &a, T &b) noexcept(IsNumeric_v< T >)
Swapping two conjugated values/objects.
Definition: Conjugate.h:195
Header file for the reset shim.
constexpr bool HasSIMDAdd_v
Auxiliary variable template for the HasSIMDAdd type trait.The HasSIMDAdd_v variable template provides...
Definition: HasSIMDAdd.h:187
Type & Reference
Reference to a non-constant matrix value.
Definition: DynamicMatrix.h:236
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:228
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
Header file for memory allocation and deallocation functionality.
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storeu(T1 *address, const SIMDi8< T2 > &value) noexcept
Unaligned store of a vector of 1-byte integral values.
Definition: Storeu.h:75
Header file for the extended initializer_list functionality.
System settings for performance optimizations.
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:221
DenseMatrix< This, SO > BaseType
Base type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:227
Header file for the MaxSize type trait.
BLAZE_ALWAYS_INLINE void stream(size_t i, size_t j, const SIMDType &value) noexcept
Aligned, non-temporal store of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2308
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
constexpr bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes....
Definition: DenseMatrix.h:81
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes....
Definition: Forward.h:145
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
bool canSMPAssign() const noexcept
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:2086
Constraint on the data type.
constexpr bool IsDenseMatrix_v
Auxiliary variable template for the IsDenseMatrix type trait.The IsDenseMatrix_v variable template pr...
Definition: IsDenseMatrix.h:138
Header file for the IsMatrix type trait.
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:816
Header file for the SparseMatrix base class.
Header file for the IsSquare type trait.
size_t spacing() const noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DynamicMatrix.h:1499
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
constexpr bool columnMajor
Storage order flag for column-major matrices.
Definition: StorageOrder.h:99
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the LowType type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
constexpr ptrdiff_t DefaultMaxSize_v
Default size of the MaxSize type trait.
Definition: MaxSize.h:72
Header file for the IsSymmetric type trait.
DynamicMatrix & ctranspose()
In-place conjugate transpose of the matrix.
Definition: DynamicMatrix.h:1904
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
decltype(auto) ctrans(const DenseMatrix< MT, SO > &dm)
Returns the conjugate transpose matrix of dm.
Definition: DMatMapExpr.h:1361
void shrinkToFit()
Requesting the removal of unused capacity.
Definition: DynamicMatrix.h:1801
bool isAliased(const Other *alias) const noexcept
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:2049
const This & CompositeType
Data type for composite expression templates.
Definition: DynamicMatrix.h:234
Header file for the IsShrinkable type trait.
DynamicMatrix< NewType, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:250
#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:79
Header file for the IsSMPAssignable type trait.
constexpr bool HasSIMDSub_v
Auxiliary variable template for the HasSIMDSub type trait.The HasSIMDSub_v variable template provides...
Definition: HasSIMDSub.h:187
Header file for the expand trait.
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1162
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:238
Header file for the HasSIMDAdd type trait.
Header file for the DenseMatrix base class.
Header file for the DenseIterator class template.
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition: DMatInvExpr.h:423
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Header file for all SIMD functionality.
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,...
Definition: Diagonal.h:79
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: DynamicMatrix.h:276
Header file for the IsLower type trait.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for the IsAligned type trait.
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1745
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > storea(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned store of a vector of 1-byte integral values.
Definition: Storea.h:78
#define BLAZE_RESTRICT
Platform dependent setup of the restrict keyword.
Definition: Restrict.h:81
Header file for the default storage order for all vectors of the Blaze library.
Header file for the Kron product trait.
#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:61
void reset()
Reset to the default initial values.
Definition: DynamicMatrix.h:1599
auto addAssign(const DenseMatrix< MT, SO > &rhs) -> DisableIf_t< VectorizedAddAssign_v< MT > >
Default implementation of the addition assignment of a row-major dense matrix.
Definition: DynamicMatrix.h:2537
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:139
SIMDTrait_t< ElementType > SIMDType
SIMD type of the matrix elements.
Definition: DynamicMatrix.h:232
Header file for the exception macros of the math module.
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1198
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition: DynamicMatrix.h:1480
Header file for the IsDenseMatrix type trait.
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:615
Header file for the IsPadded type trait.
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:237
BLAZE_ALWAYS_INLINE void storea(size_t i, size_t j, const SIMDType &value) noexcept
Aligned store of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2237
Header file for the IsVectorizable type trait.
Pointer data() noexcept
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:944
Reference operator()(size_t i, size_t j) noexcept
2D-access to the matrix elements.
Definition: DynamicMatrix.h:844
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:512
Header file for the RemoveConst type trait.
Header file for the IsSIMDCombinable type trait.
#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,...
Definition: Symmetric.h:79
Header file for the HasSIMDMult type trait.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Header file for run time assertion macros.
auto schurAssign(const DenseMatrix< MT, SO > &rhs) -> DisableIf_t< VectorizedSchurAssign_v< MT > >
Default implementation of the Schur product assignment of a row-major dense matrix.
Definition: DynamicMatrix.h:2965
Iterator begin(size_t i) noexcept
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:1025
Header file for the addition trait.
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1643
Header file for the division trait.
Header file for the submatrix trait.
ConstIterator cbegin(size_t i) const noexcept
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:1069
Constraint on the data type.
Header file for the IsContiguous type trait.
Header file for the columns trait.
Headerfile for the generic transfer algorithm.
size_t m_
The current number of rows of the matrix.
Definition: DynamicMatrix.h:510
static constexpr size_t SIMDSIZE
The number of elements packed within a single SIMD element.
Definition: DynamicMatrix.h:428
SIMD characteristics of data types.The SIMDTrait class template provides the SIMD characteristics of ...
Definition: SIMDTrait.h:295
Header file for the cache size of the target architecture.
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:230
#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,...
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
System settings for the restrict keyword.
bool canAlias(const Other *alias) const noexcept
Returns whether the matrix can alias with the given address alias.
Definition: DynamicMatrix.h:2029
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Constraint on the data type.
auto assign(const DenseMatrix< MT, SO > &rhs) -> DisableIf_t< VectorizedAssign_v< MT > >
Default implementation of the assignment of a row-major dense matrix.
Definition: DynamicMatrix.h:2339
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:114
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
Constraint on the data type.
void swap(DynamicMatrix &m) noexcept
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1818
Constraint on the data type.
Header file for the HasSIMDSub type trait.
Header file for the HasMutableDataAccess type trait.
DenseIterator< Type, usePadding > Iterator
Iterator over non-constant elements.
Definition: DynamicMatrix.h:241
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition: Size.h:72
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: DynamicMatrix.h:1549
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant alias template represents ...
Definition: IntegralConstant.h:110
auto smpSchurAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP Schur product assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:194
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b) noexcept
Swapping the contents of two dynamic matrices.
Definition: DynamicMatrix.h:6305
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
Header file for the IsDenseVector type trait.
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for the rows trait.
typename T::ConstIterator ConstIterator_t
Alias declaration for nested ConstIterator type definitions.The ConstIterator_t alias declaration pro...
Definition: Aliases.h:110
BLAZE_ALWAYS_INLINE EnableIf_t< IsIntegral_v< T1 > &&HasSize_v< T1, 1UL > > stream(T1 *address, const SIMDi8< T2 > &value) noexcept
Aligned, non-temporal store of a vector of 1-byte integral values.
Definition: Stream.h:74
BLAZE_ALWAYS_INLINE bool checkAlignment(const T *address)
Checks the alignment of the given address.
Definition: AlignmentCheck.h:68
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
BLAZE_ALWAYS_INLINE SIMDType loada(size_t i, size_t j) const noexcept
Aligned load of a SIMD element of the matrix.
Definition: DynamicMatrix.h:2139
Iterator end(size_t i) noexcept
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:1091
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:226
DynamicMatrix< Type, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:260
EnableIf_t< IsBuiltin_v< T > > deallocate(T *address) noexcept
Deallocation of memory for built-in data types.
Definition: Memory.h:224
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
Header file for the default transpose flag for all vectors of the Blaze library.
Initializer list type of the Blaze library.
bool isIntact() const noexcept
Returns whether the invariants of the dynamic matrix are intact.
Definition: DynamicMatrix.h:1989
constexpr bool HasSIMDMult_v
Auxiliary variable template for the HasSIMDMult type trait.The HasSIMDMult_v variable template provid...
Definition: HasSIMDMult.h:188
Header file for the alignment check function.
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:513
constexpr bool IsDenseVector_v
Auxiliary variable template for the IsDenseVector type trait.The IsDenseVector_v variable template pr...
Definition: IsDenseVector.h:138
Header file for the StorageOrder type trait.
Header file for the IntegralConstant class template.
Resize mechanism to obtain a DynamicMatrix with different fixed dimensions.
Definition: DynamicMatrix.h:259
constexpr Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1080
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
Rebind mechanism to obtain a DynamicMatrix with different data/element type.
Definition: DynamicMatrix.h:249
DenseIterator< const Type, usePadding > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:242
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
Header file for the IsUpper type trait.
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
size_t capacity() const noexcept
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1513
constexpr bool IsDiagonal_v
Auxiliary variable template for the IsDiagonal type trait.The IsDiagonal_v variable template provides...
Definition: IsDiagonal.h:148
Header file for the IsColumnVector type trait.
OutputIterator transfer(InputIterator first, InputIterator last, OutputIterator dest)
Transfers the elements from the given source range to the destination range.
Definition: Transfer.h:70
Reference at(size_t i, size_t j)
Checked access to the matrix elements.
Definition: DynamicMatrix.h:889
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the Size type trait.
EnableIf_t< IsBuiltin_v< T >, T * > allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:156
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
static constexpr bool simdEnabled
Compilation flag for SIMD optimization.
Definition: DynamicMatrix.h:270
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
Definition: Assert.h:101
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:233
DynamicMatrix & transpose()
In-place transpose of the matrix.
Definition: DynamicMatrix.h:1866
constexpr size_t determineColumns(initializer_list< initializer_list< Type > > list) noexcept
Determines the maximum number of columns specified by the given initializer list.
Definition: InitializerList.h:108
Header file for the HighType type trait.
Header file for the clear shim.
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:239
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825