35 #ifndef _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
36 #define _BLAZE_MATH_DENSE_DYNAMICMATRIX_H_
174 template<
typename Type
213 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
214 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
216 template<
typename Other,
size_t M,
size_t N >
236 inline Type*
data ();
237 inline const Type*
data ()
const;
238 inline Type*
data (
size_t i );
239 inline const Type*
data (
size_t i )
const;
252 template<
typename Other,
size_t M,
size_t N >
253 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
262 template<
typename Other >
264 operator*=( Other rhs );
266 template<
typename Other >
268 operator/=( Other rhs );
275 inline size_t rows()
const;
279 inline size_t capacity(
size_t i )
const;
281 inline size_t nonZeros(
size_t i )
const;
283 inline void reset(
size_t i );
285 void resize (
size_t m,
size_t n,
bool preserve=
true );
286 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
287 inline void reserve(
size_t elements );
289 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
297 template<
typename MT >
299 struct VectorizedAssign {
300 enum { value = vectorizable && MT::vectorizable &&
308 template<
typename MT >
310 struct VectorizedAddAssign {
311 enum { value = vectorizable && MT::vectorizable &&
312 IsSame<Type,typename MT::ElementType>::value &&
313 IntrinsicTrait<Type>::addition };
320 template<
typename MT >
322 struct VectorizedSubAssign {
323 enum { value = vectorizable && MT::vectorizable &&
324 IsSame<Type,typename MT::ElementType>::value &&
325 IntrinsicTrait<Type>::subtraction };
334 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
335 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
343 template<
typename MT >
344 inline typename DisableIf< VectorizedAssign<MT> >::Type
345 assign(
const DenseMatrix<MT,SO>& rhs );
347 template<
typename MT >
348 inline typename EnableIf< VectorizedAssign<MT> >::Type
349 assign(
const DenseMatrix<MT,SO>& rhs );
351 template<
typename MT >
inline void assign(
const DenseMatrix<MT,!SO>& rhs );
352 template<
typename MT >
inline void assign(
const SparseMatrix<MT,SO>& rhs );
353 template<
typename MT >
inline void assign(
const SparseMatrix<MT,!SO>& rhs );
355 template<
typename MT >
356 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
357 addAssign(
const DenseMatrix<MT,SO>& rhs );
359 template<
typename MT >
360 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
361 addAssign(
const DenseMatrix<MT,SO>& rhs );
363 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,!SO>& rhs );
364 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,SO>& rhs );
365 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,!SO>& rhs );
367 template<
typename MT >
368 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
369 subAssign(
const DenseMatrix<MT,SO>& rhs );
371 template<
typename MT >
372 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
373 subAssign(
const DenseMatrix<MT,SO>& rhs );
375 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,!SO>& rhs );
376 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,SO>& rhs );
377 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,!SO>& rhs );
432 template<
typename Type
453 template<
typename Type
458 , nn_ ( adjustColumns( n ) )
463 for(
size_t i=0UL; i<
m_; ++i ) {
464 for(
size_t j=
n_; j<
nn_; ++j )
465 v_[i*nn_+j] = Type();
481 template<
typename Type
486 , nn_ ( adjustColumns( n ) )
490 for(
size_t i=0UL; i<m; ++i ) {
491 for(
size_t j=0UL; j<
n_; ++j )
495 for(
size_t j=n_; j<
nn_; ++j )
496 v_[i*nn_+j] = Type();
526 template<
typename Type
528 template<
typename Other >
532 , nn_ ( adjustColumns( n ) )
536 for(
size_t i=0UL; i<m; ++i ) {
537 for(
size_t j=0UL; j<n; ++j )
538 v_[i*
nn_+j] = array[i*n+j];
541 for(
size_t j=n; j<
nn_; ++j )
542 v_[i*nn_+j] = Type();
570 template<
typename Type
572 template<
typename Other
578 , nn_ ( adjustColumns( N ) )
582 for(
size_t i=0UL; i<M; ++i ) {
583 for(
size_t j=0UL; j<N; ++j )
584 v_[i*
nn_+j] = array[i][j];
587 for(
size_t j=N; j<
nn_; ++j )
588 v_[i*nn_+j] = Type();
603 template<
typename Type
625 template<
typename Type
627 template<
typename MT
632 , nn_ ( adjustColumns(
n_ ) )
639 for(
size_t i=0UL; i<
m_; ++i ) {
641 v_[i*nn_+j] = Type();
661 template<
typename Type
685 template<
typename Type
704 template<
typename Type
725 template<
typename Type
743 template<
typename Type
760 template<
typename Type
778 template<
typename Type
799 template<
typename Type
821 template<
typename Type
843 template<
typename Type
865 template<
typename Type
887 template<
typename Type
909 template<
typename Type
949 template<
typename Type
951 template<
typename Other
956 resize( M, N,
false );
958 for(
size_t i=0UL; i<M; ++i )
959 for(
size_t j=0UL; j<N; ++j )
960 v_[i*nn_+j] = array[i][j];
973 template<
typename Type
977 for(
size_t i=0UL; i<
m_; ++i )
978 for(
size_t j=0UL; j<
n_; ++j )
995 template<
typename Type
999 if( &rhs ==
this )
return *
this;
1001 resize( rhs.
m_, rhs.
n_,
false );
1003 for(
size_t i=0UL; i<
m_; ++i )
1004 for(
size_t j=0UL; j<
n_; ++j )
1005 v_[i*nn_+j] = rhs(i,j);
1021 template<
typename Type
1023 template<
typename MT
1029 if( (~rhs).canAlias(
this ) ) {
1055 template<
typename Type
1057 template<
typename MT
1064 throw std::invalid_argument(
"Matrix sizes do not match" );
1066 if( (~rhs).canAlias(
this ) ) {
1089 template<
typename Type
1091 template<
typename MT
1098 throw std::invalid_argument(
"Matrix sizes do not match" );
1100 if( (~rhs).canAlias(
this ) ) {
1123 template<
typename Type
1125 template<
typename MT
1129 if( (~rhs).
rows() !=
n_ )
1130 throw std::invalid_argument(
"Matrix sizes do not match" );
1147 template<
typename Type
1149 template<
typename Other >
1155 assign( *
this, (*
this) * rhs );
1168 template<
typename Type
1170 template<
typename Other >
1178 assign( *
this, (*
this) / rhs );
1197 template<
typename Type
1211 template<
typename Type
1230 template<
typename Type
1244 template<
typename Type
1264 template<
typename Type
1280 template<
typename Type
1284 size_t nonzeros( 0UL );
1286 for(
size_t i=0UL; i<
m_; ++i )
1287 for(
size_t j=0UL; j<
n_; ++j )
1302 template<
typename Type
1308 const size_t jend( (i+1UL)*nn_ );
1309 size_t nonzeros( 0UL );
1311 for(
size_t j=i*nn_; j<jend; ++j )
1325 template<
typename Type
1331 for(
size_t i=0UL; i<
m_; ++i )
1332 for(
size_t j=0UL; j<
n_; ++j )
1333 reset( v_[i*nn_+j] );
1349 template<
typename Type
1356 for(
size_t j=0UL; j<
n_; ++j )
1357 reset( v_[i*nn_+j] );
1369 template<
typename Type
1373 resize( 0UL, 0UL,
false );
1411 template<
typename Type
1417 if( m ==
m_ && n ==
n_ )
return;
1419 const size_t nn( adjustColumns( n ) );
1424 const size_t min_m( min( m,
m_ ) );
1425 const size_t min_n( min( n,
n_ ) );
1427 for(
size_t i=0UL; i<min_m; ++i )
1428 for(
size_t j=0UL; j<min_n; ++j )
1429 v[i*nn+j] = v_[i*nn_+j];
1443 for(
size_t i=0UL; i<m; ++i )
1444 for(
size_t j=n; j<nn; ++j )
1445 v_[i*nn+j] = Type();
1469 template<
typename Type
1473 resize(
m_+m,
n_+n, preserve );
1487 template<
typename Type
1500 for(
size_t i=
capacity_; i<elements; ++i )
1518 template<
typename Type
1535 template<
typename Type
1537 template<
typename Other >
1540 for(
size_t i=0UL; i<
m_; ++i )
1541 for(
size_t j=0UL; j<
n_; ++j )
1542 v_[i*nn_+j] *= scalar;
1556 template<
typename Type
1575 template<
typename Type
1580 return minColumns + ( IT::size - ( minColumns % IT::size ) ) % IT::size;
1581 else return minColumns;
1604 template<
typename Type
1606 template<
typename Other >
1609 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1624 template<
typename Type
1626 template<
typename Other >
1629 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
1649 template<
typename Type
1663 return load( v_+i*nn_+j );
1683 template<
typename Type
1696 return loadu( v_+i*nn_+j );
1717 template<
typename Type
1730 store( v_+i*nn_+j, value );
1751 template<
typename Type
1763 storeu( v_+i*nn_+j, value );
1784 template<
typename Type
1797 stream( v_+i*nn_+j, value );
1813 template<
typename Type
1815 template<
typename MT >
1822 const size_t jend(
n_ &
size_t(-2) );
1825 for(
size_t i=0UL; i<
m_; ++i ) {
1826 for(
size_t j=0UL; j<jend; j+=2UL ) {
1827 v_[i*nn_+j ] = (~rhs)(i,j );
1828 v_[i*nn_+j+1UL] = (~rhs)(i,j+1UL);
1831 v_[i*nn_+jend] = (~rhs)(i,jend);
1849 template<
typename Type
1851 template<
typename MT >
1865 for(
size_t i=0UL; i<
m_; ++i )
1866 for(
size_t j=0UL; j<
n_; j+=IT::size )
1871 const size_t jend(
n_ &
size_t(-IT::size*4) );
1874 for(
size_t i=0UL; i<
m_; ++i ) {
1876 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
1877 store( v_+i*nn_+j , it.load() ); it += IT::size;
1878 store( v_+i*nn_+j+IT::size , it.load() ); it += IT::size;
1879 store( v_+i*nn_+j+IT::size*2UL, it.load() ); it += IT::size;
1880 store( v_+i*nn_+j+IT::size*3UL, it.load() ); it += IT::size;
1882 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
1883 store( v_+i*nn_+j, it.load() );
1902 template<
typename Type
1904 template<
typename MT >
1910 const size_t block( 16UL );
1912 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
1913 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
1914 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
1915 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
1916 for(
size_t i=ii; i<iend; ++i ) {
1917 for(
size_t j=jj; j<jend; ++j ) {
1918 v_[i*nn_+j] = (~rhs)(i,j);
1938 template<
typename Type
1940 template<
typename MT >
1946 for(
size_t i=0UL; i<
m_; ++i )
1947 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
1948 v_[i*nn_+element->index()] = element->value();
1964 template<
typename Type
1966 template<
typename MT >
1972 for(
size_t j=0UL; j<
n_; ++j )
1973 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
1974 v_[element->index()*nn_+j] = element->value();
1990 template<
typename Type
1992 template<
typename MT >
1999 const size_t jend(
n_ &
size_t(-2) );
2002 for(
size_t i=0UL; i<
m_; ++i ) {
2003 for(
size_t j=0UL; j<jend; j+=2UL ) {
2004 v_[i*nn_+j ] += (~rhs)(i,j );
2005 v_[i*nn_+j+1UL] += (~rhs)(i,j+1UL);
2008 v_[i*nn_+jend] += (~rhs)(i,jend);
2026 template<
typename Type
2028 template<
typename MT >
2040 const size_t jend(
n_ &
size_t(-IT::size*4) );
2043 for(
size_t i=0UL; i<
m_; ++i ) {
2045 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2046 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) + it.load() ); it += IT::size;
2047 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) + it.load() ); it += IT::size;
2048 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) + it.load() ); it += IT::size;
2049 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) + it.load() ); it += IT::size;
2051 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2052 store( v_+i*nn_+j,
load( v_+i*nn_+j ) + it.load() );
2070 template<
typename Type
2072 template<
typename MT >
2078 const size_t block( 16UL );
2080 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2081 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2082 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2083 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2084 for(
size_t i=ii; i<iend; ++i ) {
2085 for(
size_t j=jj; j<jend; ++j ) {
2086 v_[i*nn_+j] += (~rhs)(i,j);
2106 template<
typename Type
2108 template<
typename MT >
2114 for(
size_t i=0UL; i<
m_; ++i )
2115 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2116 v_[i*nn_+element->index()] += element->value();
2132 template<
typename Type
2134 template<
typename MT >
2140 for(
size_t j=0UL; j<
n_; ++j )
2141 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2142 v_[element->index()*nn_+j] += element->value();
2158 template<
typename Type
2160 template<
typename MT >
2167 const size_t jend(
n_ &
size_t(-2) );
2170 for(
size_t i=0UL; i<
m_; ++i ) {
2171 for(
size_t j=0UL; j<jend; j+=2UL ) {
2172 v_[i*nn_+j ] -= (~rhs)(i,j );
2173 v_[i*nn_+j+1UL] -= (~rhs)(i,j+1UL);
2176 v_[i*nn_+jend] -= (~rhs)(i,jend);
2194 template<
typename Type
2196 template<
typename MT >
2208 const size_t jend(
n_ &
size_t(-IT::size*4) );
2211 for(
size_t i=0UL; i<
m_; ++i ) {
2213 for(
size_t j=0UL; j<jend; j+=IT::size*4UL ) {
2214 store( v_+i*nn_+j ,
load( v_+i*nn_+j ) - it.load() ); it += IT::size;
2215 store( v_+i*nn_+j+IT::size ,
load( v_+i*nn_+j+IT::size ) - it.load() ); it += IT::size;
2216 store( v_+i*nn_+j+IT::size*2UL,
load( v_+i*nn_+j+IT::size*2UL ) - it.load() ); it += IT::size;
2217 store( v_+i*nn_+j+IT::size*3UL,
load( v_+i*nn_+j+IT::size*3UL ) - it.load() ); it += IT::size;
2219 for(
size_t j=jend; j<
n_; j+=IT::size, it+=IT::size ) {
2220 store( v_+i*nn_+j,
load( v_+i*nn_+j ) - it.load() );
2238 template<
typename Type
2240 template<
typename MT >
2246 const size_t block( 16UL );
2248 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
2249 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
2250 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
2251 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
2252 for(
size_t i=ii; i<iend; ++i ) {
2253 for(
size_t j=jj; j<jend; ++j ) {
2254 v_[i*nn_+j] -= (~rhs)(i,j);
2274 template<
typename Type
2276 template<
typename MT >
2282 for(
size_t i=0UL; i<
m_; ++i )
2283 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
2284 v_[i*nn_+element->index()] -= element->value();
2300 template<
typename Type
2302 template<
typename MT >
2308 for(
size_t j=0UL; j<
n_; ++j )
2309 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
2310 v_[element->index()*nn_+j] -= element->value();
2335 template<
typename Type >
2373 explicit inline DynamicMatrix(
size_t m,
size_t n,
const Type& init );
2374 template<
typename Other >
explicit inline DynamicMatrix(
size_t m,
size_t n,
const Other* array );
2376 template<
typename Other,
size_t M,
size_t N >
2377 explicit inline DynamicMatrix(
const Other (&array)[M][N] );
2380 template<
typename MT,
bool SO >
inline DynamicMatrix(
const Matrix<MT,SO>& m );
2396 inline Type*
data ();
2397 inline const Type*
data ()
const;
2398 inline Type*
data (
size_t j );
2399 inline const Type*
data (
size_t j )
const;
2412 template<
typename Other,
size_t M,
size_t N >
2413 inline DynamicMatrix& operator=(
const Other (&array)[M][N] );
2417 template<
typename MT,
bool SO >
inline DynamicMatrix& operator= (
const Matrix<MT,SO>& rhs );
2418 template<
typename MT,
bool SO >
inline DynamicMatrix& operator+=(
const Matrix<MT,SO>& rhs );
2419 template<
typename MT,
bool SO >
inline DynamicMatrix& operator-=(
const Matrix<MT,SO>& rhs );
2420 template<
typename MT,
bool SO >
inline DynamicMatrix& operator*=(
const Matrix<MT,SO>& rhs );
2422 template<
typename Other >
2423 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2424 operator*=( Other rhs );
2426 template<
typename Other >
2427 inline typename EnableIf< IsNumeric<Other>,
DynamicMatrix >::Type&
2428 operator/=( Other rhs );
2435 inline size_t rows()
const;
2436 inline size_t columns()
const;
2437 inline size_t spacing()
const;
2439 inline size_t capacity(
size_t j )
const;
2441 inline size_t nonZeros(
size_t j )
const;
2442 inline void reset();
2443 inline void reset(
size_t j );
2444 inline void clear();
2445 void resize (
size_t m,
size_t n,
bool preserve=
true );
2446 inline void extend (
size_t m,
size_t n,
bool preserve=
true );
2447 inline void reserve(
size_t elements );
2449 template<
typename Other >
inline DynamicMatrix& scale( Other scalar );
2457 template<
typename MT >
2458 struct VectorizedAssign {
2459 enum { value = vectorizable && MT::vectorizable &&
2460 IsSame<Type,typename MT::ElementType>::value };
2466 template<
typename MT >
2467 struct VectorizedAddAssign {
2468 enum { value = vectorizable && MT::vectorizable &&
2469 IsSame<Type,typename MT::ElementType>::value &&
2470 IntrinsicTrait<Type>::addition };
2476 template<
typename MT >
2477 struct VectorizedSubAssign {
2478 enum { value = vectorizable && MT::vectorizable &&
2479 IsSame<Type,typename MT::ElementType>::value &&
2480 IntrinsicTrait<Type>::subtraction };
2488 template<
typename Other >
inline bool canAlias (
const Other* alias )
const;
2489 template<
typename Other >
inline bool isAliased(
const Other* alias )
const;
2497 template<
typename MT >
2498 inline typename DisableIf< VectorizedAssign<MT> >::Type
2499 assign(
const DenseMatrix<MT,true>& rhs );
2501 template<
typename MT >
2502 inline typename EnableIf< VectorizedAssign<MT> >::Type
2503 assign(
const DenseMatrix<MT,true>& rhs );
2505 template<
typename MT >
inline void assign(
const DenseMatrix<MT,false>& rhs );
2506 template<
typename MT >
inline void assign(
const SparseMatrix<MT,true>& rhs );
2507 template<
typename MT >
inline void assign(
const SparseMatrix<MT,false>& rhs );
2509 template<
typename MT >
2510 inline typename DisableIf< VectorizedAddAssign<MT> >::Type
2511 addAssign(
const DenseMatrix<MT,true>& rhs );
2513 template<
typename MT >
2514 inline typename EnableIf< VectorizedAddAssign<MT> >::Type
2515 addAssign(
const DenseMatrix<MT,true>& rhs );
2517 template<
typename MT >
inline void addAssign(
const DenseMatrix<MT,false>& rhs );
2518 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,true>& rhs );
2519 template<
typename MT >
inline void addAssign(
const SparseMatrix<MT,false>& rhs );
2521 template<
typename MT >
2522 inline typename DisableIf< VectorizedSubAssign<MT> >::Type
2523 subAssign (
const DenseMatrix<MT,true>& rhs );
2525 template<
typename MT >
2526 inline typename EnableIf< VectorizedSubAssign<MT> >::Type
2527 subAssign (
const DenseMatrix<MT,true>& rhs );
2529 template<
typename MT >
inline void subAssign(
const DenseMatrix<MT,false>& rhs );
2530 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,true>& rhs );
2531 template<
typename MT >
inline void subAssign(
const SparseMatrix<MT,false>& rhs );
2539 inline size_t adjustRows(
size_t minRows )
const;
2586 template<
typename Type >
2608 template<
typename Type >
2611 , mm_ ( adjustRows( m ) )
2616 if( IsNumeric<Type>::value ) {
2617 for(
size_t j=0UL; j<
n_; ++j )
2618 for(
size_t i=
m_; i<mm_; ++i ) {
2619 v_[i+j*mm_] = Type();
2637 template<
typename Type >
2640 , mm_ ( adjustRows( m ) )
2645 for(
size_t j=0UL; j<
n_; ++j ) {
2646 for(
size_t i=0UL; i<
m_; ++i )
2649 if( IsNumeric<Type>::value ) {
2650 for(
size_t i=m_; i<mm_; ++i )
2651 v_[i+j*mm_] = Type();
2683 template<
typename Type >
2684 template<
typename Other >
2687 , mm_ ( adjustRows( m ) )
2692 for(
size_t j=0UL; j<n; ++j ) {
2693 for(
size_t i=0UL; i<m; ++i )
2694 v_[i+j*mm_] = array[i+j*m];
2696 if( IsNumeric<Type>::value ) {
2697 for(
size_t i=m; i<mm_; ++i )
2698 v_[i+j*mm_] = Type();
2728 template<
typename Type >
2729 template<
typename Other
2734 , mm_ ( adjustRows( M ) )
2739 for(
size_t j=0UL; j<N; ++j ) {
2740 for(
size_t i=0UL; i<M; ++i )
2741 v_[i+j*mm_] = array[i][j];
2743 if( IsNumeric<Type>::value ) {
2744 for(
size_t i=M; i<mm_; ++i )
2745 v_[i+j*mm_] = Type();
2762 template<
typename Type >
2785 template<
typename Type >
2786 template<
typename MT
2789 : m_ ( (~m).
rows() )
2790 , mm_ ( adjustRows( m_ ) )
2797 if( IsNumeric<Type>::value ) {
2798 for(
size_t j=0UL; j<
n_; ++j )
2799 for(
size_t i=( IsSparseMatrix<MT>::value )?( 0UL ):( m_ ); i<mm_; ++i ) {
2800 v_[i+j*mm_] = Type();
2804 assign( *
this, ~m );
2822 template<
typename Type >
2847 template<
typename Type >
2867 template<
typename Type >
2889 template<
typename Type >
2908 template<
typename Type >
2926 template<
typename Type >
2945 template<
typename Type >
2962 template<
typename Type >
2980 template<
typename Type >
2998 template<
typename Type >
3016 template<
typename Type >
3021 return Iterator( v_ + j*mm_ + m_ );
3034 template<
typename Type >
3052 template<
typename Type >
3093 template<
typename Type >
3094 template<
typename Other
3097 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Other (&array)[M][N] )
3099 resize( M, N,
false );
3101 for(
size_t j=0UL; j<N; ++j )
3102 for(
size_t i=0UL; i<M; ++i )
3103 v_[i+j*mm_] = array[i][j];
3118 template<
typename Type >
3119 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=( Type rhs )
3121 for(
size_t j=0UL; j<
n_; ++j )
3122 for(
size_t i=0UL; i<
m_; ++i )
3141 template<
typename Type >
3142 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const DynamicMatrix& rhs )
3144 if( &rhs ==
this )
return *
this;
3146 resize( rhs.m_, rhs.n_,
false );
3148 for(
size_t j=0UL; j<
n_; ++j )
3149 for(
size_t i=0UL; i<
m_; ++i )
3150 v_[i+j*mm_] = rhs(i,j);
3168 template<
typename Type >
3169 template<
typename MT
3171 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator=(
const Matrix<MT,SO>& rhs )
3175 if( (~rhs).canAlias(
this ) ) {
3176 DynamicMatrix tmp( ~rhs );
3181 if( IsSparseMatrix<MT>::value )
3203 template<
typename Type >
3204 template<
typename MT
3206 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator+=(
const Matrix<MT,SO>& rhs )
3210 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3211 throw std::invalid_argument(
"Matrix sizes do not match" );
3213 if( (~rhs).canAlias(
this ) ) {
3238 template<
typename Type >
3239 template<
typename MT
3241 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator-=(
const Matrix<MT,SO>& rhs )
3245 if( (~rhs).
rows() != m_ || (~rhs).
columns() != n_ )
3246 throw std::invalid_argument(
"Matrix sizes do not match" );
3248 if( (~rhs).canAlias(
this ) ) {
3273 template<
typename Type >
3274 template<
typename MT
3276 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::operator*=(
const Matrix<MT,SO>& rhs )
3278 if( (~rhs).
rows() != n_ )
3279 throw std::invalid_argument(
"Matrix sizes do not match" );
3281 DynamicMatrix tmp( *
this * (~rhs) );
3298 template<
typename Type >
3299 template<
typename Other >
3300 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3301 DynamicMatrix<Type,true>::operator*=( Other rhs )
3305 assign( *
this, (*
this) * rhs );
3320 template<
typename Type >
3321 template<
typename Other >
3322 inline typename EnableIf< IsNumeric<Other>, DynamicMatrix<Type,true> >::Type&
3323 DynamicMatrix<Type,true>::operator/=( Other rhs )
3329 assign( *
this, (*
this) / rhs );
3350 template<
typename Type >
3365 template<
typename Type >
3383 template<
typename Type >
3398 template<
typename Type >
3414 template<
typename Type >
3431 template<
typename Type >
3434 size_t nonzeros( 0UL );
3436 for(
size_t j=0UL; j<
n_; ++j )
3437 for(
size_t i=0UL; i<
m_; ++i )
3454 template<
typename Type >
3459 const size_t iend( (j+1UL)*mm_ );
3460 size_t nonzeros( 0UL );
3462 for(
size_t i=j*mm_; i<iend; ++i )
3478 template<
typename Type >
3483 for(
size_t j=0UL; j<
n_; ++j )
3484 for(
size_t i=0UL; i<
m_; ++i )
3485 reset( v_[i+j*mm_] );
3501 template<
typename Type >
3507 for(
size_t i=0UL; i<
m_; ++i )
3508 reset( v_[i+j*mm_] );
3522 template<
typename Type >
3525 resize( 0UL, 0UL,
false );
3565 template<
typename Type >
3570 if( m == m_ && n == n_ )
return;
3572 const size_t mm( adjustRows( m ) );
3577 const size_t min_m( min( m, m_ ) );
3578 const size_t min_n( min( n, n_ ) );
3580 for(
size_t j=0UL; j<min_n; ++j )
3581 for(
size_t i=0UL; i<min_m; ++i )
3582 v[i+j*mm] = v_[i+j*mm_];
3595 if( IsNumeric<Type>::value ) {
3596 for(
size_t j=0UL; j<n; ++j )
3597 for(
size_t i=m; i<mm; ++i )
3598 v_[i+j*mm] = Type();
3624 template<
typename Type >
3627 resize( m_+m, n_+n, preserve );
3643 template<
typename Type >
3654 if( IsNumeric<Type>::value ) {
3655 for(
size_t i=
capacity_; i<elements; ++i )
3675 template<
typename Type >
3678 DynamicMatrix tmp(
trans(*
this) );
3693 template<
typename Type >
3694 template<
typename Other >
3695 inline DynamicMatrix<Type,true>& DynamicMatrix<Type,true>::scale( Other scalar )
3697 for(
size_t j=0UL; j<
n_; ++j )
3698 for(
size_t i=0UL; i<
m_; ++i )
3699 v_[i+j*mm_] *= scalar;
3715 template<
typename Type >
3735 template<
typename Type >
3736 inline size_t DynamicMatrix<Type,true>::adjustRows(
size_t minRows )
const
3738 if( IsNumeric<Type>::value )
3739 return minRows + ( IT::size - ( minRows % IT::size ) ) % IT::size;
3740 else return minRows;
3765 template<
typename Type >
3766 template<
typename Other >
3769 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3786 template<
typename Type >
3787 template<
typename Other >
3790 return static_cast<const void*
>( this ) == static_cast<const void*>( alias );
3811 template<
typename Type >
3812 inline typename DynamicMatrix<Type,true>::IntrinsicType
3824 return load( v_+i+j*mm_ );
3845 template<
typename Type >
3846 inline typename DynamicMatrix<Type,true>::IntrinsicType
3857 return loadu( v_+i+j*mm_ );
3879 template<
typename Type >
3891 store( v_+i+j*mm_, value );
3913 template<
typename Type >
3924 storeu( v_+i+j*mm_, value );
3947 template<
typename Type >
3959 stream( v_+i+j*mm_, value );
3977 template<
typename Type >
3978 template<
typename MT >
3979 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
3985 const size_t iend( m_ &
size_t(-2) );
3988 for(
size_t j=0UL; j<
n_; ++j ) {
3989 for(
size_t i=0UL; i<iend; i+=2UL ) {
3990 v_[i +j*mm_] = (~rhs)(i ,j);
3991 v_[i+1UL+j*mm_] = (~rhs)(i+1UL,j);
3994 v_[iend+j*mm_] = (~rhs)(iend,j);
4014 template<
typename Type >
4015 template<
typename MT >
4016 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAssign<MT> >::Type
4029 for(
size_t j=0UL; j<
n_; ++j )
4030 for(
size_t i=0UL; i<
m_; i+=IT::size )
4035 const size_t iend( m_ &
size_t(-IT::size*4) );
4038 for(
size_t j=0UL; j<
n_; ++j ) {
4040 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4041 store( v_+i+j*mm_ , it.load() ); it += IT::size;
4042 store( v_+i+j*mm_+IT::size , it.load() ); it += IT::size;
4043 store( v_+i+j*mm_+IT::size*2UL, it.load() ); it += IT::size;
4044 store( v_+i+j*mm_+IT::size*3UL, it.load() ); it += IT::size;
4046 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4047 store( v_+i+j*mm_, it.load() );
4068 template<
typename Type >
4069 template<
typename MT >
4075 const size_t block( 16UL );
4077 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4078 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4079 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4080 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4081 for(
size_t j=jj; j<jend; ++j ) {
4082 for(
size_t i=ii; i<iend; ++i ) {
4083 v_[i+j*mm_] = (~rhs)(i,j);
4105 template<
typename Type >
4106 template<
typename MT >
4109 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4110 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4111 v_[element->index()+j*mm_] = element->value();
4129 template<
typename Type >
4130 template<
typename MT >
4133 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4134 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4135 v_[i+element->index()*mm_] = element->value();
4153 template<
typename Type >
4154 template<
typename MT >
4155 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4161 const size_t iend( m_ &
size_t(-2) );
4164 for(
size_t j=0UL; j<
n_; ++j ) {
4165 for(
size_t i=0UL; i<iend; i+=2UL ) {
4166 v_[i +j*mm_] += (~rhs)(i ,j);
4167 v_[i+1UL+j*mm_] += (~rhs)(i+1UL,j);
4170 v_[iend+j*mm_] += (~rhs)(iend,j);
4190 template<
typename Type >
4191 template<
typename MT >
4192 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedAddAssign<MT> >::Type
4203 const size_t iend( m_ &
size_t(-IT::size*4) );
4206 for(
size_t j=0UL; j<
n_; ++j ) {
4208 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4209 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) + it.load() ); it += IT::size;
4210 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) + it.load() ); it += IT::size;
4211 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) + it.load() ); it += IT::size;
4212 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) + it.load() ); it += IT::size;
4214 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4215 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) + it.load() );
4235 template<
typename Type >
4236 template<
typename MT >
4242 const size_t block( 16UL );
4244 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4245 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4246 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4247 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4248 for(
size_t j=jj; j<jend; ++j ) {
4249 for(
size_t i=ii; i<iend; ++i ) {
4250 v_[i+j*mm_] += (~rhs)(i,j);
4272 template<
typename Type >
4273 template<
typename MT >
4276 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4277 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4278 v_[element->index()+j*mm_] += element->value();
4296 template<
typename Type >
4297 template<
typename MT >
4300 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4301 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4302 v_[i+element->index()*mm_] += element->value();
4320 template<
typename Type >
4321 template<
typename MT >
4322 inline typename DisableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4328 const size_t iend( m_ &
size_t(-2) );
4331 for(
size_t j=0UL; j<
n_; ++j ) {
4332 for(
size_t i=0UL; i<iend; i+=2UL ) {
4333 v_[i +j*mm_] -= (~rhs)(i ,j);
4334 v_[i+1+j*mm_] -= (~rhs)(i+1,j);
4337 v_[iend+j*mm_] -= (~rhs)(iend,j);
4358 template<
typename Type >
4359 template<
typename MT >
4360 inline typename EnableIf< typename DynamicMatrix<Type,true>::BLAZE_TEMPLATE VectorizedSubAssign<MT> >::Type
4371 const size_t iend( m_ &
size_t(-IT::size*4) );
4374 for(
size_t j=0UL; j<
n_; ++j ) {
4376 for(
size_t i=0UL; i<iend; i+=IT::size*4UL ) {
4377 store( v_+i+j*mm_ ,
load( v_+i+j*mm_ ) - it.load() ); it += IT::size;
4378 store( v_+i+j*mm_+IT::size ,
load( v_+i+j*mm_+IT::size ) - it.load() ); it += IT::size;
4379 store( v_+i+j*mm_+IT::size*2UL,
load( v_+i+j*mm_+IT::size*2UL ) - it.load() ); it += IT::size;
4380 store( v_+i+j*mm_+IT::size*3UL,
load( v_+i+j*mm_+IT::size*3UL ) - it.load() ); it += IT::size;
4382 for(
size_t i=iend; i<
m_; i+=IT::size, it+=IT::size ) {
4383 store( v_+i+j*mm_,
load( v_+i+j*mm_ ) - it.load() );
4403 template<
typename Type >
4404 template<
typename MT >
4407 const size_t block( 16UL );
4409 for(
size_t jj=0UL; jj<
n_; jj+=block ) {
4410 const size_t jend( ( n_<(jj+block) )?( n_ ):( jj+block ) );
4411 for(
size_t ii=0UL; ii<
m_; ii+=block ) {
4412 const size_t iend( ( m_<(ii+block) )?( m_ ):( ii+block ) );
4413 for(
size_t j=jj; j<jend; ++j ) {
4414 for(
size_t i=ii; i<iend; ++i ) {
4415 v_[i+j*mm_] -= (~rhs)(i,j);
4437 template<
typename Type >
4438 template<
typename MT >
4441 for(
size_t j=0UL; j<(~rhs).
columns(); ++j )
4442 for(
typename MT::ConstIterator element=(~rhs).begin(j); element!=(~rhs).end(j); ++element )
4443 v_[element->index()+j*mm_] -= element->value();
4461 template<
typename Type >
4462 template<
typename MT >
4465 for(
size_t i=0UL; i<(~rhs).
rows(); ++i )
4466 for(
typename MT::ConstIterator element=(~rhs).begin(i); element!=(~rhs).end(i); ++element )
4467 v_[i+element->index()*mm_] -= element->value();
4488 template<
typename Type,
bool SO >
4489 inline void reset( DynamicMatrix<Type,SO>& m );
4491 template<
typename Type,
bool SO >
4492 inline void clear( DynamicMatrix<Type,SO>& m );
4494 template<
typename Type,
bool SO >
4495 inline bool isDefault(
const DynamicMatrix<Type,SO>& m );
4497 template<
typename Type,
bool SO >
4498 inline void swap( DynamicMatrix<Type,SO>& a, DynamicMatrix<Type,SO>& b ) ;
4510 template<
typename Type
4526 template<
typename Type
4553 template<
typename Type
4558 for(
size_t i=0UL; i<m.
rows(); ++i )
4559 for(
size_t j=0UL; j<m.
columns(); ++j )
4560 if( !
isDefault( m(i,j) ) )
return false;
4563 for(
size_t j=0UL; j<m.
columns(); ++j )
4564 for(
size_t i=0UL; i<m.
rows(); ++i )
4565 if( !
isDefault( m(i,j) ) )
return false;
4582 template<
typename Type
4601 template<
typename T,
bool SO >
4602 struct IsResizable< DynamicMatrix<T,SO> > :
public TrueType
4608 template<
typename T,
bool SO >
4609 struct IsResizable< const DynamicMatrix<T,SO> > :
public TrueType
4615 template<
typename T,
bool SO >
4616 struct IsResizable< volatile DynamicMatrix<T,SO> > :
public TrueType
4622 template<
typename T,
bool SO >
4623 struct IsResizable< const volatile DynamicMatrix<T,SO> > :
public TrueType
4642 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4643 struct AddTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4645 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4648 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4649 struct AddTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4651 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4654 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4655 struct AddTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4657 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N, SO > Type;
4660 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4661 struct AddTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4663 typedef StaticMatrix< typename AddTrait<T1,T2>::Type, M, N,
false > Type;
4666 template<
typename T1,
bool SO,
typename T2 >
4667 struct AddTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4669 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type , SO > Type;
4672 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4673 struct AddTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4675 typedef DynamicMatrix< typename AddTrait<T1,T2>::Type ,
false > Type;
4691 template<
typename T1,
bool SO,
typename T2,
size_t M,
size_t N >
4692 struct SubTrait< DynamicMatrix<T1,SO>, StaticMatrix<T2,M,N,SO> >
4694 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4697 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4698 struct SubTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4700 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4703 template<
typename T1,
size_t M,
size_t N,
bool SO,
typename T2 >
4704 struct SubTrait< StaticMatrix<T1,M,N,SO>, DynamicMatrix<T2,SO> >
4706 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N, SO > Type;
4709 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4710 struct SubTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4712 typedef StaticMatrix< typename SubTrait<T1,T2>::Type, M, N,
false > Type;
4715 template<
typename T1,
bool SO,
typename T2 >
4716 struct SubTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4718 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type , SO > Type;
4721 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4722 struct SubTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4724 typedef DynamicMatrix< typename SubTrait<T1,T2>::Type ,
false > Type;
4740 template<
typename T1,
bool SO,
typename T2 >
4741 struct MultTrait< DynamicMatrix<T1,SO>, T2 >
4743 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4747 template<
typename T1,
typename T2,
bool SO >
4748 struct MultTrait< T1, DynamicMatrix<T2,SO> >
4750 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO > Type;
4754 template<
typename T1,
bool SO,
typename T2,
size_t N >
4755 struct MultTrait< DynamicMatrix<T1,SO>, StaticVector<T2,N,false> >
4757 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4760 template<
typename T1,
size_t N,
typename T2,
bool SO >
4761 struct MultTrait< StaticVector<T1,N,true>, DynamicMatrix<T2,SO> >
4763 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4766 template<
typename T1,
bool SO,
typename T2,
size_t N >
4767 struct MultTrait< DynamicMatrix<T1,SO>, HybridVector<T2,N,false> >
4769 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4772 template<
typename T1,
size_t N,
typename T2,
bool SO >
4773 struct MultTrait< HybridVector<T1,N,true>, DynamicMatrix<T2,SO> >
4775 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4778 template<
typename T1,
bool SO,
typename T2 >
4779 struct MultTrait< DynamicMatrix<T1,SO>, DynamicVector<T2,false> >
4781 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4784 template<
typename T1,
typename T2,
bool SO >
4785 struct MultTrait< DynamicVector<T1,true>, DynamicMatrix<T2,SO> >
4787 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4790 template<
typename T1,
bool SO,
typename T2 >
4791 struct MultTrait< DynamicMatrix<T1,SO>, CompressedVector<T2,false> >
4793 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
false > Type;
4796 template<
typename T1,
typename T2,
bool SO >
4797 struct MultTrait< CompressedVector<T1,true>, DynamicMatrix<T2,SO> >
4799 typedef DynamicVector< typename MultTrait<T1,T2>::Type,
true > Type;
4802 template<
typename T1,
bool SO1,
typename T2,
size_t M,
size_t N,
bool SO2 >
4803 struct MultTrait< DynamicMatrix<T1,SO1>, StaticMatrix<T2,M,N,SO2> >
4805 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4808 template<
typename T1,
size_t M,
size_t N,
bool SO1,
typename T2,
bool SO2 >
4809 struct MultTrait< StaticMatrix<T1,M,N,SO1>, DynamicMatrix<T2,SO2> >
4811 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4814 template<
typename T1,
bool SO1,
typename T2,
bool SO2 >
4815 struct MultTrait< DynamicMatrix<T1,SO1>, DynamicMatrix<T2,SO2> >
4817 typedef DynamicMatrix< typename MultTrait<T1,T2>::Type, SO1 > Type;
4833 template<
typename T1,
bool SO,
typename T2 >
4834 struct DivTrait< DynamicMatrix<T1,SO>, T2 >
4836 typedef DynamicMatrix< typename DivTrait<T1,T2>::Type , SO > Type;
4853 template<
typename T1,
bool SO,
typename T2 >
4854 struct MathTrait< DynamicMatrix<T1,SO>, DynamicMatrix<T2,SO> >
4856 typedef DynamicMatrix< typename MathTrait<T1,T2>::HighType, SO > HighType;
4857 typedef DynamicMatrix< typename MathTrait<T1,T2>::LowType , SO > LowType;
4873 template<
typename T1,
bool SO >
4874 struct SubmatrixTrait< DynamicMatrix<T1,SO> >
4876 typedef DynamicMatrix<T1,SO> Type;
4892 template<
typename T1,
bool SO >
4893 struct RowTrait< DynamicMatrix<T1,SO> >
4895 typedef DynamicVector<T1,true> Type;
4911 template<
typename T1,
bool SO >
4912 struct ColumnTrait< DynamicMatrix<T1,SO> >
4914 typedef DynamicVector<T1,false> Type;
Compile time check for vectorizable types.Depending on the available instruction set (SSE...
Definition: IsVectorizable.h:107
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:688
size_t n_
The current number of columns of the matrix.
Definition: DynamicMatrix.h:393
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:98
Constraint on the data type.
Header file for mathematical functions.
void reserve(size_t elements)
Setting the minimum capacity of the matrix.
Definition: DynamicMatrix.h:1489
void reset(DynamicMatrix< Type, SO > &m)
Resetting the given dense matrix.
Definition: DynamicMatrix.h:4512
#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 >, 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:846
Header file for the row trait.
Type *BLAZE_RESTRICT v_
The dynamically allocated matrix elements.
Definition: DynamicMatrix.h:396
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:446
void deallocate(T *address)
Deallocation of memory.
Definition: Memory.h:113
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:4555
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the represent...
Definition: CompressedMatrix.h:196
void resize(size_t m, size_t n, bool preserve=true)
Changing the size of the matrix.
Definition: DynamicMatrix.h:1413
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:1213
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:1753
void storeu(float *address, const sse_float_t &value)
Unaligned store of a vector of 'float' values.
Definition: Storeu.h:234
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
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a no...
Definition: MatrixAccessProxy.h:86
DynamicMatrix()
The default constructor for DynamicMatrix.
Definition: DynamicMatrix.h:434
Type relationship analysis.This class tests if the two data types A and B are equal. For this type comparison, the cv-qualifiers of both data types are ignored. If A and B are the same data type (ignoring the cv-qualifiers), then the value member enumeration is set to 1, the nested type definition Type is TrueType, and the class derives from TrueType. Otherwise value is set to 0, Type is FalseType, and the class derives from FalseType.
Definition: IsSame.h:158
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:1232
Efficient implementation of a dynamic matrix.The DynamicMatrix class template is the representation ...
Definition: DynamicMatrix.h:176
void clear(DynamicMatrix< Type, SO > &m)
Clearing the given dense matrix.
Definition: DynamicMatrix.h:4528
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:192
Base class for sparse matrices.The SparseMatrix class is a base class for all sparse matrix classes...
Definition: Forward.h:104
Constraint on the data type.
size_t capacity_
The current capacity of the pointer array.
Definition: CompressedMatrix.h:2513
~DynamicMatrix()
The destructor for DynamicMatrix.
Definition: DynamicMatrix.h:663
This ResultType
Result type for expression template evaluations.
Definition: DynamicMatrix.h:186
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:1282
size_t adjustColumns(size_t minColumns) const
Adjusting the number columns of the matrix according to its data type Type.
Definition: DynamicMatrix.h:1577
void stream(float *address, const sse_float_t &value)
Aligned, non-temporal store of a vector of 'float' values.
Definition: Stream.h:233
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:912
Header file for the multiplication trait.
IntrinsicType loadu(size_t i, size_t j) const
Unaligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1686
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:4541
Type ElementType
Type of the matrix elements.
Definition: DynamicMatrix.h:189
Header file for all forward declarations of the math module.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2379
#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
IntrinsicTrait< Type > IT
Intrinsic trait for the matrix element type.
Definition: DynamicMatrix.h:180
DynamicMatrix< Type, SO > This
Type of this DynamicMatrix instance.
Definition: DynamicMatrix.h:185
Header file for the DenseMatrix base class.
Header file for the DenseIterator class template.
const Type & ReturnType
Return type for expression template evaluations.
Definition: DynamicMatrix.h:191
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:179
Constraint on the data type.
size_t n_
The current number of columns of the sparse matrix.
Definition: CompressedMatrix.h:2512
void extend(size_t m, size_t n, bool preserve=true)
Extending the size of the matrix.
Definition: DynamicMatrix.h:1471
size_t rows() const
Returns the current number of rows of the matrix.
Definition: DynamicMatrix.h:1199
#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:1327
Iterator end(size_t i)
Returns an iterator just past the last element of row/column i.
Definition: DynamicMatrix.h:868
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2377
System settings for streaming (non-temporal stores)
Header file for the EnableIf class template.
T * allocate(size_t size)
Aligned array allocation.
Definition: Memory.h:85
DynamicMatrix< Type,!SO > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: DynamicMatrix.h:187
size_t capacity() const
Returns the maximum capacity of the matrix.
Definition: DynamicMatrix.h:1246
Header file for the equal shim.
Header file for the IsVectorizable type trait.
ColumnIterator< const MT > ConstIterator
Iterator over constant elements.
Definition: DenseColumn.h:1972
Header file for the IsNumeric type trait.
size_t nn_
The alignment adjusted number of columns.
Definition: DynamicMatrix.h:394
void store(size_t i, size_t j, const IntrinsicType &value)
Aligned store of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1719
Intrinsic characteristics of data types.The IntrinsicTrait class template provides the intrinsic char...
Definition: IntrinsicTrait.h:648
Header file for run time assertion macros.
Header file for the addition trait.
void clear()
Clearing the matrix.
Definition: DynamicMatrix.h:1371
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:4584
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:209
Header file for the submatrix trait.
Type * data()
Low-level data access to the matrix elements.
Definition: DynamicMatrix.h:727
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:392
Iterator begin(size_t i)
Returns an iterator to the first element of row/column i.
Definition: DynamicMatrix.h:802
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:1627
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:239
#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:2378
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:85
Constraint on the data type.
void swap(DynamicMatrix &m)
Swapping the contents of two matrices.
Definition: DynamicMatrix.h:1558
IntrinsicType load(size_t i, size_t j) const
Aligned load of an intrinsic element of the matrix.
Definition: DynamicMatrix.h:1652
size_t m_
The current number of rows of the sparse matrix.
Definition: CompressedMatrix.h:2511
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:193
DenseIterator< const Type > ConstIterator
Iterator over constant elements.
Definition: DynamicMatrix.h:196
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:190
size_t capacity_
The maximum capacity of the matrix.
Definition: DynamicMatrix.h:395
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2370
size_t columns(const Matrix< MT, SO > &m)
Returns the current number of columns of the matrix.
Definition: Matrix.h:154
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:195
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2376
const VT::ElementType min(const SparseVector< VT, TF > &sv)
Returns the smallest element of the sparse vector.
Definition: SparseVector.h:348
SelectType< useConst, ConstIterator, ColumnIterator< MT > >::Type Iterator
Iterator over non-constant elements.
Definition: DenseColumn.h:1980
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
Header file for the IsResizable type trait.
size_t rows(const Matrix< MT, SO > &m)
Returns the current number of rows of the matrix.
Definition: Matrix.h:138
#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:1607
DynamicMatrix & transpose()
Transposing the matrix.
Definition: DynamicMatrix.h:1520
const Type & ConstReference
Reference to a constant matrix value.
Definition: DynamicMatrix.h:194
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:188
void store(float *address, const sse_float_t &value)
Aligned store of a vector of 'float' values.
Definition: Store.h:242
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:1786