35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
176 template<
typename Type
206 template<
typename ET >
232 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
233 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
235 template<
typename Other,
size_t M,
size_t N >
239 template<
typename MT,
bool SO2 >
inline DynamicMatrix(
const Matrix<MT,SO2>& m );
271 template<
typename Other,
size_t M,
size_t N >
272 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
276 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator= (
const Matrix<MT,SO2>& rhs );
277 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO2>& rhs );
278 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO2>& rhs );
279 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO2>& rhs );
281 template<
typename Other >
282 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
283 operator*=( Other rhs );
285 template<
typename Other >
286 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
287 operator/=( Other rhs );
294 inline size_t rows()
const;
298 inline size_t capacity(
size_t i )
const;
300 inline size_t nonZeros(
size_t i )
const;
302 inline void reset(
size_t i );
304 void resize (
size_t m,
size_t n,
bool preserve=
true );
305 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
306 inline void reserve(
size_t elements );
308 template<
typename Other >
inline DynamicMatrix& scale(
const Other& scalar );
316 template<
typename MT >
318 struct VectorizedAssign {
319 enum { value = vectorizable && MT::vectorizable &&
320 IsSame<Type,typename MT::ElementType>::value };
327 template<
typename MT >
329 struct VectorizedAddAssign {
330 enum { value = vectorizable && MT::vectorizable &&
331 IsSame<Type,typename MT::ElementType>::value &&
332 IntrinsicTrait<Type>::addition };
339 template<
typename MT >
341 struct VectorizedSubAssign {
342 enum { value = vectorizable && MT::vectorizable &&
343 IsSame<Type,typename MT::ElementType>::value &&
344 IntrinsicTrait<Type>::subtraction };
353 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
354 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
365 template<
typename MT >
366 inline typename DisableIf< VectorizedAssign<MT> >::Type
367 assign(
const DenseMatrix<MT,SO>& rhs );
369 template<
typename MT >
370 inline typename EnableIf< VectorizedAssign<MT> >::Type
371 assign(
const DenseMatrix<MT,SO>& rhs );
373 template<
typename MT >
inline void assign(
const DenseMatrix<MT,!SO>& rhs );
374 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
375 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
377 template<
typename MT >
378 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
379 addAssign(
const DenseMatrix<MT,SO>& rhs );
381 template<
typename MT >
382 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
383 addAssign(
const DenseMatrix<MT,SO>& rhs );
385 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,!SO>& rhs );
386 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
387 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
389 template<
typename MT >
390 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
391 subAssign(
const DenseMatrix<MT,SO>& rhs );
393 template<
typename MT >
394 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
395 subAssign(
const DenseMatrix<MT,SO>& rhs );
397 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,!SO>& rhs );
398 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
399 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
454 template<
typename Type
475 template<
typename Type
480 , nn_ ( adjustColumns( n ) )
485 for(
size_t i=0UL; i<
m_; ++i ) {
486 for(
size_t j=
n_; j<
nn_; ++j )
487 v_[i*nn_+j] = Type();
503 template<
typename Type
508 , nn_ ( adjustColumns( n ) )
512 for(
size_t i=0UL; i<m; ++i ) {
513 for(
size_t j=0UL; j<
n_; ++j )
517 for(
size_t j=n_; j<
nn_; ++j )
518 v_[i*nn_+j] = Type();
548 template<
typename Type
550 template<
typename Other >
554 , nn_ ( adjustColumns( n ) )
558 for(
size_t i=0UL; i<m; ++i ) {
559 for(
size_t j=0UL; j<n; ++j )
560 v_[i*
nn_+j] = array[i*n+j];
563 for(
size_t j=n; j<
nn_; ++j )
564 v_[i*nn_+j] = Type();
592 template<
typename Type
594 template<
typename Other
600 , nn_ ( adjustColumns( N ) )
604 for(
size_t i=0UL; i<M; ++i ) {
605 for(
size_t j=0UL; j<N; ++j )
606 v_[i*
nn_+j] = array[i][j];
609 for(
size_t j=N; j<
nn_; ++j )
610 v_[i*nn_+j] = Type();
625 template<
typename Type
647 template<
typename Type
649 template<
typename MT
654 , nn_ ( adjustColumns(
n_ ) )
658 for(
size_t i=0UL; i<
m_; ++i ) {
660 j<( IsVectorizable<Type>::value ?
nn_ :
n_ ); ++j ) {
661 v_[i*
nn_+j] = Type();
681 template<
typename Type
705 template<
typename Type
724 template<
typename Type
748 template<
typename Type
769 template<
typename Type
786 template<
typename Type
804 template<
typename Type
825 template<
typename Type
847 template<
typename Type
869 template<
typename Type
891 template<
typename Type
913 template<
typename Type
935 template<
typename Type
975 template<
typename Type
977 template<
typename Other
984 for(
size_t i=0UL; i<M; ++i )
985 for(
size_t j=0UL; j<N; ++j )
986 v_[i*nn_+j] = array[i][j];
999 template<
typename Type
1003 for(
size_t i=0UL; i<
m_; ++i )
1004 for(
size_t j=0UL; j<
n_; ++j )
1021 template<
typename Type
1025 if( &rhs ==
this )
return *
this;
1044 template<
typename Type
1046 template<
typename MT
1050 if( (~rhs).canAlias(
this ) ) {
1076 template<
typename Type
1078 template<
typename MT
1083 throw std::invalid_argument(
"Matrix sizes do not match" );
1085 if( (~rhs).canAlias(
this ) ) {
1108 template<
typename Type
1110 template<
typename MT
1115 throw std::invalid_argument(
"Matrix sizes do not match" );
1117 if( (~rhs).canAlias(
this ) ) {
1140 template<
typename Type
1142 template<
typename MT
1146 if( (~rhs).
rows() !=
n_ )
1147 throw std::invalid_argument(
"Matrix sizes do not match" );
1164 template<
typename Type
1166 template<
typename Other >
1183 template<
typename Type
1185 template<
typename Other >
1210 template<
typename Type
1224 template<
typename Type
1243 template<
typename Type
1257 template<
typename Type
1277 template<
typename Type
1293 template<
typename Type
1297 size_t nonzeros( 0UL );
1299 for(
size_t i=0UL; i<
m_; ++i )
1300 for(
size_t j=0UL; j<
n_; ++j )
1320 template<
typename Type
1326 const size_t jend( (i+1UL)*nn_ );
1327 size_t nonzeros( 0UL );
1329 for(
size_t j=i*nn_; j<jend; ++j )
1343 template<
typename Type
1349 for(
size_t i=0UL; i<
m_; ++i )
1350 for(
size_t j=0UL; j<
n_; ++j )
1351 clear( v_[i*nn_+j] );
1367 template<
typename Type
1374 for(
size_t j=0UL; j<
n_; ++j )
1375 clear( v_[i*nn_+j] );
1387 template<
typename Type
1391 resize( 0UL, 0UL,
false );
1430 template<
typename Type
1436 if( m ==
m_ && n ==
n_ )
return;
1438 const size_t nn( adjustColumns( n ) );
1443 const size_t min_m(
min( m,
m_ ) );
1444 const size_t min_n(
min( n,
n_ ) );
1446 for(
size_t i=0UL; i<min_m; ++i )
1447 for(
size_t j=0UL; j<min_n; ++j )
1448 v[i*nn+j] = v_[i*nn_+j];
1462 for(
size_t i=0UL; i<m; ++i )
1463 for(
size_t j=n; j<nn; ++j )
1464 v_[i*nn+j] = Type();
1488 template<
typename Type
1506 template<
typename Type
1519 for(
size_t i=
capacity_; i<elements; ++i )
1537 template<
typename Type
1554 template<
typename Type
1556 template<
typename Other >
1559 for(
size_t i=0UL; i<
m_; ++i )
1560 for(
size_t j=0UL; j<
n_; ++j )
1561 v_[i*nn_+j] *= scalar;
1575 template<
typename Type
1594 template<
typename Type
1600 else return minColumns;
1623 template<
typename Type
1625 template<
typename Other >
1628 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1643 template<
typename Type
1645 template<
typename Other >
1648 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1662 template<
typename Type
1681 template<
typename Type
1705 template<
typename Type
1719 return load( v_+i*nn_+j );
1739 template<
typename Type
1752 return loadu( v_+i*nn_+j );
1773 template<
typename Type
1786 store( v_+i*nn_+j, value );
1807 template<
typename Type
1819 storeu( v_+i*nn_+j, value );
1840 template<
typename Type
1853 stream( v_+i*nn_+j, value );
1869 template<
typename Type
1871 template<
typename MT >
1878 const size_t jend(
n_ &
size_t(-2) );
1881 for(
size_t i=0UL; i<
m_; ++i ) {
1882 for(
size_t j=0UL; j<jend; j+=2UL ) {
1883 v_[i*nn_+j ] = (~rhs)(i,j );
1884 v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1887 v_[i*nn_+jend] = (~rhs)(i,jend);
1905 template<
typename Type
1907 template<
typename MT >
1921 for(
size_t i=0UL; i<
m_; ++i )
1927 const size_t jend(
n_ &
size_t(-
IT::size*4) );
1930 for(
size_t i=0UL; i<
m_; ++i ) {
1932 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
1939 store( v_+i*nn_+j, it.load() );
1958 template<
typename Type
1960 template<
typename MT >
1968 const size_t block( 16UL );
1970 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
1971 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
1972 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
1973 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
1974 for(
size_t i=ii; i<iend; ++i ) {
1975 for(
size_t j=jj; j<jend; ++j ) {
1976 v_[i*nn_+j] = (~rhs)(i,j);
1996 template<
typename Type
1998 template<
typename MT >
2004 for(
size_t i=0UL; i<
m_; ++i )
2006 v_[i*nn_+element->index()] = element->value();
2022 template<
typename Type
2024 template<
typename MT >
2032 for(
size_t j=0UL; j<
n_; ++j )
2034 v_[element->index()*nn_+j] = element->value();
2050 template<
typename Type
2052 template<
typename MT >
2059 const size_t jend(
n_ &
size_t(-2) );
2062 for(
size_t i=0UL; i<
m_; ++i ) {
2063 for(
size_t j=0UL; j<jend; j+=2UL ) {
2064 v_[i*nn_+j ] += (~rhs)(i,j );
2065 v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2068 v_[i*nn_+jend] += (~rhs)(i,jend);
2086 template<
typename Type
2088 template<
typename MT >
2100 const size_t jend(
n_ &
size_t(-
IT::size*4) );
2103 for(
size_t i=0UL; i<
m_; ++i ) {
2105 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
2112 store( v_+i*nn_+j,
load( v_+i*nn_+j ) + it.load() );
2130 template<
typename Type
2132 template<
typename MT >
2140 const size_t block( 16UL );
2142 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2143 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2144 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2145 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2146 for(
size_t i=ii; i<iend; ++i ) {
2147 for(
size_t j=jj; j<jend; ++j ) {
2148 v_[i*nn_+j] += (~rhs)(i,j);
2168 template<
typename Type
2170 template<
typename MT >
2176 for(
size_t i=0UL; i<
m_; ++i )
2178 v_[i*nn_+element->index()] += element->value();
2194 template<
typename Type
2196 template<
typename MT >
2204 for(
size_t j=0UL; j<
n_; ++j )
2206 v_[element->index()*nn_+j] += element->value();
2222 template<
typename Type
2224 template<
typename MT >
2231 const size_t jend(
n_ &
size_t(-2) );
2234 for(
size_t i=0UL; i<
m_; ++i ) {
2235 for(
size_t j=0UL; j<jend; j+=2UL ) {
2236 v_[i*nn_+j ] -= (~rhs)(i,j );
2237 v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2240 v_[i*nn_+jend] -= (~rhs)(i,jend);
2258 template<
typename Type
2260 template<
typename MT >
2272 const size_t jend(
n_ &
size_t(-
IT::size*4) );
2275 for(
size_t i=0UL; i<
m_; ++i ) {
2277 for(
size_t j=0UL; j<jend; j+=
IT::size*4UL ) {
2284 store( v_+i*nn_+j,
load( v_+i*nn_+j ) - it.load() );
2302 template<
typename Type
2304 template<
typename MT >
2312 const size_t block( 16UL );
2314 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2315 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2316 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2317 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2318 for(
size_t i=ii; i<iend; ++i ) {
2319 for(
size_t j=jj; j<jend; ++j ) {
2320 v_[i*nn_+j] -= (~rhs)(i,j);
2340 template<
typename Type
2342 template<
typename MT >
2348 for(
size_t i=0UL; i<
m_; ++i )
2350 v_[i*nn_+element->index()] -= element->value();
2366 template<
typename Type
2368 template<
typename MT >
2376 for(
size_t j=0UL; j<
n_; ++j )
2378 v_[element->index()*nn_+j] -= element->value();
2403 template<
typename Type >
2432 template<
typename ET >
2444 enum { vectorizable = IsVectorizable<Type>::value };
2450 enum { smpAssignable = !IsSMPAssignable<Type>::value };
2458 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
2459 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
2461 template<
typename Other,
size_t M,
size_t N >
2462 explicit inline DynamicMatrix(
const Other (&array)[M][N] );
2465 template<
typename MT,
bool SO >
inline DynamicMatrix(
const Matrix<MT,SO>& m );
2497 template<
typename Other,
size_t M,
size_t N >
2498 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
2502 template<
typename MT,
bool SO >
inline DynamicMatrix& operator= (
const Matrix<MT,SO>& rhs );
2503 template<
typename MT,
bool SO >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2504 template<
typename MT,
bool SO >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2505 template<
typename MT,
bool SO >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2507 template<
typename Other >
2508 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2509 operator*=( Other rhs );
2511 template<
typename Other >
2512 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2513 operator/=( Other rhs );
2520 inline size_t rows()
const;
2521 inline size_t columns()
const;
2522 inline size_t spacing()
const;
2524 inline size_t capacity(
size_t j )
const;
2526 inline size_t nonZeros(
size_t j )
const;
2527 inline void reset();
2528 inline void reset(
size_t j );
2529 inline void clear();
2530 void resize (
size_t m,
size_t n,
bool preserve=
true );
2531 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2532 inline void reserve(
size_t elements );
2534 template<
typename Other >
inline DynamicMatrix& scale(
const Other& scalar );
2542 template<
typename MT >
2543 struct VectorizedAssign {
2544 enum { value = vectorizable && MT::vectorizable &&
2545 IsSame<Type,typename MT::ElementType>::value };
2551 template<
typename MT >
2552 struct VectorizedAddAssign {
2553 enum { value = vectorizable && MT::vectorizable &&
2554 IsSame<Type,typename MT::ElementType>::value &&
2555 IntrinsicTrait<Type>::addition };
2561 template<
typename MT >
2562 struct VectorizedSubAssign {
2563 enum { value = vectorizable && MT::vectorizable &&
2564 IsSame<Type,typename MT::ElementType>::value &&
2565 IntrinsicTrait<Type>::subtraction };
2573 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2574 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2585 template<
typename MT >
2586 inline typename DisableIf< VectorizedAssign<MT> >::Type
2587 assign(
const DenseMatrix<MT,true>& rhs );
2589 template<
typename MT >
2590 inline typename EnableIf< VectorizedAssign<MT> >::Type
2591 assign(
const DenseMatrix<MT,true>& rhs );
2593 template<
typename MT >
inline void assign(
const DenseMatrix<MT,false>& rhs );
2594 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2595 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2597 template<
typename MT >
2598 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2599 addAssign(
const DenseMatrix<MT,true>& rhs );
2601 template<
typename MT >
2602 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2603 addAssign(
const DenseMatrix<MT,true>& rhs );
2605 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,false>& rhs );
2606 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2607 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2609 template<
typename MT >
2610 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2611 subAssign (
const DenseMatrix<MT,true>& rhs );
2613 template<
typename MT >
2614 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2615 subAssign (
const DenseMatrix<MT,true>& rhs );
2617 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,false>& rhs );
2618 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2619 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2627 inline size_t adjustRows(
size_t minRows )
const;
2674 template<
typename Type >
2696 template<
typename Type >
2699 , mm_ ( adjustRows( m ) )
2704 if( IsVectorizable<Type>::value ) {
2705 for(
size_t j=0UL; j<
n_; ++j )
2706 for(
size_t i=
m_; i<mm_; ++i ) {
2707 v_[i+j*mm_] = Type();
2725 template<
typename Type >
2728 , mm_ ( adjustRows( m ) )
2733 for(
size_t j=0UL; j<
n_; ++j ) {
2734 for(
size_t i=0UL; i<
m_; ++i )
2737 if( IsVectorizable<Type>::value ) {
2738 for(
size_t i=m_; i<mm_; ++i )
2739 v_[i+j*mm_] = Type();
2771 template<
typename Type >
2772 template<
typename Other >
2775 , mm_ ( adjustRows( m ) )
2780 for(
size_t j=0UL; j<n; ++j ) {
2781 for(
size_t i=0UL; i<m; ++i )
2782 v_[i+j*mm_] = array[i+j*m];
2784 if( IsVectorizable<Type>::value ) {
2785 for(
size_t i=m; i<mm_; ++i )
2786 v_[i+j*mm_] = Type();
2816 template<
typename Type >
2817 template<
typename Other
2822 , mm_ ( adjustRows( M ) )
2827 for(
size_t j=0UL; j<N; ++j ) {
2828 for(
size_t i=0UL; i<M; ++i )
2829 v_[i+j*mm_] = array[i][j];
2831 if( IsVectorizable<Type>::value ) {
2832 for(
size_t i=M; i<mm_; ++i )
2833 v_[i+j*mm_] = Type();
2850 template<
typename Type >
2873 template<
typename Type >
2874 template<
typename MT
2877 : m_ ( (~m).
rows() )
2878 , mm_ ( adjustRows( m_ ) )
2883 for(
size_t j=0UL; j<
n_; ++j ) {
2884 for(
size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
2885 i<( IsVectorizable<Type>::value ? mm_ :
m_ ); ++i ) {
2886 v_[i+j*mm_] = Type();
2908 template<
typename Type >
2933 template<
typename Type >
2953 template<
typename Type >
2977 template<
typename Type >
2998 template<
typename Type >
3016 template<
typename Type >
3035 template<
typename Type >
3052 template<
typename Type >
3070 template<
typename Type >
3088 template<
typename Type >
3106 template<
typename Type >
3111 return Iterator( v_ + j*mm_ + m_ );
3124 template<
typename Type >
3142 template<
typename Type >
3183 template<
typename Type >
3184 template<
typename Other
3187 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Other (&array)[M][N] )
3191 for(
size_t j=0UL; j<N; ++j )
3192 for(
size_t i=0UL; i<M; ++i )
3193 v_[i+j*mm_] = array[i][j];
3208 template<
typename Type >
3209 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3211 for(
size_t j=0UL; j<
n_; ++j )
3212 for(
size_t i=0UL; i<
m_; ++i )
3231 template<
typename Type >
3232 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const DynamicMatrix& rhs )
3234 if( &rhs ==
this )
return *
this;
3236 resize( rhs.m_, rhs.n_,
false );
3255 template<
typename Type >
3256 template<
typename MT
3258 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Matrix<MT,SO>& rhs )
3260 if( (~rhs).canAlias(
this ) ) {
3261 DynamicMatrix tmp( ~rhs );
3266 if( IsSparseMatrix<MT>::value )
3288 template<
typename Type >
3289 template<
typename MT
3291 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3293 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3294 throw std::invalid_argument(
"Matrix sizes do not match" );
3296 if( (~rhs).canAlias(
this ) ) {
3321 template<
typename Type >
3322 template<
typename MT
3324 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3326 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3327 throw std::invalid_argument(
"Matrix sizes do not match" );
3329 if( (~rhs).canAlias(
this ) ) {
3354 template<
typename Type >
3355 template<
typename MT
3357 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3359 if( (~rhs).
rows() != n_ )
3360 throw std::invalid_argument(
"Matrix sizes do not match" );
3362 DynamicMatrix tmp( *
this * (~rhs) );
3379 template<
typename Type >
3380 template<
typename Other >
3381 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3382 DynamicMatrix<Type,true>::operator*=( Other rhs )
3399 template<
typename Type >
3400 template<
typename Other >
3401 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3402 DynamicMatrix<Type,true>::operator/=( Other rhs )
3427 template<
typename Type >
3442 template<
typename Type >
3460 template<
typename Type >
3475 template<
typename Type >
3491 template<
typename Type >
3508 template<
typename Type >
3511 size_t nonzeros( 0UL );
3513 for(
size_t j=0UL; j<
n_; ++j )
3514 for(
size_t i=0UL; i<
m_; ++i )
3531 template<
typename Type >
3536 const size_t iend( (j+1UL)*mm_ );
3537 size_t nonzeros( 0UL );
3539 for(
size_t i=j*mm_; i<iend; ++i )
3555 template<
typename Type >
3560 for(
size_t j=0UL; j<
n_; ++j )
3561 for(
size_t i=0UL; i<
m_; ++i )
3562 clear( v_[i+j*mm_] );
3578 template<
typename Type >
3584 for(
size_t i=0UL; i<
m_; ++i )
3585 clear( v_[i+j*mm_] );
3599 template<
typename Type >
3602 resize( 0UL, 0UL,
false );
3643 template<
typename Type >
3648 if( m == m_ && n == n_ )
return;
3650 const size_t mm( adjustRows( m ) );
3655 const size_t min_m(
min( m, m_ ) );
3656 const size_t min_n(
min( n, n_ ) );
3658 for(
size_t j=0UL; j<min_n; ++j )
3659 for(
size_t i=0UL; i<min_m; ++i )
3660 v[i+j*mm] = v_[i+j*mm_];
3673 if( IsVectorizable<Type>::value ) {
3674 for(
size_t j=0UL; j<n; ++j )
3675 for(
size_t i=m; i<mm; ++i )
3676 v_[i+j*mm] = Type();
3702 template<
typename Type >
3705 resize( m_+m, n_+n, preserve );
3721 template<
typename Type >
3732 if( IsVectorizable<Type>::value ) {
3733 for(
size_t i=
capacity_; i<elements; ++i )
3753 template<
typename Type >
3756 DynamicMatrix tmp(
trans(*
this) );
3771 template<
typename Type >
3772 template<
typename Other >
3773 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale(
const Other& scalar )
3775 for(
size_t j=0UL; j<
n_; ++j )
3776 for(
size_t i=0UL; i<
m_; ++i )
3777 v_[i+j*mm_] *= scalar;
3793 template<
typename Type >
3813 template<
typename Type >
3814 inline size_t DynamicMatrix<Type,true>::adjustRows(
size_t minRows )
const
3816 if( IsVectorizable<Type>::value )
3818 else return minRows;
3843 template<
typename Type >
3844 template<
typename Other >
3847 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3864 template<
typename Type >
3865 template<
typename Other >
3868 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3884 template<
typename Type >
3904 template<
typename Type >
3928 template<
typename Type >
3929 inline typename DynamicMatrix<Type,true>::IntrinsicType
3941 return load( v_+i+j*mm_ );
3962 template<
typename Type >
3963 inline typename DynamicMatrix<Type,true>::IntrinsicType
3974 return loadu( v_+i+j*mm_ );
3996 template<
typename Type >
4008 store( v_+i+j*mm_, value );
4030 template<
typename Type >
4041 storeu( v_+i+j*mm_, value );
4064 template<
typename Type >
4076 stream( v_+i+j*mm_, value );
4094 template<
typename Type >
4095 template<
typename MT >
4096 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4102 const size_t iend( m_ &
size_t(-2) );
4105 for(
size_t j=0UL; j<
n_; ++j ) {
4106 for(
size_t i=0UL; i<iend; i+=2UL ) {
4107 v_[i +j*mm_] = (~rhs)(i ,j);
4108 v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4111 v_[iend+j*mm_] = (~rhs)(iend,j);
4131 template<
typename Type >
4132 template<
typename MT >
4133 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4146 for(
size_t j=0UL; j<
n_; ++j )
4152 const size_t iend( m_ &
size_t(-
IT::size*4) );
4155 for(
size_t j=0UL; j<
n_; ++j ) {
4157 for(
size_t i=0UL; i<iend; i+=
IT::size*4UL ) {
4164 store( v_+i+j*mm_, it.load() );
4185 template<
typename Type >
4186 template<
typename MT >
4194 const size_t block( 16UL );
4196 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4197 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4198 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4199 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4200 for(
size_t j=jj; j<jend; ++j ) {
4201 for(
size_t i=ii; i<iend; ++i ) {
4202 v_[i+j*mm_] = (~rhs)(i,j);
4224 template<
typename Type >
4225 template<
typename MT >
4231 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4233 v_[element->index()+j*mm_] = element->value();
4251 template<
typename Type >
4252 template<
typename MT >
4260 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4262 v_[i+element->index()*mm_] = element->value();
4280 template<
typename Type >
4281 template<
typename MT >
4282 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4288 const size_t iend( m_ &
size_t(-2) );
4291 for(
size_t j=0UL; j<
n_; ++j ) {
4292 for(
size_t i=0UL; i<iend; i+=2UL ) {
4293 v_[i +j*mm_] += (~rhs)(i ,j);
4294 v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4297 v_[iend+j*mm_] += (~rhs)(iend,j);
4317 template<
typename Type >
4318 template<
typename MT >
4319 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4330 const size_t iend( m_ &
size_t(-
IT::size*4) );
4333 for(
size_t j=0UL; j<
n_; ++j ) {
4335 for(
size_t i=0UL; i<iend; i+=
IT::size*4UL ) {
4342 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) + it.load() );
4362 template<
typename Type >
4363 template<
typename MT >
4371 const size_t block( 16UL );
4373 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4374 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4375 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4376 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4377 for(
size_t j=jj; j<jend; ++j ) {
4378 for(
size_t i=ii; i<iend; ++i ) {
4379 v_[i+j*mm_] += (~rhs)(i,j);
4401 template<
typename Type >
4402 template<
typename MT >
4408 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4410 v_[element->index()+j*mm_] += element->value();
4428 template<
typename Type >
4429 template<
typename MT >
4437 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4439 v_[i+element->index()*mm_] += element->value();
4457 template<
typename Type >
4458 template<
typename MT >
4459 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4465 const size_t iend( m_ &
size_t(-2) );
4468 for(
size_t j=0UL; j<
n_; ++j ) {
4469 for(
size_t i=0UL; i<iend; i+=2UL ) {
4470 v_[i +j*mm_] -= (~rhs)(i ,j);
4471 v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4474 v_[iend+j*mm_] -= (~rhs)(iend,j);
4495 template<
typename Type >
4496 template<
typename MT >
4497 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4508 const size_t iend( m_ &
size_t(-
IT::size*4) );
4511 for(
size_t j=0UL; j<
n_; ++j ) {
4513 for(
size_t i=0UL; i<iend; i+=
IT::size*4UL ) {
4520 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) - it.load() );
4540 template<
typename Type >
4541 template<
typename MT >
4549 const size_t block( 16UL );
4551 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4552 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4553 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4554 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4555 for(
size_t j=jj; j<jend; ++j ) {
4556 for(
size_t i=ii; i<iend; ++i ) {
4557 v_[i+j*mm_] -= (~rhs)(i,j);
4579 template<
typename Type >
4580 template<
typename MT >
4586 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4588 v_[element->index()+j*mm_] -= element->value();
4606 template<
typename Type >
4607 template<
typename MT >
4615 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4617 v_[i+element->index()*mm_] -= element->value();
4638 template<
typename Type,
bool SO >
4639 inline void reset( DynamicMatrix<Type,SO>& m );
4641 template<
typename Type,
bool SO >
4642 inline void reset( DynamicMatrix<Type,SO>& m,
size_t i );
4644 template<
typename Type,
bool SO >
4645 inline void clear( DynamicMatrix<Type,SO>& m );
4647 template<
typename Type,
bool SO >
4648 inline bool isDefault(
const DynamicMatrix<Type,SO>& m );
4650 template<
typename Type,
bool SO >
4651 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) ;
4653 template<
typename Type,
bool SO >
4654 inline void move( DynamicMatrix<Type,SO>& dst, DynamicMatrix<Type,SO>& src ) ;
4666 template<
typename Type
4688 template<
typename Type
4704 template<
typename Type
4731 template<
typename Type
4749 template<
typename Type
4767 template<
typename Type
4786 template<
typename T,
bool SO >
4787 struct IsResizable< DynamicMatrix<T,SO> > :
public TrueType
4806 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4807 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4809 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4812 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4813 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4815 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4818 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4819 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4821 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4824 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4825 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4827 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4830 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4831 struct AddTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4833 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4836 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4837 struct AddTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4839 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4842 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4843 struct AddTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4845 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4848 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4849 struct AddTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4851 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4854 template<
typename T1,
bool SO,
typename T2 >
4855 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4857 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4860 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4861 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4863 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4879 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4880 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4882 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4885 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4886 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4888 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4891 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4892 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4894 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4897 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4898 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4900 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4903 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4904 struct SubTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4906 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4909 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4910 struct SubTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4912 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4915 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4916 struct SubTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4918 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4921 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4922 struct SubTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4924 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4927 template<
typename T1,
bool SO,
typename T2 >
4928 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4930 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4933 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4934 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4936 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4952 template<
typename T1,
bool SO,
typename T2 >
4953 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
4955 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4959 template<
typename T1,
typename T2,
bool SO >
4960 struct MultTrait< T1, DynamicMatrix<T2,SO> >
4962 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4966 template<
typename T1,
bool SO,
typename T2,
size_t N >
4967 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
4969 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4972 template<
typename T1,
size_t N,
typename T2,
bool SO >
4973 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
4975 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4978 template<
typename T1,
bool SO,
typename T2,
size_t N >
4979 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
4981 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4984 template<
typename T1,
size_t N,
typename T2,
bool SO >
4985 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
4987 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4990 template<
typename T1,
bool SO,
typename T2 >
4991 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
4993 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4996 template<
typename T1,
typename T2,
bool SO >
4997 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
4999 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5002 template<
typename T1,
bool SO,
typename T2 >
5003 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
5005 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
5008 template<
typename T1,
typename T2,
bool SO >
5009 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
5011 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
5014 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5015 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
5017 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5020 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5021 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5023 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5026 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
5027 struct MultTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
5029 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5032 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
5033 struct MultTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
5035 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5038 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
5039 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
5041 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
5057 template<
typename T1,
bool SO,
typename T2 >
5058 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
5060 typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
5077 template<
typename T1,
bool SO,
typename T2 >
5078 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5080 typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5081 typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5097 template<
typename T1,
bool SO >
5098 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
5100 typedef DynamicMatrix<T1,SO> Type;
5116 template<
typename T1,
bool SO >
5117 struct RowTrait< DynamicMatrix<T1,SO> >
5119 typedef DynamicVector<T1,true> Type;
5135 template<
typename T1,
bool SO >
5136 struct ColumnTrait< DynamicMatrix<T1,SO> >
5138 typedef DynamicVector<T1,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
Reference operator()(size_t i, size_t j)
2D-access to the matrix elements.
Definition: DynamicMatrix.h:708
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:415
Constraint on the data type.
Header file for mathematical functions.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1508
#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.
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:258
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:872
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:418
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.
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:205
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1432
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
Header file for the IsSame and IsStrictlySame type traits.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DynamicMatrix.h:1226
const bool useStreaming
Configuration of the streaming behavior.For large vectors and matrices non-temporal stores can provid...
Definition: Streaming.h:50
void storeu(size_t i, size_t j, const IntrinsicType &value)
Unaligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1809
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2636
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#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
DynamicMatrix()
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:456
Header file for memory allocation and deallocation functionality.
size_t spacing() const
Returns the spacing between the beginning of two rows/columns.
Definition: DynamicMatrix.h:1245
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:178
EnableIf< IsBuiltin< T >, T * >::Type allocate(size_t size)
Aligned array allocation for built-in data types.
Definition: Memory.h:151
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
const This & CompositeType
Data type for composite expression templates.
Definition: DynamicMatrix.h:194
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:107
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2638
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:683
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:188
Header file for the SparseMatrix base class.
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: DynamicMatrix.h:1295
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1596
Header file for the DisableIf class template.
ConstIterator cend(size_t i) const
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:938
Header file for the multiplication trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1664
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1742
Header file for the clear shim.
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4754
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:191
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
#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
Header file for the IsSMPAssignable type trait.
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: DynamicMatrix.h:182
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:187
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
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.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a simple dense...
Definition: Thresholds.h:690
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:193
Constraint on the data type.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1490
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1212
#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.
#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: DynamicMatrix.h:1345
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:894
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 data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:120
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
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:189
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1259
Header file for the IsVectorizable type trait.
Header file for the IsNumeric type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:416
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1775
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:211
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:197
EnableIf< IsDenseMatrix< MT1 > >::Type smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:160
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:749
Header file for run time assertion macros.
EnableIf< IsDenseMatrix< MT1 > >::Type smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:98
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
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1389
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:198
Header file for the division trait.
Header file for the submatrix trait.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
#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
size_t m_
The current number of rows of the matrix.
Definition: DynamicMatrix.h:414
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:828
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:1646
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4769
Header file for the cache size of the target architecture.
#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:2481
Header file for the column trait.
Header file for the isDefault shim.
System settings for the restrict keyword.
Base class for matrices.The Matrix class is a base class for all dense and sparse matrix classes with...
Definition: Forward.h:87
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1577
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1708
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Implementation of a generic iterator for dense vectors and matrices.The DenseIterator represents a ge...
Definition: DenseIterator.h:58
Header file for all intrinsic functionality.
Header file for the mathematical trait.
Type & Reference
Reference to a non-constant matrix value.
Definition: DynamicMatrix.h:195
bool canSMPAssign() const
Returns whether the matrix can be used in SMP assignments.
Definition: DynamicMatrix.h:1683
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2637
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:200
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:932
EnableIf< IsDenseMatrix< MT1 > >::Type smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:129
IT::Type IntrinsicType
Intrinsic type of the matrix elements.
Definition: DynamicMatrix.h:192
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:417
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2473
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
Rebind mechanism to obtain a DynamicMatrix with different data/element type.
Definition: DynamicMatrix.h:207
DenseIterator< Type > Iterator
Iterator over non-constant elements.
Definition: DynamicMatrix.h:199
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Rebind mechanism to obtain a CompressedMatrix with different data/element type.
Definition: CompressedMatrix.h:2489
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
const size_t cacheSize
Cache size of the target architecture.This setting specifies the available cache size in Byte of the ...
Definition: CacheSize.h:48
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
Pointer data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:750
Header file for the IsResizable type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
bool canAlias(const Other *alias) const
Returns whether the matrix can alias with the given address alias.
Definition: DynamicMatrix.h:1626
DynamicMatrix< ET, SO > Other
The type of the other DynamicMatrix.
Definition: DynamicMatrix.h:208
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1539
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:196
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:190
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
Header file for a safe C++ NULL pointer implementation.
void stream(size_t i, size_t j, const IntrinsicType &value)
Aligned, non-temporal store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1842