35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
176 template<
typename Type
223 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
224 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
226 template<
typename Other,
size_t M,
size_t N >
230 template<
typename MT,
bool SO2 >
inline DynamicMatrix(
const Matrix<MT,SO2>& m );
262 template<
typename Other,
size_t M,
size_t N >
263 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
267 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator= (
const Matrix<MT,SO2>& rhs );
268 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO2>& rhs );
269 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO2>& rhs );
270 template<
typename MT,
bool SO2 >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO2>& rhs );
272 template<
typename Other >
273 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
274 operator*=( Other rhs );
276 template<
typename Other >
277 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
278 operator/=( Other rhs );
285 inline size_t rows()
const;
289 inline size_t capacity(
size_t i )
const;
291 inline size_t nonZeros(
size_t i )
const;
293 inline void reset(
size_t i );
295 void resize (
size_t m,
size_t n,
bool preserve=
true );
296 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
297 inline void reserve(
size_t elements );
299 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
307 template<
typename MT >
309 struct VectorizedAssign {
310 enum { value = vectorizable && MT::vectorizable &&
311 IsSame<Type,typename MT::ElementType>::value };
318 template<
typename MT >
320 struct VectorizedAddAssign {
321 enum { value = vectorizable && MT::vectorizable &&
322 IsSame<Type,typename MT::ElementType>::value &&
323 IntrinsicTrait<Type>::addition };
330 template<
typename MT >
332 struct VectorizedSubAssign {
333 enum { value = vectorizable && MT::vectorizable &&
334 IsSame<Type,typename MT::ElementType>::value &&
335 IntrinsicTrait<Type>::subtraction };
344 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
345 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
356 template<
typename MT >
357 inline typename DisableIf< VectorizedAssign<MT> >::Type
358 assign(
const DenseMatrix<MT,SO>& rhs );
360 template<
typename MT >
361 inline typename EnableIf< VectorizedAssign<MT> >::Type
362 assign(
const DenseMatrix<MT,SO>& rhs );
364 template<
typename MT >
inline void assign(
const DenseMatrix<MT,!SO>& rhs );
365 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
366 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
368 template<
typename MT >
369 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
370 addAssign(
const DenseMatrix<MT,SO>& rhs );
372 template<
typename MT >
373 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
374 addAssign(
const DenseMatrix<MT,SO>& rhs );
376 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,!SO>& rhs );
377 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
378 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
380 template<
typename MT >
381 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
382 subAssign(
const DenseMatrix<MT,SO>& rhs );
384 template<
typename MT >
385 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
386 subAssign(
const DenseMatrix<MT,SO>& rhs );
388 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,!SO>& rhs );
389 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
390 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
445 template<
typename Type
466 template<
typename Type
471 , nn_ ( adjustColumns( n ) )
476 for(
size_t i=0UL; i<
m_; ++i ) {
477 for(
size_t j=
n_; j<
nn_; ++j )
478 v_[i*nn_+j] = Type();
494 template<
typename Type
499 , nn_ ( adjustColumns( n ) )
503 for(
size_t i=0UL; i<m; ++i ) {
504 for(
size_t j=0UL; j<
n_; ++j )
508 for(
size_t j=n_; j<
nn_; ++j )
509 v_[i*nn_+j] = Type();
539 template<
typename Type
541 template<
typename Other >
545 , nn_ ( adjustColumns( n ) )
549 for(
size_t i=0UL; i<m; ++i ) {
550 for(
size_t j=0UL; j<n; ++j )
551 v_[i*
nn_+j] = array[i*n+j];
554 for(
size_t j=n; j<
nn_; ++j )
555 v_[i*nn_+j] = Type();
583 template<
typename Type
585 template<
typename Other
591 , nn_ ( adjustColumns( N ) )
595 for(
size_t i=0UL; i<M; ++i ) {
596 for(
size_t j=0UL; j<N; ++j )
597 v_[i*
nn_+j] = array[i][j];
600 for(
size_t j=N; j<
nn_; ++j )
601 v_[i*nn_+j] = Type();
616 template<
typename Type
638 template<
typename Type
640 template<
typename MT
645 , nn_ ( adjustColumns(
n_ ) )
649 for(
size_t i=0UL; i<
m_; ++i ) {
651 j<( IsVectorizable<Type>::value ?
nn_ :
n_ ); ++j ) {
652 v_[i*
nn_+j] = Type();
672 template<
typename Type
696 template<
typename Type
715 template<
typename Type
739 template<
typename Type
760 template<
typename Type
777 template<
typename Type
795 template<
typename Type
816 template<
typename Type
838 template<
typename Type
860 template<
typename Type
882 template<
typename Type
904 template<
typename Type
926 template<
typename Type
966 template<
typename Type
968 template<
typename Other
973 resize( M, N,
false );
975 for(
size_t i=0UL; i<M; ++i )
976 for(
size_t j=0UL; j<N; ++j )
977 v_[i*nn_+j] = array[i][j];
990 template<
typename Type
994 for(
size_t i=0UL; i<
m_; ++i )
995 for(
size_t j=0UL; j<
n_; ++j )
1012 template<
typename Type
1016 if( &rhs ==
this )
return *
this;
1018 resize( rhs.
m_, rhs.
n_,
false );
1035 template<
typename Type
1037 template<
typename MT
1041 if( (~rhs).canAlias(
this ) ) {
1067 template<
typename Type
1069 template<
typename MT
1074 throw std::invalid_argument(
"Matrix sizes do not match" );
1076 if( (~rhs).canAlias(
this ) ) {
1099 template<
typename Type
1101 template<
typename MT
1106 throw std::invalid_argument(
"Matrix sizes do not match" );
1108 if( (~rhs).canAlias(
this ) ) {
1131 template<
typename Type
1133 template<
typename MT
1137 if( (~rhs).
rows() !=
n_ )
1138 throw std::invalid_argument(
"Matrix sizes do not match" );
1155 template<
typename Type
1157 template<
typename Other >
1174 template<
typename Type
1176 template<
typename Other >
1201 template<
typename Type
1215 template<
typename Type
1234 template<
typename Type
1248 template<
typename Type
1268 template<
typename Type
1284 template<
typename Type
1288 size_t nonzeros( 0UL );
1290 for(
size_t i=0UL; i<
m_; ++i )
1291 for(
size_t j=0UL; j<
n_; ++j )
1311 template<
typename Type
1317 const size_t jend( (i+1UL)*nn_ );
1318 size_t nonzeros( 0UL );
1320 for(
size_t j=i*nn_; j<jend; ++j )
1334 template<
typename Type
1340 for(
size_t i=0UL; i<
m_; ++i )
1341 for(
size_t j=0UL; j<
n_; ++j )
1342 reset( v_[i*nn_+j] );
1358 template<
typename Type
1365 for(
size_t j=0UL; j<
n_; ++j )
1366 reset( v_[i*nn_+j] );
1378 template<
typename Type
1382 resize( 0UL, 0UL,
false );
1421 template<
typename Type
1427 if( m ==
m_ && n ==
n_ )
return;
1429 const size_t nn( adjustColumns( n ) );
1434 const size_t min_m( min( m,
m_ ) );
1435 const size_t min_n( min( n,
n_ ) );
1437 for(
size_t i=0UL; i<min_m; ++i )
1438 for(
size_t j=0UL; j<min_n; ++j )
1439 v[i*nn+j] = v_[i*nn_+j];
1453 for(
size_t i=0UL; i<m; ++i )
1454 for(
size_t j=n; j<nn; ++j )
1455 v_[i*nn+j] = Type();
1479 template<
typename Type
1483 resize(
m_+m,
n_+n, preserve );
1497 template<
typename Type
1510 for(
size_t i=
capacity_; i<elements; ++i )
1528 template<
typename Type
1545 template<
typename Type
1547 template<
typename Other >
1550 for(
size_t i=0UL; i<
m_; ++i )
1551 for(
size_t j=0UL; j<
n_; ++j )
1552 v_[i*nn_+j] *= scalar;
1566 template<
typename Type
1585 template<
typename Type
1590 return minColumns + ( IT::size - ( minColumns % IT::size ) ) % IT::size;
1591 else return minColumns;
1614 template<
typename Type
1616 template<
typename Other >
1619 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1634 template<
typename Type
1636 template<
typename Other >
1639 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1653 template<
typename Type
1672 template<
typename Type
1696 template<
typename Type
1710 return load( v_+i*nn_+j );
1730 template<
typename Type
1743 return loadu( v_+i*nn_+j );
1764 template<
typename Type
1777 store( v_+i*nn_+j, value );
1798 template<
typename Type
1810 storeu( v_+i*nn_+j, value );
1831 template<
typename Type
1844 stream( v_+i*nn_+j, value );
1860 template<
typename Type
1862 template<
typename MT >
1869 const size_t jend(
n_ &
size_t(-2) );
1872 for(
size_t i=0UL; i<
m_; ++i ) {
1873 for(
size_t j=0UL; j<jend; j+=2UL ) {
1874 v_[i*nn_+j ] = (~rhs)(i,j );
1875 v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1878 v_[i*nn_+jend] = (~rhs)(i,jend);
1896 template<
typename Type
1898 template<
typename MT >
1912 for(
size_t i=0UL; i<
m_; ++i )
1913 for(
size_t j=0UL; j<
n_; j+=IT::size )
1918 const size_t jend(
n_ &
size_t(-IT::size*4) );
1921 for(
size_t i=0UL; i<
m_; ++i ) {
1923 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1924 store( v_+i*nn_+j , it.load() ); it += IT::size;
1925 store( v_+i*nn_+j+IT::size , it.load() ); it += IT::size;
1926 store( v_+i*nn_+j+IT::size*2UL, it.load() ); it += IT::size;
1927 store( v_+i*nn_+j+IT::size*3UL, it.load() ); it += IT::size;
1929 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
1930 store( v_+i*nn_+j, it.load() );
1949 template<
typename Type
1951 template<
typename MT >
1957 const size_t block( 16UL );
1959 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
1960 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
1961 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
1962 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
1963 for(
size_t i=ii; i<iend; ++i ) {
1964 for(
size_t j=jj; j<jend; ++j ) {
1965 v_[i*nn_+j] = (~rhs)(i,j);
1985 template<
typename Type
1987 template<
typename MT >
1993 for(
size_t i=0UL; i<
m_; ++i )
1994 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
1995 v_[i*nn_+element->index()] = element->value();
2011 template<
typename Type
2013 template<
typename MT >
2019 for(
size_t j=0UL; j<
n_; ++j )
2020 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2021 v_[element->index()*nn_+j] = element->value();
2037 template<
typename Type
2039 template<
typename MT >
2046 const size_t jend(
n_ &
size_t(-2) );
2049 for(
size_t i=0UL; i<
m_; ++i ) {
2050 for(
size_t j=0UL; j<jend; j+=2UL ) {
2051 v_[i*nn_+j ] += (~rhs)(i,j );
2052 v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2055 v_[i*nn_+jend] += (~rhs)(i,jend);
2073 template<
typename Type
2075 template<
typename MT >
2087 const size_t jend(
n_ &
size_t(-IT::size*4) );
2090 for(
size_t i=0UL; i<
m_; ++i ) {
2092 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2093 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) + it.load() ); it += IT::size;
2094 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) + it.load() ); it += IT::size;
2095 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) + it.load() ); it += IT::size;
2096 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) + it.load() ); it += IT::size;
2098 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2099 store( v_+i*nn_+j,
load( v_+i*nn_+j ) + it.load() );
2117 template<
typename Type
2119 template<
typename MT >
2125 const size_t block( 16UL );
2127 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2128 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2129 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2130 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2131 for(
size_t i=ii; i<iend; ++i ) {
2132 for(
size_t j=jj; j<jend; ++j ) {
2133 v_[i*nn_+j] += (~rhs)(i,j);
2153 template<
typename Type
2155 template<
typename MT >
2161 for(
size_t i=0UL; i<
m_; ++i )
2162 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2163 v_[i*nn_+element->index()] += element->value();
2179 template<
typename Type
2181 template<
typename MT >
2187 for(
size_t j=0UL; j<
n_; ++j )
2188 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2189 v_[element->index()*nn_+j] += element->value();
2205 template<
typename Type
2207 template<
typename MT >
2214 const size_t jend(
n_ &
size_t(-2) );
2217 for(
size_t i=0UL; i<
m_; ++i ) {
2218 for(
size_t j=0UL; j<jend; j+=2UL ) {
2219 v_[i*nn_+j ] -= (~rhs)(i,j );
2220 v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2223 v_[i*nn_+jend] -= (~rhs)(i,jend);
2241 template<
typename Type
2243 template<
typename MT >
2255 const size_t jend(
n_ &
size_t(-IT::size*4) );
2258 for(
size_t i=0UL; i<
m_; ++i ) {
2260 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2261 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) - it.load() ); it += IT::size;
2262 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) - it.load() ); it += IT::size;
2263 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) - it.load() ); it += IT::size;
2264 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) - it.load() ); it += IT::size;
2266 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2267 store( v_+i*nn_+j,
load( v_+i*nn_+j ) - it.load() );
2285 template<
typename Type
2287 template<
typename MT >
2293 const size_t block( 16UL );
2295 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2296 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2297 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2298 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2299 for(
size_t i=ii; i<iend; ++i ) {
2300 for(
size_t j=jj; j<jend; ++j ) {
2301 v_[i*nn_+j] -= (~rhs)(i,j);
2321 template<
typename Type
2323 template<
typename MT >
2329 for(
size_t i=0UL; i<
m_; ++i )
2330 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2331 v_[i*nn_+element->index()] -= element->value();
2347 template<
typename Type
2349 template<
typename MT >
2355 for(
size_t j=0UL; j<
n_; ++j )
2356 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2357 v_[element->index()*nn_+j] -= element->value();
2382 template<
typename Type >
2420 enum { smpAssignable = !IsSMPAssignable<Type>::value };
2428 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
2429 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
2431 template<
typename Other,
size_t M,
size_t N >
2432 explicit inline DynamicMatrix(
const Other (&array)[M][N] );
2435 template<
typename MT,
bool SO >
inline DynamicMatrix(
const Matrix<MT,SO>& m );
2467 template<
typename Other,
size_t M,
size_t N >
2468 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
2472 template<
typename MT,
bool SO >
inline DynamicMatrix& operator= (
const Matrix<MT,SO>& rhs );
2473 template<
typename MT,
bool SO >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2474 template<
typename MT,
bool SO >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2475 template<
typename MT,
bool SO >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2477 template<
typename Other >
2478 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2479 operator*=( Other rhs );
2481 template<
typename Other >
2482 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2483 operator/=( Other rhs );
2490 inline size_t rows()
const;
2491 inline size_t columns()
const;
2492 inline size_t spacing()
const;
2494 inline size_t capacity(
size_t j )
const;
2496 inline size_t nonZeros(
size_t j )
const;
2497 inline void reset();
2498 inline void reset(
size_t j );
2499 inline void clear();
2500 void resize (
size_t m,
size_t n,
bool preserve=
true );
2501 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2502 inline void reserve(
size_t elements );
2504 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
2512 template<
typename MT >
2513 struct VectorizedAssign {
2514 enum { value = vectorizable && MT::vectorizable &&
2515 IsSame<Type,typename MT::ElementType>::value };
2521 template<
typename MT >
2522 struct VectorizedAddAssign {
2523 enum { value = vectorizable && MT::vectorizable &&
2524 IsSame<Type,typename MT::ElementType>::value &&
2525 IntrinsicTrait<Type>::addition };
2531 template<
typename MT >
2532 struct VectorizedSubAssign {
2533 enum { value = vectorizable && MT::vectorizable &&
2534 IsSame<Type,typename MT::ElementType>::value &&
2535 IntrinsicTrait<Type>::subtraction };
2543 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2544 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2555 template<
typename MT >
2556 inline typename DisableIf< VectorizedAssign<MT> >::Type
2557 assign(
const DenseMatrix<MT,true>& rhs );
2559 template<
typename MT >
2560 inline typename EnableIf< VectorizedAssign<MT> >::Type
2561 assign(
const DenseMatrix<MT,true>& rhs );
2563 template<
typename MT >
inline void assign(
const DenseMatrix<MT,false>& rhs );
2564 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2565 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2567 template<
typename MT >
2568 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2569 addAssign(
const DenseMatrix<MT,true>& rhs );
2571 template<
typename MT >
2572 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2573 addAssign(
const DenseMatrix<MT,true>& rhs );
2575 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,false>& rhs );
2576 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2577 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2579 template<
typename MT >
2580 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2581 subAssign (
const DenseMatrix<MT,true>& rhs );
2583 template<
typename MT >
2584 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2585 subAssign (
const DenseMatrix<MT,true>& rhs );
2587 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,false>& rhs );
2588 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2589 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2597 inline size_t adjustRows(
size_t minRows )
const;
2644 template<
typename Type >
2666 template<
typename Type >
2669 , mm_ ( adjustRows( m ) )
2674 if( IsVectorizable<Type>::value ) {
2675 for(
size_t j=0UL; j<
n_; ++j )
2676 for(
size_t i=
m_; i<mm_; ++i ) {
2677 v_[i+j*mm_] = Type();
2695 template<
typename Type >
2698 , mm_ ( adjustRows( m ) )
2703 for(
size_t j=0UL; j<
n_; ++j ) {
2704 for(
size_t i=0UL; i<
m_; ++i )
2707 if( IsVectorizable<Type>::value ) {
2708 for(
size_t i=m_; i<mm_; ++i )
2709 v_[i+j*mm_] = Type();
2741 template<
typename Type >
2742 template<
typename Other >
2745 , mm_ ( adjustRows( m ) )
2750 for(
size_t j=0UL; j<n; ++j ) {
2751 for(
size_t i=0UL; i<m; ++i )
2752 v_[i+j*mm_] = array[i+j*m];
2754 if( IsVectorizable<Type>::value ) {
2755 for(
size_t i=m; i<mm_; ++i )
2756 v_[i+j*mm_] = Type();
2786 template<
typename Type >
2787 template<
typename Other
2792 , mm_ ( adjustRows( M ) )
2797 for(
size_t j=0UL; j<N; ++j ) {
2798 for(
size_t i=0UL; i<M; ++i )
2799 v_[i+j*mm_] = array[i][j];
2801 if( IsVectorizable<Type>::value ) {
2802 for(
size_t i=M; i<mm_; ++i )
2803 v_[i+j*mm_] = Type();
2820 template<
typename Type >
2843 template<
typename Type >
2844 template<
typename MT
2847 : m_ ( (~m).
rows() )
2848 , mm_ ( adjustRows( m_ ) )
2853 for(
size_t j=0UL; j<
n_; ++j ) {
2854 for(
size_t i=( IsSparseMatrix<MT>::value ? 0UL : m_ );
2855 i<( IsVectorizable<Type>::value ? mm_ :
m_ ); ++i ) {
2856 v_[i+j*mm_] = Type();
2878 template<
typename Type >
2903 template<
typename Type >
2923 template<
typename Type >
2947 template<
typename Type >
2968 template<
typename Type >
2986 template<
typename Type >
3005 template<
typename Type >
3022 template<
typename Type >
3040 template<
typename Type >
3058 template<
typename Type >
3076 template<
typename Type >
3081 return Iterator( v_ + j*mm_ + m_ );
3094 template<
typename Type >
3112 template<
typename Type >
3153 template<
typename Type >
3154 template<
typename Other
3157 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Other (&array)[M][N] )
3159 resize( M, N,
false );
3161 for(
size_t j=0UL; j<N; ++j )
3162 for(
size_t i=0UL; i<M; ++i )
3163 v_[i+j*mm_] = array[i][j];
3178 template<
typename Type >
3179 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3181 for(
size_t j=0UL; j<
n_; ++j )
3182 for(
size_t i=0UL; i<
m_; ++i )
3201 template<
typename Type >
3202 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const DynamicMatrix& rhs )
3204 if( &rhs ==
this )
return *
this;
3206 resize( rhs.m_, rhs.n_,
false );
3225 template<
typename Type >
3226 template<
typename MT
3228 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Matrix<MT,SO>& rhs )
3230 if( (~rhs).canAlias(
this ) ) {
3231 DynamicMatrix tmp( ~rhs );
3236 if( IsSparseMatrix<MT>::value )
3258 template<
typename Type >
3259 template<
typename MT
3261 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3263 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3264 throw std::invalid_argument(
"Matrix sizes do not match" );
3266 if( (~rhs).canAlias(
this ) ) {
3291 template<
typename Type >
3292 template<
typename MT
3294 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3296 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3297 throw std::invalid_argument(
"Matrix sizes do not match" );
3299 if( (~rhs).canAlias(
this ) ) {
3324 template<
typename Type >
3325 template<
typename MT
3327 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3329 if( (~rhs).
rows() != n_ )
3330 throw std::invalid_argument(
"Matrix sizes do not match" );
3332 DynamicMatrix tmp( *
this * (~rhs) );
3349 template<
typename Type >
3350 template<
typename Other >
3351 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3352 DynamicMatrix<Type,true>::operator*=( Other rhs )
3369 template<
typename Type >
3370 template<
typename Other >
3371 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3372 DynamicMatrix<Type,true>::operator/=( Other rhs )
3397 template<
typename Type >
3412 template<
typename Type >
3430 template<
typename Type >
3445 template<
typename Type >
3461 template<
typename Type >
3478 template<
typename Type >
3481 size_t nonzeros( 0UL );
3483 for(
size_t j=0UL; j<
n_; ++j )
3484 for(
size_t i=0UL; i<
m_; ++i )
3501 template<
typename Type >
3506 const size_t iend( (j+1UL)*mm_ );
3507 size_t nonzeros( 0UL );
3509 for(
size_t i=j*mm_; i<iend; ++i )
3525 template<
typename Type >
3530 for(
size_t j=0UL; j<
n_; ++j )
3531 for(
size_t i=0UL; i<
m_; ++i )
3532 reset( v_[i+j*mm_] );
3548 template<
typename Type >
3554 for(
size_t i=0UL; i<
m_; ++i )
3555 reset( v_[i+j*mm_] );
3569 template<
typename Type >
3572 resize( 0UL, 0UL,
false );
3613 template<
typename Type >
3618 if( m == m_ && n == n_ )
return;
3620 const size_t mm( adjustRows( m ) );
3625 const size_t min_m( min( m, m_ ) );
3626 const size_t min_n( min( n, n_ ) );
3628 for(
size_t j=0UL; j<min_n; ++j )
3629 for(
size_t i=0UL; i<min_m; ++i )
3630 v[i+j*mm] = v_[i+j*mm_];
3643 if( IsVectorizable<Type>::value ) {
3644 for(
size_t j=0UL; j<n; ++j )
3645 for(
size_t i=m; i<mm; ++i )
3646 v_[i+j*mm] = Type();
3672 template<
typename Type >
3675 resize( m_+m, n_+n, preserve );
3691 template<
typename Type >
3702 if( IsVectorizable<Type>::value ) {
3703 for(
size_t i=
capacity_; i<elements; ++i )
3723 template<
typename Type >
3726 DynamicMatrix tmp(
trans(*
this) );
3741 template<
typename Type >
3742 template<
typename Other >
3743 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( Other scalar )
3745 for(
size_t j=0UL; j<
n_; ++j )
3746 for(
size_t i=0UL; i<
m_; ++i )
3747 v_[i+j*mm_] *= scalar;
3763 template<
typename Type >
3783 template<
typename Type >
3784 inline size_t DynamicMatrix<Type,true>::adjustRows(
size_t minRows )
const
3786 if( IsVectorizable<Type>::value )
3787 return minRows + ( IT::size - ( minRows % IT::size ) ) % IT::size;
3788 else return minRows;
3813 template<
typename Type >
3814 template<
typename Other >
3817 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3834 template<
typename Type >
3835 template<
typename Other >
3838 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3854 template<
typename Type >
3874 template<
typename Type >
3898 template<
typename Type >
3899 inline typename DynamicMatrix<Type,true>::IntrinsicType
3911 return load( v_+i+j*mm_ );
3932 template<
typename Type >
3933 inline typename DynamicMatrix<Type,true>::IntrinsicType
3944 return loadu( v_+i+j*mm_ );
3966 template<
typename Type >
3978 store( v_+i+j*mm_, value );
4000 template<
typename Type >
4011 storeu( v_+i+j*mm_, value );
4034 template<
typename Type >
4046 stream( v_+i+j*mm_, value );
4064 template<
typename Type >
4065 template<
typename MT >
4066 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4072 const size_t iend( m_ &
size_t(-2) );
4075 for(
size_t j=0UL; j<
n_; ++j ) {
4076 for(
size_t i=0UL; i<iend; i+=2UL ) {
4077 v_[i +j*mm_] = (~rhs)(i ,j);
4078 v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
4081 v_[iend+j*mm_] = (~rhs)(iend,j);
4101 template<
typename Type >
4102 template<
typename MT >
4103 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4116 for(
size_t j=0UL; j<
n_; ++j )
4117 for(
size_t i=0UL; i<
m_; i+=IT::size )
4122 const size_t iend( m_ &
size_t(-IT::size*4) );
4125 for(
size_t j=0UL; j<
n_; ++j ) {
4127 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4128 store( v_+i+j*mm_ , it.load() ); it += IT::size;
4129 store( v_+i+j*mm_+IT::size , it.load() ); it += IT::size;
4130 store( v_+i+j*mm_+IT::size*2UL, it.load() ); it += IT::size;
4131 store( v_+i+j*mm_+IT::size*3UL, it.load() ); it += IT::size;
4133 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4134 store( v_+i+j*mm_, it.load() );
4155 template<
typename Type >
4156 template<
typename MT >
4162 const size_t block( 16UL );
4164 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4165 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4166 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4167 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4168 for(
size_t j=jj; j<jend; ++j ) {
4169 for(
size_t i=ii; i<iend; ++i ) {
4170 v_[i+j*mm_] = (~rhs)(i,j);
4192 template<
typename Type >
4193 template<
typename MT >
4196 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4197 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4198 v_[element->index()+j*mm_] = element->value();
4216 template<
typename Type >
4217 template<
typename MT >
4220 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4221 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4222 v_[i+element->index()*mm_] = element->value();
4240 template<
typename Type >
4241 template<
typename MT >
4242 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4248 const size_t iend( m_ &
size_t(-2) );
4251 for(
size_t j=0UL; j<
n_; ++j ) {
4252 for(
size_t i=0UL; i<iend; i+=2UL ) {
4253 v_[i +j*mm_] += (~rhs)(i ,j);
4254 v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4257 v_[iend+j*mm_] += (~rhs)(iend,j);
4277 template<
typename Type >
4278 template<
typename MT >
4279 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4290 const size_t iend( m_ &
size_t(-IT::size*4) );
4293 for(
size_t j=0UL; j<
n_; ++j ) {
4295 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4296 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) + it.load() ); it += IT::size;
4297 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) + it.load() ); it += IT::size;
4298 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) + it.load() ); it += IT::size;
4299 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) + it.load() ); it += IT::size;
4301 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4302 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) + it.load() );
4322 template<
typename Type >
4323 template<
typename MT >
4329 const size_t block( 16UL );
4331 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4332 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4333 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4334 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4335 for(
size_t j=jj; j<jend; ++j ) {
4336 for(
size_t i=ii; i<iend; ++i ) {
4337 v_[i+j*mm_] += (~rhs)(i,j);
4359 template<
typename Type >
4360 template<
typename MT >
4363 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4364 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4365 v_[element->index()+j*mm_] += element->value();
4383 template<
typename Type >
4384 template<
typename MT >
4387 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4388 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4389 v_[i+element->index()*mm_] += element->value();
4407 template<
typename Type >
4408 template<
typename MT >
4409 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4415 const size_t iend( m_ &
size_t(-2) );
4418 for(
size_t j=0UL; j<
n_; ++j ) {
4419 for(
size_t i=0UL; i<iend; i+=2UL ) {
4420 v_[i +j*mm_] -= (~rhs)(i ,j);
4421 v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4424 v_[iend+j*mm_] -= (~rhs)(iend,j);
4445 template<
typename Type >
4446 template<
typename MT >
4447 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4458 const size_t iend( m_ &
size_t(-IT::size*4) );
4461 for(
size_t j=0UL; j<
n_; ++j ) {
4463 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4464 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) - it.load() ); it += IT::size;
4465 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) - it.load() ); it += IT::size;
4466 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) - it.load() ); it += IT::size;
4467 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) - it.load() ); it += IT::size;
4469 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4470 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) - it.load() );
4490 template<
typename Type >
4491 template<
typename MT >
4494 const size_t block( 16UL );
4496 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4497 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4498 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4499 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4500 for(
size_t j=jj; j<jend; ++j ) {
4501 for(
size_t i=ii; i<iend; ++i ) {
4502 v_[i+j*mm_] -= (~rhs)(i,j);
4524 template<
typename Type >
4525 template<
typename MT >
4528 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4529 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4530 v_[element->index()+j*mm_] -= element->value();
4548 template<
typename Type >
4549 template<
typename MT >
4552 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4553 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4554 v_[i+element->index()*mm_] -= element->value();
4575 template<
typename Type,
bool SO >
4576 inline void reset( DynamicMatrix<Type,SO>& m );
4578 template<
typename Type,
bool SO >
4579 inline void clear( DynamicMatrix<Type,SO>& m );
4581 template<
typename Type,
bool SO >
4582 inline bool isDefault(
const DynamicMatrix<Type,SO>& m );
4584 template<
typename Type,
bool SO >
4585 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) ;
4597 template<
typename Type
4613 template<
typename Type
4640 template<
typename Type
4645 for(
size_t i=0UL; i<m.
rows(); ++i )
4646 for(
size_t j=0UL; j<m.
columns(); ++j )
4647 if( !
isDefault( m(i,j) ) )
return false;
4650 for(
size_t j=0UL; j<m.
columns(); ++j )
4651 for(
size_t i=0UL; i<m.
rows(); ++i )
4652 if( !
isDefault( m(i,j) ) )
return false;
4669 template<
typename Type
4688 template<
typename T,
bool SO >
4689 struct IsResizable< DynamicMatrix<T,SO> > :
public TrueType
4695 template<
typename T,
bool SO >
4696 struct IsResizable< const DynamicMatrix<T,SO> > :
public TrueType
4702 template<
typename T,
bool SO >
4703 struct IsResizable< volatile DynamicMatrix<T,SO> > :
public TrueType
4709 template<
typename T,
bool SO >
4710 struct IsResizable< const volatile DynamicMatrix<T,SO> > :
public TrueType
4729 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4730 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4732 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4735 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4736 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4738 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4741 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4742 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4744 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4747 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4748 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4750 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4753 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4754 struct AddTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4756 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4759 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4760 struct AddTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4762 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4765 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4766 struct AddTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4768 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4771 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4772 struct AddTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4774 typedef HybridMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4777 template<
typename T1,
bool SO,
typename T2 >
4778 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4780 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4783 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4784 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4786 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4802 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4803 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4805 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4808 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4809 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4811 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4814 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4815 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4817 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4820 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4821 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4823 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4826 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4827 struct SubTrait< DynamicMatrix<T1,SO>, HybridMatrix<T2,M,N,SO> >
4829 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4832 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4833 struct SubTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4835 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4838 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4839 struct SubTrait< HybridMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4841 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4844 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4845 struct SubTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4847 typedef HybridMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4850 template<
typename T1,
bool SO,
typename T2 >
4851 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4853 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4856 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4857 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4859 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4875 template<
typename T1,
bool SO,
typename T2 >
4876 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
4878 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4882 template<
typename T1,
typename T2,
bool SO >
4883 struct MultTrait< T1, DynamicMatrix<T2,SO> >
4885 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4889 template<
typename T1,
bool SO,
typename T2,
size_t N >
4890 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
4892 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4895 template<
typename T1,
size_t N,
typename T2,
bool SO >
4896 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
4898 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4901 template<
typename T1,
bool SO,
typename T2,
size_t N >
4902 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
4904 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4907 template<
typename T1,
size_t N,
typename T2,
bool SO >
4908 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
4910 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4913 template<
typename T1,
bool SO,
typename T2 >
4914 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
4916 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4919 template<
typename T1,
typename T2,
bool SO >
4920 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
4922 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4925 template<
typename T1,
bool SO,
typename T2 >
4926 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
4928 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4931 template<
typename T1,
typename T2,
bool SO >
4932 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
4934 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4937 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4938 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4940 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4943 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4944 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4946 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4949 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4950 struct MultTrait< DynamicMatrix<T1,SO1>, HybridMatrix<T2,M,N,SO2> >
4952 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4955 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4956 struct MultTrait< HybridMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4958 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4961 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4962 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4964 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4980 template<
typename T1,
bool SO,
typename T2 >
4981 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
4983 typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
5000 template<
typename T1,
bool SO,
typename T2 >
5001 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
5003 typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
5004 typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
5020 template<
typename T1,
bool SO >
5021 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
5023 typedef DynamicMatrix<T1,SO> Type;
5039 template<
typename T1,
bool SO >
5040 struct RowTrait< DynamicMatrix<T1,SO> >
5042 typedef DynamicVector<T1,true> Type;
5058 template<
typename T1,
bool SO >
5059 struct ColumnTrait< DynamicMatrix<T1,SO> >
5061 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:699
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:406
Constraint on the data type.
Header file for mathematical functions.
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1499
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4599
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:223
EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:222
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
const bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.This value specifies the default stor...
Definition: StorageOrder.h:56
ConstIterator cbegin(size_t i) const
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:863
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:409
void smpSubAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:152
Header file for the IsSparseMatrix type trait.
bool isDefault(const DynamicMatrix< Type, SO > &m)
Returns whether the given dense matrix is in default state.
Definition: DynamicMatrix.h:4642
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:199
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1423
EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:219
Header file for the IsSame and IsStrictlySame type traits.
size_t columns() const
Returns the current number of columns of the matrix.
Definition: DynamicMatrix.h:1217
const blaze::Null NULL
Global NULL pointer.This instance of the Null class replaces the NULL macro to ensure a type-safe NUL...
Definition: Null.h:300
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:1800
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2555
Header file for a safe C++ NULL pointer implementation.
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:84
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:116
DynamicMatrix()
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:447
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:1236
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:178
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4615
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:70
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:2557
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:674
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:188
Header file for the SparseMatrix base class.
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:115
size_t nonZeros() const
Returns the total number of non-zero elements in the matrix.
Definition: DynamicMatrix.h:1286
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1587
void smpAddAssign(DenseMatrix< 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:122
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:929
Header file for the multiplication trait.
bool isAligned() const
Returns whether the matrix is properly aligned in memory.
Definition: DynamicMatrix.h:1655
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1733
Header file for nested template disabiguation.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two sparse matrices.
Definition: CompressedMatrix.h:4605
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:2412
#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
Header file for the DenseMatrix base class.
Header file for the DenseIterator class template.
const size_t SMP_DMATASSIGN_THRESHOLD
SMP dense matrix assignment threshold.This threshold specifies when an assignment with a plain dense ...
Definition: Thresholds.h:690
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:193
void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:271
Constraint on the data type.
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1481
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1203
#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:1336
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:885
Compile time check for data types.This type trait tests whether or not the given template parameter i...
Definition: IsSMPAssignable.h:120
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2410
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:216
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:1250
Header file for the equal shim.
Header file for the IsVectorizable type trait.
void smpAssign(DenseMatrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:92
Header file for the IsNumeric type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:407
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1766
Type * Pointer
Pointer to a non-constant matrix value.
Definition: DynamicMatrix.h:197
EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:218
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:748
Header file for run time assertion macros.
Header file for the addition trait.
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1380
const Type * ConstPointer
Pointer to a constant matrix value.
Definition: DynamicMatrix.h:198
Header file for the division trait.
void swap(DynamicMatrix< Type, SO > &a, DynamicMatrix< Type, SO > &b)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:4671
void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:301
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:405
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:819
Header file for the reset shim.
bool isAliased(const Other *alias) const
Returns whether the matrix is aliased with the given address alias.
Definition: DynamicMatrix.h:1637
Header file for the cache size of the target architecture.
void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:331
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2411
Header file for the column trait.
Header file for the isDefault shim.
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
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1568
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1699
T * allocate(size_t size)
Aligned array allocation.
Definition: Memory.h:84
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:1674
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2556
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:907
const bool rowMajor
Storage order flag for row-major matrices.
Definition: StorageOrder.h:71
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:408
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2403
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:170
Header file for basic type definitions.
Compile time check for sparse matrix types.This type trait tests whether or not the given template pa...
Definition: IsSparseMatrix.h:103
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:2409
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:351
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
Pointer data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:741
Header file for the IsResizable type trait.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:154
#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:1617
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1530
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:196
EnableIf< IsIntegral< T >, Set< T, sizeof(T)> >::Type::Type set(T value)
Sets all values in the vector to the given integral value.
Definition: Set.h:209
DynamicMatrix< Type,!SO > TransposeType
Transpose type for expression template evaluations.
Definition: DynamicMatrix.h:190
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:1833